diff options
-rw-r--r-- | src/cryptonote_core/cryptonote_format_utils.cpp | 3 | ||||
-rw-r--r-- | src/ringct/rctSigs.cpp | 4 | ||||
-rw-r--r-- | src/ringct/rctSigs.h | 4 | ||||
-rw-r--r-- | src/ringct/rctTypes.h | 2 | ||||
-rw-r--r-- | src/simplewallet/simplewallet.cpp | 2 | ||||
-rw-r--r-- | src/wallet/api/wallet.cpp | 4 | ||||
-rw-r--r-- | src/wallet/api/wallet.h | 1 | ||||
-rw-r--r-- | src/wallet/api/wallet_manager.cpp | 5 | ||||
-rw-r--r-- | src/wallet/api/wallet_manager.h | 2 | ||||
-rw-r--r-- | src/wallet/wallet2.cpp | 261 | ||||
-rw-r--r-- | src/wallet/wallet2.h | 3 | ||||
-rw-r--r-- | src/wallet/wallet2_api.h | 11 | ||||
-rw-r--r-- | tests/performance_tests/CMakeLists.txt | 3 | ||||
-rw-r--r-- | tests/performance_tests/check_tx_signature.h (renamed from tests/performance_tests/check_ring_signature.h) | 25 | ||||
-rw-r--r-- | tests/performance_tests/construct_tx.h | 6 | ||||
-rw-r--r-- | tests/performance_tests/ge_frombytes_vartime.h | 70 | ||||
-rw-r--r-- | tests/performance_tests/main.cpp | 62 | ||||
-rw-r--r-- | tests/performance_tests/multi_tx_test_base.h | 3 | ||||
-rw-r--r-- | tests/performance_tests/performance_tests.h | 1 | ||||
-rw-r--r-- | utils/gpg_keys/iDunk.asc | 52 |
20 files changed, 254 insertions, 270 deletions
diff --git a/src/cryptonote_core/cryptonote_format_utils.cpp b/src/cryptonote_core/cryptonote_format_utils.cpp index 64f8eb924..870e8f0d8 100644 --- a/src/cryptonote_core/cryptonote_format_utils.cpp +++ b/src/cryptonote_core/cryptonote_format_utils.cpp @@ -658,10 +658,7 @@ namespace cryptonote } else { - bool all_rct_inputs = true; size_t n_total_outs = sources[0].outputs.size(); // only for non-simple rct - BOOST_FOREACH(const tx_source_entry& src_entr, sources) - all_rct_inputs &= !(src_entr.mask == rct::identity()); // the non-simple version is slightly smaller, but assumes all real inputs // are on the same index, so can only be used if there just one ring. diff --git a/src/ringct/rctSigs.cpp b/src/ringct/rctSigs.cpp index ed1f8cc0e..85d21e805 100644 --- a/src/ringct/rctSigs.cpp +++ b/src/ringct/rctSigs.cpp @@ -150,7 +150,7 @@ namespace rct { // Gen creates a signature which proves that for some column in the keymatrix "pk" // the signer knows a secret key for each row in that column // Ver verifies that the MG sig was created correctly - mgSig MLSAG_Gen(key message, const keyM & pk, const keyV & xx, const unsigned int index, size_t dsRows) { + mgSig MLSAG_Gen(const key &message, const keyM & pk, const keyV & xx, const unsigned int index, size_t dsRows) { mgSig rv; size_t cols = pk.size(); CHECK_AND_ASSERT_THROW_MES(cols >= 2, "Error! What is c if cols = 1!"); @@ -239,7 +239,7 @@ namespace rct { // Gen creates a signature which proves that for some column in the keymatrix "pk" // the signer knows a secret key for each row in that column // Ver verifies that the MG sig was created correctly - bool MLSAG_Ver(key message, const keyM & pk, const mgSig & rv, size_t dsRows) { + bool MLSAG_Ver(const key &message, const keyM & pk, const mgSig & rv, size_t dsRows) { size_t cols = pk.size(); CHECK_AND_ASSERT_MES(cols >= 2, false, "Error! What is c if cols = 1!"); diff --git a/src/ringct/rctSigs.h b/src/ringct/rctSigs.h index f1c906d5e..11d771818 100644 --- a/src/ringct/rctSigs.h +++ b/src/ringct/rctSigs.h @@ -90,8 +90,8 @@ namespace rct { // the signer knows a secret key for each row in that column // Ver verifies that the MG sig was created correctly keyV keyImageV(const keyV &xx); - mgSig MLSAG_Gen(key message, const keyM & pk, const keyV & xx, const unsigned int index, size_t dsRows); - bool MLSAG_Ver(key message, const keyM &pk, const mgSig &sig, size_t dsRows); + mgSig MLSAG_Gen(const key &message, const keyM & pk, const keyV & xx, const unsigned int index, size_t dsRows); + bool MLSAG_Ver(const key &message, const keyM &pk, const mgSig &sig, size_t dsRows); //mgSig MLSAG_Gen_Old(const keyM & pk, const keyV & xx, const int index); //proveRange and verRange diff --git a/src/ringct/rctTypes.h b/src/ringct/rctTypes.h index bfafebb83..25f6f9bc9 100644 --- a/src/ringct/rctTypes.h +++ b/src/ringct/rctTypes.h @@ -415,7 +415,7 @@ namespace rct { // then the value in the first 8 bytes is returned xmr_amount h2d(const key &test); //32 byte key to int[64] - void h2b(bits amountb2, key & test); + void h2b(bits amountb2, const key & test); //int[64] to 32 byte key void b2h(key & amountdh, bits amountb2); //int[64] to uint long long diff --git a/src/simplewallet/simplewallet.cpp b/src/simplewallet/simplewallet.cpp index 3f7d6bd17..b27113473 100644 --- a/src/simplewallet/simplewallet.cpp +++ b/src/simplewallet/simplewallet.cpp @@ -678,7 +678,7 @@ simple_wallet::simple_wallet() m_cmd_binder.set_handler("transfer", boost::bind(&simple_wallet::transfer_new, this, _1), tr("Same as transfer_original, but using a new transaction building algorithm")); m_cmd_binder.set_handler("locked_transfer", boost::bind(&simple_wallet::locked_transfer, this, _1), tr("locked_transfer [<mixin_count>] <addr> <amount> <lockblocks>(Number of blocks to lock the transaction for, max 1000000) [<payment_id>]")); m_cmd_binder.set_handler("sweep_unmixable", boost::bind(&simple_wallet::sweep_unmixable, this, _1), tr("Send all unmixable outputs to yourself with mixin 0")); - m_cmd_binder.set_handler("sweep_all", boost::bind(&simple_wallet::sweep_all, this, _1), tr("Send all unlocked balance an address")); + m_cmd_binder.set_handler("sweep_all", boost::bind(&simple_wallet::sweep_all, this, _1), tr("sweep_all [mixin] address [payment_id] - Send all unlocked balance an address")); m_cmd_binder.set_handler("sign_transfer", boost::bind(&simple_wallet::sign_transfer, this, _1), tr("Sign a transaction from a file")); m_cmd_binder.set_handler("submit_transfer", boost::bind(&simple_wallet::submit_transfer, this, _1), tr("Submit a signed transaction from a file")); m_cmd_binder.set_handler("set_log", boost::bind(&simple_wallet::set_log, this, _1), tr("set_log <level> - Change current log detail level, <0-4>")); diff --git a/src/wallet/api/wallet.cpp b/src/wallet/api/wallet.cpp index a93e194b9..674670b16 100644 --- a/src/wallet/api/wallet.cpp +++ b/src/wallet/api/wallet.cpp @@ -411,6 +411,10 @@ void WalletImpl::initAsync(const string &daemon_address, uint64_t upper_transact startRefresh(); } +void WalletImpl::setRefreshFromBlockHeight(uint64_t refresh_from_block_height) +{ + m_wallet->set_refresh_from_block_height(refresh_from_block_height); +} uint64_t WalletImpl::balance() const diff --git a/src/wallet/api/wallet.h b/src/wallet/api/wallet.h index 98a5f2d09..8ce475d1c 100644 --- a/src/wallet/api/wallet.h +++ b/src/wallet/api/wallet.h @@ -83,6 +83,7 @@ public: void refreshAsync(); void setAutoRefreshInterval(int millis); int autoRefreshInterval() const; + void setRefreshFromBlockHeight(uint64_t refresh_from_block_height); diff --git a/src/wallet/api/wallet_manager.cpp b/src/wallet/api/wallet_manager.cpp index ca83806ff..aa99476ee 100644 --- a/src/wallet/api/wallet_manager.cpp +++ b/src/wallet/api/wallet_manager.cpp @@ -57,9 +57,12 @@ Wallet *WalletManagerImpl::openWallet(const std::string &path, const std::string return wallet; } -Wallet *WalletManagerImpl::recoveryWallet(const std::string &path, const std::string &memo, bool testnet) +Wallet *WalletManagerImpl::recoveryWallet(const std::string &path, const std::string &memo, bool testnet, uint64_t restoreHeight) { WalletImpl * wallet = new WalletImpl(testnet); + if(restoreHeight > 0){ + wallet->setRefreshFromBlockHeight(restoreHeight); + } wallet->recover(path, memo); return wallet; } diff --git a/src/wallet/api/wallet_manager.h b/src/wallet/api/wallet_manager.h index 7585c1af7..2e932a2a1 100644 --- a/src/wallet/api/wallet_manager.h +++ b/src/wallet/api/wallet_manager.h @@ -40,7 +40,7 @@ public: Wallet * createWallet(const std::string &path, const std::string &password, const std::string &language, bool testnet); Wallet * openWallet(const std::string &path, const std::string &password, bool testnet); - virtual Wallet * recoveryWallet(const std::string &path, const std::string &memo, bool testnet); + virtual Wallet * recoveryWallet(const std::string &path, const std::string &memo, bool testnet, uint64_t restoreHeight); virtual bool closeWallet(Wallet *wallet); bool walletExists(const std::string &path); std::vector<std::string> findWallets(const std::string &path); diff --git a/src/wallet/wallet2.cpp b/src/wallet/wallet2.cpp index e3736bc3d..98dbc4fd6 100644 --- a/src/wallet/wallet2.cpp +++ b/src/wallet/wallet2.cpp @@ -583,11 +583,14 @@ void wallet2::process_new_transaction(const cryptonote::transaction& tx, const s std::string(", expected ") + print_money(td.amount())); } amount = td.amount(); - LOG_PRINT_L0("Spent money: " << print_money(amount) << ", with tx: " << txid()); tx_money_spent_in_ins += amount; - set_spent(it->second, height); - if (0 != m_callback) - m_callback->on_money_spent(height, tx, amount, tx); + if (!pool) + { + LOG_PRINT_L0("Spent money: " << print_money(amount) << ", with tx: " << txid()); + set_spent(it->second, height); + if (0 != m_callback) + m_callback->on_money_spent(height, tx, amount, tx); + } } } @@ -3662,6 +3665,26 @@ std::vector<wallet2::pending_tx> wallet2::create_transactions_all(const cryptono { std::vector<size_t> unused_transfers_indices; std::vector<size_t> unused_dust_indices; + const bool use_rct = use_fork_rules(4, 0); + + // gather all our dust and non dust outputs + for (size_t i = 0; i < m_transfers.size(); ++i) + { + const transfer_details& td = m_transfers[i]; + if (!td.m_spent && (use_rct ? true : !td.is_rct()) && is_transfer_unlocked(td)) + { + if (td.is_rct() || is_valid_decomposed_amount(td.amount())) + unused_transfers_indices.push_back(i); + else + unused_dust_indices.push_back(i); + } + } + + return create_transactions_from(address, unused_transfers_indices, unused_dust_indices, fake_outs_count, unlock_time, priority, extra, trusted_daemon); +} + +std::vector<wallet2::pending_tx> wallet2::create_transactions_from(const cryptonote::account_public_address &address, std::vector<size_t> unused_transfers_indices, std::vector<size_t> unused_dust_indices, const size_t fake_outs_count, const uint64_t unlock_time, uint32_t priority, const std::vector<uint8_t> extra, bool trusted_daemon) +{ uint64_t accumulated_fee, accumulated_outputs, accumulated_change; struct TX { std::list<size_t> selected_transfers; @@ -3673,24 +3696,12 @@ std::vector<wallet2::pending_tx> wallet2::create_transactions_all(const cryptono std::vector<TX> txes; uint64_t needed_fee, available_for_fee = 0; uint64_t upper_transaction_size_limit = get_upper_tranaction_size_limit(); - const bool use_rct = use_fork_rules(4, 0); + const bool use_rct = use_fork_rules(4, 0); const bool use_new_fee = use_fork_rules(3, -720 * 14); const uint64_t fee_per_kb = use_new_fee ? FEE_PER_KB : FEE_PER_KB_OLD; const uint64_t fee_multiplier = get_fee_multiplier(priority, use_new_fee); - // gather all our dust and non dust outputs - for (size_t i = 0; i < m_transfers.size(); ++i) - { - const transfer_details& td = m_transfers[i]; - if (!td.m_spent && (use_rct ? true : !td.is_rct()) && is_transfer_unlocked(td)) - { - if (td.is_rct() || is_valid_decomposed_amount(td.amount())) - unused_transfers_indices.push_back(i); - else - unused_dust_indices.push_back(i); - } - } LOG_PRINT_L2("Starting with " << unused_transfers_indices.size() << " non-dust outputs and " << unused_dust_indices.size() << " dust outputs"); if (unused_dust_indices.empty() && unused_transfers_indices.empty()) @@ -3820,121 +3831,6 @@ uint64_t wallet2::unlocked_dust_balance(const tx_dust_policy &dust_policy) const } return money; } - -template<typename T> -void wallet2::transfer_from(const std::vector<size_t> &outs, size_t num_outputs, uint64_t unlock_time, uint64_t needed_fee, T destination_split_strategy, const tx_dust_policy& dust_policy, const std::vector<uint8_t> &extra, cryptonote::transaction& tx, pending_tx &ptx) -{ - using namespace cryptonote; - - uint64_t upper_transaction_size_limit = get_upper_tranaction_size_limit(); - - // select all dust inputs for transaction - // throw if there are none - uint64_t money = 0; - std::list<size_t> selected_transfers; -#if 1 - for (size_t n = 0; n < outs.size(); ++n) - { - const transfer_details& td = m_transfers[outs[n]]; - if (!td.m_spent) - { - selected_transfers.push_back (outs[n]); - money += td.amount(); - if (selected_transfers.size() >= num_outputs) - break; - } - } -#else - for (transfer_container::iterator i = m_transfers.begin(); i != m_transfers.end(); ++i) - { - const transfer_details& td = *i; - if (!td.m_spent && (td.amount() < dust_policy.dust_threshold || !is_valid_decomposed_amount(td.amount())) && is_transfer_unlocked(td)) - { - selected_transfers.push_back (i); - money += td.amount(); - if (selected_transfers.size() >= num_outputs) - break; - } - } -#endif - - // we don't allow no output to self, easier, but one may want to burn the dust if = fee - THROW_WALLET_EXCEPTION_IF(money <= needed_fee, error::not_enough_money, money, needed_fee, needed_fee); - - typedef cryptonote::tx_source_entry::output_entry tx_output_entry; - - //prepare inputs - size_t i = 0; - std::vector<cryptonote::tx_source_entry> sources; - BOOST_FOREACH(size_t idx, selected_transfers) - { - sources.resize(sources.size()+1); - cryptonote::tx_source_entry& src = sources.back(); - const transfer_details& td = m_transfers[idx]; - src.amount = td.amount(); - src.rct = td.is_rct(); - - //paste real transaction to the random index - auto it_to_insert = std::find_if(src.outputs.begin(), src.outputs.end(), [&](const tx_output_entry& a) - { - return a.first >= td.m_global_output_index; - }); - tx_output_entry real_oe; - real_oe.first = td.m_global_output_index; - real_oe.second.dest = rct::pk2rct(boost::get<txout_to_key>(td.m_tx.vout[td.m_internal_output_index].target).key); - real_oe.second.mask = rct::commit(td.amount(), td.m_mask); - auto interted_it = src.outputs.insert(it_to_insert, real_oe); - src.real_out_tx_key = get_tx_pub_key_from_extra(td.m_tx); - src.real_output = interted_it - src.outputs.begin(); - src.real_output_in_tx_index = td.m_internal_output_index; - detail::print_source_entry(src); - ++i; - } - - cryptonote::tx_destination_entry change_dts = AUTO_VAL_INIT(change_dts); - - std::vector<cryptonote::tx_destination_entry> dsts; - uint64_t money_back = money - needed_fee; - if (dust_policy.dust_threshold > 0) - money_back = money_back - money_back % dust_policy.dust_threshold; - dsts.push_back(cryptonote::tx_destination_entry(money_back, m_account_public_address)); - std::vector<cryptonote::tx_destination_entry> splitted_dsts, dust; - destination_split_strategy(dsts, change_dts, dust_policy.dust_threshold, splitted_dsts, dust); - BOOST_FOREACH(auto& d, dust) { - THROW_WALLET_EXCEPTION_IF(dust_policy.dust_threshold < d.amount, error::wallet_internal_error, "invalid dust value: dust = " + - std::to_string(d.amount) + ", dust_threshold = " + std::to_string(dust_policy.dust_threshold)); - } - - crypto::secret_key tx_key; - 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); - - std::string key_images; - bool all_are_txin_to_key = std::all_of(tx.vin.begin(), tx.vin.end(), [&](const txin_v& s_e) -> bool - { - CHECKED_GET_SPECIFIC_VARIANT(s_e, const txin_to_key, in, false); - key_images += boost::to_string(in.k_image) + " "; - return true; - }); - THROW_WALLET_EXCEPTION_IF(!all_are_txin_to_key, error::unexpected_txin_type, tx); - - ptx.key_images = key_images; - ptx.fee = money - money_back; - ptx.dust = 0; - ptx.tx = tx; - ptx.change_dts = change_dts; - ptx.selected_transfers = selected_transfers; - ptx.tx_key = tx_key; - ptx.dests = dsts; - ptx.construction_data.sources = sources; - ptx.construction_data.destinations = dsts; - ptx.construction_data.change_dts = change_dts; - ptx.construction_data.extra = tx.extra; - ptx.construction_data.unlock_time = unlock_time; - ptx.construction_data.use_rct = false; -} - //---------------------------------------------------------------------------------------------------- void wallet2::get_hard_fork_info(uint8_t version, uint64_t &earliest_height) { @@ -4114,100 +4010,17 @@ std::vector<wallet2::pending_tx> wallet2::create_unmixable_sweep_transactions(bo return std::vector<wallet2::pending_tx>(); } - // failsafe split attempt counter - size_t attempt_count = 0; - - for(attempt_count = 1; ;attempt_count++) + // split in "dust" and "non dust" to make it easier to select outputs + std::vector<size_t> unmixable_transfer_outputs, unmixable_dust_outputs; + for (auto n: unmixable_outputs) { - size_t num_tx = 0.5 + pow(1.7,attempt_count-1); - size_t num_outputs_per_tx = (num_dust_outputs + num_tx - 1) / num_tx; - - std::vector<pending_tx> ptx_vector; - try - { - // for each new tx - for (size_t i=0; i<num_tx;++i) - { - cryptonote::transaction tx; - pending_tx ptx; - std::vector<uint8_t> extra; - - // loop until fee is met without increasing tx size to next KB boundary. - uint64_t needed_fee = 0; - do - { - transfer_from(unmixable_outputs, num_outputs_per_tx, (uint64_t)0 /* unlock_time */, 0, detail::digit_split_strategy, dust_policy, extra, tx, ptx); - auto txBlob = t_serializable_object_to_blob(ptx.tx); - needed_fee = calculate_fee(fee_per_kb, txBlob, 1); - - // reroll the tx with the actual amount minus the fee - // if there's not enough for the fee, it'll throw - transfer_from(unmixable_outputs, num_outputs_per_tx, (uint64_t)0 /* unlock_time */, needed_fee, detail::digit_split_strategy, dust_policy, extra, tx, ptx); - txBlob = t_serializable_object_to_blob(ptx.tx); - needed_fee = calculate_fee(fee_per_kb, txBlob, 1); - } while (ptx.fee < needed_fee); - - ptx_vector.push_back(ptx); - - // mark transfers to be used as "spent" - BOOST_FOREACH(size_t idx, ptx.selected_transfers) - { - set_spent(idx, 0); - } - } - - // if we made it this far, we've selected our transactions. committing them will mark them spent, - // so this is a failsafe in case they don't go through - // unmark pending tx transfers as spent - for (auto & ptx : ptx_vector) - { - // mark transfers to be used as not spent - BOOST_FOREACH(size_t idx2, ptx.selected_transfers) - { - set_unspent(idx2); - } - } - - // if we made it this far, we're OK to actually send the transactions - return ptx_vector; - - } - // only catch this here, other exceptions need to pass through to the calling function - catch (const tools::error::tx_too_big& e) - { - - // unmark pending tx transfers as spent - for (auto & ptx : ptx_vector) - { - // mark transfers to be used as not spent - BOOST_FOREACH(size_t idx2, ptx.selected_transfers) - { - set_unspent(idx2); - } - } - - if (attempt_count >= MAX_SPLIT_ATTEMPTS) - { - throw; - } - } - catch (...) - { - // in case of some other exception, make sure any tx in queue are marked unspent again - - // unmark pending tx transfers as spent - for (auto & ptx : ptx_vector) - { - // mark transfers to be used as not spent - BOOST_FOREACH(size_t idx2, ptx.selected_transfers) - { - set_unspent(idx2); - } - } - - throw; - } + if (m_transfers[n].amount() < fee_per_kb) + unmixable_dust_outputs.push_back(n); + else + unmixable_transfer_outputs.push_back(n); } + + return create_transactions_from(m_account_public_address, unmixable_transfer_outputs, unmixable_dust_outputs, 0 /*fake_outs_count */, 0 /* unlock_time */, 1 /*priority */, std::vector<uint8_t>(), trusted_daemon); } bool wallet2::get_tx_key(const crypto::hash &txid, crypto::secret_key &tx_key) const diff --git a/src/wallet/wallet2.h b/src/wallet/wallet2.h index 2754f4b09..a039c92d6 100644 --- a/src/wallet/wallet2.h +++ b/src/wallet/wallet2.h @@ -346,8 +346,6 @@ namespace tools void transfer(const std::vector<cryptonote::tx_destination_entry>& dsts, const size_t fake_outputs_count, const std::vector<size_t> &unused_transfers_indices, uint64_t unlock_time, uint64_t fee, const std::vector<uint8_t>& extra, bool trusted_daemon); void transfer(const std::vector<cryptonote::tx_destination_entry>& dsts, const size_t fake_outputs_count, const std::vector<size_t> &unused_transfers_indices, uint64_t unlock_time, uint64_t fee, const std::vector<uint8_t>& extra, cryptonote::transaction& tx, pending_tx& ptx, bool trusted_daemon); template<typename T> - void transfer_from(const std::vector<size_t> &outs, size_t num_outputs, uint64_t unlock_time, uint64_t needed_fee, T destination_split_strategy, const tx_dust_policy& dust_policy, const std::vector<uint8_t>& extra, cryptonote::transaction& tx, pending_tx &ptx); - template<typename T> void transfer_selected(const std::vector<cryptonote::tx_destination_entry>& dsts, const std::list<size_t> selected_transfers, size_t fake_outputs_count, uint64_t unlock_time, uint64_t fee, const std::vector<uint8_t>& extra, T destination_split_strategy, const tx_dust_policy& dust_policy, cryptonote::transaction& tx, pending_tx &ptx); void transfer_selected_rct(std::vector<cryptonote::tx_destination_entry> dsts, const std::list<size_t> selected_transfers, size_t fake_outputs_count, @@ -361,6 +359,7 @@ namespace tools std::vector<pending_tx> create_transactions(std::vector<cryptonote::tx_destination_entry> dsts, const size_t fake_outs_count, const uint64_t unlock_time, uint32_t priority, const std::vector<uint8_t> extra, bool trusted_daemon); std::vector<wallet2::pending_tx> create_transactions_2(std::vector<cryptonote::tx_destination_entry> dsts, const size_t fake_outs_count, const uint64_t unlock_time, uint32_t priority, const std::vector<uint8_t> extra, bool trusted_daemon); std::vector<wallet2::pending_tx> create_transactions_all(const cryptonote::account_public_address &address, const size_t fake_outs_count, const uint64_t unlock_time, uint32_t priority, const std::vector<uint8_t> extra, bool trusted_daemon); + std::vector<wallet2::pending_tx> create_transactions_from(const cryptonote::account_public_address &address, std::vector<size_t> unused_transfers_indices, std::vector<size_t> unused_dust_indices, const size_t fake_outs_count, const uint64_t unlock_time, uint32_t priority, const std::vector<uint8_t> extra, bool trusted_daemon); std::vector<pending_tx> create_unmixable_sweep_transactions(bool trusted_daemon); bool check_connection(bool *same_version = NULL); void get_transfers(wallet2::transfer_container& incoming_transfers) const; diff --git a/src/wallet/wallet2_api.h b/src/wallet/wallet2_api.h index 934cc6e38..742a904ea 100644 --- a/src/wallet/wallet2_api.h +++ b/src/wallet/wallet2_api.h @@ -219,6 +219,13 @@ struct Wallet */ virtual void initAsync(const std::string &daemon_address, uint64_t upper_transaction_size_limit) = 0; + /*! + * \brief setRefreshFromBlockHeight - start refresh from block height on recover + * + * \param refresh_from_block_height - blockchain start height + */ + virtual void setRefreshFromBlockHeight(uint64_t refresh_from_block_height) = 0; + /** * @brief connectToDaemon - connects to the daemon. TODO: check if it can be removed * @return @@ -353,9 +360,11 @@ struct WalletManager * \brief recovers existing wallet using memo (electrum seed) * \param path Name of wallet file to be created * \param memo memo (25 words electrum seed) + * \param testnet testnet + * \param restoreHeight restore from start height * \return Wallet instance (Wallet::status() needs to be called to check if recovered successfully) */ - virtual Wallet * recoveryWallet(const std::string &path, const std::string &memo, bool testnet = false) = 0; + virtual Wallet * recoveryWallet(const std::string &path, const std::string &memo, bool testnet = false, uint64_t restoreHeight = 0) = 0; /*! * \brief Closes wallet. In case operation succeded, wallet object deleted. in case operation failed, wallet object not deleted diff --git a/tests/performance_tests/CMakeLists.txt b/tests/performance_tests/CMakeLists.txt index 37accb393..5ec53cd2b 100644 --- a/tests/performance_tests/CMakeLists.txt +++ b/tests/performance_tests/CMakeLists.txt @@ -30,11 +30,12 @@ set(performance_tests_sources main.cpp) set(performance_tests_headers - check_ring_signature.h + check_tx_signature.h cn_slow_hash.h construct_tx.h derive_public_key.h derive_secret_key.h + ge_frombytes_vartime.h generate_key_derivation.h generate_key_image.h generate_key_image_helper.h diff --git a/tests/performance_tests/check_ring_signature.h b/tests/performance_tests/check_tx_signature.h index a55849742..fe595a4da 100644 --- a/tests/performance_tests/check_ring_signature.h +++ b/tests/performance_tests/check_tx_signature.h @@ -36,17 +36,19 @@ #include "cryptonote_core/cryptonote_basic.h" #include "cryptonote_core/cryptonote_format_utils.h" #include "crypto/crypto.h" +#include "ringct/rctSigs.h" #include "multi_tx_test_base.h" -template<size_t a_ring_size> -class test_check_ring_signature : private multi_tx_test_base<a_ring_size> +template<size_t a_ring_size, bool a_rct> +class test_check_tx_signature : private multi_tx_test_base<a_ring_size> { static_assert(0 < a_ring_size, "ring_size must be greater than 0"); public: - static const size_t loop_count = a_ring_size < 100 ? 100 : 10; + static const size_t loop_count = a_rct ? 10 : a_ring_size < 100 ? 100 : 10; static const size_t ring_size = a_ring_size; + static const bool rct = a_rct; typedef multi_tx_test_base<a_ring_size> base_class; @@ -62,7 +64,8 @@ public: std::vector<tx_destination_entry> destinations; destinations.push_back(tx_destination_entry(this->m_source_amount, m_alice.get_keys().m_account_address)); - if (!construct_tx(this->m_miners[this->real_source_idx].get_keys(), this->m_sources, destinations, std::vector<uint8_t>(), m_tx, 0)) + crypto::secret_key tx_key; + if (!construct_tx_and_get_tx_key(this->m_miners[this->real_source_idx].get_keys(), this->m_sources, destinations, std::vector<uint8_t>(), m_tx, 0, tx_key, rct)) return false; get_transaction_prefix_hash(m_tx, m_tx_prefix_hash); @@ -72,8 +75,18 @@ public: bool test() { - const cryptonote::txin_to_key& txin = boost::get<cryptonote::txin_to_key>(m_tx.vin[0]); - return crypto::check_ring_signature(m_tx_prefix_hash, txin.k_image, this->m_public_key_ptrs, ring_size, m_tx.signatures[0].data()); + if (rct) + { + if (m_tx.rct_signatures.type == rct::RCTTypeFull) + return rct::verRct(m_tx.rct_signatures); + else + return rct::verRctSimple(m_tx.rct_signatures); + } + else + { + const cryptonote::txin_to_key& txin = boost::get<cryptonote::txin_to_key>(m_tx.vin[0]); + return crypto::check_ring_signature(m_tx_prefix_hash, txin.k_image, this->m_public_key_ptrs, ring_size, m_tx.signatures[0].data()); + } } private: diff --git a/tests/performance_tests/construct_tx.h b/tests/performance_tests/construct_tx.h index d3409c0f3..aef455eaa 100644 --- a/tests/performance_tests/construct_tx.h +++ b/tests/performance_tests/construct_tx.h @@ -36,7 +36,7 @@ #include "multi_tx_test_base.h" -template<size_t a_in_count, size_t a_out_count> +template<size_t a_in_count, size_t a_out_count, bool a_rct> class test_construct_tx : private multi_tx_test_base<a_in_count> { static_assert(0 < a_in_count, "in_count must be greater than 0"); @@ -46,6 +46,7 @@ public: static const size_t loop_count = (a_in_count + a_out_count < 100) ? 100 : 10; static const size_t in_count = a_in_count; static const size_t out_count = a_out_count; + static const bool rct = a_rct; typedef multi_tx_test_base<a_in_count> base_class; @@ -68,7 +69,8 @@ public: bool test() { - return cryptonote::construct_tx(this->m_miners[this->real_source_idx].get_keys(), this->m_sources, m_destinations, std::vector<uint8_t>(), m_tx, 0); + crypto::secret_key tx_key; + return cryptonote::construct_tx_and_get_tx_key(this->m_miners[this->real_source_idx].get_keys(), this->m_sources, m_destinations, std::vector<uint8_t>(), m_tx, 0, tx_key, rct); } private: diff --git a/tests/performance_tests/ge_frombytes_vartime.h b/tests/performance_tests/ge_frombytes_vartime.h new file mode 100644 index 000000000..c815422f9 --- /dev/null +++ b/tests/performance_tests/ge_frombytes_vartime.h @@ -0,0 +1,70 @@ +// Copyright (c) 2014-2016, The Monero Project +// +// All rights reserved. +// +// Redistribution and use in source and binary forms, with or without modification, are +// permitted provided that the following conditions are met: +// +// 1. Redistributions of source code must retain the above copyright notice, this list of +// conditions and the following disclaimer. +// +// 2. Redistributions in binary form must reproduce the above copyright notice, this list +// of conditions and the following disclaimer in the documentation and/or other +// materials provided with the distribution. +// +// 3. Neither the name of the copyright holder nor the names of its contributors may be +// used to endorse or promote products derived from this software without specific +// prior written permission. +// +// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY +// EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF +// MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL +// THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, +// PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS +// INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, +// STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF +// THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +// +// Parts of this file are originally copyright (c) 2012-2013 The Cryptonote developers + +#pragma once + +#include "crypto/crypto.h" +#include "cryptonote_core/cryptonote_basic.h" + +#include "single_tx_test_base.h" + +class test_ge_frombytes_vartime : public multi_tx_test_base<1> +{ +public: + static const size_t loop_count = 10000; + + typedef multi_tx_test_base<1> base_class; + + bool init() + { + using namespace cryptonote; + + if (!base_class::init()) + return false; + + m_alice.generate(); + + std::vector<tx_destination_entry> destinations; + destinations.push_back(tx_destination_entry(1, m_alice.get_keys().m_account_address)); + + return construct_tx(this->m_miners[this->real_source_idx].get_keys(), this->m_sources, destinations, std::vector<uint8_t>(), m_tx, 0); + } + + bool test() + { + ge_p3 unp; + const cryptonote::txin_to_key& txin = boost::get<cryptonote::txin_to_key>(m_tx.vin[0]); + return ge_frombytes_vartime(&unp, (const unsigned char*) &txin.k_image) == 0; + } + +private: + cryptonote::account_base m_alice; + cryptonote::transaction m_tx; +}; diff --git a/tests/performance_tests/main.cpp b/tests/performance_tests/main.cpp index 84a51aa96..d09276230 100644 --- a/tests/performance_tests/main.cpp +++ b/tests/performance_tests/main.cpp @@ -33,10 +33,11 @@ // tests #include "construct_tx.h" -#include "check_ring_signature.h" +#include "check_tx_signature.h" #include "cn_slow_hash.h" #include "derive_public_key.h" #include "derive_secret_key.h" +#include "ge_frombytes_vartime.h" #include "generate_key_derivation.h" #include "generate_key_image.h" #include "generate_key_image_helper.h" @@ -50,31 +51,47 @@ int main(int argc, char** argv) performance_timer timer; timer.start(); - TEST_PERFORMANCE2(test_construct_tx, 1, 1); - TEST_PERFORMANCE2(test_construct_tx, 1, 2); - TEST_PERFORMANCE2(test_construct_tx, 1, 10); - TEST_PERFORMANCE2(test_construct_tx, 1, 100); - TEST_PERFORMANCE2(test_construct_tx, 1, 1000); + TEST_PERFORMANCE3(test_construct_tx, 1, 1, false); + TEST_PERFORMANCE3(test_construct_tx, 1, 2, false); + TEST_PERFORMANCE3(test_construct_tx, 1, 10, false); + TEST_PERFORMANCE3(test_construct_tx, 1, 100, false); + TEST_PERFORMANCE3(test_construct_tx, 1, 1000, false); - TEST_PERFORMANCE2(test_construct_tx, 2, 1); - TEST_PERFORMANCE2(test_construct_tx, 2, 2); - TEST_PERFORMANCE2(test_construct_tx, 2, 10); - TEST_PERFORMANCE2(test_construct_tx, 2, 100); + TEST_PERFORMANCE3(test_construct_tx, 2, 1, false); + TEST_PERFORMANCE3(test_construct_tx, 2, 2, false); + TEST_PERFORMANCE3(test_construct_tx, 2, 10, false); + TEST_PERFORMANCE3(test_construct_tx, 2, 100, false); - TEST_PERFORMANCE2(test_construct_tx, 10, 1); - TEST_PERFORMANCE2(test_construct_tx, 10, 2); - TEST_PERFORMANCE2(test_construct_tx, 10, 10); - TEST_PERFORMANCE2(test_construct_tx, 10, 100); + TEST_PERFORMANCE3(test_construct_tx, 10, 1, false); + TEST_PERFORMANCE3(test_construct_tx, 10, 2, false); + TEST_PERFORMANCE3(test_construct_tx, 10, 10, false); + TEST_PERFORMANCE3(test_construct_tx, 10, 100, false); - TEST_PERFORMANCE2(test_construct_tx, 100, 1); - TEST_PERFORMANCE2(test_construct_tx, 100, 2); - TEST_PERFORMANCE2(test_construct_tx, 100, 10); - TEST_PERFORMANCE2(test_construct_tx, 100, 100); + TEST_PERFORMANCE3(test_construct_tx, 100, 1, false); + TEST_PERFORMANCE3(test_construct_tx, 100, 2, false); + TEST_PERFORMANCE3(test_construct_tx, 100, 10, false); + TEST_PERFORMANCE3(test_construct_tx, 100, 100, false); - TEST_PERFORMANCE1(test_check_ring_signature, 1); - TEST_PERFORMANCE1(test_check_ring_signature, 2); - TEST_PERFORMANCE1(test_check_ring_signature, 10); - TEST_PERFORMANCE1(test_check_ring_signature, 100); + TEST_PERFORMANCE3(test_construct_tx, 2, 1, true); + TEST_PERFORMANCE3(test_construct_tx, 2, 2, true); + TEST_PERFORMANCE3(test_construct_tx, 2, 10, true); + + TEST_PERFORMANCE3(test_construct_tx, 10, 1, true); + TEST_PERFORMANCE3(test_construct_tx, 10, 2, true); + TEST_PERFORMANCE3(test_construct_tx, 10, 10, true); + + TEST_PERFORMANCE3(test_construct_tx, 100, 1, true); + TEST_PERFORMANCE3(test_construct_tx, 100, 2, true); + TEST_PERFORMANCE3(test_construct_tx, 100, 10, true); + + TEST_PERFORMANCE2(test_check_tx_signature, 1, false); + TEST_PERFORMANCE2(test_check_tx_signature, 2, false); + TEST_PERFORMANCE2(test_check_tx_signature, 10, false); + TEST_PERFORMANCE2(test_check_tx_signature, 100, false); + + TEST_PERFORMANCE2(test_check_tx_signature, 2, true); + TEST_PERFORMANCE2(test_check_tx_signature, 10, true); + TEST_PERFORMANCE2(test_check_tx_signature, 100, true); TEST_PERFORMANCE0(test_is_out_to_acc); TEST_PERFORMANCE0(test_generate_key_image_helper); @@ -82,6 +99,7 @@ int main(int argc, char** argv) TEST_PERFORMANCE0(test_generate_key_image); TEST_PERFORMANCE0(test_derive_public_key); TEST_PERFORMANCE0(test_derive_secret_key); + TEST_PERFORMANCE0(test_ge_frombytes_vartime); TEST_PERFORMANCE0(test_cn_slow_hash); diff --git a/tests/performance_tests/multi_tx_test_base.h b/tests/performance_tests/multi_tx_test_base.h index d8898b60d..feabab022 100644 --- a/tests/performance_tests/multi_tx_test_base.h +++ b/tests/performance_tests/multi_tx_test_base.h @@ -59,7 +59,7 @@ public: return false; txout_to_key tx_out = boost::get<txout_to_key>(m_miner_txs[i].vout[0].target); - output_entries.push_back(std::make_pair(i, rct::ctkey({rct::pk2rct(tx_out.key), rct::identity()}))); + output_entries.push_back(std::make_pair(i, rct::ctkey({rct::pk2rct(tx_out.key), rct::zeroCommit(m_miner_txs[i].vout[0].amount)}))); m_public_keys[i] = tx_out.key; m_public_key_ptrs[i] = &m_public_keys[i]; } @@ -72,6 +72,7 @@ public: source_entry.real_output_in_tx_index = 0; source_entry.outputs.swap(output_entries); source_entry.real_output = real_source_idx; + source_entry.mask = rct::identity(); source_entry.rct = false; m_sources.push_back(source_entry); diff --git a/tests/performance_tests/performance_tests.h b/tests/performance_tests/performance_tests.h index 9781349bf..77707148b 100644 --- a/tests/performance_tests/performance_tests.h +++ b/tests/performance_tests/performance_tests.h @@ -142,3 +142,4 @@ void run_test(const char* test_name) #define TEST_PERFORMANCE0(test_class) run_test< test_class >(QUOTEME(test_class)) #define TEST_PERFORMANCE1(test_class, a0) run_test< test_class<a0> >(QUOTEME(test_class<a0>)) #define TEST_PERFORMANCE2(test_class, a0, a1) run_test< test_class<a0, a1> >(QUOTEME(test_class) "<" QUOTEME(a0) ", " QUOTEME(a1) ">") +#define TEST_PERFORMANCE3(test_class, a0, a1, a2) run_test< test_class<a0, a1, a2> >(QUOTEME(test_class) "<" QUOTEME(a0) ", " QUOTEME(a1) ", " QUOTEME(a2) ">") diff --git a/utils/gpg_keys/iDunk.asc b/utils/gpg_keys/iDunk.asc new file mode 100644 index 000000000..2c480146b --- /dev/null +++ b/utils/gpg_keys/iDunk.asc @@ -0,0 +1,52 @@ +-----BEGIN PGP PUBLIC KEY BLO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