Documentation

CslibFrontier.Crypto.Computational.MLDSA.QuantumSigningPrefix

Refreshing a signing digest after adaptive quantum and signing queries #

The prefix can measure the adversary's state, answer measured signing calls and resume coherent XOR queries on the same digest table. Capped signing uses Algorithm 7's actual ExpandMask loop. All SHAKE256 roles read the same prefix-consistent XOF, including calls to expand masks and challenges that are eventually rejected.

At the distinguished attempt an independent uniform signing mask is drawn after the representative has been chosen. The retained mask and digest go through SampleInBall, the response and hint checks, and signature encoding. Refreshing the digest for the attempt and all subsequent operations costs the prefix's query disturbance times the FIPS commitment entropy factor. For an erased rejected write, a second bound counts future signer queries and the following measured quantum interaction without revealing the rejected mask. The numerical estimate averages over a uniform coefficient matrix and a fresh independent mask at the distinguished trial. The joint seeded key and ExpandMask law and the full reduction are tracked in #4987 and #5683.

The single-trial bound is an original finite-query estimate. Rejected-transcript oracle entries are central to the CMA-to-NMA arguments of [BBD+23] and [FFH25].

@[reducible, inline]

Capped FIPS signatures have exactly this finite outward register, including the error.

noncomputable def Cslib.Crypto.MLDSA.FIPS204.sharedXofs (s : Level) (extra : Finset (List Bool)) (base : Xofs) (table : ↥(commitmentAddresses s extra) → DigestRegister s) :

Install one digest-sized prefix per raw input in the finite quantum register. Bytes after the installed prefix, raw inputs outside the register and the SHAKE128 component come from the supplied XOFs. Requests from different protocol roles share the installed prefix.

The literal digest register values of any chosen SHAKE256 stream.

theorem Cslib.Crypto.MLDSA.FIPS204.sharedXofs_digestTable (s : Level) (extra : Finset (List Bool)) (base : Xofs) :
sharedXofs s extra base (Xofs.digestTable s extra base) = base

Filling the finite register from the underlying stream preserves the entire pair of XOFs at every raw input and requested length, including at literal FIPS SHAKE.

theorem Cslib.Crypto.MLDSA.FIPS204.commitmentDigest_sharedXofs (s : Level) (extra : Finset (List Bool)) (base : Xofs) (T : ↥(commitmentAddresses s extra) → DigestRegister s) (m : BitString 512) (w : Fin s.params.k → Poly) :
(sharedXofs s extra base T).commitmentDigest s (highBitsVec s.params w) (List.ofFn m) = registerBytes s (T (commitmentAddress s extra m w))

At the actual commitment input every use of SHAKE256 reads precisely the digest in the coherent register, even when another protocol role has used that raw input.

noncomputable def Cslib.Crypto.MLDSA.FIPS204.read256 (s : Level) (extra : Finset (List Bool)) (base : Xofs) (q : ExtendableOutput.Request) :
OracleComp (fun (x : ↥(commitmentAddresses s extra)) => DigestRegister s) (List Byte)

Serve a raw SHAKE256 read by consulting the coherent table once for its stored digest prefix and using the fixed underlying XOF bytes for the rest.

A raw SHAKE256 read needs at most one query to the shared digest-prefix register.

Interpreting any adaptive raw SHAKE256 program using the finite table agrees with evaluating that program against the resulting shared, prefix-consistent XOF.

noncomputable def Cslib.Crypto.MLDSA.FIPS204.signingRequestQueries (s : Level) (extra : Finset (List Bool)) (base : Xofs) (key : List Byte) (q : SigningQuery) (rnd : FixedBytes 32) :
OracleComp (fun (x : ↥(commitmentAddresses s extra)) => DigestRegister s) (SigningReply s)

A signing request on the same raw SHAKE256 table as coherent queries. The finite reply register carries the entire encoded signature or the FIPS error.

theorem Cslib.Crypto.MLDSA.FIPS204.evalPure_signingRequestQueries (s : Level) (extra : Finset (List Bool)) (base : Xofs) (T : ↥(commitmentAddresses s extra) → DigestRegister s) (key : List Byte) (q : SigningQuery) (rnd : FixedBytes 32) :
Option.map FixedBytes.toList (OracleComp.evalPure T (signingRequestQueries s extra base key q rnd)) = (sharedXofs s extra base T).sign s key q.message q.context rnd

At every table, the measured request returns exactly Algorithm 2's bytes under the shared pair of XOFs, including malformed inputs, XOF exhaustion and exhausting the retry cap.

@[reducible, inline]

A retained-state interaction with a finite classical outward history and a coherent FIPS digest register over raw bit-string inputs.

noncomputable def Cslib.Crypto.MLDSA.FIPS204.measuredSigningCall (s : Level) (extra : Finset (List Bool)) {B W : Type} [Fintype B] [Fintype W] (p : SigningInteraction s extra W B) (base : Xofs) (key : B → List Byte) (request : B → SigningQuery) (rnd : B → FixedBytes 32) :

Append the actual external signing service to an interaction. Each message and context can depend on all previous measurements and complete signing replies. The explicit hedging tape may be fixed first and averaged independently.

@[simp]
theorem Cslib.Crypto.MLDSA.FIPS204.updateCost_measuredSigningCall (s : Level) (extra : Finset (List Bool)) {B W : Type} [Fintype B] [Fintype W] (p : SigningInteraction s extra W B) (base : Xofs) (key : B → List Byte) (request : B → SigningQuery) (rnd : B → FixedBytes 32) :

The measured call charges the two initial SHAKE256 reads and at most ℓ + 2 per trial.

noncomputable def Cslib.Crypto.MLDSA.FIPS204.completeSigningTrial (s : Level) (extra : Finset (List Bool)) (base : Xofs) (sk : PrivateKey s) (A : PublicMatrix s) (T : ↥(commitmentAddresses s extra) → DigestRegister s) (m : BitString 512) (seed : List Byte) (fuel nonce : ℕ) (y : Fin s.params.ℓ → Poly) :

Finish a signing request from the current mask. The mask determines the commitment; the selected XOF table determines the digest, the challenge expansion and all retries.

theorem Cslib.Crypto.MLDSA.FIPS204.completeSigningTrial_expandMask (s : Level) (extra : Finset (List Bool)) (base : Xofs) (sk : PrivateKey s) (A : PublicMatrix s) (T : ↥(commitmentAddresses s extra) → DigestRegister s) (m : BitString 512) (seed : List Byte) (fuel nonce : ℕ) :
have H := sharedXofs s extra base T; Option.map FixedBytes.toList (completeSigningTrial s extra base sk A T m seed fuel nonce (ringVectorCoeffs (H.expandMask s seed nonce))) = OracleComp.evalPure (ExtendableOutput.Request.answer H.h256) (signingQueries s sk A (List.ofFn m) seed id (fuel + 1) nonce)

Supplying the mask derived from the real seed and nonce recovers the entire remaining Algorithm 7 loop, including errors and all subsequent retries. The fresh ideal mask in the refresh estimate replaces exactly this value.

The three commitment-table treatments for the distinguished trial.

  • ambient : TrialRefresh

    Read the ambient table.

  • persistent : TrialRefresh

    Overwrite this entry and keep it on every outcome.

  • eraseRejected : TrialRefresh

    Overwrite, and restore the previous entry if the mask is rejected and the signer retries.

noncomputable def Cslib.Crypto.MLDSA.FIPS204.signingAttemptRefreshProbability (s : Level) (extra : Finset (List Bool)) {B W O : Type} [Fintype B] [Fintype W] [Fintype O] (refresh : TrialRefresh) (base : Xofs) (A : PublicMatrix s) (sk : B → PrivateKey s) (p : SigningInteraction s extra W B) (ψ : Quantum.ValueState (↥(commitmentAddresses s extra)) (DigestRegister s) W) (msg : B → BitString 512) (seed : B → List Byte) (fuel nonce : ℕ) (next : B → SigningReply s → SigningInteraction s extra W O) (accept : B → SigningReply s → Finset (O × ↥(commitmentAddresses s extra) × DigestRegister s × W)) :

Final decision after a measured interaction, one distinguished fresh-mask trial, the remaining capped signing trials and an adaptive measured continuation. Only the complete signing reply reaches the adversary. The distinguished trial uses the key recorded by its prefix. The mode selects the table for retries and later queries.

theorem Cslib.Crypto.MLDSA.FIPS204.abs_mean_signingAttemptRefreshProbability_sub_le (s : Level) (extra : Finset (List Bool)) {B W O : Type} [Fintype B] [Fintype W] [Fintype O] (base : PublicMatrix s → Xofs) (sk : PublicMatrix s → B → PrivateKey s) (p : PublicMatrix s → SigningInteraction s extra W B) (ψ : PublicMatrix s → Quantum.ValueState (↥(commitmentAddresses s extra)) (DigestRegister s) W) (msg : PublicMatrix s → B → BitString 512) (seed : PublicMatrix s → B → List Byte) (fuel nonce : ℕ) (next : PublicMatrix s → B → SigningReply s → SigningInteraction s extra W O) (accept : PublicMatrix s → B → SigningReply s → Finset (O × ↥(commitmentAddresses s extra) × DigestRegister s × W)) {C F : ℝ} (hψ : ∀ (A : PublicMatrix s), ‖ψ A‖ = 1) (budget : ∀ (A : PublicMatrix s), Quantum.MeasuredPrefix.updateCost (p A) ≤ C) (future : ∀ (A : PublicMatrix s) (b : B) (r : SigningReply s), Quantum.MeasuredPrefix.updateCost (next A b r) ≤ F) :
|(Finset.univ.expect fun (A : PublicMatrix s) => signingAttemptRefreshProbability s extra TrialRefresh.eraseRejected (base A) A (sk A) (p A) (ψ A) (msg A) (seed A) fuel nonce (next A) (accept A)) - Finset.univ.expect fun (A : PublicMatrix s) => signingAttemptRefreshProbability s extra TrialRefresh.ambient (base A) A (sk A) (p A) (ψ A) (msg A) (seed A) fuel nonce (next A) (accept A)| ≤ (C + √(↑((s.params.ℓ + 2) * fuel) + F ^ 2)) * (11 / 10 / √(2 ^ s.commitmentBoxBits))

Compare an honest read with a fresh digest that persists only on a terminal trial. On mask rejection the digest is restored before the signer retries. Earlier measured signing calls, coherent reads, the remaining retries and the actual adaptive continuation all contribute to the bound. The coefficient matrix is uniformly sampled at the designated FIPS level.