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.
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.
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.
With a proof of knowledge, we have to show three things.
For completeness, I showed you how this check works during the honest case, which is the easy case.
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.
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.
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:
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.
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.
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.