Skip to main content

Module sign

Module sign 

Source
Expand description

SignAlgorithm trait and ML-DSA/SLH-DSA implementations (FIPS 204/205). Digital signature backend trait and FIPS 204/205 implementations.

§Responsibility scope

This module owns the abstract [SignAlgorithm] trait, the [SignatureMode] markers, the generic [hub::Signature<A, S>] struct, and the concrete algorithm implementations:

  • ML-DSA 44/65/87 (FIPS 204, behind ml-dsa-backend feature)
  • SLH-DSA Shake128f/s, 192f/s, 256f/s (FIPS 205, behind sign-slhdsa feature)

§Feature gates

FeatureModuleTypes added
ml-dsa-backendml_dsaMlDsa44Impl, MlDsa65Impl, MlDsa87Impl
sign-slhdsaslh_dsaSlhDsaShake128fImpl, … (6 variants)

The algorithm and hub modules are unconditionally compiled.

§Key types exported

  • [SignAlgorithm] — core trait
  • [algorithm::Detached], [algorithm::MessageMode] — mode markers
  • [hub::Signature] — generic container

§Concurrency

All types are Send + Sync.

§Examples

#[cfg(feature = "ml-dsa-backend")]
{
    use crypt_guard::sign::{SignAlgorithm, ml_dsa::MlDsa65Impl};
    use crypt_guard::kem::backend::OsRng;
    let mut rng = OsRng;
    let (sk, vk) = MlDsa65Impl::keypair(&mut rng).unwrap();
    let sig = MlDsa65Impl::sign(&sk, b"hello").unwrap();
    MlDsa65Impl::verify(&vk, b"hello", &sig).unwrap();
}

Re-exports§

pub use algorithm::Detached;
pub use algorithm::Keypair;
pub use algorithm::MessageMode;
pub use algorithm::SignAlgorithm;
pub use algorithm::SignatureMode;
pub use hub::Signature as NewSignature;

Modules§

algorithm
SignAlgorithm trait and supporting types.
hub
Blanket Signature<A, S> struct wrapping any SignAlgorithm + SignatureMode.
ml_dsa
ML-DSA implementations of SignAlgorithm (FIPS 204).