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

math.log domain error #128

Open
bencrts opened this issue Sep 24, 2024 · 4 comments · May be fixed by #129
Open

math.log domain error #128

bencrts opened this issue Sep 24, 2024 · 4 comments · May be fixed by #129

Comments

@bencrts
Copy link
Collaborator

bencrts commented Sep 24, 2024

For the following params:

param = LWE.Parameters(
     n = 2**17, #32768
     q = 2**(3522),
     Xs = ND.Uniform(-1, 1),
     Xe = ND.DiscreteGaussian(3.19),
     m = oo
)

est = LWE.primal_bdd(param, red_cost_model = RC.MATZOV)

there is an error thrown by math.log():

[...]
~/Desktop/TBA/Github/lattice-estimator/estimator/lwe_primal.py in svp_dimension(cls, r, D)
    300
    301         d = len(r)
--> 302         r = [log(x) for x in r]
    303
    304         if d > 4096:

~/Desktop/TBA/Github/lattice-estimator/estimator/lwe_primal.py in <listcomp>(.0)
    300
    301         d = len(r)
--> 302         r = [log(x) for x in r]
    303
    304         if d > 4096:

ValueError: math domain error

this is caused by the math.log() function throwing a domain error for very small inputs.

@bencrts bencrts linked a pull request Sep 24, 2024 that will close this issue
@ludopulles
Copy link
Contributor

Alternatively, you might be able to avoid this error and speedup the code if the simulator outputs log(GS norm) instead.

GSA, ZGSA and LGSA internally model the log-norms base 2, e, 2 respectively.
However, CN11 takes the GS-norms from fplll, so if that is causing the issue, this doesn't help.

@ludopulles
Copy link
Contributor

It seems that the simulator from FPyLLL uses log_2(GS-norms) to simulate the profile. Perhaps it's easiest here, if you add a log2_simulator function to the FPyLLL code, and let simulator call the log2_simulator, while the lattice-estimator then directly calls the log2_simulator?

If you roll out your custom simulator in the lattice-estimator, this gives redundancy (although the FPyLLL code hasn't changed a lot the last years).

@malb
Copy link
Owner

malb commented Oct 9, 2024

I like this solution.

@bencrts
Copy link
Collaborator Author

bencrts commented Oct 9, 2024

I'll give it a shot and report back here :) thanks for the suggestions/discussion!

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

Successfully merging a pull request may close this issue.

3 participants