Skip to content

Commit 07873ba

Browse files
committed
Address reviewer comments
1 parent 75ec6cc commit 07873ba

File tree

1 file changed

+8
-4
lines changed

1 file changed

+8
-4
lines changed

src/sage/groups/generic.py

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -953,9 +953,12 @@ def discrete_log(a, base, ord=None, bounds=None, operation='*', identity=None, i
953953
if ord == Infinity:
954954
if algorithm == 'bsgs':
955955
return bsgs(base, a, bounds, identity=identity, inverse=inverse, op=op, operation=operation)
956-
else:
957-
assert algorithm == 'lambda'
956+
elif algorithm == 'lambda':
958957
return discrete_log_lambda(base, a, bounds, inverse=inverse, identity=identity, op=op, operation=operation)
958+
elif algorithm == 'rho':
959+
raise ValueError('pollard rho algorithm does not work with infinite order elements')
960+
else:
961+
raise ValueError(f"unknown algorithm {algorithm}")
959962
if base == power(base, 0) and a != base:
960963
raise ValueError
961964
f = ord.factor()
@@ -986,9 +989,10 @@ def discrete_log(a, base, ord=None, bounds=None, operation='*', identity=None, i
986989
c = bsgs(gamma, h, (0, temp_bound), inverse=inverse, identity=identity, op=op, operation=operation)
987990
elif algorithm == 'rho':
988991
c = discrete_log_rho(h, gamma, ord=pi, inverse=inverse, identity=identity, op=op, operation=operation)
989-
else:
990-
assert algorithm == 'lambda'
992+
elif algorithm == 'lambda':
991993
c = discrete_log_lambda(h, gamma, (0, temp_bound), inverse=inverse, identity=identity, op=op, operation=operation)
994+
else:
995+
raise ValueError(f"unknown algorithm {algorithm}")
992996
l[i] += c * (pi**j)
993997
running_bound //= pi
994998
running_mod *= pi

0 commit comments

Comments
 (0)