IntegrityChain: FIPS 204 Module-Lattice-Based Digital Signature Standard

crate Docs Build Status Apache2/MIT licensed Rust Version

FIPS 204 Module-Lattice-Based Digital Signature Standard written in pure Rust for server, desktop, browser and embedded applications. The source repository includes examples demonstrating benchmarking, code provenance, an embedded target, constant-time statistical measurements, a fuzzing harness, WASM execution, a C FFI shared library and Python bindings.

This crate implements the released FIPS 204 standard in pure Rust with minimal and mainstream dependencies, and without any unsafe code. All three security parameter sets are fully functional and tested. Key generation and signing are constant-time within each attempt: they do not branch on secret data, though rejection sampling makes the number of attempts vary. The crate does not require the standard library (it is #![no_std]), makes no heap allocations (no alloc needed), and exposes the RNG, so it suits the full range of applications from server down to bare metal. The API is stabilized, and the code is heavily biased towards safety and correctness.

See https://nvlpubs.nist.gov/nistpubs/FIPS/NIST.FIPS.204.pdf for a full description of the target functionality.

The functionality is extremely simple to use, as demonstrated by the following example.

// Use the desired target parameter set.
# use std::error::Error;
#
# fn main() -> Result<(), Box<dyn Error>> {
# #[cfg(all(feature = "ml-dsa-44", feature = "default-rng"))] {
use fips204::ml_dsa_44; // Could also be ml_dsa_65 or ml_dsa_87.
use fips204::traits::{SerDes, Signer, Verifier};
let message = [0u8, 1, 2, 3, 4, 5, 6, 7];

// Generate key pair and signature
let (pk1, sk) = ml_dsa_44::try_keygen()?;  // Generate both public and secret keys
let sig = sk.try_sign(&message, &[])?;  // Use the secret key to generate a message signature

// Serialize then send the public key, message and signature
let (pk_send, msg_send, sig_send) = (pk1.into_bytes(), message, sig);
let (pk_recv, msg_recv, sig_recv) = (pk_send, msg_send, sig_send);

// Deserialize the public key and signature, then verify the message
let pk2 = ml_dsa_44::PublicKey::try_from_bytes(pk_recv)?;
let v = pk2.verify(&msg_recv, &sig_recv, &[]); // Use the public key to verify the message signature
assert!(v);

// Note that the last argument to sign() and verify() is the (NIST specified) context
// value which is typically empty for basic signature generation and verification.
# }
# Ok(())
# }

The Rust Documentation lives under each Module corresponding to the desired security parameter.

Notes

License

Contents are licensed under either the Apache License, Version 2.0 or MIT license 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.