Electroneum
Loading...
Searching...
No Matches
rct.h
Go to the documentation of this file.
1// Copyrights(c) 2017-2021, The Electroneum Project
2// Copyrights(c) 2014-2019, The Monero Project
3//
4// All rights reserved.
5//
6// Redistribution and use in source and binary forms, with or without modification, are
7// permitted provided that the following conditions are met:
8//
9// 1. Redistributions of source code must retain the above copyright notice, this list of
10// conditions and the following disclaimer.
11//
12// 2. Redistributions in binary form must reproduce the above copyright notice, this list
13// of conditions and the following disclaimer in the documentation and/or other
14// materials provided with the distribution.
15//
16// 3. Neither the name of the copyright holder nor the names of its contributors may be
17// used to endorse or promote products derived from this software without specific
18// prior written permission.
19//
20// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY
21// EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
22// MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL
23// THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
24// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
25// PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
26// INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
27// STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF
28// THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
29//
30// Parts of this file are originally copyright (c) 2012-2013 The Cryptonote developers
31
32#pragma once
33#include "chaingen.h"
34
36{
44
45 bool check_tx_verification_context(const cryptonote::tx_verification_context& tvc, bool tx_added, size_t event_idx, const cryptonote::transaction& /*tx*/)
46 {
47 if (m_invalid_tx_index == event_idx)
48 return tvc.m_verification_failed;
49 else
50 return !tvc.m_verification_failed && tx_added;
51 }
52
54 {
55 if (m_invalid_block_index == event_idx)
56 return bvc.m_verification_failed;
57 else
58 return !bvc.m_verification_failed;
59 }
60
61 bool mark_invalid_block(cryptonote::core& /*c*/, size_t ev_index, const std::vector<test_event_entry>& /*events*/)
62 {
63 m_invalid_block_index = ev_index + 1;
64 return true;
65 }
66
67 bool mark_invalid_tx(cryptonote::core& /*c*/, size_t ev_index, const std::vector<test_event_entry>& /*events*/)
68 {
69 m_invalid_tx_index = ev_index + 1;
70 return true;
71 }
72
73 bool generate_with(std::vector<test_event_entry>& events, const int *out_idx, int mixin,
74 uint64_t amount_paid, bool valid,
75 const std::function<void(std::vector<cryptonote::tx_source_entry> &sources, std::vector<cryptonote::tx_destination_entry> &destinations)> &pre_tx,
76 const std::function<void(cryptonote::transaction &tx)> &post_tx) const;
77
78private:
79 size_t m_invalid_tx_index;
80 size_t m_invalid_block_index;
81};
82
83template<>
85 const std::pair<uint8_t, uint64_t> hard_forks[4] = {std::make_pair(1, 0), std::make_pair(2, 1), std::make_pair(4, 65), std::make_pair(0, 0)};
89};
90
91// valid
93{
94 bool generate(std::vector<test_event_entry>& events) const;
95};
96template<> struct get_test_options<gen_rct_tx_valid_from_pre_rct>: public get_test_options<gen_rct_tx_validation_base> {};
97
99{
100 bool generate(std::vector<test_event_entry>& events) const;
101};
102template<> struct get_test_options<gen_rct_tx_valid_from_rct>: public get_test_options<gen_rct_tx_validation_base> {};
103
105{
106 bool generate(std::vector<test_event_entry>& events) const;
107};
108template<> struct get_test_options<gen_rct_tx_valid_from_mixed>: public get_test_options<gen_rct_tx_validation_base> {};
109
110// altered commitment/dest
112{
113 bool generate(std::vector<test_event_entry>& events) const;
114};
115template<> struct get_test_options<gen_rct_tx_pre_rct_bad_real_dest>: public get_test_options<gen_rct_tx_validation_base> {};
116
118{
119 bool generate(std::vector<test_event_entry>& events) const;
120};
121template<> struct get_test_options<gen_rct_tx_pre_rct_bad_real_mask>: public get_test_options<gen_rct_tx_validation_base> {};
122
124{
125 bool generate(std::vector<test_event_entry>& events) const;
126};
127template<> struct get_test_options<gen_rct_tx_pre_rct_bad_fake_dest>: public get_test_options<gen_rct_tx_validation_base> {};
128
130{
131 bool generate(std::vector<test_event_entry>& events) const;
132};
133template<> struct get_test_options<gen_rct_tx_pre_rct_bad_fake_mask>: public get_test_options<gen_rct_tx_validation_base> {};
134
136{
137 bool generate(std::vector<test_event_entry>& events) const;
138};
139template<> struct get_test_options<gen_rct_tx_rct_bad_real_dest>: public get_test_options<gen_rct_tx_validation_base> {};
140
142{
143 bool generate(std::vector<test_event_entry>& events) const;
144};
145template<> struct get_test_options<gen_rct_tx_rct_bad_real_mask>: public get_test_options<gen_rct_tx_validation_base> {};
146
148{
149 bool generate(std::vector<test_event_entry>& events) const;
150};
151template<> struct get_test_options<gen_rct_tx_rct_bad_fake_dest>: public get_test_options<gen_rct_tx_validation_base> {};
152
154{
155 bool generate(std::vector<test_event_entry>& events) const;
156};
157template<> struct get_test_options<gen_rct_tx_rct_bad_fake_mask>: public get_test_options<gen_rct_tx_validation_base> {};
158
160{
161 bool generate(std::vector<test_event_entry>& events) const;
162};
163template<> struct get_test_options<gen_rct_tx_rct_spend_with_zero_commit>: public get_test_options<gen_rct_tx_validation_base> {};
164
165// altered amounts
167{
168 bool generate(std::vector<test_event_entry>& events) const;
169};
170template<> struct get_test_options<gen_rct_tx_pre_rct_zero_vin_amount>: public get_test_options<gen_rct_tx_validation_base> {};
171
173{
174 bool generate(std::vector<test_event_entry>& events) const;
175};
176template<> struct get_test_options<gen_rct_tx_rct_non_zero_vin_amount>: public get_test_options<gen_rct_tx_validation_base> {};
177
179{
180 bool generate(std::vector<test_event_entry>& events) const;
181};
182template<> struct get_test_options<gen_rct_tx_non_zero_vout_amount>: public get_test_options<gen_rct_tx_validation_base> {};
183
184// key image
186{
187 bool generate(std::vector<test_event_entry>& events) const;
188};
189template<> struct get_test_options<gen_rct_tx_pre_rct_duplicate_key_image>: public get_test_options<gen_rct_tx_validation_base> {};
190
192{
193 bool generate(std::vector<test_event_entry>& events) const;
194};
195template<> struct get_test_options<gen_rct_tx_rct_duplicate_key_image>: public get_test_options<gen_rct_tx_validation_base> {};
196
198{
199 bool generate(std::vector<test_event_entry>& events) const;
200};
201template<> struct get_test_options<gen_rct_tx_pre_rct_wrong_key_image>: public get_test_options<gen_rct_tx_validation_base> {};
202
204{
205 bool generate(std::vector<test_event_entry>& events) const;
206};
207template<> struct get_test_options<gen_rct_tx_rct_wrong_key_image>: public get_test_options<gen_rct_tx_validation_base> {};
208
209// fee
211{
212 bool generate(std::vector<test_event_entry>& events) const;
213};
214template<> struct get_test_options<gen_rct_tx_pre_rct_wrong_fee>: public get_test_options<gen_rct_tx_validation_base> {};
215
217{
218 bool generate(std::vector<test_event_entry>& events) const;
219};
220template<> struct get_test_options<gen_rct_tx_rct_wrong_fee>: public get_test_options<gen_rct_tx_validation_base> {};
221
223{
224 bool generate(std::vector<test_event_entry>& events) const;
225};
226template<> struct get_test_options<gen_rct_tx_pre_rct_increase_vin_and_fee>: public get_test_options<gen_rct_tx_validation_base> {};
227
228// modify vin/vout
230{
231 bool generate(std::vector<test_event_entry>& events) const;
232};
233template<> struct get_test_options<gen_rct_tx_pre_rct_remove_vin>: public get_test_options<gen_rct_tx_validation_base> {};
234
236{
237 bool generate(std::vector<test_event_entry>& events) const;
238};
239template<> struct get_test_options<gen_rct_tx_rct_remove_vin>: public get_test_options<gen_rct_tx_validation_base> {};
240
242{
243 bool generate(std::vector<test_event_entry>& events) const;
244};
245template<> struct get_test_options<gen_rct_tx_pre_rct_add_vout>: public get_test_options<gen_rct_tx_validation_base> {};
246
248{
249 bool generate(std::vector<test_event_entry>& events) const;
250};
251template<> struct get_test_options<gen_rct_tx_rct_add_vout>: public get_test_options<gen_rct_tx_validation_base> {};
252
253// extra
255{
256 bool generate(std::vector<test_event_entry>& events) const;
257};
258template<> struct get_test_options<gen_rct_tx_pre_rct_altered_extra>: public get_test_options<gen_rct_tx_validation_base> {};
259
261{
262 bool generate(std::vector<test_event_entry>& events) const;
263};
264template<> struct get_test_options<gen_rct_tx_rct_altered_extra>: public get_test_options<gen_rct_tx_validation_base> {};
265
#define REGISTER_CALLBACK_METHOD(CLASS, METHOD)
Definition chaingen.h:830
handles core cryptonote functionality
unsigned __int64 uint64_t
Definition stdint.h:136
bool generate(std::vector< test_event_entry > &events) const
Definition rct.cpp:379
bool generate(std::vector< test_event_entry > &events) const
Definition rct.cpp:473
bool generate(std::vector< test_event_entry > &events) const
Definition rct.cpp:491
bool generate(std::vector< test_event_entry > &events) const
Definition rct.cpp:288
bool generate(std::vector< test_event_entry > &events) const
Definition rct.cpp:298
bool generate(std::vector< test_event_entry > &events) const
Definition rct.cpp:265
bool generate(std::vector< test_event_entry > &events) const
Definition rct.cpp:278
bool generate(std::vector< test_event_entry > &events) const
Definition rct.cpp:388
bool generate(std::vector< test_event_entry > &events) const
Definition rct.cpp:446
bool generate(std::vector< test_event_entry > &events) const
Definition rct.cpp:455
bool generate(std::vector< test_event_entry > &events) const
Definition rct.cpp:428
bool generate(std::vector< test_event_entry > &events) const
Definition rct.cpp:406
bool generate(std::vector< test_event_entry > &events) const
Definition rct.cpp:361
bool generate(std::vector< test_event_entry > &events) const
Definition rct.cpp:482
bool generate(std::vector< test_event_entry > &events) const
Definition rct.cpp:501
bool generate(std::vector< test_event_entry > &events) const
Definition rct.cpp:331
bool generate(std::vector< test_event_entry > &events) const
Definition rct.cpp:341
bool generate(std::vector< test_event_entry > &events) const
Definition rct.cpp:308
bool generate(std::vector< test_event_entry > &events) const
Definition rct.cpp:321
bool generate(std::vector< test_event_entry > &events) const
Definition rct.cpp:397
bool generate(std::vector< test_event_entry > &events) const
Definition rct.cpp:370
bool generate(std::vector< test_event_entry > &events) const
Definition rct.cpp:464
bool generate(std::vector< test_event_entry > &events) const
Definition rct.cpp:351
bool generate(std::vector< test_event_entry > &events) const
Definition rct.cpp:437
bool generate(std::vector< test_event_entry > &events) const
Definition rct.cpp:417
bool generate(std::vector< test_event_entry > &events) const
Definition rct.cpp:257
bool generate(std::vector< test_event_entry > &events) const
Definition rct.cpp:241
bool generate(std::vector< test_event_entry > &events) const
Definition rct.cpp:249
bool check_block_verification_context(const cryptonote::block_verification_context &bvc, size_t event_idx, const cryptonote::block &)
Definition rct.h:53
bool check_tx_verification_context(const cryptonote::tx_verification_context &tvc, bool tx_added, size_t event_idx, const cryptonote::transaction &)
Definition rct.h:45
bool mark_invalid_block(cryptonote::core &, size_t ev_index, const std::vector< test_event_entry > &)
Definition rct.h:61
bool mark_invalid_tx(cryptonote::core &, size_t ev_index, const std::vector< test_event_entry > &)
Definition rct.h:67
bool generate_with(std::vector< test_event_entry > &events, const int *out_idx, int mixin, uint64_t amount_paid, bool valid, const std::function< void(std::vector< cryptonote::tx_source_entry > &sources, std::vector< cryptonote::tx_destination_entry > &destinations)> &pre_tx, const std::function< void(cryptonote::transaction &tx)> &post_tx) const
Definition rct.cpp:44
const std::pair< uint8_t, uint64_t > hard_forks[4]
Definition rct.h:85
const cryptonote::test_options test_options
Definition rct.h:86