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:
@ -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)
|
||||
|
Reference in New Issue
Block a user