Documentation

CslibFrontier.Crypto.Computational.CollisionResistant.Birthday

The birthday collision finder #

birthdayFinder digest sampler s samples s messages, computes the digest of each with the oracle program digest, and returns the first pair of different messages with equal digests ([BS23], §8.3, Algorithm BirthdayAttack, printed p. 294). It reaches the function being attacked only through its oracle, so a bound on its oracle calls is a bound on evaluations of that function.

Differences from [BS23] #

Main definitions #

Main results #

References #

def Cslib.Crypto.birthdayFinder {Query M T : Type} {spec : Query → Type} [DecidableEq M] [DecidableEq T] (digest : M → ProbOracleComp spec T) (sampler : ProbComp M) (s : ℕ) :
ProbOracleComp spec (Option (M × M × T))

The birthday collision finder ([BS23], §8.3, Algorithm BirthdayAttack, printed p. 294, with the number of samples s as a parameter): sample s messages and run bruteForceFinder digest on them (computing the digest of each with digest and returning the first pair of different messages with equal digests, together with the digest).

theorem Cslib.Crypto.isQueryBounded_birthdayFinder {Query M T : Type} {spec : Query → Type} [DecidableEq M] [DecidableEq T] {digest : M → ProbOracleComp spec T} {c : ℕ} (hdigest : ∀ (m : M), (digest m).IsQueryBounded c) (sampler : ProbComp M) (s : ℕ) :
(birthdayFinder digest sampler s).IsQueryBounded (s * c)

Cost of the birthday finder. When each digest makes at most c oracle calls, the finder makes at most s * c on every path. Sampling and the search among the digests are not counted: this is a count of oracle calls, not a running time.

theorem Cslib.Crypto.eval_run_birthdayFinder {Query M T : Type} {spec : Query → Type} [DecidableEq M] [DecidableEq T] {digest : M → ProbOracleComp spec T} (O : (q : Query) → spec q) (f : M → T) (hdigest : ∀ (m : M), ((digest m).run fun (x : Query) => pure (O x)) = pure (f m)) (sampler : ProbComp M) (s : ℕ) :
((birthdayFinder digest sampler s).run fun (x : Query) => pure (O x)).eval = PMF.map (fun (ms : Fin s → M) => collidingPair? ms fun (i : Fin s) => f (ms i)) (ProbComp.eval (OracleComp.replicateFin s sampler))

Against a deterministic oracle O under which digest m returns f m, the finder samples and searches.

theorem Cslib.Crypto.birthdayFinder_sound {Query M T : Type} {spec : Query → Type} [DecidableEq M] [DecidableEq T] {digest : M → ProbOracleComp spec T} (O : (q : Query) → spec q) (f : M → T) (hdigest : ∀ (m : M), ((digest m).run fun (x : Query) => pure (O x)) = pure (f m)) (sampler : ProbComp M) (s : ℕ) {o : Option (M × M × T)} (ho : o ∈ ((birthdayFinder digest sampler s).run fun (x : Query) => pure (O x)).eval.support) (hne : o ≠ none) :

The finder never returns a wrong pair: against a deterministic oracle under which digest m returns f m, every output other than none is a collision of f, for every sampler.

theorem Cslib.Crypto.birthdayFinder_success {Query M T : Type} {spec : Query → Type} [DecidableEq M] [DecidableEq T] [Fintype M] [Nonempty M] {digest : M → ProbOracleComp spec T} (O : (q : Query) → spec q) (f : M → T) (hdigest : ∀ (m : M), ((digest m).run fun (x : Query) => pure (O x)) = pure (f m)) (D : Finset T) (hf : ∀ (m : M), f m ∈ D) (s : ℕ) :
1 - Real.exp (-(↑s * (↑s - 1) / (2 * ↑D.card))) - ↑(s.choose 2) * (↑(Fintype.card M))⁻¹ ≤ (((birthdayFinder digest (ProbComp.uniform M) s).run fun (x : Query) => pure (O x)).eval.toOuterMeasure (collisionOutputs f)).toReal

Success probability of the birthday finder ([BS23], §8.3, Lemma 8.2, printed p. 294, with explicit error terms). Against a deterministic oracle under which digest m returns f m, with s uniform messages, the finder returns a collision of f with probability at least 1 - exp (-s (s - 1) / (2 |D|)) - C(s, 2) / |M|, where D contains every value of f.

theorem Cslib.Crypto.birthdayFinder_success_book {Query M T : Type} {spec : Query → Type} [DecidableEq M] [DecidableEq T] [Fintype M] [Nonempty M] {digest : M → ProbOracleComp spec T} (O : (q : Query) → spec q) (f : M → T) (hdigest : ∀ (m : M), ((digest m).run fun (x : Query) => pure (O x)) = pure (f m)) (D : Finset T) (hf : ∀ (m : M), f m ∈ D) (hM : 100 * D.card ≤ Fintype.card M) :
1 / 2 ≤ (((birthdayFinder digest (ProbComp.uniform M) (⌈2 * √↑D.card⌉₊ + 1)).run fun (x : Query) => pure (O x)).eval.toOuterMeasure (collisionOutputs f)).toReal

Lemma 8.2 with the book's parameters ([BS23], §8.3, printed p. 294): if |M| ≥ 100 |D|, where D contains every value of f, then the finder with s = ⌈2 √|D|⌉ + 1 uniform messages returns a collision of f with probability at least 1/2. With isQueryBounded_birthdayFinder it makes s digest computations.