we will be deriving the equations for
elliptic curve point addition and
doubling so given two distinct point on
an elliptic curve P and Q and a line
joining them let the (x3, y3) be the third
intersection point of the curve with the
line then the addition of those two
points is defined as R is equal to P
plus Q is equal to (x3, -y3) given the
symmetry across the x-axis and given
P is any point on an elliptic curve with
tangent line to curve at P let (x3, y3) be
the intersection point of the curve with
the line then point doubling is defined
as R = P + P  = 2P  =  (x3 , -y3) same thing
given the symmetry across the x-axis
so this is the equation of the line  L:  y =
= sx + m  and this is the
equation of the elliptic curve y^2 = x^3 + ax + b     and we
need to find the intersection points by
setting L is equal to E so (sx + m)^2
=  x^3 + ax + b and we flip those around so we get ...
... and we expand this
one so we end up with this and we end up
with this equation so we have three
intersection points which means we will
have a cubic equation with three
solutions so
(x - x1)(x-x2)(x-x3)=0 so we multiply those two we
get this and ... and we rearrange
those we get this and then ...
...  and we end
up with this equation
so we have those two equations that we
just derived this one and this one and
we match the coefficients so for x
squared we have those two coefficient s
squared the slope squared and x1 plus x2
 plus x3 so those two must be equal
and this means that x3 is equal to s
squared minus x1 minus x2 and from
here the x for the R is equal to x3 so
for the addition of those two points and
the y is equal to minus y3
so Xr is equal to s squared minus x1
minus x2 and we want the slope of
the line passing through (x1,y1) and  (x3, y3)
so s is equal to y3 minus y1 over x3
minus x1 so we end up with minus y3 is
equal to s times x1 minus x3 minus y it
should be y1 so also we have that Yr
is equal to minus y3 this means that Yr
is equal to s times x1 minus x3 minus y1
so this is the slope in the case we are
doing point addition so s is equal to y2
minus y1 over x2 minus x1 so (x1, y1) is P
and (x2, y2) is Q and in the case of point
doubling we take the derivative to
find the slope of the tangent line at
the (x1,y1) here at P
and this is the equation of the elliptic
curve y squared is equal to X cube plus
ax plus b so 2y dy is equal to 3x
squared plus a dx so dy/dx is equal
to 3x squared plus a over 2y so this is
the slope when we are doing point
doubling so we end up with those
equations for elliptic curve point
addition Xr and this is R here  (Xr, Yr)
so Xr is equal to s squared
minus x1 minus x2
this is (x1, y1) and (x2, y2) and Yr is equal
to the slope times x1 minus Xr from
here minus y1 and the slope is equal to
y2 minus y1 over x2 minus x1 and the
slope is the slope of the line through P
and Q and for elliptic curve point
doubling Xr is equal to s squared minus
2x1 since x1 is equal to x2 here we
only have one point so s squared minus 2
x1 and Yr is equal to s times x1 minus
Xr minus y1 same as here and the slope
is different we just derived it here
so it's 3x squared plus a over 2y1 and
this is the slope of the tangent line
through P(x1, y1) which is the same here
as Q(x2, y2)
