From 6f0fca4d73be5442fc18a87cee4559f4b248bcee Mon Sep 17 00:00:00 2001 From: Sebastian Spindler Date: Thu, 9 May 2024 00:20:38 +0200 Subject: [PATCH 1/2] Modify tests in `ell_point.py` to be more generic Make the tests of `.weil_pairing` and `.tate_pairing` independent of the implementation of `GF(65537^2)`, in view of Conway database update --- src/sage/schemes/elliptic_curves/ell_point.py | 25 +++++++------------ 1 file changed, 9 insertions(+), 16 deletions(-) diff --git a/src/sage/schemes/elliptic_curves/ell_point.py b/src/sage/schemes/elliptic_curves/ell_point.py index 9889808b35d..84a4b051793 100644 --- a/src/sage/schemes/elliptic_curves/ell_point.py +++ b/src/sage/schemes/elliptic_curves/ell_point.py @@ -1833,16 +1833,20 @@ def weil_pairing(self, Q, n, algorithm=None): TESTS: - Check that the original Sage implementation still works:: + Check that the original Sage implementation still works and + that the result coincides with the PARI implementation:: sage: # needs sage.rings.finite_rings sage: GF(65537^2).inject_variables() Defining z2 sage: E = EllipticCurve(GF(65537^2), [0,1]) - sage: P = E(22, 28891) - sage: Q = E(-93, 40438*z2 + 31573) - sage: P.weil_pairing(Q, 7282, algorithm='sage') - 19937*z2 + 65384 + sage: R, S = E.torsion_basis(7282) + sage: a, b = ZZ.random_element(), ZZ.random_element() + sage: P = a*R + b*S + sage: c, d = ZZ.random_element(), ZZ.random_element() + sage: Q = c*R + d*S + sage: P.weil_pairing(Q, 7282, algorithm='sage') == P.weil_pairing(Q, 7282, algorithm='pari') + True Passing an unknown ``algorithm=`` argument should fail:: @@ -2049,17 +2053,6 @@ def tate_pairing(self, Q, n, k, q=None): TESTS: - Check that the PARI output matches the original Sage implementation:: - - sage: # needs sage.rings.finite_rings - sage: GF(65537^2).inject_variables() - Defining z2 - sage: E = EllipticCurve(GF(65537^2), [0,1]) - sage: P = E(22, 28891) - sage: Q = E(-93, 40438*z2 + 31573) - sage: P.tate_pairing(Q, 7282, 2) - 34585*z2 + 4063 - The point ``P (self)`` must have ``n`` torsion:: sage: P.tate_pairing(Q, 163, 2) From 6973ae918c96b64d248eaa96d8318027f16746c8 Mon Sep 17 00:00:00 2001 From: Sebastian Spindler Date: Thu, 9 May 2024 01:12:15 +0200 Subject: [PATCH 2/2] Moved old tests to examples Amend: Fixed typo --- src/sage/schemes/elliptic_curves/ell_point.py | 22 +++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/src/sage/schemes/elliptic_curves/ell_point.py b/src/sage/schemes/elliptic_curves/ell_point.py index 84a4b051793..99e3e8c81fa 100644 --- a/src/sage/schemes/elliptic_curves/ell_point.py +++ b/src/sage/schemes/elliptic_curves/ell_point.py @@ -1818,6 +1818,17 @@ def weil_pairing(self, Q, n, algorithm=None): sage: z.multiplicative_order() 360 + Another larger example:: + + sage: F = GF(65537^2, modulus=[3,-1,1], name='a') + sage: F.inject_variables() + Defining a + sage: E = EllipticCurve(F, [0,1]) + sage: P = E(22, 28891) + sage: Q = E(-93, 2728*a + 64173) + sage: P.weil_pairing(Q, 7282, algorithm='sage') + 53278*a + 36700 + An example over a number field:: sage: # needs sage.rings.number_field @@ -2051,6 +2062,17 @@ def tate_pairing(self, Q, n, k, q=None): sage: Px.weil_pairing(Qx, 41)^e == num/den True + An example over a large base field:: + + sage: F = GF(65537^2, modulus=[3,46810,1], name='z2') + sage: F.inject_variables() + Defining z2 + sage: E = EllipticCurve(F, [0,1]) + sage: P = E(22, 28891) + sage: Q = E(-93, 40438*z2 + 31573) + sage: P.tate_pairing(Q, 7282, 2) + 34585*z2 + 4063 + TESTS: The point ``P (self)`` must have ``n`` torsion::