Documentation

CslibFrontier.Crypto.Computational.MLDSA.FIPS204

ML-DSA verification on byte keys and signatures #

FIPS 204, Algorithms 3, 6 and 8, with the Appendix C output limits for SHAKE rejection sampling. Verification distinguishes a malformed signature (some false) from XOF exhaustion (none). The signing digest and the challenge polynomial have distinct types. The ring products use the coefficient form of Algorithm 8, line 9.

The key-only reduction retains the matrix seed and the verifier's SHAKE-derived message representative. Its setup samples the Algorithm 6 key-generation seed. The resulting self-target experiment has that same seeded setup. For challenges supplying a full vector and a matrix at the published seed, decode_encodePublic recovers the rounded high term, and verifiedSignature_of_verifyWithExpansion recovers the full digest check for that vector.

XOFs and parameter levels #

The two XOFs used by FIPS 204. Each SHAKE variant has a single raw-bit input space, shared by key generation, signing, verification and external queries.

  • The XOF used to expand the public matrix.

  • The XOF used for secret expansion, masks, message representatives and challenges.

theorem Cslib.Crypto.MLDSA.FIPS204.Xofs.ext {x y : Xofs} (h128 : x.h128 = y.h128) (h256 : x.h256 = y.h256) :
x = y

FIPS 202 instantiation of the two FIPS 204 XOFs.

@[simp]

SHAKE256 evaluation in the FIPS 202 instantiation uses the four-one domain-separation suffix.

The parameter choices from FIPS 204, Table 1.

@[reducible, inline]

Ring and shortness parameters for the selected standard parameter set.

Each FIPS parameter set satisfies the ring, challenge and rounding conditions.

Byte length of the commitment digest (FIPS 204, Table 1, 2λ bits).

Maximum Hamming weight of the complete hint vector (Table 1).

@[reducible, inline]

A coefficient polynomial in the FIPS 204 negacyclic ring.

@[reducible, inline]

The coefficient representation of the public module matrix for the selected parameter set.

Coefficient bit-packing #

def Cslib.Crypto.MLDSA.FIPS204.packCoeffs {rows : ℕ} (width : ℕ) (coeff : Fin rows → Fin 256 → ℕ) :

Pack fixed-width nonnegative coefficients in row-major, low-bit-first order.

@[simp]
theorem Cslib.Crypto.MLDSA.FIPS204.length_packCoeffs {rows width : ℕ} (coeff : Fin rows → Fin 256 → ℕ) :
(packCoeffs width coeff).length = 32 * width * rows

Fixed-width packing uses exactly 32 times the field width bytes per polynomial.

Matrix expansion (Algorithms 30 and 32) #

FIPS 204 Algorithm 14 reads the low 23 bits of three little-endian bytes.

The successive accepted coefficients of Algorithm 30 on a finite XOF prefix.

Algorithm 30 on a finite SHAKE128 stream, failing if it supplies fewer than 256 accepted coefficients. The result is still in NTT order.

Exhaustion occurs exactly when fewer than 256 coefficients were accepted.

The sampled NTT vector consists of the first 256 accepted coefficients in stream order.

Reverse the eight bits of the FIPS evaluation index (§§2.5 and 7.5).

def Cslib.Crypto.MLDSA.FIPS204.fromNTT (values : Poly) :
Vector (ZMod 8380417) 256

The coefficient of degree j in the inverse NTT, using the evaluation points ζ^(2 BitRev8(i)+1) (FIPS 204 §2.5, equation (2.1)). The inverse of 256 modulo q is 8347681.

Algorithms 30 and 32, returning the matrix in coefficient representation. Each SHAKE128 stream absorbs ρ || column || row and may consume 894 bytes (Appendix C, Table 3).

theorem Cslib.Crypto.MLDSA.FIPS204.Xofs.expandA_congr {H K : Xofs} (ha : K.h128 = H.h128) (s : Level) (rho : List Byte) :
K.expandA s rho = H.expandA s rho

Algorithm 32 depends only on SHAKE128.

@[reducible, inline]

FIPS 202 specialization of Xofs.expandA.

Secret vector expansion (Algorithms 31 and 33) #

The two counter bytes absorbed by Algorithms 33 and 34, least significant byte first.

Algorithms 33 and 34 append the two-byte little-endian counter to the 64-byte seed.

A nonce-tagged 64-byte expansion seed occupies 528 SHAKE input bits.

theorem Cslib.Crypto.MLDSA.FIPS204.eq_of_nonceInput_eq {seed : List Byte} {i j : ℕ} (hi : i < 65536) (hj : j < 65536) (eq : nonceInput seed i = nonceInput seed j) :
i = j

For a fixed seed, the two-byte little-endian suffix recovers any counter below 65536.

An Algorithm 34 mask row has a 64-byte seed and two counter bytes. It cannot alias the SHAKE input at the 32-, 48-, or 64-byte digest consumed by Algorithm 29.

FIPS 204 Algorithm 31 on a finite SHAKE256 output. The low nibble precedes the high nibble of each byte. Exhaustion returns none when fewer than 256 coefficients were accepted.

Key encodings and key generation (Algorithm 6) #

Public-key bytes of Algorithm 6, lines 6–8: concatenate the matrix seed and the ten high bits of each coefficient of the full public vector, in row and coefficient order.

@[simp]

Algorithm 22 appends 320 bytes per rounded polynomial to the supplied matrix seed.

@[simp]

The seed used to expand the matrix can be read from the published bytes.

Algorithm 6's two encoded output keys.

  • publicKey : List Byte

    The public key, including the matrix seed.

  • secretKey : List Byte

    The private key containing the signing seed, public-key hash and three short vectors.

def Cslib.Crypto.MLDSA.FIPS204.packSigned {rows : ℕ} (width upper : ℕ) (v : Fin rows → Poly) :

Algorithms 17 and 24: pack signed coefficients as fixed-width offsets from their upper bound.

def Cslib.Crypto.MLDSA.FIPS204.unpackSigned (rows width upper : ℕ) (bytes : List Byte) :
Vector (Vector (ZMod 8380417) 256) rows

Algorithm 18 reads fixed-width signed offsets from the first field in a byte string. Array slices keep each coefficient lookup linear in its own width.

theorem Cslib.Crypto.MLDSA.FIPS204.unpackSigned_packSigned {rows width upper : ℕ} (v : Fin rows → Poly) (tail : List Byte) (hr : ∀ (i : Fin rows) (j : Fin 256), have off := ↑upper - (v i j).valMinAbs; 0 ≤ off ∧ off < ↑(2 ^ width)) (i : Fin rows) (j : Fin 256) :
((unpackSigned rows width upper (packSigned width upper v ++ tail)).get i).get j = v i j

The signed field round trip, even when other fields follow it in the input.

The six fields of the FIPS 204 private-key encoding (Algorithms 24 and 25).

Algorithm 25 decodes the stored private-key fields from their fixed-width encodings.

Decoded seed, key and public-key hash lengths are bounded by their FIPS byte widths.

Raw SHAKE256 input of FIPS 204 Algorithm 6, line 1. The 32-byte seed is followed by the one-byte matrix dimensions in row then column order.

The Algorithm 6 key expansion uses a 272-bit input at each standardized level.

Algorithm 6 reads the public matrix seed, the short-vector seed and the signing key in one 128-byte SHAKE256 expansion of the seed and the two dimension bytes.

FIPS 204 Algorithm 33 samples both short vectors from SHAKE256. The nonces of the error vector start immediately after the last nonce of the secret vector.

Algorithm 6, from the 32-byte seed to both encoded keys (Algorithms 22, 24). Rejection exhaustion during the matrix or short-vector expansion yields an error.

theorem Cslib.Crypto.MLDSA.FIPS204.Xofs.keyGen_congr_of_reads {H G : Xofs} (s : Level) (seed : FixedBytes 32) (matrixStream : G.h128 = H.h128) (seedRead : G.expandKeySeed s seed = H.expandKeySeed s seed) (nonceRead : ∀ (i : ℕ), have x := nonceInput (List.take 64 (List.drop 32 (H.expandKeySeed s seed))) i; G.h256.readBytes x 481 = H.h256.readBytes x 481) (publicRead : ∀ (x : List Byte), x.length = 32 + 320 * s.params.k → G.h256.readBytes x 64 = H.h256.readBytes x 64) :
G.keyGen s seed = H.keyGen s seed

Algorithm 6 gives the same keys or failure when the matrix stream, key expansion, secret-vector nonce reads at the generated secret seed, and encoded-public-key hash reads agree.

theorem Cslib.Crypto.MLDSA.FIPS204.publicSeed_of_keyGen {H : Xofs} {s : Level} {seed : FixedBytes 32} {keys : KeyPair} (h : H.keyGen s seed = some keys) :

The seed recovered from a successful public key is precisely the prefix used to index the SHAKE128 matrix streams during this execution of Algorithm 6.

theorem Cslib.Crypto.MLDSA.FIPS204.Xofs.keyGen_congr_off_digest {H K : Xofs} (s : Level) (seed : FixedBytes 32) (ha : K.h128 = H.h128) (agree : ∀ (x : List Bool), x.length ≠ 8 * digestBytes s → ∀ (n : ℕ), K.h256.read x n = H.h256.read x n) :
K.keyGen s seed = H.keyGen s seed

Algorithm 6 is unchanged if SHAKE128 is unchanged and the two SHAKE256 streams agree on all words outside the parameter set's digest-seed length. The key-seed input is 34 bytes, secret nonce inputs are 66 bytes, and every encoded public key is longer than a digest.

@[reducible, inline]

FIPS 202 specialization of Xofs.keyGen.

theorem Cslib.Crypto.MLDSA.FIPS204.privateKey_of_keyGen {H : Xofs} {s : Level} {seed : FixedBytes 32} {keys : KeyPair} (hg : H.keyGen s seed = some keys) :
∃ (rho : FixedBytes 32) (sk : SecretKey s.params), H.expandA s rho.toList = some sk.A ∧ keys.publicKey = encodePublic s rho.toList sk.publicKey.t ∧ decodePrivate s keys.secretKey = some { rho := rho.toList, key := List.drop 96 (H.expandKeySeed s seed), tr := H.h256.readBytes keys.publicKey 64, s₁ := sk.s₁, s₂ := sk.s₂, t₀ := publicKeyLowPart s.params 13 sk.publicKey } ∧ (∀ (i : Fin s.params.ℓ) (j : Fin s.params.n), |(sk.s₁ i j).valMinAbs| ≤ ↑s.params.η) ∧ (∀ (i : Fin s.params.k) (j : Fin s.params.n), |(sk.s₂ i j).valMinAbs| ≤ ↑s.params.η) ∧ H.expandS s (List.take 64 (List.drop 32 (H.expandKeySeed s seed))) = some (sk.s₁, sk.s₂)

A generated private key decodes to the same matrix seed, last 32 key-expansion bytes, short vectors, public-key hash and rounded low part used by Algorithm 6.

The encoded public key from Algorithm 6.

Challenge sampling (Algorithm 29) #

Algorithm 29. Preload the last τ positions with the SHAKE sign bits and exchange each with its chosen position in increasing order. Future sign positions remain untouched because an accepted index is at most the current position. The caller supplies the SHAKE256 bytes. The FIPS wrapper below chooses the minimum permitted 221-byte bound from Appendix C, Table 3.

Bounded Algorithm 29 reads 221 bytes at the challenge digest. This implementation chooses the minimum cap permitted by FIPS 204, Appendix C, Table 3.

@[reducible, inline]

FIPS 202 specialization of Xofs.sampleInBall.

Every successful Algorithm 29 byte row yields a signed challenge of weight τ.

theorem Cslib.Crypto.MLDSA.FIPS204.inBall_of_sampleInBall {H : Xofs} {s : Level} {digest : List Byte} {c : Poly} (h : H.sampleInBall s digest = some c) :

Every successful FIPS expansion gives exactly τ signed unit coefficients.

Hints and signature encoding (Algorithms 21, 26, and 27) #

The components of a FIPS 204 signature after Algorithm 27 has checked its encoding.

Algorithm 27, including the prescribed total length, increasing hint indices within each row, monotone row ends, the hint-weight bound, and zero padding (Algorithm 21).

The commitment digest occupies the first bytes of a successfully decoded signature.

theorem Cslib.Crypto.MLDSA.FIPS204.eq_of_sigDecode {s : Level} {a b : List Byte} {σ : Signature s} (ha : sigDecode s a = some σ) (hb : sigDecode s b = some σ) :
a = b

FIPS 204 Algorithms 21 and 27 give each successfully decoded signature exactly one byte representation. The hint rows determine their cumulative ends and their zero padding.

Consecutive little-endian bytes in a commitment digest register.

@[simp]

A coherent commitment digest register supplies exactly the required number of bytes.

A literal digest of the prescribed length round-trips through the XOR register.

Algorithm 26 serializes the commitment digest, signed response and sparse hint.

Length in bytes of an encoded signature (FIPS 204, Table 2).

Encoding a signature satisfying the hint and digest bounds has its prescribed length.

Algorithms 26 and 27 round-trip every signature with the prescribed digest length, an accepted response norm, and at most ω hint bits.

Public-key decoding #

Decode the rounded public coefficients and lift them by the FIPS factor 2^13.

@[simp]
theorem Cslib.Crypto.MLDSA.FIPS204.publicKey_matrix (s : Level) (bytes : List Byte) (matrix : PublicMatrix s) :
(publicKey s bytes matrix).A = matrix

Public-key decoding retains the matrix obtained from the published seed.

theorem Cslib.Crypto.MLDSA.FIPS204.decode_encodePublic (s : Level) (rho : FixedBytes 32) (A : PublicMatrix s) (t : Fin s.params.k → Poly) :
(publicKey s (encodePublic s rho.toList t) A).t = publicKeyHighTerm s.params 13 { A := A, t := t }

Decoding the public-key bytes recovers the dilated high vector 2^13 t₁ coefficientwise, including the upper endpoint 1023 in the ten-bit encoding.

Message representatives and commitment inputs #

The raw SHAKE256 input for the message representative, with its public-key hash prefix.

The 64-byte representative of a formatted bit string given the public-key hash tr.

@[reducible, inline]

FIPS 202 specialization of Xofs.representativeFromTr.

@[simp]

The message representative fits exactly in the 512-bit measured register.

SHAKE256 on BytesToBits(H(pk,64)) || M'. In particular a formatted message may end between two byte boundaries (Algorithm 8, lines 6–7).

@[reducible, inline]

FIPS 202 specialization of Xofs.messageRepresentative.

A module product on the canonical FIPS commitment grid is determined by its high bits.

Instances For

    SHAKE256 input in Algorithm 8, line 12, including the message representative and the fixed-width packing of the recovered high bits.

    Bit length of the 512-bit representative followed by FIPS 204's packed high bits. It is 6656 at ML-DSA-44 and -65, and 8704 at ML-DSA-87.

    Packing a commitment after a full message representative has the parameter-set bit width.

    The two SHAKE256 inputs in the FIPS challenge computation have different lengths: the 512-bit message representative is followed by a nonempty packed commitment, whereas the digest seed for Algorithm 29 occupies at most 512 bits.

    The message representative occupies the prefix of the Algorithm 8 preimage.

    def Cslib.Crypto.MLDSA.FIPS204.unpackCommitment (s : Level) (prefixLength : ℕ) (raw : List Bool) :
    Fin s.params.k → Fin 256 → ℤ

    Read the packed high-bit coefficients after a message prefix of the given bit length.

    theorem Cslib.Crypto.MLDSA.FIPS204.unpackCommitment_input {s : Level} {w : Fin s.params.k → Fin 256 → ℤ} (μ : List Bool) (hw : ∀ (i : Fin s.params.k) (j : Fin 256), 0 ≤ w i j ∧ w i j < ↑((s.params.q - 1) / (2 * s.params.γ₂))) :

    Unpacking the canonical FIPS address recovers each bounded high-bit coefficient.

    theorem Cslib.Crypto.MLDSA.FIPS204.eq_of_commitmentInput_eq {s : Level} {w v : Fin s.params.k → Fin 256 → ℤ} {μ : List Bool} (hw : ∀ (i : Fin s.params.k) (j : Fin 256), 0 ≤ w i j ∧ w i j < ↑((s.params.q - 1) / (2 * s.params.γ₂))) (hv : ∀ (i : Fin s.params.k) (j : Fin 256), 0 ≤ v i j ∧ v i j < ↑((s.params.q - 1) / (2 * s.params.γ₂))) (he : commitmentInput s w μ = commitmentInput s v μ) :
    w = v

    Fixed-width packing distinguishes all high-bit vectors in the range of UseHint.

    The full FIPS hash of the message representative and packed reconstructed commitment.

    @[reducible, inline]

    FIPS 202 specialization of Xofs.commitmentDigest.

    @[simp]

    The commitment hash has the parameter set's exact digest length.

    Algorithm 8 reconstructs the high commitment from the public key, response, hint and expanded challenge.

    Verification (Algorithms 3 and 8) #

    The pure-mode prefix in Algorithms 2 and 3, including the context length.

    Equal 512-bit representatives give equal full SHAKE256 outputs at the two raw inputs.

    @[simp]

    The byte verifier places exactly 512 message-representative bits before the commitment.

    theorem Cslib.Crypto.MLDSA.FIPS204.formatMessage_inj {m n : List Bool} {c d : List Byte} (hc : c.length ≤ 255) (hd : d.length ≤ 255) (h : formatMessage m c = formatMessage n d) :
    c = d ∧ m = n

    On the contexts allowed by Algorithm 3, the pure-mode prefix determines both the external context and the entire bit-string message, including a final incomplete byte.

    def Cslib.Crypto.MLDSA.FIPS204.verifyInternal (s : Level) (pk : List Byte) (formatted : List Bool) (signature : List Byte) :

    Algorithm 8 for a formatted message. Invalid encodings return some false, and the uniform Appendix C error for an exhausted SHAKE rejection stream is none.

    def Cslib.Crypto.MLDSA.FIPS204.Xofs.verifyWithExpansion (H : Xofs) (s : Level) (expand : List Byte → Option (PublicMatrix s)) (pk : List Byte) (message : List Bool) (ctx signature : List Byte) :

    Algorithm 3 with the public matrix expansion supplied at its call site. The context and signature checks, message hashing, challenge expansion, and full digest comparison are shared with the concrete verifier.

    @[reducible, inline]
    abbrev Cslib.Crypto.MLDSA.FIPS204.verifyWithExpansion (s : Level) (expand : List Byte → Option (PublicMatrix s)) (pk : List Byte) (message : List Bool) (ctx signature : List Byte) :

    FIPS 202 specialization of Xofs.verifyWithExpansion.

    theorem Cslib.Crypto.MLDSA.FIPS204.context_length_of_verifyWithExpansion {H : Xofs} {s : Level} {expand : List Byte → Option (PublicMatrix s)} {pk : List Byte} {msg : List Bool} {ctx sig : List Byte} (hv : H.verifyWithExpansion s expand pk msg ctx sig = some true) :
    ctx.length ≤ 255

    Acceptance by Xofs.verifyWithExpansion implies the Algorithm 3 context length bound.

    theorem Cslib.Crypto.MLDSA.FIPS204.verifyWithExpansion_encodePublic (s : Level) (expand : List Byte → Option (PublicMatrix s)) (rho : FixedBytes 32) (t : Fin s.params.k → Poly) (A : PublicMatrix s) (hA : expand rho.toList = some A) (msg : List Bool) (ctx sig : List Byte) :
    verifyWithExpansion s expand (encodePublic s rho.toList t) msg ctx sig = verifyWithExpansion s (fun (x : List Byte) => some A) (encodePublic s rho.toList t) msg ctx sig

    On freshly encoded public bytes, the verifier reads exactly the published seed. Once its matrix has been obtained from the shared oracle it can be reused in the digest check.

    def Cslib.Crypto.MLDSA.FIPS204.Xofs.verify (H : Xofs) (s : Level) (pk : List Byte) (message : List Bool) (ctx signature : List Byte) :

    Pure ML-DSA verification (Algorithm 3): format the context and the bit-string message, then run Algorithm 8. Contexts longer than 255 bytes return the specified error.

    theorem Cslib.Crypto.MLDSA.FIPS204.Xofs.verify_congr_of_reads {H G : Xofs} (s : Level) (pk : List Byte) (msg : List Bool) (ctx sig : List Byte) (matrix : H.expandA s (List.take 32 pk) = G.expandA s (List.take 32 pk)) (challenge : ∀ (d : List Byte), d.length = digestBytes s → H.sampleInBall s d = G.sampleInBall s d) (rep : ctx.length ≤ 255 → pk.length = 32 + 320 * s.params.k → H.messageRepresentative pk (formatMessage msg ctx) = G.messageRepresentative pk (formatMessage msg ctx)) (digest : ∀ (w : Fin s.params.k → Fin 256 → ℤ), H.commitmentDigest s w (G.messageRepresentative pk (formatMessage msg ctx)) = G.commitmentDigest s w (G.messageRepresentative pk (formatMessage msg ctx))) :
    H.verify s pk msg ctx sig = G.verify s pk msg ctx sig

    The two verifiers return the same Boolean or error if their matrix, bounded sparse challenge, message representative and final commitment digest agree. The representative needs to agree only for a well-formed context and public-key length.

    @[reducible, inline]
    abbrev Cslib.Crypto.MLDSA.FIPS204.verify (s : Level) (pk : List Byte) (message : List Bool) (ctx signature : List Byte) :

    FIPS 202 specialization of Xofs.verify.

    Expand the concrete FIPS commitment digest to a sparse challenge. The zero value on exhaustion is outside the challenge ball for every standard set.

    The byte-level forger chooses the context, message, and signature after seeing only the published key.

    • context : List Byte

      External context of at most 255 bytes for an accepted forgery.

    • message : List Bool

      Original bit-string message.

    • signature : List Byte

      Byte encoding of the purported signature.

    Algorithm 3 frames the context before the bit-string message.

    Acceptance by the byte verifier at a supplied matrix A, including the context and key length bounds, signature decoding, challenge expansion, response shortness, and full commitment-digest equality.

    theorem Cslib.Crypto.MLDSA.FIPS204.recovered_of_verifyWithExpansion {H : Xofs} {s : Level} {bytes : List Byte} {expand : List Byte → Option (PublicMatrix s)} {A : PublicMatrix s} {f : Forgery} (hA : expand (List.take 32 bytes) = some A) (hv : H.verifyWithExpansion s expand bytes f.message f.context f.signature = some true) :

    A verifying byte string determines a short response and the precise digest equality for the public vector decoded from the bytes. The calculation needs only that key and its matrix.

    theorem Cslib.Crypto.MLDSA.FIPS204.verifiedSignature_of_verifyWithExpansion {H : Xofs} {s : Level} {expand : List Byte → Option (PublicMatrix s)} {rho : FixedBytes 32} {A : PublicMatrix s} {t : Fin s.params.k → Poly} {f : Forgery} (hA : expand rho.toList = some A) (hv : H.verifyWithExpansion s expand (encodePublic s rho.toList t) f.message f.context f.signature = some true) :

    A successful byte verification on a published (ρ,t₁) determines the parsed signature, its sparse challenge, the response bound, and the complete FIPS digest equality, expressed using the rounded high term of the original full vector t.

    theorem Cslib.Crypto.MLDSA.FIPS204.verifyWithExpansion_of_recovered {H : Xofs} {s : Level} {expand : List Byte → Option (PublicMatrix s)} {rho : FixedBytes 32} {A : PublicMatrix s} {t : Fin s.params.k → Poly} {f : Forgery} {σ : Signature s} {c : Poly} (hA : expand rho.toList = some A) (hctx : f.context.length ≤ 255) (hσ : sigDecode s f.signature = some σ) (hc : H.sampleInBall s σ.digest = some c) (hz : ResponseShort s.params σ.z) (hd : H.commitmentDigest s (fun (i : Fin s.params.k) => useHintVec s.params.q s.params.γ₂ (σ.h i) (compressedVerifierCommitment s.params 13 { A := A, t := t } σ.z c i)) (H.messageRepresentative (encodePublic s rho.toList t) (formattedMessage f)) = σ.digest) :

    Positive verification direction for an encoded public key and the verifier's exact digest check. This also covers fixed, externally supplied matrix expansions.

    Self-target witness extraction and reduction #

    Extraction for a full challenge (A,t). The published bytes and message representative use the rounded key, while the witness computed from the full key includes the term c t₀ in the low vector (Dilithium v3.1, §6.2.1, equation (10)).

    Check a corrected short witness on the original raw FIPS streams. Recover the complete commitment digest only when the representative is 512 bits, the product is on the commitment grid, the low part and response obey the extraction bound, and Algorithm 29 returns the witness challenge. An exhausted expansion fails the check.

    A raw opening is equivalent to a short-vector solution on the canonical grid, with the exact commitment digest and a successful sparse expansion at that digest.

    An accepting byte signature gives a short witness whose raw opening recovers exactly the digest bytes in that signature. The matrix at the public seed and the full public vector are those of the lattice pair supplied to the extractor.

    Every accepted byte forgery yields a solution on the full vector supplied by the challenge.

    For each fixed published byte key, the solver parses the forgery and extracts a self-target candidate. The hash input contains its actual public-key-bound message representative.

    Self-target acceptance for a solver on a published byte key. The experiment constructs its own challenge matrix from that key's seed and rounded coefficients.

    theorem Cslib.Crypto.MLDSA.FIPS204.solves_extract_of_verify {s : Level} {bytes : List Byte} {f : Forgery} (hv : verify s bytes f.message f.context f.signature = some true) :
    (solves s bytes fun (matrix : PublicMatrix s) => extract s bytes matrix f) = true

    Acceptance by the FIPS byte verifier implies self-target acceptance for the extracted candidate on the same published key, including its matrix seed.

    noncomputable def Cslib.Crypto.MLDSA.FIPS204.Xofs.keyExperiment (H : Xofs) (s : Level) (run : KeyPair → Game) :

    Draw one uniform 32-byte seed and run an experiment under the resulting Algorithm 6 key pair. A key-generation failure is an unsuccessful trial.

    @[reducible, inline]
    noncomputable abbrev Cslib.Crypto.MLDSA.FIPS204.keyExperiment (s : Level) (run : KeyPair → Game) :

    Seeded key-generation experiment with the FIPS 202 XOFs.

    FIPS 204 key-only forgery: draw the uniform key-generation seed, give the generated public-key bytes to the adversary, and run Algorithm 3 on its context, message and signature.

    Self-target success for the solver extracted from the byte-key forger, on the seeded matrix and lifted public vector that the verifier can compute from the published key.

    The finite success bound under the Algorithm 6 seed law and Algorithm 3 verification. The right-hand game tests the actual extracted candidate under that same seeded public key. Replacing this seeded target by standard uniform-matrix hardness is a separate reduction.

    Expand an oracle's fixed-length commitment digest by Algorithm 29, including XOF exhaustion at the Appendix C limit.

    theorem Cslib.Crypto.MLDSA.FIPS204.selfTarget_digest_fork (s : Level) (Q : ℕ) {Coins : Type} (matrices : PMF (Matrix (Fin s.params.k) (Fin (s.params.k + s.params.ℓ + 1)) Poly)) (coins : PMF Coins) (adv : ModuleSIS.SelfTarget.Adversary s.params.k (s.params.k + s.params.ℓ) 256 8380417 (FixedBytes (digestBytes s)) Coins) (hQ : ∀ (A : Matrix (Fin s.params.k) (Fin (s.params.k + s.params.ℓ + 1)) (Fin 256 → ZMod 8380417)) (r : Coins), (adv A r).IsQueryBounded Q) :
    have radius := compressedSelfTargetRadius s.params 13; ((matrices.bind (ModuleSIS.SelfTarget.game (expandDigest s) radius coins adv)) true).toReal ≤ ↑(Q + 1) / 256 ^ digestBytes s + √(↑(Q + 1) * ((matrices.bind fun (A : Matrix (Fin s.params.k) (Fin (s.params.k + s.params.ℓ + 1)) Poly) => PMF.map (fun (w : Fin (s.params.k + s.params.ℓ + 1) → Fin 256 → ℤ) => decide (ModuleSIS.IsSolution A (2 * radius) w)) (ModuleSIS.SelfTarget.reductionLaw 0 (expandDigest s) radius Q coins adv A)) true + ModuleSIS.SelfTarget.collisionMass (expandDigest s)).toReal)

    Classical self-target forking for the three FIPS parameter sets, in the model where a fresh commitment query returns a uniform digest. Algorithm 29 acts on those digest bytes. The collision term is the largest distinct-digest collision probability of the fixed SHAKE256 expansion; the library gives it only the trivial bound of one.