holepunchto / hyperdht

The DHT powering Hyperswarm
https://docs.holepunch.to
MIT License
323 stars 46 forks source link

noise wrap passes optional curve to noise handshake async recv #87

Closed rafapaezbas closed 4 months ago

rafapaezbas commented 2 years ago

The noise handshake used in peers connection could use a custom Diffie-Hellman implementation. The Noisewarp constructor would benefit from passing the curve to the NoiseHandshake constructor making it more flexible. Besides, the implementation could be asynchronous so the receive method must await in order to decode the received buffer.

See this example:

const createHandshake = (keyPair, remotePublicKey) => {
    const curve = {
          dh: async (pk, seck) => customDH(pk, seck),
      PKLEN: 32,
          ALG: 'Ed25519',
          name: 'Ed25519',
      generateKeyPair
    }
    return new NoiseWrap(keyPair, remotePublicKey, { curve })
}

const node = new DHT()
const server = node.createServer({ createHandshake })
mafintosh commented 4 months ago

dont think this is relevant anymore, if it is please reopen