1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
//! # nivalis
//!
//! A typestate-driven, pure-Rust implementation of the [Noise Protocol
//! Framework](https://noiseprotocol.org/noise.html) (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:
//! ```rust
//! 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
//!
//! - [`builder`] — typestate builder for the Noise handshake
//! - [`crypto`] — cryptographic primitives (AEAD, hashing, DH)
//! - [`patterns`] — the standard Noise patterns (NN, XX, IK, etc.)
//! - [`state`] — handshake/session state types
//! - [`error`] / [`types`] — shared error and data types