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

add lenstra eliptic curve factoring #104

Open
wants to merge 3 commits into
base: main
Choose a base branch
from

Conversation

oscardssmith
Copy link
Member

heavily inspired by @trizen, but refactored a little to make it more reliable.

@oscardssmith
Copy link
Member Author

some benchmarks:

x = prod(nextprime(big(2)^30, i) for i in 1:2)
@time Primes.pollardfactors!(x, Dict{BigInt,Int}())
  0.028354 seconds (1.13 M allocations: 22.163 MiB)
@time lenstrafactors!(x, Dict{BigInt,Int}())
  0.110741 seconds (1.65 M allocations: 30.821 MiB, 26.82% gc time)

x = prod(nextprime(big(2)^30, i) for i in 1:20)
@time Primes.pollardfactors!(x, Dict{BigInt,Int}());
  0.830832 seconds (14.86 M allocations: 346.059 MiB, 21.69% gc time)
@time lenstrafactors!(x, Dict{BigInt,Int}());
  0.375128 seconds (3.62 M allocations: 114.038 MiB, 11.86% gc time)

x = prod(nextprime(big(2)^50, i) for i in 1:2)
@time lenstrafactors!(x, Dict{BigInt,Int}())
 18.921172 seconds (296.05 M allocations: 6.041 GiB, 14.56% gc time)
@time Primes.pollardfactors!(x, Dict{BigInt,Int}())
  56.697309 seconds (1.12 G allocations: 21.651 GiB, 20.29% gc time)

These are the bad cases for ecm (when all the factors are of similar size). That said, ecm tends to do a bunch better for larger inputs, and for numbers with a few smaller factors. This implementation is not especially optimized, but I think it is a good baseline for future improvements.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant