Skip to content

Commit

Permalink
Add EllipticCurve.is_infinity() which returns True when point at infi…
Browse files Browse the repository at this point in the history
…nity

This is required for checks in Elligator Squared mapping functions f and r.
  • Loading branch information
stratospher committed Jan 8, 2022
1 parent 95833c0 commit 1a32739
Showing 1 changed file with 7 additions and 0 deletions.
7 changes: 7 additions & 0 deletions test/functional/test_framework/key.py
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,13 @@ def on_curve(self, p1):
z4 = pow(z2, 2, self.p)
return z1 != 0 and (pow(x1, 3, self.p) + self.a * x1 * z4 + self.b * z2 * z4 - pow(y1, 2, self.p)) % self.p == 0

def is_infinity(self, p1):
"""Return true if Jacobian tuple p is at infinity"""
_, _, z1 = p1
if z1 == 0:
return True
return False

def is_x_coord(self, x):
"""Test whether x is a valid X coordinate on the curve."""
x_3 = pow(x, 3, self.p)
Expand Down

0 comments on commit 1a32739

Please sign in to comment.