The One-Line Cargo Change That Quietly Turns Hedged ML-DSA Signing Deterministic

In most Rust ML-DSA deployments, what decides whether signing is hedged or deterministic is the feature set Cargo resolves at build time, not the code that calls the signer. A single `default-features = false` added to tidy a dependency tree can drop the RNG path. The signer then falls back to the deterministic variant, every test stays green, and the reviewer approves a diff that looks like housekeeping. Nothing breaks, so nobody notices the system has lost one of its defences against fault attacks.

Why the fallback exists at all

NIST's post-quantum signature standard defines two signing modes. Both are valid. Hedged signing mixes a fresh 32-byte random value, `rnd`, into the per-signature seed, and deterministic signing fixes that value at zero. Library authors reasonably support both, because embedded targets, reproducible test vectors and some HSM integrations need the deterministic path. The trouble is how that choice gets exposed: in several crates the hedged API only compiles when an RNG feature is on, and the calling code goes through a trait or wrapper that picks whichever variant is available. Turn the feature off and the wrapper still compiles, still signs, and still produces signatures that verify everywhere. You have built in graceful degradation, and it degrades without telling anyone.

Why review and CI both miss it

The diff is in `Cargo.toml`, often in a workspace manifest that nobody on the service team owns, and its stated purpose is cutting binary size or getting rid of a transitive `std` dependency. Cargo's feature unification makes it worse, because the feature can stay enabled in one workspace member's build and be dropped in another, depending on which crates are compiled together. That means `cargo test` at the workspace root can exercise the hedged path while the production binary, built alone, does not. Known-answer tests can't help either: they pin `rnd` so the outputs are reproducible, which means they exercise exactly the deterministic path and pass whether hedging is present or not. Signature verification is also blind to the mode, since a verifier cannot tell from a valid signature whether randomness went into it.

What you actually lose

Deterministic ML-DSA is not broken by itself. It does lose its tolerance of a single induced fault. If an attacker who can glitch voltage, clock or memory gets the signer to produce two signatures over the same message and key with one intermediate value corrupted, the difference between them can leak information about the secret vector. Hedging is the part that keeps working when another part fails: with fresh randomness, the two runs never share an internal state worth comparing. In practice that protection matters most on edge gateways, smart cards and shared cloud hosts, which are exactly where people trim dependencies hardest.

A detection step you can run today

Take the binary exactly as you ship it, built with the same profile, target and feature flags as production, sign the same message twice with the same key, and compare the signatures byte for byte. If they are identical, the build is deterministic regardless of what the source appears to call. To find the cause, run `cargo tree -e features -i ml-dsa` (or the name of your signing crate) against the production package rather than the workspace root, and check that the RNG feature appears in the resolved graph. Put the twin-signature check in the release pipeline as a post-build smoke test, and use this rule: a build declared as hedged that produces byte-identical signatures over identical input fails the deploy, with no override flag. The check takes well under a second (an estimate, based on a single keygen and two signatures at the middle parameter set), so it costs nothing to run on every artifact.

Should we just force deterministic signing everywhere so behaviour is predictable?

Only if your threat model rules out physical or co-tenant fault injection and you need reproducible signatures for audit. Otherwise, make hedged the required mode, make the build fail when the RNG feature is missing instead of falling back silently, and keep deterministic signing behind an explicitly named feature that shows up in review.

Back to MLDSASafe · Domains

← Back to MLDSASafe
Engineering & Architecture Brief

The One-Line Cargo Change That Quietly Turns Hedged ML-DSA Signing Deterministic

In most Rust ML-DSA deployments, what decides whether signing is hedged or deterministic is the feature set Cargo resolves at build time, not the code that calls the signer. A single `default-features = false` added to tidy a dependency tree can drop the RNG path. The signer then falls back to the deterministic variant, every test stays green, and the reviewer approves a diff that looks like housekeeping. Nothing breaks, so nobody notices the system has lost one of its defences against fault attacks.

Why the fallback exists at all

NIST's post-quantum signature standard defines two signing modes. Both are valid. Hedged signing mixes a fresh 32-byte random value, `rnd`, into the per-signature seed, and deterministic signing fixes that value at zero. Library authors reasonably support both, because embedded targets, reproducible test vectors and some HSM integrations need the deterministic path. The trouble is how that choice gets exposed: in several crates the hedged API only compiles when an RNG feature is on, and the calling code goes through a trait or wrapper that picks whichever variant is available. Turn the feature off and the wrapper still compiles, still signs, and still produces signatures that verify everywhere. You have built in graceful degradation, and it degrades without telling anyone.

Why review and CI both miss it

The diff is in `Cargo.toml`, often in a workspace manifest that nobody on the service team owns, and its stated purpose is cutting binary size or getting rid of a transitive `std` dependency. Cargo's feature unification makes it worse, because the feature can stay enabled in one workspace member's build and be dropped in another, depending on which crates are compiled together. That means `cargo test` at the workspace root can exercise the hedged path while the production binary, built alone, does not. Known-answer tests can't help either: they pin `rnd` so the outputs are reproducible, which means they exercise exactly the deterministic path and pass whether hedging is present or not. Signature verification is also blind to the mode, since a verifier cannot tell from a valid signature whether randomness went into it.

What you actually lose

Deterministic ML-DSA is not broken by itself. It does lose its tolerance of a single induced fault. If an attacker who can glitch voltage, clock or memory gets the signer to produce two signatures over the same message and key with one intermediate value corrupted, the difference between them can leak information about the secret vector. Hedging is the part that keeps working when another part fails: with fresh randomness, the two runs never share an internal state worth comparing. In practice that protection matters most on edge gateways, smart cards and shared cloud hosts, which are exactly where people trim dependencies hardest.

A detection step you can run today

Take the binary exactly as you ship it, built with the same profile, target and feature flags as production, sign the same message twice with the same key, and compare the signatures byte for byte. If they are identical, the build is deterministic regardless of what the source appears to call. To find the cause, run `cargo tree -e features -i ml-dsa` (or the name of your signing crate) against the production package rather than the workspace root, and check that the RNG feature appears in the resolved graph. Put the twin-signature check in the release pipeline as a post-build smoke test, and use this rule: a build declared as hedged that produces byte-identical signatures over identical input fails the deploy, with no override flag. The check takes well under a second (an estimate, based on a single keygen and two signatures at the middle parameter set), so it costs nothing to run on every artifact.

Technical FAQ: Should we just force deterministic signing everywhere so behaviour is predictable?

Only if your threat model rules out physical or co-tenant fault injection and you need reproducible signatures for audit. Otherwise, make hedged the required mode, make the build fail when the RNG feature is missing instead of falling back silently, and keep deterministic signing behind an explicitly named feature that shows up in review.

Related Architecture Specifications (PQCECOSYSTEM): mlkemcert.com · mlkemsec.com · otacrypt.com

More Technical Articles on mldsasafe.com

Benchmarking Bootloader Verification Delays: ML-DSA vs SLH-DSA vs Classical RSA-3072 →Remote Attestation for Sovereign Cloud Hyperscalers Using Post-Quantum TPM Quotes →When ML-DSA Signing Quietly Goes Deterministic: The Entropy Fallback Nobody Reviews →The ML-DSA fallback that keeps the dashboard green →ML-DSA Reference Architecture: Aligning Memory-Safe Implementations with FIPS 204, LAMPS X.509 Profiles and ACVP Validation →