This is a read note of Programming Bitcoin Ch02: Elliptic Curves.
1 Definition
Elliptic curves have a form like this: y ** 2 = x ** 3 + ax + b
. The left side square of y
makes the curve symmetric over the x-axis. The secp256k1
elliptic curve used in bitcoin uses the equation y ** 2 = x ** 3 + 7
.
A point is a pair of (x, y)
that is on a specific curve defined by (a, b)
. For example, (-1, -1)
is a point of y ** 2 = x ** 3 + 5x + 7
.
2 Point Addition
Point addition is an operation that has a lot of the properties, such as communtative, of the addition operation in math.
For every elliptic curve, a line will intersect it at either one point or three points, except in a couple of special cases that a line intersects it at two points. Two special cases are vertical lines and tangent lines.
Except the special cases, two points form a line that must intersect the curve the third time. The third point reflected over the x-axis is the result of the point addition. For different values of A
and B
, A + B
could be a point on the left, on the right or between both points.
Properties of point addition are:
- Identity: the point at infinity.
I + A = A
- Invertibility:
A + (-A) = I
- Commutativity:
A + B = B + A
- Associativity:
(A + B) + C = A + (B + C)
. It is the reason that the addition operation flips over the x-axis.
The operation needs to process five cases: a point is the identity point, two different points are in a vertical line, two different different points not in a vertical line, two points are same and y = 0
(left tangent), two points are same and y != 0
.
The opearation are defined as the following:
|
|