Skip to content

Scalar multiplication by -1 is crashing #38

@AurelienCha

Description

@AurelienCha

Hi,

I have just discovered that scalar multiplication by -1 on an EC point raises an unexpected error. I am using the Montgormery Curve 25519. However it seems to fail on other curves as well (but I haven't try all the curves yet).

I can multiply an EC point by any scalar (even negative scalar) except -1. I can for example multiply a two points P by 2 and -3 respectively and then add them together to get -1*P without any error. However, doing (-1)*G crashes. Note that the simple negation -G works.

Here is a code example:

`

from ecpy.curves import Curve, Point
...
... curve = Curve.get_curve('Curve25519')
... G = curve.generator
... P = 2*G + (-3)*G
... assert P == -G
... Q = (-1)*G
...
Traceback (most recent call last):
File "", line 7, in
Q = (-1)*G
~~~~^~
File "/home/garuda/.local/lib/python3.13/site-packages/ecpy/curves.py", line 1109, in rmul
return self.mul(scal)
~~~~~~~~~~~~^^^^^^
File "/home/garuda/.local/lib/python3.13/site-packages/ecpy/curves.py", line 1105, in mul
return self.curve._mul_point(scal,self)
~~~~~~~~~~~~~~~~~~~~~^^^^^^^^^^^
File "/home/garuda/.local/lib/python3.13/site-packages/ecpy/curves.py", line 879, in _mul_point
return Point (kx, ky, self)
File "/home/garuda/.local/lib/python3.13/site-packages/ecpy/curves.py", line 981, in init
raise ECPyException("Point not on curve")
ecpy.curves.ECPyException: <exception str() failed>
`

Python Version:
Python 3.13.11 (main, Dec 7 2025, 13:01:45) [GCC 15.2.1 20251112] on linux
Type "help", "copyright", "credits" or "license" for more information.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions