]> git.codecow.com Git - Monocypher.git/commitdiff
Elligator script: added fast_from_edwards
authorLoup Vaillant <loup@loup-vaillant.fr>
Thu, 20 Feb 2020 23:21:21 +0000 (00:21 +0100)
committerLoup Vaillant <loup@loup-vaillant.fr>
Thu, 20 Feb 2020 23:21:21 +0000 (00:21 +0100)
tests/gen/elligator.py

index fa59588566b97750c0ae0d9ebc84a898e66df348..df9c394888840bdc5de6babc0e54e0c781c27c6a 100755 (executable)
@@ -240,6 +240,17 @@ def fast_scalarmult(point, scalar):
 def fast_scalarbase(scalar):
     return fast_scalarmult(edwards_base, scalar)
 
+def fast_from_edwards(point):
+    sqA = sqrt(fe(-486664)) # constant
+    x = point[0]
+    y = point[1]
+    z = point[2]
+    u  = z + y
+    zu = z - y
+    v  = u * z * sqA
+    zv = zu * x
+    return (u*zv, v*zu, zu*zv)
+
 # Explicit formula for hash_to_curve
 # We don't need the v coordinate for X25519, so it is omited
 def explicit_hash_to_curve(r):