Skip to content

Commit fa6eb65

Browse files
author
MarcoFalke
committed
test: Use python3.8 pow()
1 parent 88881cf commit fa6eb65

File tree

1 file changed

+1
-12
lines changed
  • test/functional/test_framework

1 file changed

+1
-12
lines changed

test/functional/test_framework/util.py

Lines changed: 1 addition & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -542,18 +542,7 @@ def modinv(a, n):
542542
"""Compute the modular inverse of a modulo n using the extended Euclidean
543543
Algorithm. See https://en.wikipedia.org/wiki/Extended_Euclidean_algorithm#Modular_integers.
544544
"""
545-
# TODO: Change to pow(a, -1, n) available in Python 3.8
546-
t1, t2 = 0, 1
547-
r1, r2 = n, a
548-
while r2 != 0:
549-
q = r1 // r2
550-
t1, t2 = t2, t1 - q * t2
551-
r1, r2 = r2, r1 - q * r2
552-
if r1 > 1:
553-
return None
554-
if t1 < 0:
555-
t1 += n
556-
return t1
545+
return pow(a, -1, n)
557546

558547
class TestFrameworkUtil(unittest.TestCase):
559548
def test_modinv(self):

0 commit comments

Comments
 (0)