Expand description
§nivalis
A typestate-driven, pure-Rust implementation of the Noise Protocol Framework (revision 34).
§Overview
Nivalis uses Rust’s type system to enforce the Noise handshake state machine at compile time, making it impossible to call handshake methods out of order or reuse a completed session.
§Quick start
The following example shows you how to create the builders for the IK pattern:
use nivalis::{
builder::NewBuilder,
crypto::{cipher::chacha20::ChaChaPoly, dh::{DH, DHKeypair, x25519::X25519dh}, hash::blake2s::Blake2s},
patterns::{IK, roles::{Initiator, Responder}},
};
use rand::rng;
let mut rng = rng();
let init_static = X25519dh::generate_keypair(&mut rng);
let resp_static = X25519dh::generate_keypair(&mut rng);
let initiator = NewBuilder::<IK, Initiator, X25519dh, ChaChaPoly, Blake2s>::new()
.local_static_key(init_static.private().to_owned())
.remote_static_key(resp_static.public())
.build()
.expect("failed to build initiator handshake state");
let responder = NewBuilder::<IK, Responder, X25519dh, ChaChaPoly, Blake2s>::new()
.local_static_key(resp_static.private().to_owned())
.build()
.expect("failed to build responder handshake state");
// ...§Modules
Modules§
- builder
- Typestate builder for the Noise handshake
- crypto
- Cryptographic primitives used by the Noise handshake (AEAD ciphers, DH and hash functions)
- error
- Types used by other modules
- patterns
- Noise patterns presented on NoiseExplorer https://noiseexplorer.com/patterns/
- state
- The state objects driving the Noise handshake and transport phases:
CipherState,SymmetricState,HandshakeState, andTransportState. - types
- Types used by other modules