Documentation

CslibFrontier.Crypto.Primitives.Garbling.Privacy

Simulation-based privacy of garbled circuits #

The evaluator of a garbled circuit sees a View: the garbled table, one label per input wire and the output decoding information. Privacy in the simulation sense of Bellare, Hoang and Rogaway [BHR12b] with topology side information asks for a simulator that produces an indistinguishable view from the circuit's topology and its output alone. The simulator simulate samples one uniform label per wire, writes in each gate's row named by its arguments' labels the gate's label masked under their keys, fills every other row uniformly, and sets the decoding bits so that the output labels decode to the output. It never sees the gate operations or the input.

The concrete per-instance step advantage_realGame_simGame_le bounds the advantage of every distinguisher D between the real view and the simulated view, for a circuit C and an input x, by the sum over the n + C.size wires of the PRF advantage of an explicit reduction reduction C I F tw x D j against F, provided the tweaks of distinct argument slots are distinct. The proof is a hybrid argument over the wires in wire-number order: hybrid j replaces by uniform values the rows that read an inactive label on a wire numbered below j. The reduction for wire j embeds the PRF key as the inactive key of wire j: with the keyed oracle it produces hybrid j exactly (PRF.realExperiment side), and with a random function hybrid j + 1 exactly (PRF.idealExperiment side). Each reduction reads the oracle up front at the tweaks of all argument slots, with at most one query per slot (isQueryBounded_reduction), and runs D once. Both laws hold for every j (eval_realExperiment_reduction, eval_idealExperiment_reduction): from wire n + C.size on no slot is a target and every hybrid is the simulated experiment (hybridGame_of_le), so a reduction may draw its step from a range larger than the number of wires.

Tweak injectivity is needed. Take a row that reads one wire twice with the same colour. If its two argument slots had equal tweaks, their mask terms would be equal and cancel in the Bool component, so for a binary gate that row's colour bit would be sent in the clear. The identity on Slot C.topology is an injective tweak map.

The simulator is correct: on an ordered topology every simulated view decodes to the output (View.run_simulateWith).

This is the single-instance form of simulation privacy: the circuit, input and distinguisher are fixed, so a bound uniform over a class of distinguishers follows by bounding the PRF advantage of the corresponding reductions. No bound holds for arbitrary distinguishers, since an exhaustive key search distinguishes once K is fixed. In the prv.sim game of [BHR12b] the adversary itself chooses the circuit and the input, possibly at random and keeping state for its guess. For point-and-permute garbling that game is treated in CslibFrontier.Crypto.Primitives.Garbling.PointPermute.Reduction, which runs the hybrids and reductions of this file on the adversary's choice (PointPermute.prvSimAdvantage_simWord_eq), and PseudorandomFunction.prvSim_pointPermute in CslibFrontier.Crypto.Primitives.Garbling.PointPermute.Privacy is the asymptotic prv.sim theorem for that scheme over valid conventional circuits. Running time is not tracked here: there are no cost bounds for garbling, evaluation, the simulator or the reductions.

Main definitions #

Main results #

References #

structure Cslib.Crypto.Garbling.View {n m s : ℕ} (τ : Circuits.Circuit.Topology n m s) (K : Type) :

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

  • table : Row τ → 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.View.ext {n m s : ℕ} {τ : Circuits.Circuit.Topology n m s} {K : Type} {x y : View τ K} (table : x.table = y.table) (input : x.input = y.input) (decoding : x.decoding = y.decoding) :
x = y
theorem Cslib.Crypto.Garbling.View.ext_iff {n m s : ℕ} {τ : Circuits.Circuit.Topology n m s} {K : Type} {x y : View τ K} :
def Cslib.Crypto.Garbling.Garbled.view {n m s : ℕ} {K : Type} {τ : Circuits.Circuit.Topology n m s} (G : Garbled τ K) (x : Fin n → Bool) :
View τ K

The view of a garbled circuit on an input.

def Cslib.Crypto.Garbling.View.run {n m s : ℕ} {K T : Type} [AddCommGroup K] {τ : Circuits.Circuit.Topology n m s} (V : View τ K) (F : K → T → K × Bool) (tw : Slot τ → T) :
Fin m → Bool

Evaluate a view and decode the result.

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

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

def Cslib.Crypto.Garbling.simulateWith {n m s : ℕ} {K T : Type} [AddCommGroup K] (τ : Circuits.Circuit.Topology n m s) (F : K → T → K × Bool) (tw : Slot τ → T) (y : Fin m → Bool) (A : Circuits.Wire n s → K × Bool) (R : Row τ → K × Bool) :
View τ K

The simulated view for wire labels A and filler rows R: input wires carry their labels; the row of each gate named by its arguments' colours holds the gate's label masked under their keys; every other row is filler; the decoding bits make the output labels decode to y.

theorem Cslib.Crypto.Garbling.evalStep_simulateWith {n m s : ℕ} {K T : Type} [AddCommGroup K] (τ : Circuits.Circuit.Topology n m s) (F : K → T → K × Bool) (tw : Slot τ → T) (y : Fin m → Bool) (A : Circuits.Wire n s → K × Bool) (R : Row τ → K × Bool) (w : Circuits.Wire n s) :
evalStep τ F tw (simulateWith τ F tw y A R).table (simulateWith τ F tw y A R).input A w = A w

The simulated labels are a fixed point of one evaluation round of the simulated view: the row of a gate named by its arguments' colours unmasks to the gate's label.

theorem Cslib.Crypto.Garbling.View.run_simulateWith {n m s : ℕ} {K T : Type} [AddCommGroup K] {τ : Circuits.Circuit.Topology n m s} (hτ : τ.IsOrdered) (F : K → T → K × Bool) (tw : Slot τ → T) (y : Fin m → Bool) (A : Circuits.Wire n s → K × Bool) (R : Row τ → K × Bool) :
(simulateWith τ F tw y A R).run F tw = y

Simulator correctness: on an ordered topology every simulated view decodes to y.

Hybrid views #

The active colour of each wire on input x: its plaintext value plus its permutation bit.

def Cslib.Crypto.Garbling.IsHidden {n m s : ℕ} {τ : Circuits.Circuit.Topology n m s} (a : Circuits.Wire n s → Bool) (j : ℕ) (r : Row τ) :

A row is hidden below j when it reads an inactive colour, for the active colours a, on some wire numbered below j.

Instances For
    @[instance_reducible]
    instance Cslib.Crypto.Garbling.instDecidableIsHidden {n m s : ℕ} {τ : Circuits.Circuit.Topology n m s} (a : Circuits.Wire n s → Bool) (j : ℕ) (r : Row τ) :
    def Cslib.Crypto.Garbling.IsTarget {n m s : ℕ} {τ : Circuits.Circuit.Topology n m s} (a : Circuits.Wire n s → Bool) (j : ℕ) (r : Row τ) (k : Fin (τ.arity r.fst)) :

    Argument slot k of row r is a target of step j when it reads the inactive colour, for the active colours a, of wire j.

    Instances For
      @[instance_reducible]
      instance Cslib.Crypto.Garbling.instDecidableIsTarget {n m s : ℕ} {τ : Circuits.Circuit.Topology n m s} (a : Circuits.Wire n s → Bool) (j : ℕ) (r : Row τ) (k : Fin (τ.arity r.fst)) :
      def Cslib.Crypto.Garbling.hybridView {σ : Circuits.Signature} {n m : ℕ} {K T : Type} [AddCommGroup K] (C : Circuits.Circuit σ n m) (I : Circuits.Interpretation σ Bool) (F : K → T → K × Bool) (tw : Slot C.topology → T) (x : Fin n → Bool) (j : ℕ) (key : Circuits.Wire n C.size × Bool → K) (perm : Circuits.Wire n C.size → Bool) (R : Row C.topology → K × Bool) (O : Slot C.topology → K × Bool) :

      Hybrid view j with oracle O: rows hidden below wire j are taken from R; in the other rows, the mask term of each target slot of step j is the oracle's answer.

      Experiments #

      noncomputable def Cslib.Crypto.Garbling.simulate {n m s : ℕ} {K T : Type} [AddCommGroup K] [Fintype K] [Nonempty K] (τ : Circuits.Circuit.Topology n m s) (F : K → T → K × Bool) (tw : Slot τ → T) (y : Fin m → Bool) :
      ProbComp (View τ K)

      The simulator: uniform wire labels and uniform filler rows. It sees only the topology, the public keyed function and tweaks, and the output.

      noncomputable def Cslib.Crypto.Garbling.realGame {σ : Circuits.Signature} {n m : ℕ} {K T : Type} [AddCommGroup K] [Fintype K] [Nonempty K] (C : Circuits.Circuit σ n m) (I : Circuits.Interpretation σ Bool) (F : K → T → K × Bool) (tw : Slot C.topology → T) (x : Fin n → Bool) (D : View C.topology 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.simGame {σ : Circuits.Signature} {n m : ℕ} {K T : Type} [AddCommGroup K] [Fintype K] [Nonempty K] (C : Circuits.Circuit σ n m) (I : Circuits.Interpretation σ Bool) (F : K → T → K × Bool) (tw : Slot C.topology → T) (x : Fin n → Bool) (D : View C.topology K → ProbComp Bool) :

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

      The hybrid argument #

      noncomputable def Cslib.Crypto.Garbling.hybridGame {σ : Circuits.Signature} {n m : ℕ} {K T : Type} [AddCommGroup K] [Fintype K] [Nonempty K] (C : Circuits.Circuit σ n m) (I : Circuits.Interpretation σ Bool) (F : K → T → K × Bool) (tw : Slot C.topology → T) (x : Fin n → Bool) (D : View C.topology K → ProbComp Bool) (j : ℕ) :

      Hybrid experiment j: uniform keys, permutation bits and filler rows, and D run on hybrid view j with the keyed function in every slot. Hybrid 0 is the real experiment (hybridGame_zero) and every hybrid from n + C.size on is the simulated one (hybridGame_of_le).

      noncomputable def Cslib.Crypto.Garbling.reduction {σ : Circuits.Signature} {n m : ℕ} {K T : Type} [AddCommGroup K] [Fintype K] [Nonempty K] (C : Circuits.Circuit σ n m) (I : Circuits.Interpretation σ Bool) (F : K → T → K × Bool) (tw : Slot C.topology → T) (x : Fin n → Bool) (D : View C.topology K → ProbComp Bool) (j : ℕ) :
      ProbOracleComp (fun (x : T) => K × Bool) Bool

      The PRF adversary for hybrid step j: sample keys, permutation bits and filler rows, query the oracle at the tweak of every argument slot, build hybrid view j with the answers in place of the mask terms on the inactive colour of wire j, and run D on it.

      theorem Cslib.Crypto.Garbling.isQueryBounded_reduction {σ : Circuits.Signature} {n m : ℕ} {K T : Type} [AddCommGroup K] [Fintype K] [Nonempty K] (C : Circuits.Circuit σ n m) (I : Circuits.Interpretation σ Bool) (F : K → T → K × Bool) (tw : Slot C.topology → T) (x : Fin n → Bool) (D : View C.topology K → ProbComp Bool) (j : ℕ) :

      Each reduction makes at most one oracle query per argument slot of the garbled table.

      theorem Cslib.Crypto.Garbling.eval_run_reduction {σ : Circuits.Signature} {n m : ℕ} {K T : Type} [AddCommGroup K] [Fintype K] [Nonempty K] (C : Circuits.Circuit σ n m) (I : Circuits.Interpretation σ Bool) (F : K → T → K × Bool) (tw : Slot C.topology → T) (x : Fin n → Bool) (D : View C.topology K → ProbComp Bool) (j : ℕ) (f : T → K × Bool) :
      ((reduction C I F tw x D j).run fun (t : T) => pure (f t)).eval = (Probability.PMF.uniformOfFintype (Circuits.Wire n C.size × Bool → K)).bind fun (key : Circuits.Wire n C.size × Bool → K) => (Probability.PMF.uniformOfFintype (Circuits.Wire n C.size → Bool)).bind fun (perm : Circuits.Wire n C.size → Bool) => (Probability.PMF.uniformOfFintype (Row C.topology → K × Bool)).bind fun (R : Row C.topology → K × Bool) => (D (hybridView C I F tw x j key perm R fun (p : Slot C.topology) => f (tw p))).eval

      Against a table f, the reduction samples hybrid view j with the table at the slots' tweaks in place of the target mask terms.

      theorem Cslib.Crypto.Garbling.hybridGame_zero {σ : Circuits.Signature} {n m : ℕ} {K T : Type} [AddCommGroup K] [Fintype K] [Nonempty K] (C : Circuits.Circuit σ n m) (I : Circuits.Interpretation σ Bool) (F : K → T → K × Bool) (tw : Slot C.topology → T) (x : Fin n → Bool) (D : View C.topology K → ProbComp Bool) :
      hybridGame C I F tw x D 0 = realGame C I F tw x D

      Hybrid 0 is the real experiment.

      theorem Cslib.Crypto.Garbling.hybridGame_of_le {σ : Circuits.Signature} {n m : ℕ} {K T : Type} [AddCommGroup K] [Fintype K] [Nonempty K] (C : Circuits.Circuit σ n m) (I : Circuits.Interpretation σ Bool) (F : K → T → K × Bool) (tw : Slot C.topology → T) (x : Fin n → Bool) (D : View C.topology K → ProbComp Bool) {j : ℕ} (hj : n + C.size ≤ j) :
      hybridGame C I F tw x D j = simGame C I F tw x D

      Every hybrid from n + C.size on is the simulated experiment.

      theorem Cslib.Crypto.Garbling.eval_realExperiment_reduction {σ : Circuits.Signature} {n m : ℕ} {K T : Type} [AddCommGroup K] [Fintype K] [Nonempty K] (C : Circuits.Circuit σ n m) (I : Circuits.Interpretation σ Bool) (F : K → T → K × Bool) (tw : Slot C.topology → T) (x : Fin n → Bool) (D : View C.topology K → ProbComp Bool) (j : ℕ) :
      (PRF.realExperiment F (reduction C I F tw x D j)).eval = hybridGame C I F tw x D j

      Against the keyed oracle, reduction j plays hybrid j.

      theorem Cslib.Crypto.Garbling.eval_idealExperiment_reduction {σ : Circuits.Signature} {n m : ℕ} {K T : Type} [AddCommGroup K] [Fintype K] [Nonempty K] [Fintype T] [DecidableEq T] (C : Circuits.Circuit σ n m) (I : Circuits.Interpretation σ Bool) (F : K → T → K × Bool) (tw : Slot C.topology → T) (htw : Function.Injective tw) (x : Fin n → Bool) (D : View C.topology K → ProbComp Bool) (j : ℕ) :
      (PRF.idealExperiment (reduction C I F tw x D j)).eval = hybridGame C I F tw x D (j + 1)

      Against a random function, reduction j plays hybrid j + 1, when distinct slots have distinct tweaks.

      theorem Cslib.Crypto.Garbling.advantage_realGame_simGame_le {σ : Circuits.Signature} {n m : ℕ} {K T : Type} [AddCommGroup K] [Fintype K] [Nonempty K] [Fintype T] [DecidableEq T] (C : Circuits.Circuit σ n m) (I : Circuits.Interpretation σ Bool) (F : K → T → K × Bool) (tw : Slot C.topology → T) (htw : Function.Injective tw) (x : Fin n → Bool) (D : View C.topology K → ProbComp Bool) :
      (realGame C I F tw x D).advantage (simGame C I F tw x D) ≤ ∑ j ∈ Finset.range (n + C.size), PRF.advantage F (reduction C I F tw x D j)

      The per-instance hybrid bound: a step, not the prv.sim theorem of [BHR12b], since the circuit, input and distinguisher are fixed and nothing is asymptotic; for point-and-permute garbling that theorem is PseudorandomFunction.prvSim_pointPermute. For every circuit C, input x and distinguisher D, if distinct argument slots have distinct tweaks, the advantage of D between the real and the simulated view is at most the sum, over the n + C.size wires, of the PRF advantage of the reduction for that wire against F. The hypothesis htw cannot be dropped: in a row reading one wire twice with the same colour, equal tweaks on the two slots make their mask terms cancel in the Bool component. The identity tweak map, with T = Slot C.topology, satisfies it.