|
| 1 | +r""" |
| 2 | +Homsets and endomorphism rings of elliptic curves |
| 3 | +
|
| 4 | +The set of homomorphisms between two elliptic curves (:class:`EllipticCurveHom`) |
| 5 | +forms an abelian group under addition. Moreover, if the two curves are the same, |
| 6 | +it even forms a (not always commutative) ring under composition. |
| 7 | +
|
| 8 | +This module encapsulates the set of homomorphisms between two given elliptic |
| 9 | +curves as a Sage object. |
| 10 | +
|
| 11 | +.. NOTE:: |
| 12 | +
|
| 13 | + Currently only little nontrivial functionality is available, but this will |
| 14 | + hopefully change in the future. |
| 15 | +
|
| 16 | +EXAMPLES: |
| 17 | +
|
| 18 | +The only useful thing this class does at the moment is coercing integers into |
| 19 | +the endomorphism ring as scalar multiplications:: |
| 20 | +
|
| 21 | + sage: E = EllipticCurve([1,2,3,4,5]) |
| 22 | + sage: f = End(E)(7); f |
| 23 | + Scalar-multiplication endomorphism [7] of Elliptic Curve defined by y^2 + x*y + 3*y = x^3 + 2*x^2 + 4*x + 5 over Rational Field |
| 24 | + sage: f == E.scalar_multiplication(7) |
| 25 | + True |
| 26 | +
|
| 27 | +:: |
| 28 | +
|
| 29 | + sage: E = EllipticCurve(GF(431^2), [0,1]) |
| 30 | + sage: E.automorphisms()[0] == 1 |
| 31 | + True |
| 32 | + sage: E.automorphisms()[1] == -1 |
| 33 | + True |
| 34 | + sage: omega = E.automorphisms()[2] |
| 35 | + sage: omega == 1 |
| 36 | + False |
| 37 | + sage: omega^3 == 1 |
| 38 | + True |
| 39 | + sage: (1 + omega + omega^2) == 0 |
| 40 | + True |
| 41 | + sage: (2*omega + 1)^2 == -3 |
| 42 | + True |
| 43 | +
|
| 44 | +AUTHORS: |
| 45 | +
|
| 46 | +- Lorenz Panny (2023) |
| 47 | +""" |
| 48 | + |
| 49 | +# **************************************************************************** |
| 50 | +# Copyright (C) 2023 Lorenz Panny |
| 51 | +# |
| 52 | +# This program is free software: you can redistribute it and/or modify |
| 53 | +# it under the terms of the GNU General Public License as published by |
| 54 | +# the Free Software Foundation, either version 2 of the License, or |
| 55 | +# (at your option) any later version. |
| 56 | +# https://www.gnu.org/licenses/ |
| 57 | +# **************************************************************************** |
| 58 | + |
| 59 | +from sage.rings.integer_ring import ZZ |
| 60 | +from sage.categories.morphism import Morphism |
| 61 | +from sage.schemes.generic.homset import SchemeHomset_generic |
| 62 | + |
| 63 | + |
| 64 | +class EllipticCurveHomset(SchemeHomset_generic): |
| 65 | + r""" |
| 66 | + This class represents the set of all homomorphisms between two fixed |
| 67 | + elliptic curves. |
| 68 | +
|
| 69 | + EXAMPLES:: |
| 70 | +
|
| 71 | + sage: E = EllipticCurve(GF(419^2), [1,0]) |
| 72 | + sage: E.frobenius_isogeny() in End(E) |
| 73 | + True |
| 74 | + sage: phi = E.isogenies_prime_degree(7)[0] |
| 75 | + sage: phi in End(E) |
| 76 | + False |
| 77 | + sage: phi in Hom(E, phi.codomain()) |
| 78 | + True |
| 79 | +
|
| 80 | + Note that domain and codomain are *not* taken up to isomorphism:: |
| 81 | +
|
| 82 | + sage: iso = E.isomorphism_to(EllipticCurve(GF(419^2), [2,0])) |
| 83 | + sage: iso in End(E) |
| 84 | + False |
| 85 | + """ |
| 86 | + def __init__(self, *args, **kwds): |
| 87 | + r""" |
| 88 | + Construct the homset for a given pair of curves. |
| 89 | +
|
| 90 | + TESTS:: |
| 91 | +
|
| 92 | + sage: E1 = EllipticCurve(j=42) |
| 93 | + sage: E2 = EllipticCurve(j=43) |
| 94 | + sage: Hom(E1, E2) |
| 95 | + Group of elliptic-curve morphisms |
| 96 | + From: Elliptic Curve defined by y^2 = x^3 + 5901*x + 1105454 over Rational Field |
| 97 | + To: Elliptic Curve defined by y^2 + x*y = x^3 + x^2 + 1510*x - 140675 over Rational Field |
| 98 | + """ |
| 99 | + super().__init__(*args, **kwds) |
| 100 | + |
| 101 | + if self.domain() == self.codomain(): |
| 102 | + # set up automated coercion of integers to scalar multiplications |
| 103 | + from sage.schemes.elliptic_curves.hom_scalar import EllipticCurveHom_scalar |
| 104 | + class ScalarMultiplicationEmbedding(Morphism): |
| 105 | + def __init__(self, End): |
| 106 | + assert End.domain() is End.codomain() |
| 107 | + super().__init__(ZZ, End) |
| 108 | + def _call_(self, m): |
| 109 | + return EllipticCurveHom_scalar(self.codomain().domain(), m) |
| 110 | + self.register_coercion(ScalarMultiplicationEmbedding(self)) |
| 111 | + |
| 112 | + def _repr_(self): |
| 113 | + r""" |
| 114 | + Output a description of this homset, with special formatting |
| 115 | + for endomorphism rings. |
| 116 | +
|
| 117 | + EXAMPLES:: |
| 118 | +
|
| 119 | + sage: E1 = EllipticCurve([1,1]) |
| 120 | + sage: E2 = EllipticCurve([2,2]) |
| 121 | + sage: End(E1) |
| 122 | + Ring of elliptic-curve endomorphisms |
| 123 | + From: Elliptic Curve defined by y^2 = x^3 + x + 1 over Rational Field |
| 124 | + To: Elliptic Curve defined by y^2 = x^3 + x + 1 over Rational Field |
| 125 | + sage: Hom(E1, E1) |
| 126 | + Ring of elliptic-curve endomorphisms |
| 127 | + From: Elliptic Curve defined by y^2 = x^3 + x + 1 over Rational Field |
| 128 | + To: Elliptic Curve defined by y^2 = x^3 + x + 1 over Rational Field |
| 129 | + sage: Hom(E1, E2) |
| 130 | + Group of elliptic-curve morphisms |
| 131 | + From: Elliptic Curve defined by y^2 = x^3 + x + 1 over Rational Field |
| 132 | + To: Elliptic Curve defined by y^2 = x^3 + 2*x + 2 over Rational Field |
| 133 | + """ |
| 134 | + if self.domain() == self.codomain(): |
| 135 | + s = 'Ring of elliptic-curve endomorphisms' |
| 136 | + else: |
| 137 | + s = 'Group of elliptic-curve morphisms' |
| 138 | + s += f'\n From: {self.domain()}' |
| 139 | + s += f'\n To: {self.codomain()}' |
| 140 | + return s |
| 141 | + |
0 commit comments