Documentation

CslibFrontier.Crypto.Protocols.SSP.ParFinLazy

Lazy initialization equivalence for parallel SSP packages #

This module defines Cslib.Crypto.Protocols.SSP.parFinLazy, the lazy first-touch parallel package combinator over an arbitrary [DecidableEq SID] (specializing definitionally to SSP.sessionSpec m E at SID := Fin m), and proves:

Because CslibFrontier.Crypto.Protocols.SSP.Basic supplies UC.Machine via CslibFrontier.Crypto.Protocols.UC.Linking, SSP callers can import this bridge without importing the UC ideal-functionality, execution, or joint-state modules.

Proof strategy #

RandomOracle.pi_bind_eq_map_fst_of_complete_eq equates eager upfront sampling with lazy caching over a finite-domain family of PMFs. Because each (M j).init : ProbComp (M j).State has arbitrary state type (M j).State rather than a Finite instance, we restrict each initializer to its finite support subtype EvalSupport (M j).init and convert OracleComp.pi via Probability.PMF.pi_fin_succ_dep, separating the once-sampled initial-state cache from the mutable per-session execution state. For arbitrary [DecidableEq SID], allocMachine assigns each newly queried sid : SID sequentially to slots 0, ..., b - 1 of Fin (b + 1), reducing homogeneous parFinLazy to Fin (b + 1) before invoking run_parFinLazy_eq_parFin.

Main definitions #

Main results #

@[reducible, inline]
abbrev Cslib.Crypto.Protocols.SSP.dynSessionSpec (SID : Type) {ιE : Type} (E : ιE → Type) :
SID × ιE → Type

Interface of dynamically indexed sessions over SID: a query pairs a session identifier sid : SID with an E-query q, answered as E q. Specializes definitionally to SSP.sessionSpec m E when SID := Fin m.

Lazy first-touch parallel composition of a family of closed machines M : SID → Machine OracleSpec.empty E over an arbitrary [DecidableEq SID]: each session sid starts uninitialized (none) and samples (M sid).init on its first query. At SID := Fin m this is the lazy variant of SSP.parFin.

theorem Cslib.Crypto.Protocols.SSP.isBounded_parFinLazy {SID : Type} [DecidableEq SID] {ιE : Type} {E : ιE → Type} {M : SID → UC.Machine OracleSpec.empty E} {t : ℕ} (hM : ∀ (sid : SID), (M sid).IsBounded t) :

Every activation of parFinLazy M makes at most 2 * t calls when each M sid is t-bounded (at most t for first-touch initialization plus t for the activation itself).

The Finset SID of session identifiers queried along a transcript over probOracleSpec (dynSessionSpec SID E).

@[simp]
theorem Cslib.Crypto.Protocols.SSP.mem_touchedSessions {SID : Type} [DecidableEq SID] {ιE : Type} {E : ιE → Type} (t : OracleComp.Transcript (probOracleSpec (dynSessionSpec SID E))) (sid : SID) :
sid ∈ touchedSessions t ↔ ∃ (q : ιE) (r : E q), ⟨Sum.inr (sid, q), r⟩ ∈ t

A session identifier sid belongs to touchedSessions t if and only if some external query to sid appears in the transcript t.

theorem Cslib.Crypto.Protocols.SSP.touchedSessions_transcript_card_le {SID : Type} [DecidableEq SID] {ιE : Type} {E : ιE → Type} {State γ : Type} {prog : ProbOracleComp (dynSessionSpec SID E) γ} {b : ℕ} (hprog : OracleComp.IsQueryBounded prog b) (oracle : (q : ℕ ⊕ SID × ιE) → StateT State PMF (probOracleSpec (dynSessionSpec SID E) q)) {s s' : State} {res : γ} {t : OracleComp.Transcript (probOracleSpec (dynSessionSpec SID E))} (hmem : (res, s', t) ∈ ((OracleComp.interpret (OracleComp.withTranscript oracle) prog).run (s, [])).support) :

Along any supported run of a b-query-bounded program against a stateful oracle over probOracleSpec (dynSessionSpec SID E), the Finset SID of touched session IDs has cardinality at most b.

theorem Cslib.Crypto.Protocols.SSP.mem_support_parFinLazy_touched_card_le {SID : Type} [DecidableEq SID] {ιE : Type} {E : ιE → Type} (M : SID → UC.Machine OracleSpec.empty E) {γ : Type} {prog : ProbOracleComp (dynSessionSpec SID E) γ} {b : ℕ} (hprog : OracleComp.IsCostBounded (Sum.elim (fun (x : ℕ) => 0) fun (x : SID × ιE) => 1) prog b) (S₀ : Finset SID) (s₀ : (parFinLazy M).State) (hS₀ : ∀ sid ∉ S₀, s₀ sid = none) {res : γ} {s' : (parFinLazy M).State} (hmem : (res, s') ∈ (UC.Machine.closeEval ((parFinLazy M).runFrom prog s₀)).support) :
∃ (S : Finset SID), S₀ ⊆ S ∧ S.card ≤ S₀.card + b ∧ ∀ sid ∉ S, s' sid = none

Along any supported run of parFinLazy M on a program making at most b external calls (counting private coin samples at cost 0), at most b new sessions become initialized (some).

theorem Cslib.Crypto.Protocols.SSP.mem_support_parFinLazy_init_touched_card_le {SID : Type} [DecidableEq SID] {ιE : Type} {E : ιE → Type} (M : SID → UC.Machine OracleSpec.empty E) {γ : Type} {prog : ProbOracleComp (dynSessionSpec SID E) γ} {b : ℕ} (hprog : OracleComp.IsQueryBounded prog b) {res : γ} {s' : (parFinLazy M).State} (hmem : (res, s') ∈ (UC.Machine.closeEval ((parFinLazy M).runFrom prog fun (x : SID) => none)).support) :
∃ (S : Finset SID), S.card ≤ b ∧ ∀ (sid : SID), (s' sid).isSome = true → sid ∈ S

Starting from the initial all-none state of parFinLazy M, any supported run of a b-query-bounded program leaves at most b distinct sessions initialized.

theorem Cslib.Crypto.Protocols.SSP.run_parFinLazy_eq_parFin {m : ℕ} {ιE : Type} {E : ιE → Type} {α : Type} (M : Fin m → UC.Machine OracleSpec.empty E) (program : ProbOracleComp (sessionSpec m E) α) :
((parFinLazy M).run program).eval = ((parFin M).run program).eval

Lazy first-touch initialization agrees in distribution with eager SSP.parFin initialization for any adaptive client program, via RandomOracle.pi_bind_eq_map_fst_of_complete_eq.

Finite first-touch allocator and lazy-vs-eager equivalence #

def Cslib.Crypto.Protocols.SSP.allocMachine (SID : Type) [DecidableEq SID] (m : ℕ) {ιE : Type} (E : ιE → Type) :

First-touch allocator translating dynamic queries over dynSessionSpec SID E into fixed-arity queries over SSP.sessionSpec (m + 1) E. Up to m distinct session identifiers receive sequential indices 0, ..., m - 1, and Fin.last m serves as an unreachable fallback slot.

theorem Cslib.Crypto.Protocols.SSP.eval_run_parFinLazy_eq_parFin_alloc {SID : Type} [DecidableEq SID] {ιE : Type} {E : ιE → Type} (M₀ : UC.Machine OracleSpec.empty E) (b : ℕ) {γ : Type} {prog : ProbOracleComp (dynSessionSpec SID E) γ} (hprog : OracleComp.IsQueryBounded prog b) :
((parFinLazy fun (x : SID) => M₀).run prog).eval = ((parFin fun (x : Fin (b + 1)) => M₀).run ((allocMachine SID b E).link prog)).eval

Lazy-vs-eager finite reindexing equivalence: running parFinLazy (fun _ => M₀) on any b-query-bounded dynamic-SID program gives the exact same output distribution as running eager SSP.parFin (fun (_ : Fin (b + 1)) => M₀) on the first-touch reindexed program (allocMachine SID b E).link prog.