[Error: key] When creating feed
YerkoPalma opened this issue ยท comments
Hi ๐
I'm trying to run some minimal code with hypercore, but I can't make it start.
This fails at hypercore inmediatly, this is the relevant code
const hypercore = require('hypercore')
const key = process.argv[2] || 'global'
const feed = hypercore('./.data', key, { valueEncoding: 'utf-8' })
This throws the following error
$ node hypercore/minimal/index.js
C:\CLC\VIDA\Web\Comun\ypalma\hypercore-playground\node_modules\hypercore-crypto\index.js:133
sodium.crypto_generichash(digest, HYPERCORE, publicKey)
^
Error: key
at Object.exports.discoveryKey (C:\CLC\VIDA\Web\Comun\ypalma\hypercore-playground\node_modules\hypercore-crypto\index.js:133:10)
at new Feed (C:\CLC\VIDA\Web\Comun\ypalma\hypercore-playground\node_modules\hypercore\index.js:79:42)
at Feed (C:\CLC\VIDA\Web\Comun\ypalma\hypercore-playground\node_modules\hypercore\index.js:52:39)
at Object.<anonymous> (C:\CLC\VIDA\Web\Comun\ypalma\hypercore-playground\hypercore\minimal\index.js:7:14)
at Module._compile (internal/modules/cjs/loader.js:1151:30)
at Object.Module._extensions..js (internal/modules/cjs/loader.js:1171:10)
at Module.load (internal/modules/cjs/loader.js:1000:32)
at Function.Module._load (internal/modules/cjs/loader.js:899:14)
at Function.executeUserEntryPoint [as runMain] (internal/modules/run_main.js:71:12)
at internal/main/run_main_module.js:17:47
As you can see the erro doesn't say much, so I'm stuck. Am I doing something wrong?
Any help would be appreciated.
That's a very goofy error message, but try parsing the key into a buffer
const key = Buffer.from(process.argv[2] || 'global', 'base64')
I'm unsure whether the 'global'
value would work - AFAIK it needs to be an 8-byte public key
EDIT: 8-byte sounds wrong. It's too late in the day, I can't remember how many bytes it is
Thanks, that worked! That length requirement is documented somewhere? I think it should.
closing this :)
It has to be a 32 byte public key buffer. Iโll make the assert a bit more sane