本文整理匯總了C++中EncryptSecret函數的典型用法代碼示例。如果您正苦於以下問題:C++ EncryptSecret函數的具體用法?C++ EncryptSecret怎麽用?C++ EncryptSecret使用的例子?那麽, 這裏精選的函數代碼示例或許可以為您提供幫助。
在下文中一共展示了EncryptSecret函數的6個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的C++代碼示例。
示例1: assert
bool CHDSeed::Encrypt(CKeyingMaterial& vMasterKeyIn)
{
assert(sizeof(m_UUID) == WALLET_CRYPTO_IV_SIZE);
encryptedMnemonic.clear();
if (!EncryptSecret(vMasterKeyIn, CKeyingMaterial(unencryptedMnemonic.begin(), unencryptedMnemonic.end()), std::vector<unsigned char>(m_UUID.begin(), m_UUID.end()), encryptedMnemonic))
return false;
SecureUnsignedCharVector masterKeyPrivEncoded(BIP32_EXTKEY_SIZE);
masterKeyPriv.Encode(masterKeyPrivEncoded.data());
if (!EncryptSecret(vMasterKeyIn, CKeyingMaterial(masterKeyPrivEncoded.begin(), masterKeyPrivEncoded.end()), masterKeyPub.pubkey.GetHash(), masterKeyPrivEncrypted))
return false;
SecureUnsignedCharVector purposeKeyPrivEncoded(BIP32_EXTKEY_SIZE);
purposeKeyPriv.Encode(purposeKeyPrivEncoded.data());
if (!EncryptSecret(vMasterKeyIn, CKeyingMaterial(purposeKeyPrivEncoded.begin(), purposeKeyPrivEncoded.end()), purposeKeyPub.pubkey.GetHash(), purposeKeyPrivEncrypted))
return false;
SecureUnsignedCharVector cointypeKeyPrivEncoded(BIP32_EXTKEY_SIZE);
cointypeKeyPriv.Encode(cointypeKeyPrivEncoded.data());
if (!EncryptSecret(vMasterKeyIn, CKeyingMaterial(cointypeKeyPrivEncoded.begin(), cointypeKeyPrivEncoded.end()), cointypeKeyPub.pubkey.GetHash(), cointypeKeyPrivEncrypted))
return false;
encrypted = true;
vMasterKey = vMasterKeyIn;
return true;
}
示例2: assert
bool CAccountHD::Encrypt(const CKeyingMaterial& vMasterKeyIn)
{
assert(sizeof(accountUUID) == WALLET_CRYPTO_IV_SIZE);
if (IsReadOnly())
{
return true;
}
// NB! We don't encrypt the keystores for HD accounts - as they only contain public keys.
// Encrypt account key
SecureUnsignedCharVector accountKeyPrivEncoded(BIP32_EXTKEY_SIZE);
accountKeyPriv.Encode(accountKeyPrivEncoded.data());
if (!EncryptSecret(vMasterKeyIn, CKeyingMaterial(accountKeyPrivEncoded.begin(), accountKeyPrivEncoded.end()), std::vector<unsigned char>(accountUUID.begin(), accountUUID.end()), accountKeyPrivEncrypted))
return false;
// Encrypt primary chain key
SecureUnsignedCharVector primaryChainKeyPrivEncoded(BIP32_EXTKEY_SIZE);
primaryChainKeyPriv.Encode(primaryChainKeyPrivEncoded.data());
if (!EncryptSecret(vMasterKeyIn, CKeyingMaterial(primaryChainKeyPrivEncoded.begin(), primaryChainKeyPrivEncoded.end()), primaryChainKeyPub.pubkey.GetHash(), primaryChainKeyEncrypted))
return false;
// Encrypt change chain key
SecureUnsignedCharVector changeChainKeyPrivEncoded(BIP32_EXTKEY_SIZE);
changeChainKeyPriv.Encode(changeChainKeyPrivEncoded.data());
if (!EncryptSecret(vMasterKeyIn, CKeyingMaterial(changeChainKeyPrivEncoded.begin(), changeChainKeyPrivEncoded.end()), changeChainKeyPub.pubkey.GetHash(), changeChainKeyEncrypted))
return false;
encrypted = true;
return true;
}
示例3: LOCK
bool CCryptoKeyStore::EncryptKeys(CKeyingMaterial& vMasterKeyIn)
{
{
LOCK(cs_KeyStore);
if (!mapCryptedKeys.empty() || IsCrypted())
return false;
fUseCrypto = true;
BOOST_FOREACH(KeyMap::value_type& mKey, mapKeys)
{
//const CKey &key = mKey.second;
//CPubKey vchPubKey = key.GetPubKey();
//CKeyingMaterial vchSecret(key.begin(), key.end());
CKey key;
if (!key.SetSecret(mKey.second.first, mKey.second.second))
return false;
const CPubKey vchPubKey = key.GetPubKey();
std::vector<unsigned char> vchCryptedSecret;
//if (!EncryptSecret(vMasterKeyIn, vchSecret, vchPubKey.GetHash(), vchCryptedSecret))
bool fCompressed;
if (!EncryptSecret(vMasterKeyIn, key.GetSecret(fCompressed), vchPubKey.GetHash(), vchCryptedSecret))
return false;
if (!AddCryptedKey(vchPubKey, vchCryptedSecret))
return false;
}
mapKeys.clear();
}
示例4: LOCK
bool CCryptoKeyStore::AddKey(const CKey& key)
{
{
LOCK(cs_KeyStore);
CTxDestination address = key.GetPubKey().GetID();
if (HaveWatchOnly(address))
return false;
if (!IsCrypted())
return CBasicKeyStore::AddKey(key);
if (IsLocked())
return false;
std::vector<unsigned char> vchCryptedSecret;
CPubKey vchPubKey = key.GetPubKey();
bool fCompressed;
if (!EncryptSecret(vMasterKey, key.GetSecret(fCompressed), vchPubKey.GetHash(), vchCryptedSecret))
return false;
if (!AddCryptedKey(key.GetPubKey(), vchCryptedSecret))
return false;
}
return true;
}
示例5: LOCK
bool CCryptoKeyStore::AddKeyPubKey(const CKey& key, const CPubKey &pubkey)
{
{
LOCK(cs_KeyStore);
if (!IsCrypted())
return CBasicKeyStore::AddKeyPubKey(key, pubkey);
if (IsLocked())
return false;
std::vector<unsigned char> vchCryptedSecret;
CKeyingMaterial vchSecret(key.begin(), key.end());
if (!EncryptSecret(vMasterKey, vchSecret, pubkey.GetHash(), vchCryptedSecret))
return false;
// -- NOTE: this is CWallet::AddCryptedKey
if (!AddCryptedKey(pubkey, vchCryptedSecret))
return false;
}
return true;
}
示例6: LOCK
bool CCryptoKeyStore::EncryptKeys(CKeyingMaterial& vMasterKeyIn)
{
LOCK(cs_KeyStore);
if (!mapCryptedKeys.empty() || IsCrypted())
return false;
fUseCrypto = true;
for (KeyMap::value_type& mKey : mapKeys)
{
const CKey &key = mKey.second;
CPubKey vchPubKey = key.GetPubKey();
CKeyingMaterial vchSecret(key.begin(), key.end());
std::vector<unsigned char> vchCryptedSecret;
if (!EncryptSecret(vMasterKeyIn, vchSecret, vchPubKey.GetHash(), vchCryptedSecret))
return false;
if (!AddCryptedKey(vchPubKey, vchCryptedSecret))
return false;
}
mapKeys.clear();
return true;
}