Documentation

CslibFrontier.Crypto.Computational.MLDSA.SharedSecretExpansion

Coupling private and shared ML-DSA key expansion #

FIPS 204, Algorithm 6, derives both a 32-byte public matrix seed and a 64-byte secret expansion seed from one SHAKE256 read. Algorithm 33 reads the rows of both short vectors at that second seed with successive two-byte counters. The same inputs are available to the forger through its quantum XOF interface.

QuantumSigningForger.secretExpansionViews_games expresses both online games as continuations of one random setup. Resampling the secret rows preserves the whole oracle distribution because their 528-bit addresses differ from the 272-bit input that determines those addresses. SecretExpansionViews.agree_of_mem locates every byte at which the two online oracles can differ.

The coupled FIPS setup before the signing adversary runs. Both games receive the same public seed and pair. The distinguishing experiment determines which oracle they read.

  • shared : Xofs

    Raw XOFs with the sampled secret rows installed.

  • background : Xofs

    Original raw XOFs, before installing those rows.

  • keySeed : FixedBytes 32

    Original 32-byte key-generation seed, retained by the challenger.

  • secretSeed : FixedBytes 64

    Secret 64-byte prefix derived at the actual key-generation input.

  • publicSeed : FixedBytes 32

    Matrix seed passed to the signer and encoded in the public key.

  • Matrix and full vector, absent on either native expansion failure.

noncomputable def Cslib.Crypto.MLDSA.FIPS204.Xofs.sampleSecretExpansionViews (base : Xofs) (s : Level) {a b : ℕ} (ha : 528 ≤ a) (hb : 481 ≤ b) :

Joint distribution of the two online XOFs, derived seeds and the actual (possibly failed) key-generation pair. The experiment resamples only the first 481 bytes in each of the secret and error rows selected by Algorithm 6.

theorem Cslib.Crypto.MLDSA.FIPS204.QuantumSigningForger.secretExpansionViews_games (C : QuantumSigningForger) (s : Level) (base : Xofs) {a b : ℕ} (ha : 528 ≤ a) (hb : 481 ≤ b) :
have run := fun (H : Xofs) (rho : FixedBytes 32) (pk : PublicKey s.params) => PMF.map (fun (x : C.ProgrammedSigningResult s H) => x.trial.newDigestWin) (C.publicPairSigning s H rho pk); have V := base.sampleSecretExpansionViews s ha hb; (((base.uniformPrefixes a b).bind fun (H : Xofs) => H.fullPairExperiment s (run H)) = V.bind fun (v : SecretExpansionViews s) => (Option.map (run v.shared v.publicSeed) v.pair).getD (PMF.pure false)) ∧ C.independentExpandSGame s base a b = V.bind fun (v : SecretExpansionViews s) => (Option.map (run v.background v.publicSeed) v.pair).getD (PMF.pure false)

The native public-pair signing game and the independent private-expansion game share one setup distribution. They use its identical pair and published key. Only the XOFs passed to adaptive signing, quantum queries and the final byte verifier differ.

The coupled views expand the same original 32-byte key seed to the same 128 bytes. Their published seed and private row prefix are the first 32 and following 64 of these bytes.

theorem Cslib.Crypto.MLDSA.FIPS204.SecretExpansionViews.agree_of_mem {base : Xofs} {s : Level} {a b : ℕ} {ha : 528 ≤ a} {hb : 481 ≤ b} {v : SecretExpansionViews s} (hv : v ∈ (base.sampleSecretExpansionViews s ha hb).support) :
v.shared.h128 = v.background.h128 ∧ ∀ (x : List Bool) (i : ℕ), (481 ≤ i ∨ ∀ (j : Fin (s.params.ℓ + s.params.k)), x ≠ Keccak.bytesToBitsLE (nonceInput v.secretSeed.toList ↑j)) → v.shared.h256.byteAt x i = v.background.h256.byteAt x i

The coupled views have identical SHAKE128 streams and identical SHAKE256 bytes except at the first 481 positions of an Algorithm 33 row. The nonce range includes both vectors.

A pure-mode representative can coincide with a private expansion address only on the empty message and empty context. In that case the public-key hash must equal the private seed and the little-endian nonce must be zero.

theorem Cslib.Crypto.MLDSA.FIPS204.SecretExpansionViews.representative_of_mem {base : Xofs} {s : Level} {a b : ℕ} {ha : 528 ≤ a} {hb : 481 ≤ b} {v : SecretExpansionViews s} (hv : v ∈ (base.sampleSecretExpansionViews s ha hb).support) (tr : FixedBytes 64) (ctx : List Byte) (msg : List Bool) (away : tr ≠ v.secretSeed ∨ ctx ≠ [] ∨ msg ≠ []) :

All honest pure-mode representative reads agree outside the single potential public-key-hash collision for the empty request. The equality is pointwise in the message and context on the two sampled XOFs.