Skip to content
Trapdoor·Lab

ML-DSA — post-quantum signatures

1Toy

A signature you sometimes throw away

ML-DSA (FIPS 204, August 2024) is CRYSTALS-Dilithium as a standard: a signature on the same module lattices as ML-KEM. The public key is t = A·s₁ + s₂ mod q. A is a public matrix of polynomials expanded from a 32-byte seed ρ, and s₁ and s₂ are secret polynomials with small coefficients; recovering s₁ from t is the Module-LWE problem. The signature itself is built like a Schnorr signature from the Digital signatures station: the signer draws a mask y and computes the commitment w = A·y, the challenge c is a hash of the message and the high bits of w (Fiat–Shamir), and the response is z = y + c·s₁. The verifier computes A·z − c·t = w − c·s₂, and because c·s₂ is small, the high bits come out the same as those of w.

In a lattice the response z has to be short — anyone could find a long z for any c. So the mask is short too: every coefficient of y lies within ±γ₁ = ±2¹⁹, while q = 8,380,417. But the sum of a short mask and c·s₁ gives the secret away: it shifts the range the coefficients of z come from by c·s₁. Vadim Lyubashevsky in 2009 closed that leak with rejection (“Fiat–Shamir with aborts”): the signer publishes z only when every coefficient is smaller in absolute value than γ₁ − β, where β = 196 is the largest possible |c·s₁|. Such a z could have come from any secret, so it says nothing about it. The other attempts go in the bin — for ML-DSA-65, 5.1 attempts per signature on average (FIPS 204, Table 1).

The second idea is hints. To keep the public key short, ML-DSA stores only the high bits of t in it (t₁, without the 13 low bits t₀). So the verifier computes A·z − c·t₁·2¹³ = w − c·s₂ + c·t₀, and because of c·t₀ it sometimes lands in the neighbouring interval of high bits. The signer knows t₀, so it knows where this will happen, and adds a hint vector h to the signature: at most 55 ones, each saying “move one interval over here”.

All of this runs on polynomials of degree below 256, modulo X²⁵⁶ + 1 and the prime q = 8,380,417 (the Arithmetic modulo p station). Since 512 divides q − 1, there is a root of unity ζ = 1753 of order 512, and X²⁵⁶ + 1 splits into 256 linear factors: the NTT turns a product of polynomials into 256 products of numbers. The matrix A, the secrets, the mask y and the challenge c are expanded from seeds with SHAKE128 and SHAKE256 (the Hash functions station). The toy below is real ML-DSA-65, written for this station and checked against the NIST ACVP vectors and OpenSSL 3.5. Its signature is 3,309 B — more than 50 times the 64 B of an Ed25519 signature.

Educational implementation — do not use in productionThis ML-DSA passes the NIST vectors, but it does not run in constant time and keeps secrets in ordinary memory. For real: ML-DSA from the platform (.NET 10, OpenSSL 3.5, Java 24) or an audited library.

ML-DSA-65 step by step

Real ML-DSA-65 (FIPS 204), computed by this station’s code in your browser: keys, a signature with its rejection loop, and verification with hints.

21 / 1024 B

-1003 B too long — the limit is 1 KB.

Generate an ML-DSA-65 key pair — from a random 32-byte seed ξ, as in FIPS 204.

2Break it

Without rejection the secret leaks

ML-DSA has one attack in the graph — Shor’s algorithm — and it resists it. An implementation can still be broken. The simplest mistake is an “optimisation” that skips the check on z and publishes the first attempt. The toy below shows what an attacker then sees, in miniature: polynomials of 8 coefficients and the same rejection rule. Every zᵢ is yᵢ plus a few terms ±s₁ⱼ, and the attacker knows their signs from the public c. So it multiplies zᵢ by the sign of the s₁ⱼ term and averages over many signatures: the mask cancels out and s₁ⱼ remains. With rejection the same mean does not move, because an accepted z has one distribution for every key.

Toy model — do not use in productionPolynomials of 8 coefficients instead of 256 and only the response z = y + c·s₁ — no matrix A, no hash. The rejection rule is ML-DSA’s.

Signatures without rejection

You are on the attacker’s side. You see only the public c and z of signature after signature — recover the secret s₁.

Model: n = 8, η = 2, τ = 2, γ = 32, β = τ · η = 4. The mask y is drawn from −31 … 32; a signer with rejection throws the attempt away when any |zᵢ| ≥ 28.

s₁ and y: hidden

Drawing a secret…

−28028

Bars: how often each value ±zᵢ aligned to s₁[1] came up. Dashed lines: the rejection bound ±28; bars on it and beyond come only from a signer without rejection. Diamond: the mean, i.e. the estimate of s₁[1].

Signatures collected
0 of 20,000
Attempts per signature (at the signer)
—
Extrapolation by calculation — nobody computes this

The mean of n·τ values has a spread of σ/√(n·τ), where σ is the spread of the mask y (about 18.5 here). At about 2,746 signatures the spread of the mean drops to 0.25 — rounding then hits a given coefficient about 96% of the time, and all 8 at once for roughly three keys in four. You can check that above.

ML-DSA-65 has a mask 2¹⁴ times wider (γ₁ = 2¹⁹ instead of 2⁵) and τ = 49: the same simple estimator — the mean — would need about 3.0 · 1010 signatures without rejection. That is the cost of this one method, not a lower bound: a better attack may need fewer. Rejection removes the leak entirely: an accepted z has the same distribution for every key.

The second loophole is a repeated mask — the counterpart of a repeated ECDSA nonce. Two signatures with the same y and different c give z₁ − z₂ = (c₁ − c₂)·s₁, and the difference c₁ − c₂ can usually be inverted in the ring. ML-DSA derives y from ρ″ = H(K ‖ rnd ‖ μ), so the same mask comes back only for the same message and the same c. In the deterministic variant (rnd = 0), though, a fault induced during signing that changes c but keeps y is enough: Groot Bruinderink and Pessl (TCHES 2018) recovered s₁ this way from a correct and a faulted signature of the same message. That is why FIPS 204 makes the variant with a random rnd (“hedged”) the default and says not to use the deterministic one where side-channel attacks are a concern and cannot be mitigated otherwise (§3.4).

A quantum computer does not help here the way it does against RSA and ECDSA. Shor’s algorithm finds a hidden period — that is how factoring and the discrete logarithm fall, and with them ECDSA, Ed25519 and RSA. ML-DSA rests on Module-LWE (recover s₁ from t) and Module-SIS (find a short z for someone else’s c): the periodic structure of the lattice is public, and the hard part is finding a short vector, not a period — more on the ML-KEM station. The known quantum speed-ups apply to sieving inside lattice attacks and are already in the parameters: for Dilithium3, the parameters of ML-DSA-65, the authors estimate key recovery at 2¹⁸² operations classically and 2¹⁶⁵ quantumly, and forging a signature at 2¹⁸⁶ and 2¹⁶⁹ (Core-SVP method, Dilithium specification 3.1, Table 1). That is why its status in the graph is “resistant”.

3In the real world

Where ML-DSA is used

  • OpenSSL 3.5The release of 8 April 2025 added post-quantum algorithms: ML-KEM, ML-DSA and SLH-DSA. node:crypto in Node.js 26 runs on OpenSSL 3.5 — the tests of this station check its ML-DSA against it.Source (OpenSSL 3.5)
  • Java 24 — JEP 497JDK 24 has ML-DSA in the standard APIs: KeyPairGenerator and Signature for “ML-DSA”, the parameter sets ML-DSA-44, -65 and -87, with ML-DSA-65 as the default.Source (Java 24 — JEP 497)
  • X.509 certificates — RFC 9881Since October 2025, RFC 9881 defines the identifiers of ML-DSA in X.509 certificates: OIDs 2.16.840.1.101.3.4.3.17–19 for ML-DSA-44, -65 and -87.Source (X.509 certificates — RFC 9881)
  • AWS KMSSince 13 June 2025, KMS has ML_DSA_44, ML_DSA_65 and ML_DSA_87 keys and signs whole messages with them, or a μ computed on the client side (external μ).Source (AWS KMS)
  • Apple CryptoKitSince the version 26 operating systems, CryptoKit has the MLDSA65 and MLDSA87 types with private and public keys, signing and verification, also with a context.Source (Apple CryptoKit)
4Take it to your project

ML-DSA from the platform, with a random rnd

Good practice

Take ML-DSA from the platform: .NET 10 (MLDsa), OpenSSL 3.5 (including node:crypto in Node.js), Java 24 or CryptoKit. Use ML-DSA-65 by default (category 3, like ML-KEM-768), and ML-DSA-87 where category 5 is required. Sign with pure ML-DSA and a random rnd — that is the default “hedged” variant, and FIPS 204 prefers the pure version to HashML-DSA (§5.4). Pass a context, such as the name of the purpose: a signature made with one context fails to verify under another. Plan for the space: the public key is 1,952 B and the signature 3,309 B.

JavaScript
import { generateKeyPairSync, sign, verify } from 'node:crypto';

const { publicKey, privateKey } = generateKeyPairSync('ml-dsa-65');
const context = Buffer.from('firmware-v1');
const signature = sign(null, data, { key: privateKey, context }); // 3309 B
verify(null, data, { key: publicKey, context }, signature);       // true
C#
using MLDsa key = MLDsa.GenerateKey(MLDsaAlgorithm.MLDsa65);
byte[] context = "firmware-v1"u8.ToArray();
byte[] signature = key.SignData(data, context); // 3309 B
byte[] publicKey = key.ExportMLDsaPublicKey();  // 1952 B

using MLDsa verifier = MLDsa.ImportMLDsaPublicKey(MLDsaAlgorithm.MLDsa65, publicKey);
bool ok = verifier.VerifyData(data, signature, context);
Anti-pattern

Do not write your own ML-DSA: the values of rejected attempts (y, z, w) must not leave the module, not even through a side channel (FIPS 204, §3.6.3: intermediate values must be destroyed), and this station’s code does not run in constant time. Do not skip rejection “for speed” — the toy above recovers s₁ from the signatures alone. Do not use the deterministic variant on hardware exposed to fault attacks, such as cards and microcontrollers. Do not assume a signature is 64 B: fields and limits designed for ECDSA and Ed25519 will not hold 3,309 B.

JavaScript
// ✕ a “faster” signature: the first attempt, no check of ‖z‖∞ < γ₁ − β
const z = y.map((yi, i) => add(yi, cs1[i]));
return sigEncode(cTilde, z, h); // z gives away c·s₁, many signatures give away s₁