Closed naumazeredo closed 6 years ago
Thanks for catching that, you're correct that multiplication by negatives should be multiplication by the element in Zq that they are congruent to. Fixed in commit e38578e, will be in version 1.4.3.
In [1]: from fastecdsa.curve import P256
In [2]: from fastecdsa.point import Point
In [3]: a = -1 * P256.G
In [4]: b = (-1 % P256.q) * P256.G
In [5]: assert(a == b)
In [6]:
Simple verification with negative factor fails like shown:
As stated in StackExchange, the identity
xP = (x+q)P
should hold even for negative values.I think that if all multiplications should be done modulus curve's
q
(but I don't know much about EC, so the fix could be broader).