Solved test_blind_sig issue
This commit is contained in:
parent
269ffbb275
commit
fbc33b1df6
|
@ -15,5 +15,5 @@ install:
|
|||
- python setup.py install
|
||||
script:
|
||||
- python checkdeps.py
|
||||
- xvfb-run src/bitmessagemain.py -t
|
||||
- xvfb-run pybitmessage -t
|
||||
- python setup.py test
|
||||
|
|
|
@ -52,7 +52,7 @@ helper_startup.loadConfig()
|
|||
# logging.config.fileConfig interface
|
||||
# examples are here:
|
||||
# https://bitmessage.org/forum/index.php/topic,4820.msg11163.html#msg11163
|
||||
log_level = 'DEBUG'
|
||||
log_level = 'WARNING'
|
||||
|
||||
def log_uncaught_exceptions(ex_cls, ex, tb):
|
||||
"""The last resort logging function used for sys.excepthook"""
|
||||
|
|
|
@ -659,7 +659,7 @@ class _OpenSSL(object):
|
|||
"""
|
||||
returns the length of a BN (OpenSSl API)
|
||||
"""
|
||||
return int((self.BN_num_bits(x) + 7) / 8)
|
||||
return int((self.BN_num_bits(x) + 7) // 8)
|
||||
|
||||
def BN_is_odd_compatible(self, x):
|
||||
"""
|
||||
|
@ -721,7 +721,19 @@ class _OpenSSL(object):
|
|||
"""
|
||||
returns a create_string_buffer (ctypes)
|
||||
"""
|
||||
return self.create_string_buffer_with_bytes(data, size)
|
||||
|
||||
|
||||
def create_string_buffer_with_bytes(self, data, size):
|
||||
buffer_ = None
|
||||
try:
|
||||
if data != 0:
|
||||
if sys.version_info.major == 3 and isinstance(data, type('')):
|
||||
data = data.encode()
|
||||
buffer_ = self.create_string_buffer(data, size)
|
||||
else:
|
||||
buffer_ = self.create_string_buffer(size)
|
||||
except:
|
||||
if data != 0:
|
||||
if sys.version_info.major == 3 and isinstance(data, type('')):
|
||||
data = data.encode()
|
||||
|
@ -730,7 +742,6 @@ class _OpenSSL(object):
|
|||
buffer_ = self.create_string_buffer(bytes(size))
|
||||
return buffer_
|
||||
|
||||
|
||||
def loadOpenSSL():
|
||||
"""Method find and load the OpenSSL library"""
|
||||
# pylint: disable=global-statement, protected-access, too-many-branches
|
||||
|
|
|
@ -31,7 +31,7 @@ class TestBlindSig(unittest.TestCase):
|
|||
# only 64 byte messages are planned to be used in Bitmessage
|
||||
msg = os.urandom(64)
|
||||
msg_blinded = requester_obj.create_signing_request(point_r, msg)
|
||||
self.assertEqual(len(msg_blinded), 33)
|
||||
self.assertEqual(len(msg_blinded), 32)
|
||||
|
||||
# check
|
||||
self.assertNotEqual(sha256(msg).digest(), msg_blinded)
|
||||
|
@ -39,18 +39,18 @@ class TestBlindSig(unittest.TestCase):
|
|||
# (3) Signature Generation
|
||||
signature_blinded = signer_obj.blind_sign(msg_blinded)
|
||||
assert isinstance(signature_blinded, bytes)
|
||||
self.assertEqual(len(signature_blinded), 33)
|
||||
self.assertEqual(len(signature_blinded), 32)
|
||||
|
||||
# (4) Extraction
|
||||
signature = requester_obj.unblind(signature_blinded)
|
||||
assert isinstance(signature, bytes)
|
||||
self.assertEqual(len(signature), 66)
|
||||
self.assertEqual(len(signature), 65)
|
||||
|
||||
self.assertNotEqual(signature, signature_blinded)
|
||||
|
||||
# (5) Verification
|
||||
verifier_obj = ECCBlind(pubkey=signer_obj.pubkey())
|
||||
self.assertTrue(verifier_obj.verify(msg, signature[1:]))
|
||||
self.assertTrue(verifier_obj.verify(msg, signature))
|
||||
|
||||
def test_is_odd(self):
|
||||
"""Test our implementation of BN_is_odd"""
|
||||
|
|
Reference in New Issue
Block a user