if (pkey == NULL)
throw key_error("CKey::CKey(const CKey&) : EC_KEY_dup failed");
fSet = b.fSet;
+ fCompressedPubKey = b.fCompressedPubKey;
}
CKey& CKey::operator=(const CKey& b)
if (!EC_KEY_copy(pkey, b.pkey))
throw key_error("CKey::operator=(const CKey&) : EC_KEY_copy failed");
fSet = b.fSet;
+ fCompressedPubKey = b.fCompressedPubKey;
return (*this);
}
CompareBigEndian(vch, len, half ? vchMaxModHalfOrder : vchMaxModOrder, 32) <= 0;
}
+bool CKey::ReserealizeSignature(std::vector<unsigned char>& vchSig)
+{
+ if (vchSig.empty())
+ return false;
+
+ unsigned char *pos = &vchSig[0];
+ ECDSA_SIG *sig = d2i_ECDSA_SIG(NULL, (const unsigned char **)&pos, vchSig.size());
+ if (sig == NULL)
+ return false;
+
+ bool ret = false;
+ int nSize = i2d_ECDSA_SIG(sig, NULL);
+ if (nSize > 0) {
+ vchSig.resize(nSize); // grow or shrink as needed
+
+ pos = &vchSig[0];
+ i2d_ECDSA_SIG(sig, &pos);
+
+ ret = true;
+ }
+
+ ECDSA_SIG_free(sig);
+
+ return ret;
+}
+
void CKey::MakeNewKey(bool fCompressed)
{
if (!EC_KEY_generate_key(pkey))
int nBitsS = BN_num_bits(sig->s);
if (nBitsR <= 256 && nBitsS <= 256)
{
- int nRecId = -1;
- for (int i=0; i<4; i++)
+ int8_t nRecId = -1;
+ for (int8_t i=0; i<4; i++)
{
CKey keyRec;
keyRec.fSet = true;