Documentation

CslibFrontier.Crypto.Protocols.UC.Adaptive

Adaptive corruptions (snapshot model) in the UC execution #

Extends CslibFrontier.Crypto.Protocols.UC.Execution with CorruptionMode (.static vs .adaptive) and a snapshot-based corruption exposure interface (PartyMemory: .erasing vs .nonErasing), inspired by Section 7.1 (pp. 28:69–70), Section 7.1.1 (p. 28:71), and Section 7.2 (pp. 28:73–74) of [Can20a] (J. ACM pagination; ePrint 2000/067 of Feb 11, 2020, p. 74).

Scope #

[Can20a] §7.1.1 write-once / non-erasing storage restrictions and mandatory coin-exposure / per-party activation-granularity guarantees, universal composition under adaptive corruption, multiple sessions, proactive/passive modes, subroutine corruption paths, PPT bounds, and [CF01] Theorems 8 and 11 remain open and out of scope. Existing static definitions in Execution, Emulation, DummyAdversary, and Composition are unchanged.

Main definitions #

Main results #

References #

Modes, protocols, reports, and ports #

When corruption may occur during an execution: either only at invocation (static) or at any time (adaptive) ([Can20a], Section 7.1.1, p. 28:71).

Instances For

    Router trace-exposure flag in the snapshot corruption model: .erasing exposes only the post-corruption view snapshot (CorruptionReport.history = none), while .nonErasing exposes the recorded list of per-activation P.view snapshots (some (s.trace i)). This flag governs only CorruptionReport.history in adaptiveRouter; it does not enforce [Can20a] §7.1.1's write-once storage restriction, coin exposure, or per-party activation granularity (which stay open).

    Instances For
      structure Cslib.Crypto.Protocols.UC.AdaptiveProtocol (n : ℕ) (In Out NetQ NetR View : Type) :

      An n-party protocol equipped for the snapshot adaptive-corruption model: a closed machine per security parameter κ, an arbitrary caller-supplied per-party view projection view (which need not expose all stored coins or private state, e.g. View := Unit), a state transition onCorrupt applied when party i is corrupted, and a trace-exposure flag memory.

      • machine : ℕ → Machine OracleSpec.empty (protocolSpec n In Out NetQ NetR)

        The protocol machine at security parameter κ.

      • view (κ : ℕ) : Fin n → (self.machine κ).State → View

        Arbitrary caller-supplied projection from inner protocol state to party i's reported view (may hide stored coins or state, e.g. with View := Unit).

      • onCorrupt (κ : ℕ) : Fin n → (self.machine κ).State → (self.machine κ).State

        The protocol's own reaction when party i is corrupted (replacing π κ C's dependence on C in static Protocol).

      • memory : PartyMemory

        Router trace-exposure flag selecting whether past view snapshots are omitted or included in CorruptionReport.history.

      The corruption report returned to the adversary when corrupting party i: its current view and, for .nonErasing protocols, the oldest-first history of snapshots since initialization.

      • current : View

        Party i's current view at corruption.

      • history : Option (List View)

        Oldest-first sequence of snapshots since initialization (some iff .nonErasing).

      Instances For
        @[instance_reducible]

        The state maintained by adaptiveRouter: the inner protocol state, the currently corrupted parties, and the per-party trace of oldest-first view snapshots.

        • inner : S

          The inner protocol machine's state.

        • corrupted : Finset (Fin n)

          The set of currently corrupted parties.

        • trace : Fin n → List View

          Per-party oldest-first snapshot history recorded at init and after each inner activation.

        Environment-side queries to the party and corruption-status interface: .party i x activates party i with input x, and .status queries the current set of corrupted parties ([Can20a], Section 7.1, p. 28:70, the identity-revealing f = id case of standard f-revealing corruption on the corruption aggregation ITI).

        Instances For
          @[instance_reducible]
          def Cslib.Crypto.Protocols.UC.instDecidableEqAdaptivePartyQ.decEq {n✝ : ℕ} {In✝ : Type} [DecidableEq In✝] (x✝ x✝¹ : AdaptivePartyQ n✝ In✝) :
          Decidable (x✝ = x✝¹)
          @[instance_reducible]
          instance Cslib.Crypto.Protocols.UC.instReprAdaptivePartyQ {n✝ : ℕ} {In✝ : Type} [Repr In✝] :
          Repr (AdaptivePartyQ n✝ In✝)

          Reply types for AdaptivePartyQ: party activations return Option Out, and .status returns Finset (Fin n).

          Adversary-side queries behind adaptiveRouter: drive a corrupted party (party), corrupt a party (corrupt), or send a protocol network query (net).

          Instances For
            def Cslib.Crypto.Protocols.UC.instDecidableEqAdaptiveNetQ.decEq {n✝ : ℕ} {In✝ NetQ✝ : Type} [DecidableEq In✝] [DecidableEq NetQ✝] (x✝ x✝¹ : AdaptiveNetQ n✝ In✝ NetQ✝) :
            Decidable (x✝ = x✝¹)
            @[instance_reducible]
            instance Cslib.Crypto.Protocols.UC.instDecidableEqAdaptiveNetQ {n✝ : ℕ} {In✝ NetQ✝ : Type} [DecidableEq In✝] [DecidableEq NetQ✝] :
            DecidableEq (AdaptiveNetQ n✝ In✝ NetQ✝)
            def Cslib.Crypto.Protocols.UC.instReprAdaptiveNetQ.repr {n✝ : ℕ} {In✝ NetQ✝ : Type} [Repr In✝] [Repr NetQ✝] :
            AdaptiveNetQ n✝ In✝ NetQ✝ → ℕ → Std.Format
            @[instance_reducible]
            instance Cslib.Crypto.Protocols.UC.instReprAdaptiveNetQ {n✝ : ℕ} {In✝ NetQ✝ : Type} [Repr In✝] [Repr NetQ✝] :
            Repr (AdaptiveNetQ n✝ In✝ NetQ✝)
            inductive Cslib.Crypto.Protocols.UC.AdaptiveNetR (Out NetR View : Type) :

            Adversary-side replies behind adaptiveRouter, matching AdaptiveNetQ.

            Instances For
              def Cslib.Crypto.Protocols.UC.instDecidableEqAdaptiveNetR.decEq {Out✝ NetR✝ View✝ : Type} [DecidableEq Out✝] [DecidableEq NetR✝] [DecidableEq View✝] (x✝ x✝¹ : AdaptiveNetR Out✝ NetR✝ View✝) :
              Decidable (x✝ = x✝¹)
              @[instance_reducible]
              instance Cslib.Crypto.Protocols.UC.instDecidableEqAdaptiveNetR {Out✝ NetR✝ View✝ : Type} [DecidableEq Out✝] [DecidableEq NetR✝] [DecidableEq View✝] :
              DecidableEq (AdaptiveNetR Out✝ NetR✝ View✝)
              def Cslib.Crypto.Protocols.UC.instReprAdaptiveNetR.repr {Out✝ NetR✝ View✝ : Type} [Repr Out✝] [Repr NetR✝] [Repr View✝] :
              AdaptiveNetR Out✝ NetR✝ View✝ → ℕ → Std.Format
              @[instance_reducible]
              instance Cslib.Crypto.Protocols.UC.instReprAdaptiveNetR {Out✝ NetR✝ View✝ : Type} [Repr Out✝] [Repr NetR✝] [Repr View✝] :
              Repr (AdaptiveNetR Out✝ NetR✝ View✝)
              @[reducible, inline]
              abbrev Cslib.Crypto.Protocols.UC.adaptiveProtocolSpec (n : ℕ) (In Out NetQ NetR View : Type) :
              AdaptivePartyQ n In ⊕ AdaptiveNetQ n In NetQ → Type

              The ports exported by adaptiveRouter: the environment's party/status port and the adversary's routed network port.

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

              The ports seen by an adaptive environment: the party/status port and the adversary port.

              Adaptive router and participants #

              def Cslib.Crypto.Protocols.UC.AdaptiveProtocol.applyInitialCorruptions {n : ℕ} {In Out NetQ NetR View : Type} (P : AdaptiveProtocol n In Out NetQ NetR View) (κ : ℕ) (C₀ : Finset (Fin n)) (s : (P.machine κ).State) :
              (P.machine κ).State

              Apply P.onCorrupt κ i in canonical order for every i ∈ C₀ at initialization.

              def Cslib.Crypto.Protocols.UC.AdaptiveProtocol.corruptionReport {n : ℕ} {In Out NetQ NetR View : Type} (P : AdaptiveProtocol n In Out NetQ NetR View) (κ : ℕ) (i : Fin n) (s : AdaptiveRouterState (P.machine κ).State View n) :

              Build the corruption report for party i from a router state.

              def Cslib.Crypto.Protocols.UC.AdaptiveProtocol.recordSnapshot {n : ℕ} {In Out NetQ NetR View : Type} (P : AdaptiveProtocol n In Out NetQ NetR View) (κ : ℕ) (s' : (P.machine κ).State) (corrupted : Finset (Fin n)) (trace : Fin n → List View) :

              Update the router state after an inner protocol activation by appending every party's P.view snapshot (so .nonErasing histories reflect global inner-activation counts).

              def Cslib.Crypto.Protocols.UC.adaptiveRouter {n : ℕ} {In Out NetQ NetR View : Type} (mode : CorruptionMode) (P : AdaptiveProtocol n In Out NetQ NetR View) (κ : ℕ) (C₀ : Finset (Fin n)) :

              The snapshot-model adaptive corruption router wrapping P.machine κ with initial corruptions C₀. Initial corruptions apply P.onCorrupt at init. Environment party calls addressed to corrupted parties are dropped (none, matching static corruptRouter); adversary party calls are allowed only for corrupted parties; .status returns s.corrupted; .corrupt i is ignored for i ∉ s.corrupted in .static mode and in .adaptive mode applies P.onCorrupt, inserts i, and computes P.corruptionReport after P.onCorrupt without recording an extra snapshot of the onCorrupt transition itself.

              structure Cslib.Crypto.Protocols.UC.AdaptiveAdversary (n : ℕ) (In Out NetQ NetR View AdvQ AdvR : Type) :

              An adversary (or simulator) in the adaptive execution: an initial corruption set initial κ at invocation and an interactive machine talking to the routed network port AdaptiveNetQ/AdaptiveNetR. Its internal state is generic.

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

              An environment in the adaptive execution: a program with private coins interacting with the party/status port and the adversary, outputting a bit.

              def Cslib.Crypto.Protocols.UC.liftPartyQuery {n : ℕ} {In Out AdvQ AdvR α : Type} (program : ProbOracleComp (execSpec n In Out AdvQ AdvR) α) :
              ProbOracleComp (adaptiveExecSpec n In Out AdvQ AdvR) α

              Embed a static execSpec program into adaptiveExecSpec by sending party calls to AdaptivePartyQ.party and never querying .status.

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

              Embed a static environment into AdaptiveEnvironment as one that never queries .status.

              def Cslib.Crypto.Protocols.UC.IdealFunctionality.toAdaptive {n : ℕ} {In Out View BackQ BackR : Type} (F : IdealFunctionality n In Out BackQ BackR) (reveal : ℕ → F.State → Fin n → View) (onCorrupt : ℕ → Fin n → F.State → F.State := fun (x : ℕ) (x_1 : Fin n) (s : F.State) => s) :
              AdaptiveProtocol n In Out BackQ BackR View

              Embed an IdealFunctionality as an AdaptiveProtocol with memory := .erasing, view-leakage map reveal, and optional corruption-notification state hook onCorrupt ([Can20a], Section 7.2, pp. 28:73–74, standard PID-wise corruption). Marking ideal functionalities .erasing models that F's internal state belongs to no party and only reveal is exposed on corruption; rule (1)'s disclosure of party p's past inputs and subroutine outputs holds when F's state records them and reveal exposes them. When onCorrupt is supplied, F learns of both initial corruptions (via applyInitialCorruptions) and mid-run corruptions (via adaptiveRouter), so (F.toAdaptive reveal onCorrupt).toStatic = F.toProtocol whenever F.init κ C factors as applyInitialCorruptions κ C <$> F.init κ ∅ (IdealFunctionality.toStatic_toAdaptive). In particular, corruption-independent initialization alone does not yield the static round-trip for an arbitrary onCorrupt hook; it suffices when paired with the default identity hook fun _ _ s => s (IdealFunctionality.toStatic_toAdaptive_of_initIndep), whereas deterministically tracked initial corruptions require the explicit factorization above (and arbitrary C-dependent probabilistic sampling inside F.init κ C cannot be reconstructed after init and remains outside AdaptiveProtocol).

              Execution and advantage #

              @[reducible, inline]
              abbrev Cslib.Crypto.Protocols.UC.liftAdaptiveNet {n : ℕ} {In Out Q R α : Type} (program : ProbOracleComp (netSpec Q R) α) :

              Mirror of UC.liftNet for the adaptive left port adaptivePartySpec n In Out (which extends partySpec n In Out with .status, so UC.liftNet does not apply directly).

              @[reducible, inline]
              abbrev Cslib.Crypto.Protocols.UC.liftAdaptiveAdversary {n : ℕ} {In Out Q R AdvQ AdvR : Type} (A : Machine (netSpec Q R) (netSpec AdvQ AdvR)) :
              Machine (OracleSpec.sum (adaptivePartySpec n In Out) (netSpec Q R)) (adaptiveExecSpec n In Out AdvQ AdvR)

              Mirror of UC.liftAdversary for adaptivePartySpec n In Out.

              def Cslib.Crypto.Protocols.UC.adaptiveExecMachine {n : ℕ} {In Out NetQ NetR View AdvQ AdvR : Type} (mode : CorruptionMode) (P : AdaptiveProtocol n In Out NetQ NetR View) (A : AdaptiveAdversary n In Out NetQ NetR View AdvQ AdvR) (κ : ℕ) :

              The closed machine of an adaptive execution: A placed in front of adaptiveRouter.

              def Cslib.Crypto.Protocols.UC.adaptiveExec {n : ℕ} {In Out NetQ NetR View AdvQ AdvR : Type} (mode : CorruptionMode) (P : AdaptiveProtocol n In Out NetQ NetR View) (A : AdaptiveAdversary n In Out NetQ NetR View AdvQ AdvR) (Z : AdaptiveEnvironment n In Out AdvQ AdvR) (κ : ℕ) (z : List Bool) :

              The adaptive UC execution experiment: the environment's output bit when interacting with P and A under mode, at security parameter κ and auxiliary input z.

              noncomputable def Cslib.Crypto.Protocols.UC.adaptiveAdvantage {n : ℕ} {In Out AdvQ AdvR NetQ₁ NetR₁ View₁ NetQ₂ NetR₂ View₂ : Type} (mode : CorruptionMode) (P : AdaptiveProtocol n In Out NetQ₁ NetR₁ View₁) (Q : AdaptiveProtocol n In Out NetQ₂ NetR₂ View₂) (A : AdaptiveAdversary n In Out NetQ₁ NetR₁ View₁ AdvQ AdvR) (S : AdaptiveAdversary n In Out NetQ₂ NetR₂ View₂ AdvQ AdvR) (Z : AdaptiveEnvironment n In Out AdvQ AdvR) (κ : ℕ) (z : List Bool) :

              The advantage of Z in distinguishing (P, A) from (Q, S) under mode. Both worlds run under the same mode, while each uses its own protocol's memory.

              @[simp]
              theorem Cslib.Crypto.Protocols.UC.adaptiveAdvantage_self {n : ℕ} {In Out NetQ NetR View AdvQ AdvR : Type} (mode : CorruptionMode) (P : AdaptiveProtocol n In Out NetQ NetR View) (A : AdaptiveAdversary n In Out NetQ NetR View AdvQ AdvR) (Z : AdaptiveEnvironment n In Out AdvQ AdvR) (κ : ℕ) (z : List Bool) :
              adaptiveAdvantage mode P P A A Z κ z = 0

              An adaptive execution cannot be distinguished from itself.

              theorem Cslib.Crypto.Protocols.UC.adaptiveAdvantage_comm {n : ℕ} {In Out AdvQ AdvR NetQ₁ NetR₁ View₁ NetQ₂ NetR₂ View₂ : Type} (mode : CorruptionMode) (P : AdaptiveProtocol n In Out NetQ₁ NetR₁ View₁) (Q : AdaptiveProtocol n In Out NetQ₂ NetR₂ View₂) (A : AdaptiveAdversary n In Out NetQ₁ NetR₁ View₁ AdvQ AdvR) (S : AdaptiveAdversary n In Out NetQ₂ NetR₂ View₂ AdvQ AdvR) (Z : AdaptiveEnvironment n In Out AdvQ AdvR) (κ : ℕ) (z : List Bool) :
              adaptiveAdvantage mode P Q A S Z κ z = adaptiveAdvantage mode Q P S A Z κ z

              The adaptive distinguishing advantage is symmetric.

              theorem Cslib.Crypto.Protocols.UC.adaptiveAdvantage_triangle {n : ℕ} {In Out AdvQ AdvR NetQ₁ NetR₁ View₁ NetQ₂ NetR₂ View₂ NetQ₃ NetR₃ View₃ : Type} (mode : CorruptionMode) (P₁ : AdaptiveProtocol n In Out NetQ₁ NetR₁ View₁) (P₂ : AdaptiveProtocol n In Out NetQ₂ NetR₂ View₂) (P₃ : AdaptiveProtocol n In Out NetQ₃ NetR₃ View₃) (A₁ : AdaptiveAdversary n In Out NetQ₁ NetR₁ View₁ AdvQ AdvR) (A₂ : AdaptiveAdversary n In Out NetQ₂ NetR₂ View₂ AdvQ AdvR) (A₃ : AdaptiveAdversary n In Out NetQ₃ NetR₃ View₃ AdvQ AdvR) (Z : AdaptiveEnvironment n In Out AdvQ AdvR) (κ : ℕ) (z : List Bool) :
              adaptiveAdvantage mode P₁ P₃ A₁ A₃ Z κ z ≤ adaptiveAdvantage mode P₁ P₂ A₁ A₂ Z κ z + adaptiveAdvantage mode P₂ P₃ A₂ A₃ Z κ z

              The triangle inequality for adaptive advantage through an intermediate protocol and adversary.

              Budgets and adaptive emulation #

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

              Every activation of P.machine κ makes at most p.eval κ calls.

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

              Every activation of A.machine κ makes at most p.eval κ calls (A.initial is unconstrained).

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

              At security parameter κ, Z makes at most p.eval κ calls in total, regardless of the auxiliary input z.

              theorem Cslib.Crypto.Protocols.UC.AdaptiveProtocol.PolyBounded.mono {n : ℕ} {In Out NetQ NetR View : Type} {P : AdaptiveProtocol n In Out NetQ NetR View} {p q : Polynomial ℕ} (h : P.PolyBounded p) (hpq : ∀ (κ : ℕ), Polynomial.eval κ p ≤ Polynomial.eval κ q) :
              theorem Cslib.Crypto.Protocols.UC.AdaptiveAdversary.PolyBounded.mono {n : ℕ} {In Out NetQ NetR View AdvQ AdvR : Type} {A : AdaptiveAdversary n In Out NetQ NetR View AdvQ AdvR} {p q : Polynomial ℕ} (h : A.PolyBounded p) (hpq : ∀ (κ : ℕ), Polynomial.eval κ p ≤ Polynomial.eval κ q) :
              theorem Cslib.Crypto.Protocols.UC.AdaptiveEnvironment.PolyBounded.mono {n : ℕ} {In Out AdvQ AdvR : Type} {Z : AdaptiveEnvironment n In Out AdvQ AdvR} {p q : Polynomial ℕ} (h : Z.PolyBounded p) (hpq : ∀ (κ : ℕ), Polynomial.eval κ p ≤ Polynomial.eval κ q) :
              theorem Cslib.Crypto.Protocols.UC.isQueryBounded_liftPartyQuery {n : ℕ} {In Out AdvQ AdvR α : Type} {program : ProbOracleComp (execSpec n In Out AdvQ AdvR) α} {m : ℕ} (h : OracleComp.IsQueryBounded program m) :

              Lifting static queries into adaptiveExecSpec preserves query budgets.

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

              Embedding a static environment into AdaptiveEnvironment preserves its call budget.

              def Cslib.Crypto.Protocols.UC.AdaptiveEmulatesWithin {n : ℕ} {In Out NetQ₁ NetR₁ View₁ NetQ₂ NetR₂ View₂ : Type} (mode : CorruptionMode) (P : AdaptiveProtocol n In Out NetQ₁ NetR₁ View₁) (Q : AdaptiveProtocol n In Out NetQ₂ NetR₂ View₂) (g : Polynomial ℕ) (ε : Polynomial ℕ → Polynomial ℕ → ℕ → NNReal) :

              Concrete adaptive UC emulation under mode in the snapshot corruption model (statistical, call-bounded notion inspired by [Can20a], Section 7.1.1, p. 28:71, not a theorem of the paper; §7.1.1's write-once storage restriction, coin exposure, and per-party activation granularity remain open). Every adversary A with per-activation call budget pA has a simulator S with per-activation call budget pS bounded by g at κ + pA.eval κ, such that every environment Z with call budget pZ distinguishes (P, A) from (Q, S) with advantage at most ε pA pZ κ.

              def Cslib.Crypto.Protocols.UC.AdaptiveEmulates {n : ℕ} {In Out NetQ₁ NetR₁ View₁ NetQ₂ NetR₂ View₂ : Type} (mode : CorruptionMode) (P : AdaptiveProtocol n In Out NetQ₁ NetR₁ View₁) (Q : AdaptiveProtocol n In Out NetQ₂ NetR₂ View₂) :

              Asymptotic adaptive UC emulation under mode with negligible error in the snapshot corruption model (statistical, call-bounded notion inspired by [Can20a], Section 7.1.1, p. 28:71, not a theorem of the paper; §7.1.1's write-once storage, coin exposure, and activation granularity remain open).

              theorem Cslib.Crypto.Protocols.UC.AdaptiveEmulatesWithin.mono {n : ℕ} {In Out NetQ₁ NetR₁ View₁ NetQ₂ NetR₂ View₂ : Type} {mode : CorruptionMode} {P : AdaptiveProtocol n In Out NetQ₁ NetR₁ View₁} {Q : AdaptiveProtocol n In Out NetQ₂ NetR₂ View₂} {g : Polynomial ℕ} {ε ε' : Polynomial ℕ → Polynomial ℕ → ℕ → NNReal} (h : AdaptiveEmulatesWithin mode P Q g ε) (hε : ∀ (pA pZ : Polynomial ℕ) (κ : ℕ), ε pA pZ κ ≤ ε' pA pZ κ) :
              AdaptiveEmulatesWithin mode P Q g ε'

              A larger error bound is still an error bound.

              theorem Cslib.Crypto.Protocols.UC.AdaptiveEmulatesWithin.refl {n : ℕ} {In Out NetQ NetR View : Type} (mode : CorruptionMode) (P : AdaptiveProtocol n In Out NetQ NetR View) :
              AdaptiveEmulatesWithin mode P P Polynomial.X fun (x x_1 : Polynomial ℕ) (x_2 : ℕ) => 0

              Every adaptive protocol emulates itself with zero error.

              theorem Cslib.Crypto.Protocols.UC.AdaptiveEmulatesWithin.trans {n : ℕ} {In Out NetQ₁ NetR₁ View₁ NetQ₂ NetR₂ View₂ NetQ₃ NetR₃ View₃ : Type} {mode : CorruptionMode} {P₁ : AdaptiveProtocol n In Out NetQ₁ NetR₁ View₁} {P₂ : AdaptiveProtocol n In Out NetQ₂ NetR₂ View₂} {P₃ : AdaptiveProtocol n In Out NetQ₃ NetR₃ View₃} {g₁₂ g₂₃ : Polynomial ℕ} {ε₁₂ ε₂₃ : Polynomial ℕ → Polynomial ℕ → ℕ → NNReal} (h₁₂ : AdaptiveEmulatesWithin mode P₁ P₂ g₁₂ ε₁₂) (h₂₃ : AdaptiveEmulatesWithin mode P₂ P₃ g₂₃ ε₂₃) (hmono : ∀ (p p' pZ : Polynomial ℕ) (κ : ℕ), (∀ (κ' : ℕ), Polynomial.eval κ' p ≤ Polynomial.eval κ' p') → ε₂₃ p pZ κ ≤ ε₂₃ p' pZ κ) :
              AdaptiveEmulatesWithin mode P₁ P₃ (g₂₃.comp (Polynomial.X + g₁₂)) fun (pA pZ : Polynomial ℕ) (κ : ℕ) => ε₁₂ pA pZ κ + ε₂₃ (g₁₂.comp (Polynomial.X + pA)) pZ κ

              Transitivity of concrete adaptive UC emulation.

              theorem Cslib.Crypto.Protocols.UC.AdaptiveEmulatesWithin.emulates {n : ℕ} {In Out NetQ₁ NetR₁ View₁ NetQ₂ NetR₂ View₂ : Type} {mode : CorruptionMode} {P : AdaptiveProtocol n In Out NetQ₁ NetR₁ View₁} {Q : AdaptiveProtocol n In Out NetQ₂ NetR₂ View₂} {g : Polynomial ℕ} {ε : Polynomial ℕ → Polynomial ℕ → ℕ → NNReal} (h : AdaptiveEmulatesWithin mode P Q g ε) (hε : ∀ (pA pZ : Polynomial ℕ), Negligible (ε pA pZ)) :

              Concrete adaptive emulation whose errors are negligible for all budgets is asymptotic adaptive emulation.

              theorem Cslib.Crypto.Protocols.UC.AdaptiveEmulates.refl {n : ℕ} {In Out NetQ NetR View : Type} (mode : CorruptionMode) (P : AdaptiveProtocol n In Out NetQ NetR View) :

              Every adaptive protocol emulates itself.

              theorem Cslib.Crypto.Protocols.UC.AdaptiveEmulates.trans {n : ℕ} {In Out NetQ₁ NetR₁ View₁ NetQ₂ NetR₂ View₂ NetQ₃ NetR₃ View₃ : Type} {mode : CorruptionMode} {P₁ : AdaptiveProtocol n In Out NetQ₁ NetR₁ View₁} {P₂ : AdaptiveProtocol n In Out NetQ₂ NetR₂ View₂} {P₃ : AdaptiveProtocol n In Out NetQ₃ NetR₃ View₃} (h₁₂ : AdaptiveEmulates mode P₁ P₂) (h₂₃ : AdaptiveEmulates mode P₂ P₃) :
              AdaptiveEmulates mode P₁ P₃

              Asymptotic adaptive UC emulation is transitive.

              Static corruption as a special case #

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

              Convert an adaptive protocol to a static Protocol by applying P.onCorrupt for C during initialization.

              theorem Cslib.Crypto.Protocols.UC.AdaptiveProtocol.PolyBounded.toStatic {n : ℕ} {In Out NetQ NetR View : Type} {P : AdaptiveProtocol n In Out NetQ NetR View} {p : Polynomial ℕ} (h : P.PolyBounded p) :

              Converting an adaptive protocol to a static one preserves its call budget.

              theorem Cslib.Crypto.Protocols.UC.IdealFunctionality.toStatic_toAdaptive {n : ℕ} {In Out View BackQ BackR : Type} (F : IdealFunctionality n In Out BackQ BackR) (reveal : ℕ → F.State → Fin n → View) (onCorrupt : ℕ → Fin n → F.State → F.State) (hinit : ∀ (κ : ℕ) (C : Finset (Fin n)), (F.toAdaptive reveal onCorrupt).applyInitialCorruptions κ C <$> F.init κ ∅ = F.init κ C) :
              (F.toAdaptive reveal onCorrupt).toStatic = F.toProtocol

              When F.init κ C factors as applyInitialCorruptions κ C <$> F.init κ ∅, converting F.toAdaptive reveal onCorrupt back to a static Protocol recovers F.toProtocol identically.

              theorem Cslib.Crypto.Protocols.UC.IdealFunctionality.toStatic_toAdaptive_of_initIndep {n : ℕ} {In Out View BackQ BackR : Type} (F : IdealFunctionality n In Out BackQ BackR) (reveal : ℕ → F.State → Fin n → View) (hinit : ∀ (κ : ℕ) (C : Finset (Fin n)), F.init κ C = F.init κ ∅) :

              Specialization of IdealFunctionality.toStatic_toAdaptive for IdealFunctionality instances whose initial state ignores C and with default trivial onCorrupt.

              def Cslib.Crypto.Protocols.UC.AdaptiveNetR.toRoutedNetR {Out NetR View : Type} :
              AdaptiveNetR Out NetR View → RoutedNetR Out NetR

              Project an AdaptiveNetR reply back to RoutedNetR (ignoring .corrupt, which static adversaries never send).

              def Cslib.Crypto.Protocols.UC.liftStaticNetProgram {n : ℕ} {In Out NetQ NetR View α : Type} (program : ProbOracleComp (netSpec (RoutedNetQ n In NetQ) (RoutedNetR Out NetR)) α) :
              ProbOracleComp (netSpec (AdaptiveNetQ n In NetQ) (AdaptiveNetR Out NetR View)) α

              Translate a static adversary's network program into AdaptiveNetQ/AdaptiveNetR, sending only .party and .net queries and never .corrupt.

              def Cslib.Crypto.Protocols.UC.AdaptiveAdversary.ofStatic {n : ℕ} {In Out NetQ NetR View AdvQ AdvR : Type} (A : ExecAdversary n In Out NetQ NetR AdvQ AdvR) (C : ℕ → Finset (Fin n)) :
              AdaptiveAdversary n In Out NetQ NetR View AdvQ AdvR

              Lift a static ExecAdversary to an AdaptiveAdversary with initial corruption set C that never sends .corrupt.

              theorem Cslib.Crypto.Protocols.UC.Adversary.PolyBounded.ofStatic {n : ℕ} {In Out NetQ NetR View AdvQ AdvR : Type} {A : ExecAdversary n In Out NetQ NetR AdvQ AdvR} {p : Polynomial ℕ} (h : PolyBounded A p) (C : ℕ → Finset (Fin n)) :

              Lifting a static adversary preserves its call budget.

              def Cslib.Crypto.Protocols.UC.NoNewCorruptProgram {n : ℕ} {In Out NetQ NetR View : Type} (C₀ : Finset (Fin n)) {α : Type} (program : ProbOracleComp (netSpec (AdaptiveNetQ n In NetQ) (AdaptiveNetR Out NetR View)) α) :

              Every external query of program of the form .corrupt i has i ∈ C₀.

              def Cslib.Crypto.Protocols.UC.AdaptiveAdversary.NoNewCorrupt {n : ℕ} {In Out NetQ NetR View AdvQ AdvR : Type} (A : AdaptiveAdversary n In Out NetQ NetR View AdvQ AdvR) :

              An adaptive adversary sends .corrupt i only for parties already in A.initial κ.

              theorem Cslib.Crypto.Protocols.UC.AdaptiveAdversary.noNewCorrupt_ofStatic {n : ℕ} {In Out NetQ NetR View AdvQ AdvR : Type} (A : ExecAdversary n In Out NetQ NetR AdvQ AdvR) (C : ℕ → Finset (Fin n)) :

              A static adversary lifted via AdaptiveAdversary.ofStatic never queries .corrupt.

              theorem Cslib.Crypto.Protocols.UC.sample_adaptiveExecMachine_init {n : ℕ} {In Out NetQ NetR View AdvQ AdvR : Type} (mode : CorruptionMode) (P : AdaptiveProtocol n In Out NetQ NetR View) (A : AdaptiveAdversary n In Out NetQ NetR View AdvQ AdvR) (κ : ℕ) {α : Type} (f : (A.machine κ).State × AdaptiveRouterState (P.machine κ).State View n → ProbOracleComp OracleSpec.empty α) :
              ProbOracleComp.sample (adaptiveExecMachine mode P A κ).init >>= f = do let s₀ ← ProbOracleComp.sample (P.machine κ).init let sA ← ProbOracleComp.sample (A.machine κ).init have s₁ : (P.machine κ).State := P.applyInitialCorruptions κ (A.initial κ) s₀ f (sA, { inner := s₁, corrupted := A.initial κ, trace := fun (i : Fin n) => [P.view κ i s₁] })

              Sample the initial state of adaptiveExecMachine as independent samples of protocol and adversary initial states.

              theorem Cslib.Crypto.Protocols.UC.adaptiveExecMachine_handle_inl_party {n : ℕ} {In Out NetQ NetR View AdvQ AdvR : Type} (mode : CorruptionMode) (P : AdaptiveProtocol n In Out NetQ NetR View) (A : AdaptiveAdversary n In Out NetQ NetR View AdvQ AdvR) (κ : ℕ) (i : Fin n) (x : In) (sA : (A.machine κ).State) (rs : AdaptiveRouterState (P.machine κ).State View n) :
              ((adaptiveExecMachine mode P A κ).handle (Sum.inl (AdaptivePartyQ.party i x))).run (sA, rs) = if i ∈ rs.corrupted then pure (none, sA, rs) else do let p ← ((P.machine κ).handle (Sum.inl (i, x))).run rs.inner pure (p.1, sA, P.recordSnapshot κ p.2 rs.corrupted rs.trace)

              Left-port party query step of adaptiveExecMachine.

              theorem Cslib.Crypto.Protocols.UC.adaptiveExecMachine_handle_inl_status {n : ℕ} {In Out NetQ NetR View AdvQ AdvR : Type} (mode : CorruptionMode) (P : AdaptiveProtocol n In Out NetQ NetR View) (A : AdaptiveAdversary n In Out NetQ NetR View AdvQ AdvR) (κ : ℕ) (sA : (A.machine κ).State) (rs : AdaptiveRouterState (P.machine κ).State View n) :

              Left-port .status query step of adaptiveExecMachine.

              theorem Cslib.Crypto.Protocols.UC.runFrom_adaptiveExecMachine_intertwine {n : ℕ} {In Out NetQ NetR View AdvQ AdvR α : Type} (mode₁ mode₂ : CorruptionMode) (P : AdaptiveProtocol n In Out NetQ NetR View) (A₁ A₂ : AdaptiveAdversary n In Out NetQ NetR View AdvQ AdvR) (κ : ℕ) (RA : (A₁.machine κ).State → (A₂.machine κ).State → Prop) (hnet : ∀ (a : AdvQ) (sA₁ : (A₁.machine κ).State) (sA₂ : (A₂.machine κ).State) (rs : AdaptiveRouterState (P.machine κ).State View n) (k₁ : (AdvR × (A₁.machine κ).State) × AdaptiveRouterState (P.machine κ).State View n → ProbOracleComp OracleSpec.empty α) (k₂ : (AdvR × (A₂.machine κ).State) × AdaptiveRouterState (P.machine κ).State View n → ProbOracleComp OracleSpec.empty α), RA sA₁ sA₂ → rs.corrupted = A₁.initial κ → (∀ (r : AdvR) (sA₁' : (A₁.machine κ).State) (sA₂' : (A₂.machine κ).State) (rs' : AdaptiveRouterState (P.machine κ).State View n), RA sA₁' sA₂' → rs'.corrupted = A₁.initial κ → k₁ ((r, sA₁'), rs') = k₂ ((r, sA₂'), rs')) → (adaptiveRouter mode₁ P κ (A₁.initial κ)).runFrom (liftAdaptiveNet (((A₁.machine κ).handle a).run sA₁)) rs >>= k₁ = (adaptiveRouter mode₂ P κ (A₂.initial κ)).runFrom (liftAdaptiveNet (((A₂.machine κ).handle a).run sA₂)) rs >>= k₂) (program : ProbOracleComp (adaptiveExecSpec n In Out AdvQ AdvR) α) (sA₁ : (A₁.machine κ).State) (sA₂ : (A₂.machine κ).State) (hsA : RA sA₁ sA₂) (rs : AdaptiveRouterState (P.machine κ).State View n) (hrs : rs.corrupted = A₁.initial κ) :
              Prod.fst <$> (adaptiveExecMachine mode₁ P A₁ κ).runFrom program (sA₁, rs) = Prod.fst <$> (adaptiveExecMachine mode₂ P A₂ κ).runFrom program (sA₂, rs)

              Network-congruence intertwining for adaptiveExecMachine: two (mode, A) pairs whose router-lifted adversary activations intertwine under RA (preserving rs.corrupted = A₁.initial κ) produce equal adaptiveExecMachine outputs.

              theorem Cslib.Crypto.Protocols.UC.adaptiveExec_static_eq_adaptive_of_noCorrupt {n : ℕ} {In Out NetQ NetR View AdvQ AdvR : Type} (P : AdaptiveProtocol n In Out NetQ NetR View) (A : AdaptiveAdversary n In Out NetQ NetR View AdvQ AdvR) (hno : A.NoNewCorrupt) (Z : AdaptiveEnvironment n In Out AdvQ AdvR) (κ : ℕ) (z : List Bool) :

              If A satisfies NoNewCorrupt (it sends .corrupt i only for parties already in A.initial κ), then .static and .adaptive modes produce the exact same execution.

              theorem Cslib.Crypto.Protocols.UC.adaptiveExec_static_ofStatic {n : ℕ} {In Out NetQ NetR View AdvQ AdvR : Type} (P : AdaptiveProtocol n In Out NetQ NetR View) (A : ExecAdversary n In Out NetQ NetR AdvQ AdvR) (C : ℕ → Finset (Fin n)) (Z : Environment n In Out AdvQ AdvR) (κ : ℕ) (z : List Bool) :

              Running a static adversary lifted via AdaptiveAdversary.ofStatic against P in .static mode with embedded environment Z.toAdaptive equals the static UC execution exec P.toStatic.

              theorem Cslib.Crypto.Protocols.UC.adaptiveExec_adaptive_ofStatic {n : ℕ} {In Out NetQ NetR View AdvQ AdvR : Type} (P : AdaptiveProtocol n In Out NetQ NetR View) (A : ExecAdversary n In Out NetQ NetR AdvQ AdvR) (C : ℕ → Finset (Fin n)) (Z : Environment n In Out AdvQ AdvR) (κ : ℕ) (z : List Bool) :

              Running a static adversary lifted via AdaptiveAdversary.ofStatic against P in .adaptive mode with embedded environment Z.toAdaptive also equals the static UC execution exec P.toStatic, because ofStatic never sends .corrupt.