Skip to main content

Crate module_lattice

Crate module_lattice 

Source
Expand description

§RustCrypto: Module Lattice

crate Docs Build Status Apache2/MIT licensed Rust Version Project Chat HAZMAT

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_field macro creates a zero-sized struct and an implementation of the Field trait for that struct. The caller must specify:

Structs§

Elem
An Elem is a member of the specified prime-order field.
NttMatrix
A K x L matrix of NTT-domain polynomials.
NttPolynomial
An NttPolynomial is a member of the NTT algebra T_q = Z_q[X]^256 of 256-tuples of field elements.
NttVector
An NttVector is a vector of polynomials from T_q of length K.
Polynomial
A Polynomial is a member of the ring R_q = Z_q[X] / (X^256) of degree-256 polynomials over the finite field with prime order q.
Vector
A Vector is a vector of polynomials from R_q of length K.

Traits§

ArraySize
An array length with other useful properties
Encode
Encoding trait.
EncodingSize
An integer that can describe encoded polynomials.
Field
Finite field with efficient modular reduction for lattice-based cryptography.
MultiplyNtt
Perform multiplication in the NTT domain.
Truncate
Safely truncate an unsigned integer value to shorter representation
VectorEncodingSize
An integer that can describe encoded vectors.

Functions§

byte_decode
FIPS 203: Algorithm 5 ByteDecode_d(F) FIPS 204: Algorithm 18 SimpleBitUnpack
byte_encode
FIPS 203: Algorithm 4 ByteEncode_d. FIPS 204: Algorithm 16 SimpleBitPack.

Type Aliases§

DecodedValue
Decoded value.
EncodedPolynomial
Encoded polynomial.
EncodedPolynomialSize
Size of an encoded polynomial.
EncodedVector
Encoded vector.
EncodedVectorSize
Size of an encoded vector.