1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48
|
# -*- coding: utf-8 -*-
"""
Test if Python BKZ classes can be instantiated and run.
"""
from copy import copy
from fpylll import IntegerMatrix
from fpylll.algorithms.simple_bkz import BKZReduction as SimpleBKZ
from fpylll.algorithms.simple_dbkz import DBKZReduction as SimpleDualBKZ
from fpylll.algorithms.bkz import BKZReduction as BKZ
from fpylll.algorithms.bkz2 import BKZReduction as BKZ2
from fpylll import BKZ as fplll_bkz
from fpylll.util import set_random_seed
dimensions = (31, 37)
def make_integer_matrix(n):
A = IntegerMatrix.random(n, "ntrulike", bits=30)
return A
def test_bkz_init():
for cls in (SimpleBKZ, SimpleDualBKZ, BKZ, BKZ2):
for n in dimensions:
set_random_seed(2**10 + n)
A = make_integer_matrix(n)
B = cls(copy(A))
del B
def test_simple_bkz_call(block_size=10):
for cls in (SimpleBKZ, SimpleDualBKZ):
for n in dimensions:
set_random_seed(n)
A = make_integer_matrix(n)
cls(A)(block_size=block_size)
def test_bkz_call(block_size=10):
params = fplll_bkz.Param(block_size=block_size, flags=fplll_bkz.VERBOSE|fplll_bkz.GH_BND)
for cls in (BKZ, BKZ2):
for n in dimensions:
set_random_seed(n)
A = make_integer_matrix(n)
B = copy(A)
cls(B)(params=params)
|