mirror of
https://github.com/dashpay/dash.git
synced 2024-12-30 14:25:53 +01:00
611879aa6d
* Support passing CKeyID to CMessageSigner/CHashSigner * Use Dash addresses instead of raw public keys for sporks The spork addresses are identical to the previously used public keys. Also use CKeyID/CKey directly inside CSporkManager instead of parsing the addresses/keys over and over. The default spork key (from chainparams) is initialized with InitDefaultSporkAddress(). SetPrivKey parses the private key now and stores it in sporkPrivKey instead of parsing it in CSporkMessage::Sign(). * Allow setting of spork address via command line * Remove unused strMasternodePaymentsPubKey chainparam Traces from the past... * Review fixes 1. Remove the need for InitDefaultSporkAddress 2. Remove bogus checks for hex private keys 3. Alphabetical order for new include 4. Add . to help string * Add regtest spork key As this key is not meant to be private, the private key is also added in the form of a comment (for later use in regtests) * Review fixes
39 lines
1.8 KiB
C++
39 lines
1.8 KiB
C++
// Copyright (c) 2014-2017 The Dash Core developers
|
|
// Distributed under the MIT/X11 software license, see the accompanying
|
|
// file COPYING or http://www.opensource.org/licenses/mit-license.php.
|
|
|
|
#ifndef MESSAGESIGNER_H
|
|
#define MESSAGESIGNER_H
|
|
|
|
#include "key.h"
|
|
|
|
/** Helper class for signing messages and checking their signatures
|
|
*/
|
|
class CMessageSigner
|
|
{
|
|
public:
|
|
/// Set the private/public key values, returns true if successful
|
|
static bool GetKeysFromSecret(const std::string& strSecret, CKey& keyRet, CPubKey& pubkeyRet);
|
|
/// Sign the message, returns true if successful
|
|
static bool SignMessage(const std::string& strMessage, std::vector<unsigned char>& vchSigRet, const CKey& key);
|
|
/// Verify the message signature, returns true if succcessful
|
|
static bool VerifyMessage(const CPubKey& pubkey, const std::vector<unsigned char>& vchSig, const std::string& strMessage, std::string& strErrorRet);
|
|
/// Verify the message signature, returns true if succcessful
|
|
static bool VerifyMessage(const CKeyID& keyID, const std::vector<unsigned char>& vchSig, const std::string& strMessage, std::string& strErrorRet);
|
|
};
|
|
|
|
/** Helper class for signing hashes and checking their signatures
|
|
*/
|
|
class CHashSigner
|
|
{
|
|
public:
|
|
/// Sign the hash, returns true if successful
|
|
static bool SignHash(const uint256& hash, const CKey& key, std::vector<unsigned char>& vchSigRet);
|
|
/// Verify the hash signature, returns true if succcessful
|
|
static bool VerifyHash(const uint256& hash, const CPubKey& pubkey, const std::vector<unsigned char>& vchSig, std::string& strErrorRet);
|
|
/// Verify the hash signature, returns true if succcessful
|
|
static bool VerifyHash(const uint256& hash, const CKeyID& keyID, const std::vector<unsigned char>& vchSig, std::string& strErrorRet);
|
|
};
|
|
|
|
#endif
|