MCPcopy Create free account
hub / github.com/attermann/microReticulum / validate

Method validate

src/microReticulum/Identity.cpp:571–585  ·  view source on GitHub ↗

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. */

Source from the content-addressed store, hash-verified

569:raises: *KeyError* if the instance does not hold a public key.
570*/
571bool 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
587void Identity::prove(const Packet& packet, const Destination& destination /*= {Type::NONE}*/) const {
588 assert(_object);

Callers 1

validate_announceMethod · 0.45

Calls 2

toHexMethod · 0.80
verifyMethod · 0.45

Tested by

no test coverage detected