Bitcoin ABC  0.24.10
P2P Digital Currency
message.h
Go to the documentation of this file.
1 // Copyright (c) 2009-2010 Satoshi Nakamoto
2 // Copyright (c) 2009-2020 The Bitcoin Core developers
3 // Distributed under the MIT software license, see the accompanying
4 // file COPYING or http://www.opensource.org/licenses/mit-license.php.
5 
6 #ifndef BITCOIN_UTIL_MESSAGE_H
7 #define BITCOIN_UTIL_MESSAGE_H
8 
9 #include <uint256.h>
10 
11 #include <string>
12 
13 class CChainParams;
14 class CKey;
15 
16 extern const std::string MESSAGE_MAGIC;
17 
29 
32 
35 
39 
42 
44  OK
45 };
46 
47 enum class SigningResult {
48  OK,
51 };
52 
62  const std::string &address,
63  const std::string &signature,
64  const std::string &message);
65 
74 bool MessageSign(const CKey &privkey, const std::string &message,
75  std::string &signature);
76 
81 uint256 MessageHash(const std::string &message);
82 
83 std::string SigningResultString(const SigningResult res);
84 
85 #endif // BITCOIN_UTIL_MESSAGE_H
MessageVerificationResult::ERR_MALFORMED_SIGNATURE
@ ERR_MALFORMED_SIGNATURE
The provided signature couldn't be parsed (maybe invalid base64).
SigningResult::OK
@ OK
No error.
uint256.h
CChainParams
CChainParams defines various tweakable parameters of a given instance of the Bitcoin system.
Definition: chainparams.h:47
MessageVerificationResult::ERR_NOT_SIGNED
@ ERR_NOT_SIGNED
The message was not signed with the private key of the provided address.
SigningResult
SigningResult
Definition: message.h:47
MessageVerificationResult
MessageVerificationResult
The result of a signed message verification.
Definition: message.h:26
SigningResult::PRIVATE_KEY_NOT_AVAILABLE
@ PRIVATE_KEY_NOT_AVAILABLE
MessageSign
bool MessageSign(const CKey &privkey, const std::string &message, std::string &signature)
Sign a message.
Definition: message.cpp:56
MessageVerificationResult::ERR_INVALID_ADDRESS
@ ERR_INVALID_ADDRESS
The provided address is invalid.
uint256
256-bit opaque blob.
Definition: uint256.h:127
SigningResultString
std::string SigningResultString(const SigningResult res)
Definition: message.cpp:76
MessageVerificationResult::ERR_PUBKEY_NOT_RECOVERED
@ ERR_PUBKEY_NOT_RECOVERED
A public key could not be recovered from the provided signature and message.
MessageVerificationResult::ERR_ADDRESS_NO_KEY
@ ERR_ADDRESS_NO_KEY
The provided address is valid but does not refer to a public key.
MessageVerify
MessageVerificationResult MessageVerify(const CChainParams &params, const std::string &address, const std::string &signature, const std::string &message)
Verify a signed message.
Definition: message.cpp:24
CKey
An encapsulated secp256k1 private key.
Definition: key.h:28
MessageHash
uint256 MessageHash(const std::string &message)
Hashes a message for signing and verification in a manner that prevents inadvertently signing a trans...
Definition: message.cpp:69
SigningResult::SIGNING_FAILED
@ SIGNING_FAILED
MessageVerificationResult::OK
@ OK
The message verification was successful.
MESSAGE_MAGIC
const std::string MESSAGE_MAGIC
Text used to signify that a signed message follows and to prevent inadvertently signing a transaction...
Definition: message.cpp:22