Documentation

CslibFrontier.Crypto.Primitives.Garbling.Conventional

Conventional circuits as circuits #

A conventional circuit f = (n, m, q, A, B, G) of Bellare, Hoang and Rogaway [BHR12b] (ConventionalCircuit), numbers its wires from 1, reads its gates' arguments from the 1-indexed wires A g and B g, and outputs its last m wires. A valid one is a circuit ConventionalCircuit.toCircuit f : Circuit (fullSignature 2 Bool) n m over the full binary basis: gate g applies the truth table G g to the 0-indexed wires A g - 1 and B g - 1, and output o is wire n + q - m + o. It is decoded with Circuit.ofCode from this gate list (ConventionalCircuit.code_toCircuit), so the garbling and privacy results stated for Circuit apply to conventional circuits. Both semantics agree (ConventionalCircuit.eval_toCircuit): on an n-bit input the circuit's outputs are ConventionalCircuit.evalCirc.

Main definitions #

Main results #

Since toCircuit is not exposed, its gates, their binary operations and argument wires, and its output wires are read through interface lemmas (ConventionalCircuit.size_toCircuit, ConventionalCircuit.lines_toCircuit, ConventionalCircuit.arity_topology_toCircuit, ConventionalCircuit.ofFn_toNat_wires_toCircuit, ConventionalCircuit.wires_toCircuit_zero, ConventionalCircuit.wires_toCircuit_one, ConventionalCircuit.toNat_outputs_toCircuit).

References #

The gates of a conventional circuit as circuit code over the full binary basis: gate i applies its truth table to the 0-indexed wires A i - 1 and B i - 1.

The output wires of a conventional circuit as circuit code: output o is the 0-indexed wire n + q - m + o, one of the last m wires.

A valid conventional circuit as a circuit over the full binary basis, decoded from its gate list.

The code of toCircuit f is the gate list of f with its last m wires as outputs.

The argument wires of gate g of toCircuit f are the 0-indexed wires A g - 1 and B g - 1.

theorem Cslib.Crypto.Garbling.ConventionalCircuit.wires_toCircuit_zero (f : ValidCircuit) (g : Fin (toCircuit f).size) (hlt : (↑f).A (Fin.cast ⋯ g) - 1 < (↑f).n + (toCircuit f).size) :
(toCircuit f).topology.wires g (Fin.cast ⋯ 0) = Circuits.Wire.ofNat ((↑f).A (Fin.cast ⋯ g) - 1) hlt

The first argument wire of gate g of toCircuit f is the 0-indexed wire A g - 1.

theorem Cslib.Crypto.Garbling.ConventionalCircuit.wires_toCircuit_one (f : ValidCircuit) (g : Fin (toCircuit f).size) (hlt : (↑f).B (Fin.cast ⋯ g) - 1 < (↑f).n + (toCircuit f).size) :
(toCircuit f).topology.wires g (Fin.cast ⋯ 1) = Circuits.Wire.ofNat ((↑f).B (Fin.cast ⋯ g) - 1) hlt

The second argument wire of gate g of toCircuit f is the 0-indexed wire B g - 1.

theorem Cslib.Crypto.Garbling.ConventionalCircuit.lines_toCircuit (f : ValidCircuit) (g : Fin (toCircuit f).size) :
(toCircuit f).program.lines g = { op := Circuits.FullOp.fn fun (a : Fin 2 → Bool) => (↑f).G (Fin.cast ⋯ g) (a 0) (a 1), wires := ![Circuits.Wire.ofNat ((↑f).A (Fin.cast ⋯ g) - 1) ⋯, Circuits.Wire.ofNat ((↑f).B (Fin.cast ⋯ g) - 1) ⋯] }

The lines of toCircuit f: gate g applies the truth table G g to the 0-indexed wires A g - 1 and B g - 1.

theorem Cslib.Crypto.Garbling.ConventionalCircuit.toNat_outputs_toCircuit (f : ValidCircuit) (o : Fin (↑f).m) :
((toCircuit f).outputs o).toNat = (↑f).n + (↑f).q - (↑f).m + ↑o

Output o of toCircuit f is the 0-indexed wire n + q - m + o.

The value of wire w of toCircuit f on an n-bit input is wire w of the conventional evaluation, numbered from 0.

The translation computes the conventional semantics. On every n-bit input, the outputs of toCircuit f are evalCirc f.