Documentation

CslibFrontier.Crypto.Primitives.Garbling.Rerandomizable

Rerandomizable garbling schemes #

A rerandomizable garbling scheme (RGS), adapting Acharya, Hazay, Kolesnikov and Prabhakaran [AcharyaHazayKolesnikovPrabhakaran2024, Definition 3] (full version, ePrint 2024/383), is a projective garbling scheme with an extra algorithm rerand that takes a garbled circuit gc and returns a fresh-looking garbled circuit gc' together with one label permutation per input wire. Applying the permutations to the input labels of gc gives the input labels of gc', so an evaluator holding an encoding for gc can move to gc' without the garbler. All randomness is explicit: garble f r garbles f with coins r, returning a Garbled record (the circuit and its label pairs), and rerand gc r' rerandomizes with coins r', returning a Rerandomized record (the new circuit and its wire permutations). Decoding is folded into evaluate. Unlike Cslib.Crypto.Garbling.Scheme (CslibFrontier/Crypto/Primitives/Garbling/Scheme.lean), which is typed by List Bool, indexed by a security parameter, and intentionally omits projective structure, RerandomizableGarbling exposes per-wire label pairs so per-wire permutations can act directly on encodings.

Randomness composition (RandomnessComposition) says that a rerandomized garbling (rerandGarbled) is itself an honest garbling, with coins explainGb r r' computed from the garbling coins and the rerandomization coins, and that two rerandomizations (rerandTwice) compose into one with coins explainRerand r₁ r₂. The garbling half adapts the randomness-composition property of Definition 3, while explainRerand is an explicit two-step rerandomization-composition axiom of this formalization. With garble_explainGb, correctness of fresh garblings implies correctness of rerandomized ones (rerandCorrect_of_correct).

Two security notions are compared. Each has a view record handed to the distinguisher, a real and an ideal sampler of that view, the two experiments running a distinguisher on the sampled view, and an advantage; the projective encoding is encode, and permEncoding and permInput apply wire permutations.

This development proves two generic single-instance reductions relating sampled-coin explainability to rerandomization privacy under explicit algebraic invertibility hypotheses (RandomnessComposition.Invertible). The advantage of any distinguisher against explainable garbling equals the rerandomization-privacy advantage of explainGbReduction (explainGbAdvantage_eq). The advantage against explainable rerandomization is at most the sum of the rerandomization-privacy advantages of two reductions (explainRerandAdvantage_le), through one intermediate hybrid: the right reduction run on the ideal rerandomization-privacy view, which has the same law as the left reduction on that view. Running the right reduction on the real view is the ideal explainable-rerandomization experiment, by definition (rerandRealExperiment_explainRerandReductionRight). Both reductions use the inverse data of RandomnessComposition.Invertible (introduced for this development): the garbling explanation is a bijection in the garbling coins with an explicit inverse, the rerandomization explanation is a bijection in its first argument, and some rerandomization coins undo each rerandomization step. The rerandomization bound also assumes that the label action respects composition of permutations.

When the explanation maps are bijective in their second argument, rerandomization privacy and the stronger fixed-coin explainability variants (explainGbFixedRealView, explainRerandFixedRealView, which hold the base coins r and r₁ fixed rather than sampling them) hold with zero error, as equalities of view laws (eval_explainGbFixedRealView, eval_explainRerandFixedRealView, eval_rerandRealView).

Scope #

In explainGbRealView/explainGbIdealView and explainRerandRealView/explainRerandIdealView, the garbling and rerandomization coins are sampled uniformly (matching the sampled-coin experiment structure of Definition 9 in ePrint 2024/383, p. 33): each samples the base coins and runs its fixed-coin variant explainGbFixed*View or explainRerandFixed*View, which appear in the zero-error bijectivity lemmas. On the hypothesis side, rerandRealView samples r uniformly whereas Definition 3 quantifies over fixed r; because privacy at every fixed r implies privacy for uniformly sampled r, the sampled-r assumption used by the reductions is weaker. The generic reductions explainGbAdvantage_eq and explainRerandAdvantage_le, together with the two-step composition field explainRerand and the inverse structure RandomnessComposition.Invertible, are results and hypotheses of this development rather than transcriptions of a numbered theorem in the paper. All statements are single-instance: the function, input and distinguisher are fixed, and running time is not tracked, so no asymptotic security or efficiency of the reductions is claimed.

Main definitions #

Main results #

References #

The output of garbling: a garbled circuit and, for each of the m input wires, its pair of labels for the bits false and true.

  • circuit : GC

    The garbled circuit.

  • labels : Fin m → Label × Label

    The labels of each input wire, for the bits false and true.

theorem Cslib.Crypto.Garbling.RerandomizableGarbling.Garbled.ext {GC Label : Type} {m : ℕ} {x y : Garbled GC Label m} (circuit : x.circuit = y.circuit) (labels : x.labels = y.labels) :
x = y

The output of rerandomization: a rerandomized circuit and one label permutation per input wire, carrying the labels of the old circuit to those of the new one.

  • circuit : GC

    The rerandomized circuit.

  • perm : Fin m → Perm

    The label permutation of each input wire.

theorem Cslib.Crypto.Garbling.RerandomizableGarbling.Rerandomized.ext {GC Perm : Type} {m : ℕ} {x y : Rerandomized GC Perm m} (circuit : x.circuit = y.circuit) (perm : x.perm = y.perm) :
x = y

A projective rerandomizable garbling scheme for functions F on m input bits, with explicit garbling coins Coins and rerandomization coins RerandCoins. garble f r returns a garbled circuit and one pair of labels per input wire (for bits false and true); rerand gc r' returns a rerandomized circuit and one label permutation per input wire, acting on labels by act; comp p q is meant as the permutation p followed by q, a property that is not part of the structure and is assumed where needed (explainRerandAdvantage_le).

Encodings and correctness #

def Cslib.Crypto.Garbling.RerandomizableGarbling.encode {F : Type} {m : ℕ} (G : RerandomizableGarbling F m) (e : Fin m → G.Label × G.Label) (x : Fin m → Bool) :
Fin m → G.Label

The projective input encoding: the label of bit x i on each wire i.

Apply one permutation per wire to both labels of an encoding table.

def Cslib.Crypto.Garbling.RerandomizableGarbling.permInput {F : Type} {m : ℕ} (G : RerandomizableGarbling F m) (π : Fin m → G.Perm) (X : Fin m → G.Label) :
Fin m → G.Label

Apply one permutation per wire to an encoded input.

theorem Cslib.Crypto.Garbling.RerandomizableGarbling.encode_permEncoding {F : Type} {m : ℕ} (G : RerandomizableGarbling F m) (π : Fin m → G.Perm) (e : Fin m → G.Label × G.Label) (x : Fin m → Bool) :
G.encode (G.permEncoding π e) x = G.permInput π (G.encode e x)

Encoding commutes with permuting the labels.

Evaluate a garbling on input x: run its circuit on the encoding of x.

Rerandomize a garbling with coins r': the rerandomized circuit, with the labels permuted by the rerandomization's wire permutations.

Rerandomize gc with coins r₁ and then r₂: the final circuit, with each wire's two permutations composed.

Correctness of fresh garblings: evaluating garble f r on x gives f x.

Correctness of rerandomized garblings: evaluating the rerandomization of garble f r on x gives f x.

Randomness composition. A rerandomization of garble f r with coins r', with its permuted encoding table, is the honest garbling of f with coins explainGb r r'; and rerandomizing garble f r with coins r₁ and then r₂ gives the rerandomization with coins explainRerand r₁ r₂, with the composed permutations.

Under randomness composition, correctness of fresh garblings gives correctness of rerandomized ones.

Inverse data for randomness composition, used by the reductions from rerandomization privacy to explainability: unexplainGb · r' inverts explainGb · r', explainRerand is a bijection in its first argument, and the coins invRerand r' undo a rerandomization step with coins r', on the circuit and on every label.

Views #

What a rerandomization-privacy distinguisher sees.

  • coins : G.Coins

    The coins of the base garbling.

  • circuit : G.GC

    The challenge circuit.

  • input : Fin m → G.Label

    The evaluator's input labels for the challenge circuit.

What an explainable-garbling distinguisher sees.

  • input : Fin m → G.Label

    The evaluator's input labels for the base circuit.

  • base : G.GC

    The base circuit.

  • candidate : G.GC

    The challenge circuit.

  • coins : G.Coins

    The garbling coins claimed to produce the challenge circuit.

What an explainable-rerandomization distinguisher sees.

  • base : G.GC

    The base circuit.

  • input : Fin m → G.Label

    The evaluator's input labels for the first rerandomization.

  • rerandomized : G.GC

    The first rerandomization of the base circuit.

  • candidate : G.GC

    The challenge circuit.

  • coins : G.RerandCoins

    The rerandomization coins claimed to carry the base circuit to the challenge circuit.

View samplers #

Rerandomization privacy, real view: garble with uniform coins r, rerandomize with uniform coins, and show r, the rerandomized circuit and the permuted encoding of x.

Rerandomization privacy, ideal view: uniform coins r together with an independent fresh garbling and the encoding of x.

Explainable garbling with fixed garbling coins r, real view: the encoding of x and the circuit of garble f r, a rerandomization of that circuit with uniform coins r', and the explanation explainGb r r'.

Explainable garbling with fixed garbling coins r, ideal view: the challenge is a fresh garbled circuit and its coins.

Explainable garbling, real view (sampled garbling coins).

Explainable garbling, ideal view (sampled garbling coins).

Explainable rerandomization with fixed coins r and r₁, real view: garble with coins r, rerandomize with r₁ and then uniform r₂, and show the base circuit, the encoding of x for the first rerandomization, both rerandomized circuits and the explanation explainRerand r₁ r₂.

Explainable rerandomization with fixed coins r and r₁, ideal view: the challenge is a direct rerandomization of the base circuit and its coins.

Explainable rerandomization, real view (sampled coins).

Explainable rerandomization, ideal view (sampled coins).

Experiments and advantages #

The real rerandomization-privacy experiment: D guesses on the real view.

The ideal rerandomization-privacy experiment: D guesses on the ideal view.

The real explainable-garbling experiment: D guesses on the real view.

The ideal explainable-garbling experiment: D guesses on the ideal view.

The real explainable-rerandomization experiment: D guesses on the real view.

The ideal explainable-rerandomization experiment: D guesses on the ideal view.

The advantage of D in telling the real rerandomization-privacy view from the ideal one.

The advantage of D in telling the real explainable-garbling view from the ideal one.

The advantage of D in telling the real explainable-rerandomization view from the ideal one.

Reductions #

The rerandomization-privacy distinguisher built from an explainable-garbling distinguisher: it shows D the challenge input labels and circuit as the base, and the circuit of garble f v.coins with those coins as the challenge.

The first rerandomization-privacy distinguisher built from an explainable-rerandomization distinguisher: it samples s, takes the base circuit garbled with coins unexplainGb v.coins s, and shows D that base, the challenge input labels and circuit, the base's rerandomization with coins s, and s.

The second rerandomization-privacy distinguisher built from an explainable-rerandomization distinguisher: it samples s, takes the base circuit garbled with coins v.coins, and shows D that base, the challenge input labels and circuit, the base's rerandomization with coins s, and s.

Permutation lemmas #

theorem Cslib.Crypto.Garbling.RerandomizableGarbling.permInput_comp {F : Type} {m : ℕ} {G : RerandomizableGarbling F m} (hcomp : ∀ (p q : G.Perm) (L : G.Label), G.act (G.comp p q) L = G.act q (G.act p L)) (π₁ π₂ : Fin m → G.Perm) (X : Fin m → G.Label) :
G.permInput (fun (i : Fin m) => G.comp (π₁ i) (π₂ i)) X = G.permInput π₂ (G.permInput π₁ X)

Permuting by composed permutations is permuting twice, when the action respects composition.

The permutations of the undoing rerandomization step invert those of the original step.

Reindexing uniform samples #

Explainability from rerandomization privacy #

Explainable garbling from rerandomization privacy. For every distinguisher D, the explainable-garbling advantage of D equals the rerandomization-privacy advantage of explainGbReduction f D.

@[simp]

Running the right reduction on the real rerandomization-privacy view is the ideal explainable-rerandomization experiment.

theorem Cslib.Crypto.Garbling.RerandomizableGarbling.explainRerandAdvantage_le {F : Type} {m : ℕ} {G : RerandomizableGarbling F m} (rc : G.RandomnessComposition) (hinv : rc.Invertible) (hcomp : ∀ (p q : G.Perm) (L : G.Label), G.act (G.comp p q) L = G.act q (G.act p L)) (f : F) (x : Fin m → Bool) (D : G.ExplainRerandView → ProbComp Bool) :

Explainable rerandomization from rerandomization privacy. If the label action respects composition of permutations, then for every distinguisher D the explainable-rerandomization advantage of D is at most the sum of the rerandomization-privacy advantages of explainRerandReductionLeft hinv f D and explainRerandReductionRight f D. The intermediate hybrid is the right reduction on the ideal view, which equals the left reduction on the ideal view.

Zero error under bijectivity in the second argument #

If explainGb r is a bijection for every r, rerandomization privacy holds with zero error: the real and ideal views have the same law.

If explainGb r is a bijection, explainable garbling with fixed coins r holds with zero error.

If explainRerand r₁ is a bijection, explainable rerandomization with fixed coins r and r₁ holds with zero error.