aboutsummaryrefslogtreecommitdiff
path: root/src/key.cpp
diff options
context:
space:
mode:
authorPieter Wuille <pieter.wuille@gmail.com>2013-04-30 21:56:04 +0200
committerPieter Wuille <sipa@ulyssis.org>2013-05-30 05:18:42 +0200
commit5d891489ab7828ad8db15e85bb63e2f13f021a6a (patch)
tree24cd213e276977570de5b299872368bdf70ac929 /src/key.cpp
parentec0004aca0a2bf11f99c9587ddb2bf8ea818d3bb (diff)
Make CPubKey statically allocated
Diffstat (limited to 'src/key.cpp')
-rw-r--r--src/key.cpp14
1 files changed, 8 insertions, 6 deletions
diff --git a/src/key.cpp b/src/key.cpp
index 75114c6afe..a99363c124 100644
--- a/src/key.cpp
+++ b/src/key.cpp
@@ -258,11 +258,11 @@ CPrivKey CKey::GetPrivKey() const
bool CKey::SetPubKey(const CPubKey& vchPubKey)
{
- const unsigned char* pbegin = &vchPubKey.vchPubKey[0];
- if (o2i_ECPublicKey(&pkey, &pbegin, vchPubKey.vchPubKey.size()))
+ const unsigned char* pbegin = vchPubKey.begin();
+ if (o2i_ECPublicKey(&pkey, &pbegin, vchPubKey.size()))
{
fSet = true;
- if (vchPubKey.vchPubKey.size() == 33)
+ if (vchPubKey.size() == 33)
SetCompressedPubKey();
return true;
}
@@ -276,11 +276,13 @@ CPubKey CKey::GetPubKey() const
int nSize = i2o_ECPublicKey(pkey, NULL);
if (!nSize)
throw key_error("CKey::GetPubKey() : i2o_ECPublicKey failed");
- std::vector<unsigned char> vchPubKey(nSize, 0);
- unsigned char* pbegin = &vchPubKey[0];
+ assert(nSize <= 65);
+ CPubKey ret;
+ unsigned char *pbegin = ret.begin();
if (i2o_ECPublicKey(pkey, &pbegin) != nSize)
throw key_error("CKey::GetPubKey() : i2o_ECPublicKey returned unexpected size");
- return CPubKey(vchPubKey);
+ assert((int)ret.size() == nSize);
+ return ret;
}
bool CKey::Sign(uint256 hash, std::vector<unsigned char>& vchSig)