From 8ea8b7ed16826f371a27b9644980b171406b22d9 Mon Sep 17 00:00:00 2001 From: Loup Vaillant Date: Fri, 21 Feb 2020 22:07:55 +0100 Subject: [PATCH] Elligator script: avoid redundant computaton --- tests/gen/elligator.py | 17 +++++------------ 1 file changed, 5 insertions(+), 12 deletions(-) diff --git a/tests/gen/elligator.py b/tests/gen/elligator.py index df9c394..1759967 100755 --- a/tests/gen/elligator.py +++ b/tests/gen/elligator.py @@ -179,29 +179,22 @@ def from_edwards(point): return (u, v) # entire key generation chain -def private_to_hash(scalar): - xy = scalarbase(scalar) - uv = from_edwards(xy) - if can_curve_to_hash(uv): - return curve_to_hash(uv) - return None - def full_cycle_check(scalar): fe(scalar).print() xy = scalarbase(scalar) uv = from_edwards(xy) - h = private_to_hash(scalar) uv[0].print() uv[1].print() - if h is None: - print('00:') # Failure - print('00:') # dummy value for the hash - else: + if can_curve_to_hash(uv): + h = curve_to_hash(uv) print('01:') # Success h.print() # actual value for the hash c = hash_to_curve(h) if c != uv: print('Round trip failure') + else: + print('00:') # Failure + print('00:') # dummy value for the hash private = 0 for v in range(20): -- 2.47.3