Documentation

CslibFrontier.Crypto.Protocols.MPC.Beaver

Arithmetic Beaver Multiplication Triples, Online Privacy, and Tampered-Opening Attack #

This module formalizes Beaver's circuit-randomization multiplication step over ZMod p together with its semi-honest coalition privacy in the ideal triple-preprocessing hybrid model and an explicit illustration of additive-error output-opening tampering against unauthenticated 2-party Beaver multiplication:

  1. Beaver Triple Share Structure (TripleShare): per-party additive shares (a_i, b_i, c_i) of a multiplication triple over R. Input share pairs (x_i, y_i) and broadcast masked openings (d_i, e_i) = (x_i - a_i, y_i - b_i) are represented directly as R × R using Mathlib's coordinatewise AddCommGroup structure.
  2. Ideal $m$-Party Triple Preprocessing (beaverTripleFunctionality, beaverTripleSpec, beaverTripleWorld): an $m$-party generalization of the 2-party dealer ("2.5-party") functionality in [BS23], Section 23.2.2 (building on circuit randomization via multiplication triples from [Bea92] and the $m$-party additive-share online model of [DPSZ12]). It samples uniform additive shares (a_i, b_i, c_i) over ZMod p conditioned on $\sum_i c_i = (\sum_i a_i) \cdot (\sum_i b_i)$, reusing ProbComp.sampleAdditiveShares from CslibFrontier.Languages.Probabilistic.Sharing. For every proper coalition I ≠ Finset.univ, the marginal distribution of I's triple shares is uniform (eval_restrict_beaverTripleFunctionality).
  3. Beaver Online Share Multiplication (beaverMulShare, beaverMulProtocol, beaverMulSim, perfectSemiHonestPrivateProper_beaverMul): synchronous $m$-party protocol over CslibFrontier.Crypto.Protocols.MPC.Basic and CslibFrontier.Crypto.Protocols.MPC.Broadcast in which the parties query beaverTripleSpec p m, broadcast their masked openings localMaskedOpening, and output additive shares summing to $(\sum_i x_i) \cdot (\sum_i y_i)$ (sum_output_beaverMulProtocol). We prove PerfectSemiHonestPrivateProper against every proper static coalition I ≠ Finset.univ with respect to sharedMulFunctionality m (exact equality of joint view-and-output distributions, with no polynomial-time simulator certificate).
  4. Additive-Error Tampered-Opening Attack Illustration (tamperedOpening, tamperedOpeningExtract, tamperedOpeningReal, eval_tamperedOpeningReal, le_advantage_tamperedOpeningBitGame): motivated by the discussion of maliciously tampered openings in [BS23], Section 23.2.4, we give an original concrete 2-party illustration showing what goes wrong if unauthenticated Beaver multiplication of [z] = [x] * [0] is followed by an unauthenticated output-share opening. Notice that beaverMulProtocol itself only produces output shares and has no output-broadcast round; if honest party 0 subsequently reveals its output share z'₀ = beaverMulShare 0 (op₀ + tamperedOpening t₁) t₀ after party 1 substitutes e'₁ = -b₁ + 1 in the masked-opening broadcast, the tampered transcript (t₁, op₀, z'₀) determines x identically (tamperedOpeningExtract_eq). The standalone ProbComp (ZMod p) experiment tamperedOpeningReal and the toy distinguishing games tamperedOpeningTestOne, tamperedOpeningRealBitGame, and tamperedOpeningIdealBitGame package this exact recovery against any input-independent guessing distribution blindGuess : ProbComp (ZMod p).

Main definitions #

Main results #

References #

Beaver triple share structure #

One party's additive share (a, b, c) of a Beaver multiplication triple over R.

  • a : R

    Additive share of the first random mask a.

  • b : R

    Additive share of the second random mask b.

  • c : R

    Additive share of the mask product c = a * b.

Instances For
    theorem Cslib.Crypto.Protocols.MPC.Beaver.TripleShare.ext {R : Type} {x y : TripleShare R} (a : x.a = y.a) (b : x.b = y.b) (c : x.c = y.c) :
    x = y
    @[instance_reducible]

    Ideal $m$-party Beaver triple preprocessing #

    noncomputable def Cslib.Crypto.Protocols.MPC.Beaver.beaverTripleFunctionality (p m : ℕ) [NeZero p] :
    Functionality m (fun (x : Fin m) => Unit) fun (x : Fin m) => TripleShare (ZMod p)

    Randomized m-party Beaver triple preprocessing functionality over ZMod p (an m-party generalization of the 2-party dealer in [BS23], Section 23.2.2; cf. [Bea92]; [DPSZ12]): samples independent uniform additive share vectors a, b : Fin m → ZMod p and uniform additive shares c summing to (∑ i, a i) * (∑ i, b i).

    @[reducible]

    m-ary oracle specification for Beaver triple preprocessing over ZMod p.

    theorem Cslib.Crypto.Protocols.MPC.Beaver.eval_beaverTripleFunctionality_eq_bind_sharedMul (p m : ℕ) [NeZero p] (u : Fin m → Unit) :
    (beaverTripleFunctionality p m u).eval = (Probability.PMF.uniformOfFintype (Fin m → ZMod p × ZMod p)).bind fun (ab : Fin m → ZMod p × ZMod p) => PMF.map (fun (c : (i : Fin m) → (fun (x : Fin m) => ZMod p) i) (i : Fin m) => { a := (ab i).1, b := (ab i).2, c := c i }) (sharedMulFunctionality m ab).eval

    beaverTripleFunctionality p m is distributed as sampling uniform additive mask share pairs ab : Fin m → ZMod p × ZMod p, invoking sharedMulFunctionality m ab to sample additive shares of (∑ i, (ab i).1) * (∑ i, (ab i).2), and assembling fun i => ⟨(ab i).1, (ab i).2, c i⟩.

    theorem Cslib.Crypto.Protocols.MPC.Beaver.mem_support_beaverTripleFunctionality_iff {p m : ℕ} [NeZero p] [NeZero m] (u : Fin m → Unit) (t : Fin m → TripleShare (ZMod p)) :
    t ∈ (beaverTripleFunctionality p m u).eval.support ↔ ∑ i : Fin m, (t i).c = (∑ i : Fin m, (t i).a) * ∑ i : Fin m, (t i).b

    Support characterization for beaverTripleFunctionality: an m-tuple of triple shares lies in the support if and only if ∑ i, (t i).c = (∑ i, (t i).a) * (∑ i, (t i).b).

    theorem Cslib.Crypto.Protocols.MPC.Beaver.sum_c_of_mem_support_beaverTripleFunctionality {p m : ℕ} [NeZero p] [NeZero m] {u : Fin m → Unit} {t : Fin m → TripleShare (ZMod p)} (ht : t ∈ (beaverTripleFunctionality p m u).eval.support) :
    ∑ i : Fin m, (t i).c = (∑ i : Fin m, (t i).a) * ∑ i : Fin m, (t i).b

    Every triple in the support of beaverTripleFunctionality satisfies the Beaver product relation ∑ i, (t i).c = (∑ i, (t i).a) * (∑ i, (t i).b).

    For every proper coalition I ≠ Finset.univ, the marginal distribution of I's triple shares in beaverTripleFunctionality is uniform on (i : I) → TripleShare (ZMod p).

    Beaver share multiplication step and algebraic reconstruction #

    Party i's local masked opening share (x_i - a_i, y_i - b_i).

    def Cslib.Crypto.Protocols.MPC.Beaver.beaverMulShare {R : Type} [CommRing R] {m : ℕ} (i : Fin m) (op : R × R) (t : TripleShare R) :
    R

    Party i's local Beaver output share given public reconstructed masked opening op = (d, e) and party i's triple share t = (a_i, b_i, c_i) ([BS23], Section 23.2.2, generalized to m parties; [DPSZ12]; cf. [Bea92]): party 0 adds the public product term d * e to d * b_i + e * a_i + c_i.

    theorem Cslib.Crypto.Protocols.MPC.Beaver.sum_beaverMulShare {R : Type} [CommRing R] {m : ℕ} [NeZero m] (op : R × R) (t : Fin m → TripleShare R) :
    ∑ i : Fin m, beaverMulShare i op (t i) = op.1 * op.2 + op.1 * ∑ i : Fin m, (t i).b + op.2 * ∑ i : Fin m, (t i).a + ∑ i : Fin m, (t i).c

    Sum of beaverMulShare across all m parties (m > 0).

    theorem Cslib.Crypto.Protocols.MPC.Beaver.sum_beaverMulShare_eq_mul {R : Type} [CommRing R] {m : ℕ} [NeZero m] (xy : Fin m → R × R) (t : Fin m → TripleShare R) (hc : ∑ i : Fin m, (t i).c = (∑ i : Fin m, (t i).a) * ∑ i : Fin m, (t i).b) :
    ∑ i : Fin m, beaverMulShare i (∑ j : Fin m, localMaskedOpening (xy j) (t j)) (t i) = (∑ i : Fin m, (xy i).1) * ∑ i : Fin m, (xy i).2

    Algebraic correctness of Beaver multiplication ([BS23], Section 23.2.2, generalized to m parties; [DPSZ12]; cf. [Bea92]): when op = ∑ i, localMaskedOpening (xy i) (t i) and ∑ i, (t i).c = (∑ i, (t i).a) * (∑ i, (t i).b), the output shares sum to (∑ i, (xy i).1) * (∑ i, (xy i).2).

    Synchronous $m$-party Beaver online multiplication protocol and privacy #

    @[reducible]

    Schedule for beaverMulProtocol p m: one joint beaverTripleSpec p m preprocessing call followed by an all-to-all broadcast of ZMod p × ZMod p.

    def Cslib.Crypto.Protocols.MPC.Beaver.beaverMulProtocol (p m : ℕ) :
    Protocol m (beaverTripleSpec p m) (beaverMulSchedule p m) (fun (x : Fin m) => ZMod p × ZMod p) (fun (x : Fin m) => Unit) fun (x : Fin m) => ZMod p

    Synchronous m-party Beaver online multiplication protocol in the beaverTripleSpec p m-hybrid model (generalizing [BS23], Section 23.2.2 to m parties; [DPSZ12]; cf. [Bea92]):

    1. All m parties invoke beaverTripleSpec p m to receive triple shares t_i = (a_i, b_i, c_i).
    2. Each party i broadcasts localMaskedOpening xy_i t_i = (x_i - a_i, y_i - b_i).
    3. Each party i sums the received openings op = ∑ j, msgs j and outputs beaverMulShare i op t_i.
    theorem Cslib.Crypto.Protocols.MPC.Beaver.sum_output_beaverMulProtocol {p m : ℕ} [NeZero p] [NeZero m] (xy : Fin m → ZMod p × ZMod p) {res : ((i : Fin m) → PartyView (fun (x : Fin m) => ZMod p × ZMod p) (fun (x : Fin m) => Unit) (beaverMulSchedule p m) i) × (Fin m → ZMod p)} (hres : res ∈ ((beaverMulProtocol p m).evalWith (beaverTripleWorld p m) xy).support) :
    ∑ i : Fin m, res.2 i = (∑ i : Fin m, (xy i).1) * ∑ i : Fin m, (xy i).2

    Output correctness of beaverMulProtocol (m > 0): on every execution in the support of beaverTripleWorld p m, the parties' outputs sum to (∑ i, (xy i).1) * (∑ i, (xy i).2).

    noncomputable def Cslib.Crypto.Protocols.MPC.Beaver.beaverMulSim (p m : ℕ) [NeZero p] (I : Finset (Fin m)) :
    CoalitionSimulator (beaverMulSchedule p m) (fun (x : Fin m) => ZMod p × ZMod p) (fun (x : Fin m) => Unit) (fun (x : Fin m) => ZMod p) I

    Proper-coalition simulator for beaverMulProtocol p m (generalizing [BS23], Section 23.2.2 to m parties; cf. [Bea92]): samples independent uniform masks aI, bI for corrupted parties i ∈ I and independent uniform masked openings msgsCompl for honest parties j ∈ Iᶜ, computes the public sum op = ∑ j, msgs j, and sets each corrupted party's c_i share so that beaverMulShare i op t_i = zI i.

    Perfect semi-honest privacy of beaverMulProtocol p m in beaverTripleWorld p m against every proper static coalition I ≠ Finset.univ (I.card < m), realizing sharedMulFunctionality m over ZMod p (generalizing [BS23], Section 23.2.2 to m parties; cf. [Bea92]).

    Additive-error tampered-opening attack illustration on unauthenticated 2-party Beaver #

    multiplication

    Malicious party 1's tampered masked opening in 2-party Beaver multiplication of [x] * [0] (motivated by [BS23], Section 23.2.4): holding input (0, 0) and triple share t₁, party 1 adds an additive error 1 to its second opening coordinate -t₁.b.

    def Cslib.Crypto.Protocols.MPC.Beaver.tamperedOpeningExtract {R : Type} [CommRing R] (t₁ : TripleShare R) (op₀ : R × R) (z'₀ : R) :
    R

    Malicious party 1's deterministic extraction formula recovering party 0's secret input x from party 0's masked opening op₀ and opened Beaver output share z'₀ (assuming the output share z'₀ is subsequently revealed).

    theorem Cslib.Crypto.Protocols.MPC.Beaver.tamperedOpeningExtract_eq {R : Type} [CommRing R] (x : R) (t : Fin 2 → TripleShare R) (hc : (t 0).c + (t 1).c = ((t 0).a + (t 1).a) * ((t 0).b + (t 1).b)) :
    have op₀ := localMaskedOpening (x, 0) (t 0); have z'₀ := beaverMulShare 0 (op₀ + tamperedOpening (t 1)) (t 0); tamperedOpeningExtract (t 1) op₀ z'₀ = x

    Algebraic identity behind the additive-error tampered-opening attack (original 2-party illustration of output-opening tampering, motivated by [BS23], Section 23.2.4): for every valid 2-party Beaver triple t (c₀ + c₁ = (a₀ + a₁) * (b₀ + b₁)), if honest party 0's output share z'₀ is opened after party 1 broadcasts tamperedOpening (t 1), then tamperedOpeningExtract recovers honest party 0's private input x identically.

    Standalone 2-party tampered-opening experiment on [z] = [x] * [0] over ZMod p (assuming an unauthenticated output-share opening z'₀): samples a fresh triple from beaverTripleFunctionality p 2, computes honest party 0's masked opening op₀ and opened output share z'₀ on (x, 0) against tamperedOpening (t 1), and outputs party 1's extracted value.

    @[simp]

    Exact secret recovery: tamperedOpeningReal p x outputs x with probability 1.

    Toy distinguishing test checking whether a candidate value equals 1 : ZMod p.

    Original standalone Game illustration: for 2 ≤ p and any x-independent guessing program blindGuess : ProbComp (ZMod p), the sum of distinguishing advantages of tamperedOpeningTestOne between tamperedOpeningReal p 0 / tamperedOpeningReal p 1 and blindGuess is at least 1.

    Standalone hidden-bit game for tamperedOpeningReal: samples a uniform secret bit b for party 0's input x ∈ {0, 1}, runs tamperedOpeningReal p x, and tests whether the extracted value equals x.

    Standalone reference hidden-bit game for an input-independent guessing program blindGuess : ProbComp (ZMod p) that does not depend on the secret bit b.

    Original standalone Game illustration: for every modulus p ≥ 2 and every input-independent guessing program blindGuess : ProbComp (ZMod p), tamperedOpeningRealBitGame p achieves distinguishing advantage at least 1 / 2 over tamperedOpeningIdealBitGame p blindGuess.