bittorrent-dht-store-keypair
Setting up elliptic curve keys and signing properly for BEP44 can be tricky, especially since bittorrent uses the more obscure supercop/ref10 instead of sodium/nacl ed25519 key formatting.
example
quick example
var KP =var DHT =var dht = verify: KPverifyvar kp =var value = 'beep boop'dht
save and load a key from a file
var KP =var kp =console
$ node generate.js > keypair.json
var KP =var DHT =var path =var concat =var dht = verify: KPverifyvar kp =dht
$ echo wow cool | node put.js keypair.json
api
var KP =
var kp = KP(opts)
opts.publicKey
- createkp
with a buffer or hex string public keyopts.secretKey
- createkp
with a buffer or hex string private keyopts.seq
- sequence to start at inkp.store()
var signature = kp.sign(value)
Sign a buffer or string value
with the private key.
var putOpts = kp.store(value, opts)
Create the putOpts
for a value
to pass into bittorrent-dht's put()
function.
kp.seq
is incremented here unless opts.seq
is provided.
kp.publicKey
public key (32 bytes)
kp.secretKey
private key (64 bytes)
kp.id
sha1 hash of the kp.publicKey
kp.seq
sequence number
KP.verify
The underlying ed25519-supercop verify function.
This is handy to pass into the bittorrent-dht constructor as the verify
parameter:
var DHT =var KP =var dht = verify: KPverify
install
npm install bittorrent-dht-store-keypair
license
MIT