hopr_crypto_sphinx/
lib.rs

1//! This Rust crate contains implementation of the Sphinx packet format for the HOPR protocol.
2//!
3//! ## SPHINX shared keys derivation
4//! The architecture of the SPHINX shared key derivation is done generically, so it can work with any
5//! elliptic curve group for which CDH problem is hard. The generic Sphinx implementation only
6//! requires one to implement the `SphinxSuite` trait.
7//!
8//! The trait requires to have the following building blocks:
9//! - elliptic curve group ([GroupElement](shared_keys::GroupElement)) and corresponding the scalar type ([Scalar](shared_keys::Scalar))
10//! - type representing public and private keypair and their conversion to [Scalar](shared_keys::Scalar)
11//!   and [GroupElement](shared_keys::GroupElement) (by the means of the corresponding `From` trait implementation)
12//!
13//! Currently, there are the following [SphinxSuite](crate::shared_keys::SphinxSuite) implementations :
14//! - `Secp256k1Suite`: deprecated, used in previous HOPR versions
15//! - `Ed25519Suite`: simple implementation using Ed25519, used for testing
16//! - [X25519Suite](crate::ec_groups::X25519Suite) currently used, implemented using Curve25519 Montgomery curve for faster computation
17//!
18//! The implementation can be easily extended for different elliptic curves (or even arithmetic multiplicative groups).
19//! In particular, as soon as there's way to represent `Ed448` PeerIDs, it would be easy to create e.g. an `X448Suite`.
20
21/// Contains simple key derivation functions for different purposes
22pub mod derivation;
23/// Implementations of `SphinxSuite` trait for different elliptic curve groups
24pub mod ec_groups;
25/// Implementation of a pseudo-random generator function used in SPHINX packet header construction
26mod prg;
27/// Implementation of the Lioness wide-block cipher using Chacha20 and Blake2b256
28pub mod prp;
29/// Implementation of the SPHINX header format
30pub mod routing;
31/// Derivation of shared keys for SPHINX header
32pub mod shared_keys;