Skip to content

Commit

Permalink
Blazingly fast optimization by filtering primes with kronecker symbol
Browse files Browse the repository at this point in the history
  • Loading branch information
JosePisco committed Aug 15, 2024
1 parent 0866d00 commit 2e7c01c
Showing 1 changed file with 13 additions and 5 deletions.
18 changes: 13 additions & 5 deletions src/sage/schemes/elliptic_curves/ell_finite_field.py
Original file line number Diff line number Diff line change
Expand Up @@ -2803,10 +2803,17 @@ def EllipticCurve_with_prime_order(N):
sage: E.order() == N
True
The execution time largely depends on the input::
It works for large primes::
sage: N = 125577861263605878504082476745517446213
sage: E = EllipticCurve_with_prime_order(N) # Takes ~1 second.
sage: N = 0x6cbc824032974516623e732462f4b74b56c4ffbd984380d9
sage: E = EllipticCurve_with_prime_order(N)
sage: E.order() == N
True
But the execution time largely depends on the input::
sage: N = 200396817641911230625970463749415493753
sage: E = EllipticCurve_with_prime_order(N)
sage: E.order() == N
True
Expand Down Expand Up @@ -2852,7 +2859,7 @@ def EllipticCurve_with_prime_order(N):
ALGORITHM: [BS2007]_, Algorithm 2.2
"""
from sage.arith.misc import is_prime
from sage.arith.misc import is_prime, kronecker
from sage.combinat.subset import powerset
from sage.functions.other import ceil
from sage.misc.functional import symbolic_prod as product, log
Expand All @@ -2874,7 +2881,8 @@ def EllipticCurve_with_prime_order(N):

while True:
# Iterating over the odd primes by chunks of size log(`N`).
S.extend(prime_range(prime_start, prime_end))
S.extend(p for p in prime_range(prime_start, prime_end)
if kronecker(N, p) == 1)

# Every possible products of distinct elements of `S`.
# There probably is a more optimal way to compute all possible products
Expand Down

0 comments on commit 2e7c01c

Please sign in to comment.