Documentation

CslibFrontier.Crypto.Protocols.SigmaProtocol.FiatShamirNIZK

Fiat–Shamir non-interactive proofs in the random-oracle model: completeness and concrete bounds #

The Fiat–Shamir transformation ([FS87]; [BS23], Sections 20.3.3–20.3.5) compiles a public-coin Sigma protocol P : SigmaProtocol X Y T C Z for a relation R : X → Y → Prop into a non-interactive proof system in the random-oracle model: given a witness-statement pair (x, y) and commitment coins (t, st) ← P.commit x y, the prover queries a hash oracle H : Y × T → C on the pair (y, t) to obtain the challenge c and outputs (t, P.respond x y st c) (fiatShamirNIZKProve); the verifier queries H at (y, t) and checks P.verify y t c z (fiatShamirNIZKVerify). Binding both the statement y and the commitment t in the hash query is essential when statements can be chosen adaptively after querying H: hashing t alone fails soundness on protocols such as Schnorr's where a cheating prover can solve the verification equation for y after seeing H(t).

This module proves completeness of Fiat–Shamir non-interactive proofs and concrete simulation, extraction and soundness bounds for them in the OracleComp random-oracle model:

  1. Completeness (fiatShamirNIZK_complete, fiatShamirNIZK_verify_of_prove; [BS23], Section 20.3.3): for every (x, y) with R x y and every initial random-oracle cache cache, running honest commitment sampling, fiatShamirNIZKProve, and fiatShamirNIZKVerify against the lazy uniform random oracle ROMSignature.oracle C accepts with probability 1 (= PMF.pure true).
  2. The zero-knowledge bound (20.9) in the programmable ROM ([BS23], Section 20.3.5, Attack Game 20.3 and Figure 20.2; a step toward Theorem 20.3): an adaptive distinguisher queries .inl (x, y) for a proof (validated by an explicit Boolean relation checker valid : X → Y → Bool with ∀ x y, valid x y = true → R x y, returning none identically in both experiments when valid x y = false) and .inr (y, t) for the random oracle. Under P.SpecialHVZK R simulate and δ-unpredictable commitments (P.UnpredictableCommitments R δ, Definition 19.7), replacing honest proving by the witness-free programmable-ROM simulator nizkSimProve simulate changes the acceptance probability of any distinguisher making at most Qp prove calls and Qro hash calls by at most Qp * (Qp + Qro) * δ (abs_sub_fiatShamirNIZKRealGame_simGame_le, advantage_fiatShamirNIZKRealGame_simGame_le). Concrete adaptation: whereas Figure 20.2 in [BS23] outputs fail when a sampled commitment point (y, t) is already programmed in the random-oracle table, nizkSimProve overwrites (y, t) at the head of the association-list cache; the programming collision hop RandomOracle.closeTo_run_lazyProgramHandler_overwriteProgramHandler_of_isQueryBounded directly justifies this overwrite simulator.
  3. ROM extraction bounds and derived simulation-extractability bounds:
    • Plain ROM extraction bound (fiatShamirNIZKExtract, succProbability_fiatShamirNIZKPokGame_le, proved via the general forking inequality of [BN06], Lemma 1): for an explicit-coin cheating prover making at most Qro hash calls on statement y, the acceptance probability ε satisfies ε ≤ (Qro + 1) / |C| + √((Qro + 1) * ε'), where ε' is the probability that rewinding outputs some w with R w y. On a false statement this gives the soundness bound (Qro + 1) / |C| (succProbability_fiatShamirNIZKPokGame_le_of_false). [BS23], Section 20.3.4, proves soundness (Theorem 20.2) by guessing the relevant hash query instead.
    • Derived adaptive simulation-extraction bounds (fiatShamirNIZKSimExtractWith, fiatShamirNIZKSimExtract, succProbability_fiatShamirNIZKRealExtGame_le, succProbability_fiatShamirNIZKSimExtGame_le): derived here by combining our Attack Game 20.3 zero-knowledge simulation hop, SimCoinSource presampling across forks, and [BN06], Lemma 1 (rather than stated as a standalone theorem in [BS23]). When an explicit-coin adversary also makes up to Qp adaptive prove calls and outputs (y*, (t*, z*)) whose statement-commitment pair (y*, t*) was never returned by the prove oracle (which in particular holds whenever y* is a fresh statement), the witness-free rewinding extractor recovers some (y*, w*) with R w* y* with probability ε' satisfying ε ≤ Qp * (Qp + Qro) * δ + (Qro + 1) / |C| + √((Qro + 1) * ε') against real proofs (and ε ≤ (Qro + 1) / |C| + √((Qro + 1) * ε') against simulated proofs).

Specializations are provided for SigmaProtocol.linear and SigmaProtocol.schnorr, using an explicit statement-independent simulator coin source (linearSimCoinSource) so that linear and schnorr simulation-extraction bounds require no finiteness assumption on the statement or group carrier types.

Every result is about one Sigma protocol: completeness is an equality of distributions, and the other results are concrete inequalities. The zero-knowledge, extraction and soundness bounds are steps toward [BS23], Theorems 20.2 and 20.3, not the cited results: those theorems conclude that the proof system is sound (Definition 20.4) and niZK (Definition 20.5, which asks for an efficient simulator), while nothing here certifies the simulator nizkSimProve or the rewinding extractors as efficient. The asymptotic theorems are open (#5293).

Main definitions #

Main results #

Steps toward Theorems 20.2 and 20.3 #

References #

Non-interactive prover, verifier, and completeness #

@[reducible, inline]

Random-oracle query specification for Fiat–Shamir NIZK proofs ([BS23], Section 20.3.3): every challenge query binds both the statement y : Y and the commitment t : T and returns a challenge in C.

def Cslib.Crypto.Protocols.SigmaProtocol.fiatShamirNIZKProve {X Y T C Z : Type} (P : SigmaProtocol X Y T C Z) (x : X) (y : Y) (coins : T × P.State) :
OracleComp (NIZKHashSpec Y T C) (T × Z)

Fiat–Shamir non-interactive prover ([BS23], Section 20.3.3): given witness x, statement y, and commitment coins (t, st) sampled from P.commit x y, query the random oracle at (y, t) for the challenge c and output (t, P.respond x y st c).

def Cslib.Crypto.Protocols.SigmaProtocol.fiatShamirNIZKVerify {X Y T C Z : Type} (P : SigmaProtocol X Y T C Z) (y : Y) (prf : T × Z) :

Fiat–Shamir non-interactive verifier ([BS23], Section 20.3.3): query the random oracle at (y, prf.1) for the challenge c and check P.verify y prf.1 c prf.2.

theorem Cslib.Crypto.Protocols.SigmaProtocol.fiatShamirNIZK_verify_of_prove {X Y T C Z : Type} [DecidableEq Y] [DecidableEq T] [Fintype C] [Nonempty C] {P : SigmaProtocol X Y T C Z} {R : X → Y → Prop} (hP : P.Complete R) {x : X} {y : Y} (hxy : R x y) {coins : T × P.State} (hcoins : coins ∈ (P.commit x y).support) (cache : List ((Y × T) × C)) {proved : (T × Z) × List ((Y × T) × C)} (hproved : proved ∈ ((OracleComp.interpret (ROMSignature.oracle C) (P.fiatShamirNIZKProve x y coins)).run cache).support) {verified : Bool × List ((Y × T) × C)} (hverified : verified ∈ ((OracleComp.interpret (ROMSignature.oracle C) (P.fiatShamirNIZKVerify y proved.1)).run proved.2).support) :
verified.1 = true

Support-level completeness of Fiat–Shamir NIZK proofs: for any (x, y) in R, any supported commitment coins, and any initial random-oracle cache, every proof produced by fiatShamirNIZKProve is accepted by fiatShamirNIZKVerify under the updated cache.

theorem Cslib.Crypto.Protocols.SigmaProtocol.fiatShamirNIZK_complete {X Y T C Z : Type} [DecidableEq Y] [DecidableEq T] [Fintype C] [Nonempty C] {P : SigmaProtocol X Y T C Z} {R : X → Y → Prop} (hP : P.Complete R) {x : X} {y : Y} (hxy : R x y) (cache : List ((Y × T) × C)) :
(do let coins ← P.commit x y let __x ← (OracleComp.interpret (ROMSignature.oracle C) (P.fiatShamirNIZKProve x y coins)).run cache match __x with | (prf, cache') => do let __x ← (OracleComp.interpret (ROMSignature.oracle C) (P.fiatShamirNIZKVerify y prf)).run cache' match __x with | (acc, snd) => pure acc) = PMF.pure true

Perfect completeness of Fiat–Shamir NIZK proofs in the lazy random-oracle model ([BS23], Section 20.3.3): for any (x, y) satisfying R x y and any initial cache cache, sampling commitment coins, proving, and verifying in sequence against oracle C accepts with probability 1.

Unpredictable commitments and adaptive multi-theorem zero knowledge #

def Cslib.Crypto.Protocols.SigmaProtocol.UnpredictableCommitments {X Y T C Z : Type} (P : SigmaProtocol X Y T C Z) (R : X → Y → Prop) (δ : NNReal) :

Commitments of P are δ-unpredictable on R ([BS23], Definition 19.7): for every witness-statement pair (x, y) in R, no commitment value occurs with probability greater than δ.

theorem Cslib.Crypto.Protocols.SigmaProtocol.UnpredictableCommitments.mono {X Y T C Z : Type} {P : SigmaProtocol X Y T C Z} {R R' : X → Y → Prop} {δ δ' : NNReal} (h : P.UnpredictableCommitments R δ) (hR : ∀ (x : X) (y : Y), R' x y → R x y) (hδ : δ ≤ δ') :

Monotonicity of UnpredictableCommitments in both the relation and the collision bound.

@[reducible, inline]

Two-channel oracle specification for adaptive multi-theorem Fiat–Shamir NIZK experiments ([BS23], Section 20.3.5, Attack Game 20.3): .inl (x, y) requests a proof for candidate witness-statement pair (x, y) (returning Option (T × Z)) and .inr (y, t) queries the random oracle at (y, t) (returning C).

def Cslib.Crypto.Protocols.SigmaProtocol.NIZKCallBounded {X Y T C Z α : Type} (program : OracleComp (NIZKDistinguisherSpec X Y T C Z) α) (Qp Qro : ℕ) :

Separate prove-query (Qp) and hash-query (Qro) budgets for an OracleComp over NIZKDistinguisherSpec.

theorem Cslib.Crypto.Protocols.SigmaProtocol.NIZKCallBounded.isQueryBounded {X Y T C Z α : Type} {program : OracleComp (NIZKDistinguisherSpec X Y T C Z) α} {Qp Qro : ℕ} (h : NIZKCallBounded program Qp Qro) :
program.IsQueryBounded (Qp + Qro)

A program making at most Qp prove calls and Qro hash calls makes at most Qp + Qro calls in total.

noncomputable def Cslib.Crypto.Protocols.SigmaProtocol.nizkSimProve {Y T C Z : Type} [Fintype C] [Nonempty C] (simulate : Y → C → PMF (T × Z)) (y : Y) :
StateT (List ((Y × T) × C)) PMF (T × Z)

Witness-free programmable-ROM proof simulation on statement y ([BS23], Section 20.3.5, adapted from Figure 20.2): sample a uniform challenge c ← C, sample (t, z) ← simulate y c, program (y, t) ↦ c at the front of the random-oracle cache (overwriting any existing binding rather than returning fail), and return (t, z).

noncomputable def Cslib.Crypto.Protocols.SigmaProtocol.nizkRealHandler {X Y T C Z : Type} [DecidableEq Y] [DecidableEq T] [Fintype C] [Nonempty C] (P : SigmaProtocol X Y T C Z) (valid : X → Y → Bool) (q : X × Y ⊕ Y × T) :
StateT (List ((Y × T) × C)) PMF (NIZKDistinguisherSpec X Y T C Z q)

Real multi-theorem NIZK oracle handler ([BS23], Attack Game 20.3): invalid witness candidates (valid x y = false) return none without touching the random-oracle cache; valid pairs sample honest commitment coins and run fiatShamirNIZKProve against oracle C.

noncomputable def Cslib.Crypto.Protocols.SigmaProtocol.nizkSimHandler {X Y T C Z : Type} [DecidableEq Y] [DecidableEq T] [Fintype C] [Nonempty C] (simulate : Y → C → PMF (T × Z)) (valid : X → Y → Bool) (q : X × Y ⊕ Y × T) :
StateT (List ((Y × T) × C)) PMF (NIZKDistinguisherSpec X Y T C Z q)

Programmable-ROM simulated multi-theorem NIZK oracle handler ([BS23], Attack Game 20.3, using the overwrite adaptation of Figure 20.2): invalid witness candidates (valid x y = false) return none identically without touching the cache; valid pairs run the witness-free simulator nizkSimProve simulate y.

@[simp]
theorem Cslib.Crypto.Protocols.SigmaProtocol.nizkRealHandler_inl_of_false {X Y T C Z : Type} [DecidableEq Y] [DecidableEq T] [Fintype C] [Nonempty C] (P : SigmaProtocol X Y T C Z) {valid : X → Y → Bool} {x : X} {y : Y} (h : valid x y = false) (cache : List ((Y × T) × C)) :
P.nizkRealHandler valid (Sum.inl (x, y)) cache = PMF.pure (none, cache)

Invalid prove queries return none without modifying the cache in nizkRealHandler.

@[simp]
theorem Cslib.Crypto.Protocols.SigmaProtocol.nizkSimHandler_inl_of_false {X Y T C Z : Type} [DecidableEq Y] [DecidableEq T] [Fintype C] [Nonempty C] (simulate : Y → C → PMF (T × Z)) {valid : X → Y → Bool} {x : X} {y : Y} (h : valid x y = false) (cache : List ((Y × T) × C)) :
nizkSimHandler simulate valid (Sum.inl (x, y)) cache = PMF.pure (none, cache)

Invalid prove queries return none without modifying the cache in nizkSimHandler.

theorem Cslib.Crypto.Protocols.SigmaProtocol.nizkSimHandler_inl_congr {X Y T C Z : Type} [DecidableEq Y] [DecidableEq T] [Fintype C] [Nonempty C] (simulate : Y → C → PMF (T × Z)) {valid : X → Y → Bool} {x₁ x₂ : X} {y : Y} (h : valid x₁ y = valid x₂ y) (cache : List ((Y × T) × C)) :
nizkSimHandler simulate valid (Sum.inl (x₁, y)) cache = nizkSimHandler simulate valid (Sum.inl (x₂, y)) cache

Witness-invariance of nizkSimHandler: two witness candidates x₁, x₂ with the same validity bit valid x₁ y = valid x₂ y induce identical simulated prove transitions.

noncomputable def Cslib.Crypto.Protocols.SigmaProtocol.fiatShamirNIZKRealGame {X Y T C Z : Type} [DecidableEq Y] [DecidableEq T] [Fintype C] [Nonempty C] (P : SigmaProtocol X Y T C Z) (valid : X → Y → Bool) (D : OracleComp (NIZKDistinguisherSpec X Y T C Z) Bool) :

Real adaptive multi-theorem NIZK experiment ([BS23], Attack Game 20.3, Experiment 0).

noncomputable def Cslib.Crypto.Protocols.SigmaProtocol.fiatShamirNIZKSimGame {X Y T C Z : Type} [DecidableEq Y] [DecidableEq T] [Fintype C] [Nonempty C] (simulate : Y → C → PMF (T × Z)) (valid : X → Y → Bool) (D : OracleComp (NIZKDistinguisherSpec X Y T C Z) Bool) :

Simulated adaptive multi-theorem NIZK experiment in the programmable random-oracle model ([BS23], Attack Game 20.3, Experiment 1, with the overwrite simulator nizkSimProve).

Shared game-hop handlers (logging proved (y, t) pairs via RandomOracle.Programming) #

noncomputable def Cslib.Crypto.Protocols.SigmaProtocol.nizkRealExtHandler {X Y T C Z : Type} [DecidableEq Y] [DecidableEq T] [Fintype C] [Nonempty C] (P : SigmaProtocol X Y T C Z) (valid : X → Y → Bool) (q : X × Y ⊕ Y × T) :
StateT (List ((Y × T) × C) × List (Y × T)) PMF (NIZKDistinguisherSpec X Y T C Z q)

Logged real prove/hash handler, recording (y, t) on each valid prove query.

noncomputable def Cslib.Crypto.Protocols.SigmaProtocol.nizkSimExtHandler {X Y T C Z : Type} [DecidableEq Y] [DecidableEq T] [Fintype C] [Nonempty C] (simulate : Y → C → PMF (T × Z)) (valid : X → Y → Bool) (q : X × Y ⊕ Y × T) :
StateT (List ((Y × T) × C) × List (Y × T)) PMF (NIZKDistinguisherSpec X Y T C Z q)

Logged programmable-ROM simulated prove/hash handler, recording (y, t) on each valid prove query.

theorem Cslib.Crypto.Protocols.SigmaProtocol.abs_sub_fiatShamirNIZKRealGame_simGame_le {X Y T C Z : Type} [DecidableEq Y] [DecidableEq T] [Fintype C] [Nonempty C] {P : SigmaProtocol X Y T C Z} {R : X → Y → Prop} {simulate : Y → C → PMF (T × Z)} {valid : X → Y → Bool} {δ : NNReal} (hvalid : ∀ (x : X) (y : Y), valid x y = true → R x y) (hHVZK : P.SpecialHVZK R simulate) (hUnpred : P.UnpredictableCommitments R δ) {D : OracleComp (NIZKDistinguisherSpec X Y T C Z) Bool} {Qp Qro : ℕ} (hD : NIZKCallBounded D Qp Qro) :
|((P.fiatShamirNIZKRealGame valid D) true).toReal - ((fiatShamirNIZKSimGame simulate valid D) true).toReal| ≤ ↑Qp * (↑Qp + ↑Qro) * ↑δ

Concrete zero-knowledge bound (20.9) for one Sigma protocol, a step toward [BS23], Theorem 20.3, not the cited result: under SpecialHVZK and δ-unpredictable commitments, any adaptive distinguisher making at most Qp prove calls and Qro direct hash calls distinguishes fiatShamirNIZKRealGame from fiatShamirNIZKSimGame with acceptance-probability difference at most Qp * (Qp + Qro) * δ. The simulator is the overwrite variant nizkSimProve of Figure 20.2, justified by the programming hop RandomOracle.closeTo_run_lazyProgramHandler_overwriteProgramHandler_of_isQueryBounded.

Theorem 20.3 concludes that the proof system is niZK (Definition 20.5), which asks for an efficient simulator. This lemma has no efficiency claim for the simulator and fixes one protocol; the asymptotic theorem is open (#5293).

theorem Cslib.Crypto.Protocols.SigmaProtocol.advantage_fiatShamirNIZKRealGame_simGame_le {X Y T C Z : Type} [DecidableEq Y] [DecidableEq T] [Fintype C] [Nonempty C] {P : SigmaProtocol X Y T C Z} {R : X → Y → Prop} {simulate : Y → C → PMF (T × Z)} {valid : X → Y → Bool} {δ : NNReal} (hvalid : ∀ (x : X) (y : Y), valid x y = true → R x y) (hHVZK : P.SpecialHVZK R simulate) (hUnpred : P.UnpredictableCommitments R δ) {D : OracleComp (NIZKDistinguisherSpec X Y T C Z) Bool} {Qp Qro : ℕ} (hD : NIZKCallBounded D Qp Qro) :
(P.fiatShamirNIZKRealGame valid D).advantage (fiatShamirNIZKSimGame simulate valid D) ≤ ↑Qp * (↑Qp + ↑Qro) * δ

Game.advantage form of the concrete zero-knowledge bound (20.9) for one Sigma protocol, a step toward [BS23], Theorem 20.3, not the cited result: the simulator has no efficiency claim (abs_sub_fiatShamirNIZKRealGame_simGame_le; #5293).

The forking reduction for proofs of knowledge #

Plain ROM proof of knowledge #

An explicit-coin cheating prover in the plain random-oracle model: it draws private coins coins and, given statement y, queries NIZKHashSpec Y T C to output a candidate proof (t, z).

  • Coins : Type

    The cheating prover's private coin type.

  • coins : PMF self.Coins

    Distribution on the cheating prover's private coins.

  • prove : Y → self.Coins → OracleComp (NIZKHashSpec Y T C) (T × Z)

    Deterministic oracle program producing (t, z) for statement y.

noncomputable def Cslib.Crypto.Protocols.SigmaProtocol.fiatShamirNIZKPokGame {X Y T C Z : Type} [DecidableEq Y] [DecidableEq T] [Fintype C] [Nonempty C] (P : SigmaProtocol X Y T C Z) (A : NIZKProver Y T C Z) (y : Y) :

Plain random-oracle proof-of-knowledge experiment on statement y: draw s ← A.coins, run A.prove y s against oracle C from an empty cache, and verify the returned proof under the shared cache.

noncomputable def Cslib.Crypto.Protocols.SigmaProtocol.fiatShamirNIZKExtract {X Y T C Z : Type} [DecidableEq Y] [DecidableEq T] [Fintype C] [Nonempty C] [DecidableEq C] {W : Type} (P : SigmaProtocol X Y T C Z) (extract : Y → T → C → Z → C → Z → W) (A : NIZKProver Y T C Z) (Qro : ℕ) (y : Y) :

Plain ROM knowledge extractor ([BS23], Section 20.3.4; rewinding via [BN06], Lemma 1): fork A across its at most Qro + 1 hash queries on statement y and apply extract to the two accepting transcripts when the fork succeeds.

noncomputable def Cslib.Crypto.Protocols.SigmaProtocol.fiatShamirNIZKExtractGame {Y W : Type} (R : W → Y → Prop) [(w : W) → (y : Y) → Decidable (R w y)] (ext : PMF (Option W)) (y : Y) :

Game testing whether an Option W extractor distribution outputs some w satisfying R w y.

theorem Cslib.Crypto.Protocols.SigmaProtocol.succProbability_fiatShamirNIZKPokGame_le {X Y T C Z : Type} [DecidableEq Y] [DecidableEq T] [Fintype C] [Nonempty C] [DecidableEq C] {W : Type} {P : SigmaProtocol X Y T C Z} {R : W → Y → Prop} [(w : W) → (y : Y) → Decidable (R w y)] {extract : Y → T → C → Z → C → Z → W} (hsound : P.SpecialSoundness R extract) (A : NIZKProver Y T C Z) {Qro : ℕ} (y : Y) (hQro : ∀ (s : A.Coins), (A.prove y s).IsQueryBounded Qro) :
↑(P.fiatShamirNIZKPokGame A y).succProbability ≤ (↑Qro + 1) / ↑(Fintype.card C) + √((↑Qro + 1) * ↑(fiatShamirNIZKExtractGame R (P.fiatShamirNIZKExtract extract A Qro y) y).succProbability)

Concrete extraction bound for one Sigma protocol and statement, a step toward [BS23], Theorem 20.2, not the cited result (proved via the general forking inequality of [BN06], Lemma 1): if P is special sound at y with extractor extract and A makes at most Qro hash calls on y, then A's acceptance probability ε satisfies ε ≤ (Qro + 1) / |C| + √((Qro + 1) * ε'), where ε' is the probability that fiatShamirNIZKExtract P extract A Qro y outputs some w with R w y.

The book proves soundness, not extraction, in Section 20.3.4; this bound yields the soundness bound succProbability_fiatShamirNIZKPokGame_le_of_false. The extractor has no efficiency claim and the protocol is one instance (#5293).

theorem Cslib.Crypto.Protocols.SigmaProtocol.succProbability_fiatShamirNIZKPokKeyGen_le {X Y T C Z : Type} [DecidableEq Y] [DecidableEq T] [Fintype C] [Nonempty C] [DecidableEq C] [Nonempty X] {P : SigmaProtocol X Y T C Z} {keyGen : PMF (X × Y)} {R : X → Y → Prop} [(x : X) → (y : Y) → Decidable (R x y)] {extract : Y → T → C → Z → C → Z → X} (hsound : P.SpecialSoundOn keyGen R extract) (A : NIZKProver Y T C Z) {Qro : ℕ} (hQro : ∀ (y : Y) (s : A.Coins), (A.prove y s).IsQueryBounded Qro) :
↑(Game.succProbability (keyGen.bind fun (x : X × Y) => match x with | (fst, y) => P.fiatShamirNIZKPokGame A y)) ≤ (↑Qro + 1) / ↑(Fintype.card C) + √((↑Qro + 1) * ↑(oneWayGame keyGen R fun (y : Y) => PMF.map (fun (w : Option X) => w.getD (Classical.arbitrary X)) (P.fiatShamirNIZKExtract extract A Qro y)).succProbability)

Concrete extraction bound against a key generator (oneWayGame form), a step like succProbability_fiatShamirNIZKPokGame_le, with no efficiency claim for the extractor (#5293): averaging over (x, y) ← keyGen, a cheating prover making at most Qro hash calls yields a oneWayGame adversary via fiatShamirNIZKExtract.

theorem Cslib.Crypto.Protocols.SigmaProtocol.succProbability_fiatShamirNIZKPokGame_le_of_false {X Y T C Z : Type} [DecidableEq Y] [DecidableEq T] [Fintype C] [Nonempty C] {W : Type} {P : SigmaProtocol X Y T C Z} {R : W → Y → Prop} {extract : Y → T → C → Z → C → Z → W} (hsound : P.SpecialSoundness R extract) {y : Y} (hfalse : ∀ (w : W), ¬R w y) (A : NIZKProver Y T C Z) {Qro : ℕ} (hQro : ∀ (s : A.Coins), (A.prove y s).IsQueryBounded Qro) :

Concrete soundness bound on one fixed false statement, a step toward [BS23], Theorem 20.2, not the cited result: if y has no witness in R, any cheating prover making at most Qro hash calls convinces fiatShamirNIZKVerify with probability at most (Qro + 1) / |C|.

This is the bound (Qro + 1) / N that the book derives from Theorems 20.2 and 20.1 for its Chaum–Pedersen example (pp. 837–838), here from special soundness and for a statement fixed in advance. In Attack Game 20.2 the adversary chooses the statement; with special HVZK and unpredictable commitments, succProbability_fiatShamirNIZKRealExtGameOn_le_of_false bounds adaptively chosen false statements. Theorem 20.2 assumes only that the Sigma protocol is sound and concludes asymptotic soundness (#5293).

Simulation-extractability (adaptive multi-theorem proof of knowledge) #

structure Cslib.Crypto.Protocols.SigmaProtocol.SimCoinSource (Y T C Z : Type) [Fintype C] [Nonempty C] (simulate : Y → C → PMF (T × Z)) :

An explicit coin source realizing one step of simulateConversation simulate: drawing r ← coins and evaluating eval r y reproduces (t, c, z) ← simulateConversation simulate y at every statement y.

  • Coins : Type

    Coin space for one simulated transcript across statements.

  • coins : PMF self.Coins

    Distribution on simulator coins.

  • eval : self.Coins → Y → T × C × Z

    Deterministic evaluation of (t, c, z) at statement y.

  • map_eval (y : Y) : PMF.map (fun (r : self.Coins) => self.eval r y) self.coins = simulateConversation simulate y

    Marginal law at each statement y equals simulateConversation simulate y.

noncomputable def Cslib.Crypto.Protocols.SigmaProtocol.SimCoinSource.ofFintype {Y T C Z : Type} [Fintype Y] [Finite T] [Finite Z] [Fintype C] [Nonempty C] (simulate : Y → C → PMF (T × Z)) :
SimCoinSource Y T C Z simulate

Canonical SimCoinSource for any simulator over finite statement, commitment, and response types via PMF.pi.

Explicit-coin adaptive multi-theorem cheating prover: it draws private coins coins, queries both the prove oracle .inl (x, y) and the hash oracle .inr (y, t), and outputs a target statement y* paired with a candidate proof (t*, z*).

A makes at most Qp prove calls and Qro hash calls on every coin sample.

noncomputable def Cslib.Crypto.Protocols.SigmaProtocol.fiatShamirNIZKRealExtGameOn {X Y T C Z : Type} [DecidableEq Y] [DecidableEq T] [Fintype C] [Nonempty C] (admissible : Y → Bool) (P : SigmaProtocol X Y T C Z) (valid : X → Y → Bool) (A : NIZKSimProver X Y T C Z) :

Real adaptive multi-theorem proof-of-knowledge experiment with final-statement guard admissible: A interacts with the real prove and hash oracles and wins when its output (y*, (t*, z*)) satisfies admissible y*, passes fiatShamirNIZKVerify, and has a fresh statement-commitment pair (y*, t*) not returned by any valid prove query.

noncomputable def Cslib.Crypto.Protocols.SigmaProtocol.fiatShamirNIZKRealExtGame {X Y T C Z : Type} [DecidableEq Y] [DecidableEq T] [Fintype C] [Nonempty C] (P : SigmaProtocol X Y T C Z) (valid : X → Y → Bool) (A : NIZKSimProver X Y T C Z) :

Unrestricted real adaptive multi-theorem proof-of-knowledge experiment (admissible = true).

noncomputable def Cslib.Crypto.Protocols.SigmaProtocol.fiatShamirNIZKSimExtGameOn {X Y T C Z : Type} [DecidableEq Y] [DecidableEq T] [Fintype C] [Nonempty C] (admissible : Y → Bool) (P : SigmaProtocol X Y T C Z) (simulate : Y → C → PMF (T × Z)) (valid : X → Y → Bool) (A : NIZKSimProver X Y T C Z) :

Simulated adaptive multi-theorem proof-of-knowledge experiment with final-statement guard admissible: A interacts with the programmable-ROM simulated prove oracle and shared hash oracle, winning under the same fresh-(y*, t*) acceptance condition.

noncomputable def Cslib.Crypto.Protocols.SigmaProtocol.fiatShamirNIZKSimExtGame {X Y T C Z : Type} [DecidableEq Y] [DecidableEq T] [Fintype C] [Nonempty C] (P : SigmaProtocol X Y T C Z) (simulate : Y → C → PMF (T × Z)) (valid : X → Y → Bool) (A : NIZKSimProver X Y T C Z) :

Unrestricted simulated adaptive multi-theorem proof-of-knowledge experiment (admissible = true).

noncomputable def Cslib.Crypto.Protocols.SigmaProtocol.fiatShamirNIZKFreshStmtGameOn {X Y T C Z : Type} [DecidableEq Y] [DecidableEq T] [Fintype C] [Nonempty C] (admissible : Y → Bool) (P : SigmaProtocol X Y T C Z) (valid : X → Y → Bool) (A : NIZKSimProver X Y T C Z) :

Real fresh-statement experiment with final-statement guard admissible: as fiatShamirNIZKRealExtGameOn, but the output statement y* itself must not have been answered by a valid prove call.

noncomputable def Cslib.Crypto.Protocols.SigmaProtocol.fiatShamirNIZKSimExtractWith {X Y T C Z : Type} [DecidableEq Y] [DecidableEq T] [Fintype C] [Nonempty C] [DecidableEq C] {W : Type} {simulate : Y → C → PMF (T × Z)} (P : SigmaProtocol X Y T C Z) (src : SimCoinSource Y T C Z simulate) (extract : Y → T → C → Z → C → Z → W) (valid : X → Y → Bool) (admissible : Y → Bool) (A : NIZKSimProver X Y T C Z) (Qp Qro : ℕ) :
PMF (Option (Y × W))

Witness-free simulation-extractability rewinding extractor parameterized by an explicit SimCoinSource (derived adaptive multi-theorem reduction combining SimCoinSource presampling with [BN06], Lemma 1).

noncomputable def Cslib.Crypto.Protocols.SigmaProtocol.fiatShamirNIZKSimExtract {X Y T C Z : Type} [DecidableEq Y] [DecidableEq T] [Fintype Y] [Finite T] [Finite Z] [Fintype C] [Nonempty C] [DecidableEq C] {W : Type} (P : SigmaProtocol X Y T C Z) (simulate : Y → C → PMF (T × Z)) (extract : Y → T → C → Z → C → Z → W) (valid : X → Y → Bool) (A : NIZKSimProver X Y T C Z) (Qp Qro : ℕ) :
PMF (Option (Y × W))

Witness-free simulation-extractability rewinding extractor over finite statement and transcript spaces (admissible = true), answering prove queries with simulate and rewinding hash queries via Forking.fork.

noncomputable def Cslib.Crypto.Protocols.SigmaProtocol.fiatShamirNIZKSimExtractGame {Y W : Type} (R : W → Y → Prop) [(w : W) → (y : Y) → Decidable (R w y)] (admissible : Y → Bool) (ext : PMF (Option (Y × W))) :

Game testing whether a simulation-extractability extractor outputs some (y*, w*) satisfying both admissible y* and R w* y*.

theorem Cslib.Crypto.Protocols.SigmaProtocol.succProbability_fiatShamirNIZKSimExtGameOn_le {X Y T C Z : Type} [DecidableEq Y] [DecidableEq T] [Fintype C] [Nonempty C] [DecidableEq C] {W : Type} {P : SigmaProtocol X Y T C Z} {R : W → Y → Prop} [(w : W) → (y : Y) → Decidable (R w y)] {simulate : Y → C → PMF (T × Z)} {extract : Y → T → C → Z → C → Z → W} (hsound : P.SpecialSoundness R extract) (src : SimCoinSource Y T C Z simulate) (valid : X → Y → Bool) (admissible : Y → Bool) {A : NIZKSimProver X Y T C Z} {Qp Qro : ℕ} (hA : A.CallBounded Qp Qro) :
↑(fiatShamirNIZKSimExtGameOn admissible P simulate valid A).succProbability ≤ (↑Qro + 1) / ↑(Fintype.card C) + √((↑Qro + 1) * ↑(fiatShamirNIZKSimExtractGame R admissible (P.fiatShamirNIZKSimExtractWith src extract valid admissible A Qp Qro)).succProbability)

Concrete simulation-extraction bound against simulated proofs for one Sigma protocol, derived here and not a result of [BS23] (general SimCoinSource and admissible form, via SimCoinSource presampling and [BN06], Lemma 1): without needing commitment unpredictability or SpecialHVZK, an adaptive adversary making at most Qp prove calls and Qro hash calls wins fiatShamirNIZKSimExtGameOn with probability at most (Qro + 1) / |C| + √((Qro + 1) * ε'). The extractor has no efficiency claim (#5293).

theorem Cslib.Crypto.Protocols.SigmaProtocol.succProbability_fiatShamirNIZKSimExtGame_le {X Y T C Z : Type} [DecidableEq Y] [DecidableEq T] [Fintype Y] [Finite T] [Finite Z] [Fintype C] [Nonempty C] [DecidableEq C] {W : Type} {P : SigmaProtocol X Y T C Z} {R : W → Y → Prop} [(w : W) → (y : Y) → Decidable (R w y)] {simulate : Y → C → PMF (T × Z)} {extract : Y → T → C → Z → C → Z → W} (hsound : P.SpecialSoundness R extract) (valid : X → Y → Bool) {A : NIZKSimProver X Y T C Z} {Qp Qro : ℕ} (hA : A.CallBounded Qp Qro) :
↑(P.fiatShamirNIZKSimExtGame simulate valid A).succProbability ≤ (↑Qro + 1) / ↑(Fintype.card C) + √((↑Qro + 1) * ↑(fiatShamirNIZKSimExtractGame R (fun (x : Y) => true) (P.fiatShamirNIZKSimExtract simulate extract valid A Qp Qro)).succProbability)

The concrete simulation-extraction bound of succProbability_fiatShamirNIZKSimExtGameOn_le against simulated proofs, over finite statement and transcript types.

theorem Cslib.Crypto.Protocols.SigmaProtocol.succProbability_fiatShamirNIZKRealExtGameOn_le {X Y T C Z : Type} [DecidableEq Y] [DecidableEq T] [Fintype C] [Nonempty C] [DecidableEq C] {W : Type} {P : SigmaProtocol X Y T C Z} {R_honest : X → Y → Prop} {R : W → Y → Prop} [(w : W) → (y : Y) → Decidable (R w y)] {simulate : Y → C → PMF (T × Z)} {extract : Y → T → C → Z → C → Z → W} {valid : X → Y → Bool} {δ : NNReal} (hvalid : ∀ (x : X) (y : Y), valid x y = true → R_honest x y) (hsound : P.SpecialSoundness R extract) (hHVZK : P.SpecialHVZK R_honest simulate) (hUnpred : P.UnpredictableCommitments R_honest δ) (src : SimCoinSource Y T C Z simulate) (admissible : Y → Bool) {A : NIZKSimProver X Y T C Z} {Qp Qro : ℕ} (hA : A.CallBounded Qp Qro) :
↑(fiatShamirNIZKRealExtGameOn admissible P valid A).succProbability ≤ ↑Qp * (↑Qp + ↑Qro) * ↑δ + (↑Qro + 1) / ↑(Fintype.card C) + √((↑Qro + 1) * ↑(fiatShamirNIZKSimExtractGame R admissible (P.fiatShamirNIZKSimExtractWith src extract valid admissible A Qp Qro)).succProbability)

Concrete adaptive simulation-extraction bound against real proofs for one Sigma protocol, derived here and not a result of [BS23] (general SimCoinSource and admissible form, combining the Attack Game 20.3 zero-knowledge hop with SimCoinSource presampling and [BN06], Lemma 1): under SpecialSoundness, SpecialHVZK, and UnpredictableCommitments R_honest δ, an adversary making at most Qp prove calls and Qro hash calls wins fiatShamirNIZKRealExtGameOn with probability at most Qp * (Qp + Qro) * δ + (Qro + 1) / |C| + √((Qro + 1) * ε'). The extractor has no efficiency claim (#5293).

theorem Cslib.Crypto.Protocols.SigmaProtocol.succProbability_fiatShamirNIZKRealExtGame_le {X Y T C Z : Type} [DecidableEq Y] [DecidableEq T] [Fintype Y] [Finite T] [Finite Z] [Fintype C] [Nonempty C] [DecidableEq C] {W : Type} {P : SigmaProtocol X Y T C Z} {R_honest : X → Y → Prop} {R : W → Y → Prop} [(w : W) → (y : Y) → Decidable (R w y)] {simulate : Y → C → PMF (T × Z)} {extract : Y → T → C → Z → C → Z → W} {valid : X → Y → Bool} {δ : NNReal} (hvalid : ∀ (x : X) (y : Y), valid x y = true → R_honest x y) (hsound : P.SpecialSoundness R extract) (hHVZK : P.SpecialHVZK R_honest simulate) (hUnpred : P.UnpredictableCommitments R_honest δ) {A : NIZKSimProver X Y T C Z} {Qp Qro : ℕ} (hA : A.CallBounded Qp Qro) :
↑(P.fiatShamirNIZKRealExtGame valid A).succProbability ≤ ↑Qp * (↑Qp + ↑Qro) * ↑δ + (↑Qro + 1) / ↑(Fintype.card C) + √((↑Qro + 1) * ↑(fiatShamirNIZKSimExtractGame R (fun (x : Y) => true) (P.fiatShamirNIZKSimExtract simulate extract valid A Qp Qro)).succProbability)

The concrete simulation-extraction bound of succProbability_fiatShamirNIZKRealExtGameOn_le against real proofs, over finite statement and transcript types, with every final statement admissible.

theorem Cslib.Crypto.Protocols.SigmaProtocol.succProbability_fiatShamirNIZKFreshStmtGameOn_le {X Y T C Z : Type} [DecidableEq Y] [DecidableEq T] [Fintype C] [Nonempty C] [DecidableEq C] {W : Type} {P : SigmaProtocol X Y T C Z} {R_honest : X → Y → Prop} {R : W → Y → Prop} [(w : W) → (y : Y) → Decidable (R w y)] {simulate : Y → C → PMF (T × Z)} {extract : Y → T → C → Z → C → Z → W} {valid : X → Y → Bool} {δ : NNReal} (hvalid : ∀ (x : X) (y : Y), valid x y = true → R_honest x y) (hsound : P.SpecialSoundness R extract) (hHVZK : P.SpecialHVZK R_honest simulate) (hUnpred : P.UnpredictableCommitments R_honest δ) (src : SimCoinSource Y T C Z simulate) (admissible : Y → Bool) {A : NIZKSimProver X Y T C Z} {Qp Qro : ℕ} (hA : A.CallBounded Qp Qro) :
↑(fiatShamirNIZKFreshStmtGameOn admissible P valid A).succProbability ≤ ↑Qp * (↑Qp + ↑Qro) * ↑δ + (↑Qro + 1) / ↑(Fintype.card C) + √((↑Qro + 1) * ↑(fiatShamirNIZKSimExtractGame R admissible (P.fiatShamirNIZKSimExtractWith src extract valid admissible A Qp Qro)).succProbability)

Fresh-statement corollary: outputting an accepted proof on a statement y* never queried on an accepted prove call (!(proved.map Prod.fst).contains y*) implies (y*, t*) ∉ proved, so the same simulation-extractability bound applies.

theorem Cslib.Crypto.Protocols.SigmaProtocol.succProbability_fiatShamirNIZKRealExtGameOn_le_of_false {X Y T C Z : Type} [DecidableEq Y] [DecidableEq T] [Fintype C] [Nonempty C] {W : Type} {P : SigmaProtocol X Y T C Z} {R_honest : X → Y → Prop} {R : W → Y → Prop} {simulate : Y → C → PMF (T × Z)} {extract : Y → T → C → Z → C → Z → W} {valid : X → Y → Bool} {δ : NNReal} (hvalid : ∀ (x : X) (y : Y), valid x y = true → R_honest x y) (hsound : P.SpecialSoundness R extract) (hHVZK : P.SpecialHVZK R_honest simulate) (hUnpred : P.UnpredictableCommitments R_honest δ) (src : SimCoinSource Y T C Z simulate) {admissible : Y → Bool} (hfalse : ∀ (y : Y), admissible y = true → ∀ (w : W), ¬R w y) {A : NIZKSimProver X Y T C Z} {Qp Qro : ℕ} (hA : A.CallBounded Qp Qro) :
↑(fiatShamirNIZKRealExtGameOn admissible P valid A).succProbability ≤ ↑Qp * (↑Qp + ↑Qro) * ↑δ + (↑Qro + 1) / ↑(Fintype.card C)

Concrete adaptive soundness bound on false statements for one Sigma protocol, derived here: if every statement accepted by admissible lacks a witness in R, then even after Qp adaptive prove queries on valid statements, A produces an accepted proof on an admissible false statement with probability at most Qp * (Qp + Qro) * δ + (Qro + 1) / |C|.

Specializations to SigmaProtocol.linear and SigmaProtocol.schnorr #

theorem Cslib.Crypto.Protocols.SigmaProtocol.linear_unpredictableCommitments_of_injective {q : ℕ} {M N Y C : Type} [AddCommGroup M] [Module (ZMod q) M] [Fintype M] [AddCommGroup N] [Module (ZMod q) N] [DecidableEq N] (ψ : Y → M →ₗ[ZMod q] N) (u : Y → N) (ι : C ↪ ZMod q) (hinj : ∀ (x : M) (y : Y), (ψ y) x = u y → Function.Injective ⇑(ψ y)) :
(linear ψ u ι).UnpredictableCommitments (fun (x : M) (y : Y) => (ψ y) x = u y) (↑(Fintype.card M))⁻¹

When ψ y is injective on every statement y having a witness x with ψ y x = u y, the commitments ψ y r of linear ψ u ι are (Fintype.card M)⁻¹-unpredictable.

noncomputable def Cslib.Crypto.Protocols.SigmaProtocol.linearSimCoinSource {q : ℕ} {M N Y C : Type} [AddCommGroup M] [Module (ZMod q) M] [Fintype M] [AddCommGroup N] [Module (ZMod q) N] [Fintype C] [Nonempty C] (ψ : Y → M →ₗ[ZMod q] N) (u : Y → N) (ι : C ↪ ZMod q) :
SimCoinSource Y N C M (linearSimulate ψ u ι)

Statement-independent SimCoinSource for linearSimulate ψ u ι: a single uniform draw from C × M determines (ψ y z - ι c • u y, c, z) at every statement y, requiring no finiteness on Y or N.

theorem Cslib.Crypto.Protocols.SigmaProtocol.linear_advantage_fiatShamirNIZKRealGame_simGame_le {q : ℕ} {M N Y C : Type} [AddCommGroup M] [Module (ZMod q) M] [Fintype M] [AddCommGroup N] [Module (ZMod q) N] [DecidableEq N] [DecidableEq Y] [Fintype C] [Nonempty C] (ψ : Y → M →ₗ[ZMod q] N) (u : Y → N) (ι : C ↪ ZMod q) (hinj : ∀ (x : M) (y : Y), (ψ y) x = u y → Function.Injective ⇑(ψ y)) {D : OracleComp (NIZKDistinguisherSpec M Y N C M) Bool} {Qp Qro : ℕ} (hD : NIZKCallBounded D Qp Qro) :
↑(((linear ψ u ι).fiatShamirNIZKRealGame (fun (x : M) (y : Y) => decide ((ψ y) x = u y)) D).advantage (fiatShamirNIZKSimGame (linearSimulate ψ u ι) (fun (x : M) (y : Y) => decide ((ψ y) x = u y)) D)) ≤ ↑Qp * (↑Qp + ↑Qro) / ↑(Fintype.card M)

Adaptive multi-theorem NIZK zero-knowledge bound for SigmaProtocol.linear.

theorem Cslib.Crypto.Protocols.SigmaProtocol.linear_succProbability_fiatShamirNIZKPokGame_le {q : ℕ} {M N Y C : Type} [AddCommGroup M] [Module (ZMod q) M] [Fintype M] [AddCommGroup N] [Module (ZMod q) N] [DecidableEq N] [Fact (Nat.Prime q)] [DecidableEq Y] [Fintype C] [Nonempty C] [DecidableEq C] (ψ : Y → M →ₗ[ZMod q] N) (u : Y → N) (ι : C ↪ ZMod q) (A : NIZKProver Y N C M) {Qro : ℕ} (y : Y) (hQro : ∀ (s : A.Coins), (A.prove y s).IsQueryBounded Qro) :
↑((linear ψ u ι).fiatShamirNIZKPokGame A y).succProbability ≤ (↑Qro + 1) / ↑(Fintype.card C) + √((↑Qro + 1) * ↑(fiatShamirNIZKExtractGame (fun (x : M) (y : Y) => (ψ y) x = u y) ((linear ψ u ι).fiatShamirNIZKExtract (linearExtract ι) A Qro y) y).succProbability)

Plain ROM proof-of-knowledge bound for SigmaProtocol.linear when q is prime.

theorem Cslib.Crypto.Protocols.SigmaProtocol.linear_succProbability_fiatShamirNIZKRealExtGame_le {q : ℕ} {M N Y C : Type} [AddCommGroup M] [Module (ZMod q) M] [Fintype M] [AddCommGroup N] [Module (ZMod q) N] [DecidableEq N] [Fact (Nat.Prime q)] [DecidableEq Y] [Fintype C] [Nonempty C] [DecidableEq C] (ψ : Y → M →ₗ[ZMod q] N) (u : Y → N) (ι : C ↪ ZMod q) (hinj : ∀ (x : M) (y : Y), (ψ y) x = u y → Function.Injective ⇑(ψ y)) (admissible : Y → Bool) {A : NIZKSimProver M Y N C M} {Qp Qro : ℕ} (hA : A.CallBounded Qp Qro) :
↑(fiatShamirNIZKRealExtGameOn admissible (linear ψ u ι) (fun (x : M) (y : Y) => decide ((ψ y) x = u y)) A).succProbability ≤ ↑Qp * (↑Qp + ↑Qro) / ↑(Fintype.card M) + (↑Qro + 1) / ↑(Fintype.card C) + √((↑Qro + 1) * ↑(fiatShamirNIZKSimExtractGame (fun (x : M) (y : Y) => (ψ y) x = u y) admissible ((linear ψ u ι).fiatShamirNIZKSimExtractWith (linearSimCoinSource ψ u ι) (linearExtract ι) (fun (x : M) (y : Y) => decide ((ψ y) x = u y)) admissible A Qp Qro)).succProbability)

Adaptive multi-theorem simulation-extractability bound for SigmaProtocol.linear when q is prime (requiring no finiteness on Y or N).

theorem Cslib.Crypto.Protocols.SigmaProtocol.schnorr_unpredictableCommitments {q : ℕ} [Fact (Nat.Prime q)] {G C : Type} [AddCommGroup G] [Module (ZMod q) G] [DecidableEq G] {ι : C ↪ ZMod q} {g : G} (hg : g ≠ 0) :
(schnorr ι g).UnpredictableCommitments (fun (α : ZMod q) (u : G) => α • g = u) (↑q)⁻¹

Commitments of schnorr ι g are (q : ℝ≥0)⁻¹-unpredictable whenever g ≠ 0 (reusing schnorr_commit_map_fst_le).

theorem Cslib.Crypto.Protocols.SigmaProtocol.schnorr_fiatShamirNIZK_complete {q : ℕ} [Fact (Nat.Prime q)] {G C : Type} [AddCommGroup G] [Module (ZMod q) G] [DecidableEq G] {ι : C ↪ ZMod q} {g : G} [Fintype C] [Nonempty C] {α : ZMod q} {u : G} (hαu : α • g = u) (cache : List ((G × G) × C)) :
(do let coins ← (schnorr ι g).commit α u let __x ← (OracleComp.interpret (ROMSignature.oracle C) ((schnorr ι g).fiatShamirNIZKProve α u coins)).run cache match __x with | (prf, cache') => do let __x ← (OracleComp.interpret (ROMSignature.oracle C) ((schnorr ι g).fiatShamirNIZKVerify u prf)).run cache' match __x with | (acc, snd) => pure acc) = PMF.pure true

Perfect completeness of Schnorr Fiat–Shamir NIZK proofs in the lazy random-oracle model.

theorem Cslib.Crypto.Protocols.SigmaProtocol.schnorr_advantage_fiatShamirNIZKRealGame_simGame_le {q : ℕ} [Fact (Nat.Prime q)] {G C : Type} [AddCommGroup G] [Module (ZMod q) G] [DecidableEq G] {ι : C ↪ ZMod q} {g : G} [Fintype C] [Nonempty C] (hg : g ≠ 0) {D : OracleComp (NIZKDistinguisherSpec (ZMod q) G G C (ZMod q)) Bool} {Qp Qro : ℕ} (hD : NIZKCallBounded D Qp Qro) :
↑(((schnorr ι g).fiatShamirNIZKRealGame (fun (α : ZMod q) (u : G) => decide (α • g = u)) D).advantage (fiatShamirNIZKSimGame (linearSimulate (fun (x : G) => LinearMap.toSpanSingleton (ZMod q) G g) id ι) (fun (α : ZMod q) (u : G) => decide (α • g = u)) D)) ≤ ↑Qp * (↑Qp + ↑Qro) / ↑q

Adaptive multi-theorem NIZK zero-knowledge bound Qp * (Qp + Qro) / q for Schnorr Fiat–Shamir NIZK proofs when g ≠ 0.

theorem Cslib.Crypto.Protocols.SigmaProtocol.schnorr_succProbability_fiatShamirNIZKPokGame_le {q : ℕ} [Fact (Nat.Prime q)] {G C : Type} [AddCommGroup G] [Module (ZMod q) G] [DecidableEq G] {ι : C ↪ ZMod q} {g : G} [Fintype C] [Nonempty C] [DecidableEq C] (A : NIZKProver G G C (ZMod q)) {Qro : ℕ} (u : G) (hQro : ∀ (s : A.Coins), (A.prove u s).IsQueryBounded Qro) :
↑((schnorr ι g).fiatShamirNIZKPokGame A u).succProbability ≤ (↑Qro + 1) / ↑(Fintype.card C) + √((↑Qro + 1) * ↑(fiatShamirNIZKExtractGame (fun (α : ZMod q) (u : G) => α • g = u) ((schnorr ι g).fiatShamirNIZKExtract (linearExtract ι) A Qro u) u).succProbability)

Plain ROM proof-of-knowledge bound for Schnorr Fiat–Shamir NIZK proofs.

theorem Cslib.Crypto.Protocols.SigmaProtocol.schnorr_succProbability_fiatShamirNIZKRealExtGame_le {q : ℕ} [Fact (Nat.Prime q)] {G C : Type} [AddCommGroup G] [Module (ZMod q) G] [DecidableEq G] {ι : C ↪ ZMod q} {g : G} [Fintype C] [Nonempty C] [DecidableEq C] (hg : g ≠ 0) (admissible : G → Bool) {A : NIZKSimProver (ZMod q) G G C (ZMod q)} {Qp Qro : ℕ} (hA : A.CallBounded Qp Qro) :
↑(fiatShamirNIZKRealExtGameOn admissible (schnorr ι g) (fun (α : ZMod q) (u : G) => decide (α • g = u)) A).succProbability ≤ ↑Qp * (↑Qp + ↑Qro) / ↑q + (↑Qro + 1) / ↑(Fintype.card C) + √((↑Qro + 1) * ↑(fiatShamirNIZKSimExtractGame (fun (α : ZMod q) (u : G) => α • g = u) admissible ((schnorr ι g).fiatShamirNIZKSimExtractWith (linearSimCoinSource (fun (x : G) => LinearMap.toSpanSingleton (ZMod q) G g) id ι) (linearExtract ι) (fun (α : ZMod q) (u : G) => decide (α • g = u)) admissible A Qp Qro)).succProbability)

Adaptive multi-theorem simulation-extractability bound Qp * (Qp + Qro) / q + (Qro + 1) / |C| + √((Qro + 1) * ε') for Schnorr Fiat–Shamir NIZK proofs when g ≠ 0 (requiring no finiteness assumption on G).