kartikeya sharma
AI Verification · Applied Cryptography · AI Safety

Rewinding The Prover

Friday, September 25, 2026

CryptographyBitcoinDigital SignaturesZero Knowledge Proofs

Notice how a lot of these schemes assume that this problem, the discrete log problem, is hard to solve. If someone comes up with an easy solution, then all of a sudden private keys can be computed easily. All of a sudden transactions can be signed easily, because we would be able to create a forgery of the signature.

Before I talk about the actual signature scheme, we'll look at what was first discovered. The Schnorr digital signature scheme came after something called the Schnorr proof of knowledge. And this is modelled, again, as an interactive game, similar to how we saw this game between a challenger and an adversary. The goal is for a prover to prove to a verifier that they know a secret X without revealing X.

Peter and Veronica

We have the discrete log problem, which is Y = GX mod P, where P is a prime. This Y will be our public key, and this X will be our secret key. And we basically want to prove to someone that we possess this X without showing them X. So you're proving that you have knowledge of X. You're not showing X, though.

Q is a large prime, so that's public info. The generator, everyone knows. The generator is also a public parameter. Let's give them names: the prover is Peter, and V is Veronica.

  1. We randomly pick a secret value X from the set of integers up to Q, so this is from 0 to Q − 1. And then we calculate our public key, Y = GX. We know that if we just give Veronica a Y, it's very hard for her to get the X from this.
  2. Peter gives Veronica the output, Y. And he also creates another random value. Think of this as two steps. This random value is again from the same field. We're just going to create a random R as well, which also comes from ZQ. I'll just call this α = GR. And then we send both Y and α to Veronica.
  3. Veronica picks a random value C too, from the same field, and she sends it over to Peter.
  4. Then we just do this calculation: S = R + X·C mod Q. And then we send the output S to Veronica.
  5. What does she know right now? She knows Y, she knows α, and she just got S. So based on these values that she got, she checks if GS equals α · YC.
s = r + x·c mod q      gs ≟ α · yc

Why does this work? If we try to expand this equation: α is GR, and Y is GX, so YC is (GX)C. When we raise a power to a power, we multiply the exponents, and when we multiply powers of the same base, we add the exponents. So the right side becomes GR + XC. And if you notice, S was also exactly this, R + XC. So it's basically checking if GR + XC is equal to GR + XC. But obviously, they don't see this X. They're just computing on the actual output.

R is supposed to be like a masking factor. If we didn't have R, and we just sent X·C mod Q, Veronica is the one who gave C, so she might be able to calculate what X is. But if we mask this whole equation with a random value, then X stays hidden, which is our secret key. We don't want Veronica to know the secret key. We just need her to know that I have this key.

And why is she sending C? We need another party to send another random value. Otherwise, Peter could just create an equation that would satisfy this property without actually knowing X. So there has to be some input given to Peter that is not something he himself calculated. Both prover and verifier have skin in the game, because the verifier is the one who's controlling the C, and the prover is the one who's controlling these things.

Run it: does Veronica's check pass, and does she ever see x?
Toy parameters: p = 2039, q = 1019, g = 4 (g has order q mod p). Real Schnorr uses 256-bit numbers; the algebra is identical.
Peter (prover)
secret xhidden
y = gx mod p
mask rhidden
α = gr mod p
Veronica (verifier)
s = r + x·c mod q
gs mod p
α·yc mod p
Veronica only ever sees y, α, c and s. Drag the challenge: s moves all over the field, the check passes every time, and x is never sent.

Three things to prove

With a proof of knowledge, we have to show three things.

  • Completeness means an honest prover plus an honest verifier always pass the check. There shouldn't be a bug in the code where, even if we're always honest, sometimes it says you failed.
  • Soundness means a dishonest prover, being someone who actually doesn't know X, fails the check every time, except with negligible probability. There might be a fluke once in a while, because all of these values are chosen randomly. So there is a chance of one over the order of the field that they might get it correct.
  • Zero knowledge means that nothing about the private information, which is X in this case, leaks to the verifier. The whole point is for us to not show Veronica X.

For completeness, I showed you how this check works during the honest case, which is the easy case.

How often does a Peter who does not know x get through?
A cheating Peter's best move: guess the challenge c* in advance, pick any s, and send α = gs·y−c*. If Veronica happens to send c*, the check passes. Every run below is the real modular arithmetic.
group size q
who picks the challenge?
0attempts
0passed the check
–pass rate
1 / q
Press run.
When Peter picks c himself he passes every time without knowing x, which is why c has to come from someone else. The same trick, run with Veronica's real c, is what the zero-knowledge simulator does: it writes transcripts (y, α, c, s) that verify, and it never knew x.

Soundness: rewind the tape

Initially, when I first learned it, I was also kind of confused, because it didn't make any practical sense. But I was told to just think of this as a mental experiment, and maybe you can also try to do the same. Hear me out, and then let's talk about it.

X and R are both created from this field, and then we calculate Y = GX and α = GR, and we send both of these to the verifier. Now the verifier creates a random value, again from this field, and sends that over to the prover. We'll call this C1. And now the prover calculates this S value, I'll call it S1, which is R + C1X mod Q.

s1 = r + c1x mod q

Now what happens is we stop this game, and we rewind the tape. We rewind the program, the tape, the virtual machine, whatever you want to think of it. Basically, you go back in time to this point. And at this point, the α value is already calculated, and R is already calculated. Now what we can do is tell the prover to prove it again: "Hey, you've done it once, do it again." So the verifier creates a C2 and gives C2 to the prover. But our random value is fixed, remember. So S2 will now be the same random value plus C2X mod Q.

s2 = r + c2x mod q

We have the same R, the same X. We can subtract these equations, and the R will cancel out. R − R cancels out, and we can solve for X:

x = (s1 − s2) / (c1 − c2) mod q

If we were able to give two challenges to a prover at this point in time, they must know X, because if they've created valid S values, then we can see that X is easily computable. And if a prover does not know X, then they would not be able to compute these S1 and S2 correctly, so this equation would not be possible.

This is the idea behind the forking lemma. This is a point at which we forked and we fixed our random value, and then we consider two cases with the same random value. We go back, we rewind the tape, and then we look at two cases with our previous values fixed, to prove whatever we want to prove.

Rewind Peter once. How much of his secret do two answers give away?
Same toy group (p = 2039, q = 1019, g = 4). Peter commits to α once. Veronica asks c1, then the tape is rewound to just after α and she asks c2.
α (fixed by the fork)
s1, s2 (both pass Veronica's check)
(s1 − s2)·(c1 − c2)−1 mod q
Peter's actual secret x
All of it. The only case that fails is c1 = c2, where there is nothing to divide by.

Someone in the room connected this to signatures: if the same random value is used for two signatures, it cancels out and exposes the private key. That's the same algebra. Here the rewind is a thought experiment that proves soundness. In a signature scheme, reusing the random value by accident leaks the key.

Zero knowledge

With zero knowledge, you basically want to rely on a simulator. And the simulator, imagine it's just a computer program. It should be able to simulate all of the important transcript values of the scheme without actually knowing X. Whatever it does, it should give us Y, α and S, which should be computationally indistinguishable from the real Y, α and S, which were created by the actual prover. Maybe we need a full session on this: what does it mean to be computationally indistinguishable? But if we can show that a program is able to produce this type of output, and it has no knowledge of X, then we can prove that it's zero knowledge.

This is not a digital signature. This is just a proof of knowledge scheme, which came first. And then from this, Schnorr created a digital signature scheme. We'll talk about how to convert this interactive proof of knowledge into a non-interactive digital signature, and then how to turn that into an elliptic curve version, which is the one used in Bitcoin.

← Back to all articles