Documentation

CslibFrontier.Crypto.Primitives.Garbling.FreeXOR.Scheme

Free-XOR garbling as a garbling scheme #

Definitions and correctness only. The efficiency certificates of the scheme (CslibFrontier.Crypto.Primitives.Garbling.FreeXOR.Efficient), its word simulator (CslibFrontier.Crypto.Primitives.Garbling.FreeXOR.Simulator) and its simulation privacy (prv.sim) under CircularCorrelationRobust, by a certified reduction (CslibFrontier.Crypto.Primitives.Garbling.FreeXOR.Reduction, CslibFrontier.Crypto.Primitives.Garbling.FreeXOR.PrvSim), build on it.

The Free-XOR garbling of CslibFrontier.Crypto.Primitives.Garbling.FreeXOR, after Kolesnikov and Schneider [KS08] and Choi, Katz, Kumaresan and Zhou [CKKZ12], as a garbling scheme in the sense of Bellare, Hoang and Rogaway [BHR12b] (Garbling.Scheme) over valid conventional circuits (ValidCircuit): FreeXOR.scheme hash, with the hash family hash. Every gate whose truth table is XOR is marked free and emits no garbled rows; every other gate gets four point-and-permute rows masked by two single-key calls to H'(x, t) = CCR.atLevel hash k ((x, false), t).

At security parameter k, a label is a (k + 1)-bit key followed by its colour bit. Slot a of row i of gate g has the tweak 8 g + 2 i + a reduced modulo 2 ^ k (PointPermute.tweak). The coins are the k + 1 bits of the offset key R, then the n + q base labels of the n input wires and q gate wires; the offset is CCR.offset R = (R, true). Correctness holds for every hash family, even when tweaks collide (FreeXOR.scheme_correct).

Gb writes the garbled function F as the header (k, n, m, q), in unary, followed for each gate by its two argument wires A g and B g as w-bit numbers (w the bit length of n + q), a bit that is set when the gate computes XOR, and four (k + 2)-bit rows when the gate does not compute XOR. XOR gates have no rows [KS08]. The encoding information e lists both labels of each input wire, so En is projectiveEncode; the decoding information d lists the colours of the zero labels of the m output wires, and De is PointPermute.decodeWord.

The scheme is correct (FreeXOR.scheme_correct) but not valid in the sense of [BHR12b] (§3.1, p. 7: the length condition requires |F|, |e|, and |d| to depend only on (k, f.n, f.m, |f|), and non-degeneracy requires e and d to depend only on those and the coins). Here |F| depends on the number of non-XOR gates, so the length condition fails, and d holds the colours of output zero labels propagated from the gate flags, so non-degeneracy fails too. [CKKZ12] (§2.2, p. 5, locator not verified) likewise send no ciphertexts for XOR gates. Simulation privacy does not use validity.

The garbler and the evaluator are list programs. The garbler writes the typed garbling FreeXOR.garbleWith of ConventionalCircuit.toCircuit f (FreeXOR.gb_eq_encodeGarbled), and the evaluator follows every fixed point of the typed evaluation round (FreeXOR.evalWord_encodeFn), so correctness follows from FreeXOR.Garbled.run_garbleWith and ConventionalCircuit.eval_toCircuit.

Main definitions #

Main results #

References #

XOR gates #

Whether a four-bit truth table [G 0 0, G 0 1, G 1 0, G 1 1] is XOR.

isXorTable on a gate's truth table agrees with decide (G = xor).

Words #

The key-only hash at parameter k on words: hash the (k + 1)-bit key of a paired with colour false and the tweak t, reading the first k + 2 bits.

The base label of wire v read from the coins: block v of k + 2 bits after the offset key.

The zero labels of the first n + s wires of f at parameter k, in wire order: input wires and non-XOR gates read their base labels from coins, and an XOR gate takes the sum of its arguments' zero labels.

def Cslib.Crypto.Garbling.FreeXOR.rowWord (hash : List Bool → List Bool → List Bool) (k : ℕ) (f : ConventionalCircuit) (Δ : List Bool) (labels : List (List Bool)) (g : Fin f.q) (i : ℕ) :

Row i of non-XOR gate g of f at parameter k, from the offset Δ and the zero labels labels of all wires.

def Cslib.Crypto.Garbling.FreeXOR.gateWord (hash : List Bool → List Bool → List Bool) (k w : ℕ) (f : ConventionalCircuit) (Δ : List Bool) (labels : List (List Bool)) (g : Fin f.q) :

The block of gate g in the garbled function, from the zero labels labels of all wires: its argument wires A g and B g as w-bit numbers, its XOR bit, and four rows when it is not an XOR gate.

The garbled function of f: the header (k, n, m, q), then the blocks of its gates.

The decoding information of f: the colours of the zero labels of its last m wires.

def Cslib.Crypto.Garbling.FreeXOR.evalGate (hash : List Bool → List Bool → List Bool) (k w : ℕ) (body : List Bool) (state : List (List Bool) × ℕ) (g : ℕ) :

One gate of Ev, with the labels of the earlier wires and the position pos of the gate's block in the body: read the gate's argument wires and their labels, and append their sum for an XOR gate or the unmasked selected row for a non-XOR gate.

Ev(F, X): read the header (k, n, m, q) of F, start from the n labels of X, evaluate the gates in order, and return the labels of the last m wires.

Free-XOR garbling as a garbling scheme over valid conventional circuits, with the hash family hash.

Its length readers are (n, m, q) and its semantics is ConventionalCircuit.evalCirc.

The typed garbling #

Evaluating gate g of toCircuit f under fullInterpretation applies f.1.G to its two arguments.

def Cslib.Crypto.Garbling.FreeXOR.garbledRowOf {n m s : ℕ} (τ : Circuits.Circuit.Topology n m s) {free : Fin s → Bool} (g : Fin s) (hg : free g = false) (i : ℕ) :
GarbledRow τ free

Row i of non-free gate g of τ, with colours read in binary, first argument most significant.

def Cslib.Crypto.Garbling.FreeXOR.slotTweak {n m s : ℕ} (τ : Circuits.Circuit.Topology n m s) (free : Fin s → Bool) (k : ℕ) :
GarbledSlot τ free → BitString k

The tweaks of the slots of (τ, free) at parameter k: slot a of row ρ of gate g gets PointPermute.tweak k g (PointPermute.rowIndex ρ) a.

The typed base labels of all wires read from the coins.

def Cslib.Crypto.Garbling.FreeXOR.encodeGate {n m s : ℕ} (k w : ℕ) (τ : Circuits.Circuit.Topology n m s) (free : Fin s → Bool) (table : GarbledRow τ free → BitString (k + 1) × Bool) (g : Fin s) :

The block of gate g of a garbled table over (τ, free) at parameter k: its argument wires, from 1, as w-bit numbers, its free bit, and for a non-free gate its rows in garbledRowOf order.

def Cslib.Crypto.Garbling.FreeXOR.encodeFn {n m s : ℕ} (k : ℕ) (τ : Circuits.Circuit.Topology n m s) (free : Fin s → Bool) (table : GarbledRow τ free → BitString (k + 1) × Bool) :

The garbled function of a table over (τ, free) at parameter k: the header (k, n, m, s), then the blocks of the gates.

The words (F, e, d) of a typed garbling of toCircuit f at parameter k.

@[simp]
theorem Cslib.Crypto.Garbling.FreeXOR.length_keyHashWord (hash : List Bool → List Bool → List Bool) (k : ℕ) (a t : List Bool) :
(keyHashWord hash k a t).length = k + 2

A key-hash word has k + 2 bits.

CCR.atLevel hash k ((x, false), t) as a word is keyHashWord.

CCR.atLevel hash k ((labelOfWord k a).1, false) t as a word is keyHashWord.

On a label word a, keyHashWord agrees with CCR.atLevel on the label's key.

theorem Cslib.Crypto.Garbling.FreeXOR.labelBits_baseLabels {n s : ℕ} (k : ℕ) (coins : List Bool) (w : Circuits.Wire n s) :
labelBits (baseLabels k coins w) = baseWord k coins w.toNat

A base label read from the coins, as a word, is baseWord.

theorem Cslib.Crypto.Garbling.FreeXOR.propagateWords_eq (k : ℕ) (f : ValidCircuit) (coins : List Bool) {s : ℕ} (hs : s ≤ (↑f).q) :

The garbler's zero labels are the typed propagated zero labels.

Library infrastructure (no cited result): looking up gate g's wire in the ofFn label list of toCircuit f returns labelBits (W (.gate g)).

Library infrastructure (no cited result): looking up gate g's first argument wire A g - 1 in the ofFn label list of toCircuit f.

Library infrastructure (no cited result): looking up gate g's second argument wire B g - 1 in the ofFn label list of toCircuit f.

Library infrastructure (no cited result): looking up output wire o in the ofFn label list of toCircuit f returns labelBits (W ((toCircuit f).outputs o)).

The garbler computes the typed garbling. At parameter k, Gb on any coins writes the words of the typed Free-XOR garbling garbleWith of ConventionalCircuit.toCircuit f, with the hash fun key t => CCR.atLevel hash k (key, false) t, the tweaks slotTweak and the offset key and base labels read from the coins.

Evaluation #

Ev follows a fixed point of an evaluation round. If the labelling A of the wires of toCircuit f is left unchanged by one round of the typed evaluation of table on the input labels X, then Ev on the garbled function of table and the words of X returns the labels A of the output wires.

Correctness #

Correctness: decoding the evaluation of an encoded input gives the circuit's output, for every hash family.