Documentation

CslibFrontier.Crypto.Protocols.MPC.PolyTime.RunEncoded

Word-Level Execution of $\text{OT}_1^4$-Hybrid Protocols #

This module runs an ot14Spec-hybrid protocol as a word-level oracle program in Cslib.Probability.WordOracleComp Unit (List Bool): each typed ot14Spec query becomes a 6-bit word query to ot14WordHandler, whose 1-bit reply prefix is decoded back to the typed answer. The bridge lemma Protocol.eval_runEncoded_eq_evalWith_map identifies the word-level run with the typed execution Protocol.evalWith ot14World. It also defines the word-encoded randomized functionality family that the completeness theorem in Cslib.Crypto.Protocols.MPC.PolyTime compiles.

Main definitions #

Main results #

References #

Part 1: Word-Level Functionality, ot14Spec Word Handler, and Protocol.runEncoded #

Encode x : Fin m → BitString n and shared coin tape r : BitString coins as the m * n + coins-bit list List.ofFn (Fin.append (BitString.blocksEquiv.symm x) r).

noncomputable def Cslib.Crypto.Protocols.MPC.wordRandomizedFunctionality {α : Type} (m : ℕ) (coins n k : α → ℕ) (F : α × List Bool → List Bool) (a : α) :
Functionality m (fun (x : Fin m) => BitString (n a)) fun (x : Fin m) => BitString (k a)

Randomized m-party functionality family induced by a word-level function F : α × List Bool → List Bool with coins a random bits, n a-bit party inputs, and k a-bit party outputs.

Serialize a typed ot14Spec query q : (s : Fin 2) → ot14Spec.Query () s as a 6-bit word: the sender's four table bits q 0 0, q 0 1, q 0 2, q 0 3 followed by the receiver's two selector bits (fin4ToBoolPair (q 1)).1, (fin4ToBoolPair (q 1)).2.

Stateful word-oracle handler realizing ot14World on 6-bit requests produced by encodeOT14Query: returns the selected sender bit [req.getD idx false] while leaving the Unit state unchanged.

Decode a 1-bit word-oracle reply rep : List Bool into an ot14Spec answer tuple: returns () to slot 0 and rep.headD false to slot 1.

def Cslib.Crypto.Protocols.MPC.Steps.runEncoded {m : ℕ} {State Out : Fin m → Type} {sc : Schedule m ot14Spec} (steps : Steps State Out sc) (st : (i : Fin m) → State i) :

Execute steps : Steps State Out sc over ot14Spec in WordOracleComp Unit, translating each .oracle round into a 1-bit ProbOracleComp.query call with payload encodeOT14Query.

def Cslib.Crypto.Protocols.MPC.encodeViewsAndOutputs {m : ℕ} {spec : MultiOracleSpec} {sc : Schedule m spec} {In Coins Out : Fin m → Type} (encView : (i : Fin m) → PartyView In Coins sc i → List Bool) (encOut : (i : Fin m) → Out i → List Bool) (vo : ((i : Fin m) → PartyView In Coins sc i) × ((i : Fin m) → Out i)) :

Encode a complete (views, outputs) execution outcome into a single bit string List Bool by pairing the framed list of all m encoded party views with the framed list of all m encoded party outputs.

def Cslib.Crypto.Protocols.MPC.Protocol.runEncoded {m : ℕ} {sc : Schedule m ot14Spec} {In Coins Out : Fin m → Type} (encView : (i : Fin m) → PartyView In Coins sc i → List Bool) (encOut : (i : Fin m) → Out i → List Bool) (proto : Protocol m ot14Spec sc In Coins Out) (x : (i : Fin m) → In i) :

Generic word-level execution of proto.run x in WordOracleComp Unit (List Bool), translating each ot14Spec query to a word-oracle call and encoding the resulting (views, outputs) pair via (encView, encOut).

theorem Cslib.Crypto.Protocols.MPC.Steps.runWith_runEncoded_eq_evalWith {m : ℕ} {State Out : Fin m → Type} {sc : Schedule m ot14Spec} (steps : Steps State Out sc) (st : (i : Fin m) → State i) :
ProbOracleComp.runWith ot14WordHandler (steps.runEncoded st) () = PMF.map (fun (x : (i : Fin m) → sc.Received i) => (x, ())) (steps.evalWith ot14World st)

Step-level bridge lemma: interpreting steps.runEncoded st against ot14WordHandler produces the exact distribution of steps.evalWith ot14World st paired with ().

theorem Cslib.Crypto.Protocols.MPC.Protocol.eval_runEncoded_eq_evalWith_map {m : ℕ} {sc : Schedule m ot14Spec} {In Coins Out : Fin m → Type} (encView : (i : Fin m) → PartyView In Coins sc i → List Bool) (encOut : (i : Fin m) → Out i → List Bool) (proto : Protocol m ot14Spec sc In Coins Out) (x : (i : Fin m) → In i) :

Bridge lemma: interpreting proto.runEncoded against the word-encoded ot14World handler produces the exact law of proto.evalWith ot14World x mapped through encodeViewsAndOutputs.

@[simp]
theorem Cslib.Crypto.Protocols.MPC.Steps.runEncoded_mapState {m : ℕ} {State State' Out : Fin m → Type} {sc : Schedule m ot14Spec} (f : (i : Fin m) → State i → State' i) (steps : Steps State' Out sc) (st : (i : Fin m) → State i) :
(mapState f steps).runEncoded st = steps.runEncoded fun (i : Fin m) => f i (st i)

Steps.runEncoded commutes with relabelling the party states.

@[simp]
theorem Cslib.Crypto.Protocols.MPC.Steps.runEncoded_append {m : ℕ} {State Mid Out : Fin m → Type} {sc₁ sc₂ : Schedule m ot14Spec} (steps₁ : Steps State Mid sc₁) (steps₂ : Steps Mid Out sc₂) (st : (i : Fin m) → State i) :
(steps₁.append steps₂).runEncoded st = do let r₁ ← steps₁.runEncoded st let r₂ ← steps₂.runEncoded fun (i : Fin m) => steps₁.outputAt i (st i) (r₁ i) pure fun (i : Fin m) => (r₁ i).append (r₂ i)

Steps.runEncoded of concatenated steps runs the two parts in sequence.

@[simp]
theorem Cslib.Crypto.Protocols.MPC.Steps.runEncoded_embed {k m : ℕ} (parties : Fin k ↪ Fin m) (Outer : Fin m → Type) {State_k Out_k : Fin k → Type} {sc : Schedule k ot14Spec} (steps : Steps State_k Out_k sc) (st : (i : Fin m) → Outer i × ((s : Fin k) → parties s = i → State_k s)) :
(Composition.Steps.embed parties Outer steps).runEncoded st = Composition.pushScheduleReceived parties sc <$> steps.runEncoded fun (s : Fin k) => (st (parties s)).2 s ⋯

Steps.runEncoded of an embedded sub-protocol runs the sub-protocol and pushes its received messages to the embedded parties.