Even–Mansour cipher in the random-permutation model
DefinitionCityEMblock-ciphercryptographyrandom-permutation-model
Blocks are elements of a finite abelian group (for -bit blocks and is XOR). For keys and a permutation of , the Even–Mansour permutation is . A distinguisher is a deterministic adaptive oracle algorithm (LubyRackoff.OComp) whose queries are (construction) or (public permutation), each forward or inverse; QueryBounded D qe qp says that on every oracle it makes at most construction and permutation queries. For a key schedule , advK κ D is
with uniform on and independent uniform permutations of ; emAdv uses independent uniform and emAdv1 uses uniform.
Definition code
import Definitions.Def_LubyRackoff
/-!
# The Even–Mansour cipher in the random-permutation model
Blocks are elements of a finite abelian group `X` (for `n`-bit blocks take
`X = Fin n → ZMod 2`, so `|X| = 2ⁿ` and `+` is XOR). A public permutation `P` of `X` is
drawn uniformly at random, and the Even–Mansour cipher with keys `k₁, k₂ : X` is
`E(x) = P(x + k₁) + k₂`. The adversary has two-sided access both to the construction
(the cipher, or in the ideal world an independent uniform permutation) and to the public
permutation `P`. Adversaries are deterministic adaptive oracle algorithms with unbounded
computation (`LubyRackoff.OComp`), and probabilities are uniform counting probabilities
(`LubyRackoff.prob`).
-/
namespace CityEM
open LubyRackoff
variable {X : Type} [AddCommGroup X]
/-- The Even–Mansour permutation `x ↦ P(x + k₁) + k₂`. -/
def em (k₁ k₂ : X) (P : Equiv.Perm X) : Equiv.Perm X :=
((Equiv.addRight k₁).trans P).trans (Equiv.addRight k₂)
/-- Oracle queries: `inl` goes to the construction, `inr` to the public permutation;
within each, `inl x` asks for the forward value at `x` and `inr y` for the inverse at `y`. -/
abbrev Query (X : Type) := (X ⊕ X) ⊕ (X ⊕ X)
/-- The joint oracle: construction `E` and public permutation `P`, both two-sided. -/
def oracle (E P : Equiv.Perm X) : Query X → X :=
Sum.elim (both E) (both P)
/-- `c` makes at most `qe` construction queries and at most `qp` public-permutation
queries (forward and inverse both count), whatever the oracle. -/
def QueryBounded {α : Type} (c : OComp (Query X) X α) (qe qp : ℕ) : Prop :=
∀ O : Query X → X,
((c.transcript O).filter fun p => p.1.isLeft).length ≤ qe ∧
((c.transcript O).filter fun p => p.1.isRight).length ≤ qp
/-- Advantage of `D` against Even–Mansour with key schedule `κ`: the key pair `κ k` for a
uniform `k : K` and an independent uniform public permutation `P` (real world), versus
two independent uniform permutations `π, P` (ideal world). -/
noncomputable def advK [Fintype X] [DecidableEq X] {K : Type} [Fintype K]
(κ : K → X × X) (D : Dist (Query X) X) : ℝ :=
adv D (fun ω : K × Equiv.Perm X => oracle (em (κ ω.1).1 (κ ω.1).2 ω.2) ω.2)
(fun ω : Equiv.Perm X × Equiv.Perm X => oracle ω.1 ω.2)
/-- Two-key Even–Mansour: independent uniform keys `k₁, k₂`. -/
noncomputable def emAdv [Fintype X] [DecidableEq X] (D : Dist (Query X) X) : ℝ :=
advK (fun k : X × X => k) D
/-- Single-key Even–Mansour: `k₁ = k₂ = k` for a uniform `k`. -/
noncomputable def emAdv1 [Fintype X] [DecidableEq X] (D : Dist (Query X) X) : ℝ :=
advK (fun k : X => (k, k)) D
end CityEM
Source
Even–Mansour, J. Cryptology 10(3) 1997, https://doi.org/10.1007/s001459900025