Elliptic Curves and the Group Law
An elliptic curve is the set of solutions of , plus one extra "point at infinity". Its points can be added: draw a line through two points, find the third intersection, reflect. This geometric rule makes the points a group, and over finite fields that group gives the smallest and fastest public-key cryptography in use today.
The curve
A (short Weierstrass) elliptic curve is
The condition excludes curves with a cusp or a self-crossing, where the tangent line is not well defined. The set of points is , where is the point at infinity, the identity of the group. Every curve is symmetric about the -axis: if is on it, so is .
The chord-and-tangent rule
To add and : the line through them meets the curve in exactly one more point ; then is the reflection of . To double , use the tangent at . Vertical lines meet "at infinity", so .
In formulas, for and with :
Because the formulas only add, multiply and divide, rational points stay rational. On Bachet's curve , starting from the integer points:
from fractions import Fraction as F
a, b = 0, 17
def on_curve(P):
x, y = P
return y * y == x**3 + a * x + b
def add(P, Q):
if P is None: return Q
if Q is None: return P
(x1, y1), (x2, y2) = P, Q
if x1 == x2 and y1 == -y2:
return None # the point at infinity
lam = (3 * x1 * x1 + a) / (2 * y1) if P == Q else (y2 - y1) / (x2 - x1)
x3 = lam * lam - x1 - x2
return (x3, lam * (x1 - x3) - y1)
P, Q = (F(-2), F(3)), (F(-1), F(4))
for name, R in (("P + Q", add(P, Q)), ("2P", add(P, P)), ("P + Q + Q", add(add(P, Q), Q))):
print(f"{name:10} = ({R[0]}, {R[1]}) on curve: {on_curve(R)}")
print("P + (-P) =", add(P, (P[0], -P[1])))P + Q = (4, -9) on curve: True
2P = (8, -23) on curve: True
P + Q + Q = (94/25, 1047/125) on curve: True
P + (-P) = None
Fermat and Euler studied such curves to find rational solutions; the group law explains why one or two solutions generate infinitely many.
Group properties
With this addition, is an abelian group: is the identity, , addition is commutative (the line through and does not care about order), and, the hard part, associative. Associativity can be checked symbolically or numerically:
from fractions import Fraction as F
a, b = 0, 17
def add(P, Q):
if P is None: return Q
if Q is None: return P
(x1, y1), (x2, y2) = P, Q
if x1 == x2 and y1 == -y2:
return None
lam = (3 * x1 * x1 + a) / (2 * y1) if P == Q else (y2 - y1) / (x2 - x1)
x3 = lam * lam - x1 - x2
return (x3, lam * (x1 - x3) - y1)
P, Q, R = (F(-2), F(3)), (F(-1), F(4)), (F(2), F(5))
left, right = add(add(P, Q), R), add(P, add(Q, R))
print(left == right, left)
print(add(P, Q) == add(Q, P))True (Fraction(43, 1), Fraction(282, 1))
True
Scalar multiples
Repeated addition gives . Computing it with double-and-add takes group operations, exactly like square-and-multiply. Over the rationals the coordinates of blow up (their digit count grows like ); over a finite field they stay bounded, which is the setting of the next lesson.
from fractions import Fraction as F
a, b = 0, 17
def add(P, Q):
if P is None: return Q
if Q is None: return P
(x1, y1), (x2, y2) = P, Q
if x1 == x2 and y1 == -y2:
return None
lam = (3 * x1 * x1 + a) / (2 * y1) if P == Q else (y2 - y1) / (x2 - x1)
x3 = lam * lam - x1 - x2
return (x3, lam * (x1 - x3) - y1)
P, R = (F(-2), F(3)), None
for k in range(1, 9):
R = add(R, P)
print(k, "digits in x-denominator:", len(str(R[0].denominator)))1 digits in x-denominator: 1
2 digits in x-denominator: 1
3 digits in x-denominator: 2
4 digits in x-denominator: 3
5 digits in x-denominator: 5
6 digits in x-denominator: 7
7 digits in x-denominator: 8
8 digits in x-denominator: 13
In software
- Cryptographic curves are standardized: NIST P-256 (), secp256k1 (Bitcoin, , ), Curve25519 (a Montgomery curve, ) and its twisted Edwards form Ed25519. Different shapes give different, faster formulas, but the group is the same idea.
- Elliptic curves also factor integers (Lenstra's ECM) and prove primality (ECPP).
Exercises
Exercise 1: On the curve?
Which of , , lie on ?
Answer
and .
Solution
, , but .
Exercise 2: Add by hand
On , compute .
Answer
.
Solution
. . . Check: .
Exercise 3: Singular curves (code)
Compute for and . Which is singular, and where is its bad point?
Answer
The first (discriminant 0); the double root gives a crossing at .
Solution
for a, b in ((-3, 2), (-3, 7)):
print((a, b), 4 * a**3 + 27 * b**2)(-3, 2) 0
(-3, 7) 1215
, so the curve crosses itself at and the tangent there is not unique.
Test yourself
The identity element of an elliptic-curve group is…
- the point at infinity
- the generator
The negative of is…
Why must ?
- to make the curve bounded
- to exclude singular points where the tangent is undefined
- to make prime
- to allow negative