From 9c112006669ab48b9073d07880ebb79185d58ce5 Mon Sep 17 00:00:00 2001 From: Some Random Crypto Guy Date: Wed, 23 Jul 2025 10:21:13 +0100 Subject: [PATCH 1/2] fixed RCT types to support ECDHINFO for Salvium One; fixed input and output limits for TXs --- src/carrot_impl/tx_proposal_utils.cpp | 2 +- src/ringct/rctTypes.h | 5 +++-- src/wallet/tx_builder.cpp | 8 ++++---- 3 files changed, 8 insertions(+), 7 deletions(-) diff --git a/src/carrot_impl/tx_proposal_utils.cpp b/src/carrot_impl/tx_proposal_utils.cpp index 884b5825e..f217a0aec 100644 --- a/src/carrot_impl/tx_proposal_utils.cpp +++ b/src/carrot_impl/tx_proposal_utils.cpp @@ -90,7 +90,7 @@ static void append_additional_payment_proposal_if_necessary( //------------------------------------------------------------------------------------------------------------------- std::uint64_t get_carrot_default_tx_extra_size(const std::size_t n_outputs) { - CHECK_AND_ASSERT_THROW_MES(n_outputs <= FCMP_PLUS_PLUS_MAX_OUTPUTS, + CHECK_AND_ASSERT_THROW_MES(n_outputs <= CARROT_MAX_TX_OUTPUTS, "get_carrot_default_tx_extra_size: n_outputs too high: " << n_outputs); CHECK_AND_ASSERT_THROW_MES(n_outputs >= CARROT_MIN_TX_OUTPUTS, "get_carrot_default_tx_extra_size: n_outputs too low: " << n_outputs); diff --git a/src/ringct/rctTypes.h b/src/ringct/rctTypes.h index 4d1fd043e..3436acd2f 100644 --- a/src/ringct/rctTypes.h +++ b/src/ringct/rctTypes.h @@ -446,7 +446,7 @@ namespace rct { return false; for (size_t i = 0; i < outputs; ++i) { - if (type == RCTTypeBulletproofPlus || type == RCTTypeFullProofs || type == RCTTypeSalviumZero) + if (type == RCTTypeBulletproofPlus || type == RCTTypeFullProofs || type == RCTTypeSalviumZero || type == RCTTypeSalviumOne) { // Since RCTTypeBulletproof2 enote types, we don't serialize the blinding factor, and only serialize the // first 8 bytes of ecdhInfo[i].amount @@ -504,7 +504,7 @@ namespace rct { FIELD(outPk) VARINT_FIELD(txnFee) FIELD(p_r) - if (type == RCTTypeSalviumZero) + if (type == RCTTypeSalviumZero || type == RCTTypeSalviumOne) { FIELD(salvium_data) } @@ -673,6 +673,7 @@ namespace rct { FIELD(bulletproofs_plus) FIELD(MGs) FIELD(CLSAGs) + FIELD(TCLSAGs) FIELD(pseudoOuts) END_SERIALIZE() }; diff --git a/src/wallet/tx_builder.cpp b/src/wallet/tx_builder.cpp index e3b9ead74..630482026 100644 --- a/src/wallet/tx_builder.cpp +++ b/src/wallet/tx_builder.cpp @@ -590,7 +590,7 @@ std::vector make_carrot_transaction_proposa const size_t n_inputs = input_key_images.size(); CARROT_CHECK_AND_THROW(n_inputs, carrot::too_few_inputs, "no key images provided"); CARROT_CHECK_AND_THROW(n_dests_per_tx, carrot::too_few_outputs, "sweep must have at least one destination"); - CARROT_CHECK_AND_THROW(n_dests_per_tx <= FCMP_PLUS_PLUS_MAX_OUTPUTS, + CARROT_CHECK_AND_THROW(n_dests_per_tx <= CARROT_MAX_TX_OUTPUTS, carrot::too_many_outputs, "too many sweep destinations per transaction"); // Check that the key image is usable and isn't spent, collect amounts, and get subaddress account index @@ -636,11 +636,11 @@ std::vector make_carrot_transaction_proposa || (!is_selfsend_dest && normal_payment_proposals.size() == i+1), __func__ << ": BUG in build_payment_proposals: incorrect count for payment proposal lists"); } - CARROT_CHECK_AND_THROW(normal_payment_proposals.size() < FCMP_PLUS_PLUS_MAX_OUTPUTS, + CARROT_CHECK_AND_THROW(normal_payment_proposals.size() < CARROT_MAX_TX_OUTPUTS, carrot::too_many_outputs, "too many *outgoing* sweep destinations per tx, we also need 1 self-send output"); // make `n_txs` tx proposals with `n_output` payment proposals each - const size_t n_txs = div_ceil(n_inputs, FCMP_PLUS_PLUS_MAX_INPUTS); + const size_t n_txs = div_ceil(n_inputs, CARROT_MAX_TX_INPUTS); std::vector tx_proposals(n_txs); size_t ki_idx = 0; for (carrot::CarrotTransactionProposalV1 &tx_proposal : tx_proposals) @@ -650,7 +650,7 @@ std::vector make_carrot_transaction_proposa selfsend_payment_proposals.back().proposal.enote_type = carrot::CarrotEnoteType::CHANGE; // collect inputs for this tx - const size_t ki_idx_end = std::min(n_inputs, ki_idx + FCMP_PLUS_PLUS_MAX_INPUTS); + const size_t ki_idx_end = std::min(n_inputs, ki_idx + CARROT_MAX_TX_INPUTS); std::vector selected_inputs; selected_inputs.reserve(n_inputs - ki_idx_end); for (; ki_idx < ki_idx_end; ++ki_idx) From 9e20133ed9365f47cdbe3fb9967f20bbdbc79132 Mon Sep 17 00:00:00 2001 From: Some Random Crypto Guy Date: Wed, 23 Jul 2025 10:35:14 +0100 Subject: [PATCH 2/2] fixed input and output limits for TXs --- src/wallet/tx_builder.cpp | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/wallet/tx_builder.cpp b/src/wallet/tx_builder.cpp index 630482026..1ca433363 100644 --- a/src/wallet/tx_builder.cpp +++ b/src/wallet/tx_builder.cpp @@ -590,7 +590,7 @@ std::vector make_carrot_transaction_proposa const size_t n_inputs = input_key_images.size(); CARROT_CHECK_AND_THROW(n_inputs, carrot::too_few_inputs, "no key images provided"); CARROT_CHECK_AND_THROW(n_dests_per_tx, carrot::too_few_outputs, "sweep must have at least one destination"); - CARROT_CHECK_AND_THROW(n_dests_per_tx <= CARROT_MAX_TX_OUTPUTS, + CARROT_CHECK_AND_THROW(n_dests_per_tx <= carrot::CARROT_MAX_TX_OUTPUTS, carrot::too_many_outputs, "too many sweep destinations per transaction"); // Check that the key image is usable and isn't spent, collect amounts, and get subaddress account index @@ -636,11 +636,11 @@ std::vector make_carrot_transaction_proposa || (!is_selfsend_dest && normal_payment_proposals.size() == i+1), __func__ << ": BUG in build_payment_proposals: incorrect count for payment proposal lists"); } - CARROT_CHECK_AND_THROW(normal_payment_proposals.size() < CARROT_MAX_TX_OUTPUTS, + CARROT_CHECK_AND_THROW(normal_payment_proposals.size() < carrot::CARROT_MAX_TX_OUTPUTS, carrot::too_many_outputs, "too many *outgoing* sweep destinations per tx, we also need 1 self-send output"); // make `n_txs` tx proposals with `n_output` payment proposals each - const size_t n_txs = div_ceil(n_inputs, CARROT_MAX_TX_INPUTS); + const size_t n_txs = div_ceil(n_inputs, carrot::CARROT_MAX_TX_INPUTS); std::vector tx_proposals(n_txs); size_t ki_idx = 0; for (carrot::CarrotTransactionProposalV1 &tx_proposal : tx_proposals) @@ -650,7 +650,7 @@ std::vector make_carrot_transaction_proposa selfsend_payment_proposals.back().proposal.enote_type = carrot::CarrotEnoteType::CHANGE; // collect inputs for this tx - const size_t ki_idx_end = std::min(n_inputs, ki_idx + CARROT_MAX_TX_INPUTS); + const size_t ki_idx_end = std::min(n_inputs, ki_idx + carrot::CARROT_MAX_TX_INPUTS); std::vector selected_inputs; selected_inputs.reserve(n_inputs - ki_idx_end); for (; ki_idx < ki_idx_end; ++ki_idx)