TExcelTAD
Home › Number Theory & Cryptography › Elliptic Curves and the Group Law

Elliptic Curves and the Group Law

An elliptic curve is the set of solutions of y2=x3+ax+by^2 = x^3 + ax + b, 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

E:  y2=x3+ax+b,4a3+27b2≠0E: \; y^2 = x^3 + ax + b, \qquad 4a^3 + 27b^2 \ne 0

The condition excludes curves with a cusp or a self-crossing, where the tangent line is not well defined. The set of points is E={(x,y):y2=x3+ax+b}∪{O}E = \{(x, y) : y^2 = x^3 + ax + b\} \cup \{\mathcal{O}\}, where O\mathcal{O} is the point at infinity, the identity of the group. Every curve is symmetric about the xx-axis: if (x,y)(x, y) is on it, so is (x,−y)(x, -y).

The chord-and-tangent rule

To add PP and QQ: the line through them meets the curve in exactly one more point RR; then P+QP + Q is the reflection of RR. To double PP, use the tangent at PP. Vertical lines meet "at infinity", so P+(−P)=OP + (-P) = \mathcal{O}.

In formulas, for P=(x1,y1)P = (x_1, y_1) and Q=(x2,y2)Q = (x_2, y_2) with P≠−QP \ne -Q:

λ={y2−y1x2−x1P≠Q3x12+a2y1P=Q,x3=λ2−x1−x2,y3=λ(x1−x3)−y1\lambda = \begin{cases} \dfrac{y_2 - y_1}{x_2 - x_1} & P \ne Q \\[2mm] \dfrac{3x_1^2 + a}{2y_1} & P = Q \end{cases}, \qquad x_3 = \lambda^2 - x_1 - x_2, \qquad y_3 = \lambda(x_1 - x_3) - y_1

Because the formulas only add, multiply and divide, rational points stay rational. On Bachet's curve y2=x3+17y^2 = x^3 + 17, starting from the integer points:

python · try it yourself
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, EE is an abelian group: O\mathcal{O} is the identity, −(x,y)=(x,−y)-(x, y) = (x, -y), addition is commutative (the line through PP and QQ does not care about order), and, the hard part, associative. Associativity can be checked symbolically or numerically:

python · try it yourself
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 kP=P+P+⋯+PkP = P + P + \cdots + P. Computing it with double-and-add takes O(log⁡k)O(\log k) group operations, exactly like square-and-multiply. Over the rationals the coordinates of kPkP blow up (their digit count grows like k2k^2); over a finite field they stay bounded, which is the setting of the next lesson.

python · try it yourself
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 (a=−3a = -3), secp256k1 (Bitcoin, a=0a = 0, b=7b = 7), Curve25519 (a Montgomery curve, By2=x3+Ax2+xBy^2 = x^3 + Ax^2 + x) 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 (2,5)(2, 5), (4,9)(4, 9), (3,6)(3, 6) lie on y2=x3+17y^2 = x^3 + 17?

Answer

(2,5)(2, 5) and (4,9)(4, 9).

Solution

8+17=25=528 + 17 = 25 = 5^2, 64+17=81=9264 + 17 = 81 = 9^2, but 27+17=44≠3627 + 17 = 44 \ne 36.

Exercise 2: Add by hand

On y2=x3+17y^2 = x^3 + 17, compute (−2,3)+(2,5)(-2, 3) + (2, 5).

Answer

(14,−338)\left(\frac{1}{4}, -\frac{33}{8}\right).

Solution

λ=5−32−(−2)=12\lambda = \frac{5 - 3}{2 - (-2)} = \frac{1}{2}. x3=14−(−2)−2=14x_3 = \frac{1}{4} - (-2) - 2 = \frac{1}{4}. y3=12(−2−14)−3=−98−3=−338y_3 = \frac{1}{2}\left(-2 - \frac{1}{4}\right) - 3 = -\frac{9}{8} - 3 = -\frac{33}{8}. Check: (14)3+17=164+108864=108964=(338)2\left(\frac{1}{4}\right)^3 + 17 = \frac{1}{64} + \frac{1088}{64} = \frac{1089}{64} = \left(\frac{33}{8}\right)^2.

Exercise 3: Singular curves (code)

Compute 4a3+27b24a^3 + 27b^2 for y2=x3−3x+2y^2 = x^3 - 3x + 2 and y2=x3−3x+7y^2 = x^3 - 3x + 7. Which is singular, and where is its bad point?

Answer

The first (discriminant 0); the double root x=1x = 1 gives a crossing at (1,0)(1, 0).

Solution
python · try it yourself
for a, b in ((-3, 2), (-3, 7)):
    print((a, b), 4 * a**3 + 27 * b**2)
(-3, 2) 0
(-3, 7) 1215

x3−3x+2=(x−1)2(x+2)x^3 - 3x + 2 = (x - 1)^2(x + 2), so the curve crosses itself at (1,0)(1, 0) and the tangent there is not unique.

Test yourself

The identity element of an elliptic-curve group is…

  1. (0,0)(0, 0)
  2. the point at infinity O\mathcal{O}
  3. (1,1)(1, 1)
  4. the generator

The negative of P=(x,y)P = (x, y) is…

  1. (−x,y)(-x, y)
  2. (x,−y)(x, -y)
  3. (−x,−y)(-x, -y)
  4. (y,x)(y, x)

Why must 4a3+27b2≠04a^3 + 27b^2 \ne 0?

  1. to make the curve bounded
  2. to exclude singular points where the tangent is undefined
  3. to make bb prime
  4. to allow negative xx