Documentation

CslibFrontier.Crypto.Primitives.Garbling.PointPermute

Point-and-permute garbling as a garbling scheme #

The point-and-permute garbling of CslibFrontier.Crypto.Primitives.Garbling.Basic as a garbling scheme in the sense of Bellare, Hoang and Rogaway [BHR12b] (Garbling.Scheme), over valid conventional circuits (ValidCircuit): PointPermute.scheme family, whose masks are keyed by a word family family. This module gives the definitions and their correctness only. Polynomial running times are proved in CslibFrontier.Crypto.Primitives.Garbling.PointPermute.Efficient. Privacy (prv.sim with the topology as side information) for every pseudorandom family is PseudorandomFunction.prvSim_pointPermute in CslibFrontier.Crypto.Primitives.Garbling.PointPermute.Privacy.

The scheme is a variant of Garble1 of [BHR12b] (§5.1, Fig. 7) with the PRF-based dual-key cipher of §5.5, not Garble1 itself. In Garble1 the type of an output wire's token is its semantics and d is empty, and both keys of a row are used at the one tweak g ‖ a ‖ b. Here output wires are permuted too, d holds their permutation bits, and each argument slot of a row has its own tweak.

At security parameter k, a wire key has k + 1 bits and a label is the (k + 2)-bit word of a key followed by its colour bit. The masks come from the keyed function PRF.label (PRF.atLevel family (k + 1)), which sends a key and a k-bit tweak to a label (PointPermute.labelWord on words). Argument slot a of row i of gate g has the tweak 8 g + 2 i + a, reduced modulo 2 ^ k (PointPermute.tweak); rows are numbered by the colours of the two arguments, the first argument most significant. Correctness holds for every family and every tweak.

The coins are the n + q permutation bits followed by two keys for each wire, colour 0 first. 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, and its four rows. So F carries the topology, which the evaluator Ev(F, X) reads, and its length depends only on k and (n, m, q), as the length condition requires. The encoding information e lists the two labels of each input wire, for bit 0 and bit 1; the decoding information d lists the permutation bits of the m output wires. De(d, Y) reads the colour bit of each of the m labels of Y and adds the decoding bit; it fails only when |Y| is not a multiple of m.

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

Main definitions #

Main results #

References #

Words #

The tweak of argument slot a of row i of gate g at parameter k: the k low bits of 8 g + 2 i + a, least significant first.

The keyed function on words at parameter k: the label of the key word key at the tweak word t is the first k + 1 bits of family key (0 ‖ t), padded with false, followed by the first bit of family key (1 ‖ t). On a (k + 1)-bit key and a k-bit tweak it is the label of PRF.label (PRF.atLevel family (k + 1)) (labelWord_ofFn).

The permutation bit of wire v, numbered from 0: bit v of the coins.

def Cslib.Crypto.Garbling.PointPermute.keyOf (k wires : ℕ) (coins : List Bool) (v : ℕ) (c : Bool) :

The key of colour c of wire v among wires wires: key number 2 v + c of k + 1 bits, after the wires permutation bits.

def Cslib.Crypto.Garbling.PointPermute.labelOf (k wires : ℕ) (coins : List Bool) (v : ℕ) (c : Bool) :

The label of colour c of wire v: its key followed by c.

The bit length of the wire numbers of a circuit with n inputs and q gates.

def Cslib.Crypto.Garbling.PointPermute.rowWord (family : List Bool → List Bool → List Bool) (k : ℕ) (f : ConventionalCircuit) (coins : List Bool) (g : Fin f.q) (i : ℕ) :

Row i of gate g of the garbling of f at parameter k with coins coins: the label of the gate's output for the bits that the row's colours encode, masked by the keyed function at the two argument keys of those colours.

@[reducible, inline]

The header (k, n, m, q) of a garbled function, four unary numbers.

@[reducible, inline]

A garbled function: its header framed, then its body.

The garbled function of f: the header (k, n, m, q), then for each gate its argument wires as w-bit numbers and its four rows.

The encoding information of f: for each input wire, the labels encoding 0 and 1; label j encodes bit j mod 2 of input j / 2.

The decoding information of f: the permutation bits of its last m wires.

def Cslib.Crypto.Garbling.PointPermute.evalGate (family : List Bool → List Bool → List Bool) (k w : ℕ) (body : List Bool) (labels : List (List Bool)) (g : ℕ) :

One gate of Ev: read the gate's argument wires and their labels, select the row named by their colours, and remove the masks with their keys.

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.

De(d, Y): when Y splits into |d| labels of equal width, output the colour bit of each plus its decoding bit; otherwise fail.

Point-and-permute garbling as a garbling scheme over valid conventional circuits, with masks keyed by family.

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

The typed garbling #

theorem Cslib.Crypto.Garbling.PointPermute.labelWord_ofFn (family : List Bool → List Bool → List Bool) (k : ℕ) (key : BitString (k + 1)) (t : BitString k) :
labelWord family k (List.ofFn key) (List.ofFn t) = labelBits (PRF.label (PRF.atLevel family (k + 1)) key t)

On a (k + 1)-bit key and a k-bit tweak, labelWord is the label of PRF.label (PRF.atLevel family (k + 1)).

The row of gate g whose colours are the binary digits of i, the first argument most significant.

The number of a row: its colours read in binary, the first argument most significant.

The tweak of an argument slot at parameter k: slot a of row ρ of gate g gets tweak k g (rowIndex ρ) a.

The keys read from the coins: the key of colour c of wire w.

The permutation bits read from the coins.

The body of a garbled function over the topology τ: for each gate the numbers of its argument wires, from 1, as w-bit numbers, and its rows in the order of rowOf.

The garbled function of a table over the topology τ at parameter k: the header (k, n, m, s), then for each gate the numbers of its argument wires, from 1, as w-bit numbers, and its rows in the order of rowOf.

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

The garbler computes the typed garbling #

theorem Cslib.Crypto.Garbling.PointPermute.ofFn_keyFn {n s : ℕ} (k : ℕ) (coins : List Bool) (w : Circuits.Wire n s) (c : Bool) :
List.ofFn (keyFn k coins (w, c)) = keyOf k (n + s) coins w.toNat c

The bits of a key read from the coins are keyOf.

theorem Cslib.Crypto.Garbling.PointPermute.labelBits_keyFn {n s : ℕ} (k : ℕ) (coins : List Bool) (w : Circuits.Wire n s) (c : Bool) :
labelBits (keyFn k coins (w, c), c) = labelOf k (n + s) coins w.toNat c

The word of a label read from the coins is labelOf.

@[simp]

A tweak word has k bits.

theorem Cslib.Crypto.Garbling.PointPermute.rowIndex_testBit {i : ℕ} (hi : i < 4) :
(rowIndex fun (a : Fin 2) => i.testBit (2 - 1 - ↑a)) = i

The colours of row i < 4 of a binary gate read back as i.

Gate g of the garbled function of a table T over toCircuit f, as a word: the numbers of its argument wires A g and B g and its four rows.

The garbler computes the typed garbling. At parameter k, Gb on any coins writes the words of the typed point-and-permute garbling garbleWith of toCircuit f, with the keyed function PRF.label (PRF.atLevel family (k + 1)), the tweaks slotTweak and the keys and permutation bits read from the coins.

Encoding, evaluation and decoding on words #

theorem Cslib.Crypto.Garbling.PointPermute.projectiveEncode_labelBits {n k : ℕ} (e : Fin n → Bool → BitString (k + 1) × Bool) {x : List Bool} (hx : x.length = n) :
projectiveEncode (List.ofFn fun (j : Fin (2 * n)) => labelBits (e ⟨↑j / 2, ⋯⟩ ((↑j).testBit 0))).flatten x = (List.ofFn fun (i : Fin n) => labelBits (e i (BitString.ofList n x i))).flatten

En on the words of a typed input encoding writes the label of each bit.

theorem Cslib.Crypto.Garbling.PointPermute.decodeWord_ofFn {m k : ℕ} (d : Fin m → Bool) (Y : Fin m → BitString (k + 1) × Bool) :

De on the decoding bits and output labels of a typed garbling decodes them.

Evaluation #

theorem Cslib.Crypto.Garbling.PointPermute.rowIndex_of_eq_two {r : ℕ} (hr : r = 2) (colours : Fin r → Bool) :
rowIndex colours = (if colours ⟨0, ⋯⟩ = true then 2 else 0) + if colours ⟨1, ⋯⟩ = true then 1 else 0

The number of a row of a binary gate.

theorem Cslib.Crypto.Garbling.PointPermute.testBit_rowIndex_of_eq_two {r : ℕ} (hr : r = 2) (colours : Fin r → Bool) :
(fun (a : Fin r) => (rowIndex colours).testBit (r - 1 - ↑a)) = colours

The row of a binary gate named by the number of its colours is the row of those colours.

The argument wires of gate g of toCircuit f, one at a time: A g - 1, then B g - 1.

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.

Validity #

@[simp]
theorem Cslib.Crypto.Garbling.PointPermute.length_labelOf (k wires : ℕ) (coins : List Bool) (v : ℕ) (c : Bool) :
(labelOf k wires coins v c).length = k + 2

A label read from the coins has k + 2 bits.

@[simp]
theorem Cslib.Crypto.Garbling.PointPermute.length_labelWord (family : List Bool → List Bool → List Bool) (k : ℕ) (key t : List Bool) :
(labelWord family k key t).length = k + 2

A label of the keyed function has k + 2 bits.

@[simp]
theorem Cslib.Crypto.Garbling.PointPermute.length_rowWord (family : List Bool → List Bool → List Bool) (k : ℕ) (f : ConventionalCircuit) (coins : List Bool) (g : Fin f.q) (i : ℕ) :
(rowWord family k f coins g i).length = k + 2

A row has k + 2 bits.

theorem Cslib.Crypto.Garbling.PointPermute.length_fnWord (family : List Bool → List Bool → List Bool) (k : ℕ) (f : ConventionalCircuit) (coins : List Bool) :
(fnWord family k f coins).length = 2 * (encHeader (k, f.n, f.m, f.q)).length + 1 + f.q * (2 * wireWidth f.n f.q + 4 * (k + 2))

The garbled function has a length fixed by k and the shape (n, m, q).

The encoding information has 2 n labels.

Point-and-permute garbling is a valid garbling scheme: the length condition, non-degeneracy and correctness of Scheme.IsValid, for every family.