Let y2=x3+ax+b be the equation of the elliptic curve E. Any line L that intersects the curve will intersect the curve in at most 3 points. Below are examples of how these look like.
A mathematical structure can defined on E. We can "add" two points on E to get a third point. First, let's define the negative of a point. A point Q is the negative of a point P if the point Q is the mirror image of the point P with respect to the x-axis that is,
Q=−P
From the relation above, we can define O to be
P+(−P)=O
The point O is the "point at infinity".
Let L be a line that intersects E at points P, Q and R. We define the sum
P+Q+R=O
From this definition, we see that the the sum of any of the two points is the negative of the third point, that is, P+Q=−R.
So how do we actually add 2 points given their coordinates? It turns out that if we are given the x and y coordinates of 2 points, we can easily compute the third point. To see this, let y=mx+c be the equation of the line that intersects the elliptic curve y2=x3+ax+b at points P, Q and R. Solving for the x-coordinates of the intersection, we get
The variable m is the slope of the line. If the line is tangent to the curve E at point P, the slope m is calculated using the derivative of E at the P:
d(y2)2ydydxdy=d(x3+ax+b)=(3x2+a)dx=m=2y3x2+a
Addition Formula
Now that we have seen how to add two points, let's summarize the formula here:
Given points P=(x1,y1) and Q=(x2,y2), the third point R=(x3,−y3) can be computed from
x3=m2−x1−x2y3=m(x3−x1)+y1
where
m=⎩⎨⎧x1−x2y1−y22y3x2+aP=QP=Q
Important! Take note that R=(x3,−y3). The value of y3 should be the negative of the computed value.
Example 1
Let the elliptic curve be y2=x3−3+3, then points P=(−2,1) and Q=(0,1.732051) lie on the curve. The third point can be computed as follows:
The set of points of E together with the point at infinity, E∪{O}, forms a group under the addition operation defined above.
It is associative: (P+Q)+R=P+(Q+R)
Every element has an inverse: P+(−P)=O
It contains the identity element. From the inverse we have P−P=0. Therefore, P+O=P, which makes O the identity element.
It is closed: For every P,Q, P+Q∈E∪{O}
Modulo Arithmetic
The addition formula also works for modular arithmetic. Let p be a prime number, then given two points P and Q, the third point can be computed as
x3=m2−x1−x2modpy3=m(x3−x1)+y1modp
where
m=⎩⎨⎧x1−x2y1−y2modp2y3x2+amodpP=QP=Q
Example
Suppose p=71, P=(0,28) and Q=(−2,1), then we compute the third point R as follows:
m=x1−x2y1−y2mod71=0−(−2)28−1mod71=27(36)mod71, where 36 is the inverse of 2 modulo 71=49x3=m2−x1−x2mod71=492−0−(−2)mod71=60y3=m(x3−x1)+y1mod71=49(60−0)+28=57
Therefore, P+Q=R=(x3,−y3)=(60,−57)mod71=(60,14)
N-fold Point Addition
Let B be a point in E. If n is an integer greater than 1, the point nB is defined as
nB=n timesB+B+…+B
Example
Let y2=x3−3x+3mod71. Let B=(0,28), then using the formula for x3 and y3:
3B=(0,28)+(0,28)+(0,28)mod71=(37,63)mod71
Elliptic Curve Cryptography
Alice and Bob want to exchange information using Elliptic Curve Cryptography. They agree on an elliptic curve equation and a base point B. Alice and Bob both choose a random number between 1 and 71. Let ea and eb be the secret numbers chosen by Alice and Bob (respectively) and publishes the public keys eaB and ebB. Alice wants to send the message encoded in a point P. She multiplies Bob's public key and her private key and adds it to the message P to get P+eaebB and sends the pair {eaB,P+eaebB}.
Bob receives the message multiplies his private key to Alice's public key to get ebeaB. He then subtracts this to the message P+eaebB to get the original message P.
Assume Bob and Alice agree on the equation y2=x3−3x+3, the base point B=(0,28) and the modulus p=71. Suppose Alice's private key is 4 and Bob's private key is 5. Alice will publish her public key as eaB=4B=(42,57). Likewise, Bob will publish his public key as ebB=5B=(30,2).
Alice wants to send Bob a message encoded in the point P=c(2,17) of E. First, Alice will multiply Bob's public key with her private key to get eaebB=4⋅(30,2)=(18,32). She will then add this to P to get encrypted message P+eaebB=(2,17)+(18,32)=(10,11). She will send (10,11) to Bob.
Bob then receives the message (10,11). The first thing he will do is to multiply Alice's public key eaB=(42,57) with his private key to get ebeaB=5⋅(42,57)=(18,32). Next, he will subtract this from the encrypted message to get (10,11)+(18,−32)=(2,17), which is the unencrypted message of Alice!