bittorrent-dht-sodium
Sodium wrapper for working with BEP44 on bittorrent-dht
Last updated 8 months ago by emilbayes .
ISC · Repository · Bugs · Original npm · Tarball · package.json
$ cnpm install bittorrent-dht-sodium 
SYNC missed versions from official npm registry.

bittorrent-dht-sodium

Build Status

Sodium wrapper for working with BEP44 on bittorrent-dht

Usage

var eddsa = require('bittorrent-dht-sodium')
const DHT = require('bittorrent-dht')
const dht = new DHT({
  verify: eddsa.verify
})

const keys = eddsa.keygen()

dht.put({
  v: Buffer.from('Hello world'),
  k: keys.pk,
  seq: 0,
  sign: (msg) => {
    return eddsa.sign(msg, keys.sk)
  }
}, function (err, hash) {
  // ...
})

API

const { pk, sk } = eddsa.keygen([sk])

Derive a Ed25519 keypair, optionally deriving the pk from an exisiting sk. Returns pk as Public Key, sk as Secret Key. The sk here is not compatible with ed25519-supercop, as the encoding is different, but signatures will be the same.

const sig = eddsa.sign(msg, sk)

Sign Buffer msg with sk returning the signature as a Buffer

const valid = eddsa.verify(sig, msg, pk)

Verify Buffer sig against Buffer msg with pk returning boolean whether valid or not.

const salt = eddsa.salt()

Generate a 64 byte random salt. This is equal to the block size of SHA-1, the hash function used by the DHT.

Install

npm install bittorrent-dht-sodium

License

ISC

Current Tags

  • 1.2.0                                ...           latest (8 months ago)

4 Versions

  • 1.2.0                                ...           8 months ago
  • 1.1.0                                ...           8 months ago
  • 1.0.1                                ...           8 months ago
  • 1.0.0                                ...           8 months ago
Maintainers (1)
Downloads
Today 0
This Week 1
This Month 1
Last Day 0
Last Week 0
Last Month 0
Dependencies (1)
Dev Dependencies (2)
Dependents (0)
None

Copyright 2014 - 2016 © taobao.org |