From 6f0fca4d73be5442fc18a87cee4559f4b248bcee Mon Sep 17 00:00:00 2001 From: Sebastian Spindler Date: Thu, 9 May 2024 00:20:38 +0200 Subject: [PATCH] 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)