mirror of
https://github.com/bitcoin/bitcoin.git
synced 2025-11-10 22:18:54 +01:00
23
src/key.cpp
23
src/key.cpp
@@ -166,9 +166,12 @@ public:
|
||||
assert(nSize == nSize2);
|
||||
}
|
||||
|
||||
bool SetPrivKey(const CPrivKey &privkey) {
|
||||
bool SetPrivKey(const CPrivKey &privkey, bool fSkipCheck=false) {
|
||||
const unsigned char* pbegin = &privkey[0];
|
||||
if (d2i_ECPrivateKey(&pkey, &pbegin, privkey.size())) {
|
||||
if(fSkipCheck)
|
||||
return true;
|
||||
|
||||
// d2i_ECPrivateKey returns true if parsing succeeds.
|
||||
// This doesn't necessarily mean the key is valid.
|
||||
if (EC_KEY_check_key(pkey))
|
||||
@@ -411,6 +414,24 @@ bool CKey::SignCompact(const uint256 &hash, std::vector<unsigned char>& vchSig)
|
||||
return true;
|
||||
}
|
||||
|
||||
bool CKey::Load(CPrivKey &privkey, CPubKey &vchPubKey, bool fSkipCheck=false) {
|
||||
CECKey key;
|
||||
if (!key.SetPrivKey(privkey, fSkipCheck))
|
||||
return false;
|
||||
|
||||
key.GetSecretBytes(vch);
|
||||
fCompressed = vchPubKey.IsCompressed();
|
||||
fValid = true;
|
||||
|
||||
if (fSkipCheck)
|
||||
return true;
|
||||
|
||||
if (GetPubKey() != vchPubKey)
|
||||
return false;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
bool CPubKey::Verify(const uint256 &hash, const std::vector<unsigned char>& vchSig) const {
|
||||
if (!IsValid())
|
||||
return false;
|
||||
|
||||
Reference in New Issue
Block a user