27 const std::string& address,
28 const std::string& signature,
29 const std::string& message)
36 if (std::get_if<PKHash>(&destination) ==
nullptr) {
41 if (!signature_bytes) {
50 if (!(
PKHash(pubkey) == *std::get_if<PKHash>(&destination))) {
59 const std::string& message,
60 std::string& signature)
62 std::vector<unsigned char> signature_bytes;
78 return hasher.GetHash();
87 return "Private key not available";
bool IsValidDestination(const CTxDestination &dest)
Check whether a CTxDestination corresponds to one with an address.
std::variant< CNoDestination, PubKeyDestination, PKHash, ScriptHash, WitnessV0ScriptHash, WitnessV0KeyHash, WitnessV1Taproot, PayToAnchor, WitnessUnknown > CTxDestination
A txout script categorized into standard templates.
An encapsulated private key.
bool SignCompact(const uint256 &hash, std::vector< unsigned char > &vchSig) const
Create a compact signature (65 bytes), which allows reconstructing the used public key.
An encapsulated public key.
bool RecoverCompact(const uint256 &hash, const std::vector< unsigned char > &vchSig)
Recover a public key from a compact signature.
A writer stream (for serialization) that computes a 256-bit hash.
uint256 MessageHash(const std::string &message)
Hashes a message for signing and verification in a manner that prevents inadvertently signing a trans...
bool MessageSign(const CKey &privkey, const std::string &message, std::string &signature)
Sign a message.
const std::string MESSAGE_MAGIC
Text used to signify that a signed message follows and to prevent inadvertently signing a transaction...
std::string SigningResultString(const SigningResult res)
MessageVerificationResult MessageVerify(const std::string &address, const std::string &signature, const std::string &message)
Verify a signed message.
CTxDestination DecodeDestination(const std::string &str, std::string &error_msg, std::vector< int > *error_locations)
@ PRIVATE_KEY_NOT_AVAILABLE
MessageVerificationResult
The result of a signed message verification.
@ ERR_MALFORMED_SIGNATURE
The provided signature couldn't be parsed (maybe invalid base64).
@ ERR_INVALID_ADDRESS
The provided address is invalid.
@ ERR_ADDRESS_NO_KEY
The provided address is valid but does not refer to a public key.
@ ERR_NOT_SIGNED
The message was not signed with the private key of the provided address.
@ OK
The message verification was successful.
@ ERR_PUBKEY_NOT_RECOVERED
A public key could not be recovered from the provided signature and message.
std::string EncodeBase64(Span< const unsigned char > input)
std::optional< std::vector< unsigned char > > DecodeBase64(std::string_view str)