Documentation

CslibFrontier.Crypto.Primitives.PRP.BirthdayAttack

Birthday distinguisher against a block cipher as a PRF #

This module formalizes the non-adaptive collision-testing distinguisher of Boneh–Shoup (§4.4.3, printed p. 134) that separates any block cipher E : Key → Equiv.Perm D from a uniform random function D → D in the finite-type PRF experiment (Cslib.Crypto.PRF.advantage):

Differences from [BS23] #

Main definitions #

Main results #

References #

def Cslib.Crypto.PRP.birthdayDistinguisher {D : Type} [DecidableEq D] {Q : ℕ} (x : Fin Q → D) :
ProbOracleComp (fun (x : D) => D) Bool

Birthday distinguisher of Boneh–Shoup (§4.4.3, printed p. 134): given Q inputs x : Fin Q → D, it queries the PRF oracle at x 0, …, x (Q - 1) and returns true iff two responses collide.

birthdayDistinguisher x makes at most Q oracle queries on every execution path.

theorem Cslib.Crypto.PRP.run_birthdayDistinguisher {D : Type} [DecidableEq D] {Q : ℕ} (x : Fin Q → D) (f : D → D) :
((birthdayDistinguisher x).run fun (d : D) => pure (f d)) = pure (decide ¬Function.Injective (f ∘ x))

Against any deterministic oracle f : D → D, birthdayDistinguisher x returns true iff f ∘ x fails to be injective.

In Experiment 0 (PRP.realExperiment), any block cipher E : Key → Equiv.Perm D preserves injectivity of x, so birthdayDistinguisher x outputs false with probability 1.

In Experiment 1 (PRF.idealExperiment), for injective x : Fin Q → D, birthdayDistinguisher x outputs true with probability 1 - (|D|)_Q / |D|^Q.

theorem Cslib.Crypto.PRP.coe_advantage_birthdayDistinguisher {Key D : Type} [Fintype Key] [Nonempty Key] [Fintype D] [DecidableEq D] [Nonempty D] (E : Key → Equiv.Perm D) {Q : ℕ} {x : Fin Q → D} (hx : Function.Injective x) :
↑(PRF.advantage (fun (key : Key) => ⇑(E key)) (birthdayDistinguisher x)) = 1 - ↑((Fintype.card D).descFactorial Q) / ↑(Fintype.card D) ^ Q

Exact PRF distinguishing advantage of birthdayDistinguisher x against any block cipher E : Key → Equiv.Perm D when x is injective (§4.4.3, printed p. 134): 1 - (|D|)_Q / |D|^Q.

theorem Cslib.Crypto.PRP.min_le_advantage_birthdayDistinguisher {Key D : Type} [Fintype Key] [Nonempty Key] [Fintype D] [DecidableEq D] [Nonempty D] (E : Key → Equiv.Perm D) {Q : ℕ} {x : Fin Q → D} (hx : Function.Injective x) :
min (↑Q * (↑Q - 1) / (4 * ↑(Fintype.card D))) 0.63 ≤ ↑(PRF.advantage (fun (key : Key) => ⇑(E key)) (birthdayDistinguisher x))

Birthday lower bound on the PRF advantage of birthdayDistinguisher x against any block cipher E : Key → Equiv.Perm D (§4.4.3, printed p. 134): min (Q * (Q - 1) / (4 * |D|)) 0.63.

theorem Cslib.Crypto.PRP.half_le_advantage_birthdayDistinguisher_of_bijective {Key D : Type} [Fintype Key] [Nonempty Key] [Fintype D] [DecidableEq D] [Nonempty D] (E : Key → Equiv.Perm D) {Q : ℕ} {x : Fin Q → D} (hx : Function.Bijective x) (hD : 2 ≤ Fintype.card D) :
1 / 2 ≤ ↑(PRF.advantage (fun (key : Key) => ⇑(E key)) (birthdayDistinguisher x))

A tuple x that enumerates a domain of at least two points gives PRF advantage at least 1 / 2 against any block cipher E : Key → Equiv.Perm D (§4.4.3, printed p. 134): the advantage is 1 - |D|! / |D|^|D|.