Documentation

CslibFrontier.Crypto.Computational.PseudorandomPermutation.BirthdayAttack

Word-level birthday attack on block ciphers #

Formalizes the word-level collision distinguisher of Boneh–Shoup (§4.4.3, p. 134) against a BlockCipher viewed as a pseudorandom function, wrapping the finite birthday distinguisher PRP.birthdayDistinguisher with an explicit polynomial-time oracle adversary.

Main definitions #

Main results #

The deterministic counter-mode birthday attack of §4.4.4.1 is not formalized here.

References #

Word-level birthday distinguisher querying min (Q n) (2 ^ blockLen n) distinct blockLen n-bit inputs (via BitString.lowBits) and returning true iff two truncated outputs collide.

Finite BitString m query family corresponding to the first q queries made by wordBirthdayDistinguisher.

birthdayQueries m q is injective whenever q ≤ 2 ^ m.

birthdayQueries m (2 ^ m) enumerates every m-bit string bijectively.

theorem Cslib.Crypto.isQueryBounded_wordBirthdayDistinguisher (blockLen Q : ℕ → ℕ) (n : ℕ) (aux : List Bool) :
ProbOracleComp.IsQueryBounded (wordBirthdayDistinguisher blockLen Q n aux) (min (Q n) (2 ^ blockLen n))

wordBirthdayDistinguisher blockLen Q n aux makes at most min (Q n) (2 ^ blockLen n) oracle queries.

theorem Cslib.Crypto.run_wordBirthdayDistinguisher (blockLen Q : ℕ → ℕ) (n : ℕ) (f : List Bool → List Bool) :
(ProbOracleComp.run (wordBirthdayDistinguisher blockLen Q n []) fun (req : Unit × List Bool) => pure (f req.2)) = pure (decide ¬Function.Injective fun (j : Fin (min (Q n) (2 ^ blockLen n))) => List.take (blockLen n) (f (BitString.lowBits (blockLen n) ↑j)))

Deterministic execution of wordBirthdayDistinguisher against an arbitrary word oracle f.

theorem Cslib.Crypto.run_wordBirthdayDistinguisher_randomFunctionOracle (blockLen Q : ℕ → ℕ) (n : ℕ) (f : BitString (blockLen n) → BitString (blockLen n)) :
(ProbOracleComp.run (wordBirthdayDistinguisher blockLen Q n []) fun (req : Unit × List Bool) => pure (randomFunctionOracle (blockLen n) f req.2)) = (PRP.birthdayDistinguisher (birthdayQueries (blockLen n) (min (Q n) (2 ^ blockLen n)))).run fun (d : BitString (blockLen n)) => pure (f d)

Against randomFunctionOracle, wordBirthdayDistinguisher matches the finite distinguisher PRP.birthdayDistinguisher on birthdayQueries.

Output distribution of wordBirthdayDistinguisher in E.prpRealGame coincides with PRP.realExperiment on E.permEquiv.

theorem Cslib.Crypto.eval_prfIdealGame_wordBirthdayDistinguisher (blockLen Q : ℕ → ℕ) (n : ℕ) :
(prfIdealGame blockLen blockLen (wordBirthdayDistinguisher blockLen Q) n).eval = (PRF.idealExperiment (PRP.birthdayDistinguisher (birthdayQueries (blockLen n) (min (Q n) (2 ^ blockLen n))))).eval

Output distribution of wordBirthdayDistinguisher in prfIdealGame coincides with PRF.idealExperiment on PRP.birthdayDistinguisher.

Exact real-valued advantage of wordBirthdayDistinguisher between E.prpRealGame and prfIdealGame.

Concrete quadratic birthday lower bound on wordBirthdayDistinguisher against E.prpRealGame vs prfIdealGame.

Constant 1 / 2 lower bound once 1 ≤ E.blockLen n and 2 ^ E.blockLen n ≤ Q n.

Exact real-valued PRF advantage of wordBirthdayDistinguisher for a BlockCipher with E.keyLen = id.

theorem Cslib.Crypto.BlockCipher.min_le_prfAdvantage_wordBirthdayDistinguisher (E : BlockCipher) (hkey : E.keyLen = id) (Q : ℕ → ℕ) (n : ℕ) :
have q := min (Q n) (2 ^ E.blockLen n); min (↑q * (↑q - 1) / (4 * 2 ^ E.blockLen n)) 0.63 ≤ ↑(Game.advantage (prfRealGame E.blockLen (fun (key query : List Bool) => E.encrypt key.length key query) (wordBirthdayDistinguisher E.blockLen Q) n).eval (prfIdealGame E.blockLen E.blockLen (wordBirthdayDistinguisher E.blockLen Q) n).eval)

Quadratic birthday lower bound on the PRF advantage of wordBirthdayDistinguisher for a BlockCipher with E.keyLen = id.

Constant 1 / 2 PRF advantage lower bound once 1 ≤ E.blockLen n and 2 ^ E.blockLen n ≤ Q n.

If ((2 : ℝ≥0) ^ E.blockLen n)⁻¹ on nonzero blocks is not negligible, E.prpRealGame and prfIdealGame are not indistinguishable for PPT adversaries: some PPT adversary distinguishes them, namely wordBirthdayDistinguisher with a polynomial query count, whose advantage is at least 1 / 2 for infinitely many n.

Necessity of super-polynomial block size in BlockCipher.prp_iff_pseudorandomFunctionOver_of_keyLen_eq_id: when E.keyLen = id, 1 ≤ E.blockLen n eventually, and ((2 : ℝ≥0) ^ E.blockLen n)⁻¹ is not negligible, E cannot be a PseudorandomFunctionOver E.blockLen E.blockLen.