Documentation

CslibFrontier.Crypto.Protocols.SecretSharing.Shamir.Linear

Shamir Secret-Sharing Algebraic Homomorphisms, Multiplicative Property, and Marginal Uniformity #

This module extends Cslib.Crypto.Protocols.SecretSharing.Shamir with the linear and multiplicative algebraic homomorphisms of Shamir secret sharing, Lagrange weight functional identities at zero, and unauthorized-coalition marginal uniformity ([Sha79]; [BOGW88]; [GRR98]; [AL17]; [Gol04]; [KL20]):

  1. Shamir Algebraic Homomorphisms and Lagrange Weights at Zero:
  2. Multiplicative Property of Shamir Shares ($2t < |\text{Party}|$):
  3. Lagrange Share Interpolation and Unauthorized-Coalition Marginal Uniformity:
    • Given any unauthorized coalition $I \subseteq \text{Party}$ with $|I| \le t$, secret $y$, and target coalition shares $\sigma : I \to F$, interpCoeffs params I hI y σ interpolates a degree-$< t$ tail polynomial whose shares of $y$ restrict to $\sigma$ on $I$ (share_interpCoeffs).
    • Via uniformOfFintype_map_addHom, the zero-secret restriction homomorphism shareZeroRestrictHom params I is surjective for $|I| \le t$, so for every secret $y \in F$ the marginal distribution of $I$'s Shamir shares under uniform randomness is uniform on $I \to F$ (uniformOfFintype_map_restrict_share).

Main definitions #

Main results #

References #

1. Polynomial and Lagrange reconstruction linearity #

@[simp]

Polynomial.tailPolynomial maps the zero coefficient vector to the zero polynomial.

Polynomial.tailPolynomial is F-linear with respect to scalar multiplication.

theorem Cslib.Crypto.Protocols.SecretSharing.Shamir.Polynomial.tailPolynomial_sum {F : Type u_1} [Field F] {ι : Type u_2} (S : Finset ι) (n : ℕ) (f : ι → Fin n → F) :
tailPolynomial n (∑ j ∈ S, f j) = ∑ j ∈ S, tailPolynomial n (f j)

Polynomial.tailPolynomial commutes with finite sums of coefficient vectors.

@[simp]

The sharing polynomial with zero secret and zero tail is the zero polynomial.

theorem Cslib.Crypto.Protocols.SecretSharing.Shamir.Polynomial.sharingPolynomial_add {F : Type u_1} [Field F] (s₁ s₂ : F) (t₁ t₂ : Polynomial F) :
sharingPolynomial (s₁ + s₂) (t₁ + t₂) = sharingPolynomial s₁ t₁ + sharingPolynomial s₂ t₂

Polynomial.sharingPolynomial is additive in the secret and tail polynomial.

Polynomial.sharingPolynomial is homogeneous under scalar multiplication by c : F.

theorem Cslib.Crypto.Protocols.SecretSharing.Shamir.Polynomial.sharingPolynomial_sum {F : Type u_1} [Field F] {ι : Type u_2} (S : Finset ι) (s : ι → F) (t : ι → Polynomial F) :
sharingPolynomial (∑ j ∈ S, s j) (∑ j ∈ S, t j) = ∑ j ∈ S, sharingPolynomial (s j) (t j)

Polynomial.sharingPolynomial commutes with finite sums of secrets and tail polynomials.

noncomputable def Cslib.Crypto.Protocols.SecretSharing.Shamir.Polynomial.lagrangeWeightAtZero {F : Type u_1} [Field F] {ι : Type u_2} [Fintype ι] (x : ι → F) (i : ι) :
F

Explicit Lagrange interpolation weight at 0 for evaluation points x : ι → F: the constant coefficient of the i-th Lagrange basis polynomial over Finset.univ.

Polynomial.reconstruct is the F-linear combination of share values weighted by lagrangeWeightAtZero.

theorem Cslib.Crypto.Protocols.SecretSharing.Shamir.Polynomial.lagrangeWeightAtZero_ne_zero {F : Type u_1} [Field F] {ι : Type u_2} [Fintype ι] {x : ι → F} (hinj : Function.Injective x) (hnz : ∀ (i : ι), x i ≠ 0) (i : ι) :

The Lagrange interpolation weight at 0 for x : ι → F is nonzero whenever x is injective and takes nonzero values (specialization of Lagrange.eval_basis_ne_zero at 0).

theorem Cslib.Crypto.Protocols.SecretSharing.Shamir.Polynomial.reconstruct_single {F : Type u_1} [Field F] {ι : Type u_2} [Fintype ι] [DecidableEq ι] (x : ι → F) (i : ι) (c : F) :

Reconstructing a single-coordinate vector Pi.single i c evaluates to c times the Lagrange weight at 0.

@[simp]

Reconstructing the zero share vector returns 0.

theorem Cslib.Crypto.Protocols.SecretSharing.Shamir.Polynomial.reconstruct_add {F : Type u_1} [Field F] {ι : Type u_2} [Fintype ι] (x σ₁ σ₂ : ι → F) :
reconstruct x (σ₁ + σ₂) = reconstruct x σ₁ + reconstruct x σ₂

Polynomial.reconstruct is additive in the share vector σ.

theorem Cslib.Crypto.Protocols.SecretSharing.Shamir.Polynomial.reconstruct_smul {F : Type u_1} [Field F] {ι : Type u_2} [Fintype ι] (x : ι → F) (c : F) (σ : ι → F) :
reconstruct x (c • σ) = c * reconstruct x σ

Polynomial.reconstruct is homogeneous with respect to scalar multiplication.

theorem Cslib.Crypto.Protocols.SecretSharing.Shamir.Polynomial.reconstruct_sum {F : Type u_1} [Field F] {ι : Type u_2} {κ : Type u_3} [Fintype ι] (S : Finset κ) (x : ι → F) (σ : κ → ι → F) :
reconstruct x (∑ k ∈ S, σ k) = ∑ k ∈ S, reconstruct x (σ k)

Polynomial.reconstruct commutes with finite sums of share vectors.

@[simp]
theorem Cslib.Crypto.Protocols.SecretSharing.Shamir.Polynomial.reconstruct_share_eq_secret {F : Type u_1} [Field F] {Party : Type u_2} [Fintype Party] (params : Params F Party) (coeffs : Randomness params) (secretValue : F) :
(reconstruct params.point fun (i : Party) => share params coeffs secretValue i) = secretValue

Reconstructing a Shamir sharing across all parties via Polynomial.reconstruct params.point recovers secretValue.

2. Shamir secret-sharing algebraic homomorphisms #

@[simp]
theorem Cslib.Crypto.Protocols.SecretSharing.Shamir.share_zero_randomness {F : Type u_1} {Party : Type u_2} [Field F] [Fintype Party] (params : Params F Party) (s : F) (i : Party) :
share params 0 s i = s

Sharing secret s with zero randomness gives constant share s at every party.

theorem Cslib.Crypto.Protocols.SecretSharing.Shamir.share_zero {F : Type u_1} {Party : Type u_2} [Field F] [Fintype Party] (params : Params F Party) (i : Party) :
share params 0 0 i = 0

Sharing secret 0 with zero randomness gives share 0 at every party.

theorem Cslib.Crypto.Protocols.SecretSharing.Shamir.share_add {F : Type u_1} {Party : Type u_2} [Field F] [Fintype Party] (params : Params F Party) (r₁ r₂ : Randomness params) (s₁ s₂ : F) (i : Party) :
share params (r₁ + r₂) (s₁ + s₂) i = share params r₁ s₁ i + share params r₂ s₂ i

Additive homomorphism of Shamir sharing ([AL17], Section 4.1, addition gates): adding two share values at party i produces party i's share of s₁ + s₂ under randomness r₁ + r₂.

theorem Cslib.Crypto.Protocols.SecretSharing.Shamir.share_smul {F : Type u_1} {Party : Type u_2} [Field F] [Fintype Party] (params : Params F Party) (c : F) (r : Randomness params) (s : F) (i : Party) :
share params (c • r) (c * s) i = c * share params r s i

Scalar-multiplication homomorphism of Shamir sharing: scaling party i's share by c produces party i's share of c * s under randomness c • r.

theorem Cslib.Crypto.Protocols.SecretSharing.Shamir.share_add_const {F : Type u_1} {Party : Type u_2} [Field F] [Fintype Party] (params : Params F Party) (r : Randomness params) (s c : F) (i : Party) :
share params r (s + c) i = share params r s i + c

Adding a public constant c to party i's share shifts the shared secret by c under the same randomness r.

theorem Cslib.Crypto.Protocols.SecretSharing.Shamir.share_sum {F : Type u_1} {Party : Type u_2} [Field F] [Fintype Party] {ι : Type u_3} (S : Finset ι) (params : Params F Party) (r : ι → Randomness params) (s : ι → F) (i : Party) :
share params (∑ j ∈ S, r j) (∑ j ∈ S, s j) i = ∑ j ∈ S, share params (r j) (s j) i

Multi-party summation homomorphism of Shamir sharing: summing shares across a finite index set S yields the share of ∑ j ∈ S, s j under randomness ∑ j ∈ S, r j.

@[simp]
theorem Cslib.Crypto.Protocols.SecretSharing.Shamir.reconstruct_zero {F : Type u_1} {Party : Type u_2} [Field F] [Fintype Party] (params : Params F Party) (s : Finset Party) :
reconstruct params s 0 = 0

Reconstructing the zero coalition share vector returns 0.

theorem Cslib.Crypto.Protocols.SecretSharing.Shamir.reconstruct_add {F : Type u_1} {Party : Type u_2} [Field F] [Fintype Party] (params : Params F Party) (s : Finset Party) (σ₁ σ₂ : ↥s → F) :
reconstruct params s (σ₁ + σ₂) = reconstruct params s σ₁ + reconstruct params s σ₂

Shamir.reconstruct is additive in the coalition's share vector.

theorem Cslib.Crypto.Protocols.SecretSharing.Shamir.reconstruct_smul {F : Type u_1} {Party : Type u_2} [Field F] [Fintype Party] (params : Params F Party) (s : Finset Party) (c : F) (σ : ↥s → F) :
reconstruct params s (c • σ) = c * reconstruct params s σ

Shamir.reconstruct commutes with scalar multiplication of the coalition's share vector.

theorem Cslib.Crypto.Protocols.SecretSharing.Shamir.reconstruct_sum {F : Type u_1} {Party : Type u_2} [Field F] [Fintype Party] {κ : Type u_3} (S : Finset κ) (params : Params F Party) (s : Finset Party) (σ : κ → ↥s → F) :
reconstruct params s (∑ k ∈ S, σ k) = ∑ k ∈ S, reconstruct params s (σ k)

Shamir.reconstruct commutes with finite sums of coalition share vectors.

@[simp]
theorem Cslib.Crypto.Protocols.SecretSharing.Shamir.reconstruct_share_eq_secret {F : Type u_1} {Party : Type u_2} [Field F] [Fintype Party] (params : Params F Party) (coeffs : Randomness params) (secretValue : F) {s : Finset Party} (hs : authorized params s) :
(reconstruct params s fun (i : ↥s) => share params coeffs secretValue ↑i) = secretValue

Reconstructing a Shamir sharing over any authorized coalition s (params.threshold + 1 ≤ s.card) recovers secretValue directly, without requiring a TailSampler.

theorem Cslib.Crypto.Protocols.SecretSharing.Shamir.reconstruct_share_add {F : Type u_1} {Party : Type u_2} [Field F] [Fintype Party] (params : Params F Party) (r₁ r₂ : Randomness params) (s₁ s₂ : F) {s : Finset Party} (hs : authorized params s) :
(reconstruct params s fun (i : ↥s) => share params r₁ s₁ ↑i + share params r₂ s₂ ↑i) = s₁ + s₂

Reconstructing the pointwise sum of two Shamir sharings over any authorized coalition s recovers the sum of the secrets s₁ + s₂.

theorem Cslib.Crypto.Protocols.SecretSharing.Shamir.reconstruct_share_smul {F : Type u_1} {Party : Type u_2} [Field F] [Fintype Party] (params : Params F Party) (c : F) (r : Randomness params) (secretValue : F) {s : Finset Party} (hs : authorized params s) :
(reconstruct params s fun (i : ↥s) => c * share params r secretValue ↑i) = c * secretValue

Reconstructing a scalar multiple of a Shamir sharing over any authorized coalition s recovers c * secretValue.

theorem Cslib.Crypto.Protocols.SecretSharing.Shamir.reconstruct_share_sum {F : Type u_1} {Party : Type u_2} [Field F] [Fintype Party] {κ : Type u_3} (S : Finset κ) (params : Params F Party) (r : κ → Randomness params) (sec : κ → F) {s : Finset Party} (hs : authorized params s) :
(reconstruct params s fun (i : ↥s) => ∑ k ∈ S, share params (r k) (sec k) ↑i) = ∑ k ∈ S, sec k

Reconstructing the pointwise sum of a finite family of Shamir sharings over any authorized coalition s recovers the sum of the secrets.

3. Multiplicative property of Shamir shares #

noncomputable def Cslib.Crypto.Protocols.SecretSharing.Shamir.mulTailPolynomial {F : Type u_1} [Field F] (a : F) (t₁ : Polynomial F) (b : F) (t₂ : Polynomial F) :

Tail polynomial of the product of two Shamir sharing polynomials sharingPolynomial a t₁ * sharingPolynomial b t₂.

Multiplying two Shamir sharing polynomials with secrets a and b yields a Shamir sharing polynomial with secret a * b and tail mulTailPolynomial a t₁ b t₂.

theorem Cslib.Crypto.Protocols.SecretSharing.Shamir.degree_mulTailPolynomial_lt {F : Type u_1} [Field F] {t : ℕ} (a : F) {t₁ : Polynomial F} (ht₁ : t₁.degree < ↑t) (b : F) {t₂ : Polynomial F} (ht₂ : t₂.degree < ↑t) :
(mulTailPolynomial a t₁ b t₂).degree < 2 * ↑t

If t₁ and t₂ have degree < t, then mulTailPolynomial a t₁ b t₂ has degree < 2 * t.

noncomputable def Cslib.Crypto.Protocols.SecretSharing.Shamir.mulTailCoeffs {F : Type u_1} [Field F] {t : ℕ} (a : F) (r₁ : Fin t → F) (b : F) (r₂ : Fin t → F) :
Fin (2 * t) → F

Coefficient vector in Fin (2 * t) → F of the degree-< 2 * t tail polynomial of the product of two degree-$\le t$ Shamir sharing polynomials.

@[simp]
theorem Cslib.Crypto.Protocols.SecretSharing.Shamir.tailPolynomial_mulTailCoeffs {F : Type u_1} [Field F] {t : ℕ} (a : F) (r₁ : Fin t → F) (b : F) (r₂ : Fin t → F) :

Multiplying two degree-$\le t$ Shamir sharing polynomials produces the degree-$\le 2t$ Shamir sharing polynomial with secret a * b and tail coefficients mulTailCoeffs a r₁ b r₂.

theorem Cslib.Crypto.Protocols.SecretSharing.Shamir.eval_sharingPolynomial_mul {F : Type u_1} {Party : Type u_2} [Field F] [Fintype Party] (params : Params F Party) (r₁ r₂ : Randomness params) (a b : F) (i : Party) :
Polynomial.eval (params.point i) (Polynomial.sharingPolynomial (a * b) (Polynomial.tailPolynomial (2 * params.threshold) (mulTailCoeffs a r₁ b r₂))) = share params r₁ a i * share params r₂ b i

Pointwise product of party i's degree-$t$ Shamir shares of a and b equals the evaluation at params.point i of the degree-$\le 2t$ sharing polynomial with secret a * b and tail coefficients mulTailCoeffs a r₁ b r₂.

theorem Cslib.Crypto.Protocols.SecretSharing.Shamir.reconstruct_mul_share_eq_mul {F : Type u_1} {Party : Type u_2} [Field F] [Fintype Party] (params : Params F Party) (h2t : 2 * params.threshold < Fintype.card Party) (r₁ r₂ : Randomness params) (a b : F) :
(Polynomial.reconstruct params.point fun (i : Party) => share params r₁ a i * share params r₂ b i) = a * b

When 2 * params.threshold < Fintype.card Party ($t < n / 2$), Lagrange reconstruction of the pointwise product of degree-$t$ Shamir shares over Party recovers a * b.

4. Lagrange share interpolation and unauthorized-coalition marginal uniformity #

noncomputable def Cslib.Crypto.Protocols.SecretSharing.Shamir.interpTailPolynomial {F : Type u_1} {Party : Type u_2} [Field F] [Fintype Party] (params : Params F Party) (I : Finset Party) (y : F) (σ : ↥I → F) :

Interpolating tail polynomial of degree < |I| that maps each i : I to (σ i - y) / params.point i, so that sharingPolynomial y evaluates to σ i at params.point i.

theorem Cslib.Crypto.Protocols.SecretSharing.Shamir.interpTailPolynomial_eval {F : Type u_1} {Party : Type u_2} [Field F] [Fintype Party] (params : Params F Party) (I : Finset Party) (y : F) (σ : ↥I → F) (i : ↥I) :
Polynomial.eval (params.point ↑i) (interpTailPolynomial params I y σ) = (σ i - y) / params.point ↑i
theorem Cslib.Crypto.Protocols.SecretSharing.Shamir.interpTailPolynomial_degree_lt {F : Type u_1} {Party : Type u_2} [Field F] [Fintype Party] (params : Params F Party) (I : Finset Party) (hI : I.card ≤ params.threshold) (y : F) (σ : ↥I → F) :
(interpTailPolynomial params I y σ).degree < ↑params.threshold
noncomputable def Cslib.Crypto.Protocols.SecretSharing.Shamir.interpCoeffs {F : Type u_1} {Party : Type u_2} [Field F] [Fintype Party] (params : Params F Party) (I : Finset Party) (hI : I.card ≤ params.threshold) (y : F) (σ : ↥I → F) :
Randomness params

Coefficient vector in Randomness params interpolating target shares σ : I → F on an unauthorized coalition I (I.card ≤ params.threshold) for secret y : F.

@[simp]
theorem Cslib.Crypto.Protocols.SecretSharing.Shamir.tailPolynomial_interpCoeffs {F : Type u_1} {Party : Type u_2} [Field F] [Fintype Party] (params : Params F Party) (I : Finset Party) (hI : I.card ≤ params.threshold) (y : F) (σ : ↥I → F) :
@[simp]
theorem Cslib.Crypto.Protocols.SecretSharing.Shamir.share_interpCoeffs {F : Type u_1} {Party : Type u_2} [Field F] [Fintype Party] (params : Params F Party) (I : Finset Party) (hI : I.card ≤ params.threshold) (y : F) (σ : ↥I → F) (i : ↥I) :
share params (interpCoeffs params I hI y σ) y ↑i = σ i

Sharing secret y with randomness interpCoeffs params I hI y σ reproduces σ i at every coalition member i : I.

noncomputable def Cslib.Crypto.Protocols.SecretSharing.Shamir.shareZeroRestrictHom {F : Type u_1} {Party : Type u_2} [Field F] [Fintype Party] (params : Params F Party) (I : Finset Party) :
Randomness params →+ ↥I → F

Additive group homomorphism restricting a zero-secret Shamir sharing to a coalition I.

theorem Cslib.Crypto.Protocols.SecretSharing.Shamir.shareZeroRestrictHom_surjective {F : Type u_1} {Party : Type u_2} [Field F] [Fintype Party] (params : Params F Party) (I : Finset Party) (hI : I.card ≤ params.threshold) :

For any unauthorized coalition I (I.card ≤ params.threshold), shareZeroRestrictHom is surjective.

theorem Cslib.Crypto.Protocols.SecretSharing.Shamir.uniformOfFintype_map_restrict_share {F : Type u_1} {Party : Type u_2} [Field F] [Fintype Party] [Fintype F] [DecidableEq Party] (params : Params F Party) (I : Finset Party) (hI : I.card ≤ params.threshold) (secret : F) :
PMF.map (fun (coeffs : Randomness params) (i : ↥I) => share params coeffs secret ↑i) (Probability.PMF.uniformOfFintype (Randomness params)) = Probability.PMF.uniformOfFintype (↥I → F)

Unauthorized-Coalition Marginal Uniformity ([Sha79]; [AL17], Section 3.2, Claim 3.2): for any coalition I with I.card ≤ params.threshold and any secret secret : F, the restriction of share params coeffs secret to I under uniform coeffs : Randomness params is uniformly distributed on I → F.