Documentation

CslibFrontier.Crypto.Primitives.Garbling.BinaryToOneHot

Garbled binary-to-one-hot conversion #

The binary-to-one-hot conversion bin-to-hot of Heath [Hea24] (§4, pp. 13–14; the construction is in §4.1, p. 14). The lookup-table garbling scheme logrow of Heath, Kolesnikov and Ng [HKN24] uses one-hot garbling through the interface of its Figure 1 (p. 10). Wire labels live in an additive group L of characteristic two (over GF(2)^λ, addition is XOR) with a Free-XOR global offset Δ [KS08]: the label of bit b on a wire with zero-label X is X + bitOffset Δ b. From one label on each of n + 1 input wires and n ciphertexts of one label each, the evaluator obtains Free-XOR labels of the one-hot vector of its input, a vector of 2 ^ (n + 1) bits.

One-hot garbling is due to Heath and Kolesnikov [HK21]. Their conversion (§4.1, p. 10 of the ePrint full version) expands a GGM tree and sends two encrypted values per level and a final correction, 2(n - 1) + 1 ciphertexts for n input bits. The single-ciphertext step used here is Heath's, which [Hea24], §4, notes halves that material to (n - 1) κ bits. With the paper's n equal to n + 1 here, this is the (n - 1) κ term of the logrow material size ([HKN24], Theorem 1, p. 19, and the cost breakdown on p. 20). Figure 1 of [HKN24] instead states (2n - 1) κ bits for the one-hot interface, the count of [HK21]; the gadget here matches Theorem 1, not Figure 1.

Positions of the one-hot vector over t + 1 input bits are bit vectors j : Fin (t + 1) → Bool; the position Fin.snoc j c of the next vector extends j by the next input bit c. Over one input bit, the zero-labels are X at position true and X + Δ at position false, and the evaluator holding the label X + bitOffset Δ x₀ uses it at both positions; no ciphertext is needed. A doubling step (garbleStep) hashes each zero-label G j to y j, keeps G j + y j at position Fin.snoc j false and y j at Fin.snoc j true, and sends the ciphertext b + ∑ j, y j, where b is the zero-label of the new input bit. The evaluator (evalStep) knows the hot position x but not the zero-label at x. It recomputes y j at every other position, and recovers y x + bitOffset Δ c from its label b + bitOffset Δ c of the new bit and the ciphertext.

In the notation of [Hea24], §4.1, a step scales the one-hot vector h of the bits so far by the new bit (scale₁, which needs no material), joins the sum s of the scaled vector h′ with the new bit, and returns (h′ + h) ⊔ h′. Here y j is the zero-label of h′ at position j, the ciphertext is that one join, and G j + y j and y j are the zero-labels of the halves h′ + h and h′. [Hea24] recurses on x[1..] and joins x[0]; this file appends the new bit last.

Hashes are a tweakable function H : L → T → L; step t hashes position j with tweak tw t j. Correctness (evaluate_garble) holds for every H, tw, Δ, choice of zero-labels and input. In logrow the evaluator's index is the input masked by the garbler's permutation bits, which it reads from its labels; this file takes that index as given. Combined with the truth-table product, the evaluator obtains Free-XOR labels of the row of any public table at its index (tableMul_evaluate_garble). The per-instance CCR reduction step for obliviousness is in CslibFrontier.Crypto.Primitives.Garbling.BinaryToOneHotObliviousness.

Main definitions #

Main results #

References #

def Cslib.Crypto.Garbling.BinaryToOneHot.garbleStep {L : Type} [AddCommGroup L] {t : ℕ} (h : (Fin (t + 1) → Bool) → L → L) (b : L) (G : (Fin (t + 1) → Bool) → L) :
((Fin (t + 2) → Bool) → L) × L

One doubling step of the garbler, from t + 1 to t + 2 input bits. h j hashes the zero-label of position j, b is the zero-label of the new input bit and G the current zero-labels. Returns the new zero-labels and the step's ciphertext b + ∑ j, h j (G j).

def Cslib.Crypto.Garbling.BinaryToOneHot.evalStep {L : Type} [AddCommGroup L] {t : ℕ} (h : (Fin (t + 1) → Bool) → L → L) (x : Fin (t + 1) → Bool) (a ct : L) (E : (Fin (t + 1) → Bool) → L) :
(Fin (t + 2) → Bool) → L

One doubling step of the evaluator, who knows the hot position x, holds the label a of the new input bit and the current labels E, and receives the ciphertext ct. It hashes every label but the one at x, and recovers the hash at x, masked by the new bit, from a and ct.

def Cslib.Crypto.Garbling.BinaryToOneHot.hashAt {L T : Type} (H : L → T → L) (tw : (t : ℕ) → (Fin (t + 1) → Bool) → T) (t : ℕ) :
(Fin (t + 1) → Bool) → L → L

The hash of doubling step t: position j is hashed with tweak tw t j.

def Cslib.Crypto.Garbling.BinaryToOneHot.garble {L T : Type} [AddCommGroup L] (H : L → T → L) (tw : (t : ℕ) → (Fin (t + 1) → Bool) → T) (Δ : L) (n : ℕ) :
(Fin (n + 1) → L) → ((Fin (n + 1) → Bool) → L) × (Fin n → L)

The garbler with global offset Δ, from the zero-labels X of n + 1 input wires: the zero-labels of the one-hot vector and one ciphertext for each of the n doubling steps.

def Cslib.Crypto.Garbling.BinaryToOneHot.evaluate {L T : Type} [AddCommGroup L] (H : L → T → L) (tw : (t : ℕ) → (Fin (t + 1) → Bool) → T) (n : ℕ) :
(Fin (n + 1) → Bool) → (Fin (n + 1) → L) → (Fin n → L) → (Fin (n + 1) → Bool) → L

The evaluator, from the index x, one label A on each input wire and the ciphertexts ct: its labels of the one-hot vector.

theorem Cslib.Crypto.Garbling.BinaryToOneHot.evalStep_garbleStep {L : Type} [AddCommGroup L] [Module (ZMod 2) L] {t : ℕ} (h : (Fin (t + 1) → Bool) → L → L) (Δ b : L) (G : (Fin (t + 1) → Bool) → L) (x : Fin (t + 1) → Bool) (c : Bool) :
(evalStep h x (b + bitOffset Δ c) (garbleStep h b G).2 fun (j : Fin (t + 1) → Bool) => G j + bitOffset Δ (oneHot x j)) = fun (j : Fin (t + 2) → Bool) => (garbleStep h b G).1 j + bitOffset Δ (oneHot (Fin.snoc x c) j)

One doubling step is correct: if the evaluator holds the labels of the one-hot vector of x with zero-labels G and the label of bit c of the new input wire, it obtains the labels of the one-hot vector of Fin.snoc x c with the new zero-labels.

theorem Cslib.Crypto.Garbling.BinaryToOneHot.evaluate_garble {L T : Type} [AddCommGroup L] [Module (ZMod 2) L] (H : L → T → L) (tw : (t : ℕ) → (Fin (t + 1) → Bool) → T) (Δ : L) (n : ℕ) (X : Fin (n + 1) → L) (x : Fin (n + 1) → Bool) :
evaluate H tw n x (fun (t : Fin (n + 1)) => X t + bitOffset Δ (x t)) (garble H tw Δ n X).2 = fun (j : Fin (n + 1) → Bool) => (garble H tw Δ n X).1 j + bitOffset Δ (oneHot x j)

Correctness: on the labels of its input bits and the garbled ciphertexts, the evaluator obtains the labels of the one-hot vector of its input, for every hash, tweaks, offset and zero-labels.

theorem Cslib.Crypto.Garbling.BinaryToOneHot.tableMul_evaluate_garble {L T : Type} [AddCommGroup L] [Module (ZMod 2) L] {κ : Type} (H : L → T → L) (tw : (t : ℕ) → (Fin (t + 1) → Bool) → T) (Δ : L) (n : ℕ) (X : Fin (n + 1) → L) (x : Fin (n + 1) → Bool) (Tab : (Fin (n + 1) → Bool) → κ → Bool) :
tableMul Tab (evaluate H tw n x (fun (t : Fin (n + 1)) => X t + bitOffset Δ (x t)) (garble H tw Δ n X).2) = fun (u : κ) => tableMul Tab (garble H tw Δ n X).1 u + bitOffset Δ (Tab x u)

Labels of a selected row. With the labels the evaluator obtains, the product with any public table T gives, at each output u, the label of bit T x u with zero-label tableMul T G u, where G are the garbler's one-hot zero-labels.