Cache note decryptors in encrypted keystore

This commit is contained in:
Jack Grigg
2016-09-29 11:34:59 +13:00
parent 6bffc46a87
commit ad041fceec
3 changed files with 24 additions and 4 deletions

View File

@@ -318,13 +318,15 @@ bool CCryptoKeyStore::AddSpendingKey(const libzcash::SpendingKey &sk)
if (!EncryptSecret(vMasterKey, vchSecret, address.GetHash(), vchCryptedSecret))
return false;
if (!AddCryptedSpendingKey(address, vchCryptedSecret))
if (!AddCryptedSpendingKey(address, sk.viewing_key(), vchCryptedSecret))
return false;
}
return true;
}
bool CCryptoKeyStore::AddCryptedSpendingKey(const libzcash::PaymentAddress &address, const std::vector<unsigned char> &vchCryptedSecret)
bool CCryptoKeyStore::AddCryptedSpendingKey(const libzcash::PaymentAddress &address,
const libzcash::ViewingKey &vk,
const std::vector<unsigned char> &vchCryptedSecret)
{
{
LOCK(cs_KeyStore);
@@ -332,6 +334,7 @@ bool CCryptoKeyStore::AddCryptedSpendingKey(const libzcash::PaymentAddress &addr
return false;
mapCryptedSpendingKeys[address] = vchCryptedSecret;
mapNoteDecryptors.insert(std::make_pair(address, ZCNoteDecryption(vk)));
}
return true;
}
@@ -383,7 +386,7 @@ bool CCryptoKeyStore::EncryptKeys(CKeyingMaterial& vMasterKeyIn)
std::vector<unsigned char> vchCryptedSecret;
if (!EncryptSecret(vMasterKeyIn, vchSecret, address.GetHash(), vchCryptedSecret))
return false;
if (!AddCryptedSpendingKey(address, vchCryptedSecret))
if (!AddCryptedSpendingKey(address, sk.viewing_key(), vchCryptedSecret))
return false;
}
mapSpendingKeys.clear();