hypercore-protocol/p2p-multiwriter-with-autobase

node_modules/@hyperswarm/dht/lib/connect.js:374 : sodium.crypto_generichash(out, data) TypeError: in must be an instance of TypedArray

raphael10-collab opened this issue · 2 comments

I get this error :

(base) raphy@pc:~/hypercore/p2p-multiwriter-with-autobase/solutions/01$ node client.js 
/home/raphy/hypercore/p2p-multiwriter-with-autobase/solutions/01/node_modules/@hyperswarm/dht/lib/connect.js:374
  sodium.crypto_generichash(out, data)
         ^

TypeError: in must be an instance of TypedArray
    at hash (/home/raphy/hypercore/p2p-multiwriter-with-autobase/solutions/01/node_modules/@hyperswarm/dht/lib/connect.js:374:10)
    at connect (/home/raphy/hypercore/p2p-multiwriter-with-autobase/solutions/01/node_modules/@hyperswarm/dht/lib/connect.js:19:13)
    at HyperDHT.connect (/home/raphy/hypercore/p2p-multiwriter-with-autobase/solutions/01/node_modules/@hyperswarm/dht/index.js:46:12)
    at file:///home/raphy/hypercore/p2p-multiwriter-with-autobase/solutions/01/client.js:7:30
    at ModuleJob.run (internal/modules/esm/module_job.js:152:23)
    at async Loader.import (internal/modules/esm/loader.js:166:24)
    at async Object.loadESM (internal/process/esm_loader.js:68:5)


(base) raphy@pc:~/hypercore/p2p-multiwriter-with-autobase/solutions/01$ node server.js 
Connect to:
53d3d0874347e444280f569d9b39e42cbe765d899fbf0f3f055027a26e91c28e

with client.js :

import DHT from '@hyperswarm/dht'

const node = new DHT()

const remotePublicKey = Buffer.from('hex-from-above', 'hex')
const encryptedSocket = node.connect('53d3d0874347e444280f569d9b39e42cbe765d899fbf0f3f055027a26e91c28e')

encryptedSocket.on('open', function () {
  console.log('Connected to server')
})

encryptedSocket.on('data', function (data) {
  console.log('Remote said:', data.toString())
})

server.js :

import DHT from '@hyperswarm/dht'

// Make a Hyperswarm DHT node that connects to the global network.
const node = new DHT()

const server = node.createServer(function (encryptedSocket) {
  // Called when a new connection arrives.
  console.log('New connection from', encryptedSocket.remotePublicKey.toString('hex'))
  encryptedSocket.write('Hello world!')
  encryptedSocket.end()
})

const keyPair = DHT.keyPair()
await server.listen(keyPair)

// Server is now listening.
console.log('Connect to:')
console.log(keyPair.publicKey.toString('hex'))

Why did you close this?

Because it was due to my error.