Documentation

CslibFrontier.Crypto.Computational.MLDSA.DigestSigningQueries

Commitment-table queries of a complete FIPS 204 signing request #

After fixing the background SHAKE streams and hedge, the signer needs at most one commitment-table lookup per retry and one for the representative. Its mask seed, per-nonce masks and sparse challenge expansion use other input lengths. The program below returns the bytes or error of [NIST24a], Algorithms 2 and 7. The query count concerns the register of commitment-length SHAKE256 prefixes. Local computation and reads of the fixed background streams are free.

@[reducible, inline]

Classical oracle programs on the raw SHAKE256 commitment-length digest prefixes.

def Cslib.Crypto.MLDSA.FIPS204.Xofs.retryDigestQueries (H : Xofs) (s : Level) (sk : PrivateKey s) (A : PublicMatrix s) (μ : List.Vector Bool 512) (mask : ℕ → Vector (Vector (ZMod 8380417) 256) s.params.ℓ) (fuel nonce : ℕ) :

Run the remaining FIPS signing attempts with a supplied mask schedule. Each retry consults the table on the literal commitment input. The other SHAKE reads use the background streams.

theorem Cslib.Crypto.MLDSA.FIPS204.Xofs.retryDigestQueries_bounded (H : Xofs) (s : Level) (sk : PrivateKey s) (A : PublicMatrix s) (μ : List.Vector Bool 512) (mask : ℕ → Vector (Vector (ZMod 8380417) 256) s.params.ℓ) (fuel nonce : ℕ) :
OracleComp.IsQueryBounded (H.retryDigestQueries s sk A μ mask fuel nonce) fuel

The retry program makes at most one digest lookup per available attempt.

The full 814-attempt native signer with any fixed mask schedule computes exactly the table program's reply. Sparse-challenge exhaustion and reaching the retry cap both return error.

def Cslib.Crypto.MLDSA.FIPS204.Xofs.signDigestQueriesWithMask {α : Type} (H : Xofs) (s : Level) (key : List Byte) (q : SigningQuery) (prepare : PrivateKey s → List Bool → α) (expand : α → ℕ → Vector (Vector (ZMod 8380417) 256) s.params.ℓ) :

A signing request on the digest register. Prepare the mask seed or row once from the decoded key and message representative, then expand the mask at each retry counter. The representative query keeps the SHAKE256 suffix beyond the digest prefix when its input has commitment length.

A full hedged FIPS signing request with its mask seed derived from the key, hedge, and representative and its per-counter masks generated by Algorithm 34.

theorem Cslib.Crypto.MLDSA.FIPS204.Xofs.signDigestQueriesWithMask_bounded {α : Type} (H : Xofs) (s : Level) (key : List Byte) (q : SigningQuery) (prepare : PrivateKey s → List Bool → α) (expand : α → ℕ → Vector (Vector (ZMod 8380417) 256) s.params.ℓ) :

One representative query and the 814-trial cap bound every mask schedule, including the schedule derived from a native hedge and a schedule decoded from a supplied expansion row.

A native hedge selects one mask schedule and hence has the same 815-query bound.

theorem Cslib.Crypto.MLDSA.FIPS204.Xofs.evalPure_signDigestQueriesWithMask {α : Type} (H : Xofs) (s : Level) (D : BitString s.commitmentInputBits → BitString (8 * digestBytes s)) (key : List Byte) (q : SigningQuery) (prepare : PrivateKey s → List Bool → α) (expand : α → ℕ → Vector (Vector (ZMod 8380417) 256) s.params.ℓ) :
OracleComp.evalPure D (H.signDigestQueriesWithMask s key q prepare expand) = do guard (q.context.length ≤ 255) let sk ← decodePrivate s key have G : Xofs := H.withDigestRegister s D let A ← G.expandA s sk.rho have μ : List Bool := G.representativeFromTr sk.tr (formatMessage q.message q.context) G.signingRetries s sk A μ (expand (prepare sk μ))

The register interpreter runs the FIPS signing retries on the installed streams with the chosen mask schedule. It returns an error for an overlong context, invalid key, or failed matrix expansion before entering those retries.

Evaluating the bounded program under the installed register returns the actual FIPS signature bytes or error, for any signing request and each fixed hedge.

The native signing service samples one hedge, executes the bounded register program, and appends exactly the successful replies to the strong-forgery log.

Run the full FIPS verifier on the digest register. Only the representative and the recomputed commitment can consult an installed row. Invalid encodings reject and exhausted matrix or sparse-challenge expansions return the FIPS error.

Two classical digest-table queries suffice to evaluate a candidate forgery, including a representative input that itself has the commitment length.

The two-read verifier preserves all three possible FIPS results at the installed raw XOFs.

Raw SHAKE256 address chosen by an ML-DSA mask after the representative has been fixed.

Packing the real mask commitment into SHAKE input bits preserves the largest-atom bound for its rounded product. This holds for every fixed coefficient matrix.

Changing the entry at a fresh mask commitment can affect one whole native signing reply with probability at most 815 times the largest rounded-commitment atom. The digest written there may depend on the mask. The message being signed may use a different representative from the one used to draw the changed address.

A fresh mask commitment can change a completed candidate's verification result with probability at most twice the largest rounded-commitment atom. This includes errors and the raw representative lookup used for adaptive messages.