# ------------------------------------------------------------------------
#
# Copyright (c) 2020, Loup Vaillant
+# Copyright (c) 2020, Fabio Scotoni
# All rights reserved.
#
#
#
# ------------------------------------------------------------------------
#
-# Written in 2020 by Loup Vaillant
+# Written in 2020 by Loup Vaillant and Fabio Scotoni
#
# To the extent possible under law, the author(s) have dedicated all copyright
# and related neighboring rights to this software to the public domain
from elligator import p
from elligator import print_raw
from random import randrange
+from random import seed
def direct(r1, padding):
q1 = hash_to_curve(r1)
direct(fe(0), 1) # representative 0 maps to point (0, 0)
direct(fe(0), 2) # representative 0 maps to point (0, 0)
direct(fe(0), 3) # representative 0 maps to point (0, 0)
+
+# Make test vector generation deterministic, the actual randomness does
+# not matter here since these are just tests.
+seed(12345)
+
for i in range(50):
direct(fe(randrange(0, (p-1)/2)), i % 4)
# ------------------------------------------------------------------------
#
# Copyright (c) 2020, Loup Vaillant
+# Copyright (c) 2020, Fabio Scotoni
# All rights reserved.
#
#
#
# ------------------------------------------------------------------------
#
-# Written in 2020 by Loup Vaillant
+# Written in 2020 by Loup Vaillant and Fabio Scotoni
#
# To the extent possible under law, the author(s) have dedicated all copyright
# and related neighboring rights to this software to the public domain
from elligator_scalarmult import scalarmult
from random import randrange
+from random import seed
def private_to_curve_and_hash(scalar, tweak):
cofactor = scalar % 8
if u2 != u: raise ValueError('Round trip failure')
return (u, r1.val + msb)
+# Make test vector generation deterministic, the actual randomness does
+# not matter here since these are just tests.
+seed(12345)
+
# All possible failures
for cofactor in range(8):
tweak = randrange(0, 256)