signed blocks related crashes fixed hopefully

master
Kevin Froman 2018-04-26 21:14:31 -05:00
parent 28e080fe1a
commit 5086a839ee
2 changed files with 6 additions and 2 deletions

View File

@ -277,7 +277,6 @@ class OnionrCommunicate:
pass
else:
creator = self._utils.getPeerByHashId(blockMetadata['id'])
logger.debug('Proccess blocks: verifying signature by ' + creator)
if self._core._crypto.edVerify(blockContent.split(b'}')[1], creator, blockMetadata['sig'], encodedData=True):
self._core.updateBlockInfo(i, 'sig', 'true')
else:

View File

@ -44,7 +44,11 @@ class OnionrCrypto:
def edVerify(self, data, key, sig, encodedData=True):
'''Verify signed data (combined in nacl) to an ed25519 key'''
try:
key = nacl.signing.VerifyKey(key=key, encoder=nacl.encoding.Base32Encoder)
except nacl.bindings.crypto_sign_PUBLICKEYBYTES:
logger.warn('Signature by unknown key (cannot reverse hash)')
return False
retData = False
sig = base64.b64decode(sig)
try:
@ -56,6 +60,7 @@ class OnionrCrypto:
retData = key.verify(data, sig) # .encode() is not the same as nacl.encoding
except nacl.exceptions.BadSignatureError:
pass
else:
try:
retData = key.verify(data, sig)