In the previous discussion of elliptic curves we saw that, once we know some points on the curve, then these can be used to algebraically construct new curve points. Specifically, from two points, we take the line joining them and solve for the third point of intersection. This construction gives a binary operator. In mathematics, one of the most useful type of binary operators are those defining a group. There is a lot of mathematical theory developed for groups so, if we have a group operator, then it is important to realise this. Unfortunately, the operator defined on an elliptic curve as just described does not satisfy the requirements for a group. Specifically, it is not associative, meaning that if we combine together more than two elements then the result depends on the order of the operations. However, it turns out that, with a slight modification, the binary operator on an elliptic curve does define a group. Such groups are used in the digital signature algorithms employed by Bitcoin and other cryptocurrencies.
Recall that an elliptic curve is the solution set to a third order polynomial equation. For now let’s start with the relatively simple case where the equation is in Weierstrass normal form,
y^{2} = x^{3} + ax + b.  (1) 
Here, the constant coefficients a and b lie in some base field F, as do the solutions for (x,y). In addition, there is one point at infinity πͺ, which was required so that the binary operator is everywhere defined, and comes from the fact that we should consider algebraic curves as lying in projective space and, hence, can have points on the line at infinity. Also, it is assumed that the curve does not have singular points which, for the one given by (1), means that the cubic on the right hand side does not have a double root. This is equivalent to 4a^{3} + 27b^{2} being nonzero.
As it is symmetric in y, the solutions to (1) are symmetric in reflection about the xaxis. Specifically, for a point P = (x,y) on the curve, then (x,y) is also on the curve. I will denote this reflected point by P^{r}. By convention, the point at infinity is equal to its own reflection, πͺ^{r} = πͺ. As in the post on elliptic curves, I use PβQ to denote the third point of intersection of the line joining P and Q with the curve. Combining this with a reflection about the xaxis does indeed give a group operation.
Theorem 1 Let E be an elliptic curve in Weierstrass normal form, and point at infinity πͺ. Then, it is a commutative group under the binary operator
P + Q β‘ (PβQ)^{r} Furthermore, the group identity is πͺ and the inverse of an element P is P = P^{r}.
The group operator ‘+’ is as shown in figure 1 below. It is not at all obvious from looking at the plot that this operator satisfies associativity. In fact this is a rather tricky property to prove, and I go into more detail on how to prove this further below.
I previously computed explicit algebraic formulas for the binary operator on a curve in Weierstrass normal form. These can be modified by simply applying the reflection about the xaxis to obtain the equation for elliptic curve addition. Starting with two points P = (x_{1},βy_{1}) and Q = (x_{2},βy_{2}), we compute the gradient of the line joining them,
Ξ³ = 
y_{2} – y_{1}
x_{2} – x_{1}

. 
The curve sum of the points, P + Q = (x_{3},βy_{3}), is given by
x_{3} = Ξ³^{2} – x_{1} – x_{2}, 
y_{3} = Ξ³(x_{1}ββx_{3}) – y_{1}. 
In the case where the two points are equal, P = Q, the formula above for Ξ³ involves dividing by zero so, instead, we use the gradient of the curve,
Ξ³ = 
dy
dx

= 
3x^{2} + a
2y

. 
The formulas above apply so long as the points do not have the same x value and opposite y values, which would lead to division by zero in the formulas for Ξ³. However, in this case, we have P = –Q, so that P + Q = πͺ. Finally, if one or both of P and Q is the point at infinity, then addition is given simply by,
P + πͺ = P, 
πͺ + Q = Q. 
In general, an elliptic curve is defined by a cubic polynomial, which does not have to be in Weierstrass normal form. Then, it need not be symmetric about the xaxis, and there need not be a unique point at infinity. So, addition cannot be defined by theorem 1. We can still define addition, although there is no longer a uniquely specified point to use as the group identity. Instead, we need to arbitrarily pick one point, πͺ and use this.
Theorem 2 Let E be an elliptic curve, and πͺ be any fixed element of E. Then, it is a commutative group under the binary operator
P + Q β‘ πͺβ(PβQ). Furthermore, the group identity is πͺ and the inverse of an element P is –P =(πͺβπͺ)βP.
For an elliptic curve in Weierstrass form with πͺ being the point at infinity, we have πͺβP = P^{r} and πͺβπͺ = πͺ so, in that case, the group operator specified in theorem 2 coincides with the one in theorem 1 above.
Examples
I previously looked at a few explicitly calculated examples of the binary operator on an elliptic curve. Now that we have instead expressed it in terms of a group operator, we can revisit these.
We look first at the curve y^{2} = x^{3} + 3 over the rational numbers, starting with the point P = (1,2). We computed a point Q = PβP which, using the group notation is 2.P. So, using the calculation from the previous post,
2.P =  ( 
23
16

, 
11
64

)  . 
Next, we computed (P)βQ which, using the group notation, is P – Q = 3.P. So,
3.P =  ( 
1873
1521

, 
130870
59319

)  . 
Continuing in this way, we can in principle compute an infinite sequence of points n.P on the curve.
Next, we looked at the curve y^{2} = x^{3} + 7 computed over the integers modulo the prime p = 13. We found that it is of size 7, including the point at infinity, and the 6 finite points are:
P_{11} = (7,β5),  P_{12} = (7,β8),  
P_{21} = (8,β5),  P_{22} = (8,β8),  
P_{31} = (11,β5),  P_{32} = (11,β8). 
We also computed the binary operator on these points as,
P_{11}βP_{11} = P_{22}, 
P_{11}βP_{21} = P_{31}, 
P_{11}βP_{31} = P_{21}, 
P_{11}βP_{22} = P_{11}, 
P_{11}βP_{32} = P_{32}. 
Using this together with the fact that we labelled the points so that P_{i1}^{r} = P_{i2} gives the group structure,
P_{21} = 2.P_{11}, 
P_{32} = 3.P_{11}, 
P_{31} = 4.P_{11}, 
P_{22} = 5.P_{11}, 
P_{12} = 6.P_{11}, 
πͺ = 7.P_{11}, 
This explicitly shows that the group is cyclic of order 7, with P_{11} as a generator.
For the final example, we looked at the secp256k1 elliptic curve used by Bitcoin. This is defined by the equation y^{2} = x^{3} + 7 over the integers modulo the 256 bit prime number,
p  =0xfffffffffffffffffffffffffffffffffffffffffffffffffffffffefffffc2f 
= 2^{256} – 2^{32} – 2^{9} – 2^{8} – 2^{7} – 2^{6} – 2^{4} – 1. 
Directly computing the group is a bit tricky. Instead, we can quickly verify the claims made in the Bitcoin wiki page. It is stated that the group is cyclic with order equal to the 256 bit prime number
q  =0xfffffffffffffffffffffffffffffffebaaedce6af48a03bbfd25e8cd0364141 . 
This can be verified by the following steps.
 First, check that p and q are indeed prime numbers. This is easily done in Python using the Miller–Rabin primality test.
 Find an element P = (x,y) of the curve (other than the point at infinity). To do this, x can be chosen as a random 256 bit number and we set
y = (x^{3} + 7)^{(p + 1)/4} (mod p). As p + 1 is a multiple of 4, a bit of modular arithmetic tells us that if x^{3} + 7 has a square root (mod p) then it is given by (x^{3} + 7)^{(p + 1)/4}. We then check that y^{2} = x^{3} + 7 is satisfied (mod p). This has a probability of about 50% of success so, if it does not hold, we just select a different random value for x and try again. Alternatively, we can just use the generator stated in the link, as used by the Bitcoin implementation.
x= 0x79be667ef9dcbbac55a06295ce870b07029bfcdb2dce28d959f2815b16f81798
y= 0x483ada7726a3c4655da4fbfc0e1108a8fd17b448a68554199c47d08ffb10d4b8
It is easily checked that this does satisfy y^{2} = x^{3} + 7 (mod p).
 Compute q.P using the explicit formula for elliptic curve addition and the recursive formula for large exponents, and verify that it is equal to πͺ.
This is all relatively straightforward using Python3 and, as it uses a variable length integer representation, 256 bit numbers are handled with no overflow issues. Once we verify q.P = πͺ in the final point, we know that P has order q. As q is prime, this means that P is of order q or 1 and, as it is not the identity, it must be of order q. Next, the size of the elliptic curve must be a multiple of q. The only way that it could fail to be cyclic of order q is if it was at least 2q in size. However, as mentioned previously, Hasse’s theorem bounds the size of the elliptic curve from above by p + 1 + 2βp, which is smaller than 2q. Hence, the elliptic curve is cyclic of prime order q as claimed, and every element of the curve (other than the point at infinity) is a generator.
Proof of Group Action
The fact that the group operation on an elliptic curve really does satisfy the definitions of a group, is not obvious. In fact, trying to directly prove it can get rather difficult, making the result seem very surprising.
As was noted previously, the equality PβQ = R for points P,Q,R on our elliptic curve just means that there is a line intersecting the curve at exactly these 3 points. So, it is unchanged if the order of P,Q,R is changed, giving identities,
QβP = PβQ, 
Pβ(PβQ) = Q. 
The first of these shows that the addition law is commutative,
P + Q = πͺβ(PβQ) = πͺβ(QβP) = Q + P. 
The fact that πͺ is an additive identity is also straightforward,
πͺ + P = πͺβ(πͺβP) = P. 
It was also stated that the additive inverse of a point P is given by (πͺβπͺ)βP, from which we obtain,
(P)βP = ((πͺβπͺ)βP)βP = πͺβπͺ. 
Then the proof that –P is indeed an additive inverse follows,
(P) + P = πͺβ(πͺβπͺ) = πͺ. 
There is only one remaining property of the addition law required for it to satisfy the definition of a group. Namely, associativity,
(P + Q) + R = P + (Q + R). 
From the definition of elliptic curve addition, this is the same as the identity
(P + Q)βR = Pβ(Q + R) 
for all points P,Q,R on the curve. In other words, if we take the line joining P + Q and R, and the line joining P and Q + R, then these should both intersect the elliptic curve at the same point. This is as in figure 2 below where, to within the accuracy of the plot, we do see that they both intersect the elliptic curve at the same point, marked in green. However, it is not clear from the plot why this should be the case, and if it really does hold for all choices of P,Q,R. In fact, it looks like a rather surprising coincidence.
It seems that this is one of those mathematical results that you come across from time to time, which are seemingly difficult to prove but, in fact there are many different methods of proof of varying levels of sophistication and technical difficulty (cf. the fundamental theorem of arithmetic). Some approaches that I am aware of are listed below.
Method 1: We can, with some perseverance, write out the general formula for addition of two points on an elliptic curve and, then, explicitly verify that it is associative. This gets very messy though, even for the simple Weierstrass normal form for which the explicit formulas were written out above. I will not even attempt this, but it can be done in principle.
Method 2: Here is a slick method, although it does require an advanced result from from algebraic geometry. The idea is that a nonconstant rational function on an algebraic curve cannot be be deformed (in a rational sense) to be constant. This considers projective algebraic curves A_{1}, A_{2}, A_{3} defined over an algebraically closed base field, and a rational function f:A_{1}ΓA_{2} βA_{3}. If there exists a point Q_{0} in A_{2} at which f(P,βQ_{0}) is constant in P, then f(P,βQ) is constant in P for every fixed value of Q. More generally, this result holds for any complete algebraic variety A_{1}, connected variety A_{2} and any variety A_{3}, but that does not matter here. This does require the base field F to be algebraically closed, but it is always possible to extend a field to an algebraically closed one, which adds points to the elliptic curve. If the result holds in this enlarged curve, then it will also hold with the original base field.
Fix a point R of our elliptic curve E and consider the map,
f(P,βQ) = ((P + Q) + R) – (P + (Q + R)). 
This is a rational map from EΓE to E, and using the fact that πͺ is an additive identity, the equalities
f(P,βπͺ) = f(πͺ,βQ) = πͺ 
are straightforward. So, f(P,βπͺ) = πͺ is constant. By the result mentioned it follows that, for each fixed Q, f(P,βQ) is a constant function of P. Hence, f(P,βQ) = f(πͺ,βQ) = πͺ, which completes the proof of associativity.
Method 3: Writing
S = (P + Q)βR, 
T = Pβ(Q + R), 
we need to show that S and T coincide. Note that we have the following ten points on the curve,
πͺ,βP,βQ,βR,βPβQ,βQβR,βP + Q,βQ + R,βS,βT. 
Our elliptic curve can be expressed as the solutions to p(x,βy,βz) = 0 for points (x:y:z) in the projective plane, where p is a homogeneous cubic polynomial. Next, for points P,Q on the curve, use f_{P,Q}(x,βy,βz) = 0 for the linear equation of the line joining P and Q. This is of the form ax + by + cz and is uniquely determined up to an arbitrary rescaling of the coefficients. In the case where P and Q coincide, then we take the equation of the line tangent to the curve at P. Now, consider the three cubic equations,
p = 0, 
g β‘ βf_{P,Q}βf_{Pβ+βQ,R}βf_{QβR,Qβ+βR} = 0, 
h β‘ βf_{Q,R}βf_{Qβ+βR,P}βf_{PβQ,Pβ+βQ} = 0. 
These are all cubics in x,y,z, where p vanishes at all 10 points listed above, g vanishes at all points except possibly for T, and h vanishes at all points except possibly S.
As the curves defined by p,g intersect in exactly 9 points (counting multiplicity), and h vanishes on 8 of these, the following proposition states that it also vanishes at the 9th point S, giving S = T as required.
Proposition 3 If two projective cubic curves intersect in exactly nine points, then every cubic curve passing through eight of the points also passes through the ninth.
I won’t go into details here, but the idea is that a homogeneous cubic polynomial is a linear combination of the 10 monomials
x^{3},βx^{2}y,βxy^{2},βy^{3},βx^{2}z,βxyz,βy^{2}z,βxz^{2},βyz^{2},βz^{3}. 
If the cubic vanishes at 8 points in ‘general position’, this leaves two degrees of freedom. If two distinct cubics, g,h, intersect at these 8 points, then linear combinations of them span the entire space of cubics vanishing on these points. Any other cubic vanishing at these points will be a linear combination of g,h, so also vanishes at the 9th points. Here, ‘general position’ means that the size10 vector of monomials at the points are linearly independent. Dealing with points not in general position does complicate things, but the result still holds.
Method 4: Another advanced method is to use the idea of the genus of an algebraic curve, which is a rational invariant. A smooth projective curve of degree d has genus (d – 1)(d – 2)/2. Curves of degree 1 and degree 2 both have genus 0, which is why we were able to parameterise degree two curves by a projective line in the earlier posts. Curves of degree 3 have genus 1, so there is no rational onetoone and smooth map between elliptic curves and the projective line.
For points P,Q,R on the elliptic curve, using the notation of method 3 above, consider the rational function
u = 
βf_{P,Q}βf_{Pβ+βQ,R}βf_{QβR,Qβ+βR}
βf_{Q,R}βf_{Qβ+βR,P}βf_{PβQ,Pβ+βQ}

= 
g
h

. 
On the elliptic curve, the zeros in the denominator cancel with the zeros in the numerator, to give a rational function defined everywhere on the curve except, in the case with S β T, it can have a pole at T and has a unique zero at S. So, u gives a smooth onetoone and, hence, invertible rational map from the elliptic curve to the projective line, contradicting the fact that the elliptic curve has a different genus from the line.