Skip to content
This repository has been archived by the owner on Jun 3, 2020. It is now read-only.

Commit

Permalink
Switch from sha256 to blake2b for peersocket topic hashing
Browse files Browse the repository at this point in the history
  • Loading branch information
pfrazee committed Oct 4, 2018
1 parent 131876f commit 830f8c3
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 5 deletions.
9 changes: 4 additions & 5 deletions hyperswarm/peersocket.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ const crypto = require('crypto')
const createSwarm = require('@hyperswarm/network')
const lpstream = require('length-prefixed-stream')
const pump = require('pump')
const sodium = require('sodium')
const schemas = require('./peersocket-schemas')
const {extractOrigin} = require('../../../lib/strings')

Expand Down Expand Up @@ -116,12 +117,10 @@ function decodeMsg (msg) {
// internal methods
// =

function sha256 (str) {
return crypto.createHash('sha256').update(str).digest()
}

function createLobbyTopic (lobbyType, lobbyName) {
return sha256(`peersocket-${lobbyType}-${lobbyName}`)
var out = Buffer.allocUnsafe(32)
sodium.crypto_generichash(out, Buffer.from(`peersocket-${lobbyType}-${lobbyName}`, 'utf8'))
return out
}

function getSwarmId (sender, tabIdentity) {
Expand Down
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,7 @@
"scoped-fs": "^1.2.0",
"slugify": "^1.3.1",
"sodium-signatures": "^2.1.1",
"sodium-universal": "^2.0.0",
"split2": "^2.2.0",
"sqlite3": "^4.0.1",
"stream-throttle": "^0.1.3",
Expand Down

0 comments on commit 830f8c3

Please sign in to comment.