hyperdht-hugin
v1.0.3
Published
The DHT powering Hyperswarm for Hugin.
Readme
hyperdht-hugin
A fork of hyperdht with added connection signature verification for Hugin Messenger.
npm install hyperdht-huginWhat's different?
This fork adds a signature verification layer to DHT connections:
sig- A signature proving ownership of shared group keysdht_keys- DHT keypair for connectionskeychain- Shared keychain for signature verification
This prevents unauthorized connections even if topics are leaked.
Usage
import DHT from 'hyperdht-hugin'
// Create DHT with signature verification
const node = new DHT({
bootstrap: ['host:port']
}, sig, dht_keys, keychain)Server
const server = node.createServer()
server.on('connection', function (socket) {
console.log('Remote public key', socket.remotePublicKey)
process.stdin.pipe(socket).pipe(process.stdout)
})
const keyPair = DHT.keyPair()
await server.listen(keyPair)Client
const socket = node.connect(publicKey)
socket.on('open', function () {
// socket fully open with the other peer
})
process.stdin.pipe(socket).pipe(process.stdout)API
The API is identical to hyperdht with the extended constructor:
new DHT(options, sig, dht_keys, keychain)| Parameter | Description |
|-----------|-------------|
| options | Standard hyperdht options (bootstrap, keyPair, etc.) |
| sig | Signature proving group membership |
| dht_keys | Keychain providing DHT keypair via .get() |
| keychain | Keychain for verifying signatures via .verify() |
For full API documentation, see the original hyperdht docs.
Credits
Based on hyperdht by Holepunch (MIT License).
License
MIT
