aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorPieter Wuille <pieter.wuille@gmail.com>2011-07-03 15:33:01 +0200
committerMatt Corallo <matt@bluematt.me>2011-07-13 02:11:25 +0200
commit0efda1a79eab6dd2e101edc615c6dd14138c31a2 (patch)
tree948076f3e360c60969f298edc0e08bd74146b616 /src
parentb6b039d84ed3d1616cb97ee45ff24ec343efbed0 (diff)
Do not use obsolete CPrivKey for passing keys around
Diffstat (limited to 'src')
-rw-r--r--src/key.h16
-rw-r--r--src/keystore.cpp6
-rw-r--r--src/keystore.h8
-rw-r--r--src/script.cpp12
4 files changed, 12 insertions, 30 deletions
diff --git a/src/key.h b/src/key.h
index c0fce18bf3..c43e4ee235 100644
--- a/src/key.h
+++ b/src/key.h
@@ -220,22 +220,6 @@ public:
return false;
return true;
}
-
- static bool Sign(const CPrivKey& vchPrivKey, uint256 hash, std::vector<unsigned char>& vchSig)
- {
- CKey key;
- if (!key.SetPrivKey(vchPrivKey))
- return false;
- return key.Sign(hash, vchSig);
- }
-
- static bool Verify(const std::vector<unsigned char>& vchPubKey, uint256 hash, const std::vector<unsigned char>& vchSig)
- {
- CKey key;
- if (!key.SetPubKey(vchPubKey))
- return false;
- return key.Verify(hash, vchSig);
- }
};
#endif
diff --git a/src/keystore.cpp b/src/keystore.cpp
index f659495a1a..de13958a8b 100644
--- a/src/keystore.cpp
+++ b/src/keystore.cpp
@@ -100,7 +100,7 @@ bool CCryptoKeyStore::AddCryptedKey(const std::vector<unsigned char> &vchPubKey,
return true;
}
-bool CCryptoKeyStore::GetPrivKey(const std::vector<unsigned char> &vchPubKey, CPrivKey& keyOut) const
+bool CCryptoKeyStore::GetPrivKey(const std::vector<unsigned char> &vchPubKey, CKey& keyOut) const
{
CRITICAL_BLOCK(cs_vMasterKey)
{
@@ -114,9 +114,7 @@ bool CCryptoKeyStore::GetPrivKey(const std::vector<unsigned char> &vchPubKey, CP
CSecret vchSecret;
if (!DecryptSecret(vMasterKey, (*mi).second, Hash((*mi).first.begin(), (*mi).first.end()), vchSecret))
return false;
- CKey key;
- key.SetSecret(vchSecret);
- keyOut = key.GetPrivKey();
+ keyOut.SetSecret(vchSecret);
return true;
}
}
diff --git a/src/keystore.h b/src/keystore.h
index 8d445befea..0dc09f05b8 100644
--- a/src/keystore.h
+++ b/src/keystore.h
@@ -13,7 +13,7 @@ public:
virtual bool AddKey(const CKey& key) =0;
virtual bool HaveKey(const std::vector<unsigned char> &vchPubKey) const =0;
- virtual bool GetPrivKey(const std::vector<unsigned char> &vchPubKey, CPrivKey& keyOut) const =0;
+ virtual bool GetPrivKey(const std::vector<unsigned char> &vchPubKey, CKey& keyOut) const =0;
virtual std::vector<unsigned char> GenerateNewKey();
};
@@ -30,12 +30,12 @@ public:
{
return (mapKeys.count(vchPubKey) > 0);
}
- bool GetPrivKey(const std::vector<unsigned char> &vchPubKey, CPrivKey& keyOut) const
+ bool GetPrivKey(const std::vector<unsigned char> &vchPubKey, CKey& keyOut) const
{
std::map<std::vector<unsigned char>, CPrivKey>::const_iterator mi = mapKeys.find(vchPubKey);
if (mi != mapKeys.end())
{
- keyOut = (*mi).second;
+ keyOut.SetPrivKey((*mi).second);
return true;
}
return false;
@@ -109,7 +109,7 @@ public:
return CBasicKeyStore::HaveKey(vchPubKey);
return mapCryptedKeys.count(vchPubKey) > 0;
}
- bool GetPrivKey(const std::vector<unsigned char> &vchPubKey, CPrivKey& keyOut) const;
+ bool GetPrivKey(const std::vector<unsigned char> &vchPubKey, CKey& keyOut) const;
};
#endif
diff --git a/src/script.cpp b/src/script.cpp
index 13a53d6b9c..aa7f1f5116 100644
--- a/src/script.cpp
+++ b/src/script.cpp
@@ -1038,13 +1038,13 @@ bool Solver(const CKeyStore& keystore, const CScript& scriptPubKey, uint256 hash
{
// Sign
const valtype& vchPubKey = item.second;
- CPrivKey privkey;
- if (!keystore.GetPrivKey(vchPubKey, privkey))
+ CKey key;
+ if (!keystore.GetPrivKey(vchPubKey, key))
return false;
if (hash != 0)
{
vector<unsigned char> vchSig;
- if (!CKey::Sign(privkey, hash, vchSig))
+ if (!key.Sign(hash, vchSig))
return false;
vchSig.push_back((unsigned char)nHashType);
scriptSigRet << vchSig;
@@ -1057,13 +1057,13 @@ bool Solver(const CKeyStore& keystore, const CScript& scriptPubKey, uint256 hash
if (mi == mapPubKeys.end())
return false;
const vector<unsigned char>& vchPubKey = (*mi).second;
- CPrivKey privkey;
- if (!keystore.GetPrivKey(vchPubKey, privkey))
+ CKey key;
+ if (!keystore.GetPrivKey(vchPubKey, key))
return false;
if (hash != 0)
{
vector<unsigned char> vchSig;
- if (!CKey::Sign(privkey, hash, vchSig))
+ if (!key.Sign(hash, vchSig))
return false;
vchSig.push_back((unsigned char)nHashType);
scriptSigRet << vchSig << vchPubKey;