libp2p
    Preparing search index...

    Module index

    This repository contains TypeScript implementation of noise protocol, an encryption protocol used in libp2p.

    Formerly published as @chainsafe/libp2p-noise.

    Install with npm i @libp2p/noise.

    Example of using default noise configuration and passing it to the libp2p config:

    import { createLibp2p } from 'libp2p'
    import { noise } from '@libp2p/noise'

    const libp2p = await createLibp2p({
    connectionEncrypters: [noise()],
    // ... other options
    })

    See the NoiseInit interface for noise configuration options.

    To use a fixed x25519 static key instead of generating one per session, pass it as staticNoiseKey:

    import { createLibp2p } from 'libp2p'
    import { noise, pureJsCrypto } from '@libp2p/noise'

    const staticNoiseKey = pureJsCrypto.generateX25519KeyPair().privateKey

    const node = await createLibp2p({
    connectionEncrypters: [noise({ staticNoiseKey })]
    })

    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.

    The implementation must conform to the ICryptoInterface, defined in https://github.com/libp2p/js-libp2p/blob/main/packages/connection-encrypter-noise/src/crypto.ts

    ICryptoInterface
    KeyPair
    NoiseComponents
    NoiseExtensions
    NoiseInit
    pureJsCrypto
    noise