Commit eae39974 authored by GUILLEVIC Aurore's avatar GUILLEVIC Aurore

corrected sign error in param computation for running RELIC

parent e489fcbb
......@@ -195,11 +195,15 @@ def print_parameters_for_RELIC(E):
# fill at 16 hexa digits, + 2 for the 'prefix '0x' makes 18 characters
print("P{0} {1:0=-#018x}".format(i, pi))
i+=1
g,u0,v0 = xgcd(E._p,2**64)
if abs(u0) > abs(v0):
u0,v0 = v0,u0
# p_w = p-wordsize rounded to largest machine word
# we need the inverse of -p, not of p
# so either
#g,u0,v0 = xgcd(E._p,2**64) # g = u0*p + v0*2**64
#u0 = 2**64 - u0
# or directly:
g,u0,v0 = xgcd(-E._p,2**64) # g = u0*p + v0*2**64
if u0 < 0:
u0 = -u0; v0 = -v0
u0 = 2**64+u0
print("U0 {:0=-#018x}".format(u0))
#params for the ep module in RELIC
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment