Documentation

CslibFrontier.Crypto.Protocols.UC.DistributedProtocol

Distributed protocols with per-party state isolation #

Library construction (no cited definition): DistributedProtocol compiles n structurally isolated per-party local states (Fin n → PartyState) plus a shared network/channel state (NetState) into both static Protocol (UC.Execution) and snapshot adaptive AdaptiveProtocol (UC.Adaptive).

Unlike monolithic Protocol and AdaptiveProtocol machines, where protocol authors must manually route per-party state (and, for AdaptiveProtocol, supply an arbitrary view projection):

Main definitions #

Main results #

structure Cslib.Crypto.Protocols.UC.DistributedState (n : ℕ) (PartyState NetState : Type) :

Library construction (no cited definition): state of an n-party distributed protocol, separating per-party local states parties : Fin n → PartyState from the shared network or channel state net : NetState.

  • parties : Fin n → PartyState

    Per-party local states indexed by party identifier.

  • net : NetState

    Shared network or channel state.

theorem Cslib.Crypto.Protocols.UC.DistributedState.ext_iff {n : ℕ} {PartyState NetState : Type} {x y : DistributedState n PartyState NetState} :
x = y ↔ x.parties = y.parties ∧ x.net = y.net
theorem Cslib.Crypto.Protocols.UC.DistributedState.ext {n : ℕ} {PartyState NetState : Type} {x y : DistributedState n PartyState NetState} (parties : x.parties = y.parties) (net : x.net = y.net) :
x = y
structure Cslib.Crypto.Protocols.UC.DistributedProtocol (n : ℕ) (In Out NetQ NetR : Type) :

Library construction (no cited definition): an n-party distributed protocol with structurally isolated per-party local states.

Each party i initializes independently (initParty), interacts on input only with its own PartyState and the shared NetState (onInput), and cannot directly read or modify any other party j ≠ i's local state. Adversary network queries (onNet) interact only with NetState.

  • PartyState : Type

    Local state type of each individual party.

  • NetState : Type

    Shared network or channel state type.

  • initParty : ℕ → Fin n → ProbComp self.PartyState

    Independent initial local-state sampler for party i at security parameter κ.

  • initNet : ℕ → ProbComp self.NetState

    Initial shared network-state sampler at security parameter κ.

  • onInput : ℕ → Fin n → In → StateT (self.PartyState × self.NetState) ProbComp (Option Out)

    Party i's input activation, reading and updating only (parties i, net).

  • onNet : ℕ → NetQ → StateT self.NetState ProbComp NetR

    Adversary network activation, reading and updating only net.

  • onCorrupt : ℕ → Fin n → self.PartyState → self.PartyState

    Local state transformation applied when party i is corrupted (defaults to identity).

def Cslib.Crypto.Protocols.UC.DistributedProtocol.toMachine {n : ℕ} {In Out NetQ NetR : Type} (P : DistributedProtocol n In Out NetQ NetR) (κ : ℕ) :

Library construction (no cited definition): compile a DistributedProtocol at security parameter κ into a closed Machine over protocolSpec.

Parties initialize independently via OracleComp.pi; party inputs update only parties i and net; network queries update only net.

def Cslib.Crypto.Protocols.UC.DistributedProtocol.toProtocol {n : ℕ} {In Out NetQ NetR : Type} (P : DistributedProtocol n In Out NetQ NetR) :
Protocol n In Out NetQ NetR

Library construction (no cited definition): compile a DistributedProtocol into a static Protocol whose machine is P.toMachine κ (independent of the static corruption set C).

def Cslib.Crypto.Protocols.UC.DistributedProtocol.toAdaptive {n : ℕ} {In Out NetQ NetR : Type} (P : DistributedProtocol n In Out NetQ NetR) (mem : PartyMemory := PartyMemory.nonErasing) :
AdaptiveProtocol n In Out NetQ NetR P.PartyState

Library construction (no cited definition): compile a DistributedProtocol into an AdaptiveProtocol with canonical per-party view fun _ i s => s.parties i and per-party corruption hook P.onCorrupt.

This reuses AdaptiveProtocol.recordSnapshot unchanged, so .nonErasing histories still record every party's view after each inner activation (including network queries); per-party activation histories remain open under #8377 item 6.

Call budgets #

structure Cslib.Crypto.Protocols.UC.DistributedProtocol.PolyBounded {n : ℕ} {In Out NetQ NetR : Type} (P : DistributedProtocol n In Out NetQ NetR) (pInitP pInitN pIn pNet : Polynomial ℕ) :

Library construction (no cited definition): polynomial call-budget witness for a DistributedProtocol, bounding private coin draws in initParty, initNet, onInput, and onNet by polynomials in κ.

theorem Cslib.Crypto.Protocols.UC.DistributedProtocol.toMachine_isBounded {n : ℕ} {In Out NetQ NetR : Type} (P : DistributedProtocol n In Out NetQ NetR) {κ bInitP bInitN bIn bNet : ℕ} (hInitP : ∀ (i : Fin n), OracleComp.IsQueryBounded (P.initParty κ i) bInitP) (hInitN : OracleComp.IsQueryBounded (P.initNet κ) bInitN) (hIn : ∀ (i : Fin n) (x : In) (ps : P.PartyState) (ns : P.NetState), OracleComp.IsQueryBounded ((P.onInput κ i x).run (ps, ns)) bIn) (hNet : ∀ (q : NetQ) (ns : P.NetState), OracleComp.IsQueryBounded ((P.onNet κ q).run ns) bNet) :
(P.toMachine κ).IsBounded (n * bInitP + bInitN + bIn + bNet)

Library infrastructure (no cited result): if each initialization and activation component of P is call-bounded, then P.toMachine κ is call-bounded by n * bInitP + bInitN + bIn + bNet.

theorem Cslib.Crypto.Protocols.UC.DistributedProtocol.toProtocol_polyBounded {n : ℕ} {In Out NetQ NetR : Type} {P : DistributedProtocol n In Out NetQ NetR} {pInitP pInitN pIn pNet : Polynomial ℕ} (h : P.PolyBounded pInitP pInitN pIn pNet) :
P.toProtocol.PolyBounded (Polynomial.C n * pInitP + pInitN + pIn + pNet)

Library infrastructure (no cited result): polynomial call budgets of a DistributedProtocol propagate to P.toProtocol.

theorem Cslib.Crypto.Protocols.UC.DistributedProtocol.toAdaptive_polyBounded {n : ℕ} {In Out NetQ NetR : Type} {P : DistributedProtocol n In Out NetQ NetR} {pInitP pInitN pIn pNet : Polynomial ℕ} (h : P.PolyBounded pInitP pInitN pIn pNet) (mem : PartyMemory := PartyMemory.nonErasing) :
(P.toAdaptive mem).PolyBounded (Polynomial.C n * pInitP + pInitN + pIn + pNet)

Library infrastructure (no cited result): polynomial call budgets of a DistributedProtocol propagate to P.toAdaptive mem.

Initialization and single-step local-state isolation #

theorem Cslib.Crypto.Protocols.UC.DistributedProtocol.mem_support_init_iff {n : ℕ} {In Out NetQ NetR : Type} (P : DistributedProtocol n In Out NetQ NetR) (κ : ℕ) (s : DistributedState n P.PartyState P.NetState) :
s ∈ (P.toMachine κ).init.eval.support ↔ (∀ (i : Fin n), s.parties i ∈ (P.initParty κ i).eval.support) ∧ s.net ∈ (P.initNet κ).eval.support

Library infrastructure (no cited result): a distributed state is in the support of (P.toMachine κ).init iff each party's local state is in its independent initializer's support and net is in initNet's support.

theorem Cslib.Crypto.Protocols.UC.DistributedProtocol.toAdaptive_onCorrupt_parties_ne {n : ℕ} {In Out NetQ NetR : Type} (P : DistributedProtocol n In Out NetQ NetR) (mem : PartyMemory) (κ : ℕ) {i j : Fin n} (hji : j ≠ i) (s : DistributedState n P.PartyState P.NetState) :
((P.toAdaptive mem).onCorrupt κ i s).parties j = s.parties j

Library infrastructure (no cited result): corrupting party i leaves every other party j ≠ i's local state unchanged.

@[simp]
theorem Cslib.Crypto.Protocols.UC.DistributedProtocol.toAdaptive_onCorrupt_net {n : ℕ} {In Out NetQ NetR : Type} (P : DistributedProtocol n In Out NetQ NetR) (mem : PartyMemory) (κ : ℕ) (i : Fin n) (s : DistributedState n P.PartyState P.NetState) :
((P.toAdaptive mem).onCorrupt κ i s).net = s.net

Library infrastructure (no cited result): corrupting party i leaves net unchanged.

theorem Cslib.Crypto.Protocols.UC.DistributedProtocol.applyInitialCorruptions_parties_of_not_mem {n : ℕ} {In Out NetQ NetR : Type} (P : DistributedProtocol n In Out NetQ NetR) (mem : PartyMemory) (κ : ℕ) (C₀ : Finset (Fin n)) {j : Fin n} (hj : j ∉ C₀) (s : DistributedState n P.PartyState P.NetState) :

Library infrastructure (no cited result): initial corruptions C₀ leave every uncorrupted party j ∉ C₀'s local state unchanged.

theorem Cslib.Crypto.Protocols.UC.DistributedProtocol.applyInitialCorruptions_net {n : ℕ} {In Out NetQ NetR : Type} (P : DistributedProtocol n In Out NetQ NetR) (mem : PartyMemory) (κ : ℕ) (C₀ : Finset (Fin n)) (s : DistributedState n P.PartyState P.NetState) :

Library infrastructure (no cited result): initial corruptions leave the shared network state net unchanged.

theorem Cslib.Crypto.Protocols.UC.DistributedProtocol.mem_support_closeEval_handle_input {n : ℕ} {In Out NetQ NetR : Type} (P : DistributedProtocol n In Out NetQ NetR) (κ : ℕ) (i : Fin n) (x : In) (s : DistributedState n P.PartyState P.NetState) {y : Option Out × DistributedState n P.PartyState P.NetState} (hy : y ∈ (Machine.closeEval (((P.toMachine κ).handle (Sum.inl (i, x))).run s)).support) {j : Fin n} :
j ≠ i → y.2.parties j = s.parties j

Library infrastructure (no cited result): activating party i leaves every other party j ≠ i's local state unchanged on every supported outcome.

theorem Cslib.Crypto.Protocols.UC.DistributedProtocol.mem_support_closeEval_handle_net {n : ℕ} {In Out NetQ NetR : Type} (P : DistributedProtocol n In Out NetQ NetR) (κ : ℕ) (q : NetQ) (s : DistributedState n P.PartyState P.NetState) {y : NetR × DistributedState n P.PartyState P.NetState} (hy : y ∈ (Machine.closeEval (((P.toMachine κ).handle (Sum.inr q)).run s)).support) :

Library infrastructure (no cited result): a network query leaves every party's local state unchanged on every supported outcome.

End-to-end execution honest-party isolation #

theorem Cslib.Crypto.Protocols.UC.DistributedProtocol.corruptRouter_runFrom_parties_eq {n : ℕ} {In Out NetQ NetR : Type} (P : DistributedProtocol n In Out NetQ NetR) (κ : ℕ) (C : Finset (Fin n)) (j : Fin n) (hj : j ∉ C) {α : Type} (prog : ProbOracleComp (protocolSpec n In Out (RoutedNetQ n In NetQ) (RoutedNetR Out NetR)) α) (hprog : OracleComp.QueriesSatisfy (Sum.elim (fun (x : ℕ) => True) fun (q : Fin n × In ⊕ RoutedNetQ n In NetQ) => ∀ (x : In), q ≠ Sum.inl (j, x)) prog) (s : DistributedState n P.PartyState P.NetState) {y : α × DistributedState n P.PartyState P.NetState} (hy : y ∈ (Machine.closeEval ((corruptRouter C (P.toMachine κ)).runFrom prog s)).support) :
y.2.parties j = s.parties j

Library infrastructure (no cited result): under static corruptRouter C (P.toMachine κ), for any honest party j ∉ C and any program prog that never queries party j directly on the party port, j's local state s.parties j is invariant across the entire Machine.runFrom execution (even under arbitrary corrupted-party activations and network queries).

theorem Cslib.Crypto.Protocols.UC.DistributedProtocol.execMachine_runFrom_parties_eq {n : ℕ} {In Out NetQ NetR : Type} (P : DistributedProtocol n In Out NetQ NetR) {AdvQ AdvR : Type} (A : ExecAdversary n In Out NetQ NetR AdvQ AdvR) (κ : ℕ) (C : Finset (Fin n)) (j : Fin n) (hj : j ∉ C) {α : Type} (prog : ProbOracleComp (execSpec n In Out AdvQ AdvR) α) (hprog : OracleComp.QueriesSatisfy (Sum.elim (fun (x : ℕ) => True) fun (q : Fin n × In ⊕ AdvQ) => ∀ (x : In), q ≠ Sum.inl (j, x)) prog) (sA : (A κ C).State) (sP : DistributedState n P.PartyState P.NetState) {a : α} {sA' : (A κ C).State} {sP' : DistributedState n P.PartyState P.NetState} (hy : (a, sA', sP') ∈ (Machine.closeEval ((execMachine P.toProtocol A κ C).runFrom prog (sA, sP))).support) :
sP'.parties j = sP.parties j

Library infrastructure (no cited result): in the full static UC execution machine execMachine P.toProtocol A κ C, for any honest party j ∉ C and any environment program prog that never queries party j directly, j's local state parties j is invariant across Machine.runFrom, regardless of adversary A's behavior.

theorem Cslib.Crypto.Protocols.UC.DistributedProtocol.adaptiveRouter_runFrom_parties_eq {n : ℕ} {In Out NetQ NetR : Type} (P : DistributedProtocol n In Out NetQ NetR) (mode : CorruptionMode) (mem : PartyMemory) (κ : ℕ) (C₀ : Finset (Fin n)) (j : Fin n) {α : Type} (prog : ProbOracleComp (adaptiveProtocolSpec n In Out NetQ NetR P.PartyState) α) (hprog : OracleComp.QueriesSatisfy (Sum.elim (fun (x : ℕ) => True) fun (q : AdaptivePartyQ n In ⊕ AdaptiveNetQ n In NetQ) => (∀ (x : In), q ≠ Sum.inl (AdaptivePartyQ.party j x)) ∧ q ≠ Sum.inr (AdaptiveNetQ.corrupt j)) prog) (s : AdaptiveRouterState (DistributedState n P.PartyState P.NetState) P.PartyState n) (hj : j ∉ s.corrupted) {y : α × AdaptiveRouterState (DistributedState n P.PartyState P.NetState) P.PartyState n} (hy : y ∈ (Machine.closeEval ((adaptiveRouter mode (P.toAdaptive mem) κ C₀).runFrom prog s)).support) :
j ∉ y.2.corrupted ∧ y.2.inner.parties j = s.inner.parties j

Library infrastructure (no cited result): under adaptiveRouter mode (P.toAdaptive mem) κ C₀, for any initially uncorrupted party j ∉ s.corrupted and any program prog that neither activates j on the environment party port nor corrupts j, j remains uncorrupted and j's local state inner.parties j is invariant across the entire Machine.runFrom execution in both .static and .adaptive modes.

@[simp]

Library infrastructure (no cited result): under P.toAdaptive mem, the canonical corruption report's current field for party i is s.inner.parties i.

theorem Cslib.Crypto.Protocols.UC.DistributedProtocol.toAdaptive_toStatic_of_onCorrupt_eq {n : ℕ} {In Out NetQ NetR : Type} (P : DistributedProtocol n In Out NetQ NetR) (mem : PartyMemory) (hon : ∀ (κ : ℕ) (i : Fin n) (ps : P.PartyState), P.onCorrupt κ i ps = ps) :

Library infrastructure (no cited result): when P.onCorrupt is the identity, converting P.toAdaptive mem back to a static protocol yields P.toProtocol.