py-libp2p/libp2p/pubsub/validators.py
NIC619 064c109b64
Fix signature validator:
Add prefix and return verify result
2019-11-28 18:45:00 +08:00

15 lines
395 B
Python

from libp2p.crypto.keys import PublicKey
def signature_validator(pubkey: PublicKey, payload: bytes, signature: bytes) -> bool:
"""
Verify the message against the given public key.
:param pubkey: the public key which signs the message.
:param msg: the message signed.
"""
try:
return pubkey.verify(payload, signature)
except Exception:
return False