Skip to content

Commit

Permalink
gh-35799: test whether point is actually on the curve when evaluating…
Browse files Browse the repository at this point in the history
… elliptic-curve isomorphism

    
In Sage 10.0:
```sage
sage: E = EllipticCurve(GF(101), [1,1])
sage: f = E.automorphisms()[0]
sage: EE = EllipticCurve(GF(101), [5,5])
sage: P = EE.lift_x(2)
sage: P in f.domain()
False
sage: f(P)
(2 : 15 : 1)
sage: f(P) in f.codomain()
True
sage: f.codomain().defining_polynomial()(*f(P))
12
```

Sage will happily "evaluate" a `WeierstrassIsomorphism` on just about
any `EllipticCurvePoint`, even a point which explicitly lies on a
*different* curve. This simple patch adds a check to remove this
footgun.
    
URL: #35799
Reported by: Lorenz Panny
Reviewer(s): Kwankyu Lee
  • Loading branch information
Release Manager committed Dec 4, 2023
2 parents 8217447 + 94068f7 commit 69b0671
Showing 1 changed file with 19 additions and 1 deletion.
20 changes: 19 additions & 1 deletion src/sage/schemes/elliptic_curves/weierstrass_morphism.py
Original file line number Diff line number Diff line change
Expand Up @@ -611,7 +611,7 @@ def _eval(self, P):
Q = baseWI.__call__(self, P)
return self._codomain.base_extend(k).point(Q)

def __call__(self, P):
def _call_(self, P):
r"""
Call function for WeierstrassIsomorphism class.
Expand Down Expand Up @@ -648,6 +648,24 @@ def __call__(self, P):
432
sage: E(i(P))._order
432
Check that the isomorphism cannot be evaluated on points outside
its domain (see :issue:`35799`)::
sage: # needs sage.rings.finite_rings
sage: E = EllipticCurve(GF(101), [1,1])
sage: f = E.automorphisms()[0]
sage: EE = EllipticCurve(GF(101), [5,5])
sage: P = EE.lift_x(2)
sage: P in f.domain()
False
sage: f(P)
Traceback (most recent call last):
...
TypeError: (2 : 15 : 1) fails to convert into the map's
domain Elliptic Curve defined by y^2 = x^3 + x + 1 over
Finite Field of size 101, but a `pushforward` method is
not properly implemented
"""
if P[2] == 0:
return self._codomain(0)
Expand Down

0 comments on commit 69b0671

Please sign in to comment.