Documentation

CslibFrontier.Crypto.Protocols.SSP.Basic

State-separating proofs: parallel sessions and distinguishing advantage #

State-separating proofs organize a game-based security argument as an algebra of packages: stateful programs with an exported and an imported interface, which are composed sequentially and placed side by side. Here a package is an interactive machine Cslib.Crypto.Protocols.UC.Machine: sequential composition is Machine.comp, and its linking laws (Machine.link_comp, Machine.run_comp) are the associativity laws of the package algebra. This file adds

Main definitions #

Main results #

References #

Packages side by side #

@[reducible, inline]
abbrev Cslib.Crypto.Protocols.SSP.sessionSpec {ιE : Type} (m : ℕ) (E : ιE → Type) :
Fin m × ιE → Type

The interface of m sessions of the interface E: a query is a session index together with a query of E, and it is answered as in E.

def Cslib.Crypto.Protocols.SSP.parFin {ιI ιE : Type} {I : ιI → Type} {E : ιE → Type} {m : ℕ} (M : Fin m → UC.Machine I E) :

The packages M j run side by side as m independent sessions: the state is the tuple of the session states, initialized session by session, and the query (j, q) runs the activation of the j-th package on its own state, leaving the other sessions untouched.

theorem Cslib.Crypto.Protocols.SSP.parFin_handle {ιI ιE : Type} {I : ιI → Type} {E : ιE → Type} {m : ℕ} (M : Fin m → UC.Machine I E) (j : Fin m) (e : ιE) (s : (parFin M).State) :
((parFin M).handle (j, e)).run s = (fun (x : E e × (M j).State) => (x.1, Function.update s j x.2)) <$> ((M j).handle e).run (s j)

On the session j, parFin M runs an activation of M j on the state of that session.

theorem Cslib.Crypto.Protocols.SSP.isBounded_parFin {ιI ιE : Type} {I : ιI → Type} {E : ιE → Type} {m : ℕ} {M : Fin m → UC.Machine I E} {t : ℕ} (hM : ∀ (j : Fin m), (M j).IsBounded t) :
(parFin M).IsBounded (m * t)

Running m packages with per-activation call budget t side by side gives a package with call budget m * t.

def Cslib.Crypto.Protocols.SSP.par {ιI ιE₁ ιE₂ : Type} {I : ιI → Type} {E₁ : ιE₁ → Type} {E₂ : ιE₂ → Type} (M₁ : UC.Machine I E₁) (M₂ : UC.Machine I E₂) :

Two packages importing the same interface, run side by side behind the sum of their exported interfaces: each query is answered by the corresponding package, on its own state.

theorem Cslib.Crypto.Protocols.SSP.par_handle_inl {ιI ιE₁ ιE₂ : Type} {I : ιI → Type} {E₁ : ιE₁ → Type} {E₂ : ιE₂ → Type} (M₁ : UC.Machine I E₁) (M₂ : UC.Machine I E₂) (q : ιE₁) (s : (par M₁ M₂).State) :
((par M₁ M₂).handle (Sum.inl q)).run s = (fun (x : E₁ q × M₁.State) => (x.1, x.2, s.2)) <$> (M₁.handle q).run s.1

On the left interface, par M₁ M₂ runs an activation of M₁ on its own state.

theorem Cslib.Crypto.Protocols.SSP.par_handle_inr {ιI ιE₁ ιE₂ : Type} {I : ιI → Type} {E₁ : ιE₁ → Type} {E₂ : ιE₂ → Type} (M₁ : UC.Machine I E₁) (M₂ : UC.Machine I E₂) (q : ιE₂) (s : (par M₁ M₂).State) :
((par M₁ M₂).handle (Sum.inr q)).run s = (fun (x : E₂ q × M₂.State) => (x.1, s.1, x.2)) <$> (M₂.handle q).run s.2

On the right interface, par M₁ M₂ runs an activation of M₂ on its own state.

Distinguishing advantage #

noncomputable def Cslib.Crypto.Protocols.SSP.advantage {ιE : Type} {E : ιE → Type} (A : ProbOracleComp E Bool) (M₀ M₁ : UC.Machine OracleSpec.empty E) :

The advantage of the adversary A in distinguishing the closed packages M₀ and M₁: the advantage between the experiments of running A against each of them.

theorem Cslib.Crypto.Protocols.SSP.advantage_comm {ιE : Type} {E : ιE → Type} (A : ProbOracleComp E Bool) (M₀ M₁ : UC.Machine OracleSpec.empty E) :
advantage A M₀ M₁ = advantage A M₁ M₀
theorem Cslib.Crypto.Protocols.SSP.advantage_le_one {ιE : Type} {E : ιE → Type} (A : ProbOracleComp E Bool) (M₀ M₁ : UC.Machine OracleSpec.empty E) :
advantage A M₀ M₁ ≤ 1
theorem Cslib.Crypto.Protocols.SSP.advantage_triangle {ιE : Type} {E : ιE → Type} (A : ProbOracleComp E Bool) (M₀ M₁ M₂ : UC.Machine OracleSpec.empty E) :
advantage A M₀ M₂ ≤ advantage A M₀ M₁ + advantage A M₁ M₂
theorem Cslib.Crypto.Protocols.SSP.advantage_congr {ιE : Type} {E : ιE → Type} {A : ProbOracleComp E Bool} {M₀ M₀' M₁ M₁' : UC.Machine OracleSpec.empty E} (h₀ : (M₀.run A).eval = (M₀'.run A).eval) (h₁ : (M₁.run A).eval = (M₁'.run A).eval) :
advantage A M₀ M₁ = advantage A M₀' M₁'

The advantage depends on the two packages only through the output distributions that they give the adversary.

theorem Cslib.Crypto.Protocols.SSP.advantage_comp {ιJ ιE : Type} {J : ιJ → Type} {E : ιE → Type} (A : ProbOracleComp E Bool) (R : UC.Machine J E) (M₀ M₁ : UC.Machine OracleSpec.empty J) :
advantage A (R.comp M₀) (R.comp M₁) = advantage (R.link A) M₀ M₁

Reduction. Distinguishing R.comp M₀ from R.comp M₁ is distinguishing M₀ from M₁ by the adversary R.link A, which runs A against the reduction package R.

theorem Cslib.Crypto.Protocols.SSP.advantage_le_sum_range {ιE : Type} {E : ιE → Type} (A : ProbOracleComp E Bool) (H : ℕ → UC.Machine OracleSpec.empty E) (n : ℕ) :
advantage A (H 0) (H n) ≤ ∑ i ∈ Finset.range n, advantage A (H i) (H (i + 1))

Hybrid argument. The advantage between the first and the last of a sequence of closed packages is at most the sum of the advantages between consecutive ones.

State simulation #

theorem Cslib.Crypto.Protocols.SSP.eval_run {ιE : Type} {E : ιE → Type} {α : Type} (N : UC.Machine OracleSpec.empty E) (program : ProbOracleComp E α) :
(N.run program).eval = N.init.eval.bind fun (s : N.State) => PMF.map Prod.fst ((OracleComp.interpret (fun (q : ℕ ⊕ ιE) (state : N.State) => (UC.Machine.closeProgram (N.handler q state)).eval) program).run s)

The output distribution of a program run against a closed package: sample the initial state, then interpret the program with each activation read as a distribution.

theorem Cslib.Crypto.Protocols.SSP.eval_run_eq_runWith {ιE : Type} {E : ιE → Type} {α : Type} (N : UC.Machine OracleSpec.empty E) (program : ProbOracleComp E α) :
(N.run program).eval = N.init.eval.bind fun (s : N.State) => PMF.map Prod.fst (ProbOracleComp.runWith (fun (q : ιE) (s : N.State) => UC.Machine.closeEval ((N.handle q).run s)) program s)

The output distribution of a program run against a closed package, written with ProbOracleComp.runWith: sample the initial state, then run against the closed activation kernels fun q s => Machine.closeEval ((N.handle q).run s).

theorem Cslib.Crypto.Protocols.SSP.eval_run_eq_of_represent {ιE : Type} {E : ιE → Type} {α : Type} (M M' : UC.Machine OracleSpec.empty E) (represent : M.State → M'.State) (init : PMF.map represent M.init.eval = M'.init.eval) (step : ∀ (q : ιE) (s : M.State), PMF.map (fun (x : E q × M.State) => match x with | (a, s') => (a, represent s')) (UC.Machine.closeProgram ((M.handle q).run s)).eval = (UC.Machine.closeProgram ((M'.handle q).run (represent s))).eval) (program : ProbOracleComp E α) :
(M.run program).eval = (M'.run program).eval

State simulation. Let every state of the closed package M be represented by a state of the closed package M', so that the initial distribution of M maps to that of M', and every activation of M maps to the activation of M' from the represented state. Then every program has the same output distribution against M and against M'.