Merge pull request #2661

ac4018a7 wallet2: workaround for lightwallet before supporting subaddress (followup #2656) (kenshi84)
This commit is contained in:
Riccardo Spagni 2017-11-14 15:01:25 +02:00
commit 2ddb894607
No known key found for this signature in database
GPG Key ID: 55432DF31CCD4FCD

View File

@ -5359,11 +5359,27 @@ bool wallet2::light_wallet_key_image_is_ours(const crypto::key_image& key_image,
crypto::key_image calculated_key_image; crypto::key_image calculated_key_image;
cryptonote::keypair in_ephemeral; cryptonote::keypair in_ephemeral;
// Subaddresses aren't supported in mymonero/openmonero yet. Using empty values. // Subaddresses aren't supported in mymonero/openmonero yet. Roll out the original scheme:
const std::vector<crypto::public_key> additional_tx_pub_keys; // compute D = a*R
const crypto::public_key pkey = crypto::null_pkey; // compute P = Hs(D || i)*G + B
// compute x = Hs(D || i) + b (and check if P==x*G)
// compute I = x*Hp(P)
const account_keys& ack = get_account().get_keys();
crypto::key_derivation derivation;
bool r = crypto::generate_key_derivation(tx_public_key, ack.m_view_secret_key, derivation);
CHECK_AND_ASSERT_MES(r, false, "failed to generate_key_derivation(" << tx_public_key << ", " << ack.m_view_secret_key << ")");
r = crypto::derive_public_key(derivation, out_index, ack.m_account_address.m_spend_public_key, in_ephemeral.pub);
CHECK_AND_ASSERT_MES(r, false, "failed to derive_public_key (" << derivation << ", " << out_index << ", " << ack.m_account_address.m_spend_public_key << ")");
crypto::derive_secret_key(derivation, out_index, ack.m_spend_secret_key, in_ephemeral.sec);
crypto::public_key out_pkey_test;
r = crypto::secret_key_to_public_key(in_ephemeral.sec, out_pkey_test);
CHECK_AND_ASSERT_MES(r, false, "failed to secret_key_to_public_key(" << in_ephemeral.sec << ")");
CHECK_AND_ASSERT_MES(in_ephemeral.pub == out_pkey_test, false, "derived secret key doesn't match derived public key");
crypto::generate_key_image(in_ephemeral.pub, in_ephemeral.sec, calculated_key_image);
cryptonote::generate_key_image_helper(get_account().get_keys(), m_subaddresses, pkey, tx_public_key, additional_tx_pub_keys, out_index, in_ephemeral, calculated_key_image);
index_keyimage_map.emplace(out_index, calculated_key_image); index_keyimage_map.emplace(out_index, calculated_key_image);
m_key_image_cache.emplace(tx_public_key, index_keyimage_map); m_key_image_cache.emplace(tx_public_key, index_keyimage_map);
return key_image == calculated_key_image; return key_image == calculated_key_image;