Documentation

CslibFrontier.Crypto.Computational.MLDSA.SigningMaskSeeds

Coupling the mask-seed reads of all signing requests to the shared SHAKE256 oracle #

FIPS 204, Algorithm 6 line 1 derives the 32-byte private signing seed from a 272-bit input. Algorithm 7 line 7 reads the first 64 bytes from a 1024-bit input containing that component, a 32-byte hedge and the message representative. For distinct hedges, all such inputs admit independent 64-byte values in the same raw oracle. The quantum device can query this table before a signing request determines its representative.

@[reducible, inline]

The 64-byte mask seed for each signing slot and each possible 512-bit representative.

Two joint raw XOF pairs. The background supplies the ordinary byte table. The shared pair uses the supplied mask seeds at the selected Algorithm 7 addresses.

  • background : Xofs

    The pair before installing the selected seed values.

  • shared : Xofs

    The pair exposed to both the forger and the honest algorithms in the exact coupling.

noncomputable def Cslib.Crypto.MLDSA.FIPS204.Xofs.sampleSigningMaskSeeds (base : Xofs) (s : Level) (seed : FixedBytes 32) {a b n : ℕ} (t : Fin n ↪ FixedBytes 32) (ha : 1024 ≤ a) (hb : 64 ≤ b) (rows : SigningMaskSeeds n) :

Sample raw SHAKE tables, derive the private key component at the Algorithm 6 input, then install the supplied 64-byte values for every slot and every possible message representative. The experiment retains both the background oracle and the shared signing oracle.

theorem Cslib.Crypto.MLDSA.FIPS204.read_of_mem_sampleSigningMaskSeeds {base : Xofs} {s : Level} {seed : FixedBytes 32} {a b n : ℕ} {t : Fin n ↪ FixedBytes 32} {ha : 1024 ≤ a} {hb : 64 ≤ b} {rows : SigningMaskSeeds n} {pair : SigningMaskSeedOracles} (h : pair ∈ (base.sampleSigningMaskSeeds s seed t ha hb rows).support) (i : Fin n) (μ : BitString 512) :
pair.shared.h256.read (maskSeedInput (List.drop 96 (pair.shared.expandKeySeed s seed)) (t i) (List.ofFn μ)) 64 = (rows (i, μ)).toList

Algorithm 7 reads exactly the assigned mask seed at each programmed address. The private key component in that address is derived on the shared XOF through Algorithm 6.

theorem Cslib.Crypto.MLDSA.FIPS204.agree_off_sampleSigningMaskSeeds {base : Xofs} {s : Level} {seed : FixedBytes 32} {a b n : ℕ} {t : Fin n ↪ FixedBytes 32} {ha : 1024 ≤ a} {hb : 64 ≤ b} {rows : SigningMaskSeeds n} {pair : SigningMaskSeedOracles} (h : pair ∈ (base.sampleSigningMaskSeeds s seed t ha hb rows).support) :
pair.shared.h128 = pair.background.h128 ∧ ∀ (x : List Bool) (j : ℕ), (64 ≤ j ∨ ∀ (i : Fin n) (μ : BitString 512), maskSeedInput (List.drop 96 (pair.background.expandKeySeed s seed)) (t i) (List.ofFn μ) ≠ x) → pair.shared.h256.byteAt x j = pair.background.h256.byteAt x j

Exactly where the coherent oracles can differ: SHAKE128 agrees everywhere, and SHAKE256 agrees after byte 63 and at every other raw input. The key in the selected addresses can be read from the background oracle before installing the rows.

theorem Cslib.Crypto.MLDSA.FIPS204.keyGen_eq_of_mem_sampleSigningMaskSeeds {base : Xofs} {s : Level} {seed : FixedBytes 32} {a b n : ℕ} {t : Fin n ↪ FixedBytes 32} {ha : 1024 ≤ a} {hb : 64 ≤ b} {rows : SigningMaskSeeds n} {pair : SigningMaskSeedOracles} (h : pair ∈ (base.sampleSigningMaskSeeds s seed t ha hb rows).support) (level : Level) (setup : FixedBytes 32) :
pair.shared.keyGen level setup = pair.background.keyGen level setup

The original and the shared oracles produce identical FIPS key bytes, including on key-generation failures. The setup seed here can be chosen independently of the one used to locate the installed rows.

theorem Cslib.Crypto.MLDSA.FIPS204.Xofs.background_sampleSigningMaskSeeds (base : Xofs) (s : Level) (seed : FixedBytes 32) {a b n : ℕ} (t : Fin n ↪ FixedBytes 32) (ha : 1024 ≤ a) (hb : 64 ≤ b) (rows : SigningMaskSeeds n) :

For each supplied seed table, the background oracle is still the original random XOF pair.

Resampling all selected Algorithm 7 seeds at once preserves the law of the complete shared raw oracle for each fixed key-generation seed and each fixed injective hedge tape.

theorem Cslib.Crypto.MLDSA.FIPS204.Xofs.prob_representative_ne_sampleSigningMaskSeeds (base : Xofs) (s : Level) (seed : FixedBytes 32) {a b n : ℕ} (ha : 1024 ≤ a) (hb : 64 ≤ b) (hn : n ≤ 2 ^ 256) (rows : SigningMaskSeeds n) :
(((Probability.PMF.uniformOfFintype (Fin n ↪ FixedBytes 32)).bind fun (t : Fin n ↪ FixedBytes 32) => base.sampleSigningMaskSeeds s seed t ha hb rows).toOuterMeasure {pair : SigningMaskSeedOracles | ∃ (keys : KeyPair), pair.background.keyGen s seed = some keys ∧ ∃ (formatted : List Bool), pair.shared.messageRepresentative keys.publicKey formatted ≠ pair.background.messageRepresentative keys.publicKey formatted}).toReal ≤ ↑n / 2 ^ 256

For each setup seed and supplied table of mask seeds, with a uniformly drawn injective hedge tape, the chance that installing the mask seeds changes the message representative for any formatted input under the generated key is at most n / 2^256. This covers messages chosen after any number of signing replies or measurements.

noncomputable def Cslib.Crypto.MLDSA.FIPS204.QuantumSigningForger.maskSeedGame (C : QuantumSigningForger) (s : Level) (base : Xofs) {a b n : ℕ} (ha : 1024 ≤ a) (hb : 64 ≤ b) (_hn : C.SigningCallsLe n) (hsize : n ≤ 2 ^ 256) (deviceSeesRows : Bool) (score : SignedMatrixTrial s → Bool) :

The two mask-seed experiments for the signed-game comparison. Key generation uses the background table, and the signer and scorer use the shared table. With deviceSeesRows = true the device reads the shared table. With false it reads the background throughout its execution. The same setup seed and tape determine the installed addresses and the actual signing run.

theorem Cslib.Crypto.MLDSA.FIPS204.QuantumSigningForger.shared_maskSeedGame_eq_distinctHedgeGame (C : QuantumSigningForger) (s : Level) (base : Xofs) {a b n : ℕ} (ha : 1024 ≤ a) (hb : 64 ≤ b) (hn : C.SigningCallsLe n) (hsize : n ≤ 2 ^ 256) (score : SignedMatrixTrial s → Bool) :
C.maskSeedGame s base ha hb hn hsize true score = C.distinctHedgeGame s base a b hn hsize score

Installing all mask-seed rows before the adaptive quantum interaction preserves the entire signed-trial event law of the distinct-hedge game. This is the shared-device side of the comparison with a background-only device.