aboutsummaryrefslogtreecommitdiff
path: root/generate_parameters.py
diff options
context:
space:
mode:
authorGravatar Andres Erbsen <andreser@google.com>2017-11-02 15:37:23 +0000
committerGravatar Andres Erbsen <andreser@google.com>2017-11-02 15:37:23 +0000
commit228495914cf66eac4c0512d547a70b1ed40c56d0 (patch)
tree6c2c965a0ec0d9fc4693f9ed18c46090b318b077 /generate_parameters.py
parent2d7703295debda94464b955c1e1dda151ec6ea49 (diff)
generate_parameters.py: supply dummy a24 of correct length
Diffstat (limited to 'generate_parameters.py')
-rw-r--r--generate_parameters.py10
1 files changed, 6 insertions, 4 deletions
diff --git a/generate_parameters.py b/generate_parameters.py
index 99b88c11b..3df50dc02 100644
--- a/generate_parameters.py
+++ b/generate_parameters.py
@@ -145,13 +145,15 @@ def eval_numexpr(numexpr):
def get_extra_compiler_params(q, base, bitwidth, sz):
def log_wt(i):
return int(math.ceil(sum(map(Fraction, map(str.strip, str(base).split('+')))) * i))
- q_hex_stripped = hex(eval_numexpr(q.replace('^', '**')))[2:].strip('L')
- q_hex_padded = q_hex_stripped.rjust(2 * int((len(q_hex_stripped) + 1) / 2), '0')
+ q_int = eval_numexpr(q.replace('^', '**'))
+ a24 = 12345 # TODO
+ modulus_bytes = (q_int.bit_length()+7)//8
limb_widths = repr('{%s}' % ','.join(str(int(log_wt(i + 1) - log_wt(i))) for i in range(sz)))
defs = {
'q_mpz' : repr(re.sub(r'2(\s*)\^(\s*)([0-9]+)', r'(1_mpz\1<<\2\3)', str(q))),
- 'modulus_bytes_val' : repr(str(base)),
- 'modulus_array' : repr('{%s}' % ','.join('0x%s' % s for s in textwrap.wrap(q_hex_padded, 2))),
+ 'modulus_bytes_val' : repr(str(modulus_bytes)),
+ 'modulus_array' : repr('{%s}' % ','.join(reversed(list('0x%02x' % ((q_int >> 8*i)&0xff) for i in range(modulus_bytes))))),
+ 'a_minus_two_over_four_array' : repr('{%s}' % ','.join(reversed(list('0x%02x' % ((a24 >> 8*i)&0xff) for i in range(modulus_bytes))))),
'limb_t' : 'uint%d_t' % bitwidth,
'modulus_limbs' : repr(str(sz)),
'limb_weight_gaps_array' : limb_widths