AFTD Auto-Formalizing Theoretical Domains

Schnorr.schnorr_hvzk

theoremverifiedformalizationimported Lean

Honest-verifier zero knowledge of the Schnorr protocol. Let $G$ be a commutative group, let $q$ be prime, and let $g \in G$ be an element of order $q$, taken as the public generator. Fix a witness $w \in \bbz_q$ and a challenge $c \in \bbz_q$, and let $\mathit{pk} = g^{w}$ be the associated public key. Then, as functions $\bbz_q \to G \times \bbz_q \times \bbz_q$ of the prover's randomness $r$, the honest transcript map $r \mapsto \big(g^{r},\, c,\, r + c\cdot w\big)$ coincides with the simulator map fed the reindexed randomness $\sigma_{w,c}(r) = r + c\cdot w$, namely $r \mapsto \big(g^{\sigma_{w,c}(r)}\cdot(\mathit{pk}^{\,c})^{-1},\, c,\, \sigma_{w,c}(r)\big)$; that is, these two maps are equal.

Statement

set_option relaxedAutoImplicit false in
set_option autoImplicit false in
variable {G : Type*} [CommGroup G] in
variable {q : ℕ} [Fact q.Prime] in
variable (g : G) in
theorem Schnorr.schnorr_hvzk
    (hg : orderOf g = q) (w c : ZMod q) :
    (fun r => honest g w r c) =
    (fun r => simulate g (g ^ w.val) c (reindex w c r))
Formalizes
Honest-verifier zero knowledge of the Schnorr protocol, as formalized in TCSlib (`Schnorr.schnorr_hvzk`)
Lean proof
By Hydroxyi (from the file's git history), from github.com/Shilun-Allan-Li/tcslib at c8a02591b1e5 (Apache-2.0). Compiled here against leanprover/lean4:v4.33.1, Mathlib v4.33.1; written for leanprover/lean4:v4.25.0.
Verified
07 Oct 2026
Axioms
Classical.choiceQuot.soundpropext
Built on 6
  • Schnorr.reindexFor fixed $w, c \in \mathbb{Z}_q$, define the bijection $\sigma_{w,c} : \mathbb{Z}_q \xrightarrow{\;\sim\;} \mathbb{Z}_q$ by…
  • Schnorr.schnorr_completenessCompleteness of the Schnorr identification protocol. Let $q$ be a prime, let $G$ be a commutative group, and let $g \in G$ be an element…
  • Schnorr.simulateThe zero-knowledge simulator, given public key $\mathit{pk}$, challenge $c$, and a fresh response $s$, outputs the transcript…
  • Schnorr.respondGiven witness $w$, randomness $r$, and challenge $c$ in $\mathbb{Z}_q$, the response is $s := r + c \cdot w \in \mathbb{Z}_q$.
  • Schnorr.honestThe honest prover's full transcript for witness $w$, randomness $r$, and challenge $c$ is the triple…
  • Schnorr.commitGiven randomness $r \in \mathbb{Z}_q$ and a generator $g \in G$, the commitment is $a := g^{r}$, where the exponent is taken via the…

Lean source view module on GitHub

set_option relaxedAutoImplicit false inset_option autoImplicit false invariable {G : Type*} [CommGroup G] invariable {q : ℕ} [Fact q.Prime] invariable (g : G) in/-- **HVZK (pointwise)**: for every fixed witness `w` and challenge `c`, with generator `g` of order `q`, the honest transcript function `r ↦ honest g w r c` and the simulator transcript function `s ↦ simulate g (g^w) c s` are equal as functions `ZMod q → Transcript G q` after the bijective reindexing `s = r + c·w` (i.e. `reindex w c`). -/theorem Schnorr.schnorr_hvzk    (hg : orderOf g = q) (w c : ZMod q) :    (fun r => honest g w r c) =    (fun r => simulate g (g ^ w.val) c (reindex w c r)) := by  funext r  simp only [honest, simulate, commit, respond, reindex]  refine Prod.ext ?_ rfl  rw [eq_mul_inv_iff_mul_eq]  exact (schnorr_completeness g hg w r c).symm
See it in the graphDiscuss this resultChallenge it