Documentation

CslibFrontier.Crypto.Protocols.MPC.InputConsistency

Input Consistency in Two-Party Arithmetic MPC: Additive-Shift Attack and MAC Repair #

This module formalizes two complementary building blocks illustrating active input-consistency vulnerabilities in unauthenticated two-party additive secret sharing over a prime field ZMod q ([Fact (Nat.Prime q)]) and their information-theoretic repair via random MAC authentication:

  1. Corrupt-Party Additive-Shift Attack on f(x) = x * (x - 1) (bitCheckPoly, AdditiveShare2, evalShiftedBitCheck, naiveBitCheckRealExp, naiveBitCheckIdealExp): Suppose P₀ holds a secret bit x ∈ {0, 1} ⊆ ZMod q and shares it additively as (x₀, x₁) with x₀ + x₁ = x. In an unauthenticated arithmetic circuit evaluating the bit-check polynomial f(x) = x * (x - 1), a malicious P₁ can replace its share x₁ by x₁ + δ for an arbitrary offset δ : ZMod q. We prove the exact algebraic evaluation identity $$f(x + \delta) = f(x) + \delta \cdot (2x + \delta - 1).$$ For x ∈ {0, 1} and δ = 1, this simplifies to f(x + 1) = 2 * x, so f(0 + 1) = 0 while f(1 + 1) = 2. Whenever q > 2 is prime, 2 ≠ 0 in ZMod q, so the circuit output deterministically reveals x (f(x + 1) = 0 ↔ x = 0 and f(x + 1) = 2 ↔ x = 1), whereas the ideal functionality outputs f(x) = 0 identically for both x = 0 and x = 1. In the explicit ProbComp distinguishing experiments, the δ = 1 adversary achieves left-right distinguishing advantage 1 (versus 0 for any ideal-world observer) and hidden-bit recovery probability 1 (versus 1 / 2 in the ideal world).

  2. Random-MAC and Random-Linear-Combination Input-Authentication Repair (SPDZ.AuthShare.tamperParty, mkAuthShare2, macSingleCheckGame, LinearCombAuthVec2, vecLinearCombCheckGame, vecBatchMacCheckGame):

    • Single authenticated share: authenticated inputs are two-party SPDZ shares SPDZ.AuthShare q 2 with public modifier δ = 0 (mkAuthShare2). Given a uniform MAC key α ← $ᵗ ZMod q unknown to P₁ and a valid sharing of (x, t) with t = α * x, if a corrupt P₁ adds (δ_x, δ_t) to its value and MAC shares (SPDZ.AuthShare.tamperParty), the reconstructed check SPDZ.AuthShare.Valid α passes if and only if α * δ_x = δ_t. For any nonzero input shift δ_x ≠ 0, this holds with exact probability 1 / q (via SPDZ.eval_macKey_guess_eq).
    • Vector of k input shares: we package both (i) a batched vector-MAC / linear-code validity check (LinearCombAuthVec2) under a fresh uniform linear-combination key r ← $ᵗ (Fin k → ZMod q), where honest shares pass with probability 1 and any nonzero tampering vector δ ≠ 0 passes with exact probability 1 / q (via Cslib.Probability.toOuterMeasure_uniform_linearComb_eq), and (ii) a batched check (vecBatchMacCheckGame) of k SPDZ-authenticated shares under independent random weights r ← $ᵗ (Fin k → ZMod q) and scalar MAC key α ← $ᵗ ZMod q, passing with probability 1 when honest and at most 2 / q when δ_x ≠ 0; the tampered check has the distribution of SPDZ.macCheckSoundnessGame, so the bound is SPDZ.probability_macCheckSoundnessGame_le.

Source mapping #

Main definitions #

Main results #

References #

1. Corrupt-party additive-shift attack on f(x) = x * (x - 1) #

The bit-check polynomial f(x) = x * (x - 1) over a ring R.

Two-party additive sharing (x₀, x₁) of a value over R.

  • share0 : R

    Party 0's additive share x₀.

  • share1 : R

    Party 1's additive share x₁.

Instances For

    Reconstructed value x₀ + x₁ of a two-party additive sharing.

    Predicate asserting that s is a valid additive sharing of x (x₀ + x₁ = x).

    Corrupt party P₁ adds a known offset δ to its own share: (x₀, x₁) ↦ (x₀, x₁ + δ).

    Output of the naive two-party bit-check circuit when corrupt P₁ adds offset δ to its share before evaluation.

    Any binary input x ∈ {0, 1} is a root of f(x) = x * (x - 1).

    Exact algebraic shift identity: adding δ to x shifts f(x) = x * (x - 1) by δ * (2 * x + δ - 1).

    When s is a valid additive sharing of x, shifting P₁'s share by δ causes the naive bit-check circuit to evaluate to f(x) + δ * (2 * x + δ - 1).

    Converse / recovery lemma (x = 0): for binary x ∈ {0, 1} ⊆ ZMod q with q > 2 prime, under the additive shift δ = 1, f(x + 1) = 0 ↔ x = 0.

    Converse / recovery lemma (x = 1): for binary x ∈ {0, 1} ⊆ ZMod q with q > 2 prime, under the additive shift δ = 1, f(x + 1) = 2 ↔ x = 1.

    2. Explicit two-world distinguishing games for the δ = 1 shift attack #

    Sample a uniform two-party additive sharing (x₀, x - x₀) of x : ZMod q.

    Real-world experiment for secret bit b : Bool (x = if b then 1 else 0): P₀ samples a uniform additive sharing of x, corrupt P₁ adds δ to its share, and the circuit outputs evalShiftedBitCheck s δ.

    Ideal-world experiment for secret bit b : Bool (x = if b then 1 else 0): outputs the ideal evaluation f(x) = x * (x - 1) directly.

    @[simp]

    In naiveBitCheckRealExp q δ b, the circuit deterministically outputs f(x + δ) regardless of the random share x₀.

    @[simp]

    In the ideal world, naiveBitCheckIdealExp q b outputs 0 identically for both b = false and b = true.

    Distinguisher / bit-extractor for the δ = 1 attack: outputs true iff the circuit output equals 2.

    Left-right distinguishing game in the real world on secret bit b : Bool for distinguisher D : ZMod q → ProbComp Bool.

    Left-right distinguishing game in the ideal world on secret bit b : Bool for distinguisher D : ZMod q → ProbComp Bool.

    Ideal-world indistinguishability: every randomized distinguisher D : ZMod q → ProbComp Bool has distinguishing advantage 0 between b = false (x = 0) and b = true (x = 1) in the ideal world.

    Real-world advantage 1: when q > 2 is prime, the δ = 1 shift adversary together with shiftOneDistinguisher distinguishes b = false (x = 0) from b = true (x = 1) with distinguishing advantage 1.

    Hidden-bit recovery game in the real world (δ = 1): samples a uniform secret bit b ← $ᵗ Bool, runs the shifted circuit, and checks whether shiftOneDistinguisher z = b.

    Hidden-bit recovery game in the ideal world: samples a uniform secret bit b ← $ᵗ Bool, runs the ideal bit-check circuit, and checks whether an arbitrary randomized observer A : ZMod q → ProbComp Bool outputs b.

    When q > 2 is prime, the δ = 1 adversary recovers the uniform secret bit b with probability 1.

    In the ideal world, every randomized observer A : ZMod q → ProbComp Bool guesses the uniform secret bit b with probability exactly 1 / 2.

    In the uniform-bit guessing game, the δ = 1 attack outperforms every ideal-world observer A by distinguishing advantage exactly 1 / 2.

    3. Random-MAC input-authentication repair on SPDZ.AuthShare #

    The two-party SPDZ authenticated sharing of x under MAC key alpha with public modifier δ = 0, determined by party 0's value share x₀ and MAC share t₀: party 0 holds (x₀, t₀) and party 1 holds (x - x₀, alpha * x - t₀).

    Full single-input MAC verification game: samples a uniform MAC key α ← $ᵗ ZMod q and a uniform two-party authenticated sharing of x (mkAuthShare2 with uniform x₀, t₀), lets corrupt party 1 add (δ_x, δ_t) to its value and MAC shares, and checks the SPDZ MAC relation SPDZ.AuthShare.Valid α (here t' = α * x', since δ = 0).

    Honest single-input shares (δ_x = 0, δ_t = 0) pass macSingleCheckGame with probability 1.

    theorem Cslib.Crypto.Protocols.MPC.InputConsistency.probability_macSingleCheckGame_eq {q : ℕ} [Fact (Nat.Prime q)] (x : ZMod q) {δ_x δ_t : ZMod q} (hδ : δ_x ≠ 0) :
    ((macSingleCheckGame q x δ_x δ_t).eval true).toReal = 1 / ↑q

    Exact 1 / q single-input MAC soundness: for prime q and any nonzero input shift δ_x ≠ 0, macSingleCheckGame q x δ_x δ_t accepts with probability exactly 1 / q.

    4. Vector of k input shares: random-linear-combination and batched MAC checks #

    Two-party vector input sharing of length k over R authenticated by a single batched linear-combination MAC tag t = ∑ j, r j * x j.

    • vals : Fin k → AdditiveShare2 R

      Coordinatewise additive sharings (x_{j,0}, x_{j,1}) of the k input elements.

    • Additive sharing (t₀, t₁) of the batched linear-combination MAC tag.

    Instances For
      @[instance_reducible]

      Reconstructed vector of k secret inputs j ↦ x_{j,0} + x_{j,1}.

      Reconstructed batched MAC tag t₀ + t₁.

      Validity predicate under linear-combination key r : Fin k → R: t = ∑ j, r j * x j.

      Corrupt party P₁ adds an offset vector δ : Fin k → R to its input shares and δ_t : R to its MAC tag share.

      theorem Cslib.Crypto.Protocols.MPC.InputConsistency.LinearCombAuthVec2.tamper1_isValidFor_iff {R : Type} [CommRing R] {k : ℕ} {r : Fin k → R} {v : LinearCombAuthVec2 R k} (hv : IsValidFor r v) (δ : Fin k → R) (δ_t : R) :
      IsValidFor r (v.tamper1 δ δ_t) ↔ ∑ j : Fin k, r j * δ j = δ_t

      Vector linear-combination tampering equivalence: when v is valid under r, the tampered submission v.tamper1 δ δ_t satisfies t' = ∑ j, r j * x' j if and only if ∑ j, r j * δ j = δ_t.

      Sample independent uniform additive shares of x : Fin k → ZMod q and of the batched MAC tag ∑ j, r j * x j.

      noncomputable def Cslib.Crypto.Protocols.MPC.InputConsistency.vecLinearCombCheckGame (q k : ℕ) [NeZero q] (x δ : Fin k → ZMod q) (δ_t : ZMod q) :

      Two-party vector input-consistency game under a fresh uniform linear-combination key r ← $ᵗ (Fin k → ZMod q): samples r and valid additive shares of x, applies P₁'s tampering (δ, δ_t), and checks t' = ∑ j, r j * x' j.

      Honest vector shares (δ = 0, δ_t = 0) pass vecLinearCombCheckGame with probability 1.

      theorem Cslib.Crypto.Protocols.MPC.InputConsistency.eval_vecLinearCombCheckGame_eq {q k : ℕ} [Fact (Nat.Prime q)] (x : Fin k → ZMod q) {δ : Fin k → ZMod q} (hδ : δ ≠ 0) (δ_t : ZMod q) :
      (vecLinearCombCheckGame q k x δ δ_t).eval true = (↑q)⁻¹

      Exact 1 / q vector soundness (ℝ≥0∞): for prime q and any nonzero tampering vector δ ≠ 0, vecLinearCombCheckGame q k x δ δ_t accepts with exact probability q⁻¹.

      theorem Cslib.Crypto.Protocols.MPC.InputConsistency.probability_vecLinearCombCheckGame_eq {q k : ℕ} [Fact (Nat.Prime q)] (x : Fin k → ZMod q) {δ : Fin k → ZMod q} (hδ : δ ≠ 0) (δ_t : ZMod q) :
      ((vecLinearCombCheckGame q k x δ δ_t).eval true).toReal = 1 / ↑q

      Real-valued exact 1 / q soundness for vecLinearCombCheckGame when δ ≠ 0.

      Batched MAC verification predicate for k SPDZ authenticated shares under global MAC key α and random linear-combination weights r : Fin k → ZMod p: ∑ j, r j * γ_j = α * ∑ j, r j * (a_j + δ_j), the MAC relation SPDZ.AuthShare.Valid α of the r-weighted combination of the shares.

      Instances For
        @[instance_reducible]
        theorem Cslib.Crypto.Protocols.MPC.InputConsistency.batchMacCheckPasses_tamperParty_iff {p n k : ℕ} {alpha : ZMod p} {s : Fin k → SPDZ.AuthShare p n} (hs : ∀ (j : Fin k), SPDZ.AuthShare.Valid alpha (s j)) (i : Fin n) (r δ_x δ_t : Fin k → ZMod p) :
        (batchMacCheckPasses alpha r fun (j : Fin k) => (s j).tamperParty i (δ_x j) (δ_t j)) ↔ alpha * ∑ j : Fin k, r j * δ_x j = ∑ j : Fin k, r j * δ_t j

        Batched scalar-MAC tampering equivalence: when every s j is valid under α, party i's tampering by (δ_x, δ_t) passes batchMacCheckPasses alpha r if and only if α * ∑ j, r j * δ_x j = ∑ j, r j * δ_t j.

        Batched k-share MAC check game: samples a fresh uniform MAC key α ← $ᵗ ZMod q and fresh uniform linear-combination weights r ← $ᵗ (Fin k → ZMod q), generates uniform two-party authenticated sharings mkAuthShare2 of each x j, lets corrupt party 1 add (δ_x j, δ_t j) to its shares of the j-th input, and checks batchMacCheckPasses alpha r.

        Honest shares (δ_x = 0, δ_t = 0) pass vecBatchMacCheckGame with probability 1.

        theorem Cslib.Crypto.Protocols.MPC.InputConsistency.probability_vecBatchMacCheckGame_le {q k : ℕ} [Fact (Nat.Prime q)] (x : Fin k → ZMod q) {δ_x : Fin k → ZMod q} (hδ : δ_x ≠ 0) (δ_t : Fin k → ZMod q) :
        ((vecBatchMacCheckGame q k x δ_x δ_t).eval true).toReal ≤ 2 / ↑q

        Batched k-share scalar-MAC soundness (≤ 2 / q): for prime q and any nonzero input tampering vector δ_x ≠ 0, vecBatchMacCheckGame q k x δ_x δ_t passes with probability at most 2 / q; this is SPDZ.probability_macCheckSoundnessGame_le applied to the cheating equation the tampering induces.