wycheproof
wycheproof copied to clipboard
Add ML-DSA test vectors.
This PR adds test vectors for ML-DSA, for two versions: the round 3 proposal (CRYSTALS-DILITHIUM) and the current draft of the FIPS 204 standard.
These tests aim to cover the following cases:
- Baseline (signing a "Hello world" message).
- Keys and signatures of the wrong length.
- Signature with bit flips.
- Signature hints with a non-canonical encoding:
- hints that aren't sorted,
- hints are not strictly sorted (i.e. the same hint is repeated),
- too many hints (potentially causing a buffer overflow),
- non-zero padding after the hints.
- Secret keys with the
s1
ors2
vectors out of the[-eta, eta]
range. - Public key with the
t1
component set to zero (allowing trivial forgeries, but the verification algorithm should still accept signatures for this key). - Boundary conditions in the signature rejection loop (aiming to detect incorrect comparisons):
-
z_max
equalsgamma1 - beta - 1
andgamma1 - beta
, -
r0_max
equalsgamma2 - beta - 1
andgamma2 - beta
, -
h_ones
equalsomega
andomega + 1
, - in the case of ML-DSA-44 (a.k.a. Dilithium 2),
|ct0|_max
equalsgamma2 - 1
andgamma2
.
-
- A "large" number of SHAKE bytes and of SHAKE blocks generated in the
expand_a
,expand_s
,rej_ntt_poly
andrej_bounded_poly
functions. - Boundary conditions in arithmetic functions:
-
power_2_round
function: when the remainder (found int0
) is equal to 4096 or -4095, -
decompose
(viahigh_bits
orlow_bits
): when the conditionr_plus - r_0 = q - 1
happens.
-
Since the FIPS 204 standard is still a draft, I'm leaving this pull request as a draft for now.