diff --git a/src/common/variant_helper.h b/src/common/variant_helper.h index c1282d00..03d8746a 100644 --- a/src/common/variant_helper.h +++ b/src/common/variant_helper.h @@ -38,6 +38,7 @@ usage: VARIANT_CASE(NLSAG_sig, signatures); VARIANT_CASE(zarcanum_sig, s); //@#@ + VARIANT_CASE_THROW_ON_OTHER(); VARIANT_SWITCH_END(); diff --git a/src/currency_core/blockchain_storage.cpp b/src/currency_core/blockchain_storage.cpp index 41b6e32f..20bc4f0e 100644 --- a/src/currency_core/blockchain_storage.cpp +++ b/src/currency_core/blockchain_storage.cpp @@ -1528,7 +1528,7 @@ bool blockchain_storage::print_transactions_statistics() const // { // total_full_blob += get_object_blobsize(tx_entry.second.tx); // transaction tx = tx_entry.second.tx; -// tx.signatures.clear(); +// signatures.clear(); // total_cropped_blob += get_object_blobsize(tx); // } // } @@ -4295,11 +4295,11 @@ bool blockchain_storage::check_tx_inputs(const transaction& tx, const crypto::ha { if (!m_is_in_checkpoint_zone) { - VARIANT_SWITCH_BEGIN(tx.signatures); + VARIANT_SWITCH_BEGIN(tx.signature); VARIANT_CASE(void_sig, v); VARIANT_CASE(NLSAG_sig, signatures); { - CHECK_AND_ASSERT_MES(sig_index < tx.signatures.s.size(), false, "Wrong transaction: missing signature entry for input #" << sig_index << " tx: " << tx_prefix_hash); + CHECK_AND_ASSERT_MES(sig_index < signatures.s.size(), false, "Wrong transaction: missing signature entry for input #" << sig_index << " tx: " << tx_prefix_hash); psig = &signatures.s[sig_index]; } VARIANT_CASE(zarcanum_sig, s); @@ -4366,7 +4366,15 @@ bool blockchain_storage::check_tx_inputs(const transaction& tx, const crypto::ha TIME_MEASURE_START_PD(tx_check_inputs_attachment_check); if (!m_is_in_checkpoint_zone) { - CHECK_AND_ASSERT_MES(tx.signatures.size() == sig_index, false, "tx signatures count differs from inputs"); + VARIANT_SWITCH_BEGIN(tx.signature); + VARIANT_CASE(NLSAG_sig, signatures) + { + CHECK_AND_ASSERT_MES(signatures.size() == sig_index, false, "tx signatures count differs from inputs"); + } + VARIANT_CASE(zarcanum_sig, s); + //@#@ + VARIANT_CASE_THROW_ON_OTHER(); + VARIANT_SWITCH_END(); if (!(get_tx_flags(tx) & TX_FLAG_SIGNATURE_MODE_SEPARATE)) { bool r = validate_attachment_info(tx.extra, tx.attachment, false); @@ -4607,7 +4615,7 @@ bool blockchain_storage::check_ms_input(const transaction& tx, size_t in_index, VARIANT_CASE(void_sig, v); VARIANT_CASE(NLSAG_sig, signatures) { - LOC_CHK(tx.signatures.size() > in_index, "ms input index is out of signatures container bounds, tx.signatures.size() = " << tx.signatures.size()); + LOC_CHK(signatures.size() > in_index, "ms input index is out of signatures container bounds, signatures.size() = " << signatures.size()); const std::vector& input_signatures = signatures.s[in_index]; size_t expected_signatures_count = txin.sigs_count; @@ -7005,7 +7013,7 @@ bool blockchain_storage::validate_alt_block_txs(const block& b, const crypto::ha const transaction& tx = it == abei.onboard_transactions.end() ? *tx_ptr : it->second; if (tx.signature.type() == typeid(NLSAG_sig)) { - CHECK_AND_ASSERT_MES(boost::get(tx.signature).s.size() == tx.vin.size(), false, "invalid tx: tx.signatures.size() == " << boost::get(tx.signature).s.size() << ", tx.vin.size() == " << tx.vin.size()); + CHECK_AND_ASSERT_MES(boost::get(tx.signature).s.size() == tx.vin.size(), false, "invalid tx: signatures.size() == " << boost::get(tx.signature).s.size() << ", tx.vin.size() == " << tx.vin.size()); } for (size_t n = 0; n < tx.vin.size(); ++n) { diff --git a/src/currency_core/core_runtime_config.h b/src/currency_core/core_runtime_config.h index 214a1590..1f8aa1e6 100644 --- a/src/currency_core/core_runtime_config.h +++ b/src/currency_core/core_runtime_config.h @@ -36,11 +36,11 @@ namespace currency { switch (hardfork_id) { - case 0: return true; - case 1: return height > hard_forks.hard_fork_01_starts_after_height; - case 2: return height > hard_forks.hard_fork_02_starts_after_height; - case 3: return height > hard_forks.hard_fork_03_starts_after_height; - case 4: return height > hard_forks.hard_fork_04_starts_after_height; + case ZANO_HARDFORK_00_INITAL: return true; + case ZANO_HARDFORK_01: return height > hard_forks.hard_fork_01_starts_after_height; + case ZANO_HARDFORK_02: return height > hard_forks.hard_fork_02_starts_after_height; + case ZANO_HARDFORK_03: return height > hard_forks.hard_fork_03_starts_after_height; + case ZANO_HARDFORK_04_ZARCANUM: return height > hard_forks.hard_fork_04_starts_after_height; default: return false; } } diff --git a/src/currency_core/currency_boost_serialization.h b/src/currency_core/currency_boost_serialization.h index b25b1b10..76cefc06 100644 --- a/src/currency_core/currency_boost_serialization.h +++ b/src/currency_core/currency_boost_serialization.h @@ -227,7 +227,7 @@ namespace boost a & x.vin; a & x.vout; a & x.extra; - a & x.signatures; + a & x.signature; a & x.attachment; } diff --git a/src/currency_core/currency_config.h b/src/currency_core/currency_config.h index 8275d11a..37d40601 100644 --- a/src/currency_core/currency_config.h +++ b/src/currency_core/currency_config.h @@ -253,6 +253,13 @@ #endif +#define ZANO_HARDFORK_00_INITAL 0 +#define ZANO_HARDFORK_01 1 +#define ZANO_HARDFORK_02 2 +#define ZANO_HARDFORK_03 3 +#define ZANO_HARDFORK_04_ZARCANUM 4 + + static_assert(CURRENCY_MINER_TX_MAX_OUTS <= CURRENCY_TX_MAX_ALLOWED_OUTS, "Miner tx must obey normal tx max outs limit"); diff --git a/src/wallet/wallet2.cpp b/src/wallet/wallet2.cpp index b69178fe..cce55f04 100644 --- a/src/wallet/wallet2.cpp +++ b/src/wallet/wallet2.cpp @@ -3462,6 +3462,12 @@ bool wallet2::get_pos_entries(currency::COMMAND_RPC_SCAN_POS::request& req) return true; } //---------------------------------------------------------------------------------------------------- +bool wallet2::is_in_hardfork_zone(uint64_t hardfork_index) +{ + const currency::core_runtime_config& rtc = get_core_runtime_config(); + return rtc.is_hardfork_active_for_height(hardfork_index, get_blockchain_current_size()); +} +//---------------------------------------------------------------------------------------------------- bool wallet2::prepare_and_sign_pos_block(currency::block& b, const currency::pos_entry& pos_info, const crypto::public_key& source_tx_pub_key, @@ -3473,43 +3479,51 @@ bool wallet2::prepare_and_sign_pos_block(currency::block& b, WLT_CHECK_AND_ASSERT_MES(b.miner_tx.vin[1].type() == typeid(currency::txin_to_key), false, "Wrong output input in transaction"); auto& txin = boost::get(b.miner_tx.vin[1]); txin.k_image = pos_info.keyimage; - WLT_CHECK_AND_ASSERT_MES(b.miner_tx.signatures.size() == 1 && b.miner_tx.signatures[0].size() == txin.key_offsets.size(), - false, "Wrong signatures amount in coinbase transacton"); + + if (is_in_hardfork_zone(ZANO_HARDFORK_04_ZARCANUM)) + { + //@#@ TODO: add proper support of Zarcanum + WLT_THROW_IF_FALSE_WALLET_CMN_ERR_EX(false, "ZRCANUM BLOCKS NOT IMPLEMENTED YET"); + }else + { + NLSAG_sig& signatures = boost::get(b.miner_tx.signature); + WLT_CHECK_AND_ASSERT_MES(signatures.size() == 1 && signatures[0].size() == txin.key_offsets.size(), + false, "Wrong signatures amount in coinbase transacton"); + //derive secret key + crypto::key_derivation pos_coin_derivation = AUTO_VAL_INIT(pos_coin_derivation); + bool r = crypto::generate_key_derivation(source_tx_pub_key, + m_account.get_keys().view_secret_key, + pos_coin_derivation); - //derive secret key - crypto::key_derivation pos_coin_derivation = AUTO_VAL_INIT(pos_coin_derivation); - bool r = crypto::generate_key_derivation(source_tx_pub_key, - m_account.get_keys().view_secret_key, - pos_coin_derivation); + WLT_CHECK_AND_ASSERT_MES(r, false, "internal error: pos coin base generator: failed to generate_key_derivation(" + << source_tx_pub_key + << ", view secret key: " << m_account.get_keys().view_secret_key << ")"); - WLT_CHECK_AND_ASSERT_MES(r, false, "internal error: pos coin base generator: failed to generate_key_derivation(" - << source_tx_pub_key - << ", view secret key: " << m_account.get_keys().view_secret_key << ")"); + crypto::secret_key derived_secret_ephemeral_key = AUTO_VAL_INIT(derived_secret_ephemeral_key); + crypto::derive_secret_key(pos_coin_derivation, + in_tx_output_index, + m_account.get_keys().spend_secret_key, + derived_secret_ephemeral_key); - crypto::secret_key derived_secret_ephemeral_key = AUTO_VAL_INIT(derived_secret_ephemeral_key); - crypto::derive_secret_key(pos_coin_derivation, - in_tx_output_index, - m_account.get_keys().spend_secret_key, - derived_secret_ephemeral_key); + // sign block actually in coinbase transaction + crypto::hash block_hash = currency::get_block_hash(b); - // sign block actually in coinbase transaction - crypto::hash block_hash = currency::get_block_hash(b); + crypto::generate_ring_signature(block_hash, + txin.k_image, + keys_ptrs, + derived_secret_ephemeral_key, + 0, + &signatures[0][0]); - crypto::generate_ring_signature(block_hash, - txin.k_image, - keys_ptrs, - derived_secret_ephemeral_key, - 0, - &b.miner_tx.signatures[0][0]); + WLT_LOG_L4("GENERATED RING SIGNATURE: block_id " << block_hash + << "txin.k_image" << txin.k_image + << "key_ptr:" << *keys_ptrs[0] + << "signature:" << signatures[0][0]); - WLT_LOG_L4("GENERATED RING SIGNATURE: block_id " << block_hash - << "txin.k_image" << txin.k_image - << "key_ptr:" << *keys_ptrs[0] - << "signature:" << b.miner_tx.signatures[0][0]); - - return true; + return true; + } } //------------------------------------------------------------------ bool wallet2::build_kernel(const pos_entry& pe, const stake_modifier_type& stake_modifier, const uint64_t timestamp, stake_kernel& kernel) diff --git a/src/wallet/wallet2.h b/src/wallet/wallet2.h index 0a1d7e70..dae73d0b 100644 --- a/src/wallet/wallet2.h +++ b/src/wallet/wallet2.h @@ -1014,6 +1014,7 @@ private: uint64_t detach_from_block_ids(uint64_t height); uint64_t get_wallet_minimum_height(); uint64_t get_directly_spent_transfer_id_by_input_in_tracking_wallet(const currency::txin_to_key& intk); + bool is_in_hardfork_zone(uint64_t hardfork_index); void push_alias_info_to_extra_according_to_hf_status(const currency::extra_alias_entry& ai, std::vector& extra); void remove_transfer_from_amount_gindex_map(uint64_t tid); diff --git a/src/wallet/wallet2_escrow.cpp b/src/wallet/wallet2_escrow.cpp index bbf2b533..9c7e342c 100644 --- a/src/wallet/wallet2_escrow.cpp +++ b/src/wallet/wallet2_escrow.cpp @@ -233,28 +233,36 @@ bool wallet2::validate_escrow_release(const transaction& tx, bool release_type_n // (5/5) signatures - LOC_CHK(tx.signatures.size() == 1, "invalid singatures size: " << tx.signatures.size()); // only 1 input means only 1 signature vector + VARIANT_SWITCH_BEGIN(tx.signature); + VARIANT_CASE(NLSAG_sig, signatures) + { + LOC_CHK(signatures.size() == 1, "invalid singatures size: " << signatures.size()); // only 1 input means only 1 signature vector - // As we don't have b_keys we can't be sure which signature is B's and which is reserved for A (should be a null-placeholder, if present). - // Having a_keys, we determine index of A key in multisig output keys array. - // Thus it's possible to determine the order of signatures (A, B or B, A), and, eventually, validate B signature. - crypto::public_key source_tx_pub_key = get_tx_pub_key_from_extra(source_tx); - r = crypto::generate_key_derivation(source_tx_pub_key, a_keys.view_secret_key, der); - LOC_CHK(r, "generate_key_derivation failed"); - crypto::public_key ephemeral_pub_key = AUTO_VAL_INIT(ephemeral_pub_key); - r = crypto::derive_public_key(der, source_ms_out_index, a_keys.account_address.spend_public_key, ephemeral_pub_key); - LOC_CHK(r, "derive_public_key failed"); + // As we don't have b_keys we can't be sure which signature is B's and which is reserved for A (should be a null-placeholder, if present). + // Having a_keys, we determine index of A key in multisig output keys array. + // Thus it's possible to determine the order of signatures (A, B or B, A), and, eventually, validate B signature. + crypto::public_key source_tx_pub_key = get_tx_pub_key_from_extra(source_tx); + r = crypto::generate_key_derivation(source_tx_pub_key, a_keys.view_secret_key, der); + LOC_CHK(r, "generate_key_derivation failed"); + crypto::public_key ephemeral_pub_key = AUTO_VAL_INIT(ephemeral_pub_key); + r = crypto::derive_public_key(der, source_ms_out_index, a_keys.account_address.spend_public_key, ephemeral_pub_key); + LOC_CHK(r, "derive_public_key failed"); - LOC_CHK(source_ms_out.keys.size() == 2, "internal error: invalid ms output keys array, size: " << source_ms_out.keys.size()); - LOC_CHK(tx.signatures[0].size() == 2, "internal error: invalid signature size for input #0: " << tx.signatures[0].size()) - size_t ms_out_key_a_index = std::find(source_ms_out.keys.begin(), source_ms_out.keys.end(), ephemeral_pub_key) - source_ms_out.keys.begin(); - LOC_CHK(ms_out_key_a_index < source_ms_out.keys.size(), "internal error: can't find A ephemeral pub key within ms output keys"); - size_t ms_out_key_b_index = 1 - ms_out_key_a_index; + LOC_CHK(source_ms_out.keys.size() == 2, "internal error: invalid ms output keys array, size: " << source_ms_out.keys.size()); + LOC_CHK(signatures[0].size() == 2, "internal error: invalid signature size for input #0: " << signatures[0].size()) + size_t ms_out_key_a_index = std::find(source_ms_out.keys.begin(), source_ms_out.keys.end(), ephemeral_pub_key) - source_ms_out.keys.begin(); + LOC_CHK(ms_out_key_a_index < source_ms_out.keys.size(), "internal error: can't find A ephemeral pub key within ms output keys"); + size_t ms_out_key_b_index = 1 - ms_out_key_a_index; - // in this particular case (source_ms_out.minimum_sigs == source_ms_out.keys.size() == 2) index in 'keys' is the same as index in tx.signatures[0] - crypto::hash tx_hash_for_signature = prepare_prefix_hash_for_sign(tx, 0, get_transaction_hash(tx)); - r = crypto::check_signature(tx_hash_for_signature, source_ms_out.keys[ms_out_key_b_index], tx.signatures[0][ms_out_key_b_index]); - LOC_CHK(r, "B signature for multisig input is invalid"); + // in this particular case (source_ms_out.minimum_sigs == source_ms_out.keys.size() == 2) index in 'keys' is the same as index in signatures[0] + crypto::hash tx_hash_for_signature = prepare_prefix_hash_for_sign(tx, 0, get_transaction_hash(tx)); + r = crypto::check_signature(tx_hash_for_signature, source_ms_out.keys[ms_out_key_b_index], signatures[0][ms_out_key_b_index]); + LOC_CHK(r, "B signature for multisig input is invalid"); + } + VARIANT_CASE(zarcanum_sig, s); + //@#@ + VARIANT_CASE_THROW_ON_OTHER(); + VARIANT_SWITCH_END(); return true; #undef LOC_CHK @@ -409,15 +417,24 @@ bool wallet2::validate_escrow_cancel_release(const currency::transaction& tx, co // (5/5) signatures - LOC_CHK(tx.signatures.size() == 1, "invalid singatures size: " << tx.signatures.size()); // only 1 input means only 1 signature vector - LOC_CHK(tx.signatures[0].size() == 2, "invalid signature[0] size: " << tx.signatures[0].size()); // it's expected to contain A-party signature and null-sig placeholder - LOC_CHK(source_ms_out.keys.size() == 2, "internal error: invalid source ms output keys array, size: " << source_ms_out.keys.size()); + VARIANT_SWITCH_BEGIN(tx.signature); + VARIANT_CASE(NLSAG_sig, signatures) + { + LOC_CHK(signatures.size() == 1, "invalid singatures size: " << signatures.size()); // only 1 input means only 1 signature vector + LOC_CHK(signatures[0].size() == 2, "invalid signature[0] size: " << signatures[0].size()); // it's expected to contain A-party signature and null-sig placeholder + LOC_CHK(source_ms_out.keys.size() == 2, "internal error: invalid source ms output keys array, size: " << source_ms_out.keys.size()); - size_t a_sign_index = (tx.signatures[0][0] != null_sig) ? 0 : 1; + size_t a_sign_index = (signatures[0][0] != null_sig) ? 0 : 1; + + crypto::hash tx_hash_for_signature = prepare_prefix_hash_for_sign(tx, 0, get_transaction_hash(tx)); + r = crypto::check_signature(tx_hash_for_signature, source_ms_out.keys[a_sign_index], signatures[0][a_sign_index]); + LOC_CHK(r, "A signature for multisig input is invalid"); + } + VARIANT_CASE(zarcanum_sig, s); + //@#@ + VARIANT_CASE_THROW_ON_OTHER(); + VARIANT_SWITCH_END(); - crypto::hash tx_hash_for_signature = prepare_prefix_hash_for_sign(tx, 0, get_transaction_hash(tx)); - r = crypto::check_signature(tx_hash_for_signature, source_ms_out.keys[a_sign_index], tx.signatures[0][a_sign_index]); - LOC_CHK(r, "A signature for multisig input is invalid"); return true; #undef LOC_CHK diff --git a/tests/core_tests/chaingen.cpp b/tests/core_tests/chaingen.cpp index 3ce1d381..714efaee 100644 --- a/tests/core_tests/chaingen.cpp +++ b/tests/core_tests/chaingen.cpp @@ -1842,9 +1842,9 @@ bool sign_multisig_input_in_tx_custom(currency::transaction& tx, size_t ms_input bool r = currency::derive_ephemeral_key_helper(keys, source_tx_pub_key, ms_out_index, ms_in_ephemeral_key); LOC_CHK(r, "derive_ephemeral_key_helper failed"); - LOC_CHK(ms_input_index < tx.signatures.size(), "transaction does not have signatures vectory entry for ms input #" << ms_input_index); + LOC_CHK(ms_input_index < boost::get(tx.signature).s.size(), "transaction does not have signatures vectory entry for ms input #" << ms_input_index); - auto& sigs = tx.signatures[ms_input_index]; + auto& sigs = boost::get(tx.signature).s[ms_input_index]; LOC_CHK(!sigs.empty(), "empty signatures container"); bool extra_signature_expected = (get_tx_flags(tx) & TX_FLAG_SIGNATURE_MODE_SEPARATE) && ms_input_index == tx.vin.size() - 1; size_t allocated_sigs_for_participants = extra_signature_expected ? sigs.size() - 1 : sigs.size(); diff --git a/tests/core_tests/chaingen.h b/tests/core_tests/chaingen.h index 364d07e2..6a3d7f5d 100644 --- a/tests/core_tests/chaingen.h +++ b/tests/core_tests/chaingen.h @@ -743,7 +743,7 @@ bool construct_broken_tx(const currency::account_keys& sender_account_keys, cons { tx.vin.clear(); tx.vout.clear(); - tx.signatures.clear(); + boost::get(tx.signature).s.clear(); tx.extra = extra; tx.version = TRANSACTION_VERSION_PRE_HF4; @@ -845,8 +845,8 @@ bool construct_broken_tx(const currency::account_keys& sender_account_keys, cons ss_ring_s << o.second << ENDL; } - tx.signatures.push_back(std::vector()); - std::vector& sigs = tx.signatures.back(); + boost::get(tx.signature).s.push_back(std::vector()); + std::vector& sigs = boost::get(tx.signature).s.back(); sigs.resize(src_entr.outputs.size()); crypto::generate_ring_signature(tx_prefix_hash, boost::get(tx.vin[i]).k_image, keys_ptrs, in_contexts[i].in_ephemeral.sec, src_entr.real_output, sigs.data()); ss_ring_s << "signatures:" << ENDL; diff --git a/tests/core_tests/chaingen_helpers.h b/tests/core_tests/chaingen_helpers.h index 2f5921f9..823df8fc 100644 --- a/tests/core_tests/chaingen_helpers.h +++ b/tests/core_tests/chaingen_helpers.h @@ -218,7 +218,7 @@ inline bool resign_tx(const currency::account_keys& sender_keys, const std::vect if (sources.size() != tx.vin.size()) return false; - tx.signatures.clear(); + boost::get(tx.signature).s.clear(); crypto::hash tx_prefix_hash = get_transaction_hash(tx); size_t i = 0; @@ -234,8 +234,8 @@ inline bool resign_tx(const currency::account_keys& sender_keys, const std::vect return false; crypto::derive_secret_key(recv_derivation, se.real_output_in_tx_index, sender_keys.spend_secret_key, in_ephemeral_sec); - tx.signatures.push_back(std::vector()); - std::vector& sigs = tx.signatures.back(); + boost::get(tx.signature).s.push_back(std::vector()); + std::vector& sigs = boost::get(tx.signature).s.back(); if (se.is_multisig()) { diff --git a/tests/core_tests/chaingen_main.cpp b/tests/core_tests/chaingen_main.cpp index d09d1558..9339c9a3 100644 --- a/tests/core_tests/chaingen_main.cpp +++ b/tests/core_tests/chaingen_main.cpp @@ -308,7 +308,7 @@ public: return; // skip certainly invalid txs bool b_cp = c.get_blockchain_storage().is_in_checkpoint_zone(); - if (b_cp && tx.signatures.empty() && tx.attachment.empty()) + if (b_cp && boost::get(tx.signature).s.empty() && tx.attachment.empty()) return; // skip pruned txs in CP zone size_t tx_expected_blob_size = get_object_blobsize(tx); @@ -328,7 +328,7 @@ public: { // tx seems to be correct ( tx_expected_blob_size == blob.size() ) or BCS is in CP zone, prune sigs and attachments and check again currency::transaction pruned_tx = tx; - pruned_tx.signatures.clear(); + boost::get(pruned_tx.signature).s.clear(); pruned_tx.attachment.clear(); size_t pruned_tx_expected_blob_size = get_object_blobsize(pruned_tx); diff --git a/tests/core_tests/checkpoints_tests.cpp b/tests/core_tests/checkpoints_tests.cpp index 76e262da..f2dca325 100644 --- a/tests/core_tests/checkpoints_tests.cpp +++ b/tests/core_tests/checkpoints_tests.cpp @@ -121,7 +121,7 @@ bool gen_checkpoints_attachments_basic::check_tx(currency::core& c, size_t ev_in bool r = c.get_transaction(m_tx_hash, tx); CHECK_AND_ASSERT_MES(r, false, "can't get transaction"); - CHECK_AND_ASSERT_MES(tx.signatures.empty(), false, "tx has non-empty sig"); + CHECK_AND_ASSERT_MES(boost::get(tx.signature).s.empty(), false, "tx has non-empty sig"); CHECK_AND_ASSERT_MES(tx.attachment.empty(), false, "tx has non-empty attachments"); return true; } @@ -443,12 +443,12 @@ bool gen_checkpoints_prun_txs_after_blockchain_load::check_txs(currency::core& c transaction tx_0, tx_1; bool r = c.get_transaction(m_tx0_id, tx_0); CHECK_AND_ASSERT_MES(r, false, "can't get transaction tx_0"); - CHECK_AND_ASSERT_MES(tx_0.signatures.empty(), false, "tx_0 has non-empty sig"); + CHECK_AND_ASSERT_MES(boost::get(tx_0.signature).s.empty(), false, "tx_0 has non-empty sig"); CHECK_AND_ASSERT_MES(tx_0.attachment.empty(), false, "tx_0 has non-empty attachments"); r = c.get_transaction(m_tx1_id, tx_1); CHECK_AND_ASSERT_MES(r, false, "can't get transaction tx_1"); - CHECK_AND_ASSERT_MES(!tx_1.signatures.empty(), false, "tx_1 has empty sig"); + CHECK_AND_ASSERT_MES(!boost::get(tx_1.signature).s.empty(), false, "tx_1 has empty sig"); CHECK_AND_ASSERT_MES(!tx_1.attachment.empty(), false, "tx_1 has empty attachments"); return true; @@ -595,7 +595,7 @@ bool gen_checkpoints_pos_validation_on_altchain::generate(std::vector(pb.m_block.miner_tx.signature).s[0].clear(); // just to make sure blk_2 = pb.m_block; } @@ -877,7 +877,7 @@ bool gen_checkpoints_and_invalid_tx_to_pool::generate(std::vector(tx_0.signature).s.clear(); DO_CALLBACK(events, "mark_unverifiable_tx"); events.push_back(tx_0); diff --git a/tests/core_tests/escrow_wallet_common.h b/tests/core_tests/escrow_wallet_common.h index 4e9ddf90..813e2597 100644 --- a/tests/core_tests/escrow_wallet_common.h +++ b/tests/core_tests/escrow_wallet_common.h @@ -253,8 +253,8 @@ inline bool build_custom_escrow_template(const std::vector& ev if (custom_config_mask & eccf_template_no_a_sigs) { - escrow_template_tx.signatures.clear(); - escrow_template_tx.signatures.push_back(std::vector()); + boost::get(escrow_template_tx.signature).s.clear(); + boost::get(escrow_template_tx.signature).s.push_back(std::vector()); } append_vector_by_another_vector(used_sources, sources); diff --git a/tests/core_tests/multisig_wallet_tests.cpp b/tests/core_tests/multisig_wallet_tests.cpp index 4af7576f..717be7f0 100644 --- a/tests/core_tests/multisig_wallet_tests.cpp +++ b/tests/core_tests/multisig_wallet_tests.cpp @@ -1034,7 +1034,7 @@ bool multisig_minimum_sigs::generate(std::vector& events) cons CHECK_AND_ASSERT_MES(r && !tx_fully_signed, false, "sign_multisig_input_in_tx failed, tx_fully_signed : " << tx_fully_signed); r = sign_multisig_input_in_tx_custom(tx_7, ms_6_out_idx, miner_acc.get_keys(), tx_6, &tx_fully_signed, false); CHECK_AND_ASSERT_MES(r && !tx_fully_signed, false, "sign_multisig_input_in_tx failed, tx_fully_signed : " << tx_fully_signed); - tx_7.signatures[0].push_back(invalid_signature); // instead of 4th sig just add invalid sig + boost::get(tx_7.signature).s[0].push_back(invalid_signature); // instead of 4th sig just add invalid sig DO_CALLBACK(events, "mark_invalid_tx"); events.push_back(tx_7); @@ -1070,7 +1070,7 @@ bool multisig_minimum_sigs::generate(std::vector& events) cons r = construct_tx(miner_acc.get_keys(), std::vector({ se }), std::vector({ tx_destination_entry(se.amount - TESTS_DEFAULT_FEE, alice_acc.get_public_address()) }), empty_attachment, tx_9, get_tx_version_from_events(events), 0); CHECK_AND_ASSERT_MES(r, false, "construct_tx failed"); - tx_9.signatures[0].resize(redundant_keys_count, invalid_signature); + boost::get(tx_9.signature).s[0].resize(redundant_keys_count, invalid_signature); r = sign_multisig_input_in_tx_custom(tx_9, ms_8_out_idx, bob_acc.get_keys(), tx_8, &tx_fully_signed, false); CHECK_AND_ASSERT_MES(r && !tx_fully_signed, false, "sign_multisig_input_in_tx failed, tx_fully_signed : " << tx_fully_signed); @@ -1844,7 +1844,7 @@ bool multisig_and_checkpoints_bad_txs::generate(std::vector& e transaction tx_2 = AUTO_VAL_INIT(tx_2); r = make_tx_multisig_to_key(tx_1, get_tx_out_index_by_amount(tx_1, amount), std::list({ alice_acc.get_keys() }), bob_acc.get_public_address(), tx_2); CHECK_AND_ASSERT_MES(r, false, "make_tx_multisig_to_key failed"); - tx_2.signatures.resize(10); + boost::get(tx_2.signature).s.resize(10); boost::get(tx_2.vin[0]).sigs_count = 10; DO_CALLBACK(events, "mark_invalid_tx"); @@ -1860,7 +1860,7 @@ bool multisig_and_checkpoints_bad_txs::generate(std::vector& e transaction tx_3 = AUTO_VAL_INIT(tx_3); r = make_tx_multisig_to_key(tx_1, get_tx_out_index_by_amount(tx_1, amount), std::list({ alice_acc.get_keys() }), bob_acc.get_public_address(), tx_3); CHECK_AND_ASSERT_MES(r, false, "make_tx_multisig_to_key failed"); - tx_3.signatures.clear(); + boost::get(tx_3.signature).s.clear(); boost::get(tx_3.vin[0]).sigs_count = 0; events.push_back(event_visitor_settings(event_visitor_settings::set_txs_kept_by_block, true)); @@ -1892,7 +1892,7 @@ bool multisig_and_checkpoints_bad_txs::generate(std::vector& e boost::get(txb.boost::get(m_tx.vout[0]).target).keys.resize(1500, k); txb.step4_calc_hash(); txb.step5_sign(sources); - txb.m_tx.signatures.clear(); + boost::get(txb.m_tx.signature).s.clear(); transaction tx_6 = txb.m_tx; events.push_back(event_visitor_settings(event_visitor_settings::set_txs_kept_by_block, true)); events.push_back(tx_6); @@ -2113,7 +2113,7 @@ bool ref_by_id_basics::generate(std::vector& events) const r = construct_tx(miner_acc.get_keys(), sources, destinations, empty_attachment, tx_1, 0, CURRENCY_TO_KEY_OUT_RELAXED, true); CHECK_AND_ASSERT_MES(r, false, "construct_tx"); - r = check_ring_signature_at_gen_time(events, get_block_hash(blk_0r), boost::get(tx_1.vin[0]), get_transaction_hash(tx_1), tx_1.signatures[0]); + r = check_ring_signature_at_gen_time(events, get_block_hash(blk_0r), boost::get(tx_1.vin[0]), get_transaction_hash(tx_1), boost::get(tx_1.signature).s[0]); CHECK_AND_ASSERT_MES(r, false, "check_ring_signature_at_gen_time failed"); events.push_back(tx_1); diff --git a/tests/core_tests/pos_block_builder.cpp b/tests/core_tests/pos_block_builder.cpp index 811563fb..a7367922 100644 --- a/tests/core_tests/pos_block_builder.cpp +++ b/tests/core_tests/pos_block_builder.cpp @@ -173,7 +173,7 @@ void pos_block_builder::step5_sign(const crypto::public_key& stake_tx_pub_key, s // sign block actually in coinbase transaction crypto::hash block_hash = currency::get_block_hash(m_block); std::vector keys_ptrs(1, &stake_tx_out_pub_key); - crypto::generate_ring_signature(block_hash, m_stake_kernel.kimage, keys_ptrs, derived_secret_ephemeral_key, 0, &m_block.miner_tx.signatures[0][0]); + crypto::generate_ring_signature(block_hash, m_stake_kernel.kimage, keys_ptrs, derived_secret_ephemeral_key, 0, &boost::get(m_block.miner_tx.signature).s[0][0]); m_step = 5; } @@ -272,8 +272,8 @@ bool construct_homemade_pos_miner_tx(size_t height, size_t median_size, const bo posin.k_image = pos_stake_keyimage; tx.vin.push_back(posin); //reserve place for ring signature - tx.signatures.resize(1); - tx.signatures[0].resize(posin.key_offsets.size()); + boost::get(tx.signature).s.resize(1); + boost::get(tx.signature).s[0].resize(posin.key_offsets.size()); return true; } diff --git a/tests/core_tests/pos_validation.cpp b/tests/core_tests/pos_validation.cpp index 0cfb69ff..ce02e351 100644 --- a/tests/core_tests/pos_validation.cpp +++ b/tests/core_tests/pos_validation.cpp @@ -358,7 +358,7 @@ bool gen_pos_invalid_coinbase::generate(std::vector& events) c pb.step4_generate_coinbase_tx(generator.get_timestamps_median(prev_id), generator.get_already_generated_coins(prev_block), alice_acc.get_public_address()); pb.step5_sign(stake_tx_pub_key, stake_output_idx, stake_output_pubkey, miner_acc); - pb.m_block.miner_tx.signatures.clear(); // remove signatures + boost::get(pb.m_block.miner_tx.signature).s.clear(); // remove signatures block blk_1 = pb.m_block; diff --git a/tests/core_tests/pruning_ring_signatures.cpp b/tests/core_tests/pruning_ring_signatures.cpp index aedebf6f..5f2b3c46 100644 --- a/tests/core_tests/pruning_ring_signatures.cpp +++ b/tests/core_tests/pruning_ring_signatures.cpp @@ -25,8 +25,8 @@ struct ev_visitor : public boost::static_visitor { size_t real_bloc_size = t_serializable_object_to_blob(t).size(); - std::cout << "prunging sigs: " << t.signatures.size() << ENDL; - t.signatures.clear(); + std::cout << "prunging sigs: " << boost::get(t.signature).s.size() << ENDL; + boost::get(t.signature).s.clear(); //check tx pruning correctnes if (real_bloc_size != get_object_blobsize(t)) diff --git a/tests/core_tests/transaction_tests.cpp b/tests/core_tests/transaction_tests.cpp index 6607e262..b9a278d9 100644 --- a/tests/core_tests/transaction_tests.cpp +++ b/tests/core_tests/transaction_tests.cpp @@ -110,7 +110,7 @@ bool test_transaction_generation_and_ring_signature() output_keys.push_back(&boost::get(boost::get(tx_mine_4.vout[0]).target).key); output_keys.push_back(&boost::get(boost::get(tx_mine_5.vout[0]).target).key); output_keys.push_back(&boost::get(boost::get(tx_mine_6.vout[0]).target).key); - r = crypto::check_ring_signature(pref_hash, boost::get(tx_rc1.vin[0]).k_image, output_keys, &tx_rc1.signatures[0][0]); + r = crypto::check_ring_signature(pref_hash, boost::get(tx_rc1.vin[0]).k_image, output_keys, &boost::get(tx_rc1.signature).s[0][0]); CHECK_AND_ASSERT_MES(r, false, "failed to check ring signature"); std::vector outs; diff --git a/tests/core_tests/tx_builder.h b/tests/core_tests/tx_builder.h index 085f62ed..00aff6b0 100644 --- a/tests/core_tests/tx_builder.h +++ b/tests/core_tests/tx_builder.h @@ -98,7 +98,7 @@ struct tx_builder void step5_sign(const std::vector& sources) { - m_tx.signatures.clear(); + boost::get(m_tx.signature).s.clear(); size_t i = 0; for(const currency::tx_source_entry& src_entr : sources) @@ -109,8 +109,8 @@ struct tx_builder keys_ptrs.push_back(&o.second); } - m_tx.signatures.push_back(std::vector()); - std::vector& sigs = m_tx.signatures.back(); + boost::get(m_tx.signature).s.push_back(std::vector()); + std::vector& sigs = boost::get(m_tx.signature).s.back(); sigs.resize(src_entr.outputs.size()); generate_ring_signature(m_tx_prefix_hash, boost::get(m_tx.vin[i]).k_image, keys_ptrs, m_in_contexts[i].sec, src_entr.real_output, sigs.data()); i++; diff --git a/tests/core_tests/tx_validation.cpp b/tests/core_tests/tx_validation.cpp index a57426fd..f83ad53a 100644 --- a/tests/core_tests/tx_validation.cpp +++ b/tests/core_tests/tx_validation.cpp @@ -370,9 +370,9 @@ bool gen_tx_key_image_not_derive_from_tx_key::generate(std::vector(); + boost::get(builder.m_tx.signature).s.resize(1); + boost::get(builder.m_tx.signature).s[0].resize(1); + boost::get(builder.m_tx.signature).s[0][0] = boost::value_initialized(); DO_CALLBACK(events, "mark_invalid_tx"); events.push_back(builder.m_tx); @@ -404,9 +404,9 @@ bool gen_tx_key_image_is_invalid::generate(std::vector& events builder.step4_calc_hash(); // Tx with invalid key image can't be subscribed, so create empty signature - builder.m_tx.signatures.resize(1); - builder.m_tx.signatures[0].resize(1); - builder.m_tx.signatures[0][0] = boost::value_initialized(); + boost::get(builder.m_tx.signature).s.resize(1); + boost::get(builder.m_tx.signature).s[0].resize(1); + boost::get(builder.m_tx.signature).s[0][0] = boost::value_initialized(); DO_CALLBACK(events, "mark_invalid_tx"); events.push_back(builder.m_tx); @@ -633,62 +633,62 @@ bool gen_tx_signatures_are_invalid::generate(std::vector& even // create reference transaction tx_0, Carol->Alice, nmix=0 MAKE_TX(events, tx_0, carol_account, alice_account, amount, blk_1r_f); events.pop_back(); - CHECK_AND_ASSERT_MES(tx_0.vin.size() > 1 && tx_0.vout.size() > 1 && tx_0.signatures.size() > 1, false, "tx_0 is incorrect"); // need > 1 for this test + CHECK_AND_ASSERT_MES(tx_0.vin.size() > 1 && tx_0.vout.size() > 1 && boost::get(tx_0.signature).s.size() > 1, false, "tx_0 is incorrect"); // need > 1 for this test // create reference transaction tx_1, Dan->Alice, nmix=1 MAKE_TX_MIX(events, tx_1, dan_account, alice_account, amount, 1, blk_1r_f); events.pop_back(); - CHECK_AND_ASSERT_MES(tx_1.vin.size() > 1 && tx_1.vout.size() > 1 && tx_1.signatures.size() > 1, false, "tx_1 is incorrect"); // need > 1 for this test + CHECK_AND_ASSERT_MES(tx_1.vin.size() > 1 && tx_1.vout.size() > 1 && boost::get(tx_1.signature).s.size() > 1, false, "tx_1 is incorrect"); // need > 1 for this test const block& prev_block = blk_1r_f; transaction broken_tx; // Tx with nmix = 0 without signatures broken_tx = tx_0; - broken_tx.signatures.clear(); + boost::get(broken_tx.signature).s.clear(); check_broken_tx(events, broken_tx, prev_block, miner_account, generator); // Tx with nmix = 0 have a few inputs, and not enough signatures broken_tx = tx_0; - broken_tx.signatures.resize(broken_tx.signatures.size() - 1); + boost::get(broken_tx.signature).s.resize(boost::get(broken_tx.signature).s.size() - 1); check_broken_tx(events, broken_tx, prev_block, miner_account, generator); // Tx with nmix = 0 have a few inputs, and too many signatures (1/2) broken_tx = tx_0; - broken_tx.signatures.back().push_back(invalid_signature); + boost::get(broken_tx.signature).s.back().push_back(invalid_signature); check_broken_tx(events, broken_tx, prev_block, miner_account, generator); // Tx with nmix = 0 have a few inputs, and too many signatures (2/2) broken_tx = tx_0; - broken_tx.signatures.push_back(std::vector()); - broken_tx.signatures.back().push_back(invalid_signature); + boost::get(broken_tx.signature).s.push_back(std::vector()); + boost::get(broken_tx.signature).s.back().push_back(invalid_signature); check_broken_tx(events, broken_tx, prev_block, miner_account, generator); // Tx with nmix = 1 without signatures broken_tx = tx_1; - broken_tx.signatures.clear(); + boost::get(broken_tx.signature).s.clear(); check_broken_tx(events, broken_tx, prev_block, miner_account, generator); // Tx with nmix = 1 have not enough signatures (1/2) broken_tx = tx_1; - broken_tx.signatures.resize(broken_tx.signatures.size() - 1); + boost::get(broken_tx.signature).s.resize(boost::get(broken_tx.signature).s.size() - 1); check_broken_tx(events, broken_tx, prev_block, miner_account, generator); // Tx with nmix = 1 have not enough signatures (2/2) broken_tx = tx_1; - broken_tx.signatures.back().resize(broken_tx.signatures.back().size() - 1); + boost::get(broken_tx.signature).s.back().resize(boost::get(broken_tx.signature).s.back().size() - 1); check_broken_tx(events, broken_tx, prev_block, miner_account, generator); // Tx with nmix = 1 have too many signatures (1/2) broken_tx = tx_1; - broken_tx.signatures.back().push_back(invalid_signature); + boost::get(broken_tx.signature).s.back().push_back(invalid_signature); check_broken_tx(events, broken_tx, prev_block, miner_account, generator); // Tx with nmix = 1 have too many signatures (2/2) broken_tx = tx_1; - broken_tx.signatures.push_back(std::vector()); - broken_tx.signatures.back().push_back(invalid_signature); + boost::get(broken_tx.signature).s.push_back(std::vector()); + boost::get(broken_tx.signature).s.back().push_back(invalid_signature); check_broken_tx(events, broken_tx, prev_block, miner_account, generator); diff --git a/tests/performance_tests/check_ring_signature.h b/tests/performance_tests/check_ring_signature.h index 5a56a783..d63ec01f 100644 --- a/tests/performance_tests/check_ring_signature.h +++ b/tests/performance_tests/check_ring_signature.h @@ -47,7 +47,7 @@ public: bool test() { const currency::txin_to_key& txin = boost::get(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()); + return crypto::check_ring_signature(m_tx_prefix_hash, txin.k_image, this->m_public_key_ptrs, ring_size, boost::get(m_tx.signature)[0].data()); } private: diff --git a/tests/unit_tests/serialization.cpp b/tests/unit_tests/serialization.cpp index 5ebc3dd6..5091a20e 100644 --- a/tests/unit_tests/serialization.cpp +++ b/tests/unit_tests/serialization.cpp @@ -330,7 +330,7 @@ TEST(Serialization, serializes_transacion_signatures_correctly) ASSERT_TRUE(false); } - ASSERT_EQ(linearize_vector2(tx.signatures), linearize_vector2(tx1.signatures)); + ASSERT_EQ(linearize_vector2(boost::get(tx.signature).s), linearize_vector2(boost::get(tx1.signature).s)); // Miner tx without signatures txin_gen txin_gen1; @@ -344,10 +344,10 @@ TEST(Serialization, serializes_transacion_signatures_correctly) { ASSERT_TRUE(false); } - ASSERT_EQ(linearize_vector2(tx.signatures), linearize_vector2(tx1.signatures)); + ASSERT_EQ(linearize_vector2(boost::get(tx.signature).s), linearize_vector2(boost::get(tx1.signature).s)); // Miner tx with empty signatures 2nd vector - tx.signatures.resize(1); + boost::get(tx.signature).s.resize(1); ASSERT_TRUE(serialization::dump_binary(tx, blob)); ASSERT_EQ(9, blob.size()); // 5 bytes + 2 bytes vin[0] + 0 bytes extra + 0 bytes signatures + counter ASSERT_TRUE(serialization::parse_binary(blob, tx1)); @@ -355,29 +355,29 @@ TEST(Serialization, serializes_transacion_signatures_correctly) { ASSERT_TRUE(false); } - ASSERT_EQ(linearize_vector2(tx.signatures), linearize_vector2(tx1.signatures)); + ASSERT_EQ(linearize_vector2(boost::get(tx.signature).s), linearize_vector2(boost::get(tx1.signature).s)); //TX VALIDATION REMOVED FROM SERIALIZATION /* // Miner tx with one signature - tx.signatures[0].resize(1); + boost::get(tx.signature).s[0].resize(1); ASSERT_FALSE(serialization::dump_binary(tx, blob)); // Miner tx with 2 empty vectors - tx.signatures.resize(2); - tx.signatures[0].resize(0); - tx.signatures[1].resize(0); + boost::get(tx.signature).s.resize(2); + boost::get(tx.signature).s[0].resize(0); + boost::get(tx.signature).s[1].resize(0); ASSERT_FALSE(serialization::dump_binary(tx, blob)); // Miner tx with 2 signatures - tx.signatures[0].resize(1); - tx.signatures[1].resize(1); + boost::get(tx.signature).s[0].resize(1); + boost::get(tx.signature).s[1].resize(1); ASSERT_FALSE(serialization::dump_binary(tx, blob)); */ // Two txin_gen, no signatures tx.vin.push_back(txin_gen1); - tx.signatures.resize(0); + boost::get(tx.signature).s.resize(0); ASSERT_TRUE(serialization::dump_binary(tx, blob)); ASSERT_EQ(10, blob.size()); // 5 bytes + 2 * 2 bytes vins + 0 bytes extra + 0 bytes signatures ASSERT_TRUE(serialization::parse_binary(blob, tx1)); @@ -385,14 +385,14 @@ TEST(Serialization, serializes_transacion_signatures_correctly) { ASSERT_TRUE(false); } - ASSERT_EQ(linearize_vector2(tx.signatures), linearize_vector2(tx1.signatures)); + ASSERT_EQ(linearize_vector2(boost::get(tx.signature).s), linearize_vector2(boost::get(tx1.signature).s)); // Two txin_gen, signatures vector contains only one empty element - //tx.signatures.resize(1); + //signatures.resize(1); //ASSERT_FALSE(serialization::dump_binary(tx, blob)); // Two txin_gen, signatures vector contains two empty elements - tx.signatures.resize(2); + boost::get(tx.signature).s.resize(2); ASSERT_TRUE(serialization::dump_binary(tx, blob)); ASSERT_EQ(12, blob.size()); // 5 bytes + 2 * 2 bytes vins + 0 bytes extra + 0 bytes signatures ASSERT_TRUE(serialization::parse_binary(blob, tx1)); @@ -400,22 +400,22 @@ TEST(Serialization, serializes_transacion_signatures_correctly) { ASSERT_TRUE(false); } - ASSERT_EQ(linearize_vector2(tx.signatures), linearize_vector2(tx1.signatures)); + ASSERT_EQ(linearize_vector2(boost::get(tx.signature).s), linearize_vector2(boost::get(tx1.signature).s)); // Two txin_gen, signatures vector contains three empty elements - //tx.signatures.resize(3); + //signatures.resize(3); //ASSERT_FALSE(serialization::dump_binary(tx, blob)); // Two txin_gen, signatures vector contains two non empty elements - //tx.signatures.resize(2); - //tx.signatures[0].resize(1); - //tx.signatures[1].resize(1); + //signatures.resize(2); + //signatures[0].resize(1); + //signatures[1].resize(1); //ASSERT_FALSE(serialization::dump_binary(tx, blob)); // A few bytes instead of signature tx.vin.clear(); tx.vin.push_back(txin_gen1); - tx.signatures.clear(); + boost::get(tx.signature).s.clear(); ASSERT_TRUE(serialization::dump_binary(tx, blob)); blob.append(std::string(sizeof(crypto::signature) / 2, 'x')); ASSERT_FALSE(serialization::parse_binary(blob, tx1)); @@ -430,40 +430,40 @@ TEST(Serialization, serializes_transacion_signatures_correctly) //tx.vin.clear(); //tx.vin.push_back(txin_to_key1); //tx.vin.push_back(txin_to_key1); - //tx.signatures.resize(1); - //tx.signatures[0].resize(2); + //signatures.resize(1); + //signatures[0].resize(2); //ASSERT_FALSE(serialization::dump_binary(tx, blob)); /* // Too much signatures for two inputs - tx.signatures.resize(3); - tx.signatures[0].resize(2); - tx.signatures[1].resize(2); - tx.signatures[2].resize(2); + boost::get(tx.signature).s.resize(3); + boost::get(tx.signature).s[0].resize(2); + boost::get(tx.signature).s[1].resize(2); + boost::get(tx.signature).s[2].resize(2); ASSERT_FALSE(serialization::dump_binary(tx, blob)); // First signatures vector contains too little elements - tx.signatures.resize(2); - tx.signatures[0].resize(1); - tx.signatures[1].resize(2); + boost::get(tx.signature).s.resize(2); + boost::get(tx.signature).s[0].resize(1); + boost::get(tx.signature).s[1].resize(2); ASSERT_FALSE(serialization::dump_binary(tx, blob)); // First signatures vector contains too much elements - tx.signatures.resize(2); - tx.signatures[0].resize(3); - tx.signatures[1].resize(2); + boost::get(tx.signature).s.resize(2); + boost::get(tx.signature).s[0].resize(3); + boost::get(tx.signature).s[1].resize(2); ASSERT_FALSE(serialization::dump_binary(tx, blob)); // There are signatures for each input - tx.signatures.resize(2); - tx.signatures[0].resize(2); - tx.signatures[1].resize(2); + boost::get(tx.signature).s.resize(2); + boost::get(tx.signature).s[0].resize(2); + boost::get(tx.signature).s[1].resize(2); ASSERT_TRUE(serialization::dump_binary(tx, blob)); ASSERT_TRUE(serialization::parse_binary(blob, tx1)); ASSERT_EQ(tx, tx1); - ASSERT_EQ(linearize_vector2(tx.signatures), linearize_vector2(tx1.signatures)); + ASSERT_EQ(linearize_vector2(boost::get(tx.signature).s), linearize_vector2(boost::get(tx1.signature).s)); // Blob doesn't contain enough data blob.resize(blob.size() - sizeof(crypto::signature) / 2); @@ -622,7 +622,7 @@ bool operator ==(const transaction_new_tests& a, const transaction_new_tests& b) a.extra.size() == b.extra.size() && a.vin.size() == b.vin.size() && a.vout.size() == b.vout.size() && - a.signatures.size() == b.signatures.size(); + boost::get(a.signature).s.size() == boost::get(b.signature).s.size(); } bool operator ==(const transaction_new_tests& a, const transaction_old_tests& b) { @@ -630,7 +630,7 @@ bool operator ==(const transaction_new_tests& a, const transaction_old_tests& b) a.extra.size() == b.extra.size() && a.vin.size() == b.vin.size() && a.vout.size() == b.vout.size() && - a.signatures.size() == b.signatures.size(); + boost::get(a.signature).s.size() == boost::get(b.signature).s.size(); } void validate_tx_serialisation(transaction_new_tests& tx) @@ -670,7 +670,7 @@ TEST(Serialization, serializes_transacion_versions) { ASSERT_TRUE(false); } - ASSERT_EQ(linearize_vector2(tx.signatures), linearize_vector2(tx1.signatures)); + ASSERT_EQ(linearize_vector2(boost::get(tx.signature).s), linearize_vector2(boost::get(tx1.signature).s)); */ txin_gen txin_gen1; @@ -705,12 +705,12 @@ TEST(Serialization, serializes_transacion_versions) eae.m_alias = "eokcmeockme"; eae.m_text_comment = "sdssccsc"; tx.extra.push_back(eae); - tx.signatures.resize(2); + boost::get(tx.signature).s.resize(2); crypto::signature sig = epee::string_tools::parse_tpod_from_hex_string("22608f59f8080e2fbfe3c8c80eb6e6a953d47cf2d6aebd345bada3a1cab9985222608f59f8080e2fbfe3c8c80eb6e6a953d47cf2d6aebd345bada3a1cab99852"); - tx.signatures[0].push_back(sig); - tx.signatures[0].push_back(sig); - tx.signatures[1].push_back(sig); - tx.signatures[1].push_back(sig); + boost::get(tx.signature).s[0].push_back(sig); + boost::get(tx.signature).s[0].push_back(sig); + boost::get(tx.signature).s[1].push_back(sig); + boost::get(tx.signature).s[1].push_back(sig); tx.version = TRANSACTION_VERSION_INITAL;