Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Crashes in SISLattice #115

Open
lenerd opened this issue Jun 25, 2024 · 0 comments
Open

Crashes in SISLattice #115

lenerd opened this issue Jun 25, 2024 · 0 comments

Comments

@lenerd
Copy link

lenerd commented Jun 25, 2024

I was playing around with the estimator for SIS and noticed crashes for certain parameters (see below for examples) in the cost_zeta method of SISLattice when searching for beta.

# step 1. optimize β
with local_minimum(
40, baseline_cost["beta"] + 1, precision=2, log_level=log_level + 1
) as it:
for beta in it:
it.update(f(beta))
for beta in it.neighborhood:
it.update(f(beta))
cost = it.y

  1. If baseline_cost["beta"] + 1 is smaller than 40, we get a ValueError because we try to search in an empty range.
  2. If baseline_cost["beta"] + 1 is equal to 41, we get a TypeError: Because precision is set to 2, the start and stop parameters of local_minimum are divided by two, resulting in an empty range [20,20) due to rounding and no neighborhood can be computed.

Maybe the SIS parameters in the examples below are obviously stupid for a lattice expert, but it would be nicer to have a helpful error message that explains what went wrong and maybe indicates how to change the parameters to obtain useful results.


Examples Code and Stack Traces

from estimator import *

# results in `ValueError: Incorrect bounds 20 > 10`
params = SIS.Parameters(n=1, q=2^1000, length_bound=2^100, norm=oo)
est = SIS.lattice(params)
Traceback (most recent call last):
  File "/home/lennart/dev/lattice-estimator/test.sage.py", line 11, in <module>
    est = SIS.lattice(params)
          ^^^^^^^^^^^^^^^^^^^
  File "/home/lennart/dev/lattice-estimator/estimator/sis_lattice.py", line 329, in __call__
    f(
  File "/home/lennart/dev/lattice-estimator/estimator/sis_lattice.py", line 232, in cost_zeta
    with local_minimum(
         ^^^^^^^^^^^^^^
  File "/home/lennart/dev/lattice-estimator/estimator/util.py", line 256, in __init__
    local_minimum_base.__init__(self, start, stop, smallerf, suppress_bounds_warning, log_level)
  File "/home/lennart/dev/lattice-estimator/estimator/util.py", line 97, in __init__
    raise ValueError(f"Incorrect bounds {start} > {stop}.")
ValueError: Incorrect bounds 20 > 10.
from estimator import *

# results in `TypeError: unsupported operand type(s) for *: 'NoneType' and 'int'`
params = SIS.Parameters(n=1, q=2^10000, length_bound=2^100, norm=oo)
est = SIS.lattice(params)
Traceback (most recent call last):
  File "/home/lennart/dev/lattice-estimator/test.sage.py", line 15, in <module>
    est = SIS.lattice(params)
          ^^^^^^^^^^^^^^^^^^^
  File "/home/lennart/dev/lattice-estimator/estimator/sis_lattice.py", line 329, in __call__
    f(
  File "/home/lennart/dev/lattice-estimator/estimator/sis_lattice.py", line 237, in cost_zeta
    for beta in it.neighborhood:
                ^^^^^^^^^^^^^^^
  File "/home/lennart/dev/lattice-estimator/estimator/util.py", line 273, in neighborhood
    start = max(start_bound, self.x - self._precision)
                             ^^^^^^
  File "/home/lennart/dev/lattice-estimator/estimator/util.py", line 264, in x
    return self._best.low * self._precision
           ~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~
TypeError: unsupported operand type(s) for *: 'NoneType' and 'int'
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant