From: Loup Vaillant Date: Fri, 21 Feb 2020 21:07:55 +0000 (+0100) Subject: Elligator script: avoid redundant computaton X-Git-Url: https://git.codecow.com/?a=commitdiff_plain;h=8ea8b7ed16826f371a27b9644980b171406b22d9;p=Monocypher.git Elligator script: avoid redundant computaton --- 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):