Documentation

CslibFrontier.Crypto.Protocols.SigmaProtocol.ProofOfKnowledge

Sigma protocols are proofs of knowledge with a strict PPT rewinding extractor #

A special-sound Sigma protocol is a proof of knowledge: from any prover that convinces the verifier on a statement y with probability ε, a knowledge extractor that may rewind the prover computes a witness for y. This module formalizes the standard extractor for an indexed family P i of Sigma protocols with a polynomial-time special-soundness extractor (EfficientSpecialSoundness), and proves that it is uniform strict PPT whenever the prover is. Proofs of knowledge are defined by Bellare and Goldreich ([BG93a], Definition 3.1). The per-statement, strict-time form proved here, and its proof from the rewinding lemma, are the library's own; the end of this overview compares it with their definition.

A prover A : MaliciousProver I works on words, so it may cheat: at index i it commits from the encoded statement, keeping a state word, and answers the encoded challenge from that state. The verifier accepts when the two words it receives encode a commitment and a response that P i accepts (AcceptsWord). acceptanceGame is one run of A against the verifier, with challenges drawn from a given law; with the uniform law it is the honest verifier.

The extractor knowledgeExtractor runs A to its commitment, draws two challenges with a sampler sampleChallenge, answers both from the same state, and applies the word function extractWord of the special-soundness extractor to the two conversations. It runs A twice, so it is strict PPT with no expected-time argument (isPPTOn_knowledgeExtractor). Its success probability follows from the rewinding lemma Rewinding.sq_sub_mul_le_twice: on every statement,

ε ^ 2 - κ * ε ≤ ε' (sq_sub_mul_le_extractionGame),

where ε is the acceptance probability of A with challenges from the sampler, κ bounds the sampler's atoms and ε' is the extractor's success probability (extractionGame). For a sampler that is exactly uniform this is ε ^ 2 - ε / |C| ≤ ε' against the honest verifier (sq_sub_le_extractionGame). A strict PPT machine with fair coins samples a challenge space such as ZMod q only approximately; for a sampler within statistical distance δ of uniform, the honest verifier's acceptance probability satisfies ε ≤ 1 / |C| + 2 δ + √ε' (le_add_sqrt_extractionGame).

The hypotheses are only about generic components supplied by the caller: special soundness of the protocol and a polynomial-time word function realizing its extractor, and a strict PPT challenge sampler. Nothing is assumed about the knowledge extractor this module builds.

Bellare and Goldreich's validity condition asks for an extractor that, whenever ε exceeds the knowledge error κ, outputs a witness within an expected number of steps bounded by a polynomial divided by ε - κ ([BG93a], Definition 3.1). The extractor here instead runs in strict polynomial time and succeeds with probability at least ε ^ 2 - κ * ε; repeating it amplifies its success probability.

Main definitions #

Main results #

References #

Provers on words and acceptance #

A prover for a family of Sigma protocols indexed by I, which may cheat. At index i, its first stage reads the encoded statement and returns a commitment word and a state word; its second stage reads the state word and the encoded challenge and returns a response word. Both stages may use fresh randomness.

Both stages of a prover are uniform strict PPT in their whole inputs, with the index encoded by encI.

def Cslib.Crypto.Protocols.SigmaProtocol.AcceptsWord {I : Type} {X Y T C Z : I → Type} (P : (i : I) → SigmaProtocol (X i) (Y i) (T i) (C i) (Z i)) (enc : Encoding I Y T C Z) (i : I) (y : Y i) (t : List Bool) (c : C i) (z : List Bool) :

The verifier of P i on words: the commitment word t and the response word z encode a commitment and a response that P i accepts on the statement y at the challenge c. Words that encode no commitment or no response are rejected.

noncomputable def Cslib.Crypto.Protocols.SigmaProtocol.acceptanceGame {I : Type} {X Y T C Z : I → Type} (P : (i : I) → SigmaProtocol (X i) (Y i) (T i) (C i) (Z i)) (enc : Encoding I Y T C Z) (A : MaliciousProver I) (i : I) (y : Y i) (challenge : PMF (C i)) :

One run of the prover A against the verifier of P i on the statement y, with the challenge drawn from challenge; it succeeds when the verifier accepts. With challenge = PMF.uniformOfFintype (C i) this is the honest verifier.

The rewinding knowledge extractor #

noncomputable def Cslib.Crypto.Protocols.SigmaProtocol.knowledgeExtractor {I : Type} {Y T C Z : I → Type} (enc : Encoding I Y T C Z) (sampleChallenge : (i : I) → ProbComp (C i)) (extractWord : I × List Bool × List Bool × List Bool × List Bool × List Bool × List Bool → List Bool) (A : MaliciousProver I) :

The rewinding knowledge extractor: on the index i and a statement word y, run A to its commitment t, draw two challenges with sampleChallenge i, answer both from the same state, and apply the word function extractWord of a special-soundness extractor to the two conversations.

noncomputable def Cslib.Crypto.Protocols.SigmaProtocol.extractionGame {I : Type} {Y T C Z W : I → Type} (enc : Encoding I Y T C Z) (encW : (i : I) → W i ↪ List Bool) (R : (i : I) → W i → Y i → Prop) (E : I × List Bool → ProbComp (List Bool)) (i : I) (y : Y i) :

A word extractor E, run on the index i and the encoded statement y, outputs the encoding of a witness for y under the relation R i.

Efficiency #

The knowledge extractor is uniform strict PPT whenever the prover is, the challenge sampler writes encoded challenges in strict polynomial time, and extractWord is computable in polynomial time.

Success probability #

theorem Cslib.Crypto.Protocols.SigmaProtocol.sq_sub_mul_le_bind_extractionGame {I : Type} {X Y T C Z W : I → Type} {P : (i : I) → SigmaProtocol (X i) (Y i) (T i) (C i) (Z i)} {enc : Encoding I Y T C Z} {R : (i : I) → W i → Y i → Prop} {extract : (i : I) → Y i → T i → C i → Z i → C i → Z i → W i} {encW : (i : I) → W i ↪ List Bool} {extractWord : I × List Bool × List Bool × List Bool × List Bool × List Bool × List Bool → List Bool} [∀ (i : I), Finite (C i)] (hsound : ∀ (i : I), (P i).SpecialSoundness (R i) (extract i)) (hreal : ExtractorRealizedBy enc encW extract extractWord) (sampleChallenge : (i : I) → ProbComp (C i)) (A : MaliciousProver I) (i : I) (μ : PMF (Y i)) {κ : ℝ} (hκ : ∀ (c : C i), ((sampleChallenge i).eval c).toReal ≤ κ) :
↑(Game.succProbability (μ.bind fun (y : Y i) => acceptanceGame P enc A i y (sampleChallenge i).eval)) ^ 2 - κ * ↑(Game.succProbability (μ.bind fun (y : Y i) => acceptanceGame P enc A i y (sampleChallenge i).eval)) ≤ ↑(Game.succProbability (μ.bind fun (y : Y i) => extractionGame enc encW R (knowledgeExtractor enc sampleChallenge extractWord A) i y))

Average-statement extraction by rewinding: for any statement distribution μ : PMF (Y i), if the prover A convinces the verifier with average probability ε over y ← μ when challenges are drawn by sampleChallenge i, and every challenge has probability at most κ under that sampler, the knowledge extractor outputs a witness for y with average probability at least ε ^ 2 - κ * ε over y ← μ.

theorem Cslib.Crypto.Protocols.SigmaProtocol.sq_sub_mul_le_extractionGame {I : Type} {X Y T C Z W : I → Type} {P : (i : I) → SigmaProtocol (X i) (Y i) (T i) (C i) (Z i)} {enc : Encoding I Y T C Z} {R : (i : I) → W i → Y i → Prop} {extract : (i : I) → Y i → T i → C i → Z i → C i → Z i → W i} {encW : (i : I) → W i ↪ List Bool} {extractWord : I × List Bool × List Bool × List Bool × List Bool × List Bool × List Bool → List Bool} [∀ (i : I), Finite (C i)] (hsound : ∀ (i : I), (P i).SpecialSoundness (R i) (extract i)) (hreal : ExtractorRealizedBy enc encW extract extractWord) (sampleChallenge : (i : I) → ProbComp (C i)) (A : MaliciousProver I) (i : I) (y : Y i) {κ : ℝ} (hκ : ∀ (c : C i), ((sampleChallenge i).eval c).toReal ≤ κ) :
↑(acceptanceGame P enc A i y (sampleChallenge i).eval).succProbability ^ 2 - κ * ↑(acceptanceGame P enc A i y (sampleChallenge i).eval).succProbability ≤ ↑(extractionGame enc encW R (knowledgeExtractor enc sampleChallenge extractWord A) i y).succProbability

Extraction by rewinding: on every statement y, if the prover A convinces the verifier with probability ε when challenges are drawn by sampleChallenge i, and every challenge has probability at most κ under that sampler, the knowledge extractor outputs a witness for y with probability at least ε ^ 2 - κ * ε.

theorem Cslib.Crypto.Protocols.SigmaProtocol.sq_sub_le_bind_extractionGame {I : Type} {X Y T C Z W : I → Type} {P : (i : I) → SigmaProtocol (X i) (Y i) (T i) (C i) (Z i)} {enc : Encoding I Y T C Z} {R : (i : I) → W i → Y i → Prop} {extract : (i : I) → Y i → T i → C i → Z i → C i → Z i → W i} {encW : (i : I) → W i ↪ List Bool} {extractWord : I × List Bool × List Bool × List Bool × List Bool × List Bool × List Bool → List Bool} [(i : I) → Fintype (C i)] [∀ (i : I), Nonempty (C i)] (hsound : ∀ (i : I), (P i).SpecialSoundness (R i) (extract i)) (hreal : ExtractorRealizedBy enc encW extract extractWord) {sampleChallenge : (i : I) → ProbComp (C i)} (A : MaliciousProver I) (i : I) (μ : PMF (Y i)) (huniform : (sampleChallenge i).eval = Probability.PMF.uniformOfFintype (C i)) :
↑(Game.succProbability (μ.bind fun (y : Y i) => acceptanceGame P enc A i y (Probability.PMF.uniformOfFintype (C i)))) ^ 2 - ↑(Game.succProbability (μ.bind fun (y : Y i) => acceptanceGame P enc A i y (Probability.PMF.uniformOfFintype (C i)))) / ↑(Fintype.card (C i)) ≤ ↑(Game.succProbability (μ.bind fun (y : Y i) => extractionGame enc encW R (knowledgeExtractor enc sampleChallenge extractWord A) i y))

Average-statement extraction by rewinding with exactly uniform challenges: for any statement distribution μ : PMF (Y i), if the prover A convinces the honest verifier with average probability ε over y ← μ and sampleChallenge i samples uniform challenges, the knowledge extractor outputs a witness for y with average probability at least ε ^ 2 - ε / |C i| over y ← μ.

theorem Cslib.Crypto.Protocols.SigmaProtocol.sq_sub_le_extractionGame {I : Type} {X Y T C Z W : I → Type} {P : (i : I) → SigmaProtocol (X i) (Y i) (T i) (C i) (Z i)} {enc : Encoding I Y T C Z} {R : (i : I) → W i → Y i → Prop} {extract : (i : I) → Y i → T i → C i → Z i → C i → Z i → W i} {encW : (i : I) → W i ↪ List Bool} {extractWord : I × List Bool × List Bool × List Bool × List Bool × List Bool × List Bool → List Bool} [(i : I) → Fintype (C i)] [∀ (i : I), Nonempty (C i)] (hsound : ∀ (i : I), (P i).SpecialSoundness (R i) (extract i)) (hreal : ExtractorRealizedBy enc encW extract extractWord) {sampleChallenge : (i : I) → ProbComp (C i)} (A : MaliciousProver I) (i : I) (y : Y i) (huniform : (sampleChallenge i).eval = Probability.PMF.uniformOfFintype (C i)) :
↑(acceptanceGame P enc A i y (Probability.PMF.uniformOfFintype (C i))).succProbability ^ 2 - ↑(acceptanceGame P enc A i y (Probability.PMF.uniformOfFintype (C i))).succProbability / ↑(Fintype.card (C i)) ≤ ↑(extractionGame enc encW R (knowledgeExtractor enc sampleChallenge extractWord A) i y).succProbability

Extraction by rewinding with exactly uniform challenges: on every statement y, if the prover A convinces the honest verifier with probability ε and sampleChallenge i samples uniform challenges, the knowledge extractor outputs a witness for y with probability at least ε ^ 2 - ε / |C i|.

theorem Cslib.Crypto.Protocols.SigmaProtocol.le_add_sqrt_bind_extractionGame {I : Type} {X Y T C Z W : I → Type} {P : (i : I) → SigmaProtocol (X i) (Y i) (T i) (C i) (Z i)} {enc : Encoding I Y T C Z} {R : (i : I) → W i → Y i → Prop} {extract : (i : I) → Y i → T i → C i → Z i → C i → Z i → W i} {encW : (i : I) → W i ↪ List Bool} {extractWord : I × List Bool × List Bool × List Bool × List Bool × List Bool × List Bool → List Bool} [(i : I) → Fintype (C i)] [∀ (i : I), Nonempty (C i)] (hsound : ∀ (i : I), (P i).SpecialSoundness (R i) (extract i)) (hreal : ExtractorRealizedBy enc encW extract extractWord) {sampleChallenge : (i : I) → ProbComp (C i)} (A : MaliciousProver I) (i : I) (μ : PMF (Y i)) {δ : NNReal} (hclose : Probability.CloseTo (Probability.PMF.uniformOfFintype (C i)) (sampleChallenge i).eval ↑δ) :
↑(Game.succProbability (μ.bind fun (y : Y i) => acceptanceGame P enc A i y (Probability.PMF.uniformOfFintype (C i)))) ≤ 1 / ↑(Fintype.card (C i)) + 2 * ↑δ + √↑(Game.succProbability (μ.bind fun (y : Y i) => extractionGame enc encW R (knowledgeExtractor enc sampleChallenge extractWord A) i y))

Average-statement extraction by rewinding with approximately uniform challenges: for any statement distribution μ : PMF (Y i), if sampleChallenge i is within statistical distance δ of uniform, the honest verifier's average acceptance probability ε of the prover A over y ← μ and the knowledge extractor's average success probability ε' over y ← μ satisfy ε ≤ 1 / |C i| + 2 δ + √ε'.

theorem Cslib.Crypto.Protocols.SigmaProtocol.le_add_sqrt_extractionGame {I : Type} {X Y T C Z W : I → Type} {P : (i : I) → SigmaProtocol (X i) (Y i) (T i) (C i) (Z i)} {enc : Encoding I Y T C Z} {R : (i : I) → W i → Y i → Prop} {extract : (i : I) → Y i → T i → C i → Z i → C i → Z i → W i} {encW : (i : I) → W i ↪ List Bool} {extractWord : I × List Bool × List Bool × List Bool × List Bool × List Bool × List Bool → List Bool} [(i : I) → Fintype (C i)] [∀ (i : I), Nonempty (C i)] (hsound : ∀ (i : I), (P i).SpecialSoundness (R i) (extract i)) (hreal : ExtractorRealizedBy enc encW extract extractWord) {sampleChallenge : (i : I) → ProbComp (C i)} (A : MaliciousProver I) (i : I) (y : Y i) {δ : NNReal} (hclose : Probability.CloseTo (Probability.PMF.uniformOfFintype (C i)) (sampleChallenge i).eval ↑δ) :
↑(acceptanceGame P enc A i y (Probability.PMF.uniformOfFintype (C i))).succProbability ≤ 1 / ↑(Fintype.card (C i)) + 2 * ↑δ + √↑(extractionGame enc encW R (knowledgeExtractor enc sampleChallenge extractWord A) i y).succProbability

Extraction by rewinding with approximately uniform challenges: on every statement y, if sampleChallenge i is within statistical distance δ of uniform, the honest verifier's acceptance probability ε of the prover A and the knowledge extractor's success probability ε' satisfy ε ≤ 1 / |C i| + 2 δ + √ε'.