Ryan Rueger

ryan@rueg.re / picture / key / home
aboutsummaryrefslogtreecommitdiffhomepage
path: root/theta_lib/theta_structures/Theta_dim1.py
diff options
context:
space:
mode:
authorRyan Rueger <git@rueg.re>2025-03-01 20:25:41 +0100
committerRyan Rueger <git@rueg.re>2025-03-01 22:11:11 +0100
commitd40de259097c5e8d8fd35539560ca7c3d47523e7 (patch)
tree18e0f94350a2329060c2a19b56b0e3e2fdae56f1 /theta_lib/theta_structures/Theta_dim1.py
downloadpegasis-d40de259097c5e8d8fd35539560ca7c3d47523e7.tar.gz
pegasis-d40de259097c5e8d8fd35539560ca7c3d47523e7.tar.bz2
pegasis-d40de259097c5e8d8fd35539560ca7c3d47523e7.zip
Initial Commit
Co-Authored-By: Damien Robert <Damien.Olivier.Robert+git@gmail.com> Co-Authored-By: Frederik Vercauteren <frederik.vercauteren@gmail.com> Co-Authored-By: Jonathan Komada Eriksen <jonathan.eriksen97@gmail.com> Co-Authored-By: Pierrick Dartois <pierrickdartois@icloud.com> Co-Authored-By: Riccardo Invernizzi <nidadoni@gmail.com> Co-Authored-By: Ryan Rueger <git@rueg.re> [0.01s] Co-Authored-By: Benjamin Wesolowski <benjamin@pasch.umpa.ens-lyon.fr> Co-Authored-By: Arthur Herlédan Le Merdy <ahlm@riseup.net> Co-Authored-By: Boris Fouotsa <tako.fouotsa@epfl.ch>
Diffstat (limited to 'theta_lib/theta_structures/Theta_dim1.py')
-rw-r--r--theta_lib/theta_structures/Theta_dim1.py98
1 files changed, 98 insertions, 0 deletions
diff --git a/theta_lib/theta_structures/Theta_dim1.py b/theta_lib/theta_structures/Theta_dim1.py
new file mode 100644
index 0000000..e8e94dd
--- /dev/null
+++ b/theta_lib/theta_structures/Theta_dim1.py
@@ -0,0 +1,98 @@
+from sage.all import *
+from ..utilities.supersingular import compute_linearly_independent_point
+from .montgomery_theta import (
+ montgomery_point_to_theta_point,
+ theta_point_to_montgomery_point,
+ torsion_to_theta_null_point,
+)
+
+
+class ThetaStructureDim1:
+ def __init__(self,E,P=None,Q=None):
+ self.E=E
+
+ a_inv=E.a_invariants()
+
+ A =a_inv[1]
+ if a_inv != (0,A,0,1,0):
+ raise ValueError("The elliptic curve E is not in the Montgomery model.")
+
+ if Q==None:
+ y2=A-2
+ y=y2.sqrt()
+ Q=E([-1,y,1])
+ P=compute_linearly_independent_point(E,Q,4)
+ else:
+ if Q[0]!=-1:
+ raise ValueError("You should enter a canonical 4-torsion basis. Q[0] should be -1.")
+
+ self.P=P
+ self.Q=Q
+
+ self._base_ring=E.base_ring()
+
+ self._point=ThetaPointDim1
+ self._null_point=self._point(self,torsion_to_theta_null_point(P))
+
+ def null_point(self):
+ """
+ """
+ return self._null_point
+
+ def base_ring(self):
+ """
+ """
+ return self._base_ring
+
+ def zero(self):
+ """
+ """
+ return self.null_point()
+
+ def elliptic_curve(self):
+ return self.E
+
+ def torsion_basis(self):
+ return (self.P,self.Q)
+
+ def __call__(self,coords):
+ r"""
+ Input: either a tuple or list of 2 coordinates or an elliptic curve point.
+
+ Output: the corresponding theta point for the self theta structure.
+ """
+ if isinstance(coords,tuple):
+ return self._point(self,coords)
+ elif isinstance(coords,list):
+ return self._point(self,coords)
+ else:
+ return self._point(self,montgomery_point_to_theta_point(self.null_point().coords(),coords))
+
+ def __repr__(self):
+ return f"Theta structure on {self.elliptic_curve()} with null point: {self.null_point()} induced by the 4-torsion basis {self.torsion_basis()}"
+
+ def to_montgomery_point(self,P):
+ return theta_point_to_montgomery_point(self.E,self.null_point().coords(),P.coords())
+
+
+class ThetaPointDim1:
+ def __init__(self, parent, coords):
+ """
+ """
+ if not isinstance(parent, ThetaStructureDim1):
+ raise ValueError("Entry parent should be a ThetaStructureDim1 object.")
+
+ self._parent = parent
+ self._coords = tuple(coords)
+
+
+ def coords(self):
+ return self._coords
+
+ def __repr__(self):
+ return f"Theta point with coordinates: {self.coords()}"
+
+
+
+
+