-
Notifications
You must be signed in to change notification settings - Fork 18k
math/big: infinite loop in Int.ModSqrt for p = 1 #51747
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
Comments
It does indeed go into an infinite loop. Thanks for reporting. The method's documentation says
and 1 is not a prime, but going into an infinite loop is still not the best way to handle an invalid parameter. |
cc @griesemer @FiloSottile as per owners. |
Change https://go.dev/cl/394077 mentions this issue: |
Other examples of causing infinite loop in Int.ModSqrt:
|
Change https://go.dev/cl/402457 mentions this issue: |
Rolling forward to 1.20. |
@rolandshoemaker There's a pending CL. Should this move to 1.23? |
I think we can probably move this to backlog for now, it is unclear if we want to fix this with the particular method in the CL, and it's a relatively low priority problem. |
Hi,
I am working on an alternative using AKS, by implementing an IsPrime() function, but the proposed change above might be an acceptable solution. Please let me know if a deterministic solution is of interest. This would eliminate any edge case that could come from using a probabilistic method to test if p is prime. |
When passing p=1 in ModSqrt function, the code goes in infinite loop:
go/src/math/big/int.go
Line 940 in 3463852
The Jacobi symbol will gives one for ever.
For example: https://go.dev/play/p/37ExZ6Y-Hdp
The text was updated successfully, but these errors were encountered: