Documentation

CslibFrontier.Crypto.Primitives.Garbling.FreeXOR

Free-XOR garbling #

The Free-XOR technique of Kolesnikov and Schneider [KS08] fixes one secret offset δ for the whole circuit: the two labels of every wire are W and W + (δ, true), the second carrying the bit true. An XOR gate then needs no garbled rows: the sum of its arguments' labels is a label of its output for the sum of their bits. Every other gate is garbled with point-and-permute rows masked by a hash H : K → T → K × Bool.

A Boolean free on the gates marks the XOR gates, and the hypothesis hfree says that each marked gate computes the sum in Bool of its arguments, for any arity. Labels live in K × Bool for an additive group of keys K with k + k = 0 (hypothesis hK), as for bit strings under XOR. garbleWith takes the offset and a base labelling: inputs and gates that are not free keep their base label as their zero label, and the zero label of a free gate is the sum of its arguments' zero labels (propagate). The garbled table has rows only for the gates that are not free (card_garbledRow).

Main definitions #

Main results #

Implementation notes #

The per-instance reduction identity is one exact step, with no hybrids. With the circular oracle, the reduction builds the real view: shifting the base labels by the offset on the wires that carry the bit true is a bijection, and after the shift every inactive label is an oracle answer. In a row whose colours are not all active, the first slot whose colour flips asks the oracle with its bit set to the row's output bit. With a random function the answers are uniform and independent, so every such row is uniform: this is the simulated view. As in Cslib.Crypto.Garbling.Privacy, this is a fixed-instance concrete reduction step: the circuit, the input, the hash and the distinguisher are fixed, no hardness assumption is applied, and running time is not tracked. For the word-level reduction (reusing realGame_reduction and idealGame_reduction) and asymptotic prv.sim security of Free-XOR garbling, see CslibFrontier.Crypto.Primitives.Garbling.FreeXOR.Reduction and Cslib.Crypto.CircularCorrelationRobust.prvSim_freeXOR / prvSimUniversal_freeXOR in CslibFrontier.Crypto.Primitives.Garbling.FreeXOR.PrvSim.

References #

Garbled tables #

@[reducible, inline]

The rows of a Free-XOR garbled table: one for each colour vector of the arguments of each gate that is not free.

@[reducible, inline]
abbrev Cslib.Crypto.Garbling.FreeXOR.GarbledRow.gate {n m s : ℕ} {τ : Circuits.Circuit.Topology n m s} {free : Fin s → Bool} (r : GarbledRow τ free) :
Fin s

The gate of a row.

@[reducible, inline]

The argument slots of the rows of a Free-XOR garbled table.

theorem Cslib.Crypto.Garbling.FreeXOR.card_garbledRow {n m s : ℕ} (τ : Circuits.Circuit.Topology n m s) (free : Fin s → Bool) :
Fintype.card (GarbledRow τ free) = ∑ g : Fin s with free g = false, 2 ^ τ.arity g

Free gates have no rows: the table has 2 ^ a rows for each gate of arity a that is not free, and none for the others.

structure Cslib.Crypto.Garbling.FreeXOR.Garbled {n m s : ℕ} (τ : Circuits.Circuit.Topology n m s) (free : Fin s → Bool) (K : Type) :

A Free-XOR garbled circuit: its table, input encoding and output decoding.

  • table : GarbledRow τ free → K × Bool

    The garbled table.

  • encoding : Fin n → Bool → K × Bool

    The label of each bit of each input.

  • decoding : Fin m → Bool

    The colour of the zero label of each output wire.

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

What the evaluator sees: the garbled table, one label per input wire and the decoding bits.

theorem Cslib.Crypto.Garbling.FreeXOR.View.ext {n m s : ℕ} {τ : Circuits.Circuit.Topology n m s} {free : Fin s → Bool} {K : Type} {x y : View τ free K} (table : x.table = y.table) (input : x.input = y.input) (decoding : x.decoding = y.decoding) :
x = y
theorem Cslib.Crypto.Garbling.FreeXOR.View.ext_iff {n m s : ℕ} {τ : Circuits.Circuit.Topology n m s} {free : Fin s → Bool} {K : Type} {x y : View τ free K} :
def Cslib.Crypto.Garbling.FreeXOR.Garbled.view {n m s : ℕ} {K : Type} {τ : Circuits.Circuit.Topology n m s} {free : Fin s → Bool} (G : Garbled τ free K) (x : Fin n → Bool) :
View τ free K

The view of a garbled circuit on the input x.

def Cslib.Crypto.Garbling.FreeXOR.flipped {n m s : ℕ} {K : Type} {τ : Circuits.Circuit.Topology n m s} {free : Fin s → Bool} (A : Circuits.Wire n s → K × Bool) (r : GarbledRow τ free) (k : Fin (τ.arity r.gate)) :

The colour flips of a row against a labelling: slot k flips when the row's colour differs from the colour of the label of its argument.

def Cslib.Crypto.Garbling.FreeXOR.isFirst {a : ℕ} (e : Fin a → Bool) (k : Fin a) :

Slot k is the first one where e is set.

def Cslib.Crypto.Garbling.FreeXOR.rowBit {σ : Circuits.Signature} {n m : ℕ} {K : Type} (C : Circuits.Circuit σ n m) (I : Circuits.Interpretation σ Bool) {free : Fin C.size → Bool} (x : Fin n → Bool) (A : Circuits.Wire n C.size → K × Bool) (r : GarbledRow C.topology free) :

The output bit of a row against a labelling A on input x: whether the row's plaintext is the label of A or the other label of its gate.

def Cslib.Crypto.Garbling.FreeXOR.reductionQuery {σ : Circuits.Signature} {n m : ℕ} {K T : Type} (C : Circuits.Circuit σ n m) (I : Circuits.Interpretation σ Bool) {free : Fin C.size → Bool} (tw : GarbledSlot C.topology free → T) (x : Fin n → Bool) (A : Circuits.Wire n C.size → K × Bool) (p : GarbledSlot C.topology free) :

The query of the reduction for a slot: the key of the slot's argument under the labelling A, the slot's tweak, and a bit that is set only on the first flipped slot of a row whose output bit is set.

theorem Cslib.Crypto.Garbling.FreeXOR.reductionQuery_tweak {σ : Circuits.Signature} {n m : ℕ} {K T : Type} (C : Circuits.Circuit σ n m) (I : Circuits.Interpretation σ Bool) {free : Fin C.size → Bool} (tw : GarbledSlot C.topology free → T) (x : Fin n → Bool) (A : Circuits.Wire n C.size → K × Bool) (p : GarbledSlot C.topology free) :
(reductionQuery C I tw x A p).tweak = tw p

The query for a slot carries the slot's tweak.

Labels #

def Cslib.Crypto.Garbling.FreeXOR.label {K : Type} [AddCommGroup K] (δ : K) (W : K × Bool) (b : Bool) :

The label for the bit b of a wire with zero label W: W + bitOffset (δ, true) b.

theorem Cslib.Crypto.Garbling.FreeXOR.label_snd {K : Type} [AddCommGroup K] (δ : K) (W : K × Bool) (b : Bool) :
(label δ W b).2 = W.2 + b

The colour of the label for b is the colour of the zero label plus b.

theorem Cslib.Crypto.Garbling.FreeXOR.label_add_label {K : Type} [AddCommGroup K] (hK : ∀ (k : K), k + k = 0) (δ : K) (W W' : K × Bool) (b b' : Bool) :
label δ W b + label δ W' b' = label δ (W + W') (b + b')

Labels add like their bits: this is what makes XOR gates free.

theorem Cslib.Crypto.Garbling.FreeXOR.sum_label {K : Type} [AddCommGroup K] {ι : Type u_1} (hK : ∀ (k : K), k + k = 0) (δ : K) (S : Finset ι) (W : ι → K × Bool) (b : ι → Bool) :
∑ i ∈ S, label δ (W i) (b i) = label δ (∑ i ∈ S, W i) (∑ i ∈ S, b i)
theorem Cslib.Crypto.Garbling.FreeXOR.label_label {K : Type} [AddCommGroup K] (hK : ∀ (k : K), k + k = 0) (δ : K) (W : K × Bool) (b b' : Bool) :
label δ (label δ W b) b' = label δ W (b + b')
theorem Cslib.Crypto.Garbling.FreeXOR.label_label_self {K : Type} [AddCommGroup K] (hK : ∀ (k : K), k + k = 0) (δ : K) (W : K × Bool) (b : Bool) :
label δ (label δ W b) b = W

Zero labels #

def Cslib.Crypto.Garbling.FreeXOR.propagateStep {n m s : ℕ} {K : Type} [AddCommGroup K] (τ : Circuits.Circuit.Topology n m s) (free : Fin s → Bool) (base labels : Circuits.Wire n s → K × Bool) :

One round of propagation: inputs and gates that are not free read their base label, and a free gate takes the sum of its arguments' labels.

def Cslib.Crypto.Garbling.FreeXOR.propagate {n m s : ℕ} {K : Type} [AddCommGroup K] (τ : Circuits.Circuit.Topology n m s) (free : Fin s → Bool) (base : Circuits.Wire n s → K × Bool) :

The zero labels: n + s rounds of propagation, which reach every wire of an ordered topology.

theorem Cslib.Crypto.Garbling.FreeXOR.propagate_input {n m s : ℕ} {K : Type} [AddCommGroup K] {τ : Circuits.Circuit.Topology n m s} (hτ : τ.IsOrdered) (free : Fin s → Bool) (base : Circuits.Wire n s → K × Bool) (i : Fin n) :
theorem Cslib.Crypto.Garbling.FreeXOR.propagate_gate_of_not_free {n m s : ℕ} {K : Type} [AddCommGroup K] {τ : Circuits.Circuit.Topology n m s} (hτ : τ.IsOrdered) {free : Fin s → Bool} (base : Circuits.Wire n s → K × Bool) {g : Fin s} (hg : free g = false) :
theorem Cslib.Crypto.Garbling.FreeXOR.propagate_gate_of_free {n m s : ℕ} {K : Type} [AddCommGroup K] {τ : Circuits.Circuit.Topology n m s} (hτ : τ.IsOrdered) {free : Fin s → Bool} (base : Circuits.Wire n s → K × Bool) {g : Fin s} (hg : free g = true) :
propagate τ free base (Circuits.Wire.gate g) = ∑ k : Fin (τ.arity g), propagate τ free base (τ.wires g k)

Garbling and evaluation #

def Cslib.Crypto.Garbling.FreeXOR.evalStep {n m s : ℕ} {K T : Type} [AddCommGroup K] (τ : Circuits.Circuit.Topology n m s) (free : Fin s → Bool) (H : K → T → K × Bool) (tw : GarbledSlot τ free → T) (table : GarbledRow τ free → K × Bool) (X : Fin n → K × Bool) (labels : Circuits.Wire n s → K × Bool) :

One round of evaluation: an input reads its label, a gate that is not free reads the row named by its arguments' colours and removes the mask, and a free gate adds its arguments' labels.

def Cslib.Crypto.Garbling.FreeXOR.evaluate {n m s : ℕ} {K T : Type} [AddCommGroup K] (τ : Circuits.Circuit.Topology n m s) (free : Fin s → Bool) (H : K → T → K × Bool) (tw : GarbledSlot τ free → T) (table : GarbledRow τ free → K × Bool) (X : Fin n → K × Bool) :
Fin m → K × Bool

Evaluate a garbled table on input labels: n + s rounds, then read the output wires.

def Cslib.Crypto.Garbling.FreeXOR.Garbled.run {n m s : ℕ} {K T : Type} [AddCommGroup K] {τ : Circuits.Circuit.Topology n m s} {free : Fin s → Bool} (G : Garbled τ free K) (H : K → T → K × Bool) (tw : GarbledSlot τ free → T) (x : Fin n → Bool) :
Fin m → Bool

Evaluate a garbled circuit on an input and decode the result.

theorem Cslib.Crypto.Garbling.FreeXOR.isLocal_evalStep {n m s : ℕ} {K T : Type} [AddCommGroup K] {τ : Circuits.Circuit.Topology n m s} (hτ : τ.IsOrdered) (free : Fin s → Bool) (H : K → T → K × Bool) (tw : GarbledSlot τ free → T) (table : GarbledRow τ free → K × Bool) (X : Fin n → K × Bool) :
Circuits.IsLocal (evalStep τ free H tw table X)
theorem Cslib.Crypto.Garbling.FreeXOR.evaluate_eq_of_evalStep {n m s : ℕ} {K T : Type} [AddCommGroup K] {τ : Circuits.Circuit.Topology n m s} (hτ : τ.IsOrdered) (free : Fin s → Bool) (H : K → T → K × Bool) (tw : GarbledSlot τ free → T) (table : GarbledRow τ free → K × Bool) (X : Fin n → K × Bool) (A : Circuits.Wire n s → K × Bool) (hA : ∀ (w : Circuits.Wire n s), evalStep τ free H tw table X A w = A w) :
evaluate τ free H tw table X = A ∘ τ.outputs

On an ordered topology, evaluation follows every labelling A that one round leaves unchanged.

def Cslib.Crypto.Garbling.FreeXOR.garbleTable {σ : Circuits.Signature} {n m : ℕ} {K T : Type} (C : Circuits.Circuit σ n m) (I : Circuits.Interpretation σ Bool) {free : Fin C.size → Bool} (H : K → T → K × Bool) (tw : GarbledSlot C.topology free → T) [AddCommGroup K] (δ : K) (W : Circuits.Wire n C.size → K × Bool) (r : GarbledRow C.topology free) :

The row of a gate that is not free for the colours r.2 of its arguments: the label of the gate for the bit that the colours encode, masked by the hash of the matching argument labels.

def Cslib.Crypto.Garbling.FreeXOR.garbleWith {σ : Circuits.Signature} {n m : ℕ} {K T : Type} (C : Circuits.Circuit σ n m) (I : Circuits.Interpretation σ Bool) {free : Fin C.size → Bool} (H : K → T → K × Bool) (tw : GarbledSlot C.topology free → T) [AddCommGroup K] (δ : K) (base : Circuits.Wire n C.size → K × Bool) :
Garbled C.topology free K

Garble a circuit with the offset δ and the base labels base.

def Cslib.Crypto.Garbling.FreeXOR.activeLabel {σ : Circuits.Signature} {n m : ℕ} {K : Type} (C : Circuits.Circuit σ n m) (I : Circuits.Interpretation σ Bool) (x : Fin n → Bool) [AddCommGroup K] (free : Fin C.size → Bool) (δ : K) (base : Circuits.Wire n C.size → K × Bool) (w : Circuits.Wire n C.size) :

The label of each wire that the evaluator holds on input x.

theorem Cslib.Crypto.Garbling.FreeXOR.evalStep_activeLabel {σ : Circuits.Signature} {n m : ℕ} {K T : Type} (C : Circuits.Circuit σ n m) (I : Circuits.Interpretation σ Bool) {free : Fin C.size → Bool} (H : K → T → K × Bool) (tw : GarbledSlot C.topology free → T) (x : Fin n → Bool) [AddCommGroup K] (hfree : ∀ (g : Fin C.size), free g = true → ∀ (v : Fin (σ.Arity (C.program.lines g).op) → Bool), I (C.program.lines g).op v = ∑ k : Fin (σ.Arity (C.program.lines g).op), v k) (hK : ∀ (k : K), k + k = 0) (δ : K) (base : Circuits.Wire n C.size → K × Bool) (w : Circuits.Wire n C.size) :
evalStep C.topology free H tw (garbleWith C I H tw δ base).table (encode (garbleWith C I H tw δ base).encoding x) (activeLabel C I x free δ base) w = activeLabel C I x free δ base w
theorem Cslib.Crypto.Garbling.FreeXOR.Garbled.run_garbleWith {σ : Circuits.Signature} {n m : ℕ} {K T : Type} (C : Circuits.Circuit σ n m) (I : Circuits.Interpretation σ Bool) {free : Fin C.size → Bool} (H : K → T → K × Bool) (tw : GarbledSlot C.topology free → T) (x : Fin n → Bool) [AddCommGroup K] (hfree : ∀ (g : Fin C.size), free g = true → ∀ (v : Fin (σ.Arity (C.program.lines g).op) → Bool), I (C.program.lines g).op v = ∑ k : Fin (σ.Arity (C.program.lines g).op), v k) (hK : ∀ (k : K), k + k = 0) (δ : K) (base : Circuits.Wire n C.size → K × Bool) :
(garbleWith C I H tw δ base).run H tw x = C.eval I x

Correctness: on an encoded input, a Free-XOR garbled circuit decodes to the circuit's output, for every hash, tweaks, offset and base labels, when the free gates compute XOR and keys have characteristic two.

Views and the simulator #

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

Evaluate a view and decode the result.

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

The simulated view for the output y, the active labels A and the filler rows R: the row named by the active colours holds the gate's active label under its mask, and every other row is filler.

theorem Cslib.Crypto.Garbling.FreeXOR.evalStep_simulateWith {n m s : ℕ} {K T : Type} [AddCommGroup K] {τ : Circuits.Circuit.Topology n m s} (hτ : τ.IsOrdered) (free : Fin s → Bool) (H : K → T → K × Bool) (tw : GarbledSlot τ free → T) (y : Fin m → Bool) (base : Circuits.Wire n s → K × Bool) (R : GarbledRow τ free → K × Bool) (w : Circuits.Wire n s) :
evalStep τ free H tw (simulateWith τ free H tw y (propagate τ free base) R).table (simulateWith τ free H tw y (propagate τ free base) R).input (propagate τ free base) w = propagate τ free base w

The propagated labels are fixed by one evaluation round of the simulated view.

theorem Cslib.Crypto.Garbling.FreeXOR.View.run_simulateWith {n m s : ℕ} {K T : Type} [AddCommGroup K] {τ : Circuits.Circuit.Topology n m s} (hτ : τ.IsOrdered) (free : Fin s → Bool) (H : K → T → K × Bool) (tw : GarbledSlot τ free → T) (y : Fin m → Bool) (base : Circuits.Wire n s → K × Bool) (R : GarbledRow τ free → K × Bool) :
(simulateWith τ free H tw y (propagate τ free base) R).run H tw = y

Simulated views decode to the output, when the active labels are propagated.

The reduction's view #

def Cslib.Crypto.Garbling.FreeXOR.reductionTable {n m s : ℕ} {K T : Type} [AddCommGroup K] {τ : Circuits.Circuit.Topology n m s} {free : Fin s → Bool} (H : K → T → K × Bool) (tw : GarbledSlot τ free → T) (A : Circuits.Wire n s → K × Bool) (O : GarbledSlot τ free → K × Bool) (r : GarbledRow τ free) :

The table built by the reduction from oracle answers O: in each row, the slots whose colour flips against A read the oracle, and the others hash their label under A.

def Cslib.Crypto.Garbling.FreeXOR.reductionView {n m s : ℕ} {K T : Type} [AddCommGroup K] (τ : Circuits.Circuit.Topology n m s) {free : Fin s → Bool} (H : K → T → K × Bool) (tw : GarbledSlot τ free → T) (y : Fin m → Bool) (A : Circuits.Wire n s → K × Bool) (O : GarbledSlot τ free → K × Bool) :
View τ free K

The view built by the reduction.

Privacy #

noncomputable def Cslib.Crypto.Garbling.FreeXOR.garble {σ : Circuits.Signature} {n m : ℕ} {K T : Type} (C : Circuits.Circuit σ n m) (I : Circuits.Interpretation σ Bool) {free : Fin C.size → Bool} (H : K → T → K × Bool) (tw : GarbledSlot C.topology free → T) [AddCommGroup K] [Fintype K] [Nonempty K] :

Garble a circuit with a uniform offset and uniform base labels.

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

The simulator: uniform base labels, propagated to every wire, and uniform filler rows. It sees only the topology, the free gates, the hash, the tweaks and the output.

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

The simulated privacy experiment: run D on a view simulated from the output on x.

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

The adversary against circular correlation robustness: sample base labels, propagate them, query the oracle once for each slot of the garbled table, build the view from the answers, and run D on it.

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

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

theorem Cslib.Crypto.Garbling.FreeXOR.isTweakUnique_reduction {σ : Circuits.Signature} {n m : ℕ} {K T : Type} (C : Circuits.Circuit σ n m) (I : Circuits.Interpretation σ Bool) {free : Fin C.size → Bool} (H : K → T → K × Bool) (tw : GarbledSlot C.topology free → T) (x : Fin n → Bool) [AddCommGroup K] [Fintype K] [Nonempty K] (D : View C.topology free K → ProbComp Bool) [DecidableEq T] (htw : Function.Injective tw) :

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

theorem Cslib.Crypto.Garbling.FreeXOR.eval_run_reduction {σ : Circuits.Signature} {n m : ℕ} {K T : Type} (C : Circuits.Circuit σ n m) (I : Circuits.Interpretation σ Bool) {free : Fin C.size → Bool} (H : K → T → K × Bool) (tw : GarbledSlot C.topology free → T) (x : Fin n → Bool) [AddCommGroup K] [Fintype K] [Nonempty K] (D : View C.topology free K → ProbComp Bool) (f : CCR.Query K T → K × Bool) :
((reduction C I H tw x D).run fun (q : CCR.Query K T) => pure (f q)).eval = (Probability.PMF.uniformOfFintype (Circuits.Wire n C.size → K × Bool)).bind fun (base : Circuits.Wire n C.size → K × Bool) => (D (reductionView C.topology H tw (C.eval I x) (propagate C.topology free base) fun (p : GarbledSlot C.topology free) => f (reductionQuery C I tw x (propagate C.topology free base) p))).eval

Library infrastructure (no cited result): evaluation of reduction against a fixed oracle f samples uniform base labels and applies D to reductionView on the resulting answers.

theorem Cslib.Crypto.Garbling.FreeXOR.realGame_reduction {σ : Circuits.Signature} {n m : ℕ} {K T : Type} (C : Circuits.Circuit σ n m) (I : Circuits.Interpretation σ Bool) {free : Fin C.size → Bool} (H : K → T → K × Bool) (tw : GarbledSlot C.topology free → T) (x : Fin n → Bool) [AddCommGroup K] [Fintype K] [Nonempty K] (D : View C.topology free K → ProbComp Bool) (hfree : ∀ (g : Fin C.size), free g = true → ∀ (v : Fin (σ.Arity (C.program.lines g).op) → Bool), I (C.program.lines g).op v = ∑ k : Fin (σ.Arity (C.program.lines g).op), v k) (hK : ∀ (k : K), k + k = 0) :
(PRF.realExperiment (CCR.keyed H id fun (x : K) => (x, true)) (reduction C I H tw x D)).eval = realGame C I H tw x D

Library infrastructure (no cited result): with the circular oracle, the reduction plays the real experiment.

theorem Cslib.Crypto.Garbling.FreeXOR.idealGame_reduction {σ : Circuits.Signature} {n m : ℕ} {K T : Type} (C : Circuits.Circuit σ n m) (I : Circuits.Interpretation σ Bool) {free : Fin C.size → Bool} (H : K → T → K × Bool) (tw : GarbledSlot C.topology free → T) (x : Fin n → Bool) [AddCommGroup K] [Fintype K] [Nonempty K] (D : View C.topology free K → ProbComp Bool) [DecidableEq K] [Fintype T] [DecidableEq T] (htw : Function.Injective tw) :
(PRF.idealExperiment (reduction C I H tw x D)).eval = simGame C I H tw x D

Library infrastructure (no cited result): with a uniform random function, the reduction plays the simulated experiment, when distinct slots have distinct tweaks.

theorem Cslib.Crypto.Garbling.FreeXOR.advantage_realGame_simGame {σ : Circuits.Signature} {n m : ℕ} {K T : Type} (C : Circuits.Circuit σ n m) (I : Circuits.Interpretation σ Bool) {free : Fin C.size → Bool} (H : K → T → K × Bool) (tw : GarbledSlot C.topology free → T) (x : Fin n → Bool) [AddCommGroup K] [Fintype K] [Nonempty K] (D : View C.topology free K → ProbComp Bool) [DecidableEq K] [Fintype T] [DecidableEq T] (hfree : ∀ (g : Fin C.size), free g = true → ∀ (v : Fin (σ.Arity (C.program.lines g).op) → Bool), I (C.program.lines g).op v = ∑ k : Fin (σ.Arity (C.program.lines g).op), v k) (hK : ∀ (k : K), k + k = 0) (htw : Function.Injective tw) :
(realGame C I H tw x D).advantage (simGame C I H tw x D) = CCR.advantage H id (fun (x : K) => (x, true)) (reduction C I H tw x D)

Per-instance concrete reduction identity for Free-XOR garbling: a step, not an asymptotic privacy theorem, 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 theorems of Free-XOR garbling, see Cslib.Crypto.CircularCorrelationRobust.prvSim_freeXOR and prvSimUniversal_freeXOR in CslibFrontier.Crypto.Primitives.Garbling.FreeXOR.PrvSim. If the free gates compute XOR, keys have characteristic two and distinct slots have distinct tweaks, then the advantage of every distinguisher D between the real and the simulated view equals the circular correlation robustness advantage of reduction C I H tw x D against H, which asks one query per slot of the garbled table (isQueryBounded_reduction), with the slot's tweak (reductionQuery_tweak).