removed unnecessary else
@@ -152,7 +152,7 @@ class CurveGroup:
# point is assumed to be on curve
if Q[2] == 0: # Infinity point in Jacobian coordinates
return INF
- else:
+
Z2 = Q[2] * Q[2]
x = Q[0] * mod_inv(Z2, self.p)
y = Q[1] * mod_inv(Z2 * Q[2], self.p)
@@ -162,7 +162,7 @@ class CurveGroup:
# point is assumed to be on curve
if Q[2] == 0: # Infinity point in Jacobian coordinates
raise ValueError("infinity point has no x-coordinate")
- else:
+
Z2 = Q[2] * Q[2]
return (Q[0] * mod_inv(Z2, self.p)) % self.p
@@ -175,6 +175,7 @@ class CurveGroup:
QJ2 = QJ[2] * QJ[2]
if QJ[0] * PJ2 % self.p != PJ[0] * QJ2 % self.p:
return False
+
PJ3 = PJ2 * PJ[2]
QJ3 = QJ2 * QJ[2]
return QJ[1] * PJ3 % self.p == PJ[1] * QJ3 % self.p
@@ -273,7 +274,7 @@ class CurveGroup:
if R[0] == Q[0]:
if R[1] == Q[1]: # point doubling
return self._double_aff(R)
- else: # opposite points
+ # opposite points
return INF
lam = (R[1] - Q[1]) * mod_inv(R[0] - Q[0], self.p)
@@ -397,9 +398,9 @@ def _mult_recursive_aff(m: int, Q: Point, ec: CurveGroup) -> Point:
if m == 0:
return INF
- if (m % 2) == 1:
+ if m % 2 == 1:
return ec._add_aff(Q, _mult_recursive_aff((m - 1), Q, ec))
- else:
+
return _mult_recursive_aff((m // 2), ec._double_aff(Q), ec)
@@ -421,9 +422,9 @@ def _mult_recursive_jac(m: int, Q: JacPoint, ec: CurveGroup) -> JacPoint:
if m == 0:
return INFJ
- if (m % 2) == 1:
+ if m % 2 == 1:
return ec._add_jac(Q, _mult_recursive_jac((m - 1), Q, ec))
- else:
+
return _mult_recursive_jac((m // 2), ec._double_jac(Q), ec)
