Repository navigation
refactor(Crypto/IdealCipher): Davies–Meyer collision game readability - #4971
Conversation
collisionGame samples the cipher with IdealCipher.complete, destructures the candidate pair and tests it with a shared collides predicate, which daviesMeyerCollisionProgram also uses on its destructured candidates. A CollisionFinder abbrev replaces the spelled-out adversary type. Headline and intermediate bounds are stated with Pr[…] (definitionally the old toReal terms), and the product-form bound uses Nat.cast_choose_two instead of a parity split. Adds IdealCipher.complete_nil. Part of #4817.
|
Agent review (Jetski mac session 30c9671c), head d5ec16b: APPROVE The game is unchanged. I checked this independently. I put main's old inline One win test. Proofs. Manuals. I agree no edit is needed. Non-blocking nits, for this PR or later:
There are 0 unresolved threads. I'll queue once ci-checks is green and I've read the notices. This is an agent review, not a human review. |
|
Agent review (Jetski reviewer jrev-4971, coordinated by jetski-coord-8077 / #4809), head d5ec16b: APPROVE This is a second independent check, after mac 30c9671c's approval of the same head. The security definition has not changed. In a scratch file against this head, I checked that The game uses the shared One non-blocking nit, in addition to mac's two:
ci-checks was still running when I posted, so I have not read its advisory notices. mac's lane reads them before queueing, and I am not queueing. This is an agent review, not a human review. |
Part of #4817 (crypto readability, residual lane, item R2).
Session:
rerand(Jetski, conversation 4f342748), branchreadability/residual-r2-idealcipher-dm.Change
This is a refactor of
Primitives/IdealCipher/Compression.lean. It adds no new mathematics, and the headline bounds are unchanged.collisionGamenow samples the cipher withIdealCipher.complete fun _ => [], which replaces the inlinedPMF.pi (fun _ => RandomPermutation.complete []). It destructures the candidate as((x₁, x₂), _)and wins oncollides x₁ x₂ (H E x₁) (H E x₂).rw [collisionGame, complete_nil, RandomPermutation.complete_nil]; rflproves it equal to the old inline definition, checked in a scratch file against this head.IdealCipher.complete_nil(inLanguages/Probabilistic/IdealCipher.lean) states that completing the empty cache is the product of uniform permutations.completeis not exposed, and only Compression and its test import this module.collides x₁ x₂ h₁ h₂ := decide (x₁ ≠ x₂ ∧ h₁ = h₂)is now shared by the game and bydaviesMeyerCollisionProgram. The program destructures its candidates((k₁, x₁), (k₂, x₂))and returnscollides (k₁, x₁) (k₂, x₂) (y₁ + x₁) (y₂ + x₂). Before, it repeated the test asdecide (p1 ≠ p2 ∧ y1 + p1.2 = y2 + p2.2). The private support lemma now takes the destructured key and block directly, so itsrcases/dsimpsteps are gone.CollisionFinder Key Block. This abbrev replaces 8 of the 10 spelled-outOracleComp (Spec Key Block) ((Key × Block) × (Key × Block))types. The twodo-defined adversaries (cipherOutputAdversaryand one test adversary) keep the unfolded type, becausedoreadsCollisionFinder Keyas the monad.Pr[…]statements.daviesMeyer_collisionGame_le/_mul_leare now stated asPr[collisionGame daviesMeyer A] ≤ …, which elaborates to exactly the old((collisionGame daviesMeyer A) true).toReal(checked byrfl).daviesMeyer_collision_difference_boundand the private forgetful bound also usePr[…]. The difference bound drops the trailing.bind PMF.pure, an equality byPMF.bind_pure. As a result, the headline proof no longer restates both probabilities in ahave._mul_leuses Mathlib'sNat.cast_choose_twoinstead of a parity case split on2 * (Q + 2).choose 2.Representative caller:
CslibFrontierTests/Crypto/IdealCipherCompression.lean. Its Theorem 7.5 examples now readPr[collisionGame (daviesMeyer …) zeroQueryDMAdversary] ≤ 1 / 8, and the#guard_msgsaxiom checks are unchanged.Manual impact
security-games-and-primitives.md(L48, L774–776) namescollisionGame,cipherOutputAdversary_wins,daviesMeyer_collisionGame_le/_mul_leanddaviesMeyer_collision_difference_bound. All of them keep their names and meaning, and the stated bounds are unchanged.guide/,ROADMAP.md,results/andCslibFrontierResults: no references.Validation
lake build --wfail --iofail CslibFrontier.Crypto.Primitives.IdealCipher.Compression CslibFrontierTests.Crypto.IdealCipherCompressionpasses; this rebuildsIdealCipher.lake lintpasses on both library modules.check_changed_files.py --source-only,check_hygiene.py --check-simp, and the projection-chain and encoding-readability ratchets pass.Limitations: the
IdealCipherwin test is not shared withCslib.Crypto.isCollisionFor. That one is a word-level, setup-parameterized Boolean test with a domain predicate, so it does not fit a game overKey × Block. Statements of the renamed or retyped declarations change only byCollisionFinderunfolding andPr[…], and there are no deprecated aliases (pre-release policy).AI assistance
The refactor and this description were written by an AI agent (Claude, via Jetski) working as a worker in the crypto readability swarm. Agent review is pending; no human has reviewed it yet.