Point Addition in Python

Recall from the discussion in Group Theory, we learnt how a generator point can be added to itself repeatedly to generate every element of the group. In this section, we'll understand how to perform this addition, and implement it in Python.

The theory behind point addition

To add two points PPand QQ on an elliptic curve, find the third point RR where line joining PP and QQ intersects. This value of RR is equal to (P+Q)-(P+Q). Reflecting the point along the X-axis will give us P+QP+Q.

Addition of two points on an elliptic curve over a field of real numbers.

To find the coordinates of the third point of intersection, simply calculate the slope between P and Q, and extrapolate it using the general equation of elliptic curve.

Addition of two points on an elliptic curve over a finite field.

Implementation in Python

Point at Infinity

Also known as the identity point, it is the third point where P and Q meet, in the figure below.

P+(P)=IP + (-P) = I

Point at infinity is the third point where the line joining P and Q meets the curve.

We can initialise the point at infinity like this:

Resources

Last updated

Was this helpful?