
Zero Knowledge Proofs (ZKP) are a mechanism of computing a mathematically verifiable cryptographic proof of a true statement without actually revealing any amount of information about the statement other than it holds true.
For instance, a bank could use ZKP of your credit score to give you a loan without asking for your bank statements, ID, employment history, etc. Another great example is Crypto Idol, a singing contest completely judged by a neural network. You can't cheat by submitting a false result because the leaderboard system won't accept the result without a valid proof, which you can't generate unless you actually run a network on your input. Neat, right?
The Chaum-Pedersen Protocol
This protocol is used to authenticate a user with a server by proving the possession of a secret X (the password) without revealing X itself.
These are the steps:
- The prover generates two public keys: Y1 = G^X mod P and Y2 = H^X mod P, where G and H are generators of the group
- The prover picks a random number K and sends R1 = G^K mod P and R2 = H^K mod P to the verifier
- The verifier generates a random challenge C and sends it to the prover
- The prover computes S = K - C * X mod Q and sends S to the verifier
- The verifier checks if G^S * Y1^C = R1 mod P and H^S * Y2^C = R2 mod P
The Protocol Diagram

Critical Details
A very important detail is left out until now for the sake of simplicity: Y1, Y2, R1, R2 are computed modulo P and S is computed modulo Q. The strength of the protocol lies in the inability to compute the discrete logarithm in reasonable time. When given Y1 = G^X mod P, it is impossible to confidently compute X given Y1, G and P due to the circular nature of modular arithmetic.
Apart from this, it is very important to note that random numbers K and C must be:
- Truly random (not generated with a predictable pattern)
- Never reused (unique for each authentication round)
Let's see what happens if any of these two cases are not fulfilled. Imagine the client decides to reuse K for two successive authentication steps, and the server generates two different challenges C1 and C2 and receives two correct solutions S1 = K - C1 * X and S2 = K - C2 * X. By subtracting these two equations the server could easily obtain the client's password X:
S2 - S1 = (K - C1 * X) - (K - C2 * X)
S2 - S1 = K - C1 * X - K + C2 * X
S1 - S2 = (C2 - C1) * X
X = (S2 - S1) / (C2 - C1)
If we assume the generator doesn't have a uniform distribution but, for instance, draws a group of 1000 numbers more likely than others, the server could send many queries to determine those 1000 most frequent solutions the client is sending back, and then brute force each of the 1000 * 1000 pairs similarly to the previous attack.
Implementation
Implementation in Rust can be found in my GitHub repo: zkp-chaum-pedersen