Skip to content

Commit

Permalink
Trac #34681: Error with multiplication of points on elliptic curves o…
Browse files Browse the repository at this point in the history
…ver Integers(n)

{{{
sage: E = EllipticCurve(Integers(11*19), [1,0])
sage: P = E(93,3)
sage: P + P
(5 : 118 : 1)
sage: 2 * P
...
AttributeError: 'EllipticCurve_generic_with_category' object has no
attribute 'base_field'
}}}

URL: https://trac.sagemath.org/34681
Reported by: tornaria
Ticket author(s): Gonzalo Tornaría
Reviewer(s): Lorenz Panny
  • Loading branch information
Release Manager committed Nov 7, 2022
2 parents 4b482ce + 9bbacfe commit 3b60334
Showing 1 changed file with 21 additions and 5 deletions.
26 changes: 21 additions & 5 deletions src/sage/schemes/elliptic_curves/ell_point.py
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@
sage: LCM([2..60])*P
Traceback (most recent call last):
...
ZeroDivisionError: Inverse of 1520944668 does not exist (characteristic = 1715761513 = 26927*63719)
ZeroDivisionError: Inverse of 26927 does not exist (characteristic = 1715761513 = 26927*63719)
AUTHORS:
Expand Down Expand Up @@ -630,7 +630,7 @@ def _add_(self, right):
sage: LCM([2..60])*P
Traceback (most recent call last):
...
ZeroDivisionError: Inverse of 1520944668 does not exist
ZeroDivisionError: Inverse of 26927 does not exist
(characteristic = 1715761513 = 26927*63719)
sage: N = 35
Expand All @@ -639,8 +639,15 @@ def _add_(self, right):
sage: 4*P
Traceback (most recent call last):
...
ZeroDivisionError: Inverse of 28 does not exist
ZeroDivisionError: Inverse of 7 does not exist
(characteristic = 35 = 7*5)
Checks that :trac:`34681` is fixed::
sage: P+P
(15 : 14 : 1)
sage: 2*P
(15 : 14 : 1)
"""
# Use Prop 7.1.7 of Cohen "A Course in Computational Algebraic
# Number Theory"
Expand Down Expand Up @@ -3497,15 +3504,24 @@ def _acted_upon_(self, other, side):

try:
pariQ = pari.ellmul(E, self, k)
except PariError:
except PariError as err:
if str(err.errdata().component(1)) == "Fp_inv":
val = err.errdata().component(2)
a = val.lift()
N = val.mod()
N1 = N.gcd(a)
N2 = N//N1
raise ZeroDivisionError(
f"Inverse of {a} does not exist"
f" (characteristic = {N} = {N1}*{N2})")
pariQ = None

if pariQ is not None:
if pariQ == [0]:
vQ = 0
else:
assert len(pariQ) == 2
vQ = Sequence(tuple(pariQ) + (1,), E.base_field())
vQ = Sequence(tuple(pariQ) + (1,), E.base_ring())
Q = EllipticCurvePoint_finite_field(E, vQ, check=False)

else:
Expand Down

0 comments on commit 3b60334

Please sign in to comment.