return EncodeBase58Check(vch);
}
+bool CMalleablePubKey::setvch(const std::vector<unsigned char> &vchPubKeyPair)
+{
+ CDataStream ssKey(vchPubKeyPair, SER_NETWORK, PROTOCOL_VERSION);
+ ssKey >> *this;
+
+ return IsValid();
+}
+
std::vector<unsigned char> CMalleablePubKey::Raw() const
{
CDataStream ssKey(SER_NETWORK, PROTOCOL_VERSION);
CKey keyL(pvchSecretL);
CKey keyH(pvchSecretH);
- if (!keyL.IsValid() || !keyL.IsValid())
+ if (!keyL.IsValid() || !keyH.IsValid())
return false;
vchSecretL = pvchSecretL;
CMalleablePubKey CMalleableKey::GetMalleablePubKey() const
{
- CKey L, H;
- L.SetSecret(vchSecretL, true);
- H.SetSecret(vchSecretH, true);
-
- std::vector<unsigned char> vchPubKeyL = L.GetPubKey().Raw();
- std::vector<unsigned char> vchPubKeyH = H.GetPubKey().Raw();
-
- return CMalleablePubKey(vchPubKeyL, vchPubKeyH);
+ CKey L(vchSecretL), H(vchSecretH);
+ return CMalleablePubKey(L.GetPubKey().Raw(), H.GetPubKey().Raw());
}
// Check ownership
throw key_error("CMalleableKey::CheckKeyVariant() : Unable to decode R value");
}
- CKey H;
- H.SetSecret(vchSecretH, true);
+ CKey H(vchSecretH);
std::vector<unsigned char> vchPubKeyH = H.GetPubKey().Raw();
CPoint point_H;
throw key_error("CMalleableKey::CheckKeyVariant() : Unable to decode R value");
}
- CKey H;
- H.SetSecret(vchSecretH, true);
+ CKey H(vchSecretH);
std::vector<unsigned char> vchPubKeyH = H.GetPubKey().Raw();
CPoint point_H;
CBigNum bnp = bnHash + bnh;
std::vector<unsigned char> vchp = bnp.getBytes();
- privKeyVariant.SetSecret(CSecret(vchp.begin(), vchp.end()), true);
+ privKeyVariant.SetSecret(CSecret(vchp.begin(), vchp.end()));
return true;
}
throw key_error("CMalleableKeyView::CMalleableKeyView() : L size must be 32 bytes");
if (b.vchSecretH.size() != 32)
- throw key_error("CMalleableKeyView::CMalleableKeyView() : L size must be 32 bytes");
+ throw key_error("CMalleableKeyView::CMalleableKeyView() : H size must be 32 bytes");
vchSecretL = b.vchSecretL;
- CKey H;
- H.SetSecret(b.vchSecretH, true);
-
+ CKey H(b.vchSecretH);
vchPubKeyH = H.GetPubKey().Raw();
}
{
vchSecretL = b.vchSecretL;
- CKey H;
- H.SetSecret(b.vchSecretH, true);
+ CKey H(b.vchSecretH);
vchPubKeyH = H.GetPubKey().Raw();
return (*this);
CMalleablePubKey CMalleableKeyView::GetMalleablePubKey() const
{
- CKey keyL;
- keyL.SetSecret(vchSecretL, true);
+ CKey keyL(vchSecretL);
return CMalleablePubKey(keyL.GetPubKey(), vchPubKeyH);
}