Here are some tools for working with elliptic curves.
Let's start by creating and graphing an elliptic curve! In my opinion, the graphs look a lot nicer on www.desmos.com.
Note: The QQ means that the curve is defined over the rational numbers
E=EllipticCurve(QQ,[A,B]) #this defines the elliptic curve y^2=x^3+Ax+B.
show(E) #this shows you the equation of the curve you just defined
plot(E) #this graphs the curve!
Now let's add points! Note: The output of adding points is of the form (x:y:z). These are projective coordinates. We will only use the x and y coordinates in this course. However, it's important to note that the point at infinity will look like (0:1:0).
E=EllipticCurve(QQ,[A,B]) #this defines the elliptic curve y^2=x^3+Ax+B.
P=E(x1,y1) #this defines a point on the elliptic curve E. change the x- and y-coordinates so that you have a point on the curve
Q=E(x2,y2)
show(P+Q) #add two points
show(2*P) #compute a multiple of a point
Now let's work with curves over finite fields! We can use the code below to define and plot a curve. We can also use the point addition code that we used above.
Note: The GF(p) means that the curve is defined over the finite field Fp.
p=41
E=EllipticCurve(GF(p),[A,B]) #this defines the elliptic curve y^2=x^3+Ax+B.
show(E) #this shows you the equation of the curve you just defined
show(plot(E),figsize=4) #this graphs the curve. The "figsize" ensures that the graph fits on the screen
L=line([(0,p/2),(p,p/2)],rgbcolor=(1,0,0))
show(plot(E)+L,figsize=4) #This graphs E and the line of symmetry