Bitcoin Core 28.99.0
P2P Digital Currency
Functions | Variables
signmessage.cpp File Reference
#include <common/signmessage.h>
#include <hash.h>
#include <key.h>
#include <key_io.h>
#include <pubkey.h>
#include <uint256.h>
#include <util/strencodings.h>
#include <cassert>
#include <optional>
#include <string>
#include <variant>
#include <vector>
Include dependency graph for signmessage.cpp:

Go to the source code of this file.

Functions

MessageVerificationResult MessageVerify (const std::string &address, const std::string &signature, const std::string &message)
 Verify a signed message. More...
 
bool MessageSign (const CKey &privkey, const std::string &message, std::string &signature)
 Sign a message. More...
 
uint256 MessageHash (const std::string &message)
 Hashes a message for signing and verification in a manner that prevents inadvertently signing a transaction. More...
 
std::string SigningResultString (const SigningResult res)
 

Variables

const std::string MESSAGE_MAGIC = "Bitcoin Signed Message:\n"
 Text used to signify that a signed message follows and to prevent inadvertently signing a transaction. More...
 

Function Documentation

◆ MessageHash()

uint256 MessageHash ( const std::string &  message)

Hashes a message for signing and verification in a manner that prevents inadvertently signing a transaction.

Definition at line 73 of file signmessage.cpp.

Here is the caller graph for this function:

◆ MessageSign()

bool MessageSign ( const CKey privkey,
const std::string &  message,
std::string &  signature 
)

Sign a message.

Parameters
[in]privkeyPrivate key to sign with.
[in]messageThe message to sign.
[out]signatureSignature, base64 encoded, only set if true is returned.
Returns
true if signing was successful.

Definition at line 57 of file signmessage.cpp.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ MessageVerify()

MessageVerificationResult MessageVerify ( const std::string &  address,
const std::string &  signature,
const std::string &  message 
)

Verify a signed message.

Parameters
[in]addressSigner's bitcoin address, it must refer to a public key.
[in]signatureThe signature in base64 format.
[in]messageThe message that was signed.
Returns
result code

Definition at line 26 of file signmessage.cpp.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ SigningResultString()

std::string SigningResultString ( const SigningResult  res)

Definition at line 81 of file signmessage.cpp.

Here is the call graph for this function:
Here is the caller graph for this function:

Variable Documentation

◆ MESSAGE_MAGIC

const std::string MESSAGE_MAGIC = "Bitcoin Signed Message:\n"

Text used to signify that a signed message follows and to prevent inadvertently signing a transaction.

Definition at line 24 of file signmessage.cpp.