X-Git-Url: https://git.novaco.in/?a=blobdiff_plain;f=src%2Fkeystore.cpp;fp=src%2Fkeystore.cpp;h=ef617484f8b52ffc5e8f0271eda551ca0cb2e972;hb=b032c4a33e27deebe9210347048998ecc4624ee4;hp=fb85da10f59472072e9ed962ae2cb7ee517aa978;hpb=f94158ea104e435166e6e6074f0d941b903267eb;p=novacoin.git diff --git a/src/keystore.cpp b/src/keystore.cpp index fb85da1..ef61748 100644 --- a/src/keystore.cpp +++ b/src/keystore.cpp @@ -269,3 +269,33 @@ bool CCryptoKeyStore::EncryptKeys(CKeyingMaterial& vMasterKeyIn) } return true; } + +bool CCryptoKeyStore::DecryptKeys(const CKeyingMaterial& vMasterKeyIn) +{ + { + LOCK(cs_KeyStore); + if (!IsCrypted()) + return false; + + CryptedKeyMap::const_iterator mi = mapCryptedKeys.begin(); + for (; mi != mapCryptedKeys.end(); ++mi) + { + const CPubKey &vchPubKey = (*mi).second.first; + const std::vector &vchCryptedSecret = (*mi).second.second; + CSecret vchSecret; + if(!DecryptSecret(vMasterKeyIn, vchCryptedSecret, vchPubKey.GetHash(), vchSecret)) + return false; + if (vchSecret.size() != 32) + return false; + CKey key; + key.SetPubKey(vchPubKey); + key.SetSecret(vchSecret); + if (!CBasicKeyStore::AddKey(key)) + return false; + } + + mapCryptedKeys.clear(); + } + + return true; +}