mirror of
https://github.com/bitcoin/bitcoin.git
synced 2025-11-26 14:00:29 +01:00
test: remove modinv python util helper function
This commit is contained in:
@@ -15,7 +15,6 @@ import os
|
||||
import random
|
||||
import re
|
||||
import time
|
||||
import unittest
|
||||
|
||||
from . import coverage
|
||||
from .authproxy import AuthServiceProxy, JSONRPCException
|
||||
@@ -537,22 +536,3 @@ def find_vout_for_address(node, txid, addr):
|
||||
if addr == tx["vout"][i]["scriptPubKey"]["address"]:
|
||||
return i
|
||||
raise RuntimeError("Vout not found for address: txid=%s, addr=%s" % (txid, addr))
|
||||
|
||||
def modinv(a, n):
|
||||
"""Compute the modular inverse of a modulo n using the extended Euclidean
|
||||
Algorithm. See https://en.wikipedia.org/wiki/Extended_Euclidean_algorithm#Modular_integers.
|
||||
"""
|
||||
return pow(a, -1, n)
|
||||
|
||||
class TestFrameworkUtil(unittest.TestCase):
|
||||
def test_modinv(self):
|
||||
test_vectors = [
|
||||
[7, 11],
|
||||
[11, 29],
|
||||
[90, 13],
|
||||
[1891, 3797],
|
||||
[6003722857, 77695236973],
|
||||
]
|
||||
|
||||
for a, n in test_vectors:
|
||||
self.assertEqual(modinv(a, n), pow(a, n-2, n))
|
||||
|
||||
Reference in New Issue
Block a user