Add Sapling keys to CCryptoKeyStore::EncryptKeys
This commit is contained in:
parent
55f2889396
commit
85beb9c9ca
|
@ -445,10 +445,12 @@ bool CCryptoKeyStore::EncryptKeys(CKeyingMaterial& vMasterKeyIn)
|
||||||
CPubKey vchPubKey = key.GetPubKey();
|
CPubKey vchPubKey = key.GetPubKey();
|
||||||
CKeyingMaterial vchSecret(key.begin(), key.end());
|
CKeyingMaterial vchSecret(key.begin(), key.end());
|
||||||
std::vector<unsigned char> vchCryptedSecret;
|
std::vector<unsigned char> vchCryptedSecret;
|
||||||
if (!EncryptSecret(vMasterKeyIn, vchSecret, vchPubKey.GetHash(), vchCryptedSecret))
|
if (!EncryptSecret(vMasterKeyIn, vchSecret, vchPubKey.GetHash(), vchCryptedSecret)) {
|
||||||
return false;
|
return false;
|
||||||
if (!AddCryptedKey(vchPubKey, vchCryptedSecret))
|
}
|
||||||
|
if (!AddCryptedKey(vchPubKey, vchCryptedSecret)) {
|
||||||
return false;
|
return false;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
mapKeys.clear();
|
mapKeys.clear();
|
||||||
BOOST_FOREACH(SpendingKeyMap::value_type& mSpendingKey, mapSpendingKeys)
|
BOOST_FOREACH(SpendingKeyMap::value_type& mSpendingKey, mapSpendingKeys)
|
||||||
|
@ -459,12 +461,31 @@ bool CCryptoKeyStore::EncryptKeys(CKeyingMaterial& vMasterKeyIn)
|
||||||
CKeyingMaterial vchSecret(ss.begin(), ss.end());
|
CKeyingMaterial vchSecret(ss.begin(), ss.end());
|
||||||
libzcash::SproutPaymentAddress address = sk.address();
|
libzcash::SproutPaymentAddress address = sk.address();
|
||||||
std::vector<unsigned char> vchCryptedSecret;
|
std::vector<unsigned char> vchCryptedSecret;
|
||||||
if (!EncryptSecret(vMasterKeyIn, vchSecret, address.GetHash(), vchCryptedSecret))
|
if (!EncryptSecret(vMasterKeyIn, vchSecret, address.GetHash(), vchCryptedSecret)) {
|
||||||
return false;
|
return false;
|
||||||
if (!AddCryptedSpendingKey(address, sk.receiving_key(), vchCryptedSecret))
|
}
|
||||||
|
if (!AddCryptedSpendingKey(address, sk.receiving_key(), vchCryptedSecret)) {
|
||||||
return false;
|
return false;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
mapSpendingKeys.clear();
|
mapSpendingKeys.clear();
|
||||||
|
//! Sapling key support
|
||||||
|
BOOST_FOREACH(SaplingSpendingKeyMap::value_type& mSaplingSpendingKey, mapSaplingSpendingKeys)
|
||||||
|
{
|
||||||
|
const libzcash::SaplingSpendingKey &sk = mSaplingSpendingKey.second;
|
||||||
|
CSecureDataStream ss(SER_NETWORK, PROTOCOL_VERSION);
|
||||||
|
ss << sk;
|
||||||
|
CKeyingMaterial vchSecret(ss.begin(), ss.end());
|
||||||
|
libzcash::SaplingFullViewingKey fvk = sk.full_viewing_key();
|
||||||
|
std::vector<unsigned char> vchCryptedSecret;
|
||||||
|
if (!EncryptSecret(vMasterKeyIn, vchSecret, fvk.GetFingerprint(), vchCryptedSecret)) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
if (!AddCryptedSaplingSpendingKey(fvk, vchCryptedSecret)) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
mapSaplingSpendingKeys.clear();
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue