Skip to main content

Crate dilithium

Crate dilithium 

Source
Expand description

Pure Rust implementation of ML-DSA (FIPS 204) / CRYSTALS-Dilithium.

A post-quantum digital signature scheme standardized as FIPS 204. Supports all three security levels: ML-DSA-44, ML-DSA-65, ML-DSA-87.

§Features

  • FIPS 204 compliant — supports pure ML-DSA and HashML-DSA (pre-hash)
  • no_std compatible — works on embedded and WASM targets
  • WASM ready — enable the js feature for browser environments
  • Zeroize — private key material is automatically zeroized on drop
  • Constant-time — verification uses constant-time comparison
  • Optional serde — enable the serde feature for serialization
  • SIMD acceleration — AVX2 (x86_64) and NEON (AArch64) NTT behind simd

§Feature Flags

FeatureDefaultDescription
stdEnables getrandom for OS entropy (generate, sign, sign_prehash)
serdeEnables Serialize/Deserialize for key pairs, signatures, and modes
simdEnables AVX2 (x86_64) and NEON (AArch64) NTT acceleration
jsEnables getrandom/js for WASM browser targets

§Platform Support

TargetBuildNotes
x86_64 Linux/macOSFull support, AVX2 SIMD optional
AArch64 (Apple Silicon, ARM)Full support, NEON SIMD optional
wasm32-unknown-unknownRequires --no-default-features, add js for entropy
thumbv7em-none-eabihfRequires --no-default-features, deterministic APIs only

§Quick Start

use dilithium::{MlDsaKeyPair, ML_DSA_44};

let kp = MlDsaKeyPair::generate(ML_DSA_44).unwrap();
let sig = kp.sign(b"Hello, post-quantum world!", b"").unwrap();
assert!(MlDsaKeyPair::verify(
    kp.public_key(), &sig, b"Hello, post-quantum world!", b"",
    ML_DSA_44
));

Re-exports§

pub use params::DilithiumMode;
pub use params::ML_DSA_44;
pub use params::ML_DSA_65;
pub use params::ML_DSA_87;
pub use safe_api::DilithiumError;
pub use safe_api::DilithiumKeyPair;
pub use safe_api::DilithiumSignature;
pub use safe_api::MlDsaKeyPair;
pub use safe_api::MlDsaSignature;

Modules§

ntt_avx2
AVX2-accelerated NTT for x86_64 targets.
ntt_neon
NEON-accelerated NTT for AArch64 targets (Apple Silicon, ARM servers).
params
Dilithium parameter sets (FIPS 204 / ML-DSA).
safe_api
High-level safe Rust SDK for ML-DSA (FIPS 204) / CRYSTALS-Dilithium.