The Luby–Rackoff hybrid reduction (explicit PRF distinguishers)
DefinitionLubyRackoffReductionExplicit black-box reduction from a PRP distinguisher to PRF distinguishers, used to state the Luby–Rackoff PRFPRP theorem without an existential reduction. Throughout, is a finite abelian group with , is a keyed family, and is the -round Feistel network of Def_LubyRackoff (round applied first).
Oracle-algorithm combinators. bind runs one oracle algorithm and then another on its output. simulate h D runs and answers each query of by running the sub-algorithm against the outer oracle. steps chains a list of such steps.
Feistel evaluation with one oracle round. For round functions and an index , fwdSim g i x computes with exactly one oracle query , made in round . invSim g i y computes the inverse in the same way.
The hybrid reduction. The seed is . The rounds are
and redRounds stores in the unused slot . The reduction (prpRed F k D i ω) runs and answers every forward query by fwdSim with these rounds. The version for forward and inverse queries (sprpRed) answers inverse queries by invSim. Each makes one oracle query per query of and uses only through evaluation.
Seeded PRF advantage. For with finite, uniform and independent of and ,
where and (prfAdvR).
import Definitions.Def_LubyRackoff
/-!
# The Luby–Rackoff hybrid reduction
An explicit PRF distinguisher built from a PRP distinguisher `D`. It uses `D` as a black
box and evaluates the keyed family `F` itself for the rounds after the oracle round. Fixing the
reduction in the statement (instead of asserting that *some* PRF distinguisher exists)
prevents a reduction from hard-coding the keyed family `F`.
-/
namespace LubyRackoff
namespace OComp
variable {X Y X' Y' α β : Type}
/-- Sequential composition of oracle algorithms: run `c`, then `k` on its output. -/
def bind : OComp X Y α → (α → OComp X Y β) → OComp X Y β
| ret a, k => k a
| query x c, k => query x (fun y => bind (c y) k)
/-- Run `D`, answering each of its queries `x'` by running the sub-algorithm `h x'`. -/
def simulate (h : X' → OComp X Y Y') : OComp X' Y' α → OComp X Y α
| ret a => ret a
| query x' c => bind (h x') (fun y' => simulate h (c y'))
/-- Starting from `c`, apply the steps `op j` for `j` in the list `l`, in order. -/
def steps {ι : Type} (op : ι → α → OComp X Y α) (l : List ι) (c : OComp X Y α) : OComp X Y α :=
l.foldl (fun acc j => bind acc (op j)) c
end OComp
variable {G : Type} [AddCommGroup G]
/-- Forward round `j` on block `y`; round `i` is computed by one oracle query
(the oracle plays the round function of round `i`). -/
def fwdOp {k : ℕ} (g : Fin k → G → G) (i j : Fin k) (y : G × G) : OComp G G (G × G) :=
if j = i then OComp.query y.2 (fun v => OComp.ret (y.2, y.1 + v))
else OComp.ret (round (g j) y)
/-- Inverse of round `j` on block `y`; round `i` is computed by one oracle query. -/
def invOp {k : ℕ} (g : Fin k → G → G) (i j : Fin k) (y : G × G) : OComp G G (G × G) :=
if j = i then OComp.query y.1 (fun v => OComp.ret (y.2 - v, y.1))
else OComp.ret ((round (g j)).symm y)
/-- Evaluate the `k`-round Feistel network forward on `x` (rounds `0, …, k-1`), using
`g j` for rounds `j ≠ i` and the oracle for round `i`. -/
def fwdSim {k : ℕ} (g : Fin k → G → G) (i : Fin k) (x : G × G) : OComp G G (G × G) :=
OComp.steps (fwdOp g i) (List.finRange k) (OComp.ret x)
/-- Evaluate the inverse Feistel network on `y` (rounds `k-1, …, 0`), using `g j` for
rounds `j ≠ i` and the oracle for round `i`. -/
def invSim {k : ℕ} (g : Fin k → G → G) (i : Fin k) (y : G × G) : OComp G G (G × G) :=
OComp.steps (invOp g i) (List.finRange k).reverse (OComp.ret y)
/-- Round functions used by the `i`-th hybrid reduction with seed `ω = (keys, functions)`:
round `j < i` is the random function `ω.2 j`, round `j > i` is `F (ω.1 j)`, and round `i`
(answered by the oracle) is blanked to `0` here. -/
def redRounds {K : Type} (F : K → G → G) (k : ℕ) (i : Fin k)
(ω : (Fin k → K) × (Fin k → G → G)) : Fin k → G → G :=
Function.update (fun j => if (j : ℕ) < (i : ℕ) then ω.2 j else F (ω.1 j)) i (fun _ => 0)
/-- The `i`-th hybrid reduction for forward-only `D`, with seed `ω`: run `D` and answer each
query by the Feistel network with rounds `redRounds F k i ω`, round `i` asked to the oracle. -/
def prpRed {K : Type} (F : K → G → G) (k : ℕ) (D : Dist (G × G) (G × G)) (i : Fin k)
(ω : (Fin k → K) × (Fin k → G → G)) : Dist G G :=
OComp.simulate (fwdSim (redRounds F k i ω) i) D
/-- As `prpRed`, for `D` making forward (`inl`) and inverse (`inr`) queries. -/
def sprpRed {K : Type} (F : K → G → G) (k : ℕ) (D : Dist ((G × G) ⊕ (G × G)) (G × G))
(i : Fin k) (ω : (Fin k → K) × (Fin k → G → G)) : Dist G G :=
OComp.simulate (fun x => Sum.elim (fwdSim (redRounds F k i ω) i)
(invSim (redRounds F k i ω) i) x) D
/-- PRF advantage of a seeded (randomized) distinguisher `B : Ω → Dist G G`, with the seed
`ω` uniform and independent of the key `κ` (real world) or the function `f` (ideal world):
`|Pr_{ω,κ}[B ω ^ (F κ) = 1] - Pr_{ω,f}[B ω ^ f = 1]|`. -/
noncomputable def prfAdvR [Fintype G] [DecidableEq G] {K Ω : Type} [Fintype K] [Fintype Ω] (F : K → G → G)
(B : Ω → Dist G G) : ℝ :=
|prob (fun p : Ω × K => (B p.1).eval (F p.2) = true)
- prob (fun p : Ω × (G → G) => (B p.1).eval p.2 = true)|
end LubyRackoff