IntegrityChain: FIPS 205 Stateless Hash-Based Digital Signature Standard

crate Docs Build Status Apache2/MIT licensed Rust Version

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

This crate implements the released FIPS 205 standard in pure Rust with minimal and mainstream dependencies, and without any unsafe code. All twelve security parameter sets are fully functional and tested. Key generation and signing are constant-time: every branch, loop bound and memory index depends only on public data, and each signature makes the same number of hash calls for its parameter set, whatever the key, message or randomness. 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.205.pdf for a full description of the target functionality.

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

# use std::error::Error;
#
# fn main() -> Result<(), Box<dyn Error>> {
# #[cfg(all(feature = "slh-dsa-shake-128s", feature = "default-rng"))] {
use fips205::slh_dsa_shake_128s; // Could use any of the twelve security parameter sets.
use fips205::traits::{SerDes, Signer, Verifier};

let msg_bytes = [0u8, 1, 2, 3, 4, 5, 6, 7];

// Generate both public and secret keys. This only fails when the OS rng fails.
let (pk1, sk) = slh_dsa_shake_128s::try_keygen()?;
// Use the secret key to generate a signature. The second parameter is the
// context string (often just an empty &[]), and the last parameter selects
// the preferred hedged variant. This fails when the OS rng fails or the context is longer than 255 bytes.
let sig_bytes = sk.try_sign(&msg_bytes, b"context", true)?;

// Serialize the public key, and send with message and signature bytes. These
// statements model sending byte arrays over the wire.
let (pk_send, msg_send, sig_send) = (pk1.into_bytes(), msg_bytes, sig_bytes);
let (pk_recv, msg_recv, sig_recv) = (pk_send, msg_send, sig_send);

// A public key of the right length always decodes.
let pk2 = slh_dsa_shake_128s::PublicKey::try_from_bytes(pk_recv)?;
// Use the public key to verify the msg signature
let v = pk2.verify(&msg_recv, &sig_recv, b"context");
assert!(v);
# }
# 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.