-
Notifications
You must be signed in to change notification settings - Fork 29
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
galois.is_irreducible(poly) seems to return some false negatives in large odd exponent GFs #360
Comments
Hey George. Thanks for the report, as always! I do believe this is a bug. I can reproduce. In [1]: import galois
In [2]: f = galois.Poly.Degrees([233, 74, 0]); f
Out[2]: Poly(x^233 + x^74 + 1, GF(2))
In [3]: galois.is_irreducible(f)
Out[3]: False
In [4]: galois.factors(f)
Out[4]: ([Poly(x^233 + x^74 + 1, GF(2))], [1]) I believe the bug arises in cases when the polynomial degree is prime. I'll report back. |
Fixes #360. In certain circumstances a `np.int64` was returned from `Poly.degree`. When performing irreducibility checks and computing `q**m`, if either `q` or `m` wasn't an `int` the arithmetic could overflow and the irreducibility check became erroneous.
@geostergiop it turned out not to be an algorithm issue. Instead, the issue was a See #361 for more details. It will be merged into |
Ok, thanks Matt. Appreciate it. So long story short, should I re-run previous experiments that searched for irreducibles in the GF(2^256) or did those algorithms run correctly? I mean, did the I fear that maybe polynomials with prime numbers in |
I can't be certain, to be honest. Did you discover this bug after updating versions? I believe this bug was introduced recently. |
FWIW, I just ran this script against v0.0.23 (that I believe you said you used before) and the bug was not present. # test_2.py
import galois
f = galois.Poly.Degrees([233, 74, 0])
print(galois.is_irreducible(f))
#initial detection loop
for k in range(1, 233):
poly = galois.Poly.Degrees([233, k, 0])
if galois.is_irreducible(poly):
print("Found one: ", k, poly) In [1]: %run test_2.py
True
Found one: 74 Poly(x^233 + x^74 + 1, GF(2))
Found one: 159 Poly(x^233 + x^159 + 1, GF(2)) |
Indeed, I can confirm that v0.0.23 didn't have an issue, just iterated our generated irreducibles outputs from previous runs for prime exponents and they do exist, plenty of them, so I guess we are fine. |
And to be clear, I was incorrect about prime exponents. That wasn't the issue. The issue was large exponents (that were secretly Again, I appreciate the bug report! 🙏 |
Fixes #360. In certain circumstances a `np.int64` was returned from `Poly.degree`. When performing irreducibility checks and computing `q**m`, if either `q` or `m` wasn't an `int` the arithmetic could overflow and the irreducibility check became erroneous.
Yep sorry, bad reference! |
Hi Matt, hope all is well.
Even though it works fine for other groups (e.g. even groups likes GF(2^256) work well), still I 've been getting the following false negative result when using the galois.is_irreducible(poly) over odd groups tο produce irreducible polynomials over GF(2^233).
For example, we know from previous publications and research that x^233+x^74+1 is irreducible over GF(2) for creating the quotient ring of GF(2^233) but the following code returns Null for every polynomial (including the aforementioned one):
Care to share some thoughts?
The text was updated successfully, but these errors were encountered: