Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

BKZ Reduction RuntimeError Aborted #287

Open
WZHYX opened this issue Dec 10, 2024 · 1 comment
Open

BKZ Reduction RuntimeError Aborted #287

WZHYX opened this issue Dec 10, 2024 · 1 comment

Comments

@WZHYX
Copy link

WZHYX commented Dec 10, 2024

When I utilise the BKZ algorithm on a basis as shown in the code below, I will receive a runtime error. The error message produced is very vague and I am not able to solve the issue

Edit: After running the code again, I got another error that states "infinite loop in babai". Where does this error originate from?

Code

def small_poly_vector(size, high=2, low=-1):
    v = [R(list(np.random.randint(low, high, N))) for _ in range(size)]
    if size==1:
        return v[0]
    return vector(v)

Q = 3329
N = 64
k = 2
eta1 = 2
eta2 = 2

HALF_Q = int((Q + 1) / 2)
PR.<x> = PolynomialRing(GF(Q))
R.<z> = PR.quotient_ring(x^N + 1)

A = random_matrix(R, k, k)
s = small_poly_vector(k, eta1)
e = small_poly_vector(k, eta2)
t = A*s+e

A_t = matrix(QQ, 2*N+1, 2*N)
A_t[:N,:N] = A[0][0].matrix()
A_t[N:2*N,:N] = A[0][1].matrix()
A_t[:N,N:] = A[1][0].matrix()
A_t[N:2*N,N:] = A[1][1].matrix()
A_t[2*N] = [int(i) for i in t[0]]+[int(i) for i in t[1]]

lattice_size = 4*N+1
B = matrix(QQ, lattice_size, lattice_size)
B[:2*N,:2*N] = Q * identity_matrix(QQ, 2*N, 2*N)
B[2*N:,:2*N] = A_t
B[2*N:,2*N:] = identity_matrix(QQ, 2*N+1, 2*N+1)

B = IntegerMatrix.from_matrix([[int(entry) for entry in row] for row in B])
BKZ.reduction(B, o=BKZ.Param(block_size=20))
reduced_matrix = [[B[i, j] for j in range(B.ncols)] for i in range(B.nrows)]
shortest_vector = reduced_matrix[0]

Error message
image

@dimpase
Copy link

dimpase commented Dec 12, 2024

It might be insufficient precision of floats used by default. Cf.

sage: BKZ.reduction(B, o=BKZ.Param(block_size=10),float_type="mpfr", precision=53)
terminate called recursively
  • which is the error you get, but
sage: BKZ.reduction(B, o=BKZ.Param(block_size=10),float_type="mpfr", precision=70)

doesn't terminate quickly (I didn't wait for it to finish)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants