Merge branch 'master' of https://github.com/zcash/zcash into dev
This commit is contained in:
@@ -172,11 +172,11 @@ static bool DecryptSproutSpendingKey(const CKeyingMaterial& vMasterKey,
|
||||
|
||||
static bool DecryptSaplingSpendingKey(const CKeyingMaterial& vMasterKey,
|
||||
const std::vector<unsigned char>& vchCryptedSecret,
|
||||
const libzcash::SaplingFullViewingKey& fvk,
|
||||
const libzcash::SaplingExtendedFullViewingKey& extfvk,
|
||||
libzcash::SaplingExtendedSpendingKey& sk)
|
||||
{
|
||||
CKeyingMaterial vchSecret;
|
||||
if (!DecryptSecret(vMasterKey, vchCryptedSecret, fvk.GetFingerprint(), vchSecret))
|
||||
if (!DecryptSecret(vMasterKey, vchCryptedSecret, extfvk.fvk.GetFingerprint(), vchSecret))
|
||||
return false;
|
||||
|
||||
if (vchSecret.size() != ZIP32_XSK_SIZE)
|
||||
@@ -184,7 +184,7 @@ static bool DecryptSaplingSpendingKey(const CKeyingMaterial& vMasterKey,
|
||||
|
||||
CSecureDataStream ss(vchSecret, SER_NETWORK, PROTOCOL_VERSION);
|
||||
ss >> sk;
|
||||
return sk.expsk.full_viewing_key() == fvk;
|
||||
return sk.expsk.full_viewing_key() == extfvk.fvk;
|
||||
}
|
||||
|
||||
bool CCryptoKeyStore::SetCrypted()
|
||||
@@ -263,10 +263,10 @@ bool CCryptoKeyStore::Unlock(const CKeyingMaterial& vMasterKeyIn)
|
||||
CryptedSaplingSpendingKeyMap::const_iterator miSapling = mapCryptedSaplingSpendingKeys.begin();
|
||||
for (; miSapling != mapCryptedSaplingSpendingKeys.end(); ++miSapling)
|
||||
{
|
||||
const libzcash::SaplingFullViewingKey &fvk = (*miSapling).first;
|
||||
const libzcash::SaplingExtendedFullViewingKey &extfvk = (*miSapling).first;
|
||||
const std::vector<unsigned char> &vchCryptedSecret = (*miSapling).second;
|
||||
libzcash::SaplingExtendedSpendingKey sk;
|
||||
if (!DecryptSaplingSpendingKey(vMasterKeyIn, vchCryptedSecret, fvk, sk))
|
||||
if (!DecryptSaplingSpendingKey(vMasterKeyIn, vchCryptedSecret, extfvk, sk))
|
||||
{
|
||||
keyFail = true;
|
||||
break;
|
||||
@@ -467,12 +467,12 @@ bool CCryptoKeyStore::AddSaplingSpendingKey(
|
||||
CSecureDataStream ss(SER_NETWORK, PROTOCOL_VERSION);
|
||||
ss << sk;
|
||||
CKeyingMaterial vchSecret(ss.begin(), ss.end());
|
||||
auto fvk = sk.expsk.full_viewing_key();
|
||||
if (!EncryptSecret(vMasterKey, vchSecret, fvk.GetFingerprint(), vchCryptedSecret)) {
|
||||
auto extfvk = sk.ToXFVK();
|
||||
if (!EncryptSecret(vMasterKey, vchSecret, extfvk.fvk.GetFingerprint(), vchCryptedSecret)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if (!AddCryptedSaplingSpendingKey(fvk, vchCryptedSecret, defaultAddr)) {
|
||||
if (!AddCryptedSaplingSpendingKey(extfvk, vchCryptedSecret, defaultAddr)) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
@@ -496,7 +496,7 @@ bool CCryptoKeyStore::AddCryptedSproutSpendingKey(
|
||||
}
|
||||
|
||||
bool CCryptoKeyStore::AddCryptedSaplingSpendingKey(
|
||||
const libzcash::SaplingFullViewingKey &fvk,
|
||||
const libzcash::SaplingExtendedFullViewingKey &extfvk,
|
||||
const std::vector<unsigned char> &vchCryptedSecret,
|
||||
const libzcash::SaplingPaymentAddress &defaultAddr)
|
||||
{
|
||||
@@ -507,11 +507,11 @@ bool CCryptoKeyStore::AddCryptedSaplingSpendingKey(
|
||||
}
|
||||
|
||||
// if SaplingFullViewingKey is not in SaplingFullViewingKeyMap, add it
|
||||
if (!AddSaplingFullViewingKey(fvk, defaultAddr)) {
|
||||
if (!AddSaplingFullViewingKey(extfvk.fvk, defaultAddr)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
mapCryptedSaplingSpendingKeys[fvk] = vchCryptedSecret;
|
||||
mapCryptedSaplingSpendingKeys[extfvk] = vchCryptedSecret;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
@@ -540,11 +540,11 @@ bool CCryptoKeyStore::GetSaplingSpendingKey(const libzcash::SaplingFullViewingKe
|
||||
if (!IsCrypted())
|
||||
return CBasicKeyStore::GetSaplingSpendingKey(fvk, skOut);
|
||||
|
||||
CryptedSaplingSpendingKeyMap::const_iterator mi = mapCryptedSaplingSpendingKeys.find(fvk);
|
||||
if (mi != mapCryptedSaplingSpendingKeys.end())
|
||||
{
|
||||
const std::vector<unsigned char> &vchCryptedSecret = (*mi).second;
|
||||
return DecryptSaplingSpendingKey(vMasterKey, vchCryptedSecret, fvk, skOut);
|
||||
for (auto entry : mapCryptedSaplingSpendingKeys) {
|
||||
if (entry.first.fvk == fvk) {
|
||||
const std::vector<unsigned char> &vchCryptedSecret = entry.second;
|
||||
return DecryptSaplingSpendingKey(vMasterKey, vchCryptedSecret, entry.first, skOut);
|
||||
}
|
||||
}
|
||||
}
|
||||
return false;
|
||||
@@ -611,12 +611,12 @@ bool CCryptoKeyStore::EncryptKeys(CKeyingMaterial& vMasterKeyIn)
|
||||
CSecureDataStream ss(SER_NETWORK, PROTOCOL_VERSION);
|
||||
ss << sk;
|
||||
CKeyingMaterial vchSecret(ss.begin(), ss.end());
|
||||
libzcash::SaplingFullViewingKey fvk = sk.expsk.full_viewing_key();
|
||||
auto extfvk = sk.ToXFVK();
|
||||
std::vector<unsigned char> vchCryptedSecret;
|
||||
if (!EncryptSecret(vMasterKeyIn, vchSecret, fvk.GetFingerprint(), vchCryptedSecret)) {
|
||||
if (!EncryptSecret(vMasterKeyIn, vchSecret, extfvk.fvk.GetFingerprint(), vchCryptedSecret)) {
|
||||
return false;
|
||||
}
|
||||
if (!AddCryptedSaplingSpendingKey(fvk, vchCryptedSecret, sk.DefaultAddress())) {
|
||||
if (!AddCryptedSaplingSpendingKey(extfvk, vchCryptedSecret, sk.DefaultAddress())) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user