Merkle–Damgård with suffix-free padding is collision resistant
ProvedCityMD.crFor a suffix-free padding there is a fixed black-box reduction, making at most compression calls, such that for every keyed compression family and collision finder : .
Preamble
import Mathlib import Definitions.Def_CityMD open Cryptography.MerkleDamgard CityMD
Formal statement
/-- Merkle–Damgård with a suffix-free padding is collision resistant: a fixed
black-box reduction, making at most `|pad m| + |pad m'|` compression calls,
turns any collision finder for the hash into one for the compression family
with at least the same advantage. -/
theorem CityMD.cr {K S B M : Type} [Fintype K] [DecidableEq S] [DecidableEq B]
[Inhabited S] [Inhabited B] (pad : M → List B) (hpad : SuffixFree pad) (iv : S) :
∃ E : List B → List B → OComp (S × B) S ((S × B) × (S × B)),
∀ (f : K → S → B → S) (A : K → M × M),
(∀ k, (E (pad (A k).1) (pad (A k).2)).queries (uncurried (f k)) ≤
(pad (A k).1).length + (pad (A k).2).length) ∧
advCR (fun k => mdHash (f k) iv pad) A ≤
advCR (fun k => uncurried (f k))
(fun k => (E (pad (A k).1) (pad (A k).2)).run (uncurried (f k))) := by sorryRead-back
What the Lean code literally says, in plain math · claude-opus-5-5
CityMD.cr
Read-back
Fix a finite key type K, types S and B (each with decidable equality and a default element), a message type M, a suffix-free padding pad : M → List B, and an IV iv. There is a fixed oracle program E(L, L′), with oracle (S×B) → S and output a pair of (S×B) points. E is chosen before f and A. For every keyed compression family f : K → S → B → S and every deterministic hash collision finder A : K → M × M, both of the following hold:
- For every key k, running E(pad m₁, pad m₂) with (m₁,m₂) = A k against f_k makes at most |pad m₁| + |pad m₂| calls.
- Pr_k[m₁ ≠ m₂ ∧ hash_{f_k}(iv, pad m₁) = hash_{f_k}(iv, pad m₂)] ≤ Pr_k[p ≠ q ∧ f_k(p) = f_k(q)], where (p,q) is E(pad m₁, pad m₂) run against f_k. In words, the collision advantage of A against the MD hash is at most that of the composed adversary k ↦ E^{f_k}(pad(A k)) against the compression family.
Audit notes
- True. This follows from
extracttogether with suffix-freeness: m₁ ≠ m₂ means neither padded string is a suffix of the other. The bound is tight (factor 1). The success event on the left is contained pointwise in the success event on the right. - The reduction is black-box and uniform in f and A. Its only inputs are the padded messages, and iv is fixed outside the ∃.
- Edge cases: if K is empty, both advantages are 0. The
Inhabitedinstances are only needed for E's default output when extraction fails. - The docstring matches the code, including "at least the same advantage".