fix check_tx_key for carrot tx using x25519 derivation
This commit is contained in:
+35
-6
@@ -12999,15 +12999,44 @@ bool wallet2::check_spend_proof(const crypto::hash &txid, const std::string &mes
|
|||||||
void wallet2::check_tx_key(const crypto::hash &txid, const crypto::secret_key &tx_key, const std::vector<crypto::secret_key> &additional_tx_keys, const cryptonote::account_public_address &address, uint64_t &received, bool &in_pool, uint64_t &confirmations)
|
void wallet2::check_tx_key(const crypto::hash &txid, const crypto::secret_key &tx_key, const std::vector<crypto::secret_key> &additional_tx_keys, const cryptonote::account_public_address &address, uint64_t &received, bool &in_pool, uint64_t &confirmations)
|
||||||
{
|
{
|
||||||
crypto::key_derivation derivation;
|
crypto::key_derivation derivation;
|
||||||
THROW_WALLET_EXCEPTION_IF(!crypto::generate_key_derivation(address.m_view_public_key, tx_key, derivation), error::wallet_internal_error,
|
|
||||||
"Failed to generate key derivation from supplied parameters");
|
|
||||||
|
|
||||||
std::vector<crypto::key_derivation> additional_derivations;
|
std::vector<crypto::key_derivation> additional_derivations;
|
||||||
additional_derivations.resize(additional_tx_keys.size());
|
if (address.m_is_carrot)
|
||||||
for (size_t i = 0; i < additional_tx_keys.size(); ++i)
|
{
|
||||||
THROW_WALLET_EXCEPTION_IF(!crypto::generate_key_derivation(address.m_view_public_key, additional_tx_keys[i], additional_derivations[i]), error::wallet_internal_error,
|
// For Carrot enotes, use X25519 scalar multiplication
|
||||||
|
mx25519_pubkey s_sender_receiver_unctx;
|
||||||
|
bool success = carrot::make_carrot_uncontextualized_shared_key_sender(
|
||||||
|
tx_key,
|
||||||
|
address.m_view_public_key,
|
||||||
|
s_sender_receiver_unctx);
|
||||||
|
THROW_WALLET_EXCEPTION_IF(!success, error::wallet_internal_error,
|
||||||
|
"Failed to generate X25519 key derivation from supplied parameters (main)");
|
||||||
|
derivation = carrot::raw_byte_convert<crypto::key_derivation>(s_sender_receiver_unctx);
|
||||||
|
|
||||||
|
additional_derivations.resize(additional_tx_keys.size());
|
||||||
|
for (size_t i = 0; i < additional_tx_keys.size(); ++i)
|
||||||
|
{
|
||||||
|
mx25519_pubkey additional_s_sender_receiver_unctx;
|
||||||
|
success = carrot::make_carrot_uncontextualized_shared_key_sender(
|
||||||
|
additional_tx_keys[i],
|
||||||
|
address.m_view_public_key,
|
||||||
|
additional_s_sender_receiver_unctx);
|
||||||
|
THROW_WALLET_EXCEPTION_IF(!success, error::wallet_internal_error,
|
||||||
|
"Failed to generate X25519 key derivation from supplied parameters (additional)");
|
||||||
|
additional_derivations[i] = carrot::raw_byte_convert<crypto::key_derivation>(additional_s_sender_receiver_unctx);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
// For legacy enotes, use Edwards curve multiplication
|
||||||
|
THROW_WALLET_EXCEPTION_IF(!crypto::generate_key_derivation(address.m_view_public_key, tx_key, derivation), error::wallet_internal_error,
|
||||||
"Failed to generate key derivation from supplied parameters");
|
"Failed to generate key derivation from supplied parameters");
|
||||||
|
|
||||||
|
additional_derivations.resize(additional_tx_keys.size());
|
||||||
|
for (size_t i = 0; i < additional_tx_keys.size(); ++i)
|
||||||
|
THROW_WALLET_EXCEPTION_IF(!crypto::generate_key_derivation(address.m_view_public_key, additional_tx_keys[i], additional_derivations[i]), error::wallet_internal_error,
|
||||||
|
"Failed to generate key derivation from supplied parameters");
|
||||||
|
}
|
||||||
|
|
||||||
check_tx_key_helper(txid, derivation, additional_derivations, address, received, in_pool, confirmations);
|
check_tx_key_helper(txid, derivation, additional_derivations, address, received, in_pool, confirmations);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user