signed blocks related crashes fixed hopefully
This commit is contained in:
parent
28e080fe1a
commit
5086a839ee
@ -277,7 +277,6 @@ class OnionrCommunicate:
|
|||||||
pass
|
pass
|
||||||
else:
|
else:
|
||||||
creator = self._utils.getPeerByHashId(blockMetadata['id'])
|
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):
|
if self._core._crypto.edVerify(blockContent.split(b'}')[1], creator, blockMetadata['sig'], encodedData=True):
|
||||||
self._core.updateBlockInfo(i, 'sig', 'true')
|
self._core.updateBlockInfo(i, 'sig', 'true')
|
||||||
else:
|
else:
|
||||||
|
@ -44,7 +44,11 @@ class OnionrCrypto:
|
|||||||
|
|
||||||
def edVerify(self, data, key, sig, encodedData=True):
|
def edVerify(self, data, key, sig, encodedData=True):
|
||||||
'''Verify signed data (combined in nacl) to an ed25519 key'''
|
'''Verify signed data (combined in nacl) to an ed25519 key'''
|
||||||
|
try:
|
||||||
key = nacl.signing.VerifyKey(key=key, encoder=nacl.encoding.Base32Encoder)
|
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
|
retData = False
|
||||||
sig = base64.b64decode(sig)
|
sig = base64.b64decode(sig)
|
||||||
try:
|
try:
|
||||||
@ -56,6 +60,7 @@ class OnionrCrypto:
|
|||||||
retData = key.verify(data, sig) # .encode() is not the same as nacl.encoding
|
retData = key.verify(data, sig) # .encode() is not the same as nacl.encoding
|
||||||
except nacl.exceptions.BadSignatureError:
|
except nacl.exceptions.BadSignatureError:
|
||||||
pass
|
pass
|
||||||
|
|
||||||
else:
|
else:
|
||||||
try:
|
try:
|
||||||
retData = key.verify(data, sig)
|
retData = key.verify(data, sig)
|
||||||
|
Loading…
Reference in New Issue
Block a user