Documentation

CslibFrontier.Crypto.Computational.CollisionResistant.BruteForce

The brute-force collision finder and its 2 ^ ℓ + 1 hash evaluations #

bruteForceFinder digest ms computes the digest of each of s fixed messages ms : Fin s → M with the oracle program digest and returns the first pair of different messages with equal digests ([BS23], §8.3, printed pp. 293–294). Like birthdayFinder in CslibFrontier.Crypto.Computational.CollisionResistant.Birthday, it reaches the function being attacked only through its oracle, so a bound on its oracle calls bounds evaluations of that function; CslibFrontier.Crypto.Computational.CollisionResistant.GenericAttacks instead gives the polynomial-time Turing-machine refutation when 2 ^ ℓ(n) is polynomial in n.

Differences from [BS23] #

Main definitions #

Main results #

References #

def Cslib.Crypto.collidingPair? {M T : Type} [DecidableEq M] [DecidableEq T] {s : ℕ} (ms : Fin s → M) (ds : Fin s → T) :
Option (M × M × T)

The first pair of positions (in lexicographic order) whose digests agree and whose messages differ, returned as the two messages and their common digest.

theorem Cslib.Crypto.collidingPair?_eq_some {M T : Type} [DecidableEq M] [DecidableEq T] {s : ℕ} {ms : Fin s → M} {ds : Fin s → T} {m m' : M} {d : T} (h : collidingPair? ms ds = some (m, m', d)) :
m ≠ m' ∧ ∃ (i : Fin s) (j : Fin s), ms i = m ∧ ms j = m' ∧ ds i = d ∧ ds j = d

An output some (m, m', d) of collidingPair? is two different messages that occur among ms with digest d.

theorem Cslib.Crypto.isSome_collidingPair?_iff {M T : Type} [DecidableEq M] [DecidableEq T] {s : ℕ} {ms : Fin s → M} {ds : Fin s → T} :
(collidingPair? ms ds).isSome = true ↔ ∃ (i : Fin s) (j : Fin s), ds i = ds j ∧ ms i ≠ ms j

collidingPair? finds a pair exactly when two positions have equal digests and different messages.

def Cslib.Crypto.collisionOutputs {M T : Type} (f : M → T) :
Set (Option (M × M × T))

The outputs of a collision finder that are collisions of f: two different messages and their common value.

theorem Cslib.Crypto.collidingPair?_mem_collisionOutputs_of_isSome {M T : Type} [DecidableEq M] [DecidableEq T] {s : ℕ} {ms : Fin s → M} {f : M → T} (h : (collidingPair? ms fun (i : Fin s) => f (ms i)).isSome = true) :
(collidingPair? ms fun (i : Fin s) => f (ms i)) ∈ collisionOutputs f

Any non-none output of collidingPair? ms (fun i => f (ms i)) is a collision of f in collisionOutputs f.

theorem Cslib.Crypto.isSome_collidingPair?_of_card_lt {M T : Type} [DecidableEq M] [DecidableEq T] {s : ℕ} {ms : Fin s → M} (hms : Function.Injective ms) {ds : Fin s → T} {D : Finset T} (hds : ∀ (i : Fin s), ds i ∈ D) (hlt : D.card < s) :

Pigeonhole for collidingPair?: among s distinct messages whose digests all lie in a finite set D of cardinality strictly less than s, two positions have equal digests and different messages.

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

The brute-force collision finder ([BS23], §8.3, printed pp. 293–294): compute the digest of each of s fixed messages ms with the oracle program digest, and return the first pair of different messages with equal digests, together with their common digest.

theorem Cslib.Crypto.isQueryBounded_bruteForceFinder {Query M T : Type} {spec : Query → Type} [DecidableEq M] [DecidableEq T] {digest : M → ProbOracleComp spec T} {s c : ℕ} {ms : Fin s → M} (hdigest : ∀ (i : Fin s), (digest (ms i)).IsQueryBounded c) :

Cost of the brute-force finder. When each digest (ms i) makes at most c oracle calls, the finder makes at most s * c on every path. Message generation and the search among the s digests are not counted: this is a count of oracle calls, not a running time.

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

Against a deterministic oracle O under which digest (ms i) returns f (ms i), the finder deterministically returns collidingPair? ms fun i => f (ms i).

theorem Cslib.Crypto.bruteForceFinder_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) {s : ℕ} {ms : Fin s → M} (hdigest : ∀ (i : Fin s), ((digest (ms i)).run fun (x : Query) => pure (O x)) = pure (f (ms i))) {o : Option (M × M × T)} (ho : o ∈ ((bruteForceFinder digest ms).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 (ms i) returns f (ms i), every output other than none is a collision of f.

theorem Cslib.Crypto.bruteForceFinder_success {Query M T : Type} {spec : Query → Type} [DecidableEq M] [DecidableEq T] {digest : M → ProbOracleComp spec T} (O : (q : Query) → spec q) (f : M → T) {s : ℕ} {ms : Fin s → M} (hms : Function.Injective ms) (hdigest : ∀ (i : Fin s), ((digest (ms i)).run fun (x : Query) => pure (O x)) = pure (f (ms i))) (D : Finset T) (hf : ∀ (i : Fin s), f (ms i) ∈ D) (hlt : D.card < s) :
((bruteForceFinder digest ms).run fun (x : Query) => pure (O x)).eval.toOuterMeasure (collisionOutputs f) = 1

Success of the brute-force finder. Against a deterministic oracle under which digest (ms i) returns f (ms i), if ms consists of s distinct messages whose digests all lie in a finite set D with D.card < s, the finder returns a collision of f with probability 1.

theorem Cslib.Crypto.bruteForceFinder_two_pow_succ_success {Query M : Type} {spec : Query → Type} [DecidableEq M] {digest : M → ProbOracleComp spec (List Bool)} (O : (q : Query) → spec q) (f : M → List Bool) {ℓ : ℕ} {ms : Fin (2 ^ ℓ + 1) → M} (hms : Function.Injective ms) (hdigest : ∀ (i : Fin (2 ^ ℓ + 1)), ((digest (ms i)).run fun (x : Query) => pure (O x)) = pure (f (ms i))) (hlen : ∀ (i : Fin (2 ^ ℓ + 1)), (f (ms i)).length = ℓ) :
((bruteForceFinder digest ms).run fun (x : Query) => pure (O x)).eval.toOuterMeasure (collisionOutputs f) = 1

Brute force on 2 ^ ℓ + 1 distinct messages with ℓ-bit digests ([BS23], §8.3, printed pp. 293–294): for every digest length ℓ : ℕ, evaluating any 2 ^ ℓ + 1 distinct messages whose digests have length ℓ finds a collision of f with probability 1. With isQueryBounded_bruteForceFinder, this uses at most (2 ^ ℓ + 1) * c oracle calls when each digest makes at most c.

Single-query brute-force collision search for ℓ-bit digests ([BS23], §8.3, printed pp. 293–294): query the hash oracle once on each of the first 2 ^ ℓ + 1 binary words of length ℓ + 1 (BitString.lowBits (ℓ + 1)) and return the first colliding pair and its digest.

Cost of bruteForceHashFinder ([BS23], §8.3, printed pp. 293–294): for every digest length ℓ : ℕ, bruteForceHashFinder ℓ makes at most 2 ^ ℓ + 1 hash queries on every path. Generating the (ℓ + 1)-bit messages and comparing digests are not counted.

theorem Cslib.Crypto.bruteForceHashFinder_success (ℓ : ℕ) (H : List Bool → List Bool) (hlen : ∀ (m : List Bool), m.length = ℓ + 1 → (H m).length = ℓ) :

Success of bruteForceHashFinder ([BS23], §8.3, printed pp. 293–294): for every digest length ℓ : ℕ and every hash H : List Bool → List Bool mapping (ℓ + 1)-bit words to ℓ-bit digests, bruteForceHashFinder ℓ returns a collision of H with probability 1 using at most 2 ^ ℓ + 1 evaluations of H (isQueryBounded_bruteForceHashFinder).