Skip to content
This repository was archived by the owner on Jan 30, 2023. It is now read-only.

Commit eb28739

Browse files
committed
fix silent failure issue when base == identity
the code to reduce the order provided to the order of the base allowed the dlog function to silently produce a wrong answer when base == identity, a != base, and ord>1
1 parent 0a648f1 commit eb28739

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

src/sage/groups/generic.py

+3-3
Original file line numberDiff line numberDiff line change
@@ -854,8 +854,8 @@ def discrete_log(a, base, ord=None, bounds=None, operation='*', identity=None, i
854854
....: assert lo <= sol <= hi
855855
....: kwargs['bounds'] = (lo, hi)
856856
sage: res = discrete_log(*args, **kwargs)
857-
sage: res == sol
858-
True
857+
sage: if not res == sol:
858+
....: print(args, kwargs, G, res, sol)
859859
860860
AUTHORS:
861861
@@ -889,7 +889,7 @@ def discrete_log(a, base, ord=None, bounds=None, operation='*', identity=None, i
889889
from sage.rings.infinity import Infinity
890890
if ord == +Infinity:
891891
return bsgs(base, a, bounds, identity=identity, inverse=inverse, op=op, operation=operation)
892-
if ord == 1 and a != base:
892+
if base == power(base, 0) and a != base:
893893
raise ValueError
894894
f = ord.factor()
895895
l = [0] * len(f)

0 commit comments

Comments
 (0)