Expand description
§RustCrypto: Module Lattice
Functionality shared between the ml-kem and ml-dsa crates, which provide implementations of post-quantum secure
algorithms for key encapsulation and digital signatures respectively.
§About
The “ML” in ML-KEM and ML-DSA stands for “module lattice”. This crate contains the following common functionality for these algorithms:
- Linear algebra with degree-256 polynomials over a prime-order field, vectors of such polynomials, and NTT polynomials / vectors.
- Packing of polynomials into coefficients with a specified number of bits.
- Utility functions such as truncating integers, flattening arrays of arrays, and unflattening arrays into arrays of arrays.
§⚠️ Warning: Hazmat!
This crate is intended solely for the purposes of implementing the ml-kem and ml-dsa crates and should not be used
outside of that purpose.
§Minimum Supported Rust Version (MSRV) Policy
MSRV increases are not considered breaking changes and can happen in patch releases.
The crate MSRV accounts for all supported targets and crate feature combinations, excluding explicitly unstable features.
§License
Licensed under either of:
at your option.
§Contribution
Unless you explicitly state otherwise, any contribution intentionally submitted for inclusion in the work by you, as defined in the Apache-2.0 license, shall be dual licensed as above, without any additional terms or conditions.
Macros§
- define_
field - The
define_fieldmacro creates a zero-sized struct and an implementation of theFieldtrait for that struct. The caller must specify:
Structs§
- Elem
- An
Elemis a member of the specified prime-order field. - NttMatrix
- A
K x Lmatrix of NTT-domain polynomials. - NttPolynomial
- An
NttPolynomialis a member of the NTT algebraT_q = Z_q[X]^256of 256-tuples of field elements. - NttVector
- An
NttVectoris a vector of polynomials fromT_qof lengthK. - Polynomial
- A
Polynomialis a member of the ringR_q = Z_q[X] / (X^256)of degree-256 polynomials over the finite field with prime orderq. - Vector
- A
Vectoris a vector of polynomials fromR_qof lengthK.
Traits§
- Array
Size - An array length with other useful properties
- Encode
- Encoding trait.
- Encoding
Size - An integer that can describe encoded polynomials.
- Field
- Finite field with efficient modular reduction for lattice-based cryptography.
- Multiply
Ntt - Perform multiplication in the NTT domain.
- Truncate
- Safely truncate an unsigned integer value to shorter representation
- Vector
Encoding Size - An integer that can describe encoded vectors.
Functions§
- byte_
decode - FIPS 203: Algorithm 5
ByteDecode_d(F)FIPS 204: Algorithm 18SimpleBitUnpack - byte_
encode - FIPS 203: Algorithm 4
ByteEncode_d. FIPS 204: Algorithm 16SimpleBitPack.
Type Aliases§
- Decoded
Value - Decoded value.
- Encoded
Polynomial - Encoded polynomial.
- Encoded
Polynomial Size - Size of an encoded polynomial.
- Encoded
Vector - Encoded vector.
- Encoded
Vector Size - Size of an encoded vector.