Documentation

CslibFrontier.Crypto.Computational.MLDSA.RandomXofMatrix

Drawing the ML-DSA matrix inside the shared random-XOF game #

FIPS 204, Algorithm 6 derives the public seed through SHAKE256 and reads its matrix under SHAKE128. Conditional on that seed, the matrix addresses are distinct entries of the independent SHAKE128 table. Resampling the 894-byte prefixes there preserves the distribution of the entire pair of raw oracles, including every longer and overlapping read.

theorem Cslib.Crypto.MLDSA.FIPS204.uniformPrefixes_resampleMatrix (base : Xofs) (s : Level) {a b : ℕ} (ha : 272 ≤ a) (hb : 894 ≤ b) {α : Type} (run : Xofs → FixedBytes 32 → PMF α) :
have R := base.uniformPrefixes a b; have S := Probability.PMF.uniformOfFintype (FixedBytes 32); (R.bind fun (H : Xofs) => S.bind fun (seed : FixedBytes 32) => (Probability.PMF.uniformOfFintype (MatrixPrefixes s)).bind fun (t : MatrixPrefixes s) => run (H.withMatrixPrefixes s (List.take 32 (H.expandKeySeed s seed)) t) seed) = R.bind fun (H : Xofs) => S.bind fun (seed : FixedBytes 32) => run H seed

Resampling the SHAKE128 matrix rows at the public FIPS seed preserves every continuation of the joint XOFs and original 32-byte key seed, including later adaptive queries.

theorem Cslib.Crypto.MLDSA.FIPS204.uniformPrefixes_matrixSetup (base : Xofs) (s : Level) {a b : ℕ} (ha : 272 ≤ a) (hb : 894 ≤ b) :
((base.uniformPrefixes a b).bind fun (H : Xofs) => matrixSetup H s) = (base.uniformPrefixes a b).bind fun (H : Xofs) => PMF.map (fun (seed : FixedBytes 32) => (H, do let keys ← H.keyGen s seed let A ← H.expandA s (List.take 32 keys.publicKey) pure (A, keys))) (Probability.PMF.uniformOfFintype (FixedBytes 32))

Sampling the independent FIPS matrix prefixes inside an already sampled pair of random XOFs preserves their entire joint law with the honest public matrix and key pair. The table covers every 34-byte matrix input and its first 894 output bytes.

theorem Cslib.Crypto.MLDSA.FIPS204.generatedMatrix_apply_some_le_uniform (s : Level) (base : Xofs) {a b : ℕ} (ha : 272 ≤ a) (hb : 894 ≤ b) (A : PublicMatrix s) :
have matrices := (base.uniformPrefixes a b).bind fun (H : Xofs) => PMF.map (fun (seed : FixedBytes 32) => do let keys ← H.keyGen s seed H.expandA s (List.take 32 keys.publicKey)) (Probability.PMF.uniformOfFintype (FixedBytes 32)); matrices (some A) ≤ (Probability.PMF.uniformOfFintype (PublicMatrix s)) A

The mass of a successful Algorithm 6 setup at any particular matrix is at most its uniform mass. The comparison averages over the seed and raw XOFs and retains setup failure.

Equality of the strong-forgery game sampled before the seed with the averaged matrix-prefix game. The equality holds for the full adaptive quantum experiment.

The strong-forgery probability in the finite random-XOF experiment is bounded by the fresh-digest and raw SHAKE256 collision events and by the success of the extracted vector on an independently supplied uniform Hermite MSIS matrix. The solver draws its own pair of tables and runs the quantum forger once. All three terms retain the original signing access.