Documentation

CslibFrontier.Crypto.Primitives.Garbling.HalfGates.Privacy

Per-instance reduction step for half-gates garbling #

The evaluator of a half-gates garbled circuit sees a View: the two ciphertexts of each AND gate, one label per input wire and the output decoding bits. Privacy in the simulation sense of [ZRE15] asks for a simulator that produces an indistinguishable view from the circuit and its output alone. The simulator simulate samples uniform input labels and a uniform table, and sets the decoding bits so that the evaluated output labels decode to the output.

The reduction targets circular correlation robustness of the hash H [ZRE15]: for a uniform offset Δ = (R, true), the oracle (a, t, b) ↦ H(a + Δ, t) + bΔ is compared against a random function for adversaries that never query both (a, t, 0) and (a, t, 1). This is Cslib.Crypto.Garbling.CCR with a hash that reads the whole label and both offsets CCR.offset R: the oracle is CCR.keyed H CCR.offset CCR.offset R and the advantage is CCR.advantage H CCR.offset CCR.offset.

The per-instance concrete reduction identity advantage_realGame_simGame (a step, not an asymptotic privacy theorem) states that the advantage of every distinguisher D between the real and the simulated view, for a fixed circuit C and input x, equals the advantage CCR.advantage H CCR.offset CCR.offset of an explicit reduction reduction C H tw x D, provided the tweaks of distinct slots are distinct. The reduction knows x, so it knows the bit v_w every wire carries; it samples the input labels the evaluator holds and builds the table gate by gate in wire order. For an AND gate whose arguments carry labels A_a, A_b it queries (A_a, t, p_b) for the generator half, where p_b = col(A_b) + v_b is the colour of the zero label of b, and (A_b, t', v_a) for the evaluator half, and adds the parts of the two ciphertexts the evaluator can compute itself (slotKnown). With the CCR oracle this is the real table, by the half-gates identity; with a random function every query has a distinct tweak, so the table is uniform. Each slot is queried once (isQueryBounded_reduction), at its own tweak, so when distinct slots have distinct tweaks the reduction never queries both (a, t, 0) and (a, t, 1) (isTweakUnique_reduction).

This is a fixed-instance concrete reduction step, not the prv.sim theorem of [ZRE15]: the circuit, the input, the hash and the distinguisher are fixed, the simulator receives the whole circuit C (the side information Φ(C) of [ZRE15]), no hardness assumption is applied, and running time is not tracked. For the word-level reduction (which reuses realGame_reduction and simGame_reduction) and the asymptotic prv.sim theorem under CircularCorrelationRobust, see CslibFrontier.Crypto.Primitives.Garbling.HalfGates.Reduction and Cslib.Crypto.CircularCorrelationRobust.prvSim_halfGates in CslibFrontier.Crypto.Primitives.Garbling.HalfGates.PrvSim.

Main definitions #

Main results #

References #

What the evaluator of a half-gates garbled circuit sees: the garbled table, one label per input wire and the output decoding bits. The circuit is public, as an index of the type.

  • table : Slot C → K × Bool

    The garbled table.

  • input : Fin n → K × Bool

    The label of each input wire.

  • decoding : Fin m → Bool

    The decoding bit of each output wire.

theorem Cslib.Crypto.Garbling.HalfGates.View.ext {n m : ℕ} {C : Circuits.Circuit signature n m} {K : Type} {x y : View C K} (table : x.table = y.table) (input : x.input = y.input) (decoding : x.decoding = y.decoding) :
x = y
def Cslib.Crypto.Garbling.HalfGates.Garbled.view {n m : ℕ} {K : Type} {C : Circuits.Circuit signature n m} (G : Garbled C K) (x : Fin n → Bool) :
View C K

The view of a garbled circuit on an input.

def Cslib.Crypto.Garbling.HalfGates.View.run {n m : ℕ} {K T : Type} [AddCommGroup K] {C : Circuits.Circuit signature n m} (V : View C K) (H : K × Bool → T → K × Bool) (tw : Slot C → T) :
Fin m → Bool

Evaluate a view and decode the result.

theorem Cslib.Crypto.Garbling.HalfGates.Garbled.run_view {n m : ℕ} {K T : Type} [AddCommGroup K] {C : Circuits.Circuit signature n m} (G : Garbled C K) (H : K × Bool → T → K × Bool) (tw : Slot C → T) (x : Fin n → Bool) :
(G.view x).run H tw = G.run H tw x

Running the view of a garbled circuit on x is running the garbled circuit on x.

def Cslib.Crypto.Garbling.HalfGates.simulateWith {n m : ℕ} (C : Circuits.Circuit signature n m) {K T : Type} [AddCommGroup K] (H : K × Bool → T → K × Bool) (tw : Slot C → T) (y : Fin m → Bool) (X : Fin n → K × Bool) (ct : Slot C → K × Bool) :
View C K

The simulated view for input labels X and table ct: the decoding bits make the evaluated output labels decode to y.

theorem Cslib.Crypto.Garbling.HalfGates.View.run_simulateWith {n m : ℕ} (C : Circuits.Circuit signature n m) {K T : Type} [AddCommGroup K] (H : K × Bool → T → K × Bool) (tw : Slot C → T) (y : Fin m → Bool) (X : Fin n → K × Bool) (ct : Slot C → K × Bool) :
(simulateWith C H tw y X ct).run H tw = y

Simulator correctness: every simulated view decodes to y.

The reduction's table #

def Cslib.Crypto.Garbling.HalfGates.slotQuery {n m : ℕ} (C : Circuits.Circuit signature n m) {K T : Type} (tw : Slot C → T) (x : Fin n → Bool) (E : Circuits.Wire n C.size → K × Bool) (s : Slot C) :

The CCR query for a slot, from the labels E the evaluator holds on input x: (A_a, t, p_b) for the generator half and (A_b, t', v_a) for the evaluator half.

def Cslib.Crypto.Garbling.HalfGates.slotKnown {n m : ℕ} (C : Circuits.Circuit signature n m) {K T : Type} [AddCommGroup K] (H : K × Bool → T → K × Bool) (tw : Slot C → T) (E : Circuits.Wire n C.size → K × Bool) (s : Slot C) :

The part of a slot's ciphertext the evaluator computes from its own labels: H(A_a, t) for the generator half and H(A_b, t') + A_a for the evaluator half.

def Cslib.Crypto.Garbling.HalfGates.entry {n m : ℕ} (C : Circuits.Circuit signature n m) {K T : Type} [AddCommGroup K] (H : K × Bool → T → K × Bool) (tw : Slot C → T) (x : Fin n → Bool) (f : CCR.Query (K × Bool) T → K × Bool) (E : Circuits.Wire n C.size → K × Bool) (s : Slot C) :

The reduction's ciphertext for a slot, with oracle f, from the labels E.

theorem Cslib.Crypto.Garbling.HalfGates.slotQuery_tweak {n m : ℕ} (C : Circuits.Circuit signature n m) {K T : Type} (tw : Slot C → T) (x : Fin n → Bool) (E : Circuits.Wire n C.size → K × Bool) (s : Slot C) :
(slotQuery C tw x E s).tweak = tw s
theorem Cslib.Crypto.Garbling.HalfGates.slotQuery_injective {n m : ℕ} (C : Circuits.Circuit signature n m) {K T : Type} (tw : Slot C → T) (x : Fin n → Bool) (htw : Function.Injective tw) (E : Circuits.Wire n C.size → K × Bool) :
theorem Cslib.Crypto.Garbling.HalfGates.entry_congr {n m : ℕ} (C : Circuits.Circuit signature n m) {K T : Type} [AddCommGroup K] (H : K × Bool → T → K × Bool) (tw : Slot C → T) (x : Fin n → Bool) (f : CCR.Query (K × Bool) T → K × Bool) {E E' : Circuits.Wire n C.size → K × Bool} (s : Slot C) (hl : E (left C (Slot.gate C s)) = E' (left C (Slot.gate C s))) (hr : E (right C (Slot.gate C s)) = E' (right C (Slot.gate C s))) :
entry C H tw x f E s = entry C H tw x f E' s
theorem Cslib.Crypto.Garbling.HalfGates.isLocal_entry {n m : ℕ} (C : Circuits.Circuit signature n m) {K T : Type} [AddCommGroup K] (H : K × Bool → T → K × Bool) (tw : Slot C → T) (x : Fin n → Bool) (f : CCR.Query (K × Bool) T → K × Bool) (X : Fin n → K × Bool) :
Circuits.IsLocal fun (E : Circuits.Wire n C.size → K × Bool) => evalStep C H tw (entry C H tw x f E) X E
def Cslib.Crypto.Garbling.HalfGates.oracleLabels {n m : ℕ} (C : Circuits.Circuit signature n m) {K T : Type} [AddCommGroup K] (H : K × Bool → T → K × Bool) (tw : Slot C → T) (x : Fin n → Bool) (f : CCR.Query (K × Bool) T → K × Bool) (X : Fin n → K × Bool) :

The labels the evaluator holds when every ciphertext is the reduction's entry.

def Cslib.Crypto.Garbling.HalfGates.oracleTable {n m : ℕ} (C : Circuits.Circuit signature n m) {K T : Type} [AddCommGroup K] (H : K × Bool → T → K × Bool) (tw : Slot C → T) (x : Fin n → Bool) (f : CCR.Query (K × Bool) T → K × Bool) (X : Fin n → K × Bool) :
Slot C → K × Bool

The reduction's table with oracle f and input labels X.

theorem Cslib.Crypto.Garbling.HalfGates.evalLabels_oracleTable {n m : ℕ} (C : Circuits.Circuit signature n m) {K T : Type} [AddCommGroup K] (H : K × Bool → T → K × Bool) (tw : Slot C → T) (x : Fin n → Bool) (f : CCR.Query (K × Bool) T → K × Bool) (X : Fin n → K × Bool) :
evalLabels C H tw (oracleTable C H tw x f X) X = oracleLabels C H tw x f X
theorem Cslib.Crypto.Garbling.HalfGates.evalLabels_congr {n m : ℕ} (C : Circuits.Circuit signature n m) {K T : Type} [AddCommGroup K] (H : K × Bool → T → K × Bool) (tw : Slot C → T) (X : Fin n → K × Bool) {ct ct' : Slot C → K × Bool} (k : ℕ) (hct : ∀ (s : Slot C), ↑(Slot.gate C s) < k → ct s = ct' s) (w : Circuits.Wire n C.size) (hw : w.toNat < n + k) :
evalLabels C H tw ct X w = evalLabels C H tw ct' X w

Tables agreeing on the gates below k give the same labels on the wires below n + k.

theorem Cslib.Crypto.Garbling.HalfGates.oracleTable_eq_iff {n m : ℕ} (C : Circuits.Circuit signature n m) {K T : Type} [AddCommGroup K] (H : K × Bool → T → K × Bool) (tw : Slot C → T) (x : Fin n → Bool) (f : CCR.Query (K × Bool) T → K × Bool) (X : Fin n → K × Bool) (ct : Slot C → K × Bool) :
oracleTable C H tw x f X = ct ↔ (fun (s : Slot C) => f (slotQuery C tw x (evalLabels C H tw ct X) s)) = fun (s : Slot C) => ct s - slotKnown C H tw (evalLabels C H tw ct X) s

Against a fixed function the reduction's table is oracleTable: the fibre of a table ct is the set of functions taking the prescribed values at the queries made from the labels ct itself gives the evaluator.

The real table #

theorem Cslib.Crypto.Garbling.HalfGates.entry_keyed_activeLabel {n m : ℕ} (C : Circuits.Circuit signature n m) {K T : Type} [AddCommGroup K] (hK : ∀ (k : K), k + k = 0) (H : K × Bool → T → K × Bool) (tw : Slot C → T) (x : Fin n → Bool) (R : K) (W : Circuits.Wire n C.size → K × Bool) (s : Slot C) :
entry C H tw x (CCR.keyed H CCR.offset CCR.offset R) (activeLabel C W (CCR.offset R) x) s = garbleTable C H tw (CCR.offset R) W s

With the CCR oracle and the labels of the bits every wire carries, the reduction's entry is the real half-gates ciphertext.

theorem Cslib.Crypto.Garbling.HalfGates.oracleTable_keyed {n m : ℕ} (C : Circuits.Circuit signature n m) {K T : Type} [AddCommGroup K] (hK : ∀ (k : K), k + k = 0) (H : K × Bool → T → K × Bool) (tw : Slot C → T) (x : Fin n → Bool) (R : K) (Z : Fin n → K × Bool) :
(oracleTable C H tw x (CCR.keyed H CCR.offset CCR.offset R) fun (i : Fin n) => Z i + bitOffset (CCR.offset R) (x i)) = garbleTable C H tw (CCR.offset R) (zeroLabels C H tw (CCR.offset R) Z)

With the CCR oracle for offset key R, the reduction's table on the labels Z + x Δ the evaluator holds is the real garbled table for input zero labels Z.

theorem Cslib.Crypto.Garbling.HalfGates.view_garbleWith {n m : ℕ} (C : Circuits.Circuit signature n m) {K T : Type} [AddCommGroup K] (hK : ∀ (k : K), k + k = 0) (H : K × Bool → T → K × Bool) (tw : Slot C → T) (x : Fin n → Bool) (R : K) (Z : Fin n → K × Bool) :
(garbleWith C H tw R Z).view x = simulateWith C H tw (C.eval interpretation x) (fun (i : Fin n) => Z i + bitOffset (CCR.offset R) (x i)) (oracleTable C H tw x (CCR.keyed H CCR.offset CCR.offset R) fun (i : Fin n) => Z i + bitOffset (CCR.offset R) (x i))

The real view is the simulated view built from the evaluator's input labels and the reduction's table with the CCR oracle.

Building the table with the oracle #

noncomputable def Cslib.Crypto.Garbling.HalfGates.gateStep {n m : ℕ} (C : Circuits.Circuit signature n m) {K T : Type} [AddCommGroup K] (H : K × Bool → T → K × Bool) (tw : Slot C → T) (x : Fin n → Bool) (X : Fin n → K × Bool) (k : ℕ) (ct : Slot C → K × Bool) :
ProbOracleComp (fun (x : CCR.Query (K × Bool) T) => K × Bool) (Slot C → K × Bool)

The ciphertexts of gate k: query the oracle at the two slots of gate k, from the labels the evaluator holds with the table ct built so far, and keep ct elsewhere.

noncomputable def Cslib.Crypto.Garbling.HalfGates.tableRun {n m : ℕ} (C : Circuits.Circuit signature n m) {K T : Type} [AddCommGroup K] (H : K × Bool → T → K × Bool) (tw : Slot C → T) (x : Fin n → Bool) (X : Fin n → K × Bool) :
ℕ → ProbOracleComp (fun (x : CCR.Query (K × Bool) T) => K × Bool) (Slot C → K × Bool)

The table built from the gates below k.

def Cslib.Crypto.Garbling.HalfGates.detRun {n m : ℕ} (C : Circuits.Circuit signature n m) {K T : Type} [AddCommGroup K] (H : K × Bool → T → K × Bool) (tw : Slot C → T) (x : Fin n → Bool) (f : CCR.Query (K × Bool) T → K × Bool) (X : Fin n → K × Bool) :
ℕ → Slot C → K × Bool

The table built from the gates below k against a fixed function.

theorem Cslib.Crypto.Garbling.HalfGates.run_tableRun {n m : ℕ} (C : Circuits.Circuit signature n m) {K T : Type} [AddCommGroup K] (H : K × Bool → T → K × Bool) (tw : Slot C → T) (x : Fin n → Bool) (f : CCR.Query (K × Bool) T → K × Bool) (X : Fin n → K × Bool) (k : ℕ) :
((tableRun C H tw x X k).run fun (q : CCR.Query (K × Bool) T) => pure (f q)) = pure (detRun C H tw x f X k)

Against a fixed function, building the table computes detRun.

theorem Cslib.Crypto.Garbling.HalfGates.detRun_eq {n m : ℕ} (C : Circuits.Circuit signature n m) {K T : Type} [AddCommGroup K] (H : K × Bool → T → K × Bool) (tw : Slot C → T) (x : Fin n → Bool) (f : CCR.Query (K × Bool) T → K × Bool) (X : Fin n → K × Bool) :
detRun C H tw x f X C.size = oracleTable C H tw x f X
theorem Cslib.Crypto.Garbling.HalfGates.isQueryBounded_gateStep {n m : ℕ} (C : Circuits.Circuit signature n m) {K T : Type} [AddCommGroup K] (H : K × Bool → T → K × Bool) (tw : Slot C → T) (x : Fin n → Bool) (X : Fin n → K × Bool) (k : ℕ) (ct : Slot C → K × Bool) :
(gateStep C H tw x X k ct).IsQueryBounded {s : Slot C | ↑(Slot.gate C s) = k}.card

Building the ciphertexts of gate k makes at most one query per slot of gate k.

theorem Cslib.Crypto.Garbling.HalfGates.isQueryBounded_tableRun {n m : ℕ} (C : Circuits.Circuit signature n m) {K T : Type} [AddCommGroup K] (H : K × Bool → T → K × Bool) (tw : Slot C → T) (x : Fin n → Bool) (X : Fin n → K × Bool) (k : ℕ) :
(tableRun C H tw x X k).IsQueryBounded {s : Slot C | ↑(Slot.gate C s) < k}.card

Building the table up to gate k makes at most one query per slot below k.

Experiments #

noncomputable def Cslib.Crypto.Garbling.HalfGates.simulate {n m : ℕ} (C : Circuits.Circuit signature n m) {K T : Type} [AddCommGroup K] [Fintype K] [Nonempty K] (H : K × Bool → T → K × Bool) (tw : Slot C → T) (y : Fin m → Bool) :

The simulator: uniform input labels and a uniform table. It sees the circuit and the output y, but not the input.

noncomputable def Cslib.Crypto.Garbling.HalfGates.realGame {n m : ℕ} (C : Circuits.Circuit signature n m) {K T : Type} [AddCommGroup K] [Fintype K] [Nonempty K] (H : K × Bool → T → K × Bool) (tw : Slot C → T) (x : Fin n → Bool) (D : View C K → ProbComp Bool) :

The real privacy experiment: garble C, and run D on the view of the garbled circuit on x.

noncomputable def Cslib.Crypto.Garbling.HalfGates.simGame {n m : ℕ} (C : Circuits.Circuit signature n m) {K T : Type} [AddCommGroup K] [Fintype K] [Nonempty K] (H : K × Bool → T → K × Bool) (tw : Slot C → T) (x : Fin n → Bool) (D : View C K → ProbComp Bool) :

The simulated privacy experiment: run D on a view simulated from C and its output on x.

The reduction #

noncomputable def Cslib.Crypto.Garbling.HalfGates.reduction {n m : ℕ} (C : Circuits.Circuit signature n m) {K T : Type} [AddCommGroup K] [Fintype K] [Nonempty K] (H : K × Bool → T → K × Bool) (tw : Slot C → T) (x : Fin n → Bool) (D : View C K → ProbComp Bool) :
ProbOracleComp (fun (x : CCR.Query (K × Bool) T) => K × Bool) Bool

The CCR adversary: sample the input labels the evaluator holds, build the table gate by gate with the oracle, and run D on the resulting simulated view.

theorem Cslib.Crypto.Garbling.HalfGates.isQueryBounded_reduction {n m : ℕ} (C : Circuits.Circuit signature n m) {K T : Type} [AddCommGroup K] [Fintype K] [Nonempty K] (H : K × Bool → T → K × Bool) (tw : Slot C → T) (x : Fin n → Bool) (D : View C K → ProbComp Bool) :

The reduction asks at most one query per slot of the garbled table.

theorem Cslib.Crypto.Garbling.HalfGates.isTweakUnique_reduction {n m : ℕ} (C : Circuits.Circuit signature n m) {K T : Type} [AddCommGroup K] [Fintype K] [Nonempty K] (H : K × Bool → T → K × Bool) (tw : Slot C → T) (x : Fin n → Bool) [DecidableEq T] (htw : Function.Injective tw) (D : View C K → ProbComp Bool) :

When distinct slots have distinct tweaks, the reduction makes at most one query with each tweak.

theorem Cslib.Crypto.Garbling.HalfGates.eval_run_reduction {n m : ℕ} (C : Circuits.Circuit signature n m) {K T : Type} [AddCommGroup K] [Fintype K] [Nonempty K] (H : K × Bool → T → K × Bool) (tw : Slot C → T) (x : Fin n → Bool) (D : View C K → ProbComp Bool) (f : CCR.Query (K × Bool) T → K × Bool) :
((reduction C H tw x D).run fun (q : CCR.Query (K × Bool) T) => pure (f q)).eval = (Probability.PMF.uniformOfFintype (Fin n → K × Bool)).bind fun (X : Fin n → K × Bool) => (D (simulateWith C H tw (C.eval interpretation x) X (oracleTable C H tw x f X))).eval
theorem Cslib.Crypto.Garbling.HalfGates.realGame_reduction {n m : ℕ} (C : Circuits.Circuit signature n m) {K T : Type} [AddCommGroup K] [Fintype K] [Nonempty K] (H : K × Bool → T → K × Bool) (tw : Slot C → T) (x : Fin n → Bool) (hK : ∀ (k : K), k + k = 0) (D : View C K → ProbComp Bool) :

The real experiment is the CCR game with the reduction and the keyed oracle.

theorem Cslib.Crypto.Garbling.HalfGates.map_oracleTable {n m : ℕ} (C : Circuits.Circuit signature n m) {K T : Type} [AddCommGroup K] [Fintype K] [Nonempty K] (H : K × Bool → T → K × Bool) (tw : Slot C → T) (x : Fin n → Bool) [Fintype T] [DecidableEq T] [DecidableEq K] (htw : Function.Injective tw) (X : Fin n → K × Bool) :

Against a random function the reduction's table is uniform, for each choice of input labels, when distinct slots have distinct tweaks.

theorem Cslib.Crypto.Garbling.HalfGates.simGame_reduction {n m : ℕ} (C : Circuits.Circuit signature n m) {K T : Type} [AddCommGroup K] [Fintype K] [Nonempty K] (H : K × Bool → T → K × Bool) (tw : Slot C → T) (x : Fin n → Bool) [Fintype T] [DecidableEq T] [DecidableEq K] (htw : Function.Injective tw) (D : View C K → ProbComp Bool) :
(PRF.idealExperiment (reduction C H tw x D)).eval = simGame C H tw x D

The simulated experiment is the CCR game with the reduction and a random function.

theorem Cslib.Crypto.Garbling.HalfGates.advantage_realGame_simGame {n m : ℕ} (C : Circuits.Circuit signature n m) {K T : Type} [AddCommGroup K] [Fintype K] [Nonempty K] (H : K × Bool → T → K × Bool) (tw : Slot C → T) (x : Fin n → Bool) [Fintype T] [DecidableEq T] [DecidableEq K] (hK : ∀ (k : K), k + k = 0) (htw : Function.Injective tw) (D : View C K → ProbComp Bool) :
(realGame C H tw x D).advantage (simGame C H tw x D) = CCR.advantage H CCR.offset CCR.offset (reduction C H tw x D)

Per-instance concrete reduction identity for half-gates garbling: a step, not the prv.sim theorem of [ZRE15], since the circuit C, input x, hash H and distinguisher D are fixed, no hardness assumption is applied, and running time is not tracked; for the asymptotic prv.sim security of half-gates garbling under CircularCorrelationRobust, see Cslib.Crypto.CircularCorrelationRobust.prvSim_halfGates in CslibFrontier.Crypto.Primitives.Garbling.HalfGates.PrvSim. For every circuit C, input x and distinguisher D, if distinct slots have distinct tweaks and every element of K is its own negative, the advantage of D between the real and the simulated view equals the circular correlation robustness advantage CCR.advantage H CCR.offset CCR.offset of the reduction. The identity tweak map, with T = Slot C, has distinct tweaks.