Skip to content

Commit 47e1d0d

Browse files
committed
ensure that the points are really the same before doubling
1 parent e559c4a commit 47e1d0d

1 file changed

Lines changed: 6 additions & 5 deletions

File tree

src/ecdsa/ellipticcurve.py

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1185,14 +1185,15 @@ def __add__(self, other):
11851185
if self == INFINITY:
11861186
return other
11871187
assert self.__curve == other.__curve
1188-
if self.__x == other.__x:
1189-
if (self.__y + other.__y) % self.__curve.p() == 0:
1190-
return INFINITY
1191-
else:
1192-
return self.double()
11931188

11941189
p = self.__curve.p()
11951190

1191+
if (self.__x - other.__x) % p == 0:
1192+
if (self.__y + other.__y) % p == 0:
1193+
return INFINITY
1194+
elif (self.__y - other.__y) % p == 0:
1195+
return self.double()
1196+
11961197
l = (
11971198
(other.__y - self.__y)
11981199
* numbertheory.inverse_mod(other.__x - self.__x, p)

0 commit comments

Comments
 (0)