Solved TestAddresses's test_privtopub testcase issue

This commit is contained in:
jai.s 2020-10-05 18:58:03 +05:30
parent 57d22a5cd6
commit ef3e496fbd
No known key found for this signature in database
GPG Key ID: 360CFA25EFC67D12
2 changed files with 5 additions and 10 deletions

View File

@ -16,7 +16,7 @@ def inv(a, n):
lm, hm = 1, 0
low, high = a % n, n
while low > 1:
r = high / low
r = high // low
nm, new = hm - lm * r, high - low * r
lm, low, hm, high = nm, new, lm, low
return lm % n
@ -97,11 +97,6 @@ def base10_double(a):
m = int((3 * a[0] * a[0] + A) * inv(2 * a[1], P)) % P
x = int(m * m - 2 * a[0]) % P
y = int(m * (a[0] - x) - a[1]) % P
# print('++++++++++++++++++++++++++++++++')
# print('inside the base10_double')
# print('the value of x -{}'.format(x))
# print('the value of y -{}'.format(y))
# print('++++++++++++++++++++++++++++++++')
return (x, y)
def base10_multiply(a, n):
@ -111,9 +106,9 @@ def base10_multiply(a, n):
if n == 1:
return a
if (n % 2) == 0:
return base10_double(base10_multiply(a, n /2))
return base10_double(base10_multiply(a, n //2))
if (n % 2) == 1:
return base10_add(base10_double(base10_multiply(a, n /2)), a)
return base10_add(base10_double(base10_multiply(a, n //2)), a)
return None

View File

@ -79,7 +79,7 @@ class TestAddresses(unittest.TestCase):
hexlify(sample_pubsigningkey)
)
self.assertEqual(
arithmetic.privtopub(sample_privateencryptionkey),
arithmetic.privtopub(sample_privateencryptionkey.encode()),
hexlify(sample_pubencryptionkey)
)