From c3b3260ae5b5acde445fa88a6f0909f582903754 Mon Sep 17 00:00:00 2001 From: moneromooo-monero Date: Fri, 12 Aug 2016 18:45:07 +0100 Subject: New "Halfway RingCT" outputs for coinbase transactions When RingCT is enabled, outputs from coinbase transactions are created as a single output, and stored as RingCT output, with a fake mask. Their amount is not hidden on the blockchain itself, but they are then able to be used as fake inputs in a RingCT ring. Since the output amounts are hidden, their "dustiness" is not an obstacle anymore to mixing, and this makes the coinbase transactions a lot smaller, as well as helping the TXO set to grow more slowly. Also add a new "Null" type of rct signature, which decreases the size required when no signatures are to be stored, as in a coinbase tx. --- tests/core_tests/block_validation.cpp | 2 ++ tests/core_tests/chaingen.cpp | 1 + tests/core_tests/double_spend.inl | 1 + tests/core_tests/integer_overflow.cpp | 1 + tests/core_tests/rct.cpp | 28 ++++++++++++++++++---------- tests/core_tests/rct.h | 2 +- tests/core_tests/transaction_tests.cpp | 1 + tests/core_tests/v2_tests.cpp | 1 + 8 files changed, 26 insertions(+), 11 deletions(-) (limited to 'tests/core_tests') diff --git a/tests/core_tests/block_validation.cpp b/tests/core_tests/block_validation.cpp index 3989a71c9..df8972556 100644 --- a/tests/core_tests/block_validation.cpp +++ b/tests/core_tests/block_validation.cpp @@ -337,6 +337,7 @@ bool gen_block_miner_tx_has_2_in::generate(std::vector& events se.amount = blk_0.miner_tx.vout[0].amount; se.push_output(0, boost::get(blk_0.miner_tx.vout[0].target).key, se.amount); se.real_output = 0; + se.rct = false; se.real_out_tx_key = get_tx_pub_key_from_extra(blk_0.miner_tx); se.real_output_in_tx_index = 0; std::vector sources; @@ -379,6 +380,7 @@ bool gen_block_miner_tx_with_txin_to_key::generate(std::vector se.amount = blk_1.miner_tx.vout[0].amount; se.push_output(0, boost::get(blk_1.miner_tx.vout[0].target).key, se.amount); se.real_output = 0; + se.rct = false; se.real_out_tx_key = get_tx_pub_key_from_extra(blk_1.miner_tx); se.real_output_in_tx_index = 0; std::vector sources; diff --git a/tests/core_tests/chaingen.cpp b/tests/core_tests/chaingen.cpp index b7a1c3dec..4cb70e745 100644 --- a/tests/core_tests/chaingen.cpp +++ b/tests/core_tests/chaingen.cpp @@ -458,6 +458,7 @@ bool fill_tx_sources(std::vector& sources, const std::vector::generate(std::vector(tx_0.vout[0].target).key, se.amount); se.real_output = 0; + se.rct = false; se.real_out_tx_key = get_tx_pub_key_from_extra(tx_0); se.real_output_in_tx_index = 0; sources.push_back(se); diff --git a/tests/core_tests/integer_overflow.cpp b/tests/core_tests/integer_overflow.cpp index aad377d6d..936f29675 100644 --- a/tests/core_tests/integer_overflow.cpp +++ b/tests/core_tests/integer_overflow.cpp @@ -63,6 +63,7 @@ namespace se.amount = tx.vout[out_idx].amount; se.push_output(0, boost::get(tx.vout[out_idx].target).key, se.amount); se.real_output = 0; + se.rct = false; se.real_out_tx_key = get_tx_pub_key_from_extra(tx); se.real_output_in_tx_index = out_idx; diff --git a/tests/core_tests/rct.cpp b/tests/core_tests/rct.cpp index b358ce8b2..c29854888 100644 --- a/tests/core_tests/rct.cpp +++ b/tests/core_tests/rct.cpp @@ -57,8 +57,8 @@ bool gen_rct_tx_validation_base::generate_with(std::vector& ev miner_accounts[n].generate(); CHECK_AND_ASSERT_MES(generator.construct_block_manually(blocks[n], *prev_block, miner_accounts[n], test_generator::bf_major_ver | test_generator::bf_minor_ver | test_generator::bf_timestamp | test_generator::bf_hf_version, - 4, 4, prev_block->timestamp + DIFFICULTY_BLOCKS_ESTIMATE_TIMESPAN * 2, // v2 has blocks twice as long - crypto::hash(), 0, transaction(), std::vector(), 0, 0, 4), + 2, 2, prev_block->timestamp + DIFFICULTY_BLOCKS_ESTIMATE_TIMESPAN * 2, // v2 has blocks twice as long + crypto::hash(), 0, transaction(), std::vector(), 0, 0, 2), false, "Failed to generate block"); events.push_back(blocks[n]); prev_block = blocks + n; @@ -74,8 +74,8 @@ bool gen_rct_tx_validation_base::generate_with(std::vector& ev cryptonote::block blk; CHECK_AND_ASSERT_MES(generator.construct_block_manually(blk, blk_last, miner_account, test_generator::bf_major_ver | test_generator::bf_minor_ver | test_generator::bf_timestamp | test_generator::bf_hf_version, - 4, 4, blk_last.timestamp + DIFFICULTY_BLOCKS_ESTIMATE_TIMESPAN * 2, // v2 has blocks twice as long - crypto::hash(), 0, transaction(), std::vector(), 0, 0, 4), + 2, 2, blk_last.timestamp + DIFFICULTY_BLOCKS_ESTIMATE_TIMESPAN * 2, // v2 has blocks twice as long + crypto::hash(), 0, transaction(), std::vector(), 0, 0, 2), false, "Failed to generate block"); events.push_back(blk); blk_last = blk; @@ -104,6 +104,7 @@ bool gen_rct_tx_validation_base::generate_with(std::vector& ev src.real_output = n; src.real_output_in_tx_index = index_in_tx; src.mask = rct::identity(); + src.rct = false; //fill outputs entry tx_destination_entry td; @@ -135,9 +136,9 @@ bool gen_rct_tx_validation_base::generate_with(std::vector& ev } CHECK_AND_ASSERT_MES(generator.construct_block_manually(blk_txes[n], blk_last, miner_account, - test_generator::bf_major_ver | test_generator::bf_minor_ver | test_generator::bf_timestamp | test_generator::bf_tx_hashes | test_generator::bf_hf_version, + test_generator::bf_major_ver | test_generator::bf_minor_ver | test_generator::bf_timestamp | test_generator::bf_tx_hashes | test_generator::bf_hf_version | test_generator::bf_max_outs, 4, 4, blk_last.timestamp + DIFFICULTY_BLOCKS_ESTIMATE_TIMESPAN * 2, // v2 has blocks twice as long - crypto::hash(), 0, transaction(), starting_rct_tx_hashes, 0, 0, 4), + crypto::hash(), 0, transaction(), starting_rct_tx_hashes, 0, 6, 4), false, "Failed to generate block"); events.push_back(blk_txes[n]); blk_last = blk_txes[n]; @@ -149,9 +150,9 @@ bool gen_rct_tx_validation_base::generate_with(std::vector& ev { cryptonote::block blk; CHECK_AND_ASSERT_MES(generator.construct_block_manually(blk, blk_last, miner_account, - test_generator::bf_major_ver | test_generator::bf_minor_ver | test_generator::bf_timestamp | test_generator::bf_hf_version, + test_generator::bf_major_ver | test_generator::bf_minor_ver | test_generator::bf_timestamp | test_generator::bf_hf_version | test_generator::bf_max_outs, 4, 4, blk_last.timestamp + DIFFICULTY_BLOCKS_ESTIMATE_TIMESPAN * 2, // v2 has blocks twice as long - crypto::hash(), 0, transaction(), std::vector(), 0, 0, 4), + crypto::hash(), 0, transaction(), std::vector(), 0, 6, 4), false, "Failed to generate block"); events.push_back(blk); blk_last = blk; @@ -161,7 +162,9 @@ bool gen_rct_tx_validation_base::generate_with(std::vector& ev // create a tx from the requested ouputs std::vector sources; - size_t rct_idx = 0, pre_rct_idx = 0; + size_t global_rct_idx = 6; // skip first coinbase (6 outputs) + size_t rct_idx = 0; + size_t pre_rct_idx = 0; for (size_t out_idx_idx = 0; out_idx[out_idx_idx] >= 0; ++out_idx_idx) { sources.resize(sources.size()+1); tx_source_entry& src = sources.back(); @@ -173,12 +176,16 @@ bool gen_rct_tx_validation_base::generate_with(std::vector& ev src.real_out_tx_key = get_tx_pub_key_from_extra(rct_txes[rct_idx/4]); src.real_output_in_tx_index = rct_idx&3; src.mask = rct_tx_masks[rct_idx]; + src.rct = true; for (int m = 0; m <= mixin; ++m) { rct::ctkey ctkey; ctkey.dest = rct::pk2rct(boost::get(rct_txes[rct_idx/4].vout[rct_idx&3].target).key); ctkey.mask = rct_txes[rct_idx/4].rct_signatures.outPk[rct_idx&3].mask; - src.outputs.push_back(std::make_pair(rct_idx, ctkey)); + src.outputs.push_back(std::make_pair(global_rct_idx, ctkey)); ++rct_idx; + ++global_rct_idx; + if (global_rct_idx % 10 == 0) + global_rct_idx += 6; // skip the coinbase } } else @@ -188,6 +195,7 @@ bool gen_rct_tx_validation_base::generate_with(std::vector& ev src.real_out_tx_key = cryptonote::get_tx_pub_key_from_extra(blocks[pre_rct_idx].miner_tx); src.real_output_in_tx_index = 4; src.mask = rct::identity(); + src.rct = false; for (int m = 0; m <= mixin; ++m) { src.push_output(m, boost::get(blocks[pre_rct_idx].miner_tx.vout[4].target).key, src.amount); ++pre_rct_idx; diff --git a/tests/core_tests/rct.h b/tests/core_tests/rct.h index bf0dc61f5..e01815d26 100644 --- a/tests/core_tests/rct.h +++ b/tests/core_tests/rct.h @@ -81,7 +81,7 @@ private: template<> struct get_test_options { - const std::pair hard_forks[2] = {std::make_pair(1, 0), std::make_pair(4, 1)}; + const std::pair hard_forks[3] = {std::make_pair(1, 0), std::make_pair(2, 1), std::make_pair(4, 65)}; const cryptonote::test_options test_options = { hard_forks }; diff --git a/tests/core_tests/transaction_tests.cpp b/tests/core_tests/transaction_tests.cpp index 8a1638c1d..cb585b975 100644 --- a/tests/core_tests/transaction_tests.cpp +++ b/tests/core_tests/transaction_tests.cpp @@ -97,6 +97,7 @@ bool test_transaction_generation_and_ring_signature() src.real_out_tx_key = cryptonote::get_tx_pub_key_from_extra(tx_mine_2); src.real_output = 1; + src.rct = false; src.real_output_in_tx_index = 0; } //fill outputs entry diff --git a/tests/core_tests/v2_tests.cpp b/tests/core_tests/v2_tests.cpp index d9328d13a..93ddd8a12 100644 --- a/tests/core_tests/v2_tests.cpp +++ b/tests/core_tests/v2_tests.cpp @@ -96,6 +96,7 @@ bool gen_v2_tx_validation_base::generate_with(std::vector& eve } src.real_out_tx_key = cryptonote::get_tx_pub_key_from_extra(blocks[0].miner_tx); src.real_output = 0; + src.rct = false; src.real_output_in_tx_index = out_idx[out_idx_idx]; } -- cgit v1.2.3