Apply suggestions from code review

Comments and a minor refactor for consistency.
This commit is contained in:
Daira Hopwood 2021-04-29 02:07:46 +01:00 committed by GitHub
parent 9cb9e0f9bc
commit f8008a01fd
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 3 additions and 4 deletions

View File

@ -99,10 +99,7 @@ def map_to_curve_simple_swu(u):
e1 = x1 == Fp(0)
x1 = x1 + Fp(1)
if e1:
x1 = c2
else:
x1 = x1
x1 = c2 if e1 else x1 # If (tv1 + tv2) == 0, set x1 = -1 / Z
x1 = x1 * c1 # x1 = (-B / A) * (1 + (1 / (Z^2 * u^4 + Z * u^2)))
gx1 = x1.exp(2)

View File

@ -97,6 +97,7 @@ class Point(object):
elif a.is_identity:
return self
else:
# Hüseyin Hışıl. “Elliptic Curves, Group Law, and Efficient Computation”. PhD thesis.
# <https://core.ac.uk/download/pdf/10898289.pdf> section 4.1
(x1, y1) = (self.x, self.y)
(x2, y2) = (a.x, a.y)
@ -119,6 +120,7 @@ class Point(object):
if self.is_identity:
return self
# Hüseyin Hışıl. “Elliptic Curves, Group Law, and Efficient Computation”. PhD thesis.
# <https://core.ac.uk/download/pdf/10898289.pdf> section 4.1
λ = (Fp(3) * self.x * self.x + PALLAS_ISO_A) / (self.y + self.y)
x3 = λ*λ - self.x - self.x