Validates the signature of a signed message. :param signature: The signature to be validated as *bytes*. :param message: The message to be validated as *bytes*. :returns: True if the signature is valid, otherwise False. :raises: *KeyError* if the instance does not hold a public key. */
| 569 | :raises: *KeyError* if the instance does not hold a public key. |
| 570 | */ |
| 571 | bool Identity::validate(const Bytes& signature, const Bytes& message) const { |
| 572 | assert(_object); |
| 573 | if (_object->_pub) { |
| 574 | try { |
| 575 | TRACEF("Identity::validate: Verifying signature: %s against message: %s", signature.toHex().c_str(), message.toHex().c_str()); |
| 576 | return _object->_sig_pub->verify(signature, message); |
| 577 | } |
| 578 | catch (const std::exception& e) { |
| 579 | return false; |
| 580 | } |
| 581 | } |
| 582 | else { |
| 583 | throw std::runtime_error("Signature validation failed because identity does not hold a public key"); |
| 584 | } |
| 585 | } |
| 586 | |
| 587 | void Identity::prove(const Packet& packet, const Destination& destination /*= {Type::NONE}*/) const { |
| 588 | assert(_object); |
no test coverage detected