Just for a recap, the discrete log problem is the fact that if we have an equation like this, where g is a generator of the group Zp∗, and x is your private key, calculating f(x) is easy with binary exponentiation. But given g, f(x), and p, finding x is hard.
From here, I want to move on to talking about elliptic curve cryptography, or ECC. This is a different candidate one-way function, which works over a different group.
In the discrete log problem, we were working over the multiplicative group, and the multiplicative group has a few properties that it must satisfy. The first one was closure. The second was associativity. The third was an identity element. And the fourth was an inverse.
The elliptic curve works over a different group. Here, we are talking about additive groups. A standard elliptic curve equation is this:
At the x-axis, it's reflected. The exact same thing is being shown here, but it's negative.
An additive group has a different set of properties that it must fulfill. An identity element exists. The inverse must exist. We must also have point addition defined. And lastly, we should have point doubling also defined. What do all of these mean?
The identity element. In an additive group, we have this special abstract point. You can just call it big O. It's just an abstract point, which is called the point of infinity. To be honest, I don't think it's that easy to visualize these things. With integers, it's very easy to just visualize things, but when we start moving into these graph-based groups, things become more abstract. Its purpose is that if we have a point P on this curve, P + O should equal P. Nothing should happen to it. I can't just say zero here, because I think with the curve properties, that might not be true.
The inverse. We have this point, which is just coordinates on an xy coordinate plane. There also exists −P, whose coordinates are (x, −y). In an elliptic curve, the top half is just a reflection of the bottom half, because of this y2. For every point P, there's also a negative of that point, which should mean that when you add that original point with that inverse point, you should get the identity element. This is very similar language to our multiplicative group: when we have our original element and we multiply it by the inverse of that element, we get the identity element, which in that case was one.
Point addition. If you draw a straight line through P and Q, by the nature of this graph you are bound to intersect one more point, which we can call R. The negative of that R, which is −R, is P + Q.
Point doubling. We have a point P, and we want to find 2P, which is the same as P + P. There's only one P, so you can't draw a line between two points. But if I draw the tangent line, the line which just touches the curve at P, and extend it until it hits the graph again, I get one more point. We're able to double a point by drawing the tangent line through it and then reflecting it across the x-axis. And that gives us the double of that point.
Someone asked the obvious question: the line meets the curve at R, so why is the answer −R and not R? This is the property of the graph. In an elliptic curve, if you take P and Q, two random points on the curve, and you draw a line through them, it's guaranteed to intersect one more point on that curve, and the negative of that point is the answer to P + Q. The exact concept, I'm not sure where the math is coming from there. For this lesson specifically, proving the definition of an additive group is not the scope of this session. It might be a good exercise: prove this. But for now, I'm just trusting the literature.
Someone in the room suggested it might simply be a convention, and that is close. The group law is set up so that three points on one line add up to the identity, P + Q + R = O. Move R to the other side and you get P + Q = −R.
That's why I was also saying it's hard to visualize this. Let's take a step back.
Let's look at a parabola, which is simple. Everyone can visualize this easily. The equation is y = x2. The idea is that within this graph, we're able to do operations. That's the idea you should get from even this elliptic curve. In this case, the operations are addition. In a parabola, we are able to do multiplication.
If I want to do a × b, what I'm going to do in a parabola is pick P and pick Q, which are (−a, a2) and (b, b2). In this case, it's going to be 3 × 4, which is 12. We pick these two points: (−3, 9) and (4, 16). And the line through them crosses the y-axis at 12 as well.
Does that work for any two numbers, or was 3 and 4 a lucky pick? Move a and b and watch where the line crosses.
A fact of parabolas is that our line, y = mx + c, intersects the y-axis at c, and a × b is also equal to c. For parabolas, I can just show you very quickly why it's true. We have two points, (−a, a2) and (b, b2). If I substitute them into y = mx + c, I get a2 = −ma + c and b2 = mb + c. We will try to solve for c.
So the (a + b) cancels. In this case, I chose three and four. I choose the points in this form, and then I draw a straight line through them, and where it crosses the y-axis is going to be a × b. And for that, this is a proof.
For an elliptic curve, there's also something similar. The intuition you should understand is that we're able to do operations on a curve to get the answers of those operations. Here we were multiplying. Here we're doing addition, pretty much. That's it. And doubling is pretty much the same as point addition. Here we just have two P's, so it's P + P.
I have a visual here, maybe to help understand things better. The curve is y2 = x3 − 2x + 2. P is (1, 1) and Q is (2, 2.45). We drew a line through them. The green dot, which is R, the reflection of that across the x-axis is the value of P + Q. As I shift my point, we're just reflecting that point, and that's giving us the addition of those two points. Now, if I just have one point, which is P, you can see that the tangent line at P hits the curve at one more point, which is the green dot, and the reflection of that is the doubling of that point P. If I move that point, we're just creating a different tangent line, and then the value of R changes.
Here is that visual. Where does P + Q land when you move the points, when Q is the same point as P, and when Q is the mirror image of P?
When Q is the mirror image of P the line is vertical and never meets the curve a third time. That is the case the point at infinity exists for: P + (−P) = O.
Knowing that the elliptic curve has these properties of an additive group, we can now look at the elliptic curve discrete log problem. Similar to how we talked about the discrete log problem, the equation is just this:
Q is going to be your public key. Remember that Q is a coordinate point. It's not an integer. So it's going to be in the form (x, y). G is a generator. And k would be your private key. In the case of the discrete log problem, x was your private key. Similarly, k is your private key, and the public key is what the output will be, which, again, is a point on an elliptic curve.
If you want to talk about Bitcoin specifically: the standard elliptic curve equation has x and y, that's all good, but what are these constants, a and b? Different equations can change this constant value, and then it generates a new curve. If I remember correctly, for Bitcoin, a is zero and b is seven. In that case, the equation becomes y2 = x3 + 7. For Bitcoin, this is the elliptic curve that they use to pick points on the curve and generate public and private keys.
Calculating Q = k · G is easy, given point addition and point doubling. The generator is a point on this curve, and you add it k times, where k is generated randomly. You can do point doubling and point addition for that.
Two people corrected me here. k is not a point on the curve. It is a number, a 256-bit random number, and the generator is the point, added k times. In an additive group we cannot multiply two points. Yeah, I also think that makes more sense, to be honest.
I drew this graph here, but for a lot of curves, there's not even a graph. You have random points scattered across the graph, and they're part of the curve, but the curve is not continuous.
So it looks something like this: just random points. G is fixed. You can Google it. The upper bound of k is also fixed: a large prime, close to 2256. We start at G, and we jump around k times. It's very hard to predict how many times we jumped. Let's say it was here. This is now our Q. Given these two points that are public, it's very hard to trace these random steps that we took to find that k value. This is the intuition I understand around ECDLP.
This is how Bitcoin generates its raw public keys and raw private key. I don't know what it does after generating these points. I think it compresses them and does a bunch of other stuff. But the raw points that come out from this curve are, in a sense, the raw values of your public and private key.
For this specific curve, any point other than the point at infinity is a valid generator. What I understood about why that's the case: in Zp∗, I said that there is at least one generator, and that's true. It's also true that not every element is a generator. We can't choose any number within this range and expect it to generate this entire range again.
That is because of the fact that the order of Zp∗ is p − 1, because it has p − 1 elements, which means that it's composite. p is a prime, so p − 1 is even, which makes it composite. If the order of a group is composite, you can't have every element be a generator. This is a hand-wavy explanation, I guess, but you might get stuck. If you're trying to generate g1, g2, g3, and you end up at an element that you've already seen before, then you're going to start that loop again. That can exist for groups which have a size of a composite number, because they have many factors.
In the case of this curve, the order of this group is prime. It has a prime number of elements inside. So if we choose any random point inside this group, we are not expected to accidentally start this loop, where we keep repeating the same numbers and the other numbers are missed out. That's the hand-wavy explanation I'll give, and the best that I understand, for why, in the case of Bitcoin, any point is a valid generator.