Skip to content

Implement algorithm=generic_small and algorithm=hybrid for elliptic curve points #40223

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

Open
wants to merge 4 commits into
base: develop
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 25 additions & 1 deletion src/sage/groups/generic.py
Original file line number Diff line number Diff line change
Expand Up @@ -451,6 +451,15 @@ def bsgs(a, b, bounds, operation='*', identity=None, inverse=None, op=None):
AUTHOR:

- John Cremona (2008-03-15)

TESTS:

Ensures Python integers work::

sage: from sage.groups.generic import bsgs
sage: b = Mod(2,37); a = b^20
sage: bsgs(b, a, (0r, 36r))
20
"""
Z = integer_ring.ZZ

Expand All @@ -470,6 +479,8 @@ def bsgs(a, b, bounds, operation='*', identity=None, inverse=None, op=None):
raise ValueError("identity, inverse and operation must be given")

lb, ub = bounds
lb = Z(lb)
ub = Z(ub)
if lb < 0 or ub < lb:
raise ValueError("bsgs() requires 0<=lb<=ub")

Expand Down Expand Up @@ -1378,7 +1389,9 @@ def order_from_bounds(P, bounds, d=None, operation='+',
- ``P`` -- a Sage object which is a group element

- ``bounds`` -- a 2-tuple ``(lb,ub)`` such that ``m*P=0`` (or
``P**m=1``) for some ``m`` with ``lb<=m<=ub``
``P**m=1``) for some ``m`` with ``lb<=m<=ub``. If ``None``,
gradually increasing bounds will be tried (might loop infinitely
if the element has no torsion).

- ``d`` -- (optional) a positive integer; only ``m`` which are
multiples of this will be considered
Expand Down Expand Up @@ -1407,6 +1420,8 @@ def order_from_bounds(P, bounds, d=None, operation='+',
sage: b = a^4
sage: order_from_bounds(b, (5^4, 5^5), operation='*')
781
sage: order_from_bounds(b, None, operation='*')
781

sage: # needs sage.rings.finite_rings sage.schemes
sage: E = EllipticCurve(k, [2,4])
Expand All @@ -1424,6 +1439,15 @@ def order_from_bounds(P, bounds, d=None, operation='+',
sage: order_from_bounds(w, (200, 250), operation='*')
23
"""
if bounds is None:
lb = 1
ub = 256
while True:
try:
return order_from_bounds(P, (lb, ub), d, operation, identity, inverse, op)
except ValueError:
lb = ub + 1
ub *= 16
from operator import mul, add

if operation in multiplication_names:
Expand Down
Loading
Loading