Path: blob/main/foundations/06-elliptic-curves/sage/06d-group-structure-and-order.ipynb
483 views
Notebook 06d: Group Structure and Order
Module 06. Elliptic Curves
Motivating Question. We know that is a finite group with points. But how many points exactly? And what does the group look like, is it always cyclic, or can it be a product of two cyclic groups? The answers come from two deep theorems: Hasse's theorem (which bounds the count) and the structure theorem (which says the group is either or ). Understanding these is essential for choosing secure curve parameters.
Prerequisites. You should be comfortable with:
Elliptic curves over finite fields and point enumeration (Notebook 06c)
Cyclic groups, subgroups, and Lagrange's theorem (Module 01)
The order of an element in a group (Module 05)
Learning objectives. By the end of this notebook you will be able to:
State and verify Hasse's theorem for concrete curves.
Determine the group structure of using SageMath.
Compute point orders and find generators.
Explain why cryptographic curves need prime or near-prime group orders.
Describe the role of cofactors in curve selection.
1. Hasse's Theorem
Theorem (Hasse, 1933). For an elliptic curve over :
In other words, the number of points is where (the trace of Frobenius) satisfies .
This means the group order is always in the interval .
| | | Range for | |-----|------------|----------------| | 23 | | | | 101 | | | | | | |
The distribution of traces follows the Sato–Tate conjecture (now a theorem): for "random" curves, is distributed like the semicircle distribution. The peak near means most curves have .
Checkpoint 1. For a 256-bit prime , Hasse's theorem says with . Since , the relative deviation is negligible, the group order is essentially .
2. Group Structure: Cyclic or Not?
Theorem (Structure of ). The group is isomorphic to either:
(cyclic), or
where .
In practice, most curves over large primes are cyclic. The non-cyclic case occurs when the group has a non-trivial "extra" structure.
For cryptography, we prefer the cyclic case, it gives us the cleanest DLP setting.
Misconception alert. "Elliptic curve groups are always cyclic." Not true! While most curves over large primes are cyclic, the structure theorem allows . For crypto, we specifically choose curves that are cyclic (or whose large prime-order subgroup is cyclic).
3. Point Orders and Lagrange's Theorem
By Lagrange's theorem, the order of any point must divide the group order .
If , then the possible point orders are the divisors of . A point of order (a generator) exists if and only if the group is cyclic.
Checkpoint 2. In a cyclic group of order , the number of generators is (Euler's totient). If is prime, then , so every non-identity point is a generator! This is one reason we want to be prime.
Bridge from Module 01. In Module 01, we learned that is cyclic of order , and a generator (primitive root) exists when is prime, a prime power, or twice a prime power. For elliptic curves, the group structure is guaranteed to be "almost cyclic" (at most two factors), which is a much stronger result.
4. Why Prime Order Matters
For cryptographic applications, we want the group (or at least a large subgroup) to have prime order. Why?
Every non-identity point is a generator, no small-subgroup attacks.
Pohlig-Hellman cannot exploit the structure, recall from Module 05 that Pohlig-Hellman reduces the DLP to sub-DLPs in prime-order subgroups. If the whole group has prime order, there are no smaller subgroups to exploit.
Simpler parameter selection, no need to worry about cofactors.
5. Cofactors and Subgroups
Sometimes the group order is where is a large prime and is a small integer called the cofactor. In this case, we work in the subgroup of order generated by a point with .
| Curve | | Cofactor | Prime subgroup order | |-------|-------|-------------|-------------------------| | P-256 (NIST) | | 1 | (entire group) | | Curve25519 | | 8 | | | secp256k1 (Bitcoin) | | 1 | |
A cofactor means there are small-order subgroups, which can be exploited in certain protocols if not handled carefully.
Checkpoint 3. To "project" a random point into the prime-order subgroup, we compute where is the cofactor. Why does this work? Because divides , so divides . If does not have order dividing , then and has order exactly .
Crypto foreshadowing. In protocols like ECDH, if the cofactor , an attacker can send a point of small order (in the cofactor subgroup) and learn bits of the secret key. This is called a small-subgroup attack. The standard defense is to either use curves or to multiply received points by before use.
6. Counting Points Efficiently: Schoof's Algorithm
For small primes, we can count points by brute force. For cryptographic-size primes (), we need efficient algorithms.
Schoof's algorithm (1985) counts in polynomial time: or better with improvements by Elkies and Atkin (SEA algorithm).
SageMath uses SEA internally when you call E.cardinality().
Even for 256-bit primes, point counting takes only seconds. This is what makes it practical to search for curves with desired properties (e.g., prime group order).
7. Exercises
Exercise 1 (Worked): Verifying Hasse's Theorem
Problem. For over :
Count the points (use SageMath).
Compute the trace of Frobenius .
Verify .
Solution.
Exercise 2 (Guided): Finding a Prime-Order Curve
Problem. Search for an elliptic curve over such that is prime.
Steps:
Loop over until you find a curve with prime .
Verify that the discriminant is nonzero.
Check that a random point has order (confirming it is a generator).
Exercise 3 (Independent): Cofactor and Subgroup
Problem.
On over , compute and factor it.
Find the cofactor (the ratio of to its largest prime factor).
Take a random point and compute . Verify that has order equal to the largest prime factor.
Why would an attacker prefer to attack the DLP in the full group rather than the prime-order subgroup? (Hint: think about Pohlig-Hellman.)
Summary
| Concept | Key Fact |
|---|---|
| Hasse's theorem | $ |
| Group structure | Always with $n_1 |
| Point orders | Divide $ |
| Prime order | Ideal for crypto: every point is a generator, no Pohlig-Hellman |
| Cofactor | $h = |
| Schoof/SEA | Count $ |
We now understand the group structure. In the next notebook, we study scalar multiplication, the efficient computation of using double-and-add, which is the core operation in all EC cryptographic protocols.