rendezvous-point
Rendezvous points on the DHT where two authenticated peers can leave data
Last updated 2 years ago by emilbayes .
ISC · Repository · Bugs · Original npm · Tarball · package.json
$ cnpm install rendezvous-point 
SYNC missed versions from official npm registry.

rendezvous-point

Build Status

Rendezvous points on the DHT where two authenticated peers can leave data

Data could be eg. a ip:port pair

Usage

var rendezvous = require('rendezvous-point')

var keypairA = {publicKey: Buffer.from('...'), secretKey: Buffer.from('...')}
var peerA = rendezvous(dht, keypairA)

var keypairB = {publicKey: Buffer.from('...'), secretKey: Buffer.from('...')}
var peerB = rendezvous(dht, keypairB)

// Leave a message for peerB on the DHT
peerA.write(keypairB.publicKey, Buffer.from('Hello B!'), function (err) {
  if (err) throw err

  peerB.read(keypairA.publicKey, function (err, message) {
    if (err) throw err

    console.log(message.equal(Buffer.from('Hello B!')))
  })
})

API

var peer = rendezvous(dht, keypair)

Create a rendezvous instance for bittorrent-dht instance and a given libsodium X25519 key pair, eg. generated with crypto_kx_keypair

peer.write(recepientPublicKey, buf, cb)

Write a message buf at the rendezvous point between keypair and recepientPublicKey, calling cb(err, hash) with any error or the resulting hash key in the DHT.

peer.read(senderPublicKey, cb)

Read any message at the rendezvous point between keypair and senderPublicKey, calling cb(err, messageObj) with any error or the message left in the DHT with the DHT result object

Design

The rendezvous point is a public key generated from a seed, where the seed is the shared secret from a Diffie-Hellman key exchange between two peers. This means that either side can leave messages in the DHT at the rendezvous point, because both can generate the same key pair. The rendezvous point can therefore be seen as a shared mailbox between the two peers. A future extension may be to leave messages encrypted to the other party, so messages are only readable by the other party and no one else who happens upon the rendezvous point (eg. an adverse DHT node).

Install

npm install rendezvous-point

License

ISC

Current Tags

  • 2.0.0                                ...           latest (2 years ago)

2 Versions

  • 2.0.0                                ...           2 years ago
  • 1.0.2                                ...           2 years ago
Maintainers (1)
Downloads
Today 0
This Week 0
This Month 0
Last Day 0
Last Week 0
Last Month 0
Dependencies (2)
Dev Dependencies (1)
Dependents (0)
None

Copyright 2014 - 2016 © taobao.org |