From 4611b3b50e9de87e92ae0d2ce40b01977201ae29 Mon Sep 17 00:00:00 2001 From: Ludo Pulles Date: Thu, 19 Sep 2024 17:07:55 +0200 Subject: [PATCH] Fix CI --- estimator/lwe_dual.py | 4 +++- estimator/lwe_guess.py | 2 +- estimator/lwe_primal.py | 6 +++--- estimator/nd.py | 4 ++-- estimator/ntru_primal.py | 6 +++--- estimator/reduction.py | 4 ++-- estimator/util.py | 5 +++-- 7 files changed, 17 insertions(+), 14 deletions(-) diff --git a/estimator/lwe_dual.py b/estimator/lwe_dual.py index 0344f7f..f07e6c9 100644 --- a/estimator/lwe_dual.py +++ b/estimator/lwe_dual.py @@ -362,6 +362,8 @@ def __call__( EXAMPLES:: + >>> import warnings # https://github.com/sagemath/sage/issues/35473 + >>> warnings.filterwarnings("ignore", category=DeprecationWarning) >>> 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)) @@ -378,7 +380,7 @@ def __call__( >>> LWE.dual(params) rop: ≈2^103.4, mem: ≈2^63.9, m: 904, β: 251, d: 1928, ↻: 1, tag: dual >>> dual_hybrid(params) - rop: ≈2^92.1, mem: ≈2^78.2, m: 716, β: 170, d: 1464, ↻: 1989, ζ: 276, h1: 8, tag: dual_hybrid + rop: ≈2^91.6, mem: ≈2^77.2, m: 711, β: 168, d: 1456, ↻: ≈2^11.2, ζ: 279, h1: 8, tag: dual_hybrid >>> 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: ... diff --git a/estimator/lwe_guess.py b/estimator/lwe_guess.py index 6779ace..2a424c5 100644 --- a/estimator/lwe_guess.py +++ b/estimator/lwe_guess.py @@ -133,7 +133,7 @@ def __call__(self, params, log_level=5, **kwds): Compare:: >>> LWE.primal_hybrid(schemes.Kyber512.updated(Xs=ND.SparseTernary(512, 16))) - rop: ≈2^85.8, red: ≈2^84.8, svp: ≈2^84.8, β: 105, η: 2, ζ: 366, |S|: ≈2^85.1, d: 315, prob: ≈2^-23.4, ... + rop: ≈2^136.4, red: ≈2^136.3, svp: ≈2^131.1, β: 251, η: 2, ζ: 203, |S|: ≈2^152.6, d: 673, ... """ params = LWEParameters.normalize(params) diff --git a/estimator/lwe_primal.py b/estimator/lwe_primal.py index 0ae6a83..3e65940 100644 --- a/estimator/lwe_primal.py +++ b/estimator/lwe_primal.py @@ -557,13 +557,13 @@ def __call__( rop: ≈2^97.3, red: ≈2^96.3, svp: ≈2^96.3, β: 170, η: 142, ζ: 203, |S|: ≈2^16.3, d: 574, ... >>> LWE.primal_hybrid(schemes.Kyber512.updated(Xs=ND.SparseTernary(512, 16)), mitm = False, babai = True) - rop: ≈2^88.7, red: ≈2^88.0, svp: ≈2^87.2, β: 98, η: 2, ζ: 323, |S|: ≈2^39.7, d: 346, ... + rop: ≈2^102.4, red: ≈2^102.2, svp: ≈2^99.8, β: 216, η: 2, ζ: 203, |S|: ≈2^69.7, d: 632, prob: 0.002, ... >>> LWE.primal_hybrid(schemes.Kyber512.updated(Xs=ND.SparseTernary(512, 16)), mitm = True, babai = False) - rop: ≈2^74.1, red: ≈2^73.7, svp: ≈2^71.9, β: 104, η: 16, ζ: 320, |S|: ≈2^77.1, d: 359, ... + rop: ≈2^90.6, red: ≈2^89.7, svp: ≈2^89.6, β: 173, η: 138, ζ: 203, |S|: ≈2^36.4, d: 578, prob: 0.002, ... >>> LWE.primal_hybrid(schemes.Kyber512.updated(Xs=ND.SparseTernary(512, 16)), mitm = True, babai = True) - rop: ≈2^85.8, red: ≈2^84.8, svp: ≈2^84.8, β: 105, η: 2, ζ: 366, |S|: ≈2^85.1, d: 315, ... + rop: ≈2^136.4, red: ≈2^136.3, svp: ≈2^131.1, β: 251, η: 2, ζ: 203, |S|: ≈2^152.6, d: 673, ... TESTS: diff --git a/estimator/nd.py b/estimator/nd.py index ab195b3..09dbb55 100644 --- a/estimator/nd.py +++ b/estimator/nd.py @@ -338,10 +338,10 @@ def __hash__(self): EXAMPLE:: >>> from estimator import * - >>> hash(ND.Uniform(-10, 10)) == hash(("Uniform", 10, 10, None)) + >>> hash(ND.Uniform(-10, 10)) == hash(("Uniform", (-10, 10), None)) True """ - return hash(("Uniform", self.a, self.b, self.n)) + return hash(("Uniform", self.bounds, self.n)) def support_size(self, fraction=1.0): """ diff --git a/estimator/ntru_primal.py b/estimator/ntru_primal.py index 396fbf3..1ccb063 100644 --- a/estimator/ntru_primal.py +++ b/estimator/ntru_primal.py @@ -369,15 +369,15 @@ def __call__( >>> NTRU.primal_hybrid(schemes.NTRUHPS2048509Enc.updated(Xs=ND.SparseTernary(508,16)), ... mitm = False, babai = True) - rop: ≈2^88.0, red: ≈2^87.4, svp: ≈2^86.4, β: 98, η: 2, ζ: 318, |S|: ≈2^39.6, d: 328, prob: ≈2^-27.9, ... + rop: ≈2^101.6, red: ≈2^101.5, svp: ≈2^96.5, β: 205, η: 2, ζ: 197, |S|: ≈2^64.1, d: 596, prob: ≈2^-11.7, ... >>> NTRU.primal_hybrid(schemes.NTRUHPS2048509Enc.updated(Xs=ND.SparseTernary(508,16)), ... mitm = True, babai = False) - rop: ≈2^80.1, red: ≈2^79.7, svp: ≈2^78.3, β: 170, η: 22, ζ: 254, |S|: ≈2^103.7, d: 495, prob: 0.708, ... + rop: ≈2^89.6, red: ≈2^88.9, svp: ≈2^88.2, β: 172, η: 135, ζ: 197, |S|: ≈2^36.1, d: 555, prob: 0.003, ... >>> NTRU.primal_hybrid(schemes.NTRUHPS2048509Enc.updated(Xs=ND.SparseTernary(508,16)), ... mitm = True, babai = True) - rop: ≈2^85.1, red: ≈2^84.1, svp: ≈2^84.0, β: 105, η: 2, ζ: 363, |S|: ≈2^85.0, d: 294, prob: ≈2^-22.9, ... + rop: ≈2^134.5, red: ≈2^134.4, svp: ≈2^129.2, β: 248, η: 2, ζ: 197, |S|: ≈2^151.2, d: 645, ... TESTS: diff --git a/estimator/reduction.py b/estimator/reduction.py index 04ae761..d49a83b 100644 --- a/estimator/reduction.py +++ b/estimator/reduction.py @@ -515,8 +515,8 @@ def __call__(self, beta, d, B=None): >>> from sage.all import var, find_fit >>> dim = [100, 110, 120, 130, 140, 150, 160, 170, 180, 190, 200, 210, 220, 230, 240, 250] - >>> nodes = [39.0, 44.0, 49.0, 54.0, 60.0, 66.0, 72.0, 78.0, 84.0, 96.0, \ - 99.0, 105.0, 111.0, 120.0, 127.0, 134.0] + >>> nodes = [39.0, 44.0, 49.0, 54.0, 60.0, 66.0, 72.0, 78.0, 84.0, 96.0 ] + >>> nodes += [ 99.0, 105.0, 111.0, 120.0, 127.0, 134.0] # couldn't use \\ breaks stuff >>> times = [c + log(200,2).n() for c in nodes] >>> T = list(zip(dim, nodes)) >>> var("a,b,c,beta") diff --git a/estimator/util.py b/estimator/util.py index 3ecf34c..f726981 100644 --- a/estimator/util.py +++ b/estimator/util.py @@ -443,8 +443,9 @@ def batch_estimate(params, algorithm, jobs=1, log_level=0, catch_exceptions=True >>> from estimator import LWE >>> from estimator.schemes import Kyber512 - >>> _ = batch_estimate(Kyber512, [LWE.primal_usvp, LWE.primal_bdd]) - >>> _ = batch_estimate(Kyber512, [LWE.primal_usvp, LWE.primal_bdd], jobs=2) + >>> from estimator.util import batch_estimate + >>> _ = batch_estimate(Kyber512, [LWE.primal_usvp, LWE.primal_bdd], log_level=1) + >>> _ = batch_estimate(Kyber512, [LWE.primal_usvp, LWE.primal_bdd], jobs=2, log_level=1) """