|
Bitcoin Core
22.99.0
P2P Digital Currency
|
Go to the documentation of this file.
25 const std::string& address,
26 const std::string& signature,
27 const std::string& message)
34 if (std::get_if<PKHash>(&destination) ==
nullptr) {
39 std::vector<unsigned char> signature_bytes =
DecodeBase64(signature.c_str(), &invalid);
58 const std::string& message,
59 std::string& signature)
61 std::vector<unsigned char> signature_bytes;
86 return "Private key not available";
@ ERR_MALFORMED_SIGNATURE
The provided signature couldn't be parsed (maybe invalid base64).
@ ERR_NOT_SIGNED
The message was not signed with the private key of the provided address.
std::string EncodeBase64(Span< const unsigned char > input)
MessageVerificationResult MessageVerify(const std::string &address, const std::string &signature, const std::string &message)
Verify a signed message.
MessageVerificationResult
The result of a signed message verification.
std::variant< CNoDestination, PKHash, ScriptHash, WitnessV0ScriptHash, WitnessV0KeyHash, WitnessV1Taproot, WitnessUnknown > CTxDestination
A txout script template with a specific destination.
bool IsValidDestination(const CTxDestination &dest)
Check whether a CTxDestination is a CNoDestination.
std::vector< unsigned char > DecodeBase64(const char *p, bool *pf_invalid)
@ PRIVATE_KEY_NOT_AVAILABLE
bool SignCompact(const uint256 &hash, std::vector< unsigned char > &vchSig) const
Create a compact signature (65 bytes), which allows reconstructing the used public key.
@ ERR_INVALID_ADDRESS
The provided address is invalid.
std::string SigningResultString(const SigningResult res)
CTxDestination DecodeDestination(const std::string &str, std::string &error_msg)
@ ERR_PUBKEY_NOT_RECOVERED
A public key could not be recovered from the provided signature and message.
bool RecoverCompact(const uint256 &hash, const std::vector< unsigned char > &vchSig)
Recover a public key from a compact signature.
@ ERR_ADDRESS_NO_KEY
The provided address is valid but does not refer to a public key.
An encapsulated public key.
An encapsulated private key.
uint256 MessageHash(const std::string &message)
Hashes a message for signing and verification in a manner that prevents inadvertently signing a trans...
A writer stream (for serialization) that computes a 256-bit hash.
@ OK
The message verification was successful.
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...
uint256 GetHash()
Compute the double-SHA256 hash of all data written to this object.