Documentation

CslibFrontier.Crypto.Computational.CollisionResistant.GenericAttacks

Brute force and the birthday attack as polynomial-time collision finders #

The generic collision attacks of [BS23], §8.3 (printed pp. 293–295), brute force and Algorithm BirthdayAttack, as word-level CollisionFinders with IsPPT certificates, and the refutations of CollisionResistantOn they give. CslibFrontier.Crypto.Computational.CollisionResistant.Birthday instead treats the birthday finder as an oracle program and counts its oracle calls; here each finder is a probabilistic polynomial-time program that evaluates the keyed hash itself.

collidingPairList? h ms is the first pair of different messages of ms with equal digests. Brute force (bruteForceCollisionFinder) searches a fixed list of more than 2 ^ ℓ(n) distinct valid messages and always succeeds; the birthday finder (birthdayCollisionFinder) with the book's ⌈2 √N⌉ + 1 samples, N = 2 ^ ℓ(n), succeeds with probability at least 1/2 when 100 N ≤ 2 ^ msgLen(n) and valid accepts every msgLen(n)-bit message (Lemma 8.2).

Every refutation needs 2 ^ ℓ(n) to be polynomial in n (the birthday statements and not_collisionResistant_of_two_pow_polyTime assume that it is computable in unary in polynomial time), so they cover constant and logarithmic digest lengths, where brute force alone refutes collision resistance; the birthday refutation adds a certified finder with success 1/2 on msgLen(n)-bit messages. Nothing compares the √N samples with the N + 1 messages of brute force in machine time. CslibFrontier.Crypto.Computational.CollisionResistant.BruteForce counts the 2 ^ ℓ + 1 hash evaluations of brute force as oracle calls, as Birthday.lean does for the birthday finder.

Differences from [BS23] #

Main definitions #

Main results #

References #

def Cslib.Crypto.collidingPairList? {α : Type u_1} {β : Type u_2} [DecidableEq α] [DecidableEq β] (h : α → β) (ms : List α) :
Option (α × α)

The first pair of different messages of ms with equal digests under h, in the order of the pairs of ms.map fun m => (m, h m) with itself, so that each digest is computed once. This is the list form of collidingPair?.

theorem Cslib.Crypto.collidingPairList?_eq_some {α : Type u_1} {β : Type u_2} [DecidableEq α] [DecidableEq β] {h : α → β} {ms : List α} {a b : α} (hab : collidingPairList? h ms = some (a, b)) :
a ∈ ms ∧ b ∈ ms ∧ a ≠ b ∧ h a = h b

An output some (a, b) of collidingPairList? is a collision among the messages.

theorem Cslib.Crypto.isSome_collidingPairList?_iff {α : Type u_1} {β : Type u_2} [DecidableEq α] [DecidableEq β] {h : α → β} {ms : List α} :
(collidingPairList? h ms).isSome = true ↔ ∃ a ∈ ms, ∃ b ∈ ms, a ≠ b ∧ h a = h b

collidingPairList? finds a pair exactly when the messages contain a collision.

theorem Cslib.Crypto.isSome_collidingPairList?_of_two_pow_lt {α : Type u_1} [DecidableEq α] {h : α → List Bool} {ms : List α} {ℓ : ℕ} (hlen : ∀ m ∈ ms, (h m).length = ℓ) (hnd : ms.Nodup) (hlt : 2 ^ ℓ < ms.length) :

Brute force ([BS23], §8.3, printed pp. 293–294): among more than 2 ^ ℓ distinct messages with ℓ-bit digests, two have the same digest.

noncomputable def Cslib.Crypto.birthdayCollisionFinder (H : List Bool → List Bool → List Bool) (msgLen count : ℕ → ℕ) :

The birthday attack as a collision finder: at security parameter n and key k, sample count n uniform msgLen n-bit messages and return the first colliding pair, or ([], []).

Brute force as a collision finder: hash the fixed messages msgs n and return the first colliding pair, or ([], []).

theorem Cslib.Crypto.succProbability_bruteForceCollisionFinder {H : List Bool → List Bool → List Bool} {valid : ℕ → List Bool → Bool} {ℓ : ℕ → ℕ} {msgs : ℕ → List (List Bool)} (hlen : ∀ (k m : List Bool), m ∈ msgs k.length → (H k m).length = ℓ k.length) (hnd : ∀ (n : ℕ), (msgs n).Nodup) (hlt : ∀ (n : ℕ), 2 ^ ℓ n < (msgs n).length) (hvalid : ∀ (n : ℕ), ∀ m ∈ msgs n, valid n m = true) (n : ℕ) :

Brute force succeeds ([BS23], §8.3, printed pp. 293–294): searching more than 2 ^ ℓ(n) distinct valid messages with ℓ(n)-bit digests finds a collision with certainty.

theorem Cslib.Crypto.half_le_succProbability_birthdayCollisionFinder {H : List Bool → List Bool → List Bool} {valid : ℕ → List Bool → Bool} {ℓ msgLen : ℕ → ℕ} (hlen : ∀ (k m : List Bool), m.length = msgLen k.length → (H k m).length = ℓ k.length) (hvalid : ∀ (n : ℕ) (m : List Bool), m.length = msgLen n → valid n m = true) (hM : ∀ (n : ℕ), 100 * 2 ^ ℓ n ≤ 2 ^ msgLen n) (n : ℕ) :
1 / 2 ≤ Game.succProbability (collisionGame H valid (birthdayCollisionFinder H msgLen fun (n : ℕ) => ⌈2 * √↑(2 ^ ℓ n)⌉₊ + 1) n).eval

Lemma 8.2 for the birthday finder ([BS23], §8.3, printed p. 294): with ⌈2 √N⌉ + 1 uniform msgLen(n)-bit messages, N = 2 ^ ℓ(n) and 100 N ≤ 2 ^ msgLen(n), the finder outputs a collision with probability at least 1/2 when valid accepts every msgLen(n)-bit message.

The birthday attack ([BS23], §8.3, Lemma 8.2): a polynomial-time keyed hash with ℓ(n)-bit digests on msgLen(n)-bit messages, 100 * 2 ^ ℓ(n) ≤ 2 ^ msgLen(n), is not collision resistant on a domain valid that accepts every msgLen(n)-bit message, when msgLen(n) and 2 ^ ℓ(n) are computable in unary in polynomial time.

theorem Cslib.Crypto.not_collisionResistantOn_of_bruteForce {H : List Bool → List Bool → List Bool} {valid : ℕ → List Bool → Bool} {ℓ : ℕ → ℕ} {msgs : ℕ → List (List Bool)} (hH : Turing.MultiTapeTM.ComputableInPolyTime (fun (p : List Bool × List Bool) => H p.1 p.2) (Turing.MultiTapeTM.encPair Turing.MultiTapeTM.encBits Turing.MultiTapeTM.encBits) Turing.MultiTapeTM.encBits) (hmsgs : Turing.MultiTapeTM.ComputableInPolyTime msgs Turing.MultiTapeTM.encUnary (Turing.MultiTapeTM.encList Turing.MultiTapeTM.encBits)) (hlen : ∀ (k m : List Bool), m ∈ msgs k.length → (H k m).length = ℓ k.length) (hnd : ∀ (n : ℕ), (msgs n).Nodup) (hlt : ∀ (n : ℕ), 2 ^ ℓ n < (msgs n).length) (hvalid : ∀ (n : ℕ), ∀ m ∈ msgs n, valid n m = true) :

Brute force ([BS23], §8.3, printed pp. 293–294): a polynomial-time keyed hash with ℓ(n)-bit digests is not collision resistant when a polynomial-time list of more than 2 ^ ℓ(n) distinct valid messages exists.

A polynomial-time keyed hash with ℓ(n)-bit digests is not collision resistant when 2 ^ ℓ(n) is computable in unary in polynomial time: brute force on 2 ^ ℓ(n) + 1 messages.