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

Primal Hybrid reports one more guessed weight than it should #138

Open
ElenaKirshanova opened this issue Jan 16, 2025 · 1 comment
Open

Comments

@ElenaKirshanova
Copy link
Contributor

ElenaKirshanova commented Jan 16, 2025

Hi,
this piece of code

        if zeta:
            # the number of non-zero entries
            h = params.Xs.hamming_weight
            probability = RR(prob_drop(params.n, h, zeta))
            hw = 1
            while hw < min(h, zeta):
                new_search_space = binomial(zeta, hw) * base**hw
                if svp_cost.repeat(ssf(search_space + new_search_space))["rop"] >= bkz_cost["rop"]:
                    break
                search_space += new_search_space
                probability += prob_drop(params.n, h, zeta, fail=hw)
                hw += 1

            svp_cost = svp_cost.repeat(ssf(search_space))

from https://github.com/malb/lattice-estimator/blob/374f07331e6575d1856b2212f3b8aeac96e0295e/estimator/lwe_primal.py#L406C9-L420C1
computes the weight of the guessed secret on zeta coordinates.

The search space computed within the while-loop corresponds to hw-1 where hw is the weight value at the end of the loop. As the result, hw stored in the returned dictionary ret["wt"] = hw should rather be hw-1.

@bencrts
Copy link
Collaborator

bencrts commented Jan 17, 2025

Hi @ElenaKirshanova -- thanks! I agree, I will do a quick PR to fix this :).

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

2 participants