Conversation
…ation Add efficient large integer factorization using a polyalgorithm that combines perfect power detection, ECM (Elliptic Curve Method), and MPQS (Multiple Polynomial Quadratic Sieve with Self-Initialization). Key features: - ECM with Montgomery curves, Suyama parametrization, and batched GCD - SIQS with Gray code polynomial switching and incremental root updates - Double Large Prime variation with Pollard rho splitting - In-place GMP arithmetic to minimize BigInt allocations - Allocation-free sieve using unsafe_store!/unsafe_load
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #173 +/- ##
==========================================
- Coverage 93.08% 89.54% -3.55%
==========================================
Files 2 4 +2
Lines 463 1224 +761
==========================================
+ Hits 431 1096 +665
- Misses 32 128 +96 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
|
Can you separate the ECM from the quadratic sieve? The ECM code is a lot smaller and looks like it's in better shape, so I would like to review/merge that first. |
| """ | ||
| struct MontgomeryCurvePoint |
There was a problem hiding this comment.
The fact that this is GMP only is somewhat unfortunate. Ideally this code would work for BitIntegers.jl also... I'm willing to accept it though since BigInt is probably what most users are using in practice.
| should_widen = T <: BigInt || widemul(n - 1, n - 1) ≤ typemax(n) | ||
| p = should_widen ? pollardfactor(n) : pollardfactor(widen(n)) | ||
| # For large cofactors, use polyalgorithm dispatch (ECM → MPQS) | ||
| if n > big"100000000000000000000" # > 10^20 |
There was a problem hiding this comment.
is ECM slower than pollard for smaller numbers? That seems unexpected. Also, can you delete the polyalgorithm.jl file and move that code into here?
There was a problem hiding this comment.
Oh this is likely related to the ECM impl being BigInt only.
|
I don't think I can do better for code coverage. Here is what my AI agent is writing Any opinion? |
|
IMO the coverage is less important than code complexity. As such, I would prefer if this was split into separate PRs for ECM vs MPQS. I would also like for these methods (at least ECM) to not force BigInt since for smaller numbers, Int128 or Int256 (from BitIntegers) can be a lot faster. |
|
Ok I will try to tackle that tomorrow. |
Adds efficient large integer factorization via a polyalgorithm combining:
handles balanced semiprimes
Performance optimizations
unsafe_store!/unsafe_load in sieve inner loops to bypass bounds checkingBenchmarks (Apple Silicon, Julia 1.12)
Closes #159
Test plan
Tools being used: Github Spec Kit + Claude Opus 4.6
Methodology: Spec Driven Development with AI assistance