]> git.codecow.com Git - Monocypher.git/commitdiff
Elligator script: naming nitpick
authorLoup Vaillant <loup@loup-vaillant.fr>
Sun, 23 Feb 2020 09:44:44 +0000 (10:44 +0100)
committerLoup Vaillant <loup@loup-vaillant.fr>
Sun, 23 Feb 2020 09:44:44 +0000 (10:44 +0100)
tests/gen/elligator.py

index 925e88b1d648943b6c96587e2d68500f1faaef07..012b9fc447c1b0501529cfb827986c242e928a58 100755 (executable)
@@ -69,11 +69,11 @@ class fe:
 
     def __eq__(self, other): return self.val % self.p == other.val % self.p
     def __ne__(self, other): return self.val % self.p != other.val % self.p
-    def isPositive(self)   : return self.val % self.p <= (p-1) // 2
+    def is_positive(self)  : return self.val % self.p <= (p-1) // 2
 
     def abs(self):
-        if self.isPositive(): return  self
-        else                : return -self
+        if self.is_positive(): return  self
+        else                 : return -self
 
     def print(self):
         """prints a field element in little endian"""
@@ -121,8 +121,8 @@ def curve_to_hash(point):
     v   = point[1]
     sq1 = sqrt(-u     / (fe(2) * (u+A)))
     sq2 = sqrt(-(u+A) / (fe(2) * u    ))
-    if v.isPositive(): return sq1
-    else             : return sq2
+    if v.is_positive(): return sq1
+    else              : return sq2
 
 # round trip test
 for i in range(50):