Skip to main content

Module mldsa

Module mldsa 

Source
Expand description

ML-DSA post-quantum signatures standardized in FIPS 204.

This module implements the ML-DSA-44, ML-DSA-65 and ML-DSA-87 parameter sets through distinct key types:

Parameter setSecret keyPublic keyPublic key sizeSignature size
ML-DSA-44MlDsa44SecretKeyMlDsa44PublicKey1312 B2420 B
ML-DSA-65MlDsa65SecretKeyMlDsa65PublicKey1952 B3309 B
ML-DSA-87MlDsa87SecretKeyMlDsa87PublicKey2592 B4627 B

§Signing

Signing is stateful: build a secret key from a 32-byte seed with new (or with generate for a fresh random key), then call sign (randomized) or sign_derand (deterministic for a fixed nonce).

The expanded key caches the NTT-domain matrix and secret vectors, so repeated signatures skip key generation. It is a fixed-size value with no heap allocation:

let key = MlDsa65SecretKey::new(&seed);
let signature = key.sign_derand(b"message", b"", &[0u8; 32]).unwrap();
assert!(key.public_key().verify(b"message", &signature, b"").is_ok());

§Verification

Verification is stateless: the public key returned by the secret key’s public_key method (or built from raw bytes with from_bytes) exposes verify for a message and optional context, and verify_external_mu for a precomputed 64-byte message representative (FIPS 204 “external μ”). Both return MlDsaError on failure.

Structs§

MlDsa44PublicKey
An ML-DSA-44 public key.
MlDsa44SecretKey
An expanded ML-DSA-44 secret key.
MlDsa65PublicKey
An ML-DSA-65 public key.
MlDsa65SecretKey
An expanded ML-DSA-65 secret key.
MlDsa87PublicKey
An ML-DSA-87 public key.
MlDsa87SecretKey
An expanded ML-DSA-87 secret key.

Enums§

MlDsaError

Constants§

ML_DSA_44_CONTEXT_MAX_LEN
Maximum length in bytes of an ML-DSA-44 context string.
ML_DSA_44_PUBLIC_KEY_SIZE
Size in bytes of an encoded ML-DSA-44 public key.
ML_DSA_44_SECRET_KEY_SIZE
Size in bytes of an initialized MlDsa44SecretKey.
ML_DSA_44_SEED_SIZE
Size in bytes of an ML-DSA-44 seed (private key).
ML_DSA_44_SIGNATURE_SIZE
Size in bytes of an encoded ML-DSA-44 signature.
ML_DSA_65_CONTEXT_MAX_LEN
Maximum length in bytes of an ML-DSA-65 context string.
ML_DSA_65_PUBLIC_KEY_SIZE
Size in bytes of an encoded ML-DSA-65 public key.
ML_DSA_65_SECRET_KEY_SIZE
Size in bytes of an initialized MlDsa65SecretKey.
ML_DSA_65_SEED_SIZE
Size in bytes of an ML-DSA-65 seed (private key).
ML_DSA_65_SIGNATURE_SIZE
Size in bytes of an encoded ML-DSA-65 signature.
ML_DSA_87_CONTEXT_MAX_LEN
Maximum length in bytes of an ML-DSA-87 context string.
ML_DSA_87_PUBLIC_KEY_SIZE
Size in bytes of an encoded ML-DSA-87 public key.
ML_DSA_87_SECRET_KEY_SIZE
Size in bytes of an initialized MlDsa87SecretKey.
ML_DSA_87_SEED_SIZE
Size in bytes of an ML-DSA-87 seed (private key).
ML_DSA_87_SIGNATURE_SIZE
Size in bytes of an encoded ML-DSA-87 signature.