Bitcoin Core
31.1.0
P2P Digital Currency
Toggle main menu visibility
Loading...
Searching...
No Matches
src
common
signmessage.h
Go to the documentation of this file.
1
// Copyright (c) 2009-2010 Satoshi Nakamoto
2
// Copyright (c) 2009-present 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_COMMON_SIGNMESSAGE_H
7
#define BITCOIN_COMMON_SIGNMESSAGE_H
8
9
#include <
uint256.h
>
10
11
#include <string>
12
13
class
CKey
;
14
15
extern
const
std::string
MESSAGE_MAGIC
;
16
23
enum class
MessageVerificationResult
{
25
ERR_INVALID_ADDRESS
,
26
28
ERR_ADDRESS_NO_KEY
,
29
31
ERR_MALFORMED_SIGNATURE
,
32
34
ERR_PUBKEY_NOT_RECOVERED
,
35
37
ERR_NOT_SIGNED
,
38
40
OK
41
};
42
43
enum class
SigningResult
{
44
OK
,
45
PRIVATE_KEY_NOT_AVAILABLE
,
46
SIGNING_FAILED
,
47
};
48
54
MessageVerificationResult
MessageVerify
(
55
const
std::string& address,
56
const
std::string& signature,
57
const
std::string& message);
58
64
bool
MessageSign
(
65
const
CKey
& privkey,
66
const
std::string& message,
67
std::string& signature);
68
73
uint256
MessageHash
(
const
std::string& message);
74
75
std::string
SigningResultString
(
SigningResult
res);
76
77
#endif
// BITCOIN_COMMON_SIGNMESSAGE_H
CKey
An encapsulated private key.
Definition
key.h:36
uint256
256-bit opaque blob.
Definition
uint256.h:195
MESSAGE_MAGIC
const std::string MESSAGE_MAGIC
Text used to signify that a signed message follows and to prevent inadvertently signing a transaction...
Definition
signmessage.cpp:24
MessageHash
uint256 MessageHash(const std::string &message)
Hashes a message for signing and verification in a manner that prevents inadvertently signing a trans...
Definition
signmessage.cpp:73
SigningResult
SigningResult
Definition
signmessage.h:43
SigningResult::PRIVATE_KEY_NOT_AVAILABLE
@ PRIVATE_KEY_NOT_AVAILABLE
Definition
signmessage.h:45
SigningResult::SIGNING_FAILED
@ SIGNING_FAILED
Definition
signmessage.h:46
MessageVerificationResult
MessageVerificationResult
The result of a signed message verification.
Definition
signmessage.h:23
MessageVerificationResult::ERR_MALFORMED_SIGNATURE
@ ERR_MALFORMED_SIGNATURE
The provided signature couldn't be parsed (maybe invalid base64).
Definition
signmessage.h:31
MessageVerificationResult::ERR_INVALID_ADDRESS
@ ERR_INVALID_ADDRESS
The provided address is invalid.
Definition
signmessage.h:25
MessageVerificationResult::ERR_ADDRESS_NO_KEY
@ ERR_ADDRESS_NO_KEY
The provided address is valid but does not refer to a public key.
Definition
signmessage.h:28
MessageVerificationResult::ERR_NOT_SIGNED
@ ERR_NOT_SIGNED
The message was not signed with the private key of the provided address.
Definition
signmessage.h:37
MessageVerificationResult::OK
@ OK
The message verification was successful.
Definition
signmessage.h:40
MessageVerificationResult::ERR_PUBKEY_NOT_RECOVERED
@ ERR_PUBKEY_NOT_RECOVERED
A public key could not be recovered from the provided signature and message.
Definition
signmessage.h:34
MessageSign
bool MessageSign(const CKey &privkey, const std::string &message, std::string &signature)
Sign a message.
Definition
signmessage.cpp:57
SigningResultString
std::string SigningResultString(SigningResult res)
Definition
signmessage.cpp:81
MessageVerify
MessageVerificationResult MessageVerify(const std::string &address, const std::string &signature, const std::string &message)
Verify a signed message.
Definition
signmessage.cpp:26
uint256.h
Generated on
for Bitcoin Core by
1.17.0