Skip to content

Commit

Permalink
Trac sagemath#34716: fix assertion failure in _discrete_log_pgroup() …
Browse files Browse the repository at this point in the history
…when group is trivial

As of Sage 9.7, this causes an assertion failure:

{{{#!sage
sage: E = EllipticCurve(GF(487^2), [311,205])
sage: G = E.abelian_group().torsion_subgroup(42)
sage: P, Q = G.torsion_subgroup(6).gens()
sage: G.discrete_log(2*P + 3*Q, [P, Q])
}}}

The reason is that the `p`-power part of the group generated by `P` and
`Q` is trivial for some prime(s) `p` dividing the group order of `G`,
which throws off `_discrete_log_pgroup()`. Easy fix.

URL: https://trac.sagemath.org/34716
Reported by: lorenz
Ticket author(s): Lorenz Panny
Reviewer(s): Kwankyu Lee
  • Loading branch information
Release Manager committed Nov 15, 2022
2 parents 5097749 + 93dc05c commit 4edaafe
Showing 1 changed file with 16 additions and 1 deletion.
17 changes: 16 additions & 1 deletion src/sage/groups/additive_abelian/additive_abelian_wrapper.py
Original file line number Diff line number Diff line change
Expand Up @@ -371,6 +371,9 @@ def discrete_log(self, x, gens=None):
y = cofactor * x

pvals = [o.valuation(p) for o in ords]
if not any(pvals):
continue

plog = _discrete_log_pgroup(p, pvals, pgens, y)

for i, (r, v) in enumerate(zip(plog, pvals)):
Expand Down Expand Up @@ -472,7 +475,7 @@ def _element_constructor_(self, x, check=False):
def _discrete_log_pgroup(p, vals, aa, b):
r"""
Attempt to express an element of p-power order in terms of
generators of a p-subgroup of this group.
generators of a nontrivial p-subgroup of this group.
Used as a subroutine in :meth:`discrete_log`.
Expand All @@ -491,6 +494,18 @@ def _discrete_log_pgroup(p, vals, aa, b):
sage: from sage.groups.additive_abelian.additive_abelian_wrapper import _discrete_log_pgroup
sage: _discrete_log_pgroup(5, [1,2,4,4], gs, a + 17*b + 123*c + 456*d)
(1, 17, 123, 456)
TESTS:
Check for :trac:`34716`::
sage: E = EllipticCurve(GF(487^2), [311,205])
sage: G = E.abelian_group().torsion_subgroup(42)
sage: G.invariants()
(6, 42)
sage: P, Q = G.torsion_subgroup(6).gens()
sage: G.discrete_log(2*P + 3*Q, [P, Q]) # indirect doctest
(2, 3)
"""
from itertools import product as iproduct

Expand Down

0 comments on commit 4edaafe

Please sign in to comment.