This repository contains TypeScript implementation of noise protocol, an encryption protocol used in libp2p.
Install with yarn add @chainsafe/libp2p-noise or npm i @chainsafe/libp2p-noise.
yarn add @chainsafe/libp2p-noise
npm i @chainsafe/libp2p-noise
Example of using default noise configuration and passing it to the libp2p config:
import {createLibp2p} from "libp2p"import {noise} from "@chainsafe/libp2p-noise"//custom noise configuration, pass it instead of `noise()`//x25519 private keyconst n = noise({ staticNoiseKey });const libp2p = await createLibp2p({ connectionEncrypters: [noise()], //... other options}) Copy
import {createLibp2p} from "libp2p"import {noise} from "@chainsafe/libp2p-noise"//custom noise configuration, pass it instead of `noise()`//x25519 private keyconst n = noise({ staticNoiseKey });const libp2p = await createLibp2p({ connectionEncrypters: [noise()], //... other options})
See the NoiseInit interface for noise configuration options.
This module exposes an implementation of the ConnectionEncrypter interface.
You can provide a custom crypto implementation (instead of the default, based on @noble) by adding a crypto field to the init argument passed to the Noise factory.
crypto
Noise
The implementation must conform to the ICryptoInterface, defined in https://github.com/ChainSafe/js-libp2p-noise/blob/master/src/crypto.ts
ICryptoInterface
This repository contains TypeScript implementation of noise protocol, an encryption protocol used in libp2p.
Usage
Install with
yarn add @chainsafe/libp2p-noise
ornpm i @chainsafe/libp2p-noise
.Example of using default noise configuration and passing it to the libp2p config:
See the NoiseInit interface for noise configuration options.
API
This module exposes an implementation of the ConnectionEncrypter interface.
Bring your own crypto
You can provide a custom crypto implementation (instead of the default, based on @noble) by adding a
crypto
field to the init argument passed to theNoise
factory.The implementation must conform to the
ICryptoInterface
, defined in https://github.com/ChainSafe/js-libp2p-noise/blob/master/src/crypto.ts