Path: blob/main/foundations/06-elliptic-curves/sage/06c-curves-over-finite-fields.ipynb
483 views
Notebook 06c: Curves over Finite Fields
Module 06. Elliptic Curves
Motivating Question. In Notebooks 06a and 06b, we drew smooth curves over and defined the group law geometrically. But real-number arithmetic has rounding errors and infinite precision issues, useless for cryptography. What happens when we move to a finite field ? The curve becomes a finite set of discrete points, the addition formulas work exactly (no rounding!), and we get a finite group ready for cryptographic use.
Prerequisites. You should be comfortable with:
Finite fields and arithmetic modulo (Modules 01--02)
Elliptic curves and the Weierstrass equation (Notebook 06a)
The point addition and doubling formulas (Notebook 06b)
Learning objectives. By the end of this notebook you will be able to:
Define an elliptic curve over and list all its points.
Verify that the same addition formulas from 06b work over finite fields.
Visualise the discrete point set and compare it to the real curve.
Understand why finite fields are essential for cryptography.
Compute with SageMath's
EllipticCurve(GF(p), [a, b]).
1. From to
An elliptic curve over uses the same equation:
The only difference: all arithmetic is modulo . The discriminant condition still must hold.
Since and , there are at most candidate points. The actual number is determined by how many -values yield a quadratic residue.
| Over | Over |
|---|---|
| Infinitely many points | Finitely many points |
| Smooth curve | Discrete point set |
| Floating-point issues | Exact arithmetic |
| Geometric intuition | Algebraic computation |
| Not useful for crypto | The setting for all EC crypto |
2. Finding Points by Brute Force
To find all points on , we can check each :
Compute .
Check if is a quadratic residue mod (i.e., does have a solution?).
If yes, find and add the points and to the list.
Checkpoint 1. For a given , the value is either a quadratic residue (giving 2 points), zero (giving 1 point with ), or a non-residue (giving 0 points). On average, about half the -values yield points. This is why , we will make this precise with Hasse's theorem in Notebook 06d.
3. Visualising the Point Set
Over , the curve is a smooth line. Over , it becomes a scatter plot of discrete points. The -axis symmetry is preserved: if is on the curve, so is .
Observations:
Over : a smooth, continuous curve.
Over : a scattered cloud of points with no visible geometric pattern.
The symmetry is about the line instead of , because .
The "randomness" of the point distribution is what makes the ECDLP hard.
Misconception alert. "The points over lie on the real curve." No, they live in , a completely different space. The real curve gives geometric intuition for the group law, but over there is no continuous geometry at all.
4. Point Arithmetic over
The beautiful thing: the same addition formulas from Notebook 06b work over . Division by becomes multiplication by , which always exists since is prime.
| Operation over | Operation over |
|---|---|
Checkpoint 2. In the computation above, the modular inverse is computed using Fermat's little theorem: . Why does this work? (Hint: for .)
5. Multiples of a Generator
Just as in Module 05, we can take a point and compute until we cycle back to . If generates the entire group, then .
Bridge from Module 05. In Module 05, a generator of was called a primitive root: every element was a power of . Here, a generator of is a point whose multiples cover the entire group: every point is for some .
Look at the right plot: the arrows connecting consecutive multiples jump erratically around the grid. There is no spatial pattern that would help you predict from without doing the computation. This "scramble" is exactly what makes the ECDLP hard.
Checkpoint 3. If someone gives you a point on the curve and tells you for some secret , how would you find ? Over this small curve, you could try all (brute force). For a 256-bit curve with points, that is impossible.
6. Comparing Curve Sizes
How does the number of points relate to ? Roughly, . The exact count varies with the curve parameters.
Crypto foreshadowing. For a 256-bit prime , we get points. This gives us a group large enough for 128-bit security against Pollard's rho attack ( operations). By contrast, achieving 128-bit security in requires a 3072-bit prime (due to sub-exponential index calculus).
7. Exercises
Exercise 1 (Worked): Point Addition over
Problem. On over , compute where and .
Solution.
Step 1: Slope. (since ), so .
Step 2: .
Step 3: .
So .
Exercise 2 (Guided): Enumerate and Verify
Problem. On over :
Use brute force to find all points.
Verify that satisfies Hasse's bound: .
Find a generator (a point whose order equals ).
Hint: For each , compute and check if it is a quadratic residue.
Exercise 3 (Independent): The ECDLP in a Small Group
Problem.
On over , let be a generator. Compute using SageMath.
Now pretend you only know and (not the scalar 17). Write a brute-force loop to recover from by trying .
For a 256-bit curve, . If your computer can test values of per second, how long would brute force take? (Express in years.)
Summary
| Concept | Key Fact |
|---|---|
| EC over | Same equation , all arithmetic mod |
| Finite point set | At most points; approximately (Hasse) |
| Same formulas | Addition and doubling formulas from 06b apply directly |
| Division → inverse | becomes |
| Discrete scramble | Multiples of scatter unpredictably, the ECDLP is hard |
| Crypto readiness | A 256-bit prime gives group elements with 128-bit security |
Now that we can compute with curves over finite fields, the next notebook studies the group structure in more depth: How many points are there exactly? What does the group look like? (Cyclic? Product of cyclic groups?) These questions are answered by Hasse's theorem and the structure theorem for abelian groups.