Documentation

CslibFrontier.Crypto.Primitives.Garbling.BMR16

The BMR16 garbling scheme for mixed-modulus circuits #

The garbling scheme of Ball, Malkin and Rosulek [BallMalkinRosulek2016, Figure 1] for mixed-modulus circuits (MixedModulus.MixedModulusCircuit), its correctness, and the exact reduction identity behind its privacy for one hash, circuit, input and distinguisher. Privacy itself is not proved here: the privacy part of [BMR16] Theorem 1 needs a family of schemes, an assumption that bounds the adversary's efficiency and a certified reduction, and is tracked in #6068.

Each sort i has a secret offset Δ_i = (δ_i, 1) and each wire w of sort i a zero label W_w^0; the label of value x ∈ ℤ_{μ i} is W_w^x = W_w^0 + x Δ_i, whose colour is the colour of W_w^0 plus x.

The input encoding is (W^0, Δ), mapping x to W^0 + x Δ; the decoding information is the colour of the zero label of each output wire, so an output label decodes to its colour minus that colour. [BMR16] also sends output hashes, which add authenticity; they play no role in privacy and are not modelled here. Mult_c is allowed for every c, not only for c coprime to the modulus.

Correctness (Garbled.run_ofKeys) holds for every hash, tweak assignment, offsets and zero labels.

Privacy is simulation-based with the circuit's shape as side information: the simulator (simulate) samples one uniform label per input wire and uniform ciphertexts, and sets the decoding information so that the evaluated output labels decode to the output. It is polymorphic in the projection payload, so it cannot read the projection functions (a parametricity argument about its definition, not a theorem stated here), and it does not take the input. The reduction identity advantage_realGame_simGame shows that the advantage of any distinguisher D between the real and the simulated view is equal to the mixed-modulus CCR advantage (MixedModulus.ccrAdvantage) of an explicit reduction reduction, provided the tweaks of the gates are distinct. The reduction samples the active labels of the input wires, evaluates the circuit gate by gate, and asks the oracle, at projection gate g reading a wire of value v and active label A, the query (g, A, x - v, φ x - φ v) for each x ≠ v: against the real oracle the answer is H(g, W^x) + (φ x - φ v) Δ_j, which yields the real ciphertexts and active labels, and against a random function the ciphertexts are uniform. The reduction is legal in the sense of MixedModulus.CCRAdversary.IsLegal (reduction_isLegal): along every run it never uses multiplier 0, and its queries are determined by their tweak and multiplier. It asks several queries under one tweak, so it is not legal for the literal Definition 1 of [BMR16]; see MixedModulus. Running time is not tracked: there are no cost bounds for garbling, evaluation, the simulator or the reduction. No assumption is applied, so no privacy bound is concluded: that needs an asymptotic form of mixed-modulus circular correlation robustness against efficient adversaries and a PPT certificate for a family version of the reduction (#6068).

Main definitions #

Main results #

References #

Garbled tables and row reduction #

def Cslib.Crypto.Garbling.BMR16.Tables {ι : Type} {μ : ι → ℕ} (ℓ : ι → ℕ) {P : ι → ι → Type} {Γ Θ : List ι} :

The garbled tables of a circuit: for a projection gate from sort i to sort j, one label of sort j for each non-zero colour of its input; addition and multiplication gates have none.

Instances For
    @[instance_reducible]
    instance Cslib.Crypto.Garbling.BMR16.Tables.instFintype {ι : Type} {μ ℓ : ι → ℕ} {P : ι → ι → Type} [∀ (i : ι), NeZero (μ i)] {Γ Θ : List ι} (C : MixedModulus.MixedModulusCircuit μ P Γ Θ) :
    Fintype (Tables ℓ C)
    instance Cslib.Crypto.Garbling.BMR16.Tables.instNonempty {ι : Type} {μ ℓ : ι → ℕ} {P : ι → ι → Type} {Γ Θ : List ι} (C : MixedModulus.MixedModulusCircuit μ P Γ Θ) :
    def Cslib.Crypto.Garbling.BMR16.row {m : ℕ} {L : Type} [Zero L] (R : { c : ZMod m // c ≠ 0 } → L) (c : ZMod m) :
    L

    The row of colour c of a projection table; the row of colour 0 is zero.

    def Cslib.Crypto.Garbling.BMR16.reduceRows {m : ℕ} {L : Type} [AddCommGroup L] (u : ZMod m → L) (τ : ZMod m) :
    ({ c : ZMod m // c ≠ 0 } → L) × L

    Row reduction. Given the value u x to be sent in the row of input value x, relative to a zero label of colour τ, the rows u (c - τ) - u (-τ) of the non-zero colours c and the label -u (-τ) added to every row, which makes the row of colour 0 zero.

    theorem Cslib.Crypto.Garbling.BMR16.row_reduceRows {m : ℕ} {L : Type} [AddCommGroup L] (u : ZMod m → L) (τ v : ZMod m) (h w : L) (huv : u v = h + w) :
    row (reduceRows u τ).1 (τ + v) - h = (reduceRows u τ).2 + w

    Reading the row of the colour of the label of value v and subtracting the part h of u v gives the reduced label plus the rest of u v.

    theorem Cslib.Crypto.Garbling.BMR16.reduceRows_sub_const {m : ℕ} {L : Type} [AddCommGroup L] (u : ZMod m → L) (z : L) (τ : ZMod m) :
    reduceRows (fun (x : ZMod m) => u x - z) τ = ((reduceRows u τ).1, (reduceRows u τ).2 + z)

    Shifting every value by a constant z keeps the rows and shifts the reduced label by z.

    Garbling, evaluation and decoding #

    def Cslib.Crypto.Garbling.BMR16.garbleWith {ι T : Type} {μ ℓ : ι → ℕ} (H : MixedModulus.MixedModulusHash T μ ℓ) (tw : ℕ → T) (δ : (i : ι) → Fin (ℓ i) → ZMod (μ i)) {Γ Θ : List ι} :

    Garble a circuit, from its gate number k on, given the hash H, the tweak tw k of gate k, the offsets δ and the zero labels E of the wires so far: the garbled tables and the zero labels of the output wires.

    def Cslib.Crypto.Garbling.BMR16.evaluate {ι T : Type} {μ ℓ : ι → ℕ} {P : ι → ι → Type} (H : MixedModulus.MixedModulusHash T μ ℓ) (tw : ℕ → T) {Γ Θ : List ι} :

    Evaluate garbled tables, from gate number k on, given the active labels A of the wires so far: the active labels of the output wires.

    def Cslib.Crypto.Garbling.BMR16.encode {ι : Type} {μ ℓ : ι → ℕ} (δ : (i : ι) → Fin (ℓ i) → ZMod (μ i)) {Γ : List ι} (E : MixedModulus.Env (MixedModulus.Label μ ℓ) Γ) (V : MixedModulus.Env (MixedModulus.Residue μ) Γ) :

    Encode residues V with zero labels E and offsets δ: E + V Δ.

    Decode output labels Y with decoding information d: each colour minus its entry of d. With d the colours of the output zero labels this recovers the output values.

    The colours of a list of labels.

    structure Cslib.Crypto.Garbling.BMR16.Garbled {ι : Type} {μ : ι → ℕ} (ℓ : ι → ℕ) {P : ι → ι → Type} {Γ Θ : List ι} (C : MixedModulus.MixedModulusCircuit μ P Γ Θ) :

    A garbled circuit: its tables, its input encoding information (zero labels and offsets), and its decoding information.

    def Cslib.Crypto.Garbling.BMR16.Garbled.ofKeys {ι T : Type} {μ ℓ : ι → ℕ} {Γ Θ : List ι} (H : MixedModulus.MixedModulusHash T μ ℓ) (tw : ℕ → T) (δ : (i : ι) → Fin (ℓ i) → ZMod (μ i)) (C : MixedModulus.MixedModulusCircuit μ (MixedModulus.Projection μ) Γ Θ) (E : MixedModulus.Env (MixedModulus.Label μ ℓ) Γ) :
    Garbled ℓ C

    The garbled circuit with offsets δ and input zero labels E.

    def Cslib.Crypto.Garbling.BMR16.Garbled.encode {ι : Type} {μ ℓ : ι → ℕ} {P : ι → ι → Type} {Γ Θ : List ι} {C : MixedModulus.MixedModulusCircuit μ P Γ Θ} (G : Garbled ℓ C) (x : MixedModulus.Env (MixedModulus.Residue μ) Γ) :

    Encode an input with a garbled circuit's encoding information.

    def Cslib.Crypto.Garbling.BMR16.Garbled.run {ι T : Type} {μ ℓ : ι → ℕ} {P : ι → ι → Type} {Γ Θ : List ι} (H : MixedModulus.MixedModulusHash T μ ℓ) (tw : ℕ → T) {C : MixedModulus.MixedModulusCircuit μ P Γ Θ} (G : Garbled ℓ C) (x : MixedModulus.Env (MixedModulus.Residue μ) Γ) :

    Evaluate a garbled circuit on an encoded input and decode the result.

    noncomputable def Cslib.Crypto.Garbling.BMR16.garble {ι T : Type} {μ ℓ : ι → ℕ} {Γ Θ : List ι} [Fintype ι] [DecidableEq ι] [∀ (i : ι), NeZero (μ i)] (H : MixedModulus.MixedModulusHash T μ ℓ) (tw : ℕ → T) (C : MixedModulus.MixedModulusCircuit μ (MixedModulus.Projection μ) Γ Θ) :

    Garble a circuit with uniform offsets and input zero labels.

    Correctness #

    theorem Cslib.Crypto.Garbling.BMR16.get_encode {ι : Type} {μ ℓ : ι → ℕ} {Γ : List ι} (δ : (i : ι) → Fin (ℓ i) → ZMod (μ i)) (E : MixedModulus.Env (MixedModulus.Label μ ℓ) Γ) (V : MixedModulus.Env (MixedModulus.Residue μ) Γ) {i : ι} (r : MixedModulus.Ref Γ i) :
    (encode δ E V).get r = E.get r + V.get r • MixedModulus.offset δ i
    theorem Cslib.Crypto.Garbling.BMR16.encode_cons {ι : Type} {μ ℓ : ι → ℕ} {Γ : List ι} (δ : (i : ι) → Fin (ℓ i) → ZMod (μ i)) {i : ι} (W : MixedModulus.Label μ ℓ i) (E : MixedModulus.Env (MixedModulus.Label μ ℓ) Γ) (x : ZMod (μ i)) (V : MixedModulus.Env (MixedModulus.Residue μ) Γ) :
    theorem Cslib.Crypto.Garbling.BMR16.gather_encode {ι : Type} {μ ℓ : ι → ℕ} {Γ Θ : List ι} (δ : (i : ι) → Fin (ℓ i) → ZMod (μ i)) (E : MixedModulus.Env (MixedModulus.Label μ ℓ) Γ) (V : MixedModulus.Env (MixedModulus.Residue μ) Γ) (outs : MixedModulus.Env (MixedModulus.Ref Γ) Θ) :
    (encode δ E V).gather outs = encode δ (E.gather outs) (V.gather outs)
    theorem Cslib.Crypto.Garbling.BMR16.snd_add_smul_offset {ι : Type} {μ ℓ : ι → ℕ} (δ : (i : ι) → Fin (ℓ i) → ZMod (μ i)) {i : ι} (W : MixedModulus.Label μ ℓ i) (x : ZMod (μ i)) :
    (W + x • MixedModulus.offset δ i).2 = W.2 + x

    The colour of W + x Δ_i is the colour of W plus x.

    theorem Cslib.Crypto.Garbling.BMR16.decode_colours_encode {ι : Type} {μ ℓ : ι → ℕ} (δ : (i : ι) → Fin (ℓ i) → ZMod (μ i)) {Θ : List ι} (Z : MixedModulus.Env (MixedModulus.Label μ ℓ) Θ) (y : MixedModulus.Env (MixedModulus.Residue μ) Θ) :
    decode (colours Z) (encode δ Z y) = y

    Decoding encoded output labels with the colours of their zero labels gives the values.

    theorem Cslib.Crypto.Garbling.BMR16.decode_decode {ι : Type} {μ ℓ : ι → ℕ} {Θ : List ι} (y : MixedModulus.Env (MixedModulus.Residue μ) Θ) (Y : MixedModulus.Env (MixedModulus.Label μ ℓ) Θ) :
    decode (decode y Y) Y = y

    Decoding output labels Y with information decode y Y gives y.

    theorem Cslib.Crypto.Garbling.BMR16.evaluate_garbleWith {ι T : Type} {μ ℓ : ι → ℕ} (H : MixedModulus.MixedModulusHash T μ ℓ) (tw : ℕ → T) (δ : (i : ι) → Fin (ℓ i) → ZMod (μ i)) {Γ Θ : List ι} (k : ℕ) (C : MixedModulus.MixedModulusCircuit μ (MixedModulus.Projection μ) Γ Θ) (E : MixedModulus.Env (MixedModulus.Label μ ℓ) Γ) (V : MixedModulus.Env (MixedModulus.Residue μ) Γ) :
    evaluate H tw k C (garbleWith H tw δ k C E).1 (encode δ E V) = encode δ (garbleWith H tw δ k C E).2 (C.eval V)

    Evaluation follows the labels of the actual wire values: with zero labels E, the active labels E + V Δ evaluate to the encoded output values.

    theorem Cslib.Crypto.Garbling.BMR16.Garbled.run_ofKeys {ι T : Type} {μ ℓ : ι → ℕ} {Γ Θ : List ι} (H : MixedModulus.MixedModulusHash T μ ℓ) (tw : ℕ → T) (δ : (i : ι) → Fin (ℓ i) → ZMod (μ i)) (C : MixedModulus.MixedModulusCircuit μ (MixedModulus.Projection μ) Γ Θ) (E : MixedModulus.Env (MixedModulus.Label μ ℓ) Γ) (x : MixedModulus.Env (MixedModulus.Residue μ) Γ) :
    run H tw (ofKeys H tw δ C E) x = C.eval x

    Correctness: evaluating a garbled circuit on an encoded input and decoding gives the circuit's output, for every hash, tweak assignment, offsets and zero labels.

    theorem Cslib.Crypto.Garbling.BMR16.Garbled.run_of_mem_support {ι T : Type} {μ ℓ : ι → ℕ} {Γ Θ : List ι} [Fintype ι] [DecidableEq ι] [∀ (i : ι), NeZero (μ i)] (H : MixedModulus.MixedModulusHash T μ ℓ) (tw : ℕ → T) (C : MixedModulus.MixedModulusCircuit μ (MixedModulus.Projection μ) Γ Θ) {G : Garbled ℓ C} (hG : G ∈ (garble H tw C).eval.support) (x : MixedModulus.Env (MixedModulus.Residue μ) Γ) :
    run H tw G x = C.eval x

    Correctness of the randomized garbling: every garbled circuit it can output evaluates correctly on every input.

    The privacy experiments #

    structure Cslib.Crypto.Garbling.BMR16.View {ι : Type} {μ : ι → ℕ} (ℓ : ι → ℕ) {P : ι → ι → Type} {Γ Θ : List ι} (C : MixedModulus.MixedModulusCircuit μ P Γ Θ) :

    What the evaluator of a garbled circuit sees: the garbled tables, one label per input wire and the decoding information. The circuit's shape is public, as an index of the type.

    theorem Cslib.Crypto.Garbling.BMR16.View.ext_iff {ι : Type} {μ ℓ : ι → ℕ} {P : ι → ι → Type} {Γ Θ : List ι} {C : MixedModulus.MixedModulusCircuit μ P Γ Θ} {x y : View ℓ C} :
    theorem Cslib.Crypto.Garbling.BMR16.View.ext {ι : Type} {μ ℓ : ι → ℕ} {P : ι → ι → Type} {Γ Θ : List ι} {C : MixedModulus.MixedModulusCircuit μ P Γ Θ} {x y : View ℓ C} (tables : x.tables = y.tables) (input : x.input = y.input) (decoding : x.decoding = y.decoding) :
    x = y
    def Cslib.Crypto.Garbling.BMR16.Garbled.view {ι : Type} {μ ℓ : ι → ℕ} {P : ι → ι → Type} {Γ Θ : List ι} {C : MixedModulus.MixedModulusCircuit μ P Γ Θ} (G : Garbled ℓ C) (x : MixedModulus.Env (MixedModulus.Residue μ) Γ) :
    View ℓ C

    The view of a garbled circuit on an input.

    def Cslib.Crypto.Garbling.BMR16.View.run {ι T : Type} {μ ℓ : ι → ℕ} {P : ι → ι → Type} {Γ Θ : List ι} (H : MixedModulus.MixedModulusHash T μ ℓ) (tw : ℕ → T) {C : MixedModulus.MixedModulusCircuit μ P Γ Θ} (V : View ℓ C) :

    Evaluate a view and decode the result.

    theorem Cslib.Crypto.Garbling.BMR16.Garbled.run_view {ι T : Type} {μ ℓ : ι → ℕ} {P : ι → ι → Type} {Γ Θ : List ι} (H : MixedModulus.MixedModulusHash T μ ℓ) (tw : ℕ → T) {C : MixedModulus.MixedModulusCircuit μ P Γ Θ} (G : Garbled ℓ C) (x : MixedModulus.Env (MixedModulus.Residue μ) Γ) :
    View.run H tw (G.view x) = run H tw G x

    Running the view of a garbled circuit on x is running the garbled circuit on x.

    def Cslib.Crypto.Garbling.BMR16.simulateWith {ι T : Type} {μ ℓ : ι → ℕ} {P : ι → ι → Type} {Γ Θ : List ι} (H : MixedModulus.MixedModulusHash T μ ℓ) (tw : ℕ → T) (C : MixedModulus.MixedModulusCircuit μ P Γ Θ) (y : MixedModulus.Env (MixedModulus.Residue μ) Θ) (A : MixedModulus.Env (MixedModulus.Label μ ℓ) Γ) (R : Tables ℓ C) :
    View ℓ C

    The simulated view with input labels A and tables R: the decoding information makes the evaluated output labels decode to y.

    theorem Cslib.Crypto.Garbling.BMR16.View.run_simulateWith {ι T : Type} {μ ℓ : ι → ℕ} {P : ι → ι → Type} {Γ Θ : List ι} (H : MixedModulus.MixedModulusHash T μ ℓ) (tw : ℕ → T) (C : MixedModulus.MixedModulusCircuit μ P Γ Θ) (y : MixedModulus.Env (MixedModulus.Residue μ) Θ) (A : MixedModulus.Env (MixedModulus.Label μ ℓ) Γ) (R : Tables ℓ C) :
    run H tw (simulateWith H tw C y A R) = y

    Simulator correctness: every simulated view decodes to y.

    The reduction #

    def Cslib.Crypto.Garbling.BMR16.rowsWith {ι T : Type} {μ ℓ : ι → ℕ} (f : (q : T × MixedModulus.CCRInput μ ℓ) → MixedModulus.Label μ ℓ q.2.target) (H : MixedModulus.MixedModulusHash T μ ℓ) (t : T) {i j : ι} (W : MixedModulus.Label μ ℓ i) (v : ZMod (μ i)) (φ : MixedModulus.Projection μ i j) (x : ZMod (μ i)) :

    Against a fixed oracle f, the value the reduction encrypts in the row of input value x of a projection gate with tweak t reading a wire with active label W and value v: H(t, W) for x = v, and otherwise the reply to the query (t, W, x - v, φ x - φ v).

    def Cslib.Crypto.Garbling.BMR16.reduceWith {ι T : Type} {μ ℓ : ι → ℕ} (f : (q : T × MixedModulus.CCRInput μ ℓ) → MixedModulus.Label μ ℓ q.2.target) (H : MixedModulus.MixedModulusHash T μ ℓ) (tw : ℕ → T) {Γ Θ : List ι} :

    The reduction's run against a fixed oracle f, from gate number k on, given the active labels A and values V of the wires so far: the tables and the active labels of the output wires that it builds.

    def Cslib.Crypto.Garbling.BMR16.queryRows {ι T : Type} {μ ℓ : ι → ℕ} (H : MixedModulus.MixedModulusHash T μ ℓ) (t : T) {i j : ι} (W : MixedModulus.Label μ ℓ i) (v : ZMod (μ i)) (φ : MixedModulus.Projection μ i j) :
    List (ZMod (μ i)) → ProbOracleComp (MixedModulus.ccrSpec T μ ℓ) (ZMod (μ i) → MixedModulus.Label μ ℓ j)

    The oracle queries of a projection gate, for the input values in xs: the table of the values rowsWith encrypts, read from the oracle.

    noncomputable def Cslib.Crypto.Garbling.BMR16.simulate {ι T : Type} {μ ℓ : ι → ℕ} {P : ι → ι → Type} {Γ Θ : List ι} [∀ (i : ι), NeZero (μ i)] (H : MixedModulus.MixedModulusHash T μ ℓ) (tw : ℕ → T) (C : MixedModulus.MixedModulusCircuit μ P Γ Θ) (y : MixedModulus.Env (MixedModulus.Residue μ) Θ) :
    ProbComp (View ℓ C)

    The simulator: uniform input labels and uniform tables. It sees the shape of the circuit, the public hash and tweaks, and the output; being polymorphic in the projection payload P, it cannot read the projection functions.

    noncomputable def Cslib.Crypto.Garbling.BMR16.realGame {ι T : Type} {μ ℓ : ι → ℕ} {Γ Θ : List ι} [Fintype ι] [DecidableEq ι] [∀ (i : ι), NeZero (μ i)] (H : MixedModulus.MixedModulusHash T μ ℓ) (tw : ℕ → T) (C : MixedModulus.MixedModulusCircuit μ (MixedModulus.Projection μ) Γ Θ) (x : MixedModulus.Env (MixedModulus.Residue μ) Γ) (D : View ℓ C → ProbComp Bool) :

    The real privacy experiment: garble C and run D on the view of the garbled circuit on x.

    noncomputable def Cslib.Crypto.Garbling.BMR16.simGame {ι T : Type} {μ ℓ : ι → ℕ} {Γ Θ : List ι} [∀ (i : ι), NeZero (μ i)] (H : MixedModulus.MixedModulusHash T μ ℓ) (tw : ℕ → T) (C : MixedModulus.MixedModulusCircuit μ (MixedModulus.Projection μ) Γ Θ) (x : MixedModulus.Env (MixedModulus.Residue μ) Γ) (D : View ℓ C → ProbComp Bool) :

    The simulated privacy experiment: run D on a view simulated from the shape of C and its output on x.

    noncomputable def Cslib.Crypto.Garbling.BMR16.reduceM {ι T : Type} {μ ℓ : ι → ℕ} [∀ (i : ι), NeZero (μ i)] (H : MixedModulus.MixedModulusHash T μ ℓ) (tw : ℕ → T) {Γ Θ : List ι} :

    The reduction's adaptive run, from gate number k on: reduceWith with oracle queries.

    noncomputable def Cslib.Crypto.Garbling.BMR16.reduction {ι T : Type} {μ ℓ : ι → ℕ} {Γ Θ : List ι} [∀ (i : ι), NeZero (μ i)] (H : MixedModulus.MixedModulusHash T μ ℓ) (tw : ℕ → T) (C : MixedModulus.MixedModulusCircuit μ (MixedModulus.Projection μ) Γ Θ) (x : MixedModulus.Env (MixedModulus.Residue μ) Γ) (D : View ℓ C → ProbComp Bool) :

    The mixed-modulus CCR adversary built from a distinguisher D for the circuit C on input x: sample active input labels, run the circuit gate by gate with oracle queries at the projection gates, set the decoding information from the output, and run D.

    The reduction against the real oracle #

    theorem Cslib.Crypto.Garbling.BMR16.reduceWith_ccrOracle {ι T : Type} {μ ℓ : ι → ℕ} (H : MixedModulus.MixedModulusHash T μ ℓ) (tw : ℕ → T) (δ : (i : ι) → Fin (ℓ i) → ZMod (μ i)) {Γ Θ : List ι} (k : ℕ) (C : MixedModulus.MixedModulusCircuit μ (MixedModulus.Projection μ) Γ Θ) (E : MixedModulus.Env (MixedModulus.Label μ ℓ) Γ) (V : MixedModulus.Env (MixedModulus.Residue μ) Γ) :
    reduceWith (MixedModulus.ccrOracle H δ) H tw k C (encode δ E V) V = ((garbleWith H tw δ k C E).1, encode δ (garbleWith H tw δ k C E).2 (C.eval V))

    Against the real oracle, the reduction builds the real tables and active output labels.

    theorem Cslib.Crypto.Garbling.BMR16.decode_encode {ι : Type} {μ ℓ : ι → ℕ} (δ : (i : ι) → Fin (ℓ i) → ZMod (μ i)) {Θ : List ι} (Z : MixedModulus.Env (MixedModulus.Label μ ℓ) Θ) (y : MixedModulus.Env (MixedModulus.Residue μ) Θ) :
    decode y (encode δ Z y) = colours Z

    Decoding encoded output values with the outputs gives the colours of the zero labels.

    theorem Cslib.Crypto.Garbling.BMR16.map_encode_uniformOfFintype {ι : Type} {μ ℓ : ι → ℕ} {Γ : List ι} [∀ (i : ι), NeZero (μ i)] (δ : (i : ι) → Fin (ℓ i) → ZMod (μ i)) (V : MixedModulus.Env (MixedModulus.Residue μ) Γ) :

    Encoding uniform zero labels gives uniform active labels.

    The reduction against a random function #

    theorem Cslib.Crypto.Garbling.BMR16.interpret_queryRows {ι T : Type} {μ ℓ : ι → ℕ} (f : (q : T × MixedModulus.CCRInput μ ℓ) → MixedModulus.Label μ ℓ q.2.target) (H : MixedModulus.MixedModulusHash T μ ℓ) (t : T) {i j : ι} (W : MixedModulus.Label μ ℓ i) (v : ZMod (μ i)) (φ : MixedModulus.Projection μ i j) (xs : List (ZMod (μ i))) :
    OracleComp.interpret (OracleComp.sumHandler ProbComp.unifFin fun (q : T × MixedModulus.CCRInput μ ℓ) => pure (f q)) (queryRows H t W v φ xs) = pure fun (x : ZMod (μ i)) => if x ∈ xs then rowsWith f H t W v φ x else 0

    Interpreting the queries of a projection gate against a fixed oracle f reads rowsWith f on the listed values.

    theorem Cslib.Crypto.Garbling.BMR16.interpret_reduceM {ι T : Type} {μ ℓ : ι → ℕ} [∀ (i : ι), NeZero (μ i)] (f : (q : T × MixedModulus.CCRInput μ ℓ) → MixedModulus.Label μ ℓ q.2.target) (H : MixedModulus.MixedModulusHash T μ ℓ) (tw : ℕ → T) {Γ Θ : List ι} (k : ℕ) (C : MixedModulus.MixedModulusCircuit μ (MixedModulus.Projection μ) Γ Θ) (A : MixedModulus.Env (MixedModulus.Label μ ℓ) Γ) (V : MixedModulus.Env (MixedModulus.Residue μ) Γ) :
    OracleComp.interpret (OracleComp.sumHandler ProbComp.unifFin fun (q : T × MixedModulus.CCRInput μ ℓ) => pure (f q)) (reduceM H tw k C A V) = pure (reduceWith f H tw k C A V)

    Interpreting the adaptive reduction against a fixed oracle f is its run reduceWith f.

    theorem Cslib.Crypto.Garbling.BMR16.reduceWith_congr {ι T : Type} {μ ℓ : ι → ℕ} {f g : (q : T × MixedModulus.CCRInput μ ℓ) → MixedModulus.Label μ ℓ q.2.target} (H : MixedModulus.MixedModulusHash T μ ℓ) (tw : ℕ → T) {Γ Θ : List ι} (k : ℕ) (C : MixedModulus.MixedModulusCircuit μ (MixedModulus.Projection μ) Γ Θ) (A : MixedModulus.Env (MixedModulus.Label μ ℓ) Γ) (V : MixedModulus.Env (MixedModulus.Residue μ) Γ) (hfg : ∀ (n : ℕ), k ≤ n → n < k + C.size → ∀ (r : MixedModulus.CCRInput μ ℓ), f (tw n, r) = g (tw n, r)) :
    reduceWith f H tw k C A V = reduceWith g H tw k C A V

    Locality: the reduction's run from gate k on reads the oracle only at the tweaks of the remaining gates.

    theorem Cslib.Crypto.Garbling.BMR16.bind_reduceWith_uniformOfFintype {ι T : Type} {μ ℓ : ι → ℕ} [Fintype ι] [DecidableEq ι] [∀ (i : ι), NeZero (μ i)] [Fintype T] [DecidableEq T] {β : Type} (H : MixedModulus.MixedModulusHash T μ ℓ) (tw : ℕ → T) {Γ Θ : List ι} (k : ℕ) (C : MixedModulus.MixedModulusCircuit μ (MixedModulus.Projection μ) Γ Θ) (A : MixedModulus.Env (MixedModulus.Label μ ℓ) Γ) (V : MixedModulus.Env (MixedModulus.Residue μ) Γ) (htw : Set.InjOn tw (Set.Ico k (k + C.size))) (κ : Tables ℓ C × MixedModulus.Env (MixedModulus.Label μ ℓ) Θ → PMF β) :
    ((Probability.PMF.uniformOfFintype (T → MixedModulus.CCRTable μ ℓ)).bind fun (f : T → MixedModulus.CCRTable μ ℓ) => κ (reduceWith (fun (q : T × MixedModulus.CCRInput μ ℓ) => f q.1 q.2) H tw k C A V)) = (Probability.PMF.uniformOfFintype (Tables ℓ C)).bind fun (R : Tables ℓ C) => κ (R, evaluate H tw k C R A)

    The ideal step: against a uniformly random function, the tables the reduction builds are uniform, and its active output labels are the evaluation of those tables, provided the remaining gates have distinct tweaks.

    Privacy #

    theorem Cslib.Crypto.Garbling.BMR16.realGame_eq_ccrRealGame {ι T : Type} {μ ℓ : ι → ℕ} {Γ Θ : List ι} [Fintype ι] [DecidableEq ι] [∀ (i : ι), NeZero (μ i)] (H : MixedModulus.MixedModulusHash T μ ℓ) (tw : ℕ → T) (C : MixedModulus.MixedModulusCircuit μ (MixedModulus.Projection μ) Γ Θ) (x : MixedModulus.Env (MixedModulus.Residue μ) Γ) (D : View ℓ C → ProbComp Bool) :
    realGame H tw C x D = MixedModulus.ccrRealGame H (reduction H tw C x D)

    Against the real oracle, the reduction plays the real privacy experiment.

    theorem Cslib.Crypto.Garbling.BMR16.simGame_eq_ccrIdealGame {ι T : Type} {μ ℓ : ι → ℕ} {Γ Θ : List ι} [Fintype ι] [DecidableEq ι] [∀ (i : ι), NeZero (μ i)] [Fintype T] [DecidableEq T] (H : MixedModulus.MixedModulusHash T μ ℓ) (tw : ℕ → T) (C : MixedModulus.MixedModulusCircuit μ (MixedModulus.Projection μ) Γ Θ) (x : MixedModulus.Env (MixedModulus.Residue μ) Γ) (D : View ℓ C → ProbComp Bool) (htw : Set.InjOn tw (Set.Iio C.size)) :

    Against a random function, the reduction plays the simulated privacy experiment, provided the gates have distinct tweaks.

    theorem Cslib.Crypto.Garbling.BMR16.advantage_realGame_simGame {ι T : Type} {μ ℓ : ι → ℕ} {Γ Θ : List ι} [Fintype ι] [DecidableEq ι] [∀ (i : ι), NeZero (μ i)] [Fintype T] [DecidableEq T] (H : MixedModulus.MixedModulusHash T μ ℓ) (tw : ℕ → T) (C : MixedModulus.MixedModulusCircuit μ (MixedModulus.Projection μ) Γ Θ) (x : MixedModulus.Env (MixedModulus.Residue μ) Γ) (D : View ℓ C → ProbComp Bool) (htw : Set.InjOn tw (Set.Iio C.size)) :
    (realGame H tw C x D).advantage (simGame H tw C x D) = MixedModulus.ccrAdvantage H (reduction H tw C x D)

    The reduction identity behind the privacy of BMR16, not the privacy part of [BMR16] Theorem 1. For one hash H, mixed-modulus circuit C, input x and distinguisher D, if the gates have distinct tweaks, the advantage of D between the real and the simulated view equals the mixed-modulus CCR advantage of the explicit reduction reduction H tw C x D against H, which is legal (reduction_isLegal). No assumption is applied and nothing is bounded: privacy needs an asymptotic form of mixed-modulus circular correlation robustness against efficient adversaries and a PPT certificate for a family version of the reduction, which do not exist yet (#6068).

    Legality of the reduction #

    theorem Cslib.Crypto.Garbling.BMR16.reduction_isLegal {ι T : Type} {μ ℓ : ι → ℕ} {Γ Θ : List ι} [∀ (i : ι), NeZero (μ i)] (H : MixedModulus.MixedModulusHash T μ ℓ) (tw : ℕ → T) (C : MixedModulus.MixedModulusCircuit μ (MixedModulus.Projection μ) Γ Θ) (x : MixedModulus.Env (MixedModulus.Residue μ) Γ) (D : View ℓ C → ProbComp Bool) (htw : Set.InjOn tw (Set.Iio C.size)) :
    (reduction H tw C x D).IsLegal

    The reduction is legal: along every run, whatever its private coins and the oracle's replies, it never uses multiplier 0, and its queries are determined by their tweak, source sort, label and multiplier, provided the gates have distinct tweaks.