1
0
mirror of https://git.tartarus.org/simon/putty.git synced 2025-07-01 03:22:48 -05:00

Fix two misstatements of the Montgomery curve equation.

I got it right in all the serious code (or else my Curve25519 key
exchange wouldn't have worked), but I wrote it down wrongly in the
comment in ecc.h, putting the coefficient b on the RHS x term rather
than the LHS y^2. Then I repeated the same error in the point
decompression function in eccref.py.
This commit is contained in:
Simon Tatham
2019-01-03 15:26:33 +00:00
parent 4eb1dedb66
commit 992f98d5d7
2 changed files with 3 additions and 3 deletions

View File

@ -327,8 +327,8 @@ class MontgomeryCurve(CurveBase):
def cpoint(self, x, yparity=0):
if not hasattr(self, 'sqrtmodp'):
self.sqrtmodp = SqrtModP(self.p)
rhs = x**3 + self.a.n * x**2 + self.b.n * x
y = self.sqrtmodp.sqrt(rhs)
rhs = (x**3 + self.a.n * x**2 + x) / self.b
y = self.sqrtmodp.sqrt(int(rhs))
if (y - yparity) % 2:
y = -y
return self.point(x, y)