Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

Same code, (vastly) different results locally and at aleph.sagemath.org

I have SageMath 9.4 for Ubuntu 20.04 downloaded from a french mirror (link) and I am trying to run an LWE estimator (link) by Albrecht et al (link).

Running on Aleph

Without any problem, I can paste the estimator.py code (link) into Aleph (link), followed by my parameters, e.g.:

n, stdv = 1024, 2^-30.0
set_verbose(1)
_ = estimate_lwe(n, sqrt(2*pi)*stdv, 2^32,  reduction_cost_model=BKZ.sieve, secret_distribution=(0,1))

from which I obtain

Warning: the LWE secret is assumed to have Hamming weight 512.
usvp: rop: ≈2^108.0,  red: ≈2^108.0,  δ_0: 1.005242,  β:  266,  d: 1889,  m:      864,  repeat:        1,  k:        0,  postprocess:        0
 dec: rop: ≈2^131.5,  m:     1198,  red: ≈2^131.5,  δ_0: 1.004529,  β:  332,  d: 2222,  babai: ≈2^117.5,  babai_op: ≈2^132.6,  repeat:       17,  ε: 0.250000
dual: rop: ≈2^112.1,  m:      994,  red: ≈2^112.1,  δ_0: 1.005070,  β:  280,  repeat: ≈2^60.8,  d: 1986,  c:        8,  k:       32,  postprocess:        1

which tells me that I have 108.0 bits of security (2nd line: usvp: rop: ≈2^108.0). Until here -- fine.

Running locally

Now I need to process a heap of parameters automatically, which I am trying to run locally (using the aforementioned version of SageMath). Problems arise (with 1-3 possibly irrelevant, 4 indeed relevant):

  1. With the very same code I get: ImportError: cannot import name complex_mpfr, which seems to be resolved by adding import sage.all in the very beginning.
  2. Then I get: n, stdv = 1024, 2^-30.0 .. TypeError: unsupported operand type(s) for ^: 'int' and 'float' which I fix by replacing 2^-30.0 with 9.3132257e-10.
  3. Next run: NameError: name 'set_verbose' is not defined which I solved by importing from sage.misc.verbose import verbose, set_verbose, get_verbose (still some warnings -- deprecated stuff and syntax -- which I ignore)
  4. Final run: I get the results,

but with completely different numbers:

Warning: the LWE secret is assumed to have Hamming weight 512.
usvp: rop: ≈2^44.9,  red: ≈2^44.9,  δ_0: 1.013310,  β:   40,  d: 1024,  m:       -1,  repeat:        1,  k:        0,  postprocess:        0
 dec: rop: ≈2^43.6,  m:     -614,  red: ≈2^43.6,  δ_0: 1.021759,  β:   40,  d:  410,  babai:        1,  babai_op: ≈2^15.1,  repeat:        1,  ε:        1

(and then TypeError: unable to convert '2.5275472536193645856387667200778292581e-30+2.6845375638424411831060264943943048062e9*I' to a real number which I ignore)

Compared to 108.0 from Aleph, my local result 44.9 is completely false, though running the same code. I also pasted the modified code into Aleph and it still gives 108.0.

Find my final code at Pastebin (link) (gives results both on Aleph and locally).