Electroneum
gen_ring_signature_2 Class Reference

#include <ring_signature_1.h>

Inheritance diagram for gen_ring_signature_2:
Collaboration diagram for gen_ring_signature_2:

Public Member Functions

 gen_ring_signature_2 ()
 
bool generate (std::vector< test_event_entry > &events) const
 
bool check_balances_1 (cryptonote::core &c, size_t ev_index, const std::vector< test_event_entry > &events)
 
bool check_balances_2 (cryptonote::core &c, size_t ev_index, const std::vector< test_event_entry > &events)
 
- Public Member Functions inherited from test_chain_unit_base
void register_callback (const std::string &cb_name, verify_callback cb)
 
bool verify (const std::string &cb_name, cryptonote::core &c, size_t ev_index, const std::vector< test_event_entry > &events)
 
bool check_block_verification_context (const cryptonote::block_verification_context &bvc, size_t event_idx, const cryptonote::block &)
 
bool check_tx_verification_context (const cryptonote::tx_verification_context &tvc, bool, size_t, const cryptonote::transaction &)
 
bool check_tx_verification_context_array (const std::vector< cryptonote::tx_verification_context > &tvcs, size_t, size_t, const std::vector< cryptonote::transaction > &)
 

Additional Inherited Members

- Public Types inherited from test_chain_unit_base
typedef boost::function< bool(cryptonote::core &c, size_t ev_index, const std::vector< test_event_entry > &events)> verify_callback
 
typedef std::map< std::string, verify_callbackcallbacks_map
 

Detailed Description

Definition at line 57 of file ring_signature_1.h.

Constructor & Destructor Documentation

◆ gen_ring_signature_2()

gen_ring_signature_2::gen_ring_signature_2 ( )

Definition at line 141 of file ring_signature_1.cpp.

142 {
145 }
#define REGISTER_CALLBACK(CB_NAME, CLBACK)
Definition: chaingen.h:827
bool check_balances_1(cryptonote::core &c, size_t ev_index, const std::vector< test_event_entry > &events)
bool check_balances_2(cryptonote::core &c, size_t ev_index, const std::vector< test_event_entry > &events)
Here is the call graph for this function:

Member Function Documentation

◆ check_balances_1()

bool gen_ring_signature_2::check_balances_1 ( cryptonote::core c,
size_t  ev_index,
const std::vector< test_event_entry > &  events 
)

Definition at line 179 of file ring_signature_1.cpp.

180 {
181  DEFINE_TESTS_ERROR_CONTEXT("gen_ring_signature_2::check_balances_1");
182 
183  m_bob_account = boost::get<account_base>(events[1]);
184  m_alice_account = boost::get<account_base>(events[2]);
185 
186  std::vector<block> blocks;
187  bool r = c.get_blocks(0, 100 + 2 * CRYPTONOTE_MINED_ETN_UNLOCK_WINDOW, blocks);
189 
190  std::vector<cryptonote::block> chain;
191  map_hash2tx_t mtx;
192  r = find_block_chain(events, chain, mtx, get_block_hash(blocks.back()));
194  CHECK_EQ(MK_COINS(52), get_balance(m_bob_account, chain, mtx));
195  CHECK_EQ(0, get_balance(m_alice_account, chain, mtx));
196 
197  return true;
198 }
#define CRYPTONOTE_MINED_ETN_UNLOCK_WINDOW
bool find_block_chain(const std::vector< test_event_entry > &events, std::vector< cryptonote::block > &blockchain, map_hash2tx_t &mtx, const crypto::hash &head)
Definition: chaingen.cpp:1072
uint64_t get_balance(const cryptonote::account_base &addr, const std::vector< cryptonote::block > &blockchain, const map_hash2tx_t &mtx)
Definition: chaingen.cpp:940
#define CHECK_TEST_CONDITION(cond)
Definition: chaingen.h:1057
bool get_blocks(uint64_t start_offset, size_t count, std::vector< std::pair< cryptonote::blobdata, block >> &blocks, std::vector< cryptonote::blobdata > &txs) const
std::unordered_map< crypto::hash, const cryptonote::transaction * > map_hash2tx_t
Definition: chaingen.h:163
crypto::hash get_block_hash(uint64_t height)
#define MK_COINS(amount)
Definition: chaingen.h:1060
#define CHECK_EQ(v1, v2)
Definition: chaingen.h:1058
#define DEFINE_TESTS_ERROR_CONTEXT(text)
Definition: chaingen.h:1056
Here is the call graph for this function:
Here is the caller graph for this function:

◆ check_balances_2()

bool gen_ring_signature_2::check_balances_2 ( cryptonote::core c,
size_t  ev_index,
const std::vector< test_event_entry > &  events 
)

Definition at line 200 of file ring_signature_1.cpp.

201 {
202  DEFINE_TESTS_ERROR_CONTEXT("gen_ring_signature_2::check_balances_2");
203 
204  std::vector<block> blocks;
205  bool r = c.get_blocks(0, 100 + 2 * CRYPTONOTE_MINED_ETN_UNLOCK_WINDOW, blocks);
207 
208  std::vector<cryptonote::block> chain;
209  map_hash2tx_t mtx;
210  r = find_block_chain(events, chain, mtx, get_block_hash(blocks.back()));
212  CHECK_EQ(0, get_balance(m_bob_account, chain, mtx));
213  CHECK_EQ(MK_COINS(52) - TESTS_DEFAULT_FEE, get_balance(m_alice_account, chain, mtx));
214 
215  return true;
216 }
#define CRYPTONOTE_MINED_ETN_UNLOCK_WINDOW
bool find_block_chain(const std::vector< test_event_entry > &events, std::vector< cryptonote::block > &blockchain, map_hash2tx_t &mtx, const crypto::hash &head)
Definition: chaingen.cpp:1072
#define TESTS_DEFAULT_FEE
Definition: chaingen.h:1061
uint64_t get_balance(const cryptonote::account_base &addr, const std::vector< cryptonote::block > &blockchain, const map_hash2tx_t &mtx)
Definition: chaingen.cpp:940
#define CHECK_TEST_CONDITION(cond)
Definition: chaingen.h:1057
bool get_blocks(uint64_t start_offset, size_t count, std::vector< std::pair< cryptonote::blobdata, block >> &blocks, std::vector< cryptonote::blobdata > &txs) const
std::unordered_map< crypto::hash, const cryptonote::transaction * > map_hash2tx_t
Definition: chaingen.h:163
crypto::hash get_block_hash(uint64_t height)
#define MK_COINS(amount)
Definition: chaingen.h:1060
#define CHECK_EQ(v1, v2)
Definition: chaingen.h:1058
#define DEFINE_TESTS_ERROR_CONTEXT(text)
Definition: chaingen.h:1056
Here is the call graph for this function:
Here is the caller graph for this function:

◆ generate()

bool gen_ring_signature_2::generate ( std::vector< test_event_entry > &  events) const

Bob has 4 inputs by 13 coins. He sends 4 * 13 coins to Alice, using ring signature with nmix = 3. Each Bob's input is used as mix for 3 others.

Definition at line 151 of file ring_signature_1.cpp.

152 {
153  uint64_t ts_start = 1338224400;
154 
155  GENERATE_ACCOUNT(miner_account);
156 
157  // events
158  MAKE_GENESIS_BLOCK(events, blk_0, miner_account, ts_start); // 0
159  MAKE_ACCOUNT(events, bob_account); // 1
160  MAKE_ACCOUNT(events, alice_account); // 2
161  MAKE_NEXT_BLOCK(events, blk_1, blk_0, miner_account); // 3
162  MAKE_NEXT_BLOCK(events, blk_2, blk_1, miner_account); // 4
163  MAKE_NEXT_BLOCK(events, blk_3, blk_2, miner_account); // 5
164  REWIND_BLOCKS(events, blk_3r, blk_3, miner_account); // <N blocks>
165  MAKE_TX_LIST_START(events, txs_blk_4, miner_account, bob_account, MK_COINS(13), blk_3); // 6 + N
166  MAKE_TX_LIST(events, txs_blk_4, miner_account, bob_account, MK_COINS(13), blk_3); // 7 + N
167  MAKE_TX_LIST(events, txs_blk_4, miner_account, bob_account, MK_COINS(13), blk_3); // 8 + N
168  MAKE_TX_LIST(events, txs_blk_4, miner_account, bob_account, MK_COINS(13), blk_3); // 9 + N
169  MAKE_NEXT_BLOCK_TX_LIST(events, blk_4, blk_3r, miner_account, txs_blk_4); // 10 + N
170  DO_CALLBACK(events, "check_balances_1"); // 11 + N
171  REWIND_BLOCKS(events, blk_4r, blk_4, miner_account); // <N blocks>
172  MAKE_TX_MIX(events, tx_0, bob_account, alice_account, MK_COINS(52) - TESTS_DEFAULT_FEE, 3, blk_4); // 12 + 2N
173  MAKE_NEXT_BLOCK_TX1(events, blk_5, blk_4r, miner_account, tx_0); // 13 + 2N
174  DO_CALLBACK(events, "check_balances_2"); // 14 + 2N
175 
176  return true;
177 }
#define MAKE_NEXT_BLOCK_TX1(VEC_EVENTS, BLK_NAME, PREV_BLOCK, MINER_ACC, TX1)
Definition: chaingen.h:849
#define MAKE_NEXT_BLOCK(VEC_EVENTS, BLK_NAME, PREV_BLOCK, MINER_ACC)
Definition: chaingen.h:839
#define TESTS_DEFAULT_FEE
Definition: chaingen.h:1061
#define MAKE_TX_LIST(VEC_EVENTS, SET_NAME, FROM, TO, AMOUNT, HEAD)
Definition: chaingen.h:933
#define MAKE_TX_MIX(VEC_EVENTS, TX_NAME, FROM, TO, AMOUNT, NMIX, HEAD)
Definition: chaingen.h:893
#define MAKE_GENESIS_BLOCK(VEC_EVENTS, BLK_NAME, MINER_ACC, TS)
Definition: chaingen.h:833
unsigned __int64 uint64_t
Definition: stdint.h:136
#define MAKE_TX_LIST_START(VEC_EVENTS, SET_NAME, FROM, TO, AMOUNT, HEAD)
Definition: chaingen.h:935
#define MAKE_ACCOUNT(VEC_EVENTS, account)
Definition: chaingen.h:815
#define REWIND_BLOCKS(VEC_EVENTS, BLK_NAME, PREV_BLOCK, MINER_ACC)
Definition: chaingen.h:890
#define MK_COINS(amount)
Definition: chaingen.h:1060
#define GENERATE_ACCOUNT(account)
Definition: chaingen.h:801
#define DO_CALLBACK(VEC_EVENTS, CB_NAME)
Definition: chaingen.h:820
#define MAKE_NEXT_BLOCK_TX_LIST(VEC_EVENTS, BLK_NAME, PREV_BLOCK, MINER_ACC, TXLIST)
Definition: chaingen.h:867

The documentation for this class was generated from the following files: