Skip to content

Commit

Permalink
ntru.py: updated doctests. Changed *_parameters.homogeneous to _homog…
Browse files Browse the repository at this point in the history
…eneous

Doctests were changed in accordance with the updated homogeneity checks. Previously,
the +1 on line 261 of lwe_primal.py was removed, with the assumption that a homogeneous
instance would not need the additional dimension. This was a mistake, and improperly
gimping the dimension optimization functionality for homogeneous instances. This
commit rectifies this mistake by updating the doctests to be in line with the more
efficient implementation.
  • Loading branch information
hkippen-SBAQ committed Nov 1, 2023
1 parent 0dcafdc commit e5627ea
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 12 deletions.
2 changes: 1 addition & 1 deletion estimator/lwe_parameters.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ def __post_init__(self, **kwds):
self.Xe.n = self.m

@property
def homogeneous(self):
def _homogeneous(self):
return False

def normalize(self):
Expand Down
6 changes: 3 additions & 3 deletions estimator/lwe_primal.py
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@ def cost_gsa(
m = min(2 * ceil(sqrt(params.n * log(params.q) / log(delta))), m)
tau = params.Xe.stddev if tau is None else tau
# Account for homogeneous instances
if params.homogeneous:
if params._homogeneous:
tau = False # Tau false ==> instance is homogeneous

d = PrimalUSVP._solve_for_d(params, m, beta, tau, xi) if d is None else d
Expand Down Expand Up @@ -139,7 +139,7 @@ def cost_simulator(
xi = PrimalUSVP._xi_factor(params.Xs, params.Xe)
tau = params.Xe.stddev if tau is None else tau

if params.homogeneous:
if params._homogeneous:
tau = False
d -= 1 # Remove extra dimension in homogeneous instances

Expand Down Expand Up @@ -344,7 +344,7 @@ def cost(
# 1. Simulate BKZ-β
# TODO: pick τ as non default value

if params.homogeneous:
if params._homogeneous:
tau = False
d -= 1

Expand Down
14 changes: 7 additions & 7 deletions estimator/ntru.py
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ def rough(self, params, jobs=1, catch_exceptions=True):
>>> from estimator import *
>>> _ = NTRU.estimate.rough(schemes.NTRUHPS2048509Enc)
usvp :: rop: ≈2^112.1, red: ≈2^112.1, δ: 1.004096, β: 384, d: 633, tag: usvp
usvp :: rop: ≈2^109.2, red: ≈2^109.2, δ: 1.004171, β: 374, d: 643, tag: usvp
"""
params = params.normalize()
Expand Down Expand Up @@ -106,17 +106,17 @@ def __call__(
>>> from estimator import *
>>> _ = NTRU.estimate(schemes.NTRUHPS2048509Enc)
usvp :: rop: ≈2^134.5, red: ≈2^134.5, δ: 1.004179, β: 373, d: 923, tag: usvp
bdd :: rop: ≈2^131.1, red: ≈2^130.1, svp: ≈2^130.2, β: 357, η: 390, d: 916, tag: bdd
bdd_hybrid :: rop: ≈2^131.2, red: ≈2^130.2, svp: ≈2^130.2, β: 357, η: 390, ζ: 0, |S|: 1, ...
bdd_mitm_hybrid :: rop: ≈2^185.9, red: ≈2^185.1, svp: ≈2^184.7, β: 371, η: 2, ζ: 159, ...
bdd :: rop: ≈2^130.9, red: ≈2^129.9, svp: ≈2^129.9, β: 356, η: 389, d: 917, tag: bdd
bdd_hybrid :: rop: ≈2^130.9, red: ≈2^129.9, svp: ≈2^129.9, β: 356, η: 389, ζ: 0, |S|: 1, ...
bdd_mitm_hybrid :: rop: ≈2^185.3, red: ≈2^184.5, svp: ≈2^184.2, β: 371, η: 2, ζ: 159, |S|: ≈2^228.0...
>>> params = NTRU.Parameters(n=113, q=512, Xs=ND.UniformMod(3), Xe=ND.UniformMod(3))
>>> _ = NTRU.estimate(params)
usvp :: rop: ≈2^46.0, red: ≈2^46.0, δ: 1.011516, β: 59, d: 221, tag: usvp
dsd :: rop: ≈2^37.9, red: ≈2^37.9, δ: 1.013310, β: 31, d: 226, tag: dsd
bdd :: rop: ≈2^42.8, red: ≈2^41.0, svp: ≈2^42.3, β: 41, η: 72, d: 227, tag: bdd
bdd_hybrid :: rop: ≈2^42.8, red: ≈2^41.0, svp: ≈2^42.3, β: 41, η: 72, ζ: 0, |S|: 1, d: 227, ...
bdd_mitm_hybrid :: rop: ≈2^56.1, red: ≈2^55.2, svp: ≈2^55.0, β: 41, η: 2, ζ: 32, |S|: ≈2^50.7, ...
bdd :: rop: ≈2^42.4, red: ≈2^41.0, svp: ≈2^41.8, β: 41, η: 70, d: 225, tag: bdd
bdd_hybrid :: rop: ≈2^42.4, red: ≈2^41.0, svp: ≈2^41.8, β: 41, η: 70, ζ: 0, |S|: 1, d: 226, ...
bdd_mitm_hybrid :: rop: ≈2^55.6, red: ≈2^54.7, svp: ≈2^54.6, β: 41, η: 2, ζ: 32, |S|: ≈2^50.7, ...
"""
params = params.normalize()

Expand Down
2 changes: 1 addition & 1 deletion estimator/ntru_parameters.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ def possibly_overstretched(self):
return False

@property
def homogeneous(self):
def _homogeneous(self):
return True

def normalize(self):
Expand Down

0 comments on commit e5627ea

Please sign in to comment.