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
Speed up factoring finite field multiplicative order #31686
Comments
Changed keywords from none to extension-field |
comment:2
This appears to work but obviously only addresses the simplest case:
|
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
comment:5
For the general case, you can try along the lines:
Note that for small degrees, it might slow down things, so it might be worth benchmarking first. |
This comment has been minimized.
This comment has been minimized.
comment:7
Could - F = Factorization([(P(p).factor(), m) for P, m in (x^d - 1).factor()]).expand()
+ F = Factorization([(cyclotomic_value(n, p).factor(), 1)
+ for n in d.divisors()]).expand() |
comment:8
EDIT: I wrongly thought that the program hangs at factoring To my mind it is a mistake that
|
comment:9
Another example where taking advantage of the cyclotomic factorization does succeed with the proposed fix
This is a very nice proposal! Coud you submit a branch? |
comment:10
Please open a ticket to allow Of course figuring out the prime and degree |
comment:11
Replying to @slel:
This is #31709 |
comment:12
Related:
|
comment:13
The attached branch achieves the proposed goal of the ticket, sage: p = 0x24000000000024000130e0000d7f70e4a803ca76f439266f443f9a5cda8a6c7be4a7a5fe8fadffd6a2a7e8c30006b9459ffffcd300000001
sage: F = GF(p^2, 'a')
sage: F.factored_unit_order()
(2^33 * 3^4 * 17 * 67 * 293 * 313 * 349 * 751
* 1997 * 2003 * 2671 * 19556633 * 738231097 * 44179799701097
* 1461985442088199434216480729118540833655826472878315075486478169293801719414121837587283877
* 55047696457335561580180364861378466840614260303507426009866606293225963076275651294902969015038913167956483928299,) sage: p = 1100585370631
sage: F = GF(p^24, 'a')
sage: F.factored_unit_order()
(2^6 * 3^2 * 5 * 7 * 11 * 13 * 17 * 53 * 97 * 229 * 337 * 421
* 3929 * 215417 * 249737 * 262519 * 397897 * 59825761 * 692192057
* 12506651939 * 37553789761 * 46950147799 * 172462808473 * 434045140817
* 81866093016401 * 617237859576697 * 659156729361017707
* 268083135725348991493995910983015600019336657
* 90433843562394341719266736354746485652016132372842876085423636587989263202299569913,) Finding a pseudo-Conway polynomial still takes longer sage: p = 1100585370631
sage: %time F = GF(p^24, 'a')
CPU times: user 120 ms, sys: 12.3 ms, total: 132 ms
Wall time: 170 ms
sage: %time F = GF(p^24)
CPU times: user 1.76 s, sys: 303 ms, total: 2.07 s
Wall time: 2.46 s sage: p = 0x24000000000024000130e0000d7f70e4a803ca76f439266f443f9a5cda8a6c7be4a7a5fe8fadffd6a2a7e8c30006b9459ffffcd300000001
sage: %time F = GF(p^2, 'a')
CPU times: user 1.94 s, sys: 9.62 ms, total: 1.95 s
Wall time: 2.05 s
sage: %time F = GF(p^2)
CPU times: user 14.7 s, sys: 49.9 ms, total: 14.8 s
Wall time: 17.7 s Please review. New commits:
|
Author: Samuel Lelièvre |
Branch: public/31686 |
Commit: |
comment:14
Some questions and thoughts. I added a doctest in a I decided to only include a quick one, to keep Optionally, the example from #31434 and the first Maybe Flint, NTL, PARI, ... have code we could use Should |
comment:15
Replying to @slel:
I think this is a good habit.
If it does not exceed a couple of seconds, why not.
For PARI/GP https://pari.math.u-bordeaux.fr/dochtml/html/Arithmetic_functions.html#se:ffprimroot
I would say yes if it makes a difference in timings. |
comment:16
The other suggestion that I'd add is to use |
comment:18
I did not notice any significant speed up by short cutting |
Reviewer: Vincent Delecroix |
comment:19
Please @daira add your full name in the author field. |
Changed author from Samuel Lelièvre to Daira Hopwood, Samuel Lelièvre |
comment:21
(from https://github.com/daira) |
This comment has been minimized.
This comment has been minimized.
comment:23
Yes that's my name. Thankyou all for being so responsive to this ticket! :-) |
Changed branch from public/31686 to |
Initially asked at
There seems to be a unnecessary performance problem with constructing large extension fields:
This hangs trying to factor the 891-bit integer p2 - 1, which is longer than the longest solved RSA Challenge number. (As it happens, the hard part of this factorization is a 675-bit integer which is still impractical.)
It is not unreasonable that constructing the extension field requires knowing the factorization of the multiplicative order. (You can get around this by constructing it with a specific modulus, but then many operations, e.g. taking roots, require this factorization anyway.)
However, we know that p2 - 1 splits as (p-1)(p+1), and factoring those may be much more feasible:
(this takes less than a second on my desktop).
In general, computing the multiplicative order of an extension field should take advantage of the factorization of pk - 1 as a polynomial. There might also be other cases where we know the factorization by construction, and should be able to provide it.
CC: @slel
Component: finite rings
Keywords: extension-field
Author: Daira Hopwood, Samuel Lelièvre
Branch/Commit:
8704bb9
Reviewer: Vincent Delecroix
Issue created by migration from https://trac.sagemath.org/ticket/31686
The text was updated successfully, but these errors were encountered: