X-Git-Url: https://git.novaco.in/?p=novacoin.git;a=blobdiff_plain;f=src%2Frpcwallet.cpp;h=c1be5369c3a0c461a6ea2ff8fdcc4094a01f11fc;hp=22beb606d513390a38a90e9f752d675c93733692;hb=b8dd44c350c3fb0b958cea2baba8aab268f44cf2;hpb=a4bd78df61a14ec83f4a2f71edb0e18b434a8779 diff --git a/src/rpcwallet.cpp b/src/rpcwallet.cpp index 22beb60..c1be536 100644 --- a/src/rpcwallet.cpp +++ b/src/rpcwallet.cpp @@ -1893,9 +1893,26 @@ Value adjustmalleablekey(const Array& params, bool fHelp) CKey privKeyVariant; CPubKey vchPubKeyVariant = CPubKey(ParseHex(params[1].get_str())); - CPubKey vchR = CPubKey(ParseHex(params[2].get_str())); - if (!malleableKey.CheckKeyVariant(vchR,vchPubKeyVariant, privKeyVariant)) { + std::vector vchR = ParseHex(params[2].get_str()); + + CPubKey R; + if (vchR.size() == 33) + R = CPubKey(vchR); + else { + // R is encrypted + CSecret pvchSecretL, pvchSecretH; + + malleableKey.GetSecrets(pvchSecretL, pvchSecretH); + CKey key; + key.SetSecret(pvchSecretL); + + std::vector vchDecryptedR; + key.DecryptData(vchR, vchDecryptedR); + R = CPubKey(vchDecryptedR); + } + + if (!malleableKey.CheckKeyVariant(R,vchPubKeyVariant, privKeyVariant)) { throw runtime_error("Unable to calculate the private key"); } @@ -1927,10 +1944,15 @@ Value adjustmalleablepubkey(const Array& params, bool fHelp) CPubKey R, vchPubKeyVariant; malleablePubKey.GetVariant(R, vchPubKeyVariant); + std::vector encryptedR; + malleablePubKey.GetL().EncryptData(R.Raw(), encryptedR); + Object result; result.push_back(Pair("R", HexStr(R.Raw()))); + result.push_back(Pair("Rcrypted", HexStr(encryptedR))); result.push_back(Pair("PubkeyVariant", HexStr(vchPubKeyVariant.Raw()))); result.push_back(Pair("KeyVariantID", CBitcoinAddress(vchPubKeyVariant.GetID()).ToString())); + return result; }