def verify_ed25519(pub_key: Ed25519PublicKey, sig_ptrs: SignaturePtrs) -> bool: c = b''.join(bytes(blk) for blk in sig_ptrs.signature_covered_part) try: pub_key.verify(bytes(sig_ptrs.signature_value_buf), c) return True except InvalidSignature: return False
def validate_recipient_signature(self, cmd: PaymentCommand, public_key: Ed25519PublicKey) -> None: msg = cmd.travel_rule_metadata_signature_message(self.hrp) try: public_key.verify(bytes.fromhex(cmd.payment.recipient_signature), msg) except (ValueError, InvalidSignature) as e: raise command_error(ErrorCode.invalid_recipient_signature, str(e), "command.payment.recipient_signature") from e
def verify(public_key: Ed25519PublicKey, signature: bytes, data: bytes) -> bool: """ Verifies that the passed public key was used to create the signature for passed data. Args: public_key (Ed25519PublicKey): Public key to use for verification. signature (bytes): Signature to verify data (bytes): Signed data. Returns: bool: True if signature is correct. """ try: public_key.verify(signature, data) except: return False return True
def get_eddsa_verifier(pub_key: ed25519.Ed25519PublicKey): return Verifier(lambda: pub_key.verify(signature, message))