Skip to content

Commit

Permalink
cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
malb committed Feb 25, 2024
1 parent 46b2f03 commit 7354e88
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 14 deletions.
7 changes: 4 additions & 3 deletions estimator/lwe.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,8 @@
from .lwe_primal import primal_usvp, primal_bdd, primal_hybrid
from .lwe_bkw import coded_bkw
from .lwe_guess import exhaustive_search, mitm, distinguish, guess_composition # noqa
from .lwe_dual import dual, matzov
from .lwe_dual import dual
from .lwe_dual import matzov as dual_hybrid
from .gb import arora_gb # noqa
from .lwe_parameters import LWEParameters as Parameters # noqa
from .conf import (
Expand Down Expand Up @@ -53,7 +54,7 @@ def rough(self, params, jobs=1, catch_exceptions=True):
algorithms = {}

algorithms["usvp"] = partial(primal_usvp, red_cost_model=RC.ADPS16, red_shape_model="gsa")
algorithms["dual_hybrid"] = partial(matzov, red_cost_model=RC.ADPS16)
algorithms["dual_hybrid"] = partial(dual_hybrid, red_cost_model=RC.ADPS16)

if params.m > params.n**2 and params.Xe.is_bounded:
if params.Xs.is_sparse:
Expand Down Expand Up @@ -142,7 +143,7 @@ def __call__(
red_shape_model=red_shape_model,
)
algorithms["dual"] = partial(dual, red_cost_model=red_cost_model)
algorithms["dual_hybrid"] = partial(matzov, red_cost_model=red_cost_model)
algorithms["dual_hybrid"] = partial(dual_hybrid, red_cost_model=red_cost_model)

algorithms = {k: v for k, v in algorithms.items() if k not in deny_list}
algorithms.update(add_list)
Expand Down
23 changes: 12 additions & 11 deletions estimator/lwe_dual.py
Original file line number Diff line number Diff line change
Expand Up @@ -366,47 +366,48 @@ def __call__(
EXAMPLES::
>>> from estimator import *
>>> from estimator.lwe_dual import dual_hybrid
>>> params = LWE.Parameters(n=1024, q = 2**32, Xs=ND.Uniform(0,1), Xe=ND.DiscreteGaussian(3.0))
>>> LWE.dual(params)
rop: ≈2^107.0, mem: ≈2^66.4, m: 970, β: 264, d: 1994, ↻: 1, tag: dual
>>> LWE.dual_hybrid(params)
>>> dual_hybrid(params)
rop: ≈2^103.2, mem: ≈2^97.4, m: 937, β: 250, d: 1919, ↻: 1, ζ: 42, tag: dual_hybrid
>>> LWE.dual_hybrid(params, mitm_optimization=True)
>>> dual_hybrid(params, mitm_optimization=True)
rop: ≈2^130.1, mem: ≈2^127.0, m: 1144, k: 120, ↻: 1, β: 347, d: 2024, ζ: 144, tag: dual_mitm_hybrid
>>> LWE.dual_hybrid(params, mitm_optimization="numerical")
>>> dual_hybrid(params, mitm_optimization="numerical")
rop: ≈2^129.0, m: 1145, k: 1, mem: ≈2^131.0, ↻: 1, β: 346, d: 2044, ζ: 125, tag: dual_mitm_hybrid
>>> params = params.updated(Xs=ND.SparseTernary(params.n, 32))
>>> LWE.dual(params)
rop: ≈2^103.4, mem: ≈2^63.9, m: 904, β: 251, d: 1928, ↻: 1, tag: dual
>>> LWE.dual_hybrid(params)
>>> dual_hybrid(params)
rop: ≈2^92.1, mem: ≈2^78.2, m: 716, β: 170, d: 1464, ↻: 1989, ζ: 276, h1: 8, tag: dual_hybrid
>>> LWE.dual_hybrid(params, mitm_optimization=True)
>>> dual_hybrid(params, mitm_optimization=True)
rop: ≈2^98.2, mem: ≈2^78.6, m: 728, k: 292, ↻: ≈2^18.7, β: 180, d: 1267, ζ: 485, h1: 17, tag: ...
>>> params = params.updated(Xs=ND.CenteredBinomial(8))
>>> LWE.dual(params)
rop: ≈2^114.5, mem: ≈2^71.8, m: 1103, β: 291, d: 2127, ↻: 1, tag: dual
>>> LWE.dual_hybrid(params)
>>> dual_hybrid(params)
rop: ≈2^113.6, mem: ≈2^103.5, m: 1096, β: 288, d: 2110, ↻: 1, ζ: 10, tag: dual_hybrid
>>> LWE.dual_hybrid(params, mitm_optimization=True)
>>> dual_hybrid(params, mitm_optimization=True)
rop: ≈2^155.5, mem: ≈2^146.2, m: 1414, k: 34, ↻: 1, β: 438, d: 2404, ζ: 34, tag: dual_mitm_hybrid
>>> params = params.updated(Xs=ND.DiscreteGaussian(3.0))
>>> LWE.dual(params)
rop: ≈2^116.5, mem: ≈2^73.2, m: 1140, β: 298, d: 2164, ↻: 1, tag: dual
>>> LWE.dual_hybrid(params)
>>> dual_hybrid(params)
rop: ≈2^116.2, mem: ≈2^100.4, m: 1137, β: 297, d: 2155, ↻: 1, ζ: 6, tag: dual_hybrid
>>> LWE.dual_hybrid(params, mitm_optimization=True)
>>> dual_hybrid(params, mitm_optimization=True)
rop: ≈2^160.7, mem: ≈2^156.8, m: 1473, k: 25, ↻: 1, β: 456, d: 2472, ζ: 25, tag: dual_mitm_hybrid
>>> LWE.dual_hybrid(schemes.NTRUHPS2048509Enc)
>>> dual_hybrid(schemes.NTRUHPS2048509Enc)
rop: ≈2^131.7, mem: ≈2^128.5, m: 436, β: 358, d: 906, ↻: 1, ζ: 38, tag: dual_hybrid
>>> LWE.dual(schemes.CHHS_4096_67)
rop: ≈2^206.9, mem: ≈2^137.5, m: ≈2^11.8, β: 616, d: 7779, ↻: 1, tag: dual
>>> LWE.dual_hybrid(schemes.Kyber512, red_cost_model=RC.GJ21, fft=True)
>>> dual_hybrid(schemes.Kyber512, red_cost_model=RC.GJ21, fft=True)
rop: ≈2^149.8, mem: ≈2^92.1, m: 510, t: 76, β: 399, d: 1000, ↻: 1, ζ: 22, tag: dual_hybrid
"""
Expand Down

0 comments on commit 7354e88

Please sign in to comment.