Lesson 15 of 15
Zero-Knowledge Proofs (Schnorr)
Zero-Knowledge Proofs
A zero-knowledge proof (ZKP) lets a prover convince a verifier that they know a secret, without revealing the secret itself. Introduced by Goldwasser, Micali, and Rackoff (1985), ZKPs are a cornerstone of modern cryptography.
Three Properties of a ZKP
- Completeness — if the prover knows the secret, they can always convince the verifier
- Soundness — a cheating prover (who doesn't know the secret) cannot convince the verifier except with negligible probability
- Zero-knowledge — the verifier learns nothing about the secret beyond its existence
Schnorr Identification Protocol
The Schnorr protocol (Claus Schnorr, 1989) proves knowledge of a discrete logarithm in zero-knowledge.
Setup: prime , subgroup of order (where ), generator of order .
Public key: (prover knows private key ).
Protocol (3 moves):
- Commit: Prover picks random , sends
- Challenge: Verifier sends random
- Respond: Prover sends
Verification:
This works because:
Example
, , , private key , public key .
- Commit: ,
- Challenge:
- Response:
- Verify: ✓
Your Task
Implement:
schnorr_commitment(g, r, p)→schnorr_response(r, challenge, priv_key, q)→schnorr_verify(g, pub_key, commitment, challenge, response, p, q)→bool
Python runtime loading...
Loading...
Click "Run" to execute your code.