Documentation

CslibFrontier.Crypto.Computational.LinearSigmaProtocol

Fair-coin commitment and special-HVZK transfer for linear Sigma protocols #

In SigmaProtocol.linear ([BS23], Sections 19.1 and 19.5.1–19.5.4), the honest prover draws its commitment nonce from the exact uniform distribution on the witness module at the PMF level. Over a PrimeOrderGroupFamily, a strict PPT machine with fair coins cannot sample ZMod q with zero error when q is not a power of two; instead it samples s ← F.sampleExp n d and reads s mod q, within statistical distance 1 / 2 ^ n of uniform (closeTo_uniform_sampleExp).

This module equips any single-scalar SigmaProtocol.linear family over a PrimeOrderGroupFamily with that fair-coin commitment sampler (linearProbCommit, linearProbFamily) and proves the completeness and honest-verifier zero-knowledge transfer theorems once, consumed by both Schnorr's protocol (CslibFrontier.Crypto.Computational.SchnorrProtocol) and the Chaum–Pedersen protocol (CslibFrontier.Crypto.Computational.ChaumPedersenProtocol).

Main definitions #

Main results #

References #

noncomputable def Cslib.Crypto.PrimeOrderGroupFamily.linearProbCommit (F : PrimeOrderGroupFamily) {Y N : ℕ × F.Desc → Type} [(i : ℕ × F.Desc) → AddCommGroup (N i)] [(i : ℕ × F.Desc) → Module (ZMod (F.order i.2)) (N i)] (ψ : (i : ℕ × F.Desc) → Y i → ZMod (F.order i.2) →ₗ[ZMod (F.order i.2)] N i) (i : ℕ × F.Desc) :
ZMod (F.order i.2) → (y : Y i) → ProbComp (N i × ZMod (F.order i.2))

Fair-coin commitment sampler for SigmaProtocol.linear over a PrimeOrderGroupFamily: at index i = (n, d), draw s ← F.sampleExp n d, read r = s mod q, and return (ψ i y r, r).

noncomputable def Cslib.Crypto.PrimeOrderGroupFamily.linearProbFamily (F : PrimeOrderGroupFamily) {Y N C : ℕ × F.Desc → Type} [(i : ℕ × F.Desc) → AddCommGroup (N i)] [(i : ℕ × F.Desc) → Module (ZMod (F.order i.2)) (N i)] [(i : ℕ × F.Desc) → DecidableEq (N i)] (ψ : (i : ℕ × F.Desc) → Y i → ZMod (F.order i.2) →ₗ[ZMod (F.order i.2)] N i) (u : (i : ℕ × F.Desc) → Y i → N i) (ι : (i : ℕ × F.Desc) → C i ↪ ZMod (F.order i.2)) (i : ℕ × F.Desc) :
Protocols.SigmaProtocol (ZMod (F.order i.2)) (Y i) (N i) (C i) (ZMod (F.order i.2))

SigmaProtocol.linear over ZMod q with its commitment nonce sampled from fair coins by sampleExp (linearProbCommit).

theorem Cslib.Crypto.PrimeOrderGroupFamily.closeTo_transcript_linearProbFamily (F : PrimeOrderGroupFamily) {Y N C : ℕ × F.Desc → Type} [(i : ℕ × F.Desc) → AddCommGroup (N i)] [(i : ℕ × F.Desc) → Module (ZMod (F.order i.2)) (N i)] [(i : ℕ × F.Desc) → DecidableEq (N i)] (ψ : (i : ℕ × F.Desc) → Y i → ZMod (F.order i.2) →ₗ[ZMod (F.order i.2)] N i) (u : (i : ℕ × F.Desc) → Y i → N i) (ι : (i : ℕ × F.Desc) → C i ↪ ZMod (F.order i.2)) (i : ℕ × F.Desc) (x : ZMod (F.order i.2)) (y : Y i) (c : C i) :
Probability.CloseTo ((Protocols.SigmaProtocol.linear (ψ i) (u i) (ι i)).transcript x y c) ((F.linearProbFamily ψ u ι i).transcript x y c) ↑(1 / 2 ^ i.1)

The honest transcript of linearProbFamily is within statistical distance 1 / 2 ^ n of the ideal-nonce SigmaProtocol.linear transcript at every index i = (n, d), witness, statement and challenge.

theorem Cslib.Crypto.PrimeOrderGroupFamily.linearProbFamily_complete (F : PrimeOrderGroupFamily) {Y N C : ℕ × F.Desc → Type} [(i : ℕ × F.Desc) → AddCommGroup (N i)] [(i : ℕ × F.Desc) → Module (ZMod (F.order i.2)) (N i)] [(i : ℕ × F.Desc) → DecidableEq (N i)] (ψ : (i : ℕ × F.Desc) → Y i → ZMod (F.order i.2) →ₗ[ZMod (F.order i.2)] N i) (u : (i : ℕ × F.Desc) → Y i → N i) (ι : (i : ℕ × F.Desc) → C i ↪ ZMod (F.order i.2)) (i : ℕ × F.Desc) :
(F.linearProbFamily ψ u ι i).Complete fun (x : ZMod (F.order i.2)) (y : Y i) => (ψ i y) x = u i y

Completeness of linearProbFamily ([BS23], Theorem 19.12 with Definition 19.3).

theorem Cslib.Crypto.PrimeOrderGroupFamily.closeTo_transcript_linearProbFamily_simulator (F : PrimeOrderGroupFamily) {Y N C : ℕ × F.Desc → Type} [(i : ℕ × F.Desc) → AddCommGroup (N i)] [(i : ℕ × F.Desc) → Module (ZMod (F.order i.2)) (N i)] [(i : ℕ × F.Desc) → DecidableEq (N i)] {ψ : (i : ℕ × F.Desc) → Y i → ZMod (F.order i.2) →ₗ[ZMod (F.order i.2)] N i} {u : (i : ℕ × F.Desc) → Y i → N i} {ι : (i : ℕ × F.Desc) → C i ↪ ZMod (F.order i.2)} {R : (i : ℕ × F.Desc) → ZMod (F.order i.2) → Y i → Prop} {simulate : (i : ℕ × F.Desc) → Y i → C i → PMF (N i × ZMod (F.order i.2))} {sim : Protocols.SigmaProtocol.Simulator (ℕ × F.Desc) Y N C fun (i : ℕ × F.Desc) => ZMod (F.order i.2)} (hS : ∀ (i : ℕ × F.Desc), (Protocols.SigmaProtocol.linear (ψ i) (u i) (ι i)).SpecialHVZK (R i) (simulate i)) (hreal : Protocols.SigmaProtocol.SimulatorRealizedBy simulate sim fun (i : ℕ × F.Desc) => 1 / 2 ^ i.1) {i : ℕ × F.Desc} {x : ZMod (F.order i.2)} {y : Y i} (hxy : R i x y) (c : C i) :
Probability.CloseTo ((F.linearProbFamily ψ u ι i).transcript x y c) (sim i y c).eval (2 / 2 ^ i.1)

When sim realizes a perfect simulator for linear (ψ i) (u i) (ι i) up to 1 / 2 ^ n, its output is within statistical distance 2 / 2 ^ n of the honest transcript of linearProbFamily on every valid pair and challenge.

theorem Cslib.Crypto.PrimeOrderGroupFamily.advantage_chvzkGame_linearProbFamily_le (F : PrimeOrderGroupFamily) {Y N C : ℕ × F.Desc → Type} {σ : Type} [(i : ℕ × F.Desc) → AddCommGroup (N i)] [(i : ℕ × F.Desc) → Module (ZMod (F.order i.2)) (N i)] [(i : ℕ × F.Desc) → DecidableEq (N i)] [(i : ℕ × F.Desc) → Fintype (C i)] [∀ (i : ℕ × F.Desc), Nonempty (C i)] {ψ : (i : ℕ × F.Desc) → Y i → ZMod (F.order i.2) →ₗ[ZMod (F.order i.2)] N i} {u : (i : ℕ × F.Desc) → Y i → N i} {ι : (i : ℕ × F.Desc) → C i ↪ ZMod (F.order i.2)} {R : (i : ℕ × F.Desc) → ZMod (F.order i.2) → Y i → Prop} {simulate : (i : ℕ × F.Desc) → Y i → C i → PMF (N i × ZMod (F.order i.2))} {sim : Protocols.SigmaProtocol.Simulator (ℕ × F.Desc) Y N C fun (i : ℕ × F.Desc) => ZMod (F.order i.2)} (hS : ∀ (i : ℕ × F.Desc), (Protocols.SigmaProtocol.linear (ψ i) (u i) (ι i)).SpecialHVZK (R i) (simulate i)) (hreal : Protocols.SigmaProtocol.SimulatorRealizedBy simulate sim fun (i : ℕ × F.Desc) => 1 / 2 ^ i.1) (setup : ℕ → PMF F.Desc) (A : Protocols.SigmaProtocol.CHVZKAdversary (ℕ × F.Desc) (fun (i : ℕ × F.Desc) => ZMod (F.order i.2)) Y N C (fun (i : ℕ × F.Desc) => ZMod (F.order i.2)) σ) (n : ℕ) :
(Protocols.SigmaProtocol.chvzkRealGame (F.linearProbFamily ψ u ι) R (fun (m : ℕ) => PMF.map (fun (x : F.Desc) => (m, x)) (setup m)) A n).advantage (Protocols.SigmaProtocol.chvzkSimGame R (fun (m : ℕ) => PMF.map (fun (x : F.Desc) => (m, x)) (setup m)) sim A n) ≤ 2 / 2 ^ n

When sim realizes a perfect simulator for linear (ψ i) (u i) (ι i) up to 1 / 2 ^ n, Attack Game 20.4 distinguishing advantage for linearProbFamily over (setup m).map (m, ·) is at most 2 / 2 ^ n against every adversary (including computationally unbounded ones).

theorem Cslib.Crypto.PrimeOrderGroupFamily.computationalSpecialHVZK_linearProbFamily (F : PrimeOrderGroupFamily) {Y N C : ℕ × F.Desc → Type} [(i : ℕ × F.Desc) → AddCommGroup (N i)] [(i : ℕ × F.Desc) → Module (ZMod (F.order i.2)) (N i)] [(i : ℕ × F.Desc) → DecidableEq (N i)] [(i : ℕ × F.Desc) → Fintype (C i)] [∀ (i : ℕ × F.Desc), Nonempty (C i)] {ψ : (i : ℕ × F.Desc) → Y i → ZMod (F.order i.2) →ₗ[ZMod (F.order i.2)] N i} {u : (i : ℕ × F.Desc) → Y i → N i} {ι : (i : ℕ × F.Desc) → C i ↪ ZMod (F.order i.2)} {R : (i : ℕ × F.Desc) → ZMod (F.order i.2) → Y i → Prop} {enc : Protocols.SigmaProtocol.Encoding (ℕ × F.Desc) Y N C fun (i : ℕ × F.Desc) => ZMod (F.order i.2)} {encW : (i : ℕ × F.Desc) → ZMod (F.order i.2) ↪ List Bool} {setup : ℕ → PMF F.Desc} {sim : Protocols.SigmaProtocol.Simulator (ℕ × F.Desc) Y N C fun (i : ℕ × F.Desc) => ZMod (F.order i.2)} {δ : ℕ × F.Desc → ENNReal} (h : Protocols.SigmaProtocol.ComputationalSpecialHVZK (fun (i : ℕ × F.Desc) => Protocols.SigmaProtocol.linear (ψ i) (u i) (ι i)) R enc encW (fun (n : ℕ) => PMF.map (fun (x : F.Desc) => (n, x)) (setup n)) sim δ) :
Protocols.SigmaProtocol.ComputationalSpecialHVZK (F.linearProbFamily ψ u ι) R enc encW (fun (n : ℕ) => PMF.map (fun (x : F.Desc) => (n, x)) (setup n)) sim δ

Transfer ComputationalSpecialHVZK from the ideal-nonce SigmaProtocol.linear family to the fair-coin linearProbFamily over (setup n).map (n, ·), preserving the simulator and acceptance error.