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

Fixes in fpylll.algorithms.babai #274

Merged
merged 4 commits into from
Jun 6, 2024
Merged

Fixes in fpylll.algorithms.babai #274

merged 4 commits into from
Jun 6, 2024

Conversation

TheBlupper
Copy link
Contributor

This PR contains one fix and one improvement.

  • The fixed issue is that in fpylll.algorithms.babai, when the norm of the largest vector is calculated, ceil(A[-2].norm()) is used which casts the value to a double after which it is rounded. This is prone to large imprecision issues and when sufficiently large integers are used it may lead to issues with infinity. We instead opt for calculating the norm in Python and using math.isqrt which is precise.
  • Extra arguments and keyword arguments passed to babai will now also be passed onto LLL.reduction, which could be useful in some cases.

# zero vector at the end
A.swap_rows(0, B.nrows)

for j in range(B.ncols):
A[-1, j] = t[j]
A[-1, -1] = ceil(A[-2].norm())
# precise norm
A[-1, -1] = isqrt(sum(x**2 for x in A[-2])) + 1
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This would be wrong if the sqrt is an integer, no?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Technically yes, but it doesn't matter if it's too big only too small

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It should at least be documented lest future readers stumble over this

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

True, does this look better?

@malb malb merged commit 2d66121 into fplll:master Jun 6, 2024
37 checks passed
@malb
Copy link
Collaborator

malb commented Jun 6, 2024

Thanks!

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

Successfully merging this pull request may close these issues.

2 participants