Crate libp2p_noise

source ·
Expand description

Noise protocol framework support for libp2p.

Note: This crate is still experimental and subject to major breaking changes both on the API and the wire protocol.

This crate provides libp2p_core::InboundUpgrade and libp2p_core::OutboundUpgrade implementations for various noise handshake patterns (currently IK, IX, and XX) over a particular choice of Diffie–Hellman key agreement (currently only X25519).

Note: Only the XX handshake pattern is currently guaranteed to provide interoperability with other libp2p implementations.

All upgrades produce as output a pair, consisting of the remote’s static public key and a NoiseOutput which represents the established cryptographic session with the remote, implementing futures::io::AsyncRead and futures::io::AsyncWrite.



use libp2p_core::{identity, Transport, upgrade};
use libp2p::tcp::TcpTransport;
use libp2p::noise::{Keypair, X25519Spec, NoiseAuthenticated};

let id_keys = identity::Keypair::generate_ed25519();
let noise = NoiseAuthenticated::xx(&id_keys).unwrap();
let builder = TcpTransport::default().upgrade(upgrade::Version::V1).authenticate(noise);
// let transport = builder.multiplex(...);


A DH keypair that is authentic w.r.t. a identity::PublicKey.
DH keypair.
The associated public identity of a DH keypair.
Legacy configuration options.
A NoiseAuthenticated transport upgrade that wraps around any NoiseConfig handshake and verifies that the remote identified with a RemoteIdentity::IdentityKey, aborting otherwise.
The protocol upgrade configuration.
A noise session to a remote.
The parameters of a Noise protocol, consisting of a choice for a handshake pattern as well as DH, cipher and hash functions.
DH public key.
DH secret key.
A X25519 key.
A X25519 key.


Type tag for the IK handshake pattern.
Type tag for the IX handshake pattern.
libp2p_noise error type.
The identity of the remote established during a handshake.
Type tag for the XX handshake pattern.


A Noise protocol over DH keys of type C. The choice of C determines the protocol parameters for each handshake pattern.