/webrtc-explorer-peer-id

DHT circular IDs generator and methods

Primary LanguageJavaScriptMIT LicenseMIT

webrtc-explorer-peer-id

Peer Id generator and operator, designed with circular Id namespaces in mind, used in webrtc-explorer. Currently only supports 48 bits, but I'm happy to make accept PR that make it Id size agnostic.

Project Information

David Dias MSc in Peer-to-Peer Networks by Technical University of Lisbon

This work was developed by David Dias with supervision by Luís Veiga, all in INESC-ID Lisboa (Distributed Systems Group), Instituto Superior Técnico, Universidade de Lisboa, with the support of Fundação para a Ciência e Tecnologia.

More info on the team's work at:

If you use this project, please acknowledge it in your work by referencing the following document:

David Dias and Luís Veiga. browserCloud.js A federated community cloud served by a P2P overlay network on top of the web platform. INESC-ID Tec. Rep. 14/2015, Apr. 2015

Badgers

NPM Dependency Status Build Status

Properties

  • Uses sha1 to guarantee that ID's are generated with an uniform distribution
  • Runs in Node.js and in the browser
  • Respects the natural circular ID namespace DHT are known to use (meaning that there is no ID higher than 48 bits)

How to use

var Id = require('dht-id');

var idA = new Id(); // generates a new random Id with 48 bits length

var idB = new Id(<value to generate the Id from>); // generates an Id based on the value, same value always generates same Id

idA.toHex(); // returns the hex value of the Id in a string

idA.toDec(); // returns the dec value of the Id in a number

idA.next(); // basically this id + 1, useful to send to Sucessor

Id.hash(content); // convinient way to find the Id of a content and guarantee that it has our ideal id length