Cleanup and update
This commit is contained in:
parent
d0a2d35176
commit
d9c68a86c6
|
@ -1,12 +1,18 @@
|
||||||
from binascii import hexlify, unhexlify
|
from binascii import hexlify, unhexlify
|
||||||
import re
|
import re
|
||||||
import struct
|
|
||||||
from sha3 import keccak_256
|
from sha3 import keccak_256
|
||||||
|
import struct
|
||||||
|
import sys
|
||||||
|
|
||||||
from . import base58
|
from . import base58
|
||||||
from . import ed25519
|
from . import ed25519
|
||||||
from . import numbers
|
from . import numbers
|
||||||
|
|
||||||
|
if sys.version_info < (3,): # pragma: no cover
|
||||||
|
_str_types = (str, bytes, unicode)
|
||||||
|
else: # pragma: no cover
|
||||||
|
_str_types = (str, bytes)
|
||||||
|
|
||||||
_ADDR_REGEX = re.compile(r'^[123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz]{95}$')
|
_ADDR_REGEX = re.compile(r'^[123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz]{95}$')
|
||||||
_IADDR_REGEX = re.compile(r'^[123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz]{106}$')
|
_IADDR_REGEX = re.compile(r'^[123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz]{106}$')
|
||||||
|
|
||||||
|
@ -58,7 +64,7 @@ class BaseAddress(object):
|
||||||
def __eq__(self, other):
|
def __eq__(self, other):
|
||||||
if isinstance(other, BaseAddress):
|
if isinstance(other, BaseAddress):
|
||||||
return str(self) == str(other)
|
return str(self) == str(other)
|
||||||
if isinstance(other, str):
|
if isinstance(other, _str_types):
|
||||||
return str(self) == other
|
return str(self) == other
|
||||||
return super(BaseAddress, self).__eq__(other)
|
return super(BaseAddress, self).__eq__(other)
|
||||||
|
|
||||||
|
|
|
@ -9,7 +9,7 @@ import operator as _oper
|
||||||
import sys as _sys
|
import sys as _sys
|
||||||
|
|
||||||
# Set up byte handling for Python 2 or 3
|
# Set up byte handling for Python 2 or 3
|
||||||
if _sys.version_info.major == 2:
|
if _sys.version_info.major == 2: # pragma: no cover
|
||||||
int2byte = chr
|
int2byte = chr
|
||||||
range = xrange
|
range = xrange
|
||||||
|
|
||||||
|
@ -18,7 +18,7 @@ if _sys.version_info.major == 2:
|
||||||
|
|
||||||
def intlist2bytes(l):
|
def intlist2bytes(l):
|
||||||
return b"".join(chr(c) for c in l)
|
return b"".join(chr(c) for c in l)
|
||||||
else:
|
else: # pragma: no cover
|
||||||
indexbytes = _oper.getitem
|
indexbytes = _oper.getitem
|
||||||
intlist2bytes = bytes
|
intlist2bytes = bytes
|
||||||
int2byte = _oper.methodcaller("to_bytes", 1, "big")
|
int2byte = _oper.methodcaller("to_bytes", 1, "big")
|
||||||
|
@ -27,9 +27,6 @@ b = 256
|
||||||
q = 2**255 - 19
|
q = 2**255 - 19
|
||||||
l = 2**252 + 27742317777372353535851937790883648493
|
l = 2**252 + 27742317777372353535851937790883648493
|
||||||
|
|
||||||
def H(m):
|
|
||||||
return hashlib.sha512(m).digest()
|
|
||||||
|
|
||||||
def expmod(b, e, m):
|
def expmod(b, e, m):
|
||||||
if e == 0: return 1
|
if e == 0: return 1
|
||||||
t = expmod(b, e//2, m)**2 % m
|
t = expmod(b, e//2, m)**2 % m
|
||||||
|
@ -103,16 +100,6 @@ def encodepoint(P):
|
||||||
def bit(h, i):
|
def bit(h, i):
|
||||||
return (indexbytes(h, i//8) >> (i%8)) & 1
|
return (indexbytes(h, i//8) >> (i%8)) & 1
|
||||||
|
|
||||||
def publickey(sk):
|
|
||||||
h = H(sk)
|
|
||||||
a = 2**(b-2) + sum(2**i * bit(h, i) for i in range(3, b-2))
|
|
||||||
A = scalarmult(B, a)
|
|
||||||
return encodepoint(A)
|
|
||||||
|
|
||||||
def Hint(m):
|
|
||||||
h = H(m)
|
|
||||||
return sum(2**i * bit(h, i) for i in range(2*b))
|
|
||||||
|
|
||||||
def isoncurve(P):
|
def isoncurve(P):
|
||||||
x = P[0]
|
x = P[0]
|
||||||
y = P[1]
|
y = P[1]
|
||||||
|
@ -130,6 +117,19 @@ def decodepoint(s):
|
||||||
return P
|
return P
|
||||||
|
|
||||||
# These are unused but let's keep them
|
# These are unused but let's keep them
|
||||||
|
#def H(m):
|
||||||
|
# return hashlib.sha512(m).digest()
|
||||||
|
#
|
||||||
|
#def Hint(m):
|
||||||
|
# h = H(m)
|
||||||
|
# return sum(2**i * bit(h, i) for i in range(2*b))
|
||||||
|
#
|
||||||
|
#def publickey(sk):
|
||||||
|
# h = H(sk)
|
||||||
|
# a = 2**(b-2) + sum(2**i * bit(h, i) for i in range(3, b-2))
|
||||||
|
# A = scalarmult(B, a)
|
||||||
|
# return encodepoint(A)
|
||||||
|
#
|
||||||
#def signature(m, sk, pk):
|
#def signature(m, sk, pk):
|
||||||
# h = H(sk)
|
# h = H(sk)
|
||||||
# a = 2**(b-2) + sum(2**i * bit(h, i) for i in range(3, b-2))
|
# a = 2**(b-2) + sum(2**i * bit(h, i) for i in range(3, b-2))
|
||||||
|
|
|
@ -3,10 +3,10 @@ import sys
|
||||||
|
|
||||||
PICONERO = Decimal('0.000000000001')
|
PICONERO = Decimal('0.000000000001')
|
||||||
|
|
||||||
if sys.version_info < (3,):
|
if sys.version_info < (3,): # pragma: no cover
|
||||||
_integer_types = (int, long,)
|
_integer_types = (int, long,)
|
||||||
_str_types = (str, bytes, unicode)
|
_str_types = (str, bytes, unicode)
|
||||||
else:
|
else: # pragma: no cover
|
||||||
_integer_types = (int,)
|
_integer_types = (int,)
|
||||||
_str_types = (str, bytes)
|
_str_types = (str, bytes)
|
||||||
|
|
||||||
|
|
|
@ -86,9 +86,9 @@ class Transaction(object):
|
||||||
return self.hash
|
return self.hash
|
||||||
|
|
||||||
|
|
||||||
if sys.version_info < (3,):
|
if sys.version_info < (3,): # pragma: no cover
|
||||||
_str_types = (str, bytes, unicode)
|
_str_types = (str, bytes, unicode)
|
||||||
else:
|
else: # pragma: no cover
|
||||||
_str_types = (str, bytes)
|
_str_types = (str, bytes)
|
||||||
|
|
||||||
|
|
||||||
|
|
4
setup.py
4
setup.py
|
@ -42,13 +42,15 @@ setup(
|
||||||
author_email = 'michal@salaban.info',
|
author_email = 'michal@salaban.info',
|
||||||
license = 'BSD-3-Clause',
|
license = 'BSD-3-Clause',
|
||||||
classifiers = [
|
classifiers = [
|
||||||
'Development Status :: 2 - Pre-Alpha',
|
'Development Status :: 4 - Beta',
|
||||||
'Intended Audience :: Developers',
|
'Intended Audience :: Developers',
|
||||||
'License :: OSI Approved :: BSD License',
|
'License :: OSI Approved :: BSD License',
|
||||||
'Operating System :: OS Independent',
|
'Operating System :: OS Independent',
|
||||||
'Programming Language :: Python',
|
'Programming Language :: Python',
|
||||||
|
'Programming Language :: Python :: 2.7',
|
||||||
'Programming Language :: Python :: 3.6',
|
'Programming Language :: Python :: 3.6',
|
||||||
'Programming Language :: Python :: 3.7',
|
'Programming Language :: Python :: 3.7',
|
||||||
|
'Topic :: Software Development :: Libraries :: Python Modules',
|
||||||
],
|
],
|
||||||
keywords = 'monero cryptocurrency',
|
keywords = 'monero cryptocurrency',
|
||||||
test_suite='tests',
|
test_suite='tests',
|
||||||
|
|
Loading…
Reference in New Issue