From 190009443e77d1e296ca8d2f09d6c152221eab57 Mon Sep 17 00:00:00 2001 From: gilcu3 <828241+gilcu3@users.noreply.github.com> Date: Sun, 12 May 2024 19:22:44 +0200 Subject: [PATCH] more reasonable tests, remove leftover condition --- discretelog/linear_sieve_index_calculus.py | 6 +++--- tests/test_common.py | 2 +- tests/test_discretelog.py | 4 ++-- tests/test_linear_sieve_index_calculus.py | 10 +++++----- 4 files changed, 11 insertions(+), 11 deletions(-) diff --git a/discretelog/linear_sieve_index_calculus.py b/discretelog/linear_sieve_index_calculus.py index 4a9ac32..e4f7b84 100644 --- a/discretelog/linear_sieve_index_calculus.py +++ b/discretelog/linear_sieve_index_calculus.py @@ -389,7 +389,7 @@ def sieve_values(self, n, DEBUG=False): yield c2, c1, fn def sieve_values_parallel(self, n, DEBUG): - if True or (self.c2 + n) <= 1000 or cpu_count() <= 1: + if (self.c2 + n) <= 1000 or cpu_count() <= 1: yield from self.sieve_values(n, DEBUG) return rng = range(self.c2, self.c2 + n) @@ -463,7 +463,7 @@ def linear_sieve_dlog(p, gy, y, op=None, qlimit=None, climit=None, DEBUG=False): op = order(gy, p) assert isprime(op) assert (p - 1) % op == 0 - assert op >= 10 ** 5 + assert op >= 10 ** 6 assert order(gy, p) == op opq = op while (p - 1) % (opq * op) == 0: @@ -515,7 +515,7 @@ def linear_sieve_dlog(p, gy, y, op=None, qlimit=None, climit=None, DEBUG=False): if DEBUG: print('solution not converging, trying higher qlimit') return linear_sieve_dlog(p, gy, y, op, qlimit+50, climit, DEBUG) - nclimit = climit if first else max(50,climit//10) + nclimit = climit if first else max(50, climit // 10) if DEBUG: print(f'\nSolving: p={p} gy={gy} y={y} fbp={len(fbq)}', f'qlimit={qlimit}', diff --git a/tests/test_common.py b/tests/test_common.py index 67bf8c4..77b23e2 100644 --- a/tests/test_common.py +++ b/tests/test_common.py @@ -41,5 +41,5 @@ def test_factor_large(frandom): + Fore.RESET + '\n') for d in mrange(30, 100, 10, True): single_test_factor_random(d, frandom) - for d in mrange(30, 60, 10, True): + for d in mrange(30, 40, 1, True): single_test_factor_rsa(d, frandom) diff --git a/tests/test_discretelog.py b/tests/test_discretelog.py index 931c346..678a142 100644 --- a/tests/test_discretelog.py +++ b/tests/test_discretelog.py @@ -21,7 +21,7 @@ def single_test_random(nb, random): def test_dlog_small(frandom): - ntests = 200 + ntests = 1000 print('\n' + Fore.RED + 'Testing small values' + Fore.RESET + '\n') for nb in mrange(5, 30, 1, True): for _ in range(ntests): @@ -30,7 +30,7 @@ def test_dlog_small(frandom): def test_dlog_medium(frandom): print('\n' + Fore.RED + 'Testing medium values' + Fore.RESET + '\n') - for nb in mrange(30, 60, 2, True): + for nb in mrange(30, 60, 1, True): single_test_random(nb, frandom) diff --git a/tests/test_linear_sieve_index_calculus.py b/tests/test_linear_sieve_index_calculus.py index 2b62d1c..c63502d 100644 --- a/tests/test_linear_sieve_index_calculus.py +++ b/tests/test_linear_sieve_index_calculus.py @@ -66,25 +66,25 @@ def test_special(frandom): def test_linear_sieve_dlog_small(frandom): - ntests = 200 + ntests = 500 print('sophie germaine primes') - for psize in range(5, 9): + for psize in range(6, 9): print(f'psize={psize}') for _ in mrange(ntests, DEBUG=True): single_test(psize, frandom) def test_linear_sieve_dlog_medium(frandom): - ntests = 20 + ntests = 100 print('sophie germaine primes') for psize in range(9, 14): print(f'psize={psize}') for _ in mrange(ntests, DEBUG=True): single_test(psize, frandom) - ntests = 20 + ntests = 100 print('higher order') for _ in mrange(ntests, DEBUG=True): - higher_order_test(5, frandom) + higher_order_test(6, frandom) @pytest.mark.slow