This is a short tutorial to get started with elliptic curves in SageMath. For a complete reference, see the official documentation:
See also the book Computational Mathematics with SageMath.
We create finite fields by passing their cardinality
Fp = GF(11)
Fp
Finite Field of size 11
Fq = GF(11^2)
Fq
Finite Field in z2 of size 11^2
For extension fields, the generator is obtained with the .gen()
function.
z = Fq.gen()
z
z2
z^120
1
Same thing in one go
K.<t> = GF(next_prime(2^128)^2)
K
Finite Field in t of size 340282366920938463463374607431768211507^2
Curves over $ℚ$
E = EllipticCurve([-10,10])
E
Elliptic Curve defined by y^2 = x^3 - 10*x + 10 over Rational Field
E.plot()
Cuvers over other fields
F = EllipticCurve(GF(11), [1, 0])
F
Elliptic Curve defined by y^2 = x^3 + x over Finite Field of size 11
F.order()
12
F.cardinality()
12
F.points()
[(0 : 0 : 1), (0 : 1 : 0), (5 : 3 : 1), (5 : 8 : 1), (7 : 3 : 1), (7 : 8 : 1), (8 : 5 : 1), (8 : 6 : 1), (9 : 1 : 1), (9 : 10 : 1), (10 : 3 : 1), (10 : 8 : 1)]
P = F.random_point()
P
(5 : 3 : 1)
P.order()
3
Isomorphisms
F.automorphisms()
[Generic endomorphism of Abelian group of points on Elliptic Curve defined by y^2 = x^3 + x over Finite Field of size 11 Via: (u,r,s,t) = (1, 0, 0, 0), Generic endomorphism of Abelian group of points on Elliptic Curve defined by y^2 = x^3 + x over Finite Field of size 11 Via: (u,r,s,t) = (10, 0, 0, 0)]
aut = F.change_ring(GF(11^2)).automorphisms()
aut
[Generic endomorphism of Abelian group of points on Elliptic Curve defined by y^2 = x^3 + x over Finite Field in z2 of size 11^2 Via: (u,r,s,t) = (1, 0, 0, 0), Generic endomorphism of Abelian group of points on Elliptic Curve defined by y^2 = x^3 + x over Finite Field in z2 of size 11^2 Via: (u,r,s,t) = (10, 0, 0, 0), Generic endomorphism of Abelian group of points on Elliptic Curve defined by y^2 = x^3 + x over Finite Field in z2 of size 11^2 Via: (u,r,s,t) = (4*z2 + 3, 0, 0, 0), Generic endomorphism of Abelian group of points on Elliptic Curve defined by y^2 = x^3 + x over Finite Field in z2 of size 11^2 Via: (u,r,s,t) = (7*z2 + 8, 0, 0, 0)]
aut[3], aut[3]^2
(Generic endomorphism of Abelian group of points on Elliptic Curve defined by y^2 = x^3 + x over Finite Field in z2 of size 11^2 Via: (u,r,s,t) = (7*z2 + 8, 0, 0, 0), Generic endomorphism of Abelian group of points on Elliptic Curve defined by y^2 = x^3 + x over Finite Field in z2 of size 11^2 Via: (u,r,s,t) = (10, 0, 0, 0))
G = EllipticCurve(GF(11), [3, 0])
F.is_isomorphic(G)
True
u = F.isomorphism_to(G)
u
Generic morphism: From: Abelian group of points on Elliptic Curve defined by y^2 = x^3 + x over Finite Field of size 11 To: Abelian group of points on Elliptic Curve defined by y^2 = x^3 + 3*x over Finite Field of size 11 Via: (u,r,s,t) = (8, 0, 0, 0)
P, u(P)
((5 : 3 : 1), (3 : 6 : 1))
Group structure
F.abelian_group()
Additive abelian group isomorphic to Z/12 embedded in Abelian group of points on Elliptic Curve defined by y^2 = x^3 + x over Finite Field of size 11
g = F.gens()[0]
g
(8 : 5 : 1)
g.order()
12
Construct an isogeny with given kernel
origin = 6*g
origin
(0 : 0 : 1)
F.point([0,0])
(0 : 0 : 1)
I = F.isogeny(origin)
I
Isogeny of degree 2 from Elliptic Curve defined by y^2 = x^3 + x over Finite Field of size 11 to Elliptic Curve defined by y^2 = x^3 + 7*x over Finite Field of size 11
I.rational_maps()
((x^2 + 1)/x, (x^2*y - y)/x^2)
FF = I.codomain()
FF
Elliptic Curve defined by y^2 = x^3 + 7*x over Finite Field of size 11
FF.abelian_group()
Additive abelian group isomorphic to Z/6 + Z/2 embedded in Abelian group of points on Elliptic Curve defined by y^2 = x^3 + 7*x over Finite Field of size 11
FF.plot()
The same example, over the rationals
E = EllipticCurve([1,0])
P = E.lift_x(0)
P
(0 : 0 : 1)
P.order()
2
J = E.isogeny(P)
EE = J.codomain()
EE
Elliptic Curve defined by y^2 = x^3 - 4*x over Rational Field
In (very) limited cases, Sage can compute the isogeny given the image curve and the degree
JJ = E.isogeny(None, codomain=EE, degree=2)
J == JJ
True
The functionality is a bit limited, but still useful
E = EllipticCurve([1,0])
E
Elliptic Curve defined by y^2 = x^3 + x over Rational Field
E.has_cm()
True
E.cm_discriminant()
-4
Over finite fields
E = EllipticCurve(GF(101), [1,2])
E
Elliptic Curve defined by y^2 = x^3 + x + 2 over Finite Field of size 101
E.j_invariant()
4
chi = E.frobenius_polynomial()
chi
x^2 - 2*x + 101
chi.discriminant()
-400
E.trace_of_frobenius()
2
O = E.frobenius_order()
O
Order in Number Field in phi with defining polynomial x^2 - 2*x + 101
O.is_maximal()
False
O.discriminant()
-400
K = O.number_field()
K
Number Field in phi with defining polynomial x^2 - 2*x + 101
OK = K.maximal_order()
OK
Gaussian Integers in Number Field in phi with defining polynomial x^2 - 2*x + 101
OK.discriminant()
-4
K.class_number()
1
K.class_group()
Class group of order 1 of Number Field in phi with defining polynomial x^2 - 2*x + 101
O.class_number()
4
H = hilbert_class_polynomial(-400)
H
x^4 - 1938773508354872717845384224*x^3 + 12869286863161864184636279443710336*x^2 - 19075061455767889406477974994607212544*x + 87448873738295790450948276123544550117376
H.is_irreducible()
True
H.change_ring(GF(101)).factor()
(x + 7) * (x + 24) * (x + 64) * (x + 97)
Hint: try to find a solution to $p+1-t = 101$, then compute the discriminant of the Frobenius and use complex multiplication theory.
Warning: this is obviously a difficult exercise, and requires knowledge not contained in the course (for example, of Cornacchia's algorithm)