Documentation

CslibFrontier.Crypto.Primitives.Garbling.Efficient

Efficient garbling schemes #

The algorithms of a garbling scheme in the sense of Bellare, Hoang and Rogaway [BHR12b] are meant to be efficient. Scheme.IsEfficient G encFn states this for a scheme G whose function descriptions are encoded by encFn: the length readers f.n and f.m, the number of coins, the deterministic core gb of the garbling algorithm, encoding, evaluation, decoding and the semantics ev are computed in polynomial time, on the security parameter in unary and the encoded arguments.

For circuit garbling, encConventionalCircuit encodes a conventional circuit by n and m in unary followed by its gates, each the binary numbers of its two argument wires and its truth table as four bits; encValidCircuit restricts it to valid circuits. encValidTopo encodes the topology (n, m, q, A, B) revealed by phiTopo in the same layout without the truth tables, and encPrvView and encObvView encode the views (F, X, d) of a privacy adversary and (F, X) of an obliviousness or authenticity adversary.

The plaintext wire values and the semantics evalCirc of a valid circuit are computed in polynomial time from its word (wires_polyTime, evalCirc_polyTime), by a fold over the gates whose state grows by one bit per gate. This is the ev field of Scheme.IsEfficient for every scheme whose semantics is evalCirc.

Main definitions #

Main results #

References #

theorem Cslib.Crypto.Garbling.Scheme.encGarbled_decInfo_budget {γ✝ : Type} {encIn✝ : γ✝ ↪ List Bool} {S✝ : γ✝ → ℕ} {g✝ : γ✝ → Garbled} :

The encoding of a garbled triple (F, e, d): F and e framed, then d (encGarbled_apply).

theorem Cslib.Crypto.Garbling.Scheme.encGarbled_fn_budget {γ✝ : Type} {encIn✝ : γ✝ ↪ List Bool} {S✝ : γ✝ → ℕ} {g✝ : γ✝ → Garbled} :
@[reducible, inline]

The tuple of the fields of encGarbled.

theorem Cslib.Crypto.Garbling.Scheme.encGarbled_mk_budget {γ : Type} {encIn : γ ↪ List Bool} {budget : γ → ℕ} {x0 x1 x2 : γ → List Bool} (h0 : Turing.MultiTapeTM.ComputableInSpace x0 encIn Turing.MultiTapeTM.encBits budget) (h1 : Turing.MultiTapeTM.ComputableInSpace x1 encIn Turing.MultiTapeTM.encBits budget) (h2 : Turing.MultiTapeTM.ComputableInSpace x2 encIn Turing.MultiTapeTM.encBits budget) :
Turing.MultiTapeTM.ComputableInSpace (fun (x : γ) => { fn := x0 x, encInfo := x1 x, decInfo := x2 x }) encIn encGarbled budget
theorem Cslib.Crypto.Garbling.Scheme.encGarbled_encInfo_budget {γ✝ : Type} {encIn✝ : γ✝ ↪ List Bool} {S✝ : γ✝ → ℕ} {g✝ : γ✝ → Garbled} :
theorem Cslib.Crypto.Garbling.Scheme.encGarbled_mk_inO {γ : Type} {encIn : γ ↪ List Bool} {x0 : γ → List Bool} {T0 S0 : γ → ℕ} {x1 : γ → List Bool} {T1 S1 : γ → ℕ} {x2 : γ → List Bool} {T2 S2 : γ → ℕ} (h0 : Turing.MultiTapeTM.ComputableInO x0 encIn Turing.MultiTapeTM.encBits T0 S0) (h1 : Turing.MultiTapeTM.ComputableInO x1 encIn Turing.MultiTapeTM.encBits T1 S1) (h2 : Turing.MultiTapeTM.ComputableInO x2 encIn Turing.MultiTapeTM.encBits T2 S2) :
Turing.MultiTapeTM.ComputableInO (fun (x : γ) => { fn := x0 x, encInfo := x1 x, decInfo := x2 x }) encIn encGarbled (fun (x : γ) => T0 x + (T1 x + T2 x)) fun (x : γ) => S0 x + (S1 x + S2 x)
structure Cslib.Crypto.Garbling.Scheme.IsEfficient {Fn : Type} (G : Scheme Fn) (encFn : Fn ↪ List Bool) :

A garbling scheme is efficient for the encoding encFn of its function descriptions when its algorithms run in polynomial time: the length readers f.n and f.m on the encoded function, the number of coins and the deterministic core gb of Gb on the parameter in unary and the encoded function (and coins), and En, Ev, De and ev on their encoded arguments. [BHR12b], §3.1, fixes linear-time algorithms for f.n and f.m; here they are only required to run in polynomial time.

The gates of a conventional circuit as data: for each gate its argument wires A g and B g and its truth table as the four bits G g 0 0, G g 0 1, G g 1 0, G g 1 1.

theorem Cslib.Crypto.Garbling.ConventionalCircuit.gateList_injective {f f' : ConventionalCircuit} (hn : f.n = f'.n) (hm : f.m = f'.m) (h : f.gateList = f'.gateList) :
f = f'

A conventional circuit is determined by n, m and its gates.

@[reducible, inline]

The data of a conventional circuit: n and m in unary, then its gates, each the binary numbers of its two argument wires followed by its truth table as four bits.

Conventional circuits as words: n and m in unary, then the gates in order, each the binary numbers of its argument wires A g and B g and its truth table as four bits (encCircuitData of (n, m, gateList f)).

A valid circuit's word has at least n + q bits: n in unary and at least one bit per gate.

The data of a valid circuit is read from its word in polynomial time.

Evaluating conventional circuits #

theorem Cslib.Crypto.Garbling.getD_table (G : Bool → Bool → Bool) (x y : Bool) :

The truth table of a gate read from its four bits, listed as in ConventionalCircuit.gateList.

The plaintext wire values f.wires x f.q of a valid circuit on an input, the n input bits followed by the q gate values, are computed in polynomial time.

The semantics evalCirc of a valid circuit on an input, the semantics ev of the garbling schemes over conventional circuits, is computed in polynomial time.

The gates of a topology as data: for each gate its argument wires A g and B g.

theorem Cslib.Crypto.Garbling.Topo.gateList_injective {t t' : Topo} (hn : t.n = t'.n) (hm : t.m = t'.m) (h : t.gateList = t'.gateList) :
t = t'

A topology is determined by n, m and its gates.

@[reducible, inline]

The data of a topology: n and m in unary, then each gate's argument wires in binary.

Topologies as words: n and m in unary, then the gates in order, each the binary numbers of its argument wires A g and B g (encTopoData of (n, m, gateList t)). This is the layout of encConventionalCircuit without the truth tables.

Valid topologies, the side information of phiTopo, as words by encTopo.

The data of a valid topology is read from its word in polynomial time.

The topology Φ_topo(f) of a valid circuit is computed in polynomial time from its word: drop the truth table of each gate.

theorem Cslib.Crypto.Garbling.encPrvView_mk_budget {γ : Type} {encIn : γ ↪ List Bool} {budget : γ → ℕ} {x0 x1 x2 : γ → List Bool} (h0 : Turing.MultiTapeTM.ComputableInSpace x0 encIn Turing.MultiTapeTM.encBits budget) (h1 : Turing.MultiTapeTM.ComputableInSpace x1 encIn Turing.MultiTapeTM.encBits budget) (h2 : Turing.MultiTapeTM.ComputableInSpace x2 encIn Turing.MultiTapeTM.encBits budget) :
Turing.MultiTapeTM.ComputableInSpace (fun (x : γ) => { fn := x0 x, input := x1 x, decInfo := x2 x }) encIn encPrvView budget

The encoding of a privacy view (F, X, d): F and X framed, then d.

theorem Cslib.Crypto.Garbling.encPrvView_fn_budget {γ✝ : Type} {encIn✝ : γ✝ ↪ List Bool} {S✝ : γ✝ → ℕ} {g✝ : γ✝ → PrvView} :
@[reducible, inline]

The tuple of the fields of encPrvView.

theorem Cslib.Crypto.Garbling.encPrvView_input_budget {γ✝ : Type} {encIn✝ : γ✝ ↪ List Bool} {S✝ : γ✝ → ℕ} {g✝ : γ✝ → PrvView} :
theorem Cslib.Crypto.Garbling.encPrvView_mk_inO {γ : Type} {encIn : γ ↪ List Bool} {x0 : γ → List Bool} {T0 S0 : γ → ℕ} {x1 : γ → List Bool} {T1 S1 : γ → ℕ} {x2 : γ → List Bool} {T2 S2 : γ → ℕ} (h0 : Turing.MultiTapeTM.ComputableInO x0 encIn Turing.MultiTapeTM.encBits T0 S0) (h1 : Turing.MultiTapeTM.ComputableInO x1 encIn Turing.MultiTapeTM.encBits T1 S1) (h2 : Turing.MultiTapeTM.ComputableInO x2 encIn Turing.MultiTapeTM.encBits T2 S2) :
Turing.MultiTapeTM.ComputableInO (fun (x : γ) => { fn := x0 x, input := x1 x, decInfo := x2 x }) encIn encPrvView (fun (x : γ) => T0 x + (T1 x + T2 x)) fun (x : γ) => S0 x + (S1 x + S2 x)
theorem Cslib.Crypto.Garbling.encPrvView_decInfo_budget {γ✝ : Type} {encIn✝ : γ✝ ↪ List Bool} {S✝ : γ✝ → ℕ} {g✝ : γ✝ → PrvView} :
theorem Cslib.Crypto.Garbling.encObvView_mk_budget {γ : Type} {encIn : γ ↪ List Bool} {budget : γ → ℕ} {x0 x1 : γ → List Bool} (h0 : Turing.MultiTapeTM.ComputableInSpace x0 encIn Turing.MultiTapeTM.encBits budget) (h1 : Turing.MultiTapeTM.ComputableInSpace x1 encIn Turing.MultiTapeTM.encBits budget) :
Turing.MultiTapeTM.ComputableInSpace (fun (x : γ) => { fn := x0 x, input := x1 x }) encIn encObvView budget
theorem Cslib.Crypto.Garbling.encObvView_mk_inO {γ : Type} {encIn : γ ↪ List Bool} {x0 : γ → List Bool} {T0 S0 : γ → ℕ} {x1 : γ → List Bool} {T1 S1 : γ → ℕ} (h0 : Turing.MultiTapeTM.ComputableInO x0 encIn Turing.MultiTapeTM.encBits T0 S0) (h1 : Turing.MultiTapeTM.ComputableInO x1 encIn Turing.MultiTapeTM.encBits T1 S1) :
Turing.MultiTapeTM.ComputableInO (fun (x : γ) => { fn := x0 x, input := x1 x }) encIn encObvView (fun (x : γ) => T0 x + T1 x) fun (x : γ) => S0 x + S1 x
@[reducible, inline]

The tuple of the fields of encObvView.

The encoding of an obliviousness or authenticity view (F, X): F framed, then X.

theorem Cslib.Crypto.Garbling.encObvView_input_budget {γ✝ : Type} {encIn✝ : γ✝ ↪ List Bool} {S✝ : γ✝ → ℕ} {g✝ : γ✝ → ObvView} :
theorem Cslib.Crypto.Garbling.encObvView_fn_budget {γ✝ : Type} {encIn✝ : γ✝ ↪ List Bool} {S✝ : γ✝ → ℕ} {g✝ : γ✝ → ObvView} :
@[simp]
theorem Cslib.Crypto.Garbling.encQuery_apply (Fn : Type) (encFn : Fn ↪ List Bool) (a : Query Fn) :
(encQuery Fn encFn) a = (encQueryFields Fn encFn) (a.fn, a.input)
theorem Cslib.Crypto.Garbling.encQuery_mk_deg (Fn : Type) (encFn : Fn ↪ List Bool) :
Turing.MultiTapeTM.ComputableInDegree (fun (p : Fn × List Bool) => { fn := p.1, input := p.2 }) (encQueryFields Fn encFn) (encQuery Fn encFn) 1 1
theorem Cslib.Crypto.Garbling.encQuery_input_polyTime (Fn : Type) (encFn : Fn ↪ List Bool) {γ✝ : Type} {encIn✝ : γ✝ ↪ List Bool} {g✝ : γ✝ → Query Fn} :
theorem Cslib.Crypto.Garbling.encQuery_fn_polyTime (Fn : Type) (encFn : Fn ↪ List Bool) {γ✝ : Type} {encIn✝ : γ✝ ↪ List Bool} {g✝ : γ✝ → Query Fn} :
Turing.MultiTapeTM.ComputableInPolyTime g✝ encIn✝ (encQuery Fn encFn) → Turing.MultiTapeTM.ComputableInPolyTime (fun (c : γ✝) => (g✝ c).fn) encIn✝ encFn

The encoding of a query (f, x): f by encFn, framed, then x.

theorem Cslib.Crypto.Garbling.encQuery_mk_budget (Fn : Type) (encFn : Fn ↪ List Bool) {γ : Type} {encIn : γ ↪ List Bool} {budget : γ → ℕ} {x0 : γ → Fn} {x1 : γ → List Bool} (h0 : Turing.MultiTapeTM.ComputableInSpace x0 encIn encFn budget) (h1 : Turing.MultiTapeTM.ComputableInSpace x1 encIn Turing.MultiTapeTM.encBits budget) :
Turing.MultiTapeTM.ComputableInSpace (fun (x : γ) => { fn := x0 x, input := x1 x }) encIn (encQuery Fn encFn) budget
theorem Cslib.Crypto.Garbling.encQuery_fn_budget (Fn : Type) (encFn : Fn ↪ List Bool) {γ✝ : Type} {encIn✝ : γ✝ ↪ List Bool} {S✝ : γ✝ → ℕ} {g✝ : γ✝ → Query Fn} :
Turing.MultiTapeTM.ComputableInSpace g✝ encIn✝ (encQuery Fn encFn) S✝ → Turing.MultiTapeTM.ComputableInSpace (fun (c : γ✝) => (g✝ c).fn) encIn✝ encFn S✝
theorem Cslib.Crypto.Garbling.encQuery_fn_inO (Fn : Type) (encFn : Fn ↪ List Bool) :
Turing.MultiTapeTM.ComputableInO Query.fn (encQuery Fn encFn) encFn (fun (a : Query Fn) => ((encQuery Fn encFn) a).length) fun (a : Query Fn) => ((encQuery Fn encFn) a).length
@[reducible, inline]

The tuple of the fields of encQuery.

theorem Cslib.Crypto.Garbling.encQuery_mk_inO (Fn : Type) (encFn : Fn ↪ List Bool) {γ : Type} {encIn : γ ↪ List Bool} {x0 : γ → Fn} {T0 S0 : γ → ℕ} {x1 : γ → List Bool} {T1 S1 : γ → ℕ} (h0 : Turing.MultiTapeTM.ComputableInO x0 encIn encFn T0 S0) (h1 : Turing.MultiTapeTM.ComputableInO x1 encIn Turing.MultiTapeTM.encBits T1 S1) :
Turing.MultiTapeTM.ComputableInO (fun (x : γ) => { fn := x0 x, input := x1 x }) encIn (encQuery Fn encFn) (fun (x : γ) => T0 x + T1 x) fun (x : γ) => S0 x + S1 x
theorem Cslib.Crypto.Garbling.encQuery_mk_polyTime (Fn : Type) (encFn : Fn ↪ List Bool) {γ : Type} {encIn : γ ↪ List Bool} {x0 : γ → Fn} {x1 : γ → List Bool} (h0 : Turing.MultiTapeTM.ComputableInPolyTime x0 encIn encFn) (h1 : Turing.MultiTapeTM.ComputableInPolyTime x1 encIn Turing.MultiTapeTM.encBits) :
Turing.MultiTapeTM.ComputableInPolyTime (fun (x : γ) => { fn := x0 x, input := x1 x }) encIn (encQuery Fn encFn)
theorem Cslib.Crypto.Garbling.encQuery_input_inO (Fn : Type) (encFn : Fn ↪ List Bool) :
Turing.MultiTapeTM.ComputableInO Query.input (encQuery Fn encFn) Turing.MultiTapeTM.encBits (fun (a : Query Fn) => ((encQuery Fn encFn) a).length) fun (a : Query Fn) => ((encQuery Fn encFn) a).length
theorem Cslib.Crypto.Garbling.encQuery_input_budget (Fn : Type) (encFn : Fn ↪ List Bool) {γ✝ : Type} {encIn✝ : γ✝ ↪ List Bool} {S✝ : γ✝ → ℕ} {g✝ : γ✝ → Query Fn} :
Turing.MultiTapeTM.ComputableInSpace g✝ encIn✝ (encQuery Fn encFn) S✝ → Turing.MultiTapeTM.ComputableInSpace (fun (c : γ✝) => (g✝ c).input) encIn✝ Turing.MultiTapeTM.encBits S✝
theorem Cslib.Crypto.Garbling.encQuery_fn_length_le (Fn : Type) (encFn : Fn ↪ List Bool) (a : Query Fn) :
(encFn a.fn).length ≤ ((encQuery Fn encFn) a).length
@[reducible, inline]
abbrev Cslib.Crypto.Garbling.encPrvChosen {Fn σ : Type} (encFn : Fn ↪ List Bool) (encσ : σ ↪ List Bool) :

Library construction (no cited definition): the state after a prv.sim adversary's choice stage: ((1^k, aux), (query, state)).

theorem Cslib.Crypto.Garbling.isOraclePPT_prvSimReduction_of_guard {Fn σ : Type} {encFn : Fn ↪ List Bool} {encσ : σ ↪ List Bool} {B : ℕ → PrvSimAdversary Fn σ} (hB : TwoStage.IsPPT Turing.MultiTapeTM.encUnit (encQuery Fn encFn) (Turing.MultiTapeTM.encOption encPrvView) Turing.MultiTapeTM.encBool encσ B) (guard : ℕ → Query Fn → Prop) [(k : ℕ) → (q : Query Fn) → Decidable (guard k q)] (hguard : Turing.MultiTapeTM.ComputableInPolyTime (fun (p : (ℕ × List Bool) × Query Fn × σ) => decide (guard p.1.1 p.2.1)) (encPrvChosen encFn encσ) Turing.MultiTapeTM.encBool) (cont : ℕ → Query Fn → σ → Probability.WordOracleComp Unit Bool) (hcont : Probability.IsOraclePPTOn (encPrvChosen encFn encσ) Turing.MultiTapeTM.encBool fun (p : (ℕ × List Bool) × Query Fn × σ) => cont p.1.1 p.2.1 p.2.2) :
Probability.IsOraclePPT Turing.MultiTapeTM.encBool fun (k : ℕ) (x : List Bool) => do let __x ← ProbOracleComp.sample ((B k).choose ()) match __x with | (query, state) => if guard k query then cont k query state else ProbOracleComp.sample ((B k).guess state none)

Library infrastructure (no cited result): uniform strict PPT combinator for a two-stage prv.sim reduction that runs B.choose (), branches on a polynomial-time guard guard, delegates to cont when guard holds, and runs B.guess on ⊥ otherwise.

Library infrastructure (no cited result): uniform strict PPT combinator for a two-stage prv.sim reduction that checks query.input.length = n query.fn ∧ mult * q query.fn ≤ 2 ^ k, samples coinLen k query.fn uniform coin bits and delegates to cont, or runs B.guess on ⊥.

Library construction (no cited definition): one word-oracle step querying req and appending the reply truncated to len bits.

Library infrastructure (no cited result): one replyStepWord step is uniform strict oracle PPT whenever the request and length bound are computed in polynomial time.

Library infrastructure (no cited result): a replyStepWord len step increases the encoded reply-list length by at most 2 * len + 2.

theorem Cslib.Crypto.Garbling.run_iterate_replyStepWord (len c : ℕ) (req : ℕ → List Bool) (O : Unit × List Bool → ProbComp (List Bool)) (ans : ℕ → List Bool) (hO : ∀ idx < c, O ((), req idx) = pure (ans idx)) :
ProbOracleComp.run (OracleComp.iterate c (fun (rs : List (List Bool)) => replyStepWord len (req rs.length) rs) []) O = pure (List.map (fun (idx : ℕ) => List.take len (ans idx)) (List.range c))

Library infrastructure (no cited result): iterating replyStepWord len (req ·.length) from [] for c steps against a pure-answering word oracle collects (List.range c).map of the replies truncated to len bits.

Library infrastructure (no cited result): iterating replyStepWord from [] for a polynomial-time unary count count is uniform strict oracle PPT whenever the reply cap len and request function req are computed in polynomial time.