We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent 88881cf commit fa6eb65Copy full SHA for fa6eb65
test/functional/test_framework/util.py
@@ -542,18 +542,7 @@ def modinv(a, n):
542
"""Compute the modular inverse of a modulo n using the extended Euclidean
543
Algorithm. See https://en.wikipedia.org/wiki/Extended_Euclidean_algorithm#Modular_integers.
544
"""
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
+ return pow(a, -1, n)
557
558
class TestFrameworkUtil(unittest.TestCase):
559
def test_modinv(self):
0 commit comments