Caloogy Article
中文

Elliptic Curves: Why Points on a Curve Can Be "Added"

Date
Apr 25, 2025
Series
Cryptography
Reading
5 min
Topics
Elliptic curveECDSAsecp256k1Abelian group

The one-sentence version

On the curve y2=x3+ax+by^2 = x^3 + ax + b, the rule "draw a line, find the third intersection, then reflect" "adds" two points to give a third, and so all the points form an abelian group. Adding PP to itself kk times to get Q=kPQ = kP is fast; going the other way, finding kk from PP and QQ, is extremely hard (the elliptic curve discrete logarithm problem). A Bitcoin or Ethereum private key is exactly this kk.

This article has three layers:

  1. The intuition: the chord-and-tangent rule and "walking kk steps"
  2. Real-world use: Bitcoin, Ethereum, Apple Pay, Signal and the PS3 private key leak
  3. The mathematics: the group law, curves over finite fields, ECDSA and a worked example over F17\mathbb{F}_{17}

Layer 1: The Intuition

1.1 What an elliptic curve looks like

Elliptic curves have nothing to do with ellipses (the name comes from integrals for the arc length of an ellipse). An elliptic curve is simply the graph of the equation

y2=x3+ax+by^2 = x^3 + ax + b

and it is symmetric about the xx-axis. Bitcoin's secp256k1 is about the simplest one: y2=x3+7y^2 = x^3 + 7.

1.2 The chord-and-tangent rule: how "addition" is defined

Take two points PP and QQ on the curve:

  1. Draw the line through PP and QQ. It always meets the curve at a third point R′R' (a cubic equation has three roots);
  2. Reflect R′R' across the xx-axis to get RR;
  3. Define P+Q=RP + Q = R.

If P=QP = Q, use the tangent at PP in place of the line through the two points. If the line is vertical (PP and its reflection), the intersection is "at infinity", written OO, and it serves as the zero element.

draw line

reflect

P, Q

third point R'

R = P + Q

Amazingly, this seemingly arbitrary rule is commutative and associative, has a zero element, and gives every point an inverse (its reflection). In other words, the points on the curve form a group.

1.3 Private keys and public keys

It is like starting from GG on a giant, erratically jumping clock face and walking kk steps. Given the start and the end, you can hardly work out how many steps were taken. With the "double-and-add" trick, computing kGkG takes only about 256256 doublings and additions; finding kk in reverse takes even the best algorithms about 21282^{128} steps.


Layer 2: Real-World Use

Where Curve / algorithm
Bitcoin and Ethereum transaction signatures secp256k1 + ECDSA (Bitcoin Taproot switched to Schnorr)
HTTPS key exchange X25519 (ECDH on Curve25519)
SSH, Signal, Git signing Ed25519
Apple Pay, bank card chips, passports NIST P-256
Ethereum consensus layer BLS12-381 (a pairing-friendly curve; see "Bilinear Pairings and BLS Signatures")

Why it's preferred over RSA: for the same 128-bit security, an elliptic curve key is 256 bits while RSA needs 3072. Short keys, short signatures and fast computation all matter for phones, smart cards and blockchains.

The PS3 private key leak (2010)

An ECDSA signature needs a random number kk that is different every time. Sony used one fixed kk to sign PS3 games. The hacker group fail0verflow took two signatures, wrote down an equation and solved for the private key, after which anyone could sign "official" software. In 2013 some Android Bitcoin wallets also reused kk because of a random number generator bug, and bitcoin was stolen. Section 3.4 explains why.

The quantum threat

Shor's algorithm also solves the elliptic curve discrete logarithm, so ECC falls to quantum computers just as RSA does. See "Post-Quantum Cryptography".


Layer 3: The Mathematics

3.1 Formulas for the group law

Let P=(x1,y1)P = (x_1, y_1) and Q=(x2,y2)Q = (x_2, y_2). First find the slope of the line:

λ={y2−y1x2−x1,P≠Q3x12+a2y1,P=Q (tangent, by implicit differentiation)\lambda = \begin{cases} \dfrac{y_2 - y_1}{x_2 - x_1}, & P \neq Q \\[2ex] \dfrac{3x_1^2 + a}{2y_1}, & P = Q \ (\text{tangent, by implicit differentiation}) \end{cases}

Then

x3=λ2−x1−x2,y3=λ(x1−x3)−y1.x_3 = \lambda^2 - x_1 - x_2,\qquad y_3 = \lambda(x_1 - x_3) - y_1.

Derivation: substituting y=λ(x−x1)+y1y = \lambda(x - x_1) + y_1 into the curve equation gives a cubic with leading term x3x^3 and x2x^2 coefficient −λ2-\lambda^2. By Vieta's formulas, the three roots sum to x1+x2+x3=λ2x_1 + x_2 + x_3 = \lambda^2.

Associativity is the hardest part: expanding the formulas directly is extremely tedious. More elegant proofs use algebraic geometry (the Riemann–Roch theorem or the Cayley–Bacharach theorem); here we simply accept it.

3.2 Moving to a finite field

Cryptography doesn't use the real numbers but a finite field Fp\mathbb{F}_p: every division in the formulas above becomes multiplication by a multiplicative inverse modulo pp. The curve turns into a scatter of discrete points, but the group law formulas don't change at all, and it is still an abelian group.

How many points are there? Hasse's theorem says ∣#E(Fp)−(p+1)∣≤2p\big|\#E(\mathbb{F}_p) - (p+1)\big| \le 2\sqrt{p}, so the number of points is about pp. In practice one picks a curve whose point count is a large prime (or a large prime times a small cofactor), so the group is nearly cyclic and has no small subgroups to exploit (see Pohlig–Hellman in "Diffie–Hellman and the Discrete Logarithm").

3.3 A worked example: a curve over F17\mathbb{F}_{17}

E:y2=x3+2x+2E: y^2 = x^3 + 2x + 2 over F17\mathbb{F}_{17}, with base point P=(5,1)P = (5, 1)

First check that PP is on the curve: 53+2⋅5+2=137=8⋅17+1≡1=125^3 + 2\cdot 5 + 2 = 137 = 8\cdot 17 + 1 \equiv 1 = 1^2. ✓

Compute 2P2P (tangent):

  • λ=3⋅25+22⋅1=772\lambda = \dfrac{3\cdot 25 + 2}{2 \cdot 1} = \dfrac{77}{2}. 77≡977 \equiv 9 and 2−1≡9(mod17)2^{-1} \equiv 9 \pmod{17}, so λ=81≡13\lambda = 81 \equiv 13
  • x3=132−10=159≡6x_3 = 13^2 - 10 = 159 \equiv 6
  • y3=13(5−6)−1=−14≡3y_3 = 13(5 - 6) - 1 = -14 \equiv 3
  • 2P=(6,3)2P = (6, 3)

Keep adding:

kk kPkP kk kPkP
1 (5,1)(5, 1) 10 (7,11)(7, 11)
2 (6,3)(6, 3) 11 (13,10)(13, 10)
3 (10,6)(10, 6) 12 (0,11)(0, 11)
4 (3,1)(3, 1) 13 (16,4)(16, 4)
5 (9,16)(9, 16) 14 (9,1)(9, 1)
6 (16,13)(16, 13) 15 (3,16)(3, 16)
7 (0,6)(0, 6) 16 (10,11)(10, 11)
8 (13,7)(13, 7) 17 (6,14)(6, 14)
9 (7,6)(7, 6) 18 (5,16)(5, 16)

19P=O19P = O (the point at infinity). So PP has order 1919 and generates a cyclic group of order 1919. Note that 18P=(5,16)=−P18P = (5, 16) = -P, exactly the reflection of PP.

The discrete logarithm problem: if you are told only Q=(0,11)Q = (0, 11) and asked for kk in Q=kPQ = kP, you can only try values one by one; the table gives k=12k = 12. On a real curve this table has 22562^{256} rows. (Checked with Python.)

3.4 ECDSA, and why reusing kk is fatal

Let the base point GG have order nn, with private key dd, public key Q=dGQ = dG and message hash hh.

Signing: choose a random kk, compute R=kGR = kG, take r=Rx mod nr = R_x \bmod n, and

s=k−1(h+rd) mod n.s = k^{-1}(h + r d) \bmod n.

The signature is (r,s)(r, s). Verification: compute u1=hs−1u_1 = h s^{-1} and u2=rs−1u_2 = r s^{-1}, and check that the xx-coordinate of u1G+u2Qu_1 G + u_2 Q equals rr. (Because u1G+u2Q=s−1(h+rd)G=kGu_1 G + u_2 Q = s^{-1}(h + rd)G = kG.)

What happens if kk repeats: two messages h1,h2h_1, h_2 use the same kk, so rr is the same, and

s1−s2=k−1(h1−h2) ⇒ k=h1−h2s1−s2,d=s1k−h1r.s_1 - s_2 = k^{-1}(h_1 - h_2) \ \Rightarrow\ k = \frac{h_1 - h_2}{s_1 - s_2},\qquad d = \frac{s_1 k - h_1}{r}.

Two lines of algebra yield the private key. That is all the mathematics of the PS3 incident. Modern implementations use RFC 6979: kk is generated deterministically from the private key and the message hash, which doesn't depend on the quality of a random number generator and guarantees different messages get different values of kk.


Summary

Layer Key points
Intuition Draw a line, find the third point, reflect: that is "addition"
Algebra Points on the curve form an abelian group; over a finite field there are about pp points; choose a prime-order group
Security Finding kk from PP and kPkP is extremely hard (about n\sqrt{n} steps)
Engineering Short keys and fast operations; the signing nonce kk must never repeat