Skip to content

Commit

Permalink
Use hamming weight instead of own computation
Browse files Browse the repository at this point in the history
  • Loading branch information
ludopulles committed Sep 25, 2024
1 parent 15d6547 commit 956f2ee
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 5 deletions.
2 changes: 1 addition & 1 deletion estimator/lwe_guess.py
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@ def sparse_solve(cls, f, params, log_level=5, **kwds):
:param params: LWE parameters.
"""
base = params.Xs.bounds[1] - params.Xs.bounds[0] # we exclude zero
h = ceil(len(params.Xs) * params.Xs.density) # nr of non-zero entries
h = params.Xs.hamming_weight

with local_minimum(0, params.n - 40, log_level=log_level) as it:
for zeta in it:
Expand Down
6 changes: 3 additions & 3 deletions estimator/lwe_parameters.py
Original file line number Diff line number Diff line change
Expand Up @@ -140,10 +140,10 @@ def switch_modulus(self):
LWEParameters(n=128, q=5289, Xs=D(σ=0.82), Xe=D(σ=3.08), m=+Infinity, tag=None)
"""
n = self.Xs.density * len(self.Xs)
h = self.Xs.hamming_weight

# n uniform in -(0.5,0.5) ± stddev(χ_s)
Xr_stddev = sqrt(n / 12) * self.Xs.stddev # rounding noise
# h uniform in -(0.5,0.5) ± stddev(χ_s)
Xr_stddev = sqrt(h / 12) * self.Xs.stddev # rounding noise
# χ_r == p/q ⋅ χ_e # we want the rounding noise match the scaled noise
p = ceil(Xr_stddev * self.q / self.Xe.stddev)

Expand Down
2 changes: 1 addition & 1 deletion estimator/lwe_primal.py
Original file line number Diff line number Diff line change
Expand Up @@ -390,7 +390,7 @@ def ssf(x):

if zeta:
# the number of non-zero entries
h = ceil(len(params.Xs) * params.Xs.density)
h = params.Xs.hamming_weight
probability = RR(prob_drop(params.n, h, zeta))
hw = 1
while hw < min(h, zeta):
Expand Down

0 comments on commit 956f2ee

Please sign in to comment.