kartikeya sharma
AI Verification · Applied Cryptography · AI Safety

Why Bitcoin Wants A Group Of Prime Order

Friday, September 11, 2026

CryptographyBitcoinElliptic Curves

Last week, we started talking about the elliptic curve discrete log problem. Before that, we were talking about the standard discrete log problem: we have this function, f(x) = gx mod p, where x is your secret and p is a large prime.

f(x) = gx mod p

The problem with p − 1

Zp∗, which we said was a multiplicative group, included elements one up to p − 1. So the size of this group, what we also call order, is p − 1 exactly. If p is a prime, then this goes from one all the way up to p − 1. We don't skip anything, because every number is co-prime with p here.

p is a prime, so p − 1 is a composite number, which has factors. It's an even number. There's a possibility of this whole group having multiple subgroups. The way you can think of it is, since the size of this group is composite, it's possible that we can split this group into smaller subgroups, and then we can try and attack these smaller subgroups. That makes it easier for us to break the discrete log problem. If you choose a large enough prime, then you're still dealing with very large numbers, but this is a known attack. It's called the Pohlig-Hellman algorithm.

This is not really important, but I started with this because I think it gives a better intuition of how the elliptic curve discrete log problem works.

What do those subgroups look like? Pick a prime, then click any number to use it as g. The filled cells are everything g can reach.

Prime p
–
Subgroup sizes in this group (how many numbers generate a subgroup of that size)
–numbers g reaches
–p − 1
–
A filled cell is a power of g mod p. The size of the subgroup g generates always divides p − 1, so the only sizes that can appear are the ones listed.

For p = 23, p − 1 is 22 = 2 × 11. Ten of the 22 numbers generate a subgroup of exactly 11 elements, and 11 is prime. That subgroup is what the next section builds on purpose, with q = 11 and k = 2.

Forcing the math into a prime-order subgroup

If it is the case that you can break this group of composite order into smaller subgroups to do some sort of attack, what is best practice is that the order of the group should be prime. Because if its order is prime, it can't be broken down into smaller factors.

What we try to do, in the case of the discrete log problem where we're dealing with this multiplicative group of integers, is create a subgroup that is of prime order. How should we go about doing this? Because if we choose a large prime p here, we know that the total number of elements in this group goes up to p − 1. So we will always end up with a composite number.

The way to do this is we choose q, which is a large prime, and then we also choose p, which is a larger prime. So we basically choose two prime numbers. And we choose p such that p = kq + 1, where q is this prime that we just chose and k is just an integer, a constant.

p = kq + 1   ⇒   |Zp∗| = p − 1 = kq

Let's see what happens to the size of the group. The size of this group is p − 1. If our p is a constant times another prime plus one, we get kq + 1 − 1, which equals kq. So the size of that group now will be a constant times a prime.

So q divides p − 1. And if q perfectly divides p − 1, then there's a theorem that guarantees our larger group, Zp∗, has a subgroup of order q. If that subgroup exists, which is a smaller subgroup, but it's a safer subgroup, then you can do all your operations in that subgroup now, instead of doing it on this one where the size is a composite number.

The same idea on Bitcoin's curve

The reason I wanted to show this is that last week I was myself a little confused about this elliptic curve discrete log problem. We defined it like this:

Q = k · G  (mod p)

Here, Q and G are points on the elliptic curve, and these are all points that belong to a finite field. For now, just assume it contains integers up to p. The size of this field is p. Q, in the context of Bitcoin, is our public key, and G is our generator. We're multiplying it by k, which is our secret or private key. And as someone pointed out last time, k is not a point on this graph.

For Bitcoin, y2 = x3 + 7.

Suppose you have a p, which is prime. It has a lot of elements. Now you layer this equation, y2 = x3 + 7, on top of this whole set of possible numbers. You're looking for values in this finite set that satisfy this equation. Some values will not work, and so they will be excluded. You started off with order p, and then you are left with, I called it n, which is all of the points, (x1, y1), (x2, y2). These are all values in this field of size a big prime p, and they are also coordinates on this curve. The size of that set, I called it n.

In the case of Bitcoin, this is also a prime, and it's close to p. I'm sure this was on purpose. They purposefully chose the equation so this is the case. By the way, this is a different prime, different from p. And since it's a prime, its factors are only 1 and n.

Now your k, the private key, is chosen from another field. You have a field of size p, which is a prime. Now you have another field, which is the field over which the scalar value k is chosen. We can call this field q, and the size of this field is n.

The key clarification I got was that we have two fields, and they are two different fields. One is where the k is chosen from, and one is where these points Q and G are chosen. Field p works over the coordinates Q and G, and field q works over the scalar k.

k (mod q)      Q, G (mod p)

I think the reason for this is, like I tried to explain with the standard discrete log problem, that you try to force the math into a subgroup of a prime order. For Bitcoin, they chose the curve specifically so that n is also prime. But if it was not prime, you could have done an extra step, a similar exercise, to find that subgroup which is of prime order.

Someone pushed back on "two fields" near the end. Their point: q is not chosen, it is derived. It is the number of points that satisfy the equation for the given p, and k cannot usefully be bigger than it, because after q steps you are back where you started, like a clock. What I'm wondering is, aren't we using two fields, because our first one is from 0 to p − 1? k is not chosen from this. So we would need a separate field of a different order. The size is n.

Both descriptions are the same thing. Because n is prime, the whole numbers mod n are themselves a field, and that is the field the scalar k lives in.

Someone suggested trying it with small numbers: keep the equation y2 = x3 + 7 and take p as 13. I agree. I think it helps if you work with small numbers.

So here it is. How many points are on the curve for a small p, is that number prime, and can every point reach all the others?

Field prime p  (the curve is always y² = x³ + 7)
–points on the curve, n
–points G can reach
–Q = k · G
–
Every dot is a pair (x, y) below p that satisfies the equation mod p. n counts those dots plus the point at infinity. Filled dots are the ones G reaches by adding itself. The line follows the hops G, 2G, 3G, up to kG.

For p = 13 the curve has 7 points, and 7 is prime, so every point reaches all of them. For p = 17 it has 18, and a point can get stuck in a subgroup of 2, 3, 6 or 9. For p = 31 it has 21 = 3 × 7, which is not prime but contains a subgroup of prime order 7: that is the extra step mentioned above. The count is close to p but is a different number, and it can land on either side: 7 for p = 13, 18 for p = 17.

Hopping around the curve

The generator is fixed. You can Google what the Bitcoin generator is. This is hard-coded in software, hardware, etc. Now the k, which is your secret key, comes from a group of prime order. Remember, I said that if you have a group which is of composite order, you could do attacks. But if you have a group of prime order, the maximum you can reduce the problem to is that prime itself and one. And one doesn't really tell you anything, because you can't break it down further.

You're going to hop k times. I told you many times that the goal of the generator is to generate the entire group if you multiply it by itself. I showed you that with this multiplicative group. The case stays the same for elliptic curves. If I pick k = 7, I'm going to go from this generator here, 1. Maybe this was the next point, 2. Then maybe this was the next point, 3. Then 4, 5, 6, 7. And then we stop here.

This is not like Zp∗. Zp∗ is a continuous set of 1, 2, 3, 4, 5, all the way up to p − 1. This looks random. You're hopping around 7 times. You end up here. What is this point now? Q, which is our public key. Of course, some stuff probably happens beyond this to make it the true public key. This is the raw public key.

Now your adversary is wondering. This G is public, so they know this point, and they also know Q, because that's your public key. They're wondering, how did you get from here to here? How many hops did you make? We know we made seven hops, but because of the nature of this curve, even if the points are close together, you have no idea how to get to that point. You basically have to brute force.

Two fields, one reason

Initially what I didn't understand is that we're actually operating over two fields. One is the field for the scalar value, one is the field for the coordinate points. Then I tried to understand why that is the case. I think the intuition is similar to what I explained with the discrete log problem, where you want to do your operations in a set or a field which is of order a prime number, because you cannot break those down into subgroups of those factors and then solve those. Solving smaller numbers is easier. But if the order itself is a prime number, then you're stuck with that whole value.

We said we can do this trick called binary exponentiation to calculate the discrete log equation quickly. For this equation, why is calculating it easy? What are we doing? Let's talk about this next week.

← Back to all articles