def __init__(self, A, tuners=None, recycle=True): """Construct a new instance of the BKZ algorithm. :param A: an integer matrix, a GSO object or an LLL object """ self.recycle = recycle if isinstance(A, LLL.Reduction): L, M, B = A, A.M, A.M.B elif isinstance(A, GSO.Mat): L, M, B = None, A, A.B elif isinstance(A, IntegerMatrix): L, M, B = None, None, A else: raise TypeError( "type of A must be in {IntegerMatrix, GSO.Mat, LLL.Reduction}, but got type '%s'" % type(A)) if M is None and L is None: wrapper = LLL.Wrapper(B) wrapper() if M is None: M = GSO.Mat(B, flags=GSO.ROW_EXPO) if L is None: L = LLL.Reduction(M, flags=LLL.DEFAULT) self.lll_obj, self.M, self.A = L, M, B self.lll_obj() if tuners is None: self.tuners = [Tuner(b) for b in range(YOLO_MAX_BLOCK_SIZE)] else: self.tuners = tuners self.tracer = BKZTreeTracer(self, verbosity=True)
def __init__(self, A): """Construct a new instance of the BKZ algorithm. :param A: an integer matrix, a GSO object or an LLL object """ if isinstance(A, GSO.Mat): L = None M = A A = M.B elif isinstance(A, LLL.Reduction): L = A M = L.M A = M.B elif isinstance(A, IntegerMatrix): L = None M = None A = A else: raise TypeError("Matrix must be IntegerMatrix but got type '%s'"%type(A)) if M is None and L is None: # run LLL first, but only if a matrix was passed wrapper = LLL.Wrapper(A) wrapper() self.A = A if M is None: self.M = GSO.Mat(A, flags=GSO.ROW_EXPO) else: self.M = M if L is None: self.lll_obj = LLL.Reduction(self.M, flags=LLL.DEFAULT) else: self.lll_obj = L
def __init__(self, A): """Construct a new BKZ reduction instance. :param A: Integer matrix to reduce. """ if not isinstance(A, IntegerMatrix): raise TypeError("Matrix must be IntegerMatrix but got type '%s'" % type(A)) # run LLL first wrapper = LLL.Wrapper(A) wrapper() self.A = A self.m = GSO.Mat(A, flags=GSO.ROW_EXPO) self.lll_obj = LLL.Reduction(self.m)