CKey::SetPubKey(const std::string&);

This commit is contained in:
JoelKatz
2012-05-21 06:04:51 -07:00
parent 710b5ac1e3
commit 4e1f435655

View File

@@ -221,16 +221,26 @@ public:
return vchPrivKey;
}
bool SetPubKey(const std::vector<unsigned char>& vchPubKey)
bool SetPubKey(const void *ptr, size_t len)
{
const unsigned char* pbegin = &vchPubKey[0];
if (!o2i_ECPublicKey(&pkey, &pbegin, vchPubKey.size()))
const unsigned char* pbegin = static_cast<const unsigned char *>(ptr);
if (!o2i_ECPublicKey(&pkey, &pbegin, len))
return false;
EC_KEY_set_conv_form(pkey, POINT_CONVERSION_COMPRESSED);
fSet = true;
return true;
}
bool SetPubKey(const std::vector<unsigned char>& vchPubKey)
{
return SetPubKey(&vchPubKey[0], vchPubKey.size());
}
bool SetPubKey(const std::string& pubKey)
{
return SetPubKey(pubKey.data(), pubKey.size());
}
std::vector<unsigned char> GetPubKey() const
{
unsigned int nSize = i2o_ECPublicKey(pkey, NULL);