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

BDD / Hybrid-BDD speed improvement for FHE-sized parameters #97

Merged
merged 5 commits into from
Feb 6, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
35 changes: 30 additions & 5 deletions estimator/lwe_primal.py
Original file line number Diff line number Diff line change
Expand Up @@ -300,10 +300,20 @@ def gaussian_heuristic_log_input(r):

d = len(r)
r = [log(x) for x in r]
for i, _ in enumerate(r):
if gaussian_heuristic_log_input(r[i:]) < D.stddev**2 * (d - i):
return ZZ(d - (i - 1))
return ZZ(2)

if d > 4096:
for i, _ in enumerate(r):
# chosen since RC.ADPS16(1754, 1754).log(2.) = 512.168000000000
j = d - 1754 + i
if gaussian_heuristic_log_input(r[j:]) < D.stddev**2 * (d - j):
return ZZ(d - (j - 1))
return ZZ(2)

else:
for i, _ in enumerate(r):
if gaussian_heuristic_log_input(r[i:]) < D.stddev**2 * (d - i):
return ZZ(d - (i - 1))
return ZZ(2)

@staticmethod
@cached_function
Expand Down Expand Up @@ -588,8 +598,23 @@ def __call__(
log_level=log_level + 1,
)

def find_zeta_max(params, red_cost_model):
usvp_cost = primal_usvp(params, red_cost_model=red_cost_model)["rop"]
zeta_max = 1
while zeta_max < params.n:
# TODO: once support_size() is supported for NTRU, remove the below try/except
try:
if params.Xs.support_size(zeta_max) > usvp_cost:
# double it for mitm
return 2 * zeta_max
zeta_max +=1
except NotImplementedError:
return params.n
return params.n

if zeta is None:
with local_minimum(0, params.n, log_level=log_level) as it:
zeta_max = find_zeta_max(params, red_cost_model)
with local_minimum(0, min(zeta_max, params.n), log_level=log_level) as it:
for zeta in it:
it.update(
f(
Expand Down
Loading