Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
Download
342 views
# Examples of Elliptic Curves, with Graphical Representations # # plot([],figsize=(4,4),title='Here is a Graph',frame=True,axes_labels=['$x$-axis, units','$y$-axis, units']) # # The examples are from Stein's book ... # Example 6.1.2 from Ch.6 E=EllipticCurve([-5,4]); E # y2=x^3-5x+4 (implicitely) over the rational field E.plot(thickness=4, rgbcolor=(0.1,0.7,0.1),title="Elliptic Curve",frame=True)
Elliptic Curve defined by y^2 = x^3 - 5*x + 4 over Rational Field
# Elliptic curve over finite fields, a.k.a. Galois Fields: GF(p)=Z/pZ=Fp E=EllipticCurve(GF(37),[1,0]); E E.plot(pointsize=45)
Elliptic Curve defined by y^2 = x^3 + x over Finite Field of size 37
# ... what a mess :) ...
EC2=EllipticCurve(GF(7),[1,0]); EC2 EC2.plot(pointsize=45)
Elliptic Curve defined by y^2 = x^3 + x over Finite Field of size 7
# Example with prescribed roots: y^2=x^3-x => x=-1,0,1 roots # intersects the axes at (0,-1),(0,0),(0,1) EC3=EllipticCurve(GF(7),[-1,0]); EC3 EC3.plot(pointsize=25,color="red",figsize=(6,2))
Elliptic Curve defined by y^2 = x^3 + 6*x over Finite Field of size 7
# Addition on Elliptic Curves # # Ex. 6.2.3 - The Group Law E=EllipticCurve([-5,4]) P=E([1,0]); Q=E([0,2]); print P, Q, P+Q
(1 : 0 : 1) (0 : 2 : 1) (3 : 4 : 1)
# Plot with colors the points and the sum ...
P+P
(0 : 1 : 0)
P+Q+Q+Q+Q
(350497/351649 : 16920528/208527857 : 1)
P+4*Q
(350497/351649 : 16920528/208527857 : 1)
4*Q
(352225/576 : 209039023/13824 : 1)
Q+Q
(25/16 : -3/64 : 1)
# Example of addition for E(GF(7)): roots -1,0,1 => x^3+x => a=-1, b=0 E=EllipticCurve(GF(7),[-1,0]); E E.plot(pointsize=45)
Elliptic Curve defined by y^2 = x^3 + 6*x over Finite Field of size 7
# Selecting points on the curve and adding them ... P=E([1,0]); Q=E([4,2]); R=E([5,1]) P+P P+Q
(0 : 1 : 0) (4 : 5 : 1)
# Changing the Finite Field from F7 to F5 ... # # Example K=GF(5), EC: roots -1,0,1 E=EllipticCurve(GF(5),[-1,0]); E E.plot(pointsize=45)
Elliptic Curve defined by y^2 = x^3 + 4*x over Finite Field of size 5
P=E([1,0]); Q=E([0,0]); R=E([2,1]); S=E([2,-1]) O=Q+Q O 2*P
(0 : 1 : 0) (0 : 1 : 0)
# P and Q have order 2 2*E([-1,0]) 2*R
(0 : 1 : 0) (0 : 0 : 1)
# 2R=Q, so ord(R)=4; since |E|=7+1 (point at infinity: O), either it's Z4xZ2 or Z8 ... 2*S
(0 : 0 : 1)
# of course S=-R has the same order and 3S=R and they form one orbit / 4-cycle 3*S 2*E([-2,2])
(2 : 1 : 1) (0 : 0 : 1)
# [-2,2] has order 4 too, so ... pick two generators: R and [-1,0]? E([-2,2])-R
(4 : 0 : 1)
# yep! now sketch nicely the 4x2-1 "curved pointed torus" inside the 5x5 torus ... if you can :) where is "infinity" O? # the point is: "continuity", i.e. smooth connecting dots, should be replaced by the (cyclic) order defined by orbits of generators; so join points as a graph ... (Cayley graph of a group with respect to a set of generators; but this is another story :)
# Another example E=EllipticCurve(GF(5),[1,1]); E E.plot(pointsize=45)
Elliptic Curve defined by y^2 = x^3 + x + 1 over Finite Field of size 5
A=E([0,1]) 3*A 6*A
(2 : 1 : 1) (2 : 4 : 1)
B=E([2,1]) B*3
(0 : 1 : 0)
3*E([2,4]) E([3,1])+E([4,2])
(0 : 1 : 0) (4 : 3 : 1)
# So A=(0,1) is a generator
# # Another example: y^2=x^3+1 over GF(5) E=EllipticCurve(GF(5),[0,1]) E.plot(pointsize=45) E([0,1])+E([2,2])
(2 : 3 : 1)
# Note: the geometric construction fails: (2,2) is a double point of int. with the line => # 3rd point: -(2,2)=(2,-2)=(2,3)
# ***************************************************************** # 6.4 Example of Discrete Log Problem # ***************************************************************** E=EllipticCurve(GF(7),[1,1]); E E.plot(pointsize=45)
Elliptic Curve defined by y^2 = x^3 + x + 1 over Finite Field of size 7
3*E([2,2]) 2*E([2,2])
(0 : 6 : 1) (0 : 1 : 1)