noise-protocol-stream
Node stream wrapper for Noise Protocol C implementation compiled to WebAssembly.
npm install noise-protocol-stream
Usage
The constructor returns a stream pair for encrypting outgoing and decrypting incoming data. Both streams need to be connected for the initial noise handshake to succeed. After the handshake is complete writing to the encrypt stream will output the encrypted the data and reading from the decrypt stream returns the decrypted data (note that it's not possible to connect the same encrypt and decrypt pair directly).
var net = var noise = var socket = netvar client = clientencrypt clientdecrypt clientencrypt
The Noise_XX_25519_AESGCM_SHA256
handshake pattern is used to establish a secure connection, it supports mutual authentication and transmission of static public keys. If no key is specified in the constructor a new one will be created.
Constructor options:
initiator: true // Protocol initiator or responder. prologue: Buffer // Data that both parties want to confirm is identical. privateKey: Buffer // Static private key. Public key is computed from it. {} // Verify remote public key before any actual communication.
The verify
function is called with the local key pair, the received remote public key and a callback function wich must be called to either accept or terminate the connection. If no verify
function is provided the default is to accept any connection.
var net = var noise = var TRUSTED_PUBLIC_KEY = Buffer net
See the Noise protocol specifications for more details.