From d53a0669c95eabc400a91be3442782c704471387 Mon Sep 17 00:00:00 2001 From: Some Random Crypto Guy Date: Mon, 9 Jun 2025 11:18:51 +0100 Subject: [PATCH] fixed building issues; added carrot key initialisation to wallet2 --- src/carrot_impl/account.cpp | 5 +++-- src/ringct/rctSigs.h | 4 ++-- src/wallet/CMakeLists.txt | 1 - src/wallet/tx_builder.cpp | 3 ++- src/wallet/wallet2.cpp | 9 +++++++++ src/wallet/wallet2.h | 2 ++ 6 files changed, 18 insertions(+), 6 deletions(-) diff --git a/src/carrot_impl/account.cpp b/src/carrot_impl/account.cpp index f8674fa24..48c79e9a3 100644 --- a/src/carrot_impl/account.cpp +++ b/src/carrot_impl/account.cpp @@ -294,9 +294,10 @@ void carrot_and_legacy_account::generate_subaddress_map() //---------------------------------------------------------------------------------------------------------------------- void carrot_and_legacy_account::generate(const AddressDeriveType default_derive_type) { - legacy_acb.generate(); + //legacy_acb.generate(); - crypto::generate_random_bytes_thread_safe(sizeof(crypto::secret_key), to_bytes(s_master)); + //crypto::generate_random_bytes_thread_safe(sizeof(crypto::secret_key), to_bytes(s_master)); + s_master = legacy_acb.get_keys().m_spend_secret_key; make_carrot_provespend_key(s_master, k_prove_spend); make_carrot_viewbalance_secret(s_master, s_view_balance); make_carrot_generateimage_key(s_view_balance, k_generate_image); diff --git a/src/ringct/rctSigs.h b/src/ringct/rctSigs.h index 9730e2804..930a58de8 100644 --- a/src/ringct/rctSigs.h +++ b/src/ringct/rctSigs.h @@ -92,8 +92,8 @@ namespace rct { zk_proof PRProof_Gen(const rct::key &difference); bool PRProof_Ver(const rct::key &C, const zk_proof &proof); - zk_proof SAProof_Gen(const key &P, const key &x_change, const key &y_change, const key &key_yF); - bool SAProof_Ver(const zk_proof &proof, const key &P, const key &key_yF); + zk_proof SAProof_Gen(const key &P, const key &x_change, const key &y_change); + bool SAProof_Ver(const zk_proof &proof, const key &P); //proveRange and verRange //proveRange gives C, and mask such that \sumCi = C diff --git a/src/wallet/CMakeLists.txt b/src/wallet/CMakeLists.txt index 884f96bc7..ae8c05143 100644 --- a/src/wallet/CMakeLists.txt +++ b/src/wallet/CMakeLists.txt @@ -38,7 +38,6 @@ set(wallet_sources message_store.cpp message_transporter.cpp wallet_rpc_payments.cpp - scanning_tools.cpp tx_builder.cpp ) diff --git a/src/wallet/tx_builder.cpp b/src/wallet/tx_builder.cpp index 19df29cb0..1aeb047be 100644 --- a/src/wallet/tx_builder.cpp +++ b/src/wallet/tx_builder.cpp @@ -639,7 +639,8 @@ std::vector get_sources( const size_t fake_outputs_count = 15; std::vector> outs; std::unordered_set valid_public_keys_cache; - w.get_outs(outs, selected_transfers, fake_outputs_count, true, valid_public_keys_cache); // may throw + wallet2 &w2 = const_cast(w); + w2.get_outs(outs, selected_transfers, fake_outputs_count, true, valid_public_keys_cache); // may throw LOG_PRINT_L2("preparing outputs"); size_t i = 0, out_index = 0; diff --git a/src/wallet/wallet2.cpp b/src/wallet/wallet2.cpp index 74f519bf0..71c7e971e 100644 --- a/src/wallet/wallet2.cpp +++ b/src/wallet/wallet2.cpp @@ -2323,6 +2323,7 @@ bool wallet2::get_yield_summary_info(uint64_t &total_burnt, // Return success to caller return true; } +/* //---------------------------------------------------------------------------------------------------- bool wallet2::verify_spend_authority_proof(const cryptonote::transaction &tx, const size_t i, const tx_scan_info_t &tx_scan_info) { @@ -2394,6 +2395,7 @@ bool wallet2::verify_spend_authority_proof(const cryptonote::transaction &tx, co // Return success to caller return true; } +*/ //---------------------------------------------------------------------------------------------------- void wallet2::scan_key_image(const wallet::enote_view_incoming_scan_info_t &enote_scan_info, const bool pool, @@ -5300,6 +5302,13 @@ bool wallet2::load_keys_buf(const std::string& keys_buf, const epee::wipeable_st r = r && hwdev.verify_keys(keys.m_spend_secret_key, keys.m_account_address.m_spend_public_key); THROW_WALLET_EXCEPTION_IF(!r, error::wallet_files_doesnt_correspond, m_keys_file, m_wallet_file); + if (r) + { + // Generate the Carrot keys here + m_carrot_account.legacy_acb = m_account; + m_carrot_account.generate(); + } + if (r) { if (!m_is_background_wallet) diff --git a/src/wallet/wallet2.h b/src/wallet/wallet2.h index 10d3579c9..22ce8b35d 100644 --- a/src/wallet/wallet2.h +++ b/src/wallet/wallet2.h @@ -2032,8 +2032,10 @@ private: void set_unspent(size_t idx); bool is_spent(const transfer_details &td, bool strict = true) const; bool is_spent(size_t idx, bool strict = true) const; + public: void get_outs(std::vector> &outs, const std::vector &selected_transfers, size_t fake_outputs_count, bool rct, std::unordered_set &valid_public_keys_cache); void get_outs(std::vector> &outs, const std::vector &selected_transfers, size_t fake_outputs_count, std::vector &rct_offsets, std::unordered_set &valid_public_keys_cache, uint64_t &num_spendable_global_outs, uint64_t &num_outs); + private: bool tx_add_fake_output(std::vector> &outs, uint64_t global_index, const crypto::public_key& tx_public_key, const rct::key& mask, uint64_t real_index, bool unlocked, std::unordered_set &valid_public_keys_cache) const; bool should_pick_a_second_output(bool use_rct, size_t n_transfers, const std::vector &unused_transfers_indices, const std::vector &unused_dust_indices) const; std::vector get_only_rct(const std::vector &unused_dust_indices, const std::vector &unused_transfers_indices) const;