@@ -953,9 +953,12 @@ def discrete_log(a, base, ord=None, bounds=None, operation='*', identity=None, i
953
953
if ord == Infinity :
954
954
if algorithm == 'bsgs' :
955
955
return bsgs (base , a , bounds , identity = identity , inverse = inverse , op = op , operation = operation )
956
- else :
957
- assert algorithm == 'lambda'
956
+ elif algorithm == 'lambda' :
958
957
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 } " )
959
962
if base == power (base , 0 ) and a != base :
960
963
raise ValueError
961
964
f = ord .factor ()
@@ -986,9 +989,10 @@ def discrete_log(a, base, ord=None, bounds=None, operation='*', identity=None, i
986
989
c = bsgs (gamma , h , (0 , temp_bound ), inverse = inverse , identity = identity , op = op , operation = operation )
987
990
elif algorithm == 'rho' :
988
991
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' :
991
993
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 } " )
992
996
l [i ] += c * (pi ** j )
993
997
running_bound //= pi
994
998
running_mod *= pi
0 commit comments