Documentation

CslibFrontier.Crypto.Protocols.UC.Execution

Call-bounded UC execution with static corruptions #

This module defines an execution experiment for the universal-composability (UC) framework of [Can20a], in this library's novel call-bounded port model: its budgets (Protocol.PolyBounded, Adversary.PolyBounded, Environment.PolyBounded) bound oracle call counts only, with unbounded local computation, and computational polynomial-time machine execution is open in #6043. For n-party protocols with a fixed set of statically corrupted parties, in the package style of CslibFrontier.Crypto.Protocols.UC.Machine:

In the execution UC.exec π A C Z κ z, the protocol π κ C is wrapped in UC.corruptRouter C: on the party port, the environment reaches only honest parties (i ∉ C), while the adversary reaches the party port of corrupted parties (i ∈ C) through .inl (i, x) on its network port, and every other network query .inr q is forwarded to π κ C. Thus corruptRouter C itself only redirects party-port inputs and outputs for C; stronger corruption behavior (such as Byzantine state exposure or arbitrary message injection, as in [Can20a]) is determined by how π κ C depends on C, and a protocol independent of C is tested only against party-port input/output substitution. Messages are pulled: a machine's outgoing messages wait in its state until queried.

UC.advantage π φ A S C Z κ z is the distinguishing advantage of Z between (π, A) and (φ, S). The budgets Protocol.PolyBounded, Adversary.PolyBounded and Environment.PolyBounded bound the number of calls of every activation, and the calls of the whole environment, by a polynomial in κ; the environment may read an auxiliary input of any length, but its budget does not grow with it, as in the model of [Can20a] where the environment's run time is bounded in terms of the security parameter. As always for call budgets, they bound interaction, not running time. UC.SimPolyBound g pA pS bounds a simulator's budget by g evaluated at κ plus the adversary's budget.

Main definitions #

Main results #

References #

Ports #

@[reducible, inline]
abbrev Cslib.Crypto.Protocols.UC.partySpec (n : ℕ) (In Out : Type) :
Fin n × In → Type

The party port of n parties: the query (i, x) gives input x to party i (or polls it), and the reply is party i's pending output, if any.

@[reducible, inline]

A port answering every query of type Q with a reply of type R.

@[reducible, inline]
abbrev Cslib.Crypto.Protocols.UC.protocolSpec (n : ℕ) (In Out NetQ NetR : Type) :
Fin n × In ⊕ NetQ → Type

The ports of a protocol: the party port and the network port.

@[reducible, inline]
abbrev Cslib.Crypto.Protocols.UC.execSpec (n : ℕ) (In Out AdvQ AdvR : Type) :
Fin n × In ⊕ AdvQ → Type

The ports of an execution seen by the environment: the party port and the adversary port.

@[reducible, inline]
abbrev Cslib.Crypto.Protocols.UC.queryParty {n : ℕ} {In Out AdvQ AdvR : Type} (i : Fin n) (x : In) :
ProbOracleComp (execSpec n In Out AdvQ AdvR) (Option Out)

Library infrastructure (no cited result): query party i with input x on the party port of an execution or protocol interface (execSpec / protocolSpec).

@[reducible, inline]
abbrev Cslib.Crypto.Protocols.UC.queryAdv {n : ℕ} {In Out AdvQ AdvR : Type} (q : AdvQ) :
ProbOracleComp (execSpec n In Out AdvQ AdvR) AdvR

Library infrastructure (no cited result): send query q to the adversary (or network) port of an execution or protocol interface (execSpec / protocolSpec).

@[reducible, inline]
abbrev Cslib.Crypto.Protocols.UC.queryNet {NetQ NetR : Type} (q : NetQ) :
ProbOracleComp (netSpec NetQ NetR) NetR

Library infrastructure (no cited result): send query q on a standalone network port (netSpec NetQ NetR).

Participants #

@[reducible, inline]
abbrev Cslib.Crypto.Protocols.UC.Protocol (n : ℕ) (In Out NetQ NetR : Type) :

An n-party protocol: a closed machine with a party port and a network port for every security parameter and set of corrupted parties.

structure Cslib.Crypto.Protocols.UC.IdealFunctionality (n : ℕ) (In Out BackQ BackR : Type) :

An n-party ideal functionality: a trusted machine with private state, which answers party inputs and the simulator's backdoor queries.

  • State : Type

    The private state.

  • init : ℕ → Finset (Fin n) → ProbComp self.State

    The initial state, given the security parameter and the corrupted parties.

  • onInput : Fin n → In → StateT self.State ProbComp (Option Out)

    Party i gives input x (or polls) and receives its pending output, if any.

  • onBackdoor : BackQ → StateT self.State ProbComp BackR

    A backdoor query of the adversary.

def Cslib.Crypto.Protocols.UC.IdealFunctionality.toProtocol {n : ℕ} {In Out BackQ BackR : Type} (F : IdealFunctionality n In Out BackQ BackR) :
Protocol n In Out BackQ BackR

The ideal protocol of a functionality: party inputs go to onInput, and the network port is the backdoor.

@[reducible, inline]
abbrev Cslib.Crypto.Protocols.UC.Adversary (n : ℕ) (AdvQ AdvR NetQ NetR : Type) :

An adversary (or simulator): a machine answering the environment's queries AdvQ with replies AdvR, talking to a network port with queries NetQ and replies NetR.

@[reducible, inline]
abbrev Cslib.Crypto.Protocols.UC.Environment (n : ℕ) (In Out AdvQ AdvR : Type) :

An environment: for every security parameter and auxiliary input, a program with private coins that activates parties and the adversary and outputs a bit.

@[reducible, inline]

The network queries of an n-party protocol with party inputs In and network queries NetQ behind static-corruption routing (corruptRouter): .inl (i, x) is an input to corrupted party i, and .inr q is a network query of the protocol.

@[reducible, inline]

The network replies of a protocol with party outputs Out and network replies NetR behind static-corruption routing: .inl o is the pending output of a corrupted party, if any, and .inr r is a network reply of the protocol.

@[reducible, inline]
abbrev Cslib.Crypto.Protocols.UC.ExecAdversary (n : ℕ) (In Out NetQ NetR AdvQ AdvR : Type) :

An adversary in the UC execution of an n-party protocol with party inputs In, outputs Out and network port NetQ/NetR: it answers the environment's queries AdvQ with replies AdvR by talking to the protocol's network port behind static-corruption routing.

Execution #

def Cslib.Crypto.Protocols.UC.routeNet {m : Type → Type} [Monad m] {n : ℕ} {In Out NetQ NetR : Type} (C : Finset (Fin n)) (onIn : Fin n → In → m (Option Out)) (onBack : NetQ → m NetR) :
RoutedNetQ n In NetQ → m (RoutedNetR Out NetR)

Network-side static-corruption routing over a monad m: an adversary-routed input .inl (i, x) reaches onIn i x only when i ∈ C (returning .inl none otherwise), and a network query .inr q is forwarded to onBack q.

@[simp]
theorem Cslib.Crypto.Protocols.UC.routeNet_inl {m : Type → Type} [Monad m] {n : ℕ} {In Out NetQ NetR : Type} (C : Finset (Fin n)) (onIn : Fin n → In → m (Option Out)) (onBack : NetQ → m NetR) (i : Fin n) (x : In) :
routeNet C onIn onBack (Sum.inl (i, x)) = if i ∈ C then Sum.inl <$> onIn i x else pure (Sum.inl none)

Library infrastructure (no cited result): routeNet on an adversary-routed party input runs onIn for corrupted parties and refuses honest parties.

@[simp]
theorem Cslib.Crypto.Protocols.UC.routeNet_inr {m : Type → Type} [Monad m] {n : ℕ} {In Out NetQ NetR : Type} (C : Finset (Fin n)) (onIn : Fin n → In → m (Option Out)) (onBack : NetQ → m NetR) (q : NetQ) :
routeNet C onIn onBack (Sum.inr q) = Sum.inr <$> onBack q

Library infrastructure (no cited result): routeNet on a network query forwards to onBack and wraps the reply in Sum.inr.

def Cslib.Crypto.Protocols.UC.corruptRouter {n : ℕ} {In Out NetQ NetR : Type} (C : Finset (Fin n)) (P : Machine OracleSpec.empty (protocolSpec n In Out NetQ NetR)) :
Machine OracleSpec.empty (protocolSpec n In Out (RoutedNetQ n In NetQ) (RoutedNetR Out NetR))

Static-corruption routing. The environment's input (i, x) reaches party i only when i is honest; the adversary's .inl (i, x) reaches party i only when i is corrupted; every other network query of the adversary is forwarded to the protocol.

@[simp]
theorem Cslib.Crypto.Protocols.UC.corruptRouter_handle_inl_of_notMem {n : ℕ} {In Out NetQ NetR : Type} (C : Finset (Fin n)) (P : Machine OracleSpec.empty (protocolSpec n In Out NetQ NetR)) {i : Fin n} (hi : i ∉ C) (x : In) :

Library infrastructure (no cited result): on an honest party query (i ∉ C), corruptRouter forwards the activation to P.

@[simp]
theorem Cslib.Crypto.Protocols.UC.corruptRouter_handle_inl_of_mem {n : ℕ} {In Out NetQ NetR : Type} (C : Finset (Fin n)) (P : Machine OracleSpec.empty (protocolSpec n In Out NetQ NetR)) {i : Fin n} (hi : i ∈ C) (x : In) :

Library infrastructure (no cited result): on a corrupted party query (i ∈ C), corruptRouter returns none without changing P's state.

@[simp]
theorem Cslib.Crypto.Protocols.UC.corruptRouter_handle_inr_inl_of_mem {n : ℕ} {In Out NetQ NetR : Type} (C : Finset (Fin n)) (P : Machine OracleSpec.empty (protocolSpec n In Out NetQ NetR)) {i : Fin n} (hi : i ∈ C) (x : In) :

Library infrastructure (no cited result): on an adversary-routed query to a corrupted party (i ∈ C), corruptRouter forwards to P's party port and wraps the reply in Sum.inl.

@[simp]
theorem Cslib.Crypto.Protocols.UC.corruptRouter_handle_inr_inl_of_notMem {n : ℕ} {In Out NetQ NetR : Type} (C : Finset (Fin n)) (P : Machine OracleSpec.empty (protocolSpec n In Out NetQ NetR)) {i : Fin n} (hi : i ∉ C) (x : In) :

Library infrastructure (no cited result): on an adversary-routed query to an honest party (i ∉ C), corruptRouter returns .inl none without changing P's state.

@[simp]
theorem Cslib.Crypto.Protocols.UC.corruptRouter_handle_inr_inr {n : ℕ} {In Out NetQ NetR : Type} (C : Finset (Fin n)) (P : Machine OracleSpec.empty (protocolSpec n In Out NetQ NetR)) (q : NetQ) :

Library infrastructure (no cited result): on a network query .inr q, corruptRouter forwards to P's network port and wraps the reply in Sum.inr.

theorem Cslib.Crypto.Protocols.UC.handle_corruptRouter_map_state {n : ℕ} {In Out NetQ NetR : Type} (C : Finset (Fin n)) (P₁ P₂ : Machine OracleSpec.empty (protocolSpec n In Out NetQ NetR)) (f : P₂.State → P₁.State) (h : ∀ (q : Fin n × In ⊕ NetQ) (s : P₂.State), (P₁.handle q).run (f s) = Prod.map id f <$> (P₂.handle q).run s) (q : Fin n × In ⊕ RoutedNetQ n In NetQ) (s : P₂.State) :
((corruptRouter C P₁).handle q).run (f s) = Prod.map id f <$> ((corruptRouter C P₂).handle q).run s

Intertwining two protocol machines intertwines their corruptRouter wrappers for any static corruption set C.

theorem Cslib.Crypto.Protocols.UC.corruptRouter_invariant_of_mem_support_runFrom {n : ℕ} {In Out NetQ NetR α : Type} (C : Finset (Fin n)) (P : Machine OracleSpec.empty (protocolSpec n In Out NetQ NetR)) (R : P.State → P.State → Prop) (hrefl : ∀ (s : P.State), R s s) (htrans : ∀ {a b c : P.State}, R a b → R b c → R a c) (hsingle : ∀ (q₀ : Fin n × In ⊕ NetQ) (s : P.State), ∀ r ∈ (Machine.closeEval ((P.handle q₀).run s)).support, R s r.2) (prog : ProbOracleComp (protocolSpec n In Out (RoutedNetQ n In NetQ) (RoutedNetR Out NetR)) α) (s : P.State) {x : α × P.State} (hx : x ∈ (Machine.closeEval ((corruptRouter C P).runFrom prog s)).support) :
R s x.2

Lifts a reflexive, transitive per-activation relation R from single steps of P through corruptRouter C P and any multi-step execution runFrom prog s.

@[reducible, inline]
abbrev Cslib.Crypto.Protocols.UC.liftNet {n : ℕ} {In Out NetQ NetR α : Type} (program : ProbOracleComp (netSpec NetQ NetR) α) :
ProbOracleComp (protocolSpec n In Out NetQ NetR) α

A program calling only the network port, as a program calling the ports of a protocol.

theorem Cslib.Crypto.Protocols.UC.runFrom_liftNet_map_state {n : ℕ} {In Out NetQ NetR ιI : Type} {I : ιI → Type} {α : Type} (M₁ : Machine I (protocolSpec n In Out NetQ NetR)) (M₂ : Machine I (netSpec NetQ NetR)) (f : M₂.State → M₁.State) (h : ∀ (q : NetQ) (s : M₂.State), (M₁.handle (Sum.inr q)).run (f s) = Prod.map id f <$> (M₂.handle q).run s) (program : ProbOracleComp (netSpec NetQ NetR) α) (s : M₂.State) :
M₁.runFrom (liftNet program) (f s) = Prod.map id f <$> M₂.runFrom program s

Running a network-port program liftNet program against a protocol-interface machine M₁ from f s factors through a network-interface machine M₂ whenever f intertwines M₁'s network-port handler (M₁.handle (.inr q)) with M₂.handle q.

@[reducible, inline]
abbrev Cslib.Crypto.Protocols.UC.liftAdversary {n : ℕ} {In Out NetQ NetR AdvQ AdvR : Type} (A : Machine (netSpec NetQ NetR) (netSpec AdvQ AdvR)) :
Machine (protocolSpec n In Out NetQ NetR) (execSpec n In Out AdvQ AdvR)

The adversary in front of the network port: party queries pass through unchanged, and the adversary's activations call the network port.

def Cslib.Crypto.Protocols.UC.execMachine {n : ℕ} {In Out NetQ NetR AdvQ AdvR : Type} (π : Protocol n In Out NetQ NetR) (A : ExecAdversary n In Out NetQ NetR AdvQ AdvR) (κ : ℕ) (C : Finset (Fin n)) :
Machine OracleSpec.empty (execSpec n In Out AdvQ AdvR)

The closed system the environment talks to: the adversary in front of the corruption-routed protocol.

theorem Cslib.Crypto.Protocols.UC.execMachine_handle_inl_of_notMem {n : ℕ} {In Out NetQ NetR AdvQ AdvR : Type} (π : Protocol n In Out NetQ NetR) (A : ExecAdversary n In Out NetQ NetR AdvQ AdvR) (κ : ℕ) (C : Finset (Fin n)) {i : Fin n} (hi : i ∉ C) (x : In) (s : (execMachine π A κ C).State) :
((execMachine π A κ C).handle (Sum.inl (i, x))).run s = (fun (p : Option Out × (π κ C).State) => (p.1, s.1, p.2)) <$> ((π κ C).handle (Sum.inl (i, x))).run s.2

Library infrastructure (no cited result): an honest party query (i ∉ C) to execMachine bypasses the adversary, runs π κ C on party i, and leaves the adversary's state unchanged.

@[simp]
theorem Cslib.Crypto.Protocols.UC.execMachine_handle_inl_of_mem {n : ℕ} {In Out NetQ NetR AdvQ AdvR : Type} (π : Protocol n In Out NetQ NetR) (A : ExecAdversary n In Out NetQ NetR AdvQ AdvR) (κ : ℕ) (C : Finset (Fin n)) {i : Fin n} (hi : i ∈ C) (x : In) :

Library infrastructure (no cited result): a corrupted party query (i ∈ C) to execMachine returns none without invoking the adversary or changing either state.

theorem Cslib.Crypto.Protocols.UC.execMachine_handle_inr {n : ℕ} {In Out NetQ NetR AdvQ AdvR : Type} (π : Protocol n In Out NetQ NetR) (A : ExecAdversary n In Out NetQ NetR AdvQ AdvR) (κ : ℕ) (C : Finset (Fin n)) (q : AdvQ) (s : (execMachine π A κ C).State) :
((execMachine π A κ C).handle (Sum.inr q)).run s = (fun (x : (netSpec AdvQ AdvR q × (A κ C).State) × (corruptRouter C (π κ C)).State) => match x with | ((r, sA), sP) => (r, sA, sP)) <$> (corruptRouter C (π κ C)).runFrom (liftNet (((A κ C).handle q).run s.1)) s.2

Library infrastructure (no cited result): an adversary query q to execMachine runs (A κ C).handle q lifted onto the network port against corruptRouter C (π κ C) and reassociates the resulting state pair.

def Cslib.Crypto.Protocols.UC.exec {n : ℕ} {In Out NetQ NetR AdvQ AdvR : Type} (π : Protocol n In Out NetQ NetR) (A : ExecAdversary n In Out NetQ NetR AdvQ AdvR) (C : Finset (Fin n)) (Z : Environment n In Out AdvQ AdvR) (κ : ℕ) (z : List Bool) :

The UC execution experiment: the environment's output bit when it interacts with protocol π and adversary A, with corrupted parties C, security parameter κ and auxiliary input z.

noncomputable def Cslib.Crypto.Protocols.UC.advantage {n : ℕ} {In Out AdvQ AdvR NetQ₁ NetR₁ NetQ₂ NetR₂ : Type} (π : Protocol n In Out NetQ₁ NetR₁) (φ : Protocol n In Out NetQ₂ NetR₂) (A : ExecAdversary n In Out NetQ₁ NetR₁ AdvQ AdvR) (S : ExecAdversary n In Out NetQ₂ NetR₂ AdvQ AdvR) (C : Finset (Fin n)) (Z : Environment n In Out AdvQ AdvR) (κ : ℕ) (z : List Bool) :

The advantage of the environment Z in distinguishing protocol π with adversary A from protocol φ with adversary S.

@[simp]
theorem Cslib.Crypto.Protocols.UC.advantage_self {n : ℕ} {In Out NetQ NetR AdvQ AdvR : Type} (π : Protocol n In Out NetQ NetR) (A : ExecAdversary n In Out NetQ NetR AdvQ AdvR) (C : Finset (Fin n)) (Z : Environment n In Out AdvQ AdvR) (κ : ℕ) (z : List Bool) :
advantage π π A A C Z κ z = 0

An execution cannot be distinguished from itself.

theorem Cslib.Crypto.Protocols.UC.advantage_comm {n : ℕ} {In Out AdvQ AdvR NetQ₁ NetR₁ NetQ₂ NetR₂ : Type} (π : Protocol n In Out NetQ₁ NetR₁) (φ : Protocol n In Out NetQ₂ NetR₂) (A : ExecAdversary n In Out NetQ₁ NetR₁ AdvQ AdvR) (S : ExecAdversary n In Out NetQ₂ NetR₂ AdvQ AdvR) (C : Finset (Fin n)) (Z : Environment n In Out AdvQ AdvR) (κ : ℕ) (z : List Bool) :
advantage π φ A S C Z κ z = advantage φ π S A C Z κ z

The advantage is symmetric.

theorem Cslib.Crypto.Protocols.UC.advantage_triangle {n : ℕ} {In Out AdvQ AdvR NetQ₁ NetR₁ NetQ₂ NetR₂ NetQ₃ NetR₃ : Type} (π₁ : Protocol n In Out NetQ₁ NetR₁) (π₂ : Protocol n In Out NetQ₂ NetR₂) (π₃ : Protocol n In Out NetQ₃ NetR₃) (A₁ : ExecAdversary n In Out NetQ₁ NetR₁ AdvQ AdvR) (A₂ : ExecAdversary n In Out NetQ₂ NetR₂ AdvQ AdvR) (A₃ : ExecAdversary n In Out NetQ₃ NetR₃ AdvQ AdvR) (C : Finset (Fin n)) (Z : Environment n In Out AdvQ AdvR) (κ : ℕ) (z : List Bool) :
advantage π₁ π₃ A₁ A₃ C Z κ z ≤ advantage π₁ π₂ A₁ A₂ C Z κ z + advantage π₂ π₃ A₂ A₃ C Z κ z

The triangle inequality through an intermediate protocol and adversary.

Polynomial budgets #

def Cslib.Crypto.Protocols.UC.Protocol.PolyBounded {n : ℕ} {In Out NetQ NetR : Type} (π : Protocol n In Out NetQ NetR) (p : Polynomial ℕ) :

Polynomial oracle-call-count bound on protocol activations (bounding oracle call counts only and leaving local computation unbounded, in this library's novel call-bounded port model; computational polynomial-time machine execution is open in #6043): every activation of the protocol at security parameter κ makes at most p.eval κ calls.

def Cslib.Crypto.Protocols.UC.Adversary.PolyBounded {n : ℕ} {NetQ NetR AdvQ AdvR : Type} (A : Adversary n AdvQ AdvR NetQ NetR) (p : Polynomial ℕ) :

Polynomial oracle-call-count bound on adversary activations (bounding oracle call counts only and leaving local computation unbounded, in this library's novel call-bounded port model; computational polynomial-time machine execution is open in #6043): every activation of the adversary at security parameter κ makes at most p.eval κ calls.

def Cslib.Crypto.Protocols.UC.Environment.PolyBounded {n : ℕ} {In Out AdvQ AdvR : Type} (Z : Environment n In Out AdvQ AdvR) (p : Polynomial ℕ) :

Polynomial oracle-call-count bound on an environment (bounding oracle call counts only and leaving local computation unbounded, in this library's novel call-bounded port model; computational polynomial-time machine execution is open in #6043): at security parameter κ, the environment makes at most p.eval κ calls in total, counting its private samples, whatever its auxiliary input.

The simulator budget pS is at most g evaluated at the security parameter plus the adversary budget pA. Since polynomials over ℕ are monotone, this is a bound by a polynomial in both the security parameter and the adversary's budget.

theorem Cslib.Crypto.Protocols.UC.Protocol.PolyBounded.mono {n : ℕ} {In Out NetQ NetR : Type} {π : Protocol n In Out NetQ NetR} {p q : Polynomial ℕ} (h : π.PolyBounded p) (hpq : ∀ (κ : ℕ), Polynomial.eval κ p ≤ Polynomial.eval κ q) :
theorem Cslib.Crypto.Protocols.UC.Adversary.PolyBounded.mono {n : ℕ} {NetQ NetR AdvQ AdvR : Type} {A : Adversary n AdvQ AdvR NetQ NetR} {p q : Polynomial ℕ} (h : A.PolyBounded p) (hpq : ∀ (κ : ℕ), Polynomial.eval κ p ≤ Polynomial.eval κ q) :
theorem Cslib.Crypto.Protocols.UC.Environment.PolyBounded.mono {n : ℕ} {In Out AdvQ AdvR : Type} {Z : Environment n In Out AdvQ AdvR} {p q : Polynomial ℕ} (h : Z.PolyBounded p) (hpq : ∀ (κ : ℕ), Polynomial.eval κ p ≤ Polynomial.eval κ q) :

An adversary's own budget is a simulator budget for it.

theorem Cslib.Crypto.Protocols.UC.SimPolyBound.trans {g₁₂ g₂₃ pA pS₂ pS₃ : Polynomial ℕ} (h₁₂ : SimPolyBound g₁₂ pA pS₂) (h₂₃ : SimPolyBound g₂₃ pS₂ pS₃) :
SimPolyBound (g₂₃.comp (Polynomial.X + g₁₂)) pA pS₃

Simulator budgets compose: a simulator for a simulator.

The simulator's budget is dominated pointwise by g composed with X + pA.