Documentation

CslibFrontier.Crypto.Protocols.SigmaProtocol.Efficient

Efficient special soundness and special HVZK #

SigmaProtocol.SpecialSoundness and SigmaProtocol.SpecialHVZK name their extractor and simulator but accept arbitrary functions and distributions. Boneh and Shoup require an efficient deterministic extractor (Definition 19.4) and an efficient probabilistic simulator (Definition 19.5). Without that requirement the notions say little: a Sigma protocol has some extractor exactly when two accepting conversations with a common commitment and distinct challenges certify that the statement has a witness, and for a relation in which every statement has exactly one witness, even the protocol that reveals its witness is special HVZK (test module CslibFrontierTests.UnboundedSimulators). This module adds the efficient variants; the test module CslibFrontierTests.EfficientSimulators shows that, under the discrete-logarithm assumption, they rule out both examples.

Efficiency is uniform over a family P i of Sigma protocols indexed by i : I, typically a unary security parameter together with a system parameter such as a group description ([BS23], Definition 2.9). The types of statements, commitments, challenges and responses may depend on the index, so the algorithms are certified on words, through the encodings collected in a SigmaProtocol.Encoding.

Both variants contain the exact property at every index with the same extractor or simulator, so every theorem about SpecialSoundness and SpecialHVZK applies to them. An efficient simulator is δ i-close to honest transcripts (SimulatorRealizedBy.closeTo_transcript) and outputs an accepting conversation except with probability δ i (SimulatorRealizedBy.one_sub_le_accepts), which relaxes Definition 19.5 (i). A simulator certified by Simulator.IsPPT is computed on words by a uniform strict PPT program that agrees with it on every encoded input (Simulator.IsPPT.exists_word), and conversely a word program that agrees with a typed simulator certifies it (Simulator.IsPPT.of_word). Note that δ in EfficientSpecialHVZK is an unconstrained parameter of the predicate rather than a bundled Negligible condition: at δ i ≥ 1 (since event probabilities are at most 1), SimulatorRealizedBy holds trivially for every simulator, reducing EfficientSpecialHVZK to the unbounded SpecialHVZK field (not_efficientSpecialHVZK_sendWitness in CslibFrontierTests.EfficientSimulators requires δ i ≤ 1 / 2). Computational special HVZK ([BS23], Definition 20.6) is defined in CslibFrontier.Crypto.Protocols.SigmaProtocol.Computational (SigmaProtocol.ComputationalSpecialHVZK); when δ is bounded along the setup distribution by a negligible function, EfficientSpecialHVZK.exists_computationalSpecialHVZK derives it.

Main definitions #

Main results #

References #

structure Cslib.Crypto.Protocols.SigmaProtocol.Encoding (I : Type) (Y T C Z : I → Type) :

Word encodings for a family of Sigma protocols indexed by I, with statements in Y i, commitments in T i, challenges in C i and responses in Z i at the index i.

  • index : I ↪ List Bool

    The index, such as a unary security parameter with a system parameter.

  • statement (i : I) : Y i ↪ List Bool

    The statements at each index.

  • commitment (i : I) : T i ↪ List Bool

    The commitments at each index.

  • challenge (i : I) : C i ↪ List Bool

    The challenges at each index.

  • response (i : I) : Z i ↪ List Bool

    The responses at each index.

def Cslib.Crypto.Protocols.SigmaProtocol.ExtractorRealizedBy {I : Type} {Y T C Z W : I → Type} (enc : Encoding I Y T C Z) (encW : (i : I) → W i ↪ List Bool) (extract : (i : I) → Y i → T i → C i → Z i → C i → Z i → W i) (f : I × List Bool × List Bool × List Bool × List Bool × List Bool × List Bool → List Bool) :

The word function f computes the extractor family extract on encodings: from the index, the encoded statement and the encoded conversations (t, c, z) and (t, c', z'), it returns the encoded witness.

The input of a special HVZK simulator: an index, a statement and a challenge at that index.

  • index : I

    The index.

  • statement : Y self.index

    The statement.

  • challenge : C self.index

    The challenge.

theorem Cslib.Crypto.Protocols.SigmaProtocol.encSimulatorInput_index_length_le {I : Type} {Y T C Z : I → Type} (enc : Encoding I Y T C Z) (a : SimulatorInput I Y C) :
(enc.index ((fun (a : SimulatorInput I Y C) => a.index) a)).length ≤ ((encSimulatorInput enc) a).length
theorem Cslib.Crypto.Protocols.SigmaProtocol.encSimulatorInput_index_budget {I : Type} {Y T C Z : I → Type} (enc : Encoding I Y T C Z) {γ✝ : Type} {encIn✝ : γ✝ ↪ List Bool} {S✝ : γ✝ → ℕ} {g✝ : γ✝ → SimulatorInput I Y C} :
Turing.MultiTapeTM.ComputableInSpace g✝ encIn✝ (encSimulatorInput enc) S✝ → Turing.MultiTapeTM.ComputableInSpace (fun (c : γ✝) => (g✝ c).index) encIn✝ enc.index S✝
theorem Cslib.Crypto.Protocols.SigmaProtocol.encSimulatorInput_challenge_budget {I : Type} {Y T C Z : I → Type} (enc : Encoding I Y T C Z) {γ✝ : Type} {encIn✝ : γ✝ ↪ List Bool} {S✝ : γ✝ → ℕ} {g✝ : γ✝ → SimulatorInput I Y C} :
Turing.MultiTapeTM.ComputableInSpace g✝ encIn✝ (encSimulatorInput enc) S✝ → Turing.MultiTapeTM.ComputableInSpace (fun (c : γ✝) => (enc.challenge (g✝ c).index) (g✝ c).challenge) encIn✝ Turing.MultiTapeTM.encBits S✝
@[reducible, inline]

The tuple of the fields of encSimulatorInput.

theorem Cslib.Crypto.Protocols.SigmaProtocol.encSimulatorInput_index_polyTime {I : Type} {Y T C Z : I → Type} (enc : Encoding I Y T C Z) {γ✝ : Type} {encIn✝ : γ✝ ↪ List Bool} {g✝ : γ✝ → SimulatorInput I Y C} :
Turing.MultiTapeTM.ComputableInPolyTime g✝ encIn✝ (encSimulatorInput enc) → Turing.MultiTapeTM.ComputableInPolyTime (fun (c : γ✝) => (g✝ c).index) encIn✝ enc.index
theorem Cslib.Crypto.Protocols.SigmaProtocol.encSimulatorInput_statement_polyTime {I : Type} {Y T C Z : I → Type} (enc : Encoding I Y T C Z) {γ✝ : Type} {encIn✝ : γ✝ ↪ List Bool} {g✝ : γ✝ → SimulatorInput I Y C} :
theorem Cslib.Crypto.Protocols.SigmaProtocol.encSimulatorInput_challenge_polyTime {I : Type} {Y T C Z : I → Type} (enc : Encoding I Y T C Z) {γ✝ : Type} {encIn✝ : γ✝ ↪ List Bool} {g✝ : γ✝ → SimulatorInput I Y C} :
theorem Cslib.Crypto.Protocols.SigmaProtocol.encSimulatorInput_statement_budget {I : Type} {Y T C Z : I → Type} (enc : Encoding I Y T C Z) {γ✝ : Type} {encIn✝ : γ✝ ↪ List Bool} {S✝ : γ✝ → ℕ} {g✝ : γ✝ → SimulatorInput I Y C} :
Turing.MultiTapeTM.ComputableInSpace g✝ encIn✝ (encSimulatorInput enc) S✝ → Turing.MultiTapeTM.ComputableInSpace (fun (c : γ✝) => (enc.statement (g✝ c).index) (g✝ c).statement) encIn✝ Turing.MultiTapeTM.encBits S✝
theorem Cslib.Crypto.Protocols.SigmaProtocol.encSimulatorInput_index_inO {I : Type} {Y T C Z : I → Type} (enc : Encoding I Y T C Z) :
Turing.MultiTapeTM.ComputableInO (fun (a : SimulatorInput I Y C) => a.index) (encSimulatorInput enc) enc.index (fun (a : SimulatorInput I Y C) => ((encSimulatorInput enc) a).length) fun (a : SimulatorInput I Y C) => ((encSimulatorInput enc) a).length

The encoding of a simulator's input: the index, then the words of the statement and the challenge under enc at that index, each framed except the last (encSimulatorInput_apply).

theorem Cslib.Crypto.Protocols.SigmaProtocol.encSimulatorInput_mk_inO {I : Type} {Y T C Z : I → Type} (enc : Encoding I Y T C Z) {γ : Type} {encIn : γ ↪ List Bool} {x0 : γ → I} {T0 S0 : γ → ℕ} {x1 : (c : γ) → Y (x0 c)} {T1 S1 : γ → ℕ} {x2 : (c : γ) → C (x0 c)} {T2 S2 : γ → ℕ} (h0 : Turing.MultiTapeTM.ComputableInO x0 encIn enc.index T0 S0) (h1 : Turing.MultiTapeTM.ComputableInO (fun (c : γ) => (enc.statement (x0 c)) (x1 c)) encIn Turing.MultiTapeTM.encBits T1 S1) (h2 : Turing.MultiTapeTM.ComputableInO (fun (c : γ) => (enc.challenge (x0 c)) (x2 c)) encIn Turing.MultiTapeTM.encBits T2 S2) :
Turing.MultiTapeTM.ComputableInO (fun (x : γ) => { index := x0 x, statement := x1 x, challenge := x2 x }) encIn (encSimulatorInput enc) (fun (x : γ) => T0 x + (T1 x + T2 x)) fun (x : γ) => S0 x + (S1 x + S2 x)
theorem Cslib.Crypto.Protocols.SigmaProtocol.encSimulatorInput_mk_polyTime {I : Type} {Y T C Z : I → Type} (enc : Encoding I Y T C Z) {γ : Type} {encIn : γ ↪ List Bool} {x0 : γ → I} {x1 : (c : γ) → Y (x0 c)} {x2 : (c : γ) → C (x0 c)} (h0 : Turing.MultiTapeTM.ComputableInPolyTime x0 encIn enc.index) (h1 : Turing.MultiTapeTM.ComputableInPolyTime (fun (c : γ) => (enc.statement (x0 c)) (x1 c)) encIn Turing.MultiTapeTM.encBits) (h2 : Turing.MultiTapeTM.ComputableInPolyTime (fun (c : γ) => (enc.challenge (x0 c)) (x2 c)) encIn Turing.MultiTapeTM.encBits) :
Turing.MultiTapeTM.ComputableInPolyTime (fun (x : γ) => { index := x0 x, statement := x1 x, challenge := x2 x }) encIn (encSimulatorInput enc)
theorem Cslib.Crypto.Protocols.SigmaProtocol.encSimulatorInput_mk_budget {I : Type} {Y T C Z : I → Type} (enc : Encoding I Y T C Z) {γ : Type} {encIn : γ ↪ List Bool} {budget : γ → ℕ} {x0 : γ → I} {x1 : (c : γ) → Y (x0 c)} {x2 : (c : γ) → C (x0 c)} (h0 : Turing.MultiTapeTM.ComputableInSpace x0 encIn enc.index budget) (h1 : Turing.MultiTapeTM.ComputableInSpace (fun (c : γ) => (enc.statement (x0 c)) (x1 c)) encIn Turing.MultiTapeTM.encBits budget) (h2 : Turing.MultiTapeTM.ComputableInSpace (fun (c : γ) => (enc.challenge (x0 c)) (x2 c)) encIn Turing.MultiTapeTM.encBits budget) :
Turing.MultiTapeTM.ComputableInSpace (fun (x : γ) => { index := x0 x, statement := x1 x, challenge := x2 x }) encIn (encSimulatorInput enc) budget
@[reducible, inline]

A family of special HVZK simulators: at index i, a probabilistic program from a statement and a challenge to a commitment and a response. Simulator.IsPPT states its efficiency on encodings.

def Cslib.Crypto.Protocols.SigmaProtocol.Simulator.IsPPT {I : Type} {Y T C Z : I → Type} (enc : Encoding I Y T C Z) (sim : Simulator I Y T C Z) :

A simulator family is uniform strict PPT: one machine reads encSimulatorInput enc and writes the encoded commitment and response, framing the commitment.

@[reducible, inline]

Input (i, y, c) of a word program computing a special HVZK simulator: the index i encoded by encI, then the encoded statement and the encoded challenge as bit words. The index and the statement are framed.

def Cslib.Crypto.Protocols.SigmaProtocol.WordSimulatorRealizedBy {I : Type} {Y T C Z : I → Type} (enc : Encoding I Y T C Z) (simulate : (i : I) → Y i → C i → PMF (T i × Z i)) (program : I × List Bool × List Bool → ProbComp (List Bool × List Bool)) (δ : I → ENNReal) :

The word program program realizes the simulator family simulate on encodings up to statistical distance δ: on the index, the encoded statement and the encoded challenge, its output is within δ i of the encoded commitment and response sampled by simulate i. This is the word-level form of SimulatorRealizedBy that SimulatorRealizedBy.exists_word provides.

theorem Cslib.Crypto.Protocols.SigmaProtocol.isPPTOn_encSimulatorInput_of_word {I : Type} {Y T C Z : I → Type} {β : Type} {out : β ↪ List Bool} (enc : Encoding I Y T C Z) {typed : SimulatorInput I Y C → ProbComp β} {program : I × List Bool × List Bool → ProbComp β} (hprogram : Probability.IsPPTOn (encSimulatorWordInput enc.index) out program) (heq : ∀ (s : SimulatorInput I Y C), (typed s).eval = (program (s.index, (enc.statement s.index) s.statement, (enc.challenge s.index) s.challenge)).eval) :

A uniform strict PPT word program on the index and the encoded statement and challenge that computes a typed program on encodings certifies the typed program. Its output type β and its output encoding out are arbitrary, so this also certifies simulators with aborts.

theorem Cslib.Crypto.Protocols.SigmaProtocol.Simulator.IsPPT.of_word {I : Type} {Y T C Z : I → Type} {enc : Encoding I Y T C Z} {sim : Simulator I Y T C Z} {program : I × List Bool × List Bool → ProbComp (List Bool × List Bool)} (hprogram : Probability.IsPPTOn (encSimulatorWordInput enc.index) (Turing.MultiTapeTM.encPair Turing.MultiTapeTM.encBits Turing.MultiTapeTM.encBits) program) (heq : ∀ (i : I) (y : Y i) (c : C i), PMF.map (Prod.map ⇑(enc.commitment i) ⇑(enc.response i)) (sim i y c).eval = (program (i, (enc.statement i) y, (enc.challenge i) c)).eval) :
IsPPT enc sim

A uniform strict PPT word program that computes a typed simulator on encodings certifies it.

theorem Cslib.Crypto.Protocols.SigmaProtocol.Simulator.IsPPT.exists_word {I : Type} {Y T C Z : I → Type} {enc : Encoding I Y T C Z} {sim : Simulator I Y T C Z} (h : IsPPT enc sim) :
∃ (program : I × List Bool × List Bool → ProbComp (List Bool × List Bool)), Probability.IsPPTOn (encSimulatorWordInput enc.index) (Turing.MultiTapeTM.encPair Turing.MultiTapeTM.encBits Turing.MultiTapeTM.encBits) program ∧ ∀ (i : I) (y : Y i) (c : C i), PMF.map (Prod.map ⇑(enc.commitment i) ⇑(enc.response i)) (sim i y c).eval = (program (i, (enc.statement i) y, (enc.challenge i) c)).eval

A uniform strict PPT simulator family is computed on words by a uniform strict PPT program of the index and arbitrary statement and challenge words, which agrees with it on every encoded input.

def Cslib.Crypto.Protocols.SigmaProtocol.SimulatorRealizedBy {I : Type} {Y C O : I → Type} (simulate : (i : I) → Y i → C i → PMF (O i)) (sim : (i : I) → Y i → C i → ProbComp (O i)) (δ : I → ENNReal) :

The typed simulator family sim realizes the family of distributions simulate up to statistical distance δ: on every statement and challenge at index i, its output law is within δ i of simulate i. The outputs O i are commitment-response pairs for EfficientSpecialHVZK and optional pairs for simulators with aborts.

theorem Cslib.Crypto.Protocols.SigmaProtocol.SimulatorRealizedBy.exists_word {I : Type} {Y T C Z : I → Type} {enc : Encoding I Y T C Z} {simulate : (i : I) → Y i → C i → PMF (T i × Z i)} {sim : Simulator I Y T C Z} {δ : I → ENNReal} (h : SimulatorRealizedBy simulate sim δ) (hppt : Simulator.IsPPT enc sim) :

A uniform strict PPT simulator family within δ of simulate yields a uniform strict PPT word program of the index and arbitrary statement and challenge words whose output on every encoded input is within δ i of the encoded simulate i.

@[reducible, inline]

Input (i, y, t, c, z, c', z') of a word function computing a special-soundness extractor: the index i encoded by encI, then the encoded statement, commitment, and two challenge-response pairs as bit words.

@[reducible, inline]

Input (i, c, c₀) of a word function computing challenge subtraction for orProof: the index i encoded by encI, then the two encoded challenges as bit words.

structure Cslib.Crypto.Protocols.SigmaProtocol.EfficientSpecialSoundness {I : Type} {X Y T C Z W : I → Type} (P : (i : I) → SigmaProtocol (X i) (Y i) (T i) (C i) (Z i)) (R : (i : I) → W i → Y i → Prop) (enc : Encoding I Y T C Z) (encW : (i : I) → W i ↪ List Bool) (extract : (i : I) → Y i → T i → C i → Z i → C i → Z i → W i) :

Efficient special soundness ([BS23], Definition 19.4). At every index, extract i is a witness extractor for P i, and one deterministic polynomial-time function of the index and words computes the whole family on encodings. As in SpecialSoundness, the extracted witness has a type W i and a relation R i of its own.

structure Cslib.Crypto.Protocols.SigmaProtocol.EfficientSpecialHVZK {I : Type} {X Y T C Z : I → Type} (P : (i : I) → SigmaProtocol (X i) (Y i) (T i) (C i) (Z i)) (R : (i : I) → X i → Y i → Prop) (enc : Encoding I Y T C Z) (simulate : (i : I) → Y i → C i → PMF (T i × Z i)) (δ : I → ENNReal) :

Efficient special HVZK ([BS23], Definition 19.5), up to a statistical error δ. At every index, simulate i is a perfect special HVZK simulator for P i, and one uniform strict PPT simulator family realizes the whole family up to δ, for every statement and challenge.

  • specialHVZK (i : I) : (P i).SpecialHVZK (R i) (simulate i)

    simulate i is a perfect special HVZK simulator at every index.

  • realized : ∃ (sim : Simulator I Y T C Z), Simulator.IsPPT enc sim ∧ SimulatorRealizedBy simulate sim δ

    One uniform strict PPT simulator family realizes simulate up to δ.

theorem Cslib.Crypto.Protocols.SigmaProtocol.SimulatorRealizedBy.closeTo_transcript {I : Type} {X Y T C Z : I → Type} {P : (i : I) → SigmaProtocol (X i) (Y i) (T i) (C i) (Z i)} {R : (i : I) → X i → Y i → Prop} {simulate : (i : I) → Y i → C i → PMF (T i × Z i)} {sim : Simulator I Y T C Z} {δ : I → ENNReal} (hS : ∀ (i : I), (P i).SpecialHVZK (R i) (simulate i)) (h : SimulatorRealizedBy simulate sim δ) {i : I} {x : X i} {y : Y i} (hxy : R i x y) (c : C i) :
Probability.CloseTo ((P i).transcript x y c) (sim i y c).eval (δ i)

A simulator realizing a perfect simulator is δ i-close to the honest prover's commitment and response, for every witness-statement pair and every challenge.

theorem Cslib.Crypto.Protocols.SigmaProtocol.SimulatorRealizedBy.one_sub_le_accepts {I : Type} {X Y T C Z : I → Type} {P : (i : I) → SigmaProtocol (X i) (Y i) (T i) (C i) (Z i)} {R : (i : I) → X i → Y i → Prop} {simulate : (i : I) → Y i → C i → PMF (T i × Z i)} {sim : Simulator I Y T C Z} {δ : I → ENNReal} (hS : ∀ (i : I), (P i).SpecialHVZK (R i) (simulate i)) (h : SimulatorRealizedBy simulate sim δ) (i : I) (y : Y i) (c : C i) :
1 - δ i ≤ (sim i y c).eval.toOuterMeasure {tz : T i × Z i | (P i).Accepts y tz.1 c tz.2}

A simulator realizing a perfect simulator outputs an accepting conversation with probability at least 1 - δ i, for every statement and challenge (a relaxation of [BS23], Definition 19.5 (i)).

Efficiency transfer through andProof #

def Cslib.Crypto.Protocols.SigmaProtocol.Encoding.andProof {I : Type} {C Y₀ T₀ Z₀ Y₁ T₁ Z₁ : I → Type} (enc₀ : Encoding I Y₀ T₀ C Z₀) (enc₁ : Encoding I Y₁ T₁ C Z₁) :
Encoding I (fun (i : I) => Y₀ i × Y₁ i) (fun (i : I) => T₀ i × T₁ i) C fun (i : I) => Z₀ i × Z₁ i

Combined encodings for andProof: statements, commitments, and responses are paired with encPair, while the index and challenge encodings are taken from enc₀.

Word-level extractor for andProof: unframe the paired statement, commitment, and responses, run f₀ and f₁ on their respective halves at the shared challenges, and pair the encoded witnesses.

andExtractWord is computable in polynomial time when both component word extractors are and they share the same index encoding.

theorem Cslib.Crypto.Protocols.SigmaProtocol.extractorRealizedBy_andExtractWord {I : Type} {C Y₀ T₀ Z₀ W₀ Y₁ T₁ Z₁ W₁ : I → Type} {enc₀ : Encoding I Y₀ T₀ C Z₀} {enc₁ : Encoding I Y₁ T₁ C Z₁} (hC : ∀ (i : I), enc₀.challenge i = enc₁.challenge i) {encW₀ : (i : I) → W₀ i ↪ List Bool} {encW₁ : (i : I) → W₁ i ↪ List Bool} {extract₀ : (i : I) → Y₀ i → T₀ i → C i → Z₀ i → C i → Z₀ i → W₀ i} {extract₁ : (i : I) → Y₁ i → T₁ i → C i → Z₁ i → C i → Z₁ i → W₁ i} {f₀ f₁ : I × List Bool × List Bool × List Bool × List Bool × List Bool × List Bool → List Bool} (h₀ : ExtractorRealizedBy enc₀ encW₀ extract₀ f₀) (h₁ : ExtractorRealizedBy enc₁ encW₁ extract₁ f₁) :
ExtractorRealizedBy (enc₀.andProof enc₁) (fun (i : I) => Turing.MultiTapeTM.encPair (encW₀ i) (encW₁ i)) (fun (i : I) => andExtract (extract₀ i) (extract₁ i)) (andExtractWord f₀ f₁)

andExtractWord realizes andExtract on enc₀.andProof enc₁ when f₀ and f₁ realize extract₀ and extract₁ and share the same challenge encoding.

theorem Cslib.Crypto.Protocols.SigmaProtocol.EfficientSpecialSoundness.andProof {I : Type} {C X₀ Y₀ T₀ Z₀ W₀ X₁ Y₁ T₁ Z₁ W₁ : I → Type} {P₀ : (i : I) → SigmaProtocol (X₀ i) (Y₀ i) (T₀ i) (C i) (Z₀ i)} {P₁ : (i : I) → SigmaProtocol (X₁ i) (Y₁ i) (T₁ i) (C i) (Z₁ i)} {R₀ : (i : I) → W₀ i → Y₀ i → Prop} {R₁ : (i : I) → W₁ i → Y₁ i → Prop} {enc₀ : Encoding I Y₀ T₀ C Z₀} {enc₁ : Encoding I Y₁ T₁ C Z₁} {encW₀ : (i : I) → W₀ i ↪ List Bool} {encW₁ : (i : I) → W₁ i ↪ List Bool} {extract₀ : (i : I) → Y₀ i → T₀ i → C i → Z₀ i → C i → Z₀ i → W₀ i} {extract₁ : (i : I) → Y₁ i → T₁ i → C i → Z₁ i → C i → Z₁ i → W₁ i} (hI : enc₀.index = enc₁.index) (hC : ∀ (i : I), enc₀.challenge i = enc₁.challenge i) (h₀ : EfficientSpecialSoundness P₀ R₀ enc₀ encW₀ extract₀) (h₁ : EfficientSpecialSoundness P₁ R₁ enc₁ encW₁ extract₁) :
EfficientSpecialSoundness (fun (i : I) => (P₀ i).andProof (P₁ i)) (fun (i : I) (x : W₀ i × W₁ i) (y : Y₀ i × Y₁ i) => R₀ i x.1 y.1 ∧ R₁ i x.2 y.2) (enc₀.andProof enc₁) (fun (i : I) => Turing.MultiTapeTM.encPair (encW₀ i) (encW₁ i)) fun (i : I) => andExtract (extract₀ i) (extract₁ i)

Efficient special soundness of andProof.

def Cslib.Crypto.Protocols.SigmaProtocol.andSimulator {I : Type} {C Y₀ T₀ Z₀ Y₁ T₁ Z₁ : I → Type} (sim₀ : Simulator I Y₀ T₀ C Z₀) (sim₁ : Simulator I Y₁ T₁ C Z₁) :
Simulator I (fun (i : I) => Y₀ i × Y₁ i) (fun (i : I) => T₀ i × T₁ i) C fun (i : I) => Z₀ i × Z₁ i

Combined typed simulator for andProof: run sim₀ and sim₁ independently at the shared challenge c and pair their commitments and responses.

theorem Cslib.Crypto.Protocols.SigmaProtocol.isPPT_andSimulator {I : Type} {C Y₀ T₀ Z₀ Y₁ T₁ Z₁ : I → Type} {enc₀ : Encoding I Y₀ T₀ C Z₀} {enc₁ : Encoding I Y₁ T₁ C Z₁} {sim₀ : Simulator I Y₀ T₀ C Z₀} {sim₁ : Simulator I Y₁ T₁ C Z₁} (hI : enc₀.index = enc₁.index) (hC : ∀ (i : I), enc₀.challenge i = enc₁.challenge i) (hppt₀ : Simulator.IsPPT enc₀ sim₀) (hppt₁ : Simulator.IsPPT enc₁ sim₁) :
Simulator.IsPPT (enc₀.andProof enc₁) (andSimulator sim₀ sim₁)

andSimulator is uniform strict PPT when both component simulators are and they share the same index and challenge encodings.

theorem Cslib.Crypto.Protocols.SigmaProtocol.simulatorRealizedBy_andSimulator {I : Type} {C Y₀ T₀ Z₀ Y₁ T₁ Z₁ : I → Type} {simulate₀ : (i : I) → Y₀ i → C i → PMF (T₀ i × Z₀ i)} {simulate₁ : (i : I) → Y₁ i → C i → PMF (T₁ i × Z₁ i)} {sim₀ : Simulator I Y₀ T₀ C Z₀} {sim₁ : Simulator I Y₁ T₁ C Z₁} {δ₀ δ₁ : I → ENNReal} (h₀ : SimulatorRealizedBy simulate₀ sim₀ δ₀) (h₁ : SimulatorRealizedBy simulate₁ sim₁ δ₁) :
SimulatorRealizedBy (fun (i : I) => andSimulate (simulate₀ i) (simulate₁ i)) (andSimulator sim₀ sim₁) fun (i : I) => δ₀ i + δ₁ i

andSimulator realizes andSimulate with statistical error δ₀ i + δ₁ i.

theorem Cslib.Crypto.Protocols.SigmaProtocol.EfficientSpecialHVZK.andProof {I : Type} {C X₀ Y₀ T₀ Z₀ X₁ Y₁ T₁ Z₁ : I → Type} {P₀ : (i : I) → SigmaProtocol (X₀ i) (Y₀ i) (T₀ i) (C i) (Z₀ i)} {P₁ : (i : I) → SigmaProtocol (X₁ i) (Y₁ i) (T₁ i) (C i) (Z₁ i)} {R₀ : (i : I) → X₀ i → Y₀ i → Prop} {R₁ : (i : I) → X₁ i → Y₁ i → Prop} {enc₀ : Encoding I Y₀ T₀ C Z₀} {enc₁ : Encoding I Y₁ T₁ C Z₁} {simulate₀ : (i : I) → Y₀ i → C i → PMF (T₀ i × Z₀ i)} {simulate₁ : (i : I) → Y₁ i → C i → PMF (T₁ i × Z₁ i)} {δ₀ δ₁ : I → ENNReal} (hI : enc₀.index = enc₁.index) (hC : ∀ (i : I), enc₀.challenge i = enc₁.challenge i) (h₀ : EfficientSpecialHVZK P₀ R₀ enc₀ simulate₀ δ₀) (h₁ : EfficientSpecialHVZK P₁ R₁ enc₁ simulate₁ δ₁) :
EfficientSpecialHVZK (fun (i : I) => (P₀ i).andProof (P₁ i)) (fun (i : I) (x : X₀ i × X₁ i) (y : Y₀ i × Y₁ i) => R₀ i x.1 y.1 ∧ R₁ i x.2 y.2) (enc₀.andProof enc₁) (fun (i : I) => andSimulate (simulate₀ i) (simulate₁ i)) fun (i : I) => δ₀ i + δ₁ i

Efficient special HVZK of andProof.

Efficiency transfer through orProof #

def Cslib.Crypto.Protocols.SigmaProtocol.Encoding.orProof {I : Type} {C Y₀ T₀ Z₀ Y₁ T₁ Z₁ : I → Type} (enc₀ : Encoding I Y₀ T₀ C Z₀) (enc₁ : Encoding I Y₁ T₁ C Z₁) :
Encoding I (fun (i : I) => Y₀ i × Y₁ i) (fun (i : I) => T₀ i × T₁ i) C fun (i : I) => C i × Z₀ i × Z₁ i

Combined encodings for orProof: statements and commitments are paired with encPair, responses (c₀, z₀, z₁) are encoded by encPair (enc₀.challenge i) (encPair (enc₀.response i) (enc₁.response i)), and the index and challenge encodings are taken from enc₀.

Word-level extractor for orProof: compare the first side's challenge words unframe z and unframe z', and run f₁ with subtracted challenges subWord (i, c, unframe z) when they agree, or f₀ on the first side when they differ, tagging the output with true or false (encSum).

orExtractWord is computable in polynomial time when subWord, f₀, and f₁ are and enc₀ and enc₁ share the same index encoding.

theorem Cslib.Crypto.Protocols.SigmaProtocol.extractorRealizedBy_orExtractWord {I : Type} {C Y₀ T₀ Z₀ W₀ Y₁ T₁ Z₁ W₁ : I → Type} [(i : I) → AddCommGroup (C i)] [(i : I) → DecidableEq (C i)] {enc₀ : Encoding I Y₀ T₀ C Z₀} {enc₁ : Encoding I Y₁ T₁ C Z₁} (hC : ∀ (i : I), enc₀.challenge i = enc₁.challenge i) {subWord : I × List Bool × List Bool → List Bool} (hsub_eq : ∀ (i : I) (c c₀ : C i), subWord (i, (enc₀.challenge i) c, (enc₀.challenge i) c₀) = (enc₀.challenge i) (c - c₀)) {encW₀ : (i : I) → W₀ i ↪ List Bool} {encW₁ : (i : I) → W₁ i ↪ List Bool} {extract₀ : (i : I) → Y₀ i → T₀ i → C i → Z₀ i → C i → Z₀ i → W₀ i} {extract₁ : (i : I) → Y₁ i → T₁ i → C i → Z₁ i → C i → Z₁ i → W₁ i} {f₀ f₁ : I × List Bool × List Bool × List Bool × List Bool × List Bool × List Bool → List Bool} (h₀ : ExtractorRealizedBy enc₀ encW₀ extract₀ f₀) (h₁ : ExtractorRealizedBy enc₁ encW₁ extract₁ f₁) :
ExtractorRealizedBy (enc₀.orProof enc₁) (fun (i : I) => Turing.MultiTapeTM.encSum (encW₀ i) (encW₁ i)) (fun (i : I) => orExtract (extract₀ i) (extract₁ i)) (orExtractWord subWord f₀ f₁)

orExtractWord realizes orExtract on enc₀.orProof enc₁ with witness encoding encSum.

theorem Cslib.Crypto.Protocols.SigmaProtocol.EfficientSpecialSoundness.orProof {I : Type} {C X₀ Y₀ T₀ Z₀ W₀ X₁ Y₁ T₁ Z₁ W₁ : I → Type} [(i : I) → AddCommGroup (C i)] [(i : I) → Fintype (C i)] [(i : I) → DecidableEq (C i)] {P₀ : (i : I) → SigmaProtocol (X₀ i) (Y₀ i) (T₀ i) (C i) (Z₀ i)} {P₁ : (i : I) → SigmaProtocol (X₁ i) (Y₁ i) (T₁ i) (C i) (Z₁ i)} {simulate₀ : (i : I) → Y₀ i → C i → PMF (T₀ i × Z₀ i)} {simulate₁ : (i : I) → Y₁ i → C i → PMF (T₁ i × Z₁ i)} {R₀ : (i : I) → W₀ i → Y₀ i → Prop} {R₁ : (i : I) → W₁ i → Y₁ i → Prop} {enc₀ : Encoding I Y₀ T₀ C Z₀} {enc₁ : Encoding I Y₁ T₁ C Z₁} {encW₀ : (i : I) → W₀ i ↪ List Bool} {encW₁ : (i : I) → W₁ i ↪ List Bool} {extract₀ : (i : I) → Y₀ i → T₀ i → C i → Z₀ i → C i → Z₀ i → W₀ i} {extract₁ : (i : I) → Y₁ i → T₁ i → C i → Z₁ i → C i → Z₁ i → W₁ i} {subWord : I × List Bool × List Bool → List Bool} (hI : enc₀.index = enc₁.index) (hC : ∀ (i : I), enc₀.challenge i = enc₁.challenge i) (hsub : Turing.MultiTapeTM.ComputableInPolyTime subWord (encSubChallengeWordInput enc₀.index) Turing.MultiTapeTM.encBits) (hsub_eq : ∀ (i : I) (c c₀ : C i), subWord (i, (enc₀.challenge i) c, (enc₀.challenge i) c₀) = (enc₀.challenge i) (c - c₀)) (h₀ : EfficientSpecialSoundness P₀ R₀ enc₀ encW₀ extract₀) (h₁ : EfficientSpecialSoundness P₁ R₁ enc₁ encW₁ extract₁) :
EfficientSpecialSoundness (fun (i : I) => (P₀ i).orProof (P₁ i) (simulate₀ i) (simulate₁ i)) (fun (i : I) => orRelation (R₀ i) (R₁ i)) (enc₀.orProof enc₁) (fun (i : I) => Turing.MultiTapeTM.encSum (encW₀ i) (encW₁ i)) fun (i : I) => orExtract (extract₀ i) (extract₁ i)

Efficient special soundness of orProof.

def Cslib.Crypto.Protocols.SigmaProtocol.orSimulator {I : Type} {C Y₀ T₀ Z₀ Y₁ T₁ Z₁ : I → Type} [(i : I) → Sub (C i)] (sampleChallenge : (i : I) → ProbComp (C i)) (sim₀ : Simulator I Y₀ T₀ C Z₀) (sim₁ : Simulator I Y₁ T₁ C Z₁) :
Simulator I (fun (i : I) => Y₀ i × Y₁ i) (fun (i : I) => T₀ i × T₁ i) C fun (i : I) => C i × Z₀ i × Z₁ i

Combined typed simulator for orProof: sample c₀ ← sampleChallenge i, run sim₀ i y.1 c₀ and sim₁ i y.2 (c - c₀), and return ((a.1, b.1), c₀, a.2, b.2).

theorem Cslib.Crypto.Protocols.SigmaProtocol.isPPT_orSimulator {I : Type} {C Y₀ T₀ Z₀ Y₁ T₁ Z₁ : I → Type} [(i : I) → Sub (C i)] {enc₀ : Encoding I Y₀ T₀ C Z₀} {enc₁ : Encoding I Y₁ T₁ C Z₁} {sampleChallenge : (i : I) → ProbComp (C i)} {subWord : I × List Bool × List Bool → List Bool} {sim₀ : Simulator I Y₀ T₀ C Z₀} {sim₁ : Simulator I Y₁ T₁ C Z₁} (hI : enc₀.index = enc₁.index) (hC : ∀ (i : I), enc₀.challenge i = enc₁.challenge i) (hsample : Probability.IsPPTOn enc₀.index Turing.MultiTapeTM.encBits fun (i : I) => ⇑(enc₀.challenge i) <$> sampleChallenge i) (hsub : Turing.MultiTapeTM.ComputableInPolyTime subWord (encSubChallengeWordInput enc₀.index) Turing.MultiTapeTM.encBits) (hsub_eq : ∀ (i : I) (c c₀ : C i), subWord (i, (enc₀.challenge i) c, (enc₀.challenge i) c₀) = (enc₀.challenge i) (c - c₀)) (hppt₀ : Simulator.IsPPT enc₀ sim₀) (hppt₁ : Simulator.IsPPT enc₁ sim₁) :
Simulator.IsPPT (enc₀.orProof enc₁) (orSimulator sampleChallenge sim₀ sim₁)

orSimulator is uniform strict PPT when the challenge sampler, challenge subtraction, and both component simulators are.

theorem Cslib.Crypto.Protocols.SigmaProtocol.simulatorRealizedBy_orSimulator {I : Type} {C Y₀ T₀ Z₀ Y₁ T₁ Z₁ : I → Type} [(i : I) → AddCommGroup (C i)] [(i : I) → Fintype (C i)] {sampleChallenge : (i : I) → ProbComp (C i)} {simulate₀ : (i : I) → Y₀ i → C i → PMF (T₀ i × Z₀ i)} {simulate₁ : (i : I) → Y₁ i → C i → PMF (T₁ i × Z₁ i)} {sim₀ : Simulator I Y₀ T₀ C Z₀} {sim₁ : Simulator I Y₁ T₁ C Z₁} {δC δ₀ δ₁ : I → ENNReal} (hsample : ∀ (i : I), Probability.CloseTo (Probability.PMF.uniformOfFintype (C i)) (sampleChallenge i).eval (δC i)) (h₀ : SimulatorRealizedBy simulate₀ sim₀ δ₀) (h₁ : SimulatorRealizedBy simulate₁ sim₁ δ₁) :
SimulatorRealizedBy (fun (i : I) => orSimulate (simulate₀ i) (simulate₁ i)) (orSimulator sampleChallenge sim₀ sim₁) fun (i : I) => δC i + (δ₀ i + δ₁ i)

orSimulator realizes orSimulate with statistical error δC i + (δ₀ i + δ₁ i).

theorem Cslib.Crypto.Protocols.SigmaProtocol.EfficientSpecialHVZK.orProof {I : Type} {C X₀ Y₀ T₀ Z₀ X₁ Y₁ T₁ Z₁ : I → Type} [(i : I) → AddCommGroup (C i)] [(i : I) → Fintype (C i)] {P₀ : (i : I) → SigmaProtocol (X₀ i) (Y₀ i) (T₀ i) (C i) (Z₀ i)} {P₁ : (i : I) → SigmaProtocol (X₁ i) (Y₁ i) (T₁ i) (C i) (Z₁ i)} {R₀ : (i : I) → X₀ i → Y₀ i → Prop} {R₁ : (i : I) → X₁ i → Y₁ i → Prop} {enc₀ : Encoding I Y₀ T₀ C Z₀} {enc₁ : Encoding I Y₁ T₁ C Z₁} {sampleChallenge : (i : I) → ProbComp (C i)} {subWord : I × List Bool × List Bool → List Bool} {simulate₀ : (i : I) → Y₀ i → C i → PMF (T₀ i × Z₀ i)} {simulate₁ : (i : I) → Y₁ i → C i → PMF (T₁ i × Z₁ i)} {δC δ₀ δ₁ : I → ENNReal} (hI : enc₀.index = enc₁.index) (hC : ∀ (i : I), enc₀.challenge i = enc₁.challenge i) (hsample_ppt : Probability.IsPPTOn enc₀.index Turing.MultiTapeTM.encBits fun (i : I) => ⇑(enc₀.challenge i) <$> sampleChallenge i) (hsample_close : ∀ (i : I), Probability.CloseTo (Probability.PMF.uniformOfFintype (C i)) (sampleChallenge i).eval (δC i)) (hsub : Turing.MultiTapeTM.ComputableInPolyTime subWord (encSubChallengeWordInput enc₀.index) Turing.MultiTapeTM.encBits) (hsub_eq : ∀ (i : I) (c c₀ : C i), subWord (i, (enc₀.challenge i) c, (enc₀.challenge i) c₀) = (enc₀.challenge i) (c - c₀)) (h₀ : EfficientSpecialHVZK P₀ R₀ enc₀ simulate₀ δ₀) (h₁ : EfficientSpecialHVZK P₁ R₁ enc₁ simulate₁ δ₁) :
EfficientSpecialHVZK (fun (i : I) => (P₀ i).orProof (P₁ i) (simulate₀ i) (simulate₁ i)) (fun (i : I) => orRelation (R₀ i) (R₁ i)) (enc₀.orProof enc₁) (fun (i : I) => orSimulate (simulate₀ i) (simulate₁ i)) fun (i : I) => δC i + (δ₀ i + δ₁ i)

Efficient special HVZK of orProof.

Efficiency transfer through parallelRepetition #

def Cslib.Crypto.Protocols.SigmaProtocol.Encoding.parallelRepetition {I : Type} {Y T C Z : I → Type} (enc : Encoding I Y T C Z) (k : I → ℕ) :
Encoding I Y (fun (i : I) => Fin (k i) → T i) (fun (i : I) => Fin (k i) → C i) fun (i : I) => Fin (k i) → Z i

Encodings for k-fold parallel repetition (P i).parallelRepetition (k i): statements and indices keep their encodings from enc, while commitment, challenge, and response tuples are encoded by encFinFn (k i).

Word-level extractor for parallelRepetition: split the tuple words into their framed coordinate words, find the first index where the two challenge words differ, and run f on that coordinate's words. Equal challenge tuples use coordinate zero when nonempty, and defaultWord i only for the empty tuple.

theorem Cslib.Crypto.Protocols.SigmaProtocol.extractorRealizedBy_parallelExtractWord {I : Type} {Y T C Z W : I → Type} [(i : I) → DecidableEq (C i)] [(i : I) → Inhabited (W i)] {enc : Encoding I Y T C Z} {encW : (i : I) → W i ↪ List Bool} {k : I → ℕ} {defaultWord : I → List Bool} (hdef_eq : ∀ (i : I), k i = 0 → defaultWord i = (encW i) default) {extract : (i : I) → Y i → T i → C i → Z i → C i → Z i → W i} {f : I × List Bool × List Bool × List Bool × List Bool × List Bool × List Bool → List Bool} (hf : ExtractorRealizedBy enc encW extract f) :
ExtractorRealizedBy (enc.parallelRepetition k) encW (fun (i : I) => parallelExtract (extract i) (k i)) (parallelExtractWord defaultWord f)

parallelExtractWord realizes parallelExtract on enc.parallelRepetition k.

theorem Cslib.Crypto.Protocols.SigmaProtocol.EfficientSpecialSoundness.parallelRepetition_of_default {I : Type} {X Y T C Z W : I → Type} [(i : I) → DecidableEq (C i)] [(i : I) → Inhabited (W i)] {P : (i : I) → SigmaProtocol (X i) (Y i) (T i) (C i) (Z i)} {R : (i : I) → W i → Y i → Prop} {enc : Encoding I Y T C Z} {encW : (i : I) → W i ↪ List Bool} {extract : (i : I) → Y i → T i → C i → Z i → C i → Z i → W i} {k : I → ℕ} (hdefault : Turing.MultiTapeTM.ComputableInPolyTime (fun (i : I) => (encW i) default) enc.index Turing.MultiTapeTM.encBits) (h : EfficientSpecialSoundness P R enc encW extract) :
EfficientSpecialSoundness (fun (i : I) => (P i).parallelRepetition (k i)) R (enc.parallelRepetition k) encW fun (i : I) => parallelExtract (extract i) (k i)

Polynomial-time extraction for arbitrary repetition counts, including zero, when the encoded default witness is polynomial-time computable. Positive repetition uses EfficientSpecialSoundness.parallelRepetition without this default-witness premise.

theorem Cslib.Crypto.Protocols.SigmaProtocol.EfficientSpecialSoundness.parallelRepetition {I : Type} {X Y T C Z W : I → Type} [(i : I) → DecidableEq (C i)] [(i : I) → Inhabited (W i)] {P : (i : I) → SigmaProtocol (X i) (Y i) (T i) (C i) (Z i)} {R : (i : I) → W i → Y i → Prop} {enc : Encoding I Y T C Z} {encW : (i : I) → W i ↪ List Bool} {extract : (i : I) → Y i → T i → C i → Z i → C i → Z i → W i} {k : I → ℕ} (hk : ∀ (i : I), 0 < k i) (h : EfficientSpecialSoundness P R enc encW extract) :
EfficientSpecialSoundness (fun (i : I) => (P i).parallelRepetition (k i)) R (enc.parallelRepetition k) encW fun (i : I) => parallelExtract (extract i) (k i)

Polynomial-time special-soundness extraction is preserved by positive parallel repetition ([BS23], Exercise 19.6(b), pp. 810–811). On equal challenge tuples the extractor runs the component extractor at coordinate zero, so no efficient default witness is assumed.

def Cslib.Crypto.Protocols.SigmaProtocol.parallelSimulator {I : Type} {Y T C Z : I → Type} (sim : Simulator I Y T C Z) (k : I → ℕ) :
Simulator I Y (fun (i : I) => Fin (k i) → T i) (fun (i : I) => Fin (k i) → C i) fun (i : I) => Fin (k i) → Z i

Typed simulator for parallelRepetition: run sim i y (c j) independently at each coordinate j : Fin (k i) and unzip the resulting commitments and responses.

theorem Cslib.Crypto.Protocols.SigmaProtocol.isPPT_parallelSimulator {I : Type} {Y T C Z : I → Type} {enc : Encoding I Y T C Z} {sim : Simulator I Y T C Z} (k : I → ℕ) (hppt : Simulator.IsPPT enc sim) :

parallelSimulator is uniform strict PPT whenever sim is.

theorem Cslib.Crypto.Protocols.SigmaProtocol.simulatorRealizedBy_parallelSimulator {I : Type} {Y T C Z : I → Type} {simulate : (i : I) → Y i → C i → PMF (T i × Z i)} {sim : Simulator I Y T C Z} {δ : I → ENNReal} (k : I → ℕ) (hreal : SimulatorRealizedBy simulate sim δ) :
SimulatorRealizedBy (fun (i : I) => parallelSimulate (simulate i) (k i)) (parallelSimulator sim k) fun (i : I) => ↑(k i) * δ i

parallelSimulator realizes parallelSimulate with statistical error (k i : ℝ≥0∞) * δ i.

theorem Cslib.Crypto.Protocols.SigmaProtocol.EfficientSpecialHVZK.parallelRepetition {I : Type} {X Y T C Z : I → Type} {P : (i : I) → SigmaProtocol (X i) (Y i) (T i) (C i) (Z i)} {R : (i : I) → X i → Y i → Prop} {enc : Encoding I Y T C Z} {simulate : (i : I) → Y i → C i → PMF (T i × Z i)} {δ : I → ENNReal} (k : I → ℕ) (h : EfficientSpecialHVZK P R enc simulate δ) :
EfficientSpecialHVZK (fun (i : I) => (P i).parallelRepetition (k i)) R (enc.parallelRepetition k) (fun (i : I) => parallelSimulate (simulate i) (k i)) fun (i : I) => ↑(k i) * δ i

Efficient special HVZK of parallelRepetition.