Documentation

CslibFrontier.Crypto.Computational.MLDSA.PublicPairSigning

Public-pair signing after refreshing masks and commitment digests #

Barbosa et al., Figure 7, construct an accepting-transcript simulator from the full pair (A,t). Here the forger receives the rounded FIPS public-key bytes and retains its quantum register across queries and classical signing requests. In the compared hybrid every attempt draws an independent ideal mask and digest. A norm or hint rejection leaves the raw table unchanged. A signature or Algorithm 29 exhaustion writes the new digest at the full commitment input. This implementation chooses the minimum limits permitted by [NIST24a], Appendix C, Table 3, of 814 signing attempts and 221 challenge-expansion bytes.

The exact comparison below starts after those replacements. Bounding the cost of refreshing actual seeded masks and digests in the device's prior quantum state is a separate game hop.

Replace the specified commitment's SHAKE256 prefix, preserving the suffix, the other SHAKE256 input rows and the SHAKE128 stream.

theorem Cslib.Crypto.MLDSA.FIPS204.Xofs.sampleInBall_writeCommitment (s : Level) (H : Xofs) (μ : List Bool) (hμ : μ.length = 512) (w : Fin s.params.k → Fin 256 → ℤ) (value : List Byte) (d : FixedBytes (digestBytes s)) :

A write at a commitment input leaves the complete bounded expansion of every digest unchanged. The FIPS input lengths separate these roles at all three parameter sets.

One raw commitment write retained when a signing attempt terminates its request.

  • request : SigningQuery

    The measured request that caused the write.

  • point : Fin s.params.k → Fin 256 → ℤ

    High-order commitment coefficients of this attempt.

  • address : List Bool

    Actual untagged SHAKE256 commitment input.

  • digest : FixedBytes (digestBytes s)

    Digest installed at this address.

  • reply : Option (List Byte)

    A signature, or the public error following expansion exhaustion.

Chronological signing writes starting at base. Each address contains the message representative read from the current table using the public-key hash stored at setup.

theorem Cslib.Crypto.MLDSA.FIPS204.TerminalSigningWrite.History.read_publicKey {s : Level} {base G : Xofs} {tr : List Byte} {writes : List (TerminalSigningWrite s)} (history : History s base tr writes G) (rho : FixedBytes 32) (t : Fin s.params.k → Poly) (n : ℕ) :

Every terminal commitment update leaves the encoded FIPS public key's raw SHAKE256 stream unchanged. This includes fatal signing requests.

theorem Cslib.Crypto.MLDSA.FIPS204.TerminalSigningWrite.History.read_representative {s : Level} {base G : Xofs} {tr : List Byte} {writes : List (TerminalSigningWrite s)} (history : History s base tr writes G) (ht : tr.length = 64) (miss : ∀ w ∈ writes, base.h256.read (representativeInput tr (formatMessage w.request.message w.request.context)) 64 ≠ tr) (formatted : List Bool) (n : ℕ) :
G.h256.read (representativeInput tr formatted) n = base.h256.read (representativeInput tr formatted) n

If the ambient oracle has no representative equal to the stored public-key hash on a terminal signing request, every representative read, including final verification, sees the ambient stream. Requests may have been chosen after earlier writes and coherent queries.

A signing experiment at the original FIPS seeded law of (ρ,A,t). A setup error returns false. The continuation receives the matrix and full vector before public-key rounding.

theorem Cslib.Crypto.MLDSA.FIPS204.Xofs.fullPairExperiment_eq_expand (H : Xofs) (s : Level) (run : FixedBytes 32 → PublicKey s.params → Game) :
H.fullPairExperiment s run = (Probability.PMF.uniformOfFintype (FixedBytes 32)).bind fun (seed : FixedBytes 32) => have ex := H.expandKeySeed s seed; have rho := List.take 32 ex; (do let A ← H.expandA s rho let __x ← H.expandS s (List.take 64 (List.drop 32 ex)) match __x with | (x, e) => pure (run (fun (i : Fin 32) => rho[↑i]!) { A := A, t := ModuleLWE.sample A x e })).getD (PMF.pure false)

Draw the FIPS seed and form the unrounded pair directly from the two expansions of Algorithm 6. This is the same experiment as generating and decoding the private and public key bytes.

The final shared XOFs, public bytes, forgery and successful signing log, together with writes on fatal expansions and the complete residual quantum device.

An accepted forgery's digest differs from every terminal write on which a previous call returned the expansion error, even if other signing calls changed the table in between.

A winning fresh digest differs from every digest installed by the simulator. Successful writes appear in the signed log; fatal writes remain failed Algorithm 29 inputs.

Run the public-pair signing simulator on an externally supplied (A,t) and matrix seed. Only the rounded encoded key reaches the forger. Every terminal commitment write is visible to all subsequent raw queries and to the final verifier.

theorem Cslib.Crypto.MLDSA.FIPS204.QuantumSigningForger.publicPairSigning_key_of_mem {C : QuantumSigningForger} {s : Level} {base : Xofs} {rho : FixedBytes 32} {pair : PublicKey s.params} {result : C.ProgrammedSigningResult s base} (hr : result ∈ (C.publicPairSigning s base rho pair).support) :
result.trial.publicKey = encodePublic s rho.toList pair.t ∧ result.tr = base.h256.readBytes result.trial.publicKey 64

The external public pair determines the rounded key given to the forger and the stored key hash used by every request, including after earlier raw writes.

The refreshed signing hybrid initialized from generated byte keys. The signing service uses their decoded private fields, its stored public-key hash and the expanded matrix. It draws an ideal mask and digest at each attempt and retains terminal commitment writes.

For a generated FIPS key, both services induce the same joint law of the forgery, residual device, successful signing log, terminal writes and final shared XOFs. The pair on the public side is the matrix and full public vector of the generated key.

theorem Cslib.Crypto.MLDSA.FIPS204.QuantumSigningForger.freshMask_newDigestGame_eq_publicPair (C : QuantumSigningForger) (s : Level) (base : Xofs) (a b : ℕ) :
((base.uniformPrefixes a b).bind fun (H : Xofs) => H.keyExperiment s fun (keys : KeyPair) => PMF.map (fun (x : Option (C.ProgrammedSigningResult s H)) => Option.any (fun (r : C.ProgrammedSigningResult s H) => r.trial.newDigestWin) x) (C.freshMaskSigning s H keys)) = (base.uniformPrefixes a b).bind fun (H : Xofs) => H.fullPairExperiment s fun (ρ : FixedBytes 32) (pair : PublicKey s.params) => PMF.map (fun (r : C.ProgrammedSigningResult s H) => r.trial.newDigestWin) (C.publicPairSigning s H ρ pair)

Fresh-digest winning game for the ideal-mask, fresh-digest signing hybrid: replace its secret-dependent byte signing service by the public-pair simulator. Both sides first sample the finite raw SHAKE streams and the FIPS key seed. Final verification runs on the actual XOFs left by signing. This equality preserves the fatal errors and the 814-attempt cutoff.

theorem Cslib.Crypto.MLDSA.FIPS204.QuantumSigningForger.publicPairSigning_match_of_changed_representative {C : QuantumSigningForger} {s : Level} {base : Xofs} {rho : FixedBytes 32} {pair : PublicKey s.params} {result : C.ProgrammedSigningResult s base} (hr : result ∈ (C.publicPairSigning s base rho pair).support) (formatted : List Bool) (changed : result.trial.xofs.messageRepresentative result.trial.publicKey formatted ≠ base.messageRepresentative result.trial.publicKey formatted) :
have tr := base.h256.readBytes result.trial.publicKey 64; have addr := fun (w : TerminalSigningWrite s) => representativeInput tr (formatMessage w.request.message w.request.context); ∃ (w : TerminalSigningWrite s), List.find? (fun (z : TerminalSigningWrite s) => base.h256.read (addr z) 64 == tr) result.writes = some w ∧ base.h256.read (addr w) 64 = tr

A changed message representative in a real output of the public-pair simulator yields a terminal request whose representative in the original oracle equals the original public-key hash. The search checks fatal and successful writes in order.