From: Loup Vaillant Date: Sat, 21 Mar 2020 12:18:48 +0000 (+0100) Subject: Elligator script: added padding to test vectors X-Git-Url: https://git.codecow.com/?a=commitdiff_plain;h=d68706518341922129ec60f8efea248d8acf650b;p=Monocypher.git Elligator script: added padding to test vectors So we properly test Monocypher ignores the padding --- diff --git a/tests/gen/elligator-direct.py b/tests/gen/elligator-direct.py index 7cc12b5..cee3e56 100755 --- a/tests/gen/elligator-direct.py +++ b/tests/gen/elligator-direct.py @@ -56,18 +56,22 @@ from elligator import curve_to_hash from elligator import hash_to_curve from elligator import fast_hash_to_curve from elligator import p +from elligator import print_raw from random import randrange -def direct(r1): +def direct(r1, padding): q1 = hash_to_curve(r1) q2 = fast_hash_to_curve(r1) r2 = curve_to_hash(q1[0], q1[1].is_negative()) if q1 != q2: raise ValueError('Incorrect fast_hash_to_curve') if r1 != r2: raise ValueError('Round trip failure') - r1 .print() + print_raw(r1.val + padding * 2**254) q1[0].print() # u coordinate only print() -direct(fe(0)) # representative 0 maps to point (0, 0) +direct(fe(0), 0) # representative 0 maps to point (0, 0) +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) for i in range(50): - direct(fe(randrange(0, (p-1)/2))) + direct(fe(randrange(0, (p-1)/2)), i % 4)