Documentation

CslibFrontier.Crypto.Protocols.SigmaProtocol.Composition

AND, OR, and parallel composition of Sigma protocols #

Two Sigma protocols with a common challenge type combine into protocols proving knowledge of witnesses for both statements, or for at least one of them, without revealing which ([BS23], Section 19.7). A single Sigma protocol also composes with itself in k-fold parallel repetition on the same statement with independent challenges Fin k → C ([BS23], Exercise 19.6, pp. 810–811; our parallelRepetition allows k = 0, whereas Exercise 19.6 assumes k ≥ 1).

The AND-proof runs both protocols in parallel and sends the same challenge to both. The OR-proof needs the challenges to form a finite additive group; Boneh and Shoup use {0, 1}ⁿ with exclusive or, which is the bit-string group with +. A prover with a witness for one statement simulates the other side with a challenge of its own choice, and answers the verifier's challenge c by splitting it as c₀ + c₁. A witness for the OR relation is Sum.inl x₀ or Sum.inr x₁. The honest OR prover is determined by the challenge sampler (orProofWith, specialized to exact uniform by orProof) and the two simulators. In k-fold parallel repetition (parallelRepetition), the prover draws k independent commitments, answers each coordinate challenge c j independently, and extraction uses the first coordinate j : Fin k where the two challenge tuples differ.

This module supplies the transcript identities and structural preservation laws. The polynomial-time extractor and strict-PPT simulator preservation results are in CslibFrontier.Crypto.Protocols.SigmaProtocol.Efficient: those are the efficient counterparts of Theorems 19.18–19.19 and Exercise 19.6(b–c). Exact special HVZK corresponds to their zero-error specializations.

Main definitions #

Main results #

References #

AND #

noncomputable def Cslib.Crypto.Protocols.SigmaProtocol.andProof {X₀ Y₀ T₀ Z₀ X₁ Y₁ T₁ Z₁ C : Type u} (P₀ : SigmaProtocol X₀ Y₀ T₀ C Z₀) (P₁ : SigmaProtocol X₁ Y₁ T₁ C Z₁) :
SigmaProtocol (X₀ × X₁) (Y₀ × Y₁) (T₀ × T₁) C (Z₀ × Z₁)

The AND-proof ([BS23], Section 19.7.1): commit with both provers and answer the shared challenge with both.

def Cslib.Crypto.Protocols.SigmaProtocol.andExtract {Y₀ T₀ Z₀ Y₁ T₁ Z₁ C W₀ W₁ : Type u} (extract₀ : Y₀ → T₀ → C → Z₀ → C → Z₀ → W₀) (extract₁ : Y₁ → T₁ → C → Z₁ → C → Z₁ → W₁) (y : Y₀ × Y₁) (t : T₀ × T₁) (c : C) (z : Z₀ × Z₁) (c' : C) (z' : Z₀ × Z₁) :
W₀ × W₁

The AND extractor applies each extractor to its half of the conversations.

noncomputable def Cslib.Crypto.Protocols.SigmaProtocol.andSimulate {Y₀ T₀ Z₀ Y₁ T₁ Z₁ C : Type u} (simulate₀ : Y₀ → C → PMF (T₀ × Z₀)) (simulate₁ : Y₁ → C → PMF (T₁ × Z₁)) (y : Y₀ × Y₁) (c : C) :
PMF ((T₀ × T₁) × Z₀ × Z₁)

The AND simulator runs both simulators independently at the shared challenge.

@[simp]
theorem Cslib.Crypto.Protocols.SigmaProtocol.andProof_accepts_iff {X₀ Y₀ T₀ Z₀ X₁ Y₁ T₁ Z₁ C : Type u} {P₀ : SigmaProtocol X₀ Y₀ T₀ C Z₀} {P₁ : SigmaProtocol X₁ Y₁ T₁ C Z₁} {y : Y₀ × Y₁} {t : T₀ × T₁} {c : C} {z : Z₀ × Z₁} :
(P₀.andProof P₁).Accepts y t c z ↔ P₀.Accepts y.1 t.1 c z.1 ∧ P₁.Accepts y.2 t.2 c z.2

An AND conversation is accepting exactly when both halves are accepting at the shared challenge.

theorem Cslib.Crypto.Protocols.SigmaProtocol.andProof_transcript {X₀ Y₀ T₀ Z₀ X₁ Y₁ T₁ Z₁ C : Type u} {P₀ : SigmaProtocol X₀ Y₀ T₀ C Z₀} {P₁ : SigmaProtocol X₁ Y₁ T₁ C Z₁} (x : X₀ × X₁) (y : Y₀ × Y₁) (c : C) :
(P₀.andProof P₁).transcript x y c = do let a ← P₀.transcript x.1 y.1 c let b ← P₁.transcript x.2 y.2 c pure ((a.1, b.1), a.2, b.2)

The AND-proof's honest transcript pairs independent honest transcripts at the shared challenge.

theorem Cslib.Crypto.Protocols.SigmaProtocol.andProof_complete {X₀ Y₀ T₀ Z₀ X₁ Y₁ T₁ Z₁ C : Type u} {P₀ : SigmaProtocol X₀ Y₀ T₀ C Z₀} {P₁ : SigmaProtocol X₁ Y₁ T₁ C Z₁} {R₀ : X₀ → Y₀ → Prop} {R₁ : X₁ → Y₁ → Prop} (h₀ : P₀.Complete R₀) (h₁ : P₁.Complete R₁) :
(P₀.andProof P₁).Complete fun (x : X₀ × X₁) (y : Y₀ × Y₁) => R₀ x.1 y.1 ∧ R₁ x.2 y.2

Completeness of the AND construction.

theorem Cslib.Crypto.Protocols.SigmaProtocol.andProof_specialSoundness {X₀ Y₀ T₀ Z₀ X₁ Y₁ T₁ Z₁ C : Type u} {P₀ : SigmaProtocol X₀ Y₀ T₀ C Z₀} {P₁ : SigmaProtocol X₁ Y₁ T₁ C Z₁} {W₀ W₁ : Type u} {R₀' : W₀ → Y₀ → Prop} {R₁' : W₁ → Y₁ → Prop} {extract₀ : Y₀ → T₀ → C → Z₀ → C → Z₀ → W₀} {extract₁ : Y₁ → T₁ → C → Z₁ → C → Z₁ → W₁} (h₀ : P₀.SpecialSoundness R₀' extract₀) (h₁ : P₁.SpecialSoundness R₁' extract₁) :
(P₀.andProof P₁).SpecialSoundness (fun (x : W₀ × W₁) (y : Y₀ × Y₁) => R₀' x.1 y.1 ∧ R₁' x.2 y.2) (andExtract extract₀ extract₁)

Structural special soundness of the AND construction. Polynomial-time extraction is preserved by EfficientSpecialSoundness.andProof in the efficient API.

theorem Cslib.Crypto.Protocols.SigmaProtocol.andProof_specialHVZK {X₀ Y₀ T₀ Z₀ X₁ Y₁ T₁ Z₁ C : Type u} {P₀ : SigmaProtocol X₀ Y₀ T₀ C Z₀} {P₁ : SigmaProtocol X₁ Y₁ T₁ C Z₁} {R₀ : X₀ → Y₀ → Prop} {R₁ : X₁ → Y₁ → Prop} {simulate₀ : Y₀ → C → PMF (T₀ × Z₀)} {simulate₁ : Y₁ → C → PMF (T₁ × Z₁)} (h₀ : P₀.SpecialHVZK R₀ simulate₀) (h₁ : P₁.SpecialHVZK R₁ simulate₁) :
(P₀.andProof P₁).SpecialHVZK (fun (x : X₀ × X₁) (y : Y₀ × Y₁) => R₀ x.1 y.1 ∧ R₁ x.2 y.2) (andSimulate simulate₀ simulate₁)

Exact transcript simulation for the AND construction. Strict-PPT simulation is preserved by EfficientSpecialHVZK.andProof in the efficient API.

OR #

def Cslib.Crypto.Protocols.SigmaProtocol.orRelation {X₀ Y₀ X₁ Y₁ : Type u} (R₀ : X₀ → Y₀ → Prop) (R₁ : X₁ → Y₁ → Prop) :
X₀ ⊕ X₁ → Y₀ × Y₁ → Prop

The OR relation: a witness for the first statement or a witness for the second ([BS23], Equation 19.23).

noncomputable def Cslib.Crypto.Protocols.SigmaProtocol.orProofWith {X₀ Y₀ T₀ Z₀ X₁ Y₁ T₁ Z₁ C : Type u} [AddCommGroup C] (sampleChallenge : PMF C) (P₀ : SigmaProtocol X₀ Y₀ T₀ C Z₀) (P₁ : SigmaProtocol X₁ Y₁ T₁ C Z₁) (simulate₀ : Y₀ → C → PMF (T₀ × Z₀)) (simulate₁ : Y₁ → C → PMF (T₁ × Z₁)) :
SigmaProtocol (X₀ ⊕ X₁) (Y₀ × Y₁) (T₀ × T₁) C (C × Z₀ × Z₁)

The OR-proof ([BS23], Section 19.7.2, pp. 788–789) parameterized by the challenge sampler sampleChallenge for the simulated side. With a witness for one side, the prover draws c' ← sampleChallenge, simulates the other side at c', commits honestly on its own side, and answers the verifier's challenge c on its own side at c - c'. The response (c₀, z₀, z₁) names the first side's challenge; the second side's is c - c₀.

@[reducible, inline]
noncomputable abbrev Cslib.Crypto.Protocols.SigmaProtocol.orProof {X₀ Y₀ T₀ Z₀ X₁ Y₁ T₁ Z₁ C : Type u} [AddCommGroup C] [Fintype C] (P₀ : SigmaProtocol X₀ Y₀ T₀ C Z₀) (P₁ : SigmaProtocol X₁ Y₁ T₁ C Z₁) (simulate₀ : Y₀ → C → PMF (T₀ × Z₀)) (simulate₁ : Y₁ → C → PMF (T₁ × Z₁)) :
SigmaProtocol (X₀ ⊕ X₁) (Y₀ × Y₁) (T₀ × T₁) C (C × Z₀ × Z₁)

The ideal-challenge OR-proof ([BS23], Section 19.7.2): orProofWith with the simulated side's challenge drawn from PMF.uniformOfFintype C.

def Cslib.Crypto.Protocols.SigmaProtocol.orExtract {Y₀ T₀ Z₀ Y₁ T₁ Z₁ C : Type u} [AddCommGroup C] [DecidableEq C] {W₀ W₁ : Type u} (extract₀ : Y₀ → T₀ → C → Z₀ → C → Z₀ → W₀) (extract₁ : Y₁ → T₁ → C → Z₁ → C → Z₁ → W₁) (y : Y₀ × Y₁) (t : T₀ × T₁) (c : C) (z : C × Z₀ × Z₁) (c' : C) (z' : C × Z₀ × Z₁) :
W₀ ⊕ W₁

The OR extractor uses the first side when the first side's challenges differ, and the second side otherwise.

noncomputable def Cslib.Crypto.Protocols.SigmaProtocol.orSimulate {Y₀ T₀ Z₀ Y₁ T₁ Z₁ C : Type u} [AddCommGroup C] [Fintype C] (simulate₀ : Y₀ → C → PMF (T₀ × Z₀)) (simulate₁ : Y₁ → C → PMF (T₁ × Z₁)) (y : Y₀ × Y₁) (c : C) :
PMF ((T₀ × T₁) × C × Z₀ × Z₁)

The OR simulator splits the challenge uniformly and simulates both sides.

@[simp]
theorem Cslib.Crypto.Protocols.SigmaProtocol.orProofWith_accepts_iff {X₀ Y₀ T₀ Z₀ X₁ Y₁ T₁ Z₁ C : Type u} [AddCommGroup C] {sampleChallenge : PMF C} {P₀ : SigmaProtocol X₀ Y₀ T₀ C Z₀} {P₁ : SigmaProtocol X₁ Y₁ T₁ C Z₁} {simulate₀ : Y₀ → C → PMF (T₀ × Z₀)} {simulate₁ : Y₁ → C → PMF (T₁ × Z₁)} {y : Y₀ × Y₁} {t : T₀ × T₁} {c c₀ : C} {z₀ : Z₀} {z₁ : Z₁} :
(orProofWith sampleChallenge P₀ P₁ simulate₀ simulate₁).Accepts y t c (c₀, z₀, z₁) ↔ P₀.Accepts y.1 t.1 c₀ z₀ ∧ P₁.Accepts y.2 t.2 (c - c₀) z₁

An OR conversation (c₀, z₀, z₁) for the challenge c is accepting exactly when the first side accepts at c₀ and the second at c - c₀.

theorem Cslib.Crypto.Protocols.SigmaProtocol.orProofWith_transcript_inl {X₀ Y₀ T₀ Z₀ X₁ Y₁ T₁ Z₁ C : Type u} [AddCommGroup C] {sampleChallenge : PMF C} {P₀ : SigmaProtocol X₀ Y₀ T₀ C Z₀} {P₁ : SigmaProtocol X₁ Y₁ T₁ C Z₁} {simulate₀ : Y₀ → C → PMF (T₀ × Z₀)} {simulate₁ : Y₁ → C → PMF (T₁ × Z₁)} (x : X₀) (y : Y₀ × Y₁) (c : C) :
(orProofWith sampleChallenge P₀ P₁ simulate₀ simulate₁).transcript (Sum.inl x) y c = do let c₁ ← sampleChallenge let b ← simulate₁ y.2 c₁ let a ← P₀.transcript x y.1 (c - c₁) pure ((a.1, b.1), c - c₁, a.2, b.2)

With a witness for the first statement, orProofWith draws c₁ ← sampleChallenge, simulates the second side at c₁, and answers honestly on the first side at c - c₁.

theorem Cslib.Crypto.Protocols.SigmaProtocol.orProofWith_transcript_inr {X₀ Y₀ T₀ Z₀ X₁ Y₁ T₁ Z₁ C : Type u} [AddCommGroup C] {sampleChallenge : PMF C} {P₀ : SigmaProtocol X₀ Y₀ T₀ C Z₀} {P₁ : SigmaProtocol X₁ Y₁ T₁ C Z₁} {simulate₀ : Y₀ → C → PMF (T₀ × Z₀)} {simulate₁ : Y₁ → C → PMF (T₁ × Z₁)} (x : X₁) (y : Y₀ × Y₁) (c : C) :
(orProofWith sampleChallenge P₀ P₁ simulate₀ simulate₁).transcript (Sum.inr x) y c = do let c₀ ← sampleChallenge let a ← simulate₀ y.1 c₀ let b ← P₁.transcript x y.2 (c - c₀) pure ((a.1, b.1), c₀, a.2, b.2)

With a witness for the second statement, orProofWith draws c₀ ← sampleChallenge, simulates the first side at c₀, and answers honestly on the second side at c - c₀.

theorem Cslib.Crypto.Protocols.SigmaProtocol.orProofWith_complete {X₀ Y₀ T₀ Z₀ X₁ Y₁ T₁ Z₁ C : Type u} [AddCommGroup C] {sampleChallenge : PMF C} {P₀ : SigmaProtocol X₀ Y₀ T₀ C Z₀} {P₁ : SigmaProtocol X₁ Y₁ T₁ C Z₁} {R₀ : X₀ → Y₀ → Prop} {R₁ : X₁ → Y₁ → Prop} {simulate₀ : Y₀ → C → PMF (T₀ × Z₀)} {simulate₁ : Y₁ → C → PMF (T₁ × Z₁)} (h₀ : P₀.Complete R₀) (h₁ : P₁.Complete R₁) (hs₀ : ∀ (y₀ : Y₀) (c₀ : C), ∀ tz ∈ (simulate₀ y₀ c₀).support, P₀.Accepts y₀ tz.1 c₀ tz.2) (hs₁ : ∀ (y₁ : Y₁) (c₁ : C), ∀ tz ∈ (simulate₁ y₁ c₁).support, P₁.Accepts y₁ tz.1 c₁ tz.2) :
(orProofWith sampleChallenge P₀ P₁ simulate₀ simulate₁).Complete (orRelation R₀ R₁)

Completeness of orProofWith, assuming only that both component provers are complete and every conversation in the support of simulate₀ or simulate₁ is accepting ([BS23], Theorem 19.19 proof, p. 789).

theorem Cslib.Crypto.Protocols.SigmaProtocol.orProof_complete {X₀ Y₀ T₀ Z₀ X₁ Y₁ T₁ Z₁ C : Type u} [AddCommGroup C] {P₀ : SigmaProtocol X₀ Y₀ T₀ C Z₀} {P₁ : SigmaProtocol X₁ Y₁ T₁ C Z₁} {R₀ : X₀ → Y₀ → Prop} {R₁ : X₁ → Y₁ → Prop} {simulate₀ : Y₀ → C → PMF (T₀ × Z₀)} {simulate₁ : Y₁ → C → PMF (T₁ × Z₁)} [Fintype C] (h₀ : P₀.Complete R₀) (h₁ : P₁.Complete R₁) (hs₀ : P₀.SpecialHVZK R₀ simulate₀) (hs₁ : P₁.SpecialHVZK R₁ simulate₁) :
(P₀.orProof P₁ simulate₀ simulate₁).Complete (orRelation R₀ R₁)

Completeness of the OR construction, using that both SpecialHVZK simulators output accepting conversations.

theorem Cslib.Crypto.Protocols.SigmaProtocol.orProofWith_specialSoundness {X₀ Y₀ T₀ Z₀ X₁ Y₁ T₁ Z₁ C : Type u} [AddCommGroup C] {sampleChallenge : PMF C} {P₀ : SigmaProtocol X₀ Y₀ T₀ C Z₀} {P₁ : SigmaProtocol X₁ Y₁ T₁ C Z₁} {simulate₀ : Y₀ → C → PMF (T₀ × Z₀)} {simulate₁ : Y₁ → C → PMF (T₁ × Z₁)} [DecidableEq C] {W₀ W₁ : Type u} {R₀' : W₀ → Y₀ → Prop} {R₁' : W₁ → Y₁ → Prop} {extract₀ : Y₀ → T₀ → C → Z₀ → C → Z₀ → W₀} {extract₁ : Y₁ → T₁ → C → Z₁ → C → Z₁ → W₁} (h₀ : P₀.SpecialSoundness R₀' extract₀) (h₁ : P₁.SpecialSoundness R₁' extract₁) :
(orProofWith sampleChallenge P₀ P₁ simulate₀ simulate₁).SpecialSoundness (orRelation R₀' R₁') (orExtract extract₀ extract₁)

Structural special soundness of orProofWith (and hence orProof): distinct challenges differ on the first side or the second. EfficientSpecialSoundness.orProof certifies the constructed extractor.

theorem Cslib.Crypto.Protocols.SigmaProtocol.orProof_specialHVZK {X₀ Y₀ T₀ Z₀ X₁ Y₁ T₁ Z₁ C : Type u} [AddCommGroup C] {P₀ : SigmaProtocol X₀ Y₀ T₀ C Z₀} {P₁ : SigmaProtocol X₁ Y₁ T₁ C Z₁} {R₀ : X₀ → Y₀ → Prop} {R₁ : X₁ → Y₁ → Prop} {simulate₀ : Y₀ → C → PMF (T₀ × Z₀)} {simulate₁ : Y₁ → C → PMF (T₁ × Z₁)} [Fintype C] (hs₀ : P₀.SpecialHVZK R₀ simulate₀) (hs₁ : P₁.SpecialHVZK R₁ simulate₁) :
(P₀.orProof P₁ simulate₀ simulate₁).SpecialHVZK (orRelation R₀ R₁) (orSimulate simulate₀ simulate₁)

Exact transcript simulation for the OR construction: the honest prover's own-side challenge c - c' is uniform. EfficientSpecialHVZK.orProof certifies the constructed simulator.

Parallel repetition #

noncomputable def Cslib.Crypto.Protocols.SigmaProtocol.parallelRepetition {C X Y T Z : Type u} (P : SigmaProtocol X Y T C Z) (k : ℕ) :
SigmaProtocol X Y (Fin k → T) (Fin k → C) (Fin k → Z)

k-fold parallel repetition of a Sigma protocol P on the same statement with independent challenges ([BS23], Exercise 19.6, pp. 810–811; allowing k = 0): commit k independent times, answer each coordinate challenge c j independently, and verify all k coordinates.

def Cslib.Crypto.Protocols.SigmaProtocol.parallelExtract {C Y T Z : Type u} [DecidableEq C] {W : Type u} [Inhabited W] (extract : Y → T → C → Z → C → Z → W) (k : ℕ) (y : Y) (t : Fin k → T) (c : Fin k → C) (z : Fin k → Z) (c' : Fin k → C) (z' : Fin k → Z) :
W

The parallel-repetition extractor finds the first coordinate j : Fin k where the two challenge tuples differ and runs extract on that coordinate's conversations. On equal challenge tuples it uses coordinate zero when k > 0, and default only when k = 0.

noncomputable def Cslib.Crypto.Protocols.SigmaProtocol.parallelSimulate {C Y T Z : Type u} (simulate : Y → C → PMF (T × Z)) (k : ℕ) (y : Y) (c : Fin k → C) :
PMF ((Fin k → T) × (Fin k → Z))

The parallel-repetition simulator runs simulate independently at each coordinate challenge c j.

@[simp]
theorem Cslib.Crypto.Protocols.SigmaProtocol.parallelRepetition_accepts_iff {C X Y T Z : Type u} {P : SigmaProtocol X Y T C Z} {k : ℕ} {y : Y} {t : Fin k → T} {c : Fin k → C} {z : Fin k → Z} :
(P.parallelRepetition k).Accepts y t c z ↔ ∀ (j : Fin k), P.Accepts y (t j) (c j) (z j)

A parallel-repetition conversation is accepting iff every coordinate conversation is accepting.

theorem Cslib.Crypto.Protocols.SigmaProtocol.parallelRepetition_transcript {C X Y T Z : Type u} {P : SigmaProtocol X Y T C Z} (k : ℕ) (x : X) (y : Y) (c : Fin k → C) :
(P.parallelRepetition k).transcript x y c = PMF.map (fun (tz : Fin k → T × Z) => (fun (j : Fin k) => (tz j).1, fun (j : Fin k) => (tz j).2)) (Probability.PMF.piFin fun (j : Fin k) => P.transcript x y (c j))

The honest transcript of parallelRepetition is the coordinatewise product of the honest transcripts at c j.

theorem Cslib.Crypto.Protocols.SigmaProtocol.parallelRepetition_complete {C X Y T Z : Type u} {P : SigmaProtocol X Y T C Z} {R : X → Y → Prop} {k : ℕ} (h : P.Complete R) :

Completeness is preserved under k-fold parallel repetition.

theorem Cslib.Crypto.Protocols.SigmaProtocol.parallelRepetition_specialSoundness {C X Y T Z : Type u} {P : SigmaProtocol X Y T C Z} [DecidableEq C] {W : Type u} [Inhabited W] {k : ℕ} {R' : W → Y → Prop} {extract : Y → T → C → Z → C → Z → W} (h : P.SpecialSoundness R' extract) :

Special soundness is preserved under k-fold parallel repetition: two distinct challenge tuples c ≠ c' must differ at some coordinate j : Fin k.

theorem Cslib.Crypto.Protocols.SigmaProtocol.parallelRepetition_specialHVZK {C X Y T Z : Type u} {P : SigmaProtocol X Y T C Z} {R : X → Y → Prop} {k : ℕ} {simulate : Y → C → PMF (T × Z)} (h : P.SpecialHVZK R simulate) :

Special honest-verifier zero knowledge is preserved under k-fold parallel repetition.