X-Git-Url: https://git.novaco.in/?a=blobdiff_plain;f=src%2Fkey.cpp;h=022d83afcd203667889ea1bd63e28661c9b5566c;hb=d4488b9d263e4799f7bb4a1aaa1f692aa995f517;hp=b1db7cbf0e6a6f313ce1509a6d659f4640412bba;hpb=5f3f7465db4444e49dd4a896f88c090b40d0a303;p=novacoin.git diff --git a/src/key.cpp b/src/key.cpp index b1db7cb..022d83a 100644 --- a/src/key.cpp +++ b/src/key.cpp @@ -725,6 +725,14 @@ std::string CMalleablePubKey::ToString() const return EncodeBase58Check(vch); } +bool CMalleablePubKey::setvch(const std::vector &vchPubKeyPair) +{ + CDataStream ssKey(vchPubKeyPair, SER_NETWORK, PROTOCOL_VERSION); + ssKey >> *this; + + return IsValid(); +} + std::vector CMalleablePubKey::Raw() const { CDataStream ssKey(SER_NETWORK, PROTOCOL_VERSION); @@ -804,7 +812,7 @@ bool CMalleableKey::SetSecrets(const CSecret &pvchSecretL, const CSecret &pvchSe CKey keyL(pvchSecretL); CKey keyH(pvchSecretH); - if (!keyL.IsValid() || !keyL.IsValid()) + if (!keyL.IsValid() || !keyH.IsValid()) return false; vchSecretL = pvchSecretL; @@ -815,14 +823,8 @@ bool CMalleableKey::SetSecrets(const CSecret &pvchSecretL, const CSecret &pvchSe CMalleablePubKey CMalleableKey::GetMalleablePubKey() const { - CKey L, H; - L.SetSecret(vchSecretL, true); - H.SetSecret(vchSecretH, true); - - std::vector vchPubKeyL = L.GetPubKey().Raw(); - std::vector vchPubKeyH = H.GetPubKey().Raw(); - - return CMalleablePubKey(vchPubKeyL, vchPubKeyH); + CKey L(vchSecretL), H(vchSecretH); + return CMalleablePubKey(L.GetPubKey().Raw(), H.GetPubKey().Raw()); } // Check ownership @@ -845,8 +847,7 @@ bool CMalleableKey::CheckKeyVariant(const CPubKey &R, const CPubKey &vchPubKeyVa throw key_error("CMalleableKey::CheckKeyVariant() : Unable to decode R value"); } - CKey H; - H.SetSecret(vchSecretH, true); + CKey H(vchSecretH); std::vector vchPubKeyH = H.GetPubKey().Raw(); CPoint point_H; @@ -915,8 +916,7 @@ bool CMalleableKey::CheckKeyVariant(const CPubKey &R, const CPubKey &vchPubKeyVa throw key_error("CMalleableKey::CheckKeyVariant() : Unable to decode R value"); } - CKey H; - H.SetSecret(vchSecretH, true); + CKey H(vchSecretH); std::vector vchPubKeyH = H.GetPubKey().Raw(); CPoint point_H; @@ -970,7 +970,7 @@ bool CMalleableKey::CheckKeyVariant(const CPubKey &R, const CPubKey &vchPubKeyVa CBigNum bnp = bnHash + bnh; std::vector vchp = bnp.getBytes(); - privKeyVariant.SetSecret(CSecret(vchp.begin(), vchp.end()), true); + privKeyVariant.SetSecret(CSecret(vchp.begin(), vchp.end())); return true; } @@ -1019,13 +1019,11 @@ CMalleableKeyView::CMalleableKeyView(const CMalleableKey &b) 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(); } @@ -1039,8 +1037,7 @@ CMalleableKeyView& CMalleableKeyView::operator=(const CMalleableKey &b) { vchSecretL = b.vchSecretL; - CKey H; - H.SetSecret(b.vchSecretH, true); + CKey H(b.vchSecretH); vchPubKeyH = H.GetPubKey().Raw(); return (*this); @@ -1052,8 +1049,7 @@ CMalleableKeyView::~CMalleableKeyView() CMalleablePubKey CMalleableKeyView::GetMalleablePubKey() const { - CKey keyL; - keyL.SetSecret(vchSecretL, true); + CKey keyL(vchSecretL); return CMalleablePubKey(keyL.GetPubKey(), vchPubKeyH); }