Skip to main content

Module slh_dsa

Module slh_dsa 

Source
Expand description

SLH-DSA: Stateless Hash-Based Digital Signature Standard (FIPS 205).

This crate provides a pure-Rust implementation of SLH-DSA (formerly known as SPHINCS+), a post-quantum digital signature scheme standardized in FIPS 205. SLH-DSA is purely hash-based: its security relies only on the properties of cryptographic hash functions, with no algebraic structure (lattices, codes, etc.) that could be exploited by quantum or classical algorithms beyond generic attacks.

§Architecture

SLH-DSA is built from a hierarchy of hash-based primitives:

  1. WOTS+ – A one-time signature scheme that signs a single n-byte message using hash chains (see wots, internal).
  2. XMSS – An eXtended Merkle Signature Scheme that authenticates 2^h’ WOTS+ keys via a binary Merkle tree, producing a few-time signature (see xmss, internal).
  3. Hypertree – A tree of XMSS trees stacked in d layers, giving a many-time signature scheme with a total tree height of h = d * h' (see hypertree, internal).
  4. FORS – A Forest of Random Subsets, a few-time signature used to sign the message digest before passing it to the hypertree (see fors, internal).
  5. SLH-DSA – The top-level scheme that combines FORS + Hypertree to produce a stateless, many-time signature (see slh, internal).

§Supported parameter sets

This crate implements all six SHAKE-based parameter sets defined in FIPS 205 Section 11:

Type128-bit192-bit256-bit
Small (s)Shake128sShake192sShake256s
Fast (f)Shake128fShake192fShake256f

The “s” variants produce smaller signatures; the “f” variants are faster to sign and verify.

§Examples

use quantica::slh_dsa::{SlhDsa, Shake128f, OsRng};

// Generate a key pair
let mut rng = OsRng;
let (secret_key, public_key) = SlhDsa::<Shake128f>::keygen(&mut rng).unwrap();

// Sign a message (empty context string)
let message = b"hello, post-quantum world!";
let signature = SlhDsa::<Shake128f>::sign(message, b"", &secret_key, &mut rng).unwrap();

// Verify the signature
let valid = SlhDsa::<Shake128f>::verify(message, b"", &signature, &public_key).unwrap();
assert!(valid);

Re-exports§

pub use crate::prehash::PreHash;
pub use params::Params;
pub use params::Sha2_128f;
pub use params::Sha2_128s;
pub use params::Sha2_192f;
pub use params::Sha2_192s;
pub use params::Sha2_256f;
pub use params::Sha2_256s;
pub use params::Shake128f;
pub use params::Shake128s;
pub use params::Shake192f;
pub use params::Shake192s;
pub use params::Shake256f;
pub use params::Shake256s;
pub use rng::CryptoRng;
pub use rng::OsRng;

Modules§

params
SLH-DSA parameter set definitions and the Params trait. SLH-DSA parameter sets (FIPS 205, Section 11).
rng
Minimal cryptographic RNG trait and OS-backed implementation. Minimal cryptographic RNG trait and OS-backed implementation.

Structs§

Signature
SLH-DSA signature. Type-tagged with P.
SigningKey
SLH-DSA signing key (secret key, 4 * P::N bytes).
SlhDsa
Generic SLH-DSA interface parameterized by parameter set (FIPS 205).
VerifyingKey
SLH-DSA verifying key (public key, 2 * P::N bytes).

Enums§

SlhDsaError
Errors that can occur in SLH-DSA operations.