Documentation

CslibFrontier.Crypto.Computational.RainbowTable.RunCost

Deterministic run-cost analysis of rainbow-table and Hellman inversion #

Deterministic request-trace (OracleComp.queriesWith) cost bounds for rainbowAttack and hellmanAttack ([BS23], Section 18.7, pp. 743–746), consuming the four decomposition lemmas of CslibFrontier.Languages.Probabilistic.QueriesWith.Cost.

Correspondence with [BS23], Section 18.7 #

Main results #

References #

Private trace and summation helpers #

Run-cost analysis of rainbowAttack #

@[simp]
theorem Cslib.Crypto.sum_map_lookupCost_queriesWith_rainbowAttackStep {P Y : Type} [DecidableEq Y] (h : P → Y) (lookup : P → Option P) (g : ℕ → Y → P) (τ : ℕ) (y : Y) (k : ℕ) :

Every step k of rainbowAttack makes 1 table lookup along a deterministic run.

theorem Cslib.Crypto.sum_map_hashCost_queriesWith_rainbowAttackStep {P Y : Type} [DecidableEq Y] (h : P → Y) (lookup : P → Option P) (g : ℕ → Y → P) {τ : ℕ} (y : Y) {k : ℕ} (hk : k < τ) :

At step k < τ, rainbowAttackStep makes k hash queries when lookup misses and τ hash queries (k forward, τ - 1 - k backward from pw₀, 1 verification) when lookup hits.

theorem Cslib.Crypto.sum_map_lookupCost_queriesWith_rainbowAttack_le {P Y : Type} [DecidableEq Y] (h : P → Y) (lookup : P → Option P) (g : ℕ → Y → P) (τ : ℕ) (y : Y) :

Along any deterministic run, rainbowAttack makes at most τ table lookups ([BS23], Section 18.7, p. 746).

When rainbowAttack returns none, all τ steps execute and the run makes τ table lookups.

theorem Cslib.Crypto.sum_map_hashCost_queriesWith_rainbowAttack_of_forall_lookup_eq_none {P Y : Type} [DecidableEq Y] {h : P → Y} {lookup : P → Option P} {g : ℕ → Y → P} {τ : ℕ} {y : Y} (hmiss : ∀ k < τ, lookup (rainbowChainPure h g (τ - k) k (g (τ - 1 - k) y)) = none) :

Exact miss-run hash count of rainbowAttack ([BS23], Section 18.7, line 2 of Algorithm A₁, p. 746): when no candidate endpoint hits the table, rainbowAttack evaluates 0 + 1 + ⋯ + (τ - 1) = τ * (τ - 1) / 2 hashes (τ - i evaluations at iteration i = τ down to 1 as printed on line 2).

theorem Cslib.Crypto.sum_map_hashCost_queriesWith_rainbowAttack_le {P Y : Type} [DecidableEq Y] (h : P → Y) (lookup : P → Option P) (g : ℕ → Y → P) (τ : ℕ) (y : Y) :
(List.map TableAttackSpec.hashCost (OracleComp.queriesWith (OracleComp.sumPure h lookup) (rainbowAttack g τ y))).sum ≤ τ * (τ - 1) / 2 + List.countP (fun (k : ℕ) => (lookup (rainbowChainPure h g (τ - k) k (g (τ - 1 - k) y))).isSome) (List.range τ) * τ

General run hash bound of rainbowAttack. Along any deterministic run (including early termination when a preimage is found), total hash evaluations are at most τ * (τ - 1) / 2 + hits * τ, where hits counts steps k < τ whose candidate endpoint hits lookup.

theorem Cslib.Crypto.sum_map_hashCost_queriesWith_rainbowAttack_le_of_no_false_alarm {P Y : Type} [DecidableEq Y] {h : P → Y} {lookup : P → Option P} {g : ℕ → Y → P} {τ : ℕ} {y : Y} (hnofa : ∀ k < τ, ∀ (pw₀ : P), lookup (rainbowChainPure h g (τ - k) k (g (τ - 1 - k) y)) = some pw₀ → h (rainbowChainPure h g 0 (τ - 1 - k) pw₀) = y) :

Rainbow-table run hash bound without false alarms (cf. [BS23], Section 18.7, p. 746): when every table hit along the candidate endpoints yields a valid preimage of y, the first hit terminates rainbowAttack, so the run makes at most τ * (τ + 1) / 2 hash evaluations (0 + ⋯ + (τ - 1) = τ * (τ - 1) / 2 from line 2 as printed across i = τ down to 1, plus at most τ from lines 4–5 reconstructing and verifying a single hit; this total coincides numerically with p. 746's 1 + 2 + ⋯ + τ = τ(τ + 1)/2 ≈ τ²/2 figure stated for the worst-case work of line 2 alone in setting t := τ²/2).

Run-cost analysis of hellmanAttack #

theorem Cslib.Crypto.sum_map_lookupCost_queriesWith_hellmanAttack_le {P Y : Type} [DecidableEq Y] (h : P → Y) (lookup : P → Option P) (g₀ : Y → P) (τ : ℕ) (y : Y) :

Along any deterministic run, hellmanAttack makes at most τ table lookups ([BS23], Section 18.7, p. 744).

theorem Cslib.Crypto.sum_map_hashCost_queriesWith_hellmanAttack_le {P Y : Type} [DecidableEq Y] (h : P → Y) (lookup : P → Option P) (g₀ : Y → P) (τ : ℕ) (y : Y) :

Along any deterministic run (even when every lookup is a false alarm), hellmanAttack makes at most τ * (τ + 3) / 2 hash evaluations.

@[simp]
theorem Cslib.Crypto.sum_map_hashCost_queriesWith_hellmanLoop_zero {P Y : Type} [DecidableEq Y] (h : P → Y) (lookup : P → Option P) (g₀ : Y → P) (y : Y) (z : P) :

Zero remaining iterations of hellmanLoop make 0 hash evaluations.

theorem Cslib.Crypto.sum_map_hashCost_queriesWith_hellmanLoop_succ {P Y : Type} [DecidableEq Y] (h : P → Y) (lookup : P → Option P) (g₀ : Y → P) (y : Y) (m : ℕ) (z : P) :
(List.map TableAttackSpec.hashCost (OracleComp.queriesWith (OracleComp.sumPure h lookup) (hellmanLoop g₀ y (m + 1) z))).sum = match lookup z with | none => 1 + (List.map TableAttackSpec.hashCost (OracleComp.queriesWith (OracleComp.sumPure h lookup) (hellmanLoop g₀ y m (g₀ (h z))))).sum | some pw₀ => if h ((fun (x : P) => g₀ (h x))^[m] pw₀) = y then m + 1 else m + 2 + (List.map TableAttackSpec.hashCost (OracleComp.queriesWith (OracleComp.sumPure h lookup) (hellmanLoop g₀ y m (g₀ (h z))))).sum

One iteration of hellmanLoop at remaining depth m + 1 makes 1 hash evaluation before recursing on a lookup miss, m + 1 hash evaluations on a verified hit, and m + 2 hash evaluations before recursing on a false alarm.

theorem Cslib.Crypto.le_sum_map_hashCost_queriesWith_hellmanAttack {P Y : Type} [DecidableEq Y] (h : P → Y) (lookup : P → Option P) (g₀ : Y → P) (τ : ℕ) (y : Y) :

Every deterministic run of hellmanAttack makes at least τ hash evaluations.

theorem Cslib.Crypto.sum_map_hashCost_queriesWith_hellmanAttack_of_no_false_alarm {P Y : Type} [DecidableEq Y] {h : P → Y} {lookup : P → Option P} {g₀ : Y → P} {τ : ℕ} {y : Y} (hnofa : ∀ k < τ, ∀ (pw₀ : P), lookup ((fun (x : P) => g₀ (h x))^[k] (g₀ y)) = some pw₀ → h ((fun (x : P) => g₀ (h x))^[τ - 1 - k] pw₀) = y) :

Hellman's hash count without false alarms ([BS23], Section 18.7, p. 744): when every table hit along the queried orbit yields a valid preimage of y, hellmanAttack makes τ hash evaluations (k single-step advances prior to a hit at step k, τ - 1 - k steps to reconstruct pw, and 1 evaluation to check h(pw) = y; or τ single-step advances when all τ lookups miss).

theorem Cslib.Crypto.add_le_sum_map_hashCost_queriesWith_hellmanAttack_of_false_alarm {P Y : Type} [DecidableEq Y] {h : P → Y} {lookup : P → Option P} {g₀ : Y → P} {τ k : ℕ} {y : Y} {pw₀ : P} (hk : k < τ) (hbefore : ∀ j < k, ∀ (pw₁ : P), lookup ((fun (x : P) => g₀ (h x))^[j] (g₀ y)) = some pw₁ → h ((fun (x : P) => g₀ (h x))^[τ - 1 - j] pw₁) ≠ y) (hhit : lookup ((fun (x : P) => g₀ (h x))^[k] (g₀ y)) = some pw₀) (hfa : h ((fun (x : P) => g₀ (h x))^[τ - 1 - k] pw₀) ≠ y) :

Extra hash cost of a false alarm in Hellman's attack ([BS23], Section 18.7, pp. 744–745; Fig. 18.14, p. 745): a false alarm reached at iteration k < τ (with only misses or false alarms at earlier iterations j < k) adds at least τ - k hash evaluations above τ.