Fix signature validator:

Add prefix and return verify result
This commit is contained in:
NIC619
2019-11-28 18:45:00 +08:00
parent d5d6962dce
commit 064c109b64
2 changed files with 20 additions and 7 deletions

View File

@ -1,9 +1,7 @@
from libp2p.crypto.keys import PublicKey
from .pb import rpc_pb2
def signature_validator(pubkey: PublicKey, msg: rpc_pb2.Message) -> bool:
def signature_validator(pubkey: PublicKey, payload: bytes, signature: bytes) -> bool:
"""
Verify the message against the given public key.
@ -11,7 +9,6 @@ def signature_validator(pubkey: PublicKey, msg: rpc_pb2.Message) -> bool:
:param msg: the message signed.
"""
try:
pubkey.verify(msg.SerializeToString(), msg.signature)
return pubkey.verify(payload, signature)
except Exception:
return False
return True