aboutsummaryrefslogtreecommitdiff
path: root/src/wallet
diff options
context:
space:
mode:
authormoneromooo-monero <moneromooo-monero@users.noreply.github.com>2016-08-10 12:48:20 +0100
committermoneromooo-monero <moneromooo-monero@users.noreply.github.com>2016-08-28 21:30:19 +0100
commitd4b62a1e295a7fb19de6081733b1d8e0610cbf08 (patch)
treea40178b339e35090117d3b3d2680a79a0bc28ac6 /src/wallet
parentrct: rework v2 txes into prunable and non prunable data (diff)
downloadmonero-d4b62a1e295a7fb19de6081733b1d8e0610cbf08.tar.xz
rct amount key modified as per luigi1111's recommendations
This allows the key to be not the same for two outputs sent to the same address (eg, if you pay yourself, and also get change back). Also remove the key amounts lists and return parameters since we don't actually generate random ones, so we don't need to save them as we can recalculate them when needed if we have the correct keys.
Diffstat (limited to 'src/wallet')
-rw-r--r--src/wallet/wallet2.cpp39
-rw-r--r--src/wallet/wallet2.h5
-rw-r--r--src/wallet/wallet_rpc_server.cpp31
-rw-r--r--src/wallet/wallet_rpc_server_commands_defs.h6
4 files changed, 20 insertions, 61 deletions
diff --git a/src/wallet/wallet2.cpp b/src/wallet/wallet2.cpp
index c3fb160a0..b3b8e6561 100644
--- a/src/wallet/wallet2.cpp
+++ b/src/wallet/wallet2.cpp
@@ -207,16 +207,25 @@ void wallet2::check_acc_out(const account_keys &acc, const tx_out &o, const cryp
error = false;
}
//----------------------------------------------------------------------------------------------------
-static uint64_t decodeRct(const rct::rctSig & rv, const rct::key & sk, unsigned int i, rct::key & mask)
+static uint64_t decodeRct(const rct::rctSig & rv, const crypto::public_key pub, const crypto::secret_key &sec, unsigned int i, rct::key & mask)
{
+ crypto::key_derivation derivation;
+ bool r = crypto::generate_key_derivation(pub, sec, derivation);
+ if (!r)
+ {
+ LOG_ERROR("Failed to generate key derivation to decode rct output " << i);
+ return 0;
+ }
+ crypto::secret_key scalar1;
+ crypto::derivation_to_scalar(derivation, i, scalar1);
try
{
switch (rv.type)
{
case rct::RCTTypeSimple:
- return rct::decodeRctSimpleFromSharedSecret(rv, sk, i, mask);
+ return rct::decodeRctSimple(rv, rct::sk2rct(scalar1), i, mask);
case rct::RCTTypeFull:
- return rct::decodeRctFromSharedSecret(rv, sk, i, mask);
+ return rct::decodeRct(rv, rct::sk2rct(scalar1), i, mask);
default:
LOG_ERROR("Unsupported rct type: " << rv.type);
return 0;
@@ -308,8 +317,7 @@ void wallet2::process_new_transaction(const cryptonote::transaction& tx, const s
if (money_transfered == 0)
{
const cryptonote::account_keys& keys = m_account.get_keys();
- rct::key amount_key = rct::hash_to_scalar(rct::scalarmultKey(rct::pk2rct(pub_key_field.pub_key), rct::sk2rct(keys.m_view_secret_key)));
- money_transfered = tools::decodeRct(tx.rct_signatures, amount_key, 0, mask[0]);
+ money_transfered = tools::decodeRct(tx.rct_signatures, pub_key_field.pub_key, keys.m_view_secret_key, 0, mask[0]);
}
amount[0] = money_transfered;
tx_money_got_in_outs = money_transfered;
@@ -352,8 +360,7 @@ void wallet2::process_new_transaction(const cryptonote::transaction& tx, const s
if (money_transfered[i] == 0)
{
const cryptonote::account_keys& keys = m_account.get_keys();
- rct::key amount_key = rct::hash_to_scalar(rct::scalarmultKey(rct::pk2rct(pub_key_field.pub_key), rct::sk2rct(keys.m_view_secret_key)));
- money_transfered[i] = tools::decodeRct(tx.rct_signatures, amount_key, i, mask[i]);
+ money_transfered[i] = tools::decodeRct(tx.rct_signatures, pub_key_field.pub_key, keys.m_view_secret_key, i, mask[i]);
}
tx_money_got_in_outs += money_transfered[i];
amount[i] = money_transfered[i];
@@ -401,8 +408,7 @@ void wallet2::process_new_transaction(const cryptonote::transaction& tx, const s
if (money_transfered[i] == 0)
{
const cryptonote::account_keys& keys = m_account.get_keys();
- rct::key amount_key = rct::hash_to_scalar(rct::scalarmultKey(rct::pk2rct(pub_key_field.pub_key), rct::sk2rct(keys.m_view_secret_key)));
- money_transfered[i] = tools::decodeRct(tx.rct_signatures, amount_key, i, mask[i]);
+ money_transfered[i] = tools::decodeRct(tx.rct_signatures, pub_key_field.pub_key, keys.m_view_secret_key, i, mask[i]);
}
tx_money_got_in_outs += money_transfered[i];
amount[i] = money_transfered[i];
@@ -434,8 +440,7 @@ void wallet2::process_new_transaction(const cryptonote::transaction& tx, const s
if (money_transfered == 0)
{
const cryptonote::account_keys& keys = m_account.get_keys();
- rct::key amount_key = rct::hash_to_scalar(rct::scalarmultKey(rct::pk2rct(pub_key_field.pub_key), rct::sk2rct(keys.m_view_secret_key)));
- money_transfered = tools::decodeRct(tx.rct_signatures, amount_key, i, mask[i]);
+ money_transfered = tools::decodeRct(tx.rct_signatures, pub_key_field.pub_key, keys.m_view_secret_key, i, mask[i]);
}
amount[i] = money_transfered;
tx_money_got_in_outs += money_transfered;
@@ -2896,8 +2901,7 @@ void wallet2::transfer_selected(const std::vector<cryptonote::tx_destination_ent
}
crypto::secret_key tx_key;
- std::vector<crypto::secret_key> amount_keys;
- bool r = cryptonote::construct_tx_and_get_tx_keys(m_account.get_keys(), sources, splitted_dsts, extra, tx, unlock_time, tx_key, amount_keys);
+ bool r = cryptonote::construct_tx_and_get_tx_key(m_account.get_keys(), sources, splitted_dsts, extra, tx, unlock_time, tx_key);
THROW_WALLET_EXCEPTION_IF(!r, error::tx_not_constructed, sources, splitted_dsts, unlock_time, m_testnet);
THROW_WALLET_EXCEPTION_IF(upper_transaction_size_limit <= get_object_blobsize(tx), error::tx_too_big, tx, upper_transaction_size_limit);
@@ -2924,7 +2928,6 @@ void wallet2::transfer_selected(const std::vector<cryptonote::tx_destination_ent
ptx.change_dts = change_dts;
ptx.selected_transfers = selected_transfers;
ptx.tx_key = tx_key;
- ptx.amount_keys = amount_keys;
ptx.dests = dsts;
}
@@ -3113,8 +3116,7 @@ void wallet2::transfer_selected_rct(std::vector<cryptonote::tx_destination_entry
dsts.push_back(change_dts);
crypto::secret_key tx_key;
- std::vector<crypto::secret_key> amount_keys;
- bool r = cryptonote::construct_tx_and_get_tx_keys(m_account.get_keys(), sources, dsts, extra, tx, unlock_time, tx_key, amount_keys, true);
+ bool r = cryptonote::construct_tx_and_get_tx_key(m_account.get_keys(), sources, dsts, extra, tx, unlock_time, tx_key, true);
THROW_WALLET_EXCEPTION_IF(!r, error::tx_not_constructed, sources, dsts, unlock_time, m_testnet);
THROW_WALLET_EXCEPTION_IF(upper_transaction_size_limit <= get_object_blobsize(tx), error::tx_too_big, tx, upper_transaction_size_limit);
@@ -3135,7 +3137,6 @@ void wallet2::transfer_selected_rct(std::vector<cryptonote::tx_destination_entry
ptx.change_dts = change_dts;
ptx.selected_transfers = selected_transfers;
ptx.tx_key = tx_key;
- ptx.amount_keys = amount_keys;
ptx.dests = dsts;
}
@@ -3764,8 +3765,7 @@ void wallet2::transfer_from(const std::vector<size_t> &outs, size_t num_outputs,
}
crypto::secret_key tx_key;
- std::vector<crypto::secret_key> amount_keys;
- bool r = cryptonote::construct_tx_and_get_tx_keys(m_account.get_keys(), sources, splitted_dsts, extra, tx, unlock_time, tx_key, amount_keys);
+ bool r = cryptonote::construct_tx_and_get_tx_key(m_account.get_keys(), sources, splitted_dsts, extra, tx, unlock_time, tx_key);
THROW_WALLET_EXCEPTION_IF(!r, error::tx_not_constructed, sources, splitted_dsts, unlock_time, m_testnet);
THROW_WALLET_EXCEPTION_IF(upper_transaction_size_limit <= get_object_blobsize(tx), error::tx_too_big, tx, upper_transaction_size_limit);
@@ -3785,7 +3785,6 @@ void wallet2::transfer_from(const std::vector<size_t> &outs, size_t num_outputs,
ptx.change_dts = change_dts;
ptx.selected_transfers = selected_transfers;
ptx.tx_key = tx_key;
- ptx.amount_keys = amount_keys;
ptx.dests = dsts;
}
diff --git a/src/wallet/wallet2.h b/src/wallet/wallet2.h
index 488902d5d..0d61f90e2 100644
--- a/src/wallet/wallet2.h
+++ b/src/wallet/wallet2.h
@@ -162,7 +162,6 @@ namespace tools
std::list<transfer_container::iterator> selected_transfers;
std::string key_images;
crypto::secret_key tx_key;
- std::vector<crypto::secret_key> amount_keys;
std::vector<cryptonote::tx_destination_entry> dests;
};
@@ -828,8 +827,7 @@ namespace tools
}
crypto::secret_key tx_key;
- std::vector<crypto::secret_key> amount_keys;
- bool r = cryptonote::construct_tx_and_get_tx_keys(m_account.get_keys(), sources, splitted_dsts, extra, tx, unlock_time, tx_key, amount_keys);
+ bool r = cryptonote::construct_tx_and_get_tx_key(m_account.get_keys(), sources, splitted_dsts, extra, tx, unlock_time, tx_key);
THROW_WALLET_EXCEPTION_IF(!r, error::tx_not_constructed, sources, splitted_dsts, unlock_time, m_testnet);
THROW_WALLET_EXCEPTION_IF(upper_transaction_size_limit <= get_object_blobsize(tx), error::tx_too_big, tx, upper_transaction_size_limit);
@@ -855,7 +853,6 @@ namespace tools
ptx.change_dts = change_dts;
ptx.selected_transfers = selected_transfers;
ptx.tx_key = tx_key;
- ptx.amount_keys = amount_keys;
ptx.dests = dsts;
}
diff --git a/src/wallet/wallet_rpc_server.cpp b/src/wallet/wallet_rpc_server.cpp
index 1786b776f..4c190b005 100644
--- a/src/wallet/wallet_rpc_server.cpp
+++ b/src/wallet/wallet_rpc_server.cpp
@@ -256,13 +256,6 @@ namespace tools
if (req.get_tx_key)
{
res.tx_key = epee::string_tools::pod_to_hex(ptx_vector.back().tx_key);
- if (ptx_vector.back().tx.version > 1)
- {
- for (const auto &i: ptx_vector.back().amount_keys)
- {
- res.amount_keys.push_back(epee::string_tools::pod_to_hex(i));
- }
- }
}
return true;
}
@@ -325,14 +318,6 @@ namespace tools
if (req.get_tx_keys)
{
res.tx_key_list.push_back(epee::string_tools::pod_to_hex(ptx.tx_key));
- res.amount_key_list.push_back(wallet_rpc::COMMAND_RPC_TRANSFER_SPLIT::key_list());
- if (ptx.tx.version > 1)
- {
- for (const auto &i: ptx.amount_keys)
- {
- res.amount_key_list.back().keys.push_back(epee::string_tools::pod_to_hex(i));
- }
- }
}
}
@@ -381,14 +366,6 @@ namespace tools
if (req.get_tx_keys)
{
res.tx_key_list.push_back(epee::string_tools::pod_to_hex(ptx.tx_key));
- res.amount_key_list.push_back(wallet_rpc::COMMAND_RPC_SWEEP_DUST::key_list());
- if (ptx.tx.version > 1)
- {
- for (const auto &i: ptx.amount_keys)
- {
- res.amount_key_list.back().keys.push_back(epee::string_tools::pod_to_hex(i));
- }
- }
}
}
@@ -450,14 +427,6 @@ namespace tools
if (req.get_tx_keys)
{
res.tx_key_list.push_back(epee::string_tools::pod_to_hex(ptx.tx_key));
- res.amount_key_list.push_back(wallet_rpc::COMMAND_RPC_SWEEP_ALL::key_list());
- if (ptx.tx.version > 1)
- {
- for (const auto &i: ptx.amount_keys)
- {
- res.amount_key_list.back().keys.push_back(epee::string_tools::pod_to_hex(i));
- }
- }
}
}
diff --git a/src/wallet/wallet_rpc_server_commands_defs.h b/src/wallet/wallet_rpc_server_commands_defs.h
index 4df259242..27b897dab 100644
--- a/src/wallet/wallet_rpc_server_commands_defs.h
+++ b/src/wallet/wallet_rpc_server_commands_defs.h
@@ -178,12 +178,10 @@ namespace wallet_rpc
{
std::list<std::string> tx_hash_list;
std::list<std::string> tx_key_list;
- std::list<key_list> amount_key_list;
BEGIN_KV_SERIALIZE_MAP()
KV_SERIALIZE(tx_hash_list)
KV_SERIALIZE(tx_key_list)
- KV_SERIALIZE(amount_key_list)
END_KV_SERIALIZE_MAP()
};
};
@@ -214,12 +212,10 @@ namespace wallet_rpc
{
std::list<std::string> tx_hash_list;
std::list<std::string> tx_key_list;
- std::list<key_list> amount_key_list;
BEGIN_KV_SERIALIZE_MAP()
KV_SERIALIZE(tx_hash_list)
KV_SERIALIZE(tx_key_list)
- KV_SERIALIZE(amount_key_list)
END_KV_SERIALIZE_MAP()
};
};
@@ -260,12 +256,10 @@ namespace wallet_rpc
{
std::list<std::string> tx_hash_list;
std::list<std::string> tx_key_list;
- std::list<key_list> amount_key_list;
BEGIN_KV_SERIALIZE_MAP()
KV_SERIALIZE(tx_hash_list)
KV_SERIALIZE(tx_key_list)
- KV_SERIALIZE(amount_key_list)
END_KV_SERIALIZE_MAP()
};
};