Monero
Loading...
Searching...
No Matches
rct.h
Go to the documentation of this file.
1// Copyright (c) 2014-2022, The Monero Project
2//
3// All rights reserved.
4//
5// Redistribution and use in source and binary forms, with or without modification, are
6// permitted provided that the following conditions are met:
7//
8// 1. Redistributions of source code must retain the above copyright notice, this list of
9// conditions and the following disclaimer.
10//
11// 2. Redistributions in binary form must reproduce the above copyright notice, this list
12// of conditions and the following disclaimer in the documentation and/or other
13// materials provided with the distribution.
14//
15// 3. Neither the name of the copyright holder nor the names of its contributors may be
16// used to endorse or promote products derived from this software without specific
17// prior written permission.
18//
19// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY
20// EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
21// MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL
22// THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
23// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
24// PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
25// INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
26// STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF
27// THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
28//
29// Parts of this file are originally copyright (c) 2012-2013 The Cryptonote developers
30
31#pragma once
32#include "chaingen.h"
33
35{
43
44 bool check_tx_verification_context(const cryptonote::tx_verification_context& tvc, bool tx_added, size_t event_idx, const cryptonote::transaction& /*tx*/)
45 {
46 if (m_invalid_tx_index == event_idx)
47 return tvc.m_verifivation_failed;
48 else
49 return !tvc.m_verifivation_failed && tx_added;
50 }
51
53 {
54 if (m_invalid_block_index == event_idx)
55 return bvc.m_verifivation_failed;
56 else
57 return !bvc.m_verifivation_failed;
58 }
59
60 bool mark_invalid_block(cryptonote::core& /*c*/, size_t ev_index, const std::vector<test_event_entry>& /*events*/)
61 {
62 m_invalid_block_index = ev_index + 1;
63 return true;
64 }
65
66 bool mark_invalid_tx(cryptonote::core& /*c*/, size_t ev_index, const std::vector<test_event_entry>& /*events*/)
67 {
68 m_invalid_tx_index = ev_index + 1;
69 return true;
70 }
71
72 bool generate_with_full(std::vector<test_event_entry>& events, const int *out_idx, int mixin,
73 uint64_t amount_paid, size_t second_rewind, uint8_t last_version, const rct::RCTConfig &rct_config, bool use_view_tags, bool valid,
74 const std::function<void(std::vector<cryptonote::tx_source_entry> &sources, std::vector<cryptonote::tx_destination_entry> &destinations)> &pre_tx,
75 const std::function<void(cryptonote::transaction &tx)> &post_tx) const;
76 bool generate_with(std::vector<test_event_entry>& events, const int *out_idx, int mixin,
77 uint64_t amount_paid, bool valid,
78 const std::function<void(std::vector<cryptonote::tx_source_entry> &sources, std::vector<cryptonote::tx_destination_entry> &destinations)> &pre_tx,
79 const std::function<void(cryptonote::transaction &tx)> &post_tx) const;
80
81private:
84};
85
86template<>
88 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)};
92};
93
94// valid
96{
97 bool generate(std::vector<test_event_entry>& events) const;
98};
99template<> struct get_test_options<gen_rct_tx_valid_from_pre_rct>: public get_test_options<gen_rct_tx_validation_base> {};
100
102{
103 bool generate(std::vector<test_event_entry>& events) const;
104};
105template<> struct get_test_options<gen_rct_tx_valid_from_rct>: public get_test_options<gen_rct_tx_validation_base> {};
106
108{
109 bool generate(std::vector<test_event_entry>& events) const;
110};
111template<> struct get_test_options<gen_rct_tx_valid_from_mixed>: public get_test_options<gen_rct_tx_validation_base> {};
112
113// altered commitment/dest
115{
116 bool generate(std::vector<test_event_entry>& events) const;
117};
118template<> struct get_test_options<gen_rct_tx_pre_rct_bad_real_dest>: public get_test_options<gen_rct_tx_validation_base> {};
119
121{
122 bool generate(std::vector<test_event_entry>& events) const;
123};
124template<> struct get_test_options<gen_rct_tx_pre_rct_bad_real_mask>: public get_test_options<gen_rct_tx_validation_base> {};
125
127{
128 bool generate(std::vector<test_event_entry>& events) const;
129};
130template<> struct get_test_options<gen_rct_tx_pre_rct_bad_fake_dest>: public get_test_options<gen_rct_tx_validation_base> {};
131
133{
134 bool generate(std::vector<test_event_entry>& events) const;
135};
136template<> struct get_test_options<gen_rct_tx_pre_rct_bad_fake_mask>: public get_test_options<gen_rct_tx_validation_base> {};
137
139{
140 bool generate(std::vector<test_event_entry>& events) const;
141};
142template<> struct get_test_options<gen_rct_tx_rct_bad_real_dest>: public get_test_options<gen_rct_tx_validation_base> {};
143
145{
146 bool generate(std::vector<test_event_entry>& events) const;
147};
148template<> struct get_test_options<gen_rct_tx_rct_bad_real_mask>: public get_test_options<gen_rct_tx_validation_base> {};
149
151{
152 bool generate(std::vector<test_event_entry>& events) const;
153};
154template<> struct get_test_options<gen_rct_tx_rct_bad_fake_dest>: public get_test_options<gen_rct_tx_validation_base> {};
155
157{
158 bool generate(std::vector<test_event_entry>& events) const;
159};
160template<> struct get_test_options<gen_rct_tx_rct_bad_fake_mask>: public get_test_options<gen_rct_tx_validation_base> {};
161
163{
164 bool generate(std::vector<test_event_entry>& events) const;
165};
166template<> struct get_test_options<gen_rct_tx_rct_spend_with_zero_commit>: public get_test_options<gen_rct_tx_validation_base> {};
167
168// altered amounts
170{
171 bool generate(std::vector<test_event_entry>& events) const;
172};
173template<> struct get_test_options<gen_rct_tx_pre_rct_zero_vin_amount>: public get_test_options<gen_rct_tx_validation_base> {};
174
176{
177 bool generate(std::vector<test_event_entry>& events) const;
178};
179template<> struct get_test_options<gen_rct_tx_rct_non_zero_vin_amount>: public get_test_options<gen_rct_tx_validation_base> {};
180
182{
183 bool generate(std::vector<test_event_entry>& events) const;
184};
185template<> struct get_test_options<gen_rct_tx_non_zero_vout_amount>: public get_test_options<gen_rct_tx_validation_base> {};
186
187// key image
189{
190 bool generate(std::vector<test_event_entry>& events) const;
191};
192template<> struct get_test_options<gen_rct_tx_pre_rct_duplicate_key_image>: public get_test_options<gen_rct_tx_validation_base> {};
193
195{
196 bool generate(std::vector<test_event_entry>& events) const;
197};
198template<> struct get_test_options<gen_rct_tx_rct_duplicate_key_image>: public get_test_options<gen_rct_tx_validation_base> {};
199
201{
202 bool generate(std::vector<test_event_entry>& events) const;
203};
204template<> struct get_test_options<gen_rct_tx_pre_rct_wrong_key_image>: public get_test_options<gen_rct_tx_validation_base> {};
205
207{
208 bool generate(std::vector<test_event_entry>& events) const;
209};
210template<> struct get_test_options<gen_rct_tx_rct_wrong_key_image>: public get_test_options<gen_rct_tx_validation_base> {};
211
212// fee
214{
215 bool generate(std::vector<test_event_entry>& events) const;
216};
217template<> struct get_test_options<gen_rct_tx_pre_rct_wrong_fee>: public get_test_options<gen_rct_tx_validation_base> {};
218
220{
221 bool generate(std::vector<test_event_entry>& events) const;
222};
223template<> struct get_test_options<gen_rct_tx_rct_wrong_fee>: public get_test_options<gen_rct_tx_validation_base> {};
224
226{
227 bool generate(std::vector<test_event_entry>& events) const;
228};
229template<> struct get_test_options<gen_rct_tx_pre_rct_increase_vin_and_fee>: public get_test_options<gen_rct_tx_validation_base> {};
230
231// modify vin/vout
233{
234 bool generate(std::vector<test_event_entry>& events) const;
235};
236template<> struct get_test_options<gen_rct_tx_pre_rct_remove_vin>: public get_test_options<gen_rct_tx_validation_base> {};
237
239{
240 bool generate(std::vector<test_event_entry>& events) const;
241};
242template<> struct get_test_options<gen_rct_tx_rct_remove_vin>: public get_test_options<gen_rct_tx_validation_base> {};
243
245{
246 bool generate(std::vector<test_event_entry>& events) const;
247};
248template<> struct get_test_options<gen_rct_tx_pre_rct_add_vout>: public get_test_options<gen_rct_tx_validation_base> {};
249
251{
252 bool generate(std::vector<test_event_entry>& events) const;
253};
254template<> struct get_test_options<gen_rct_tx_rct_add_vout>: public get_test_options<gen_rct_tx_validation_base> {};
255
256// extra
258{
259 bool generate(std::vector<test_event_entry>& events) const;
260};
261template<> struct get_test_options<gen_rct_tx_pre_rct_altered_extra>: public get_test_options<gen_rct_tx_validation_base> {};
262
264{
265 bool generate(std::vector<test_event_entry>& events) const;
266};
267template<> struct get_test_options<gen_rct_tx_rct_altered_extra>: public get_test_options<gen_rct_tx_validation_base> {};
268
270{
271 bool generate(std::vector<test_event_entry>& events) const;
272};
273template<> struct get_test_options<gen_rct_tx_pre_rct_has_no_view_tag_before_hf_view_tags>: public get_test_options<gen_rct_tx_validation_base> {};
274
276{
277 bool generate(std::vector<test_event_entry>& events) const;
278};
280 const std::pair<uint8_t, uint64_t> hard_forks[5] = {std::make_pair(1, 0), std::make_pair(2, 1), std::make_pair(4, 65), std::make_pair(HF_VERSION_VIEW_TAGS, 69), std::make_pair(0, 0)};
284};
285
287{
288 bool generate(std::vector<test_event_entry>& events) const;
289};
290template<> struct get_test_options<gen_rct_tx_pre_rct_has_view_tag_before_hf_view_tags>: public get_test_options<gen_rct_tx_validation_base> {};
291
293{
294 bool generate(std::vector<test_event_entry>& events) const;
295};
297 const std::pair<uint8_t, uint64_t> hard_forks[5] = {std::make_pair(1, 0), std::make_pair(2, 1), std::make_pair(4, 65), std::make_pair(HF_VERSION_VIEW_TAGS, 69), std::make_pair(0, 0)};
301};
302
304{
305 bool generate(std::vector<test_event_entry>& events) const;
306};
307template<> struct get_test_options<gen_rct_tx_rct_has_no_view_tag_before_hf_view_tags>: public get_test_options<gen_rct_tx_validation_base> {};
308
310{
311 bool generate(std::vector<test_event_entry>& events) const;
312};
314 const std::pair<uint8_t, uint64_t> hard_forks[5] = {std::make_pair(1, 0), std::make_pair(2, 1), std::make_pair(4, 65), std::make_pair(HF_VERSION_VIEW_TAGS+1, 69), std::make_pair(0, 0)};
318};
319
321{
322 bool generate(std::vector<test_event_entry>& events) const;
323};
324template<> struct get_test_options<gen_rct_tx_rct_has_view_tag_before_hf_view_tags>: public get_test_options<gen_rct_tx_validation_base> {};
325
327{
328 bool generate(std::vector<test_event_entry>& events) const;
329};
331 const std::pair<uint8_t, uint64_t> hard_forks[5] = {std::make_pair(1, 0), std::make_pair(2, 1), std::make_pair(4, 65), std::make_pair(HF_VERSION_VIEW_TAGS, 69), std::make_pair(0, 0)};
335};
336
338{
339 bool generate(std::vector<test_event_entry>& events) const;
340};
342 const std::pair<uint8_t, uint64_t> hard_forks[5] = {std::make_pair(1, 0), std::make_pair(2, 1), std::make_pair(4, 65), std::make_pair(12, 69), std::make_pair(0, 0)};
346};
#define REGISTER_CALLBACK_METHOD(CLASS, METHOD)
Definition chaingen.h:859
handles core cryptonote functionality
Definition cryptonote_core.h:87
Definition cryptonote_basic.h:205
Definition chaingen.h:166
#define HF_VERSION_VIEW_TAGS
Definition cryptonote_config.h:193
unsigned char uint8_t
Definition stdint.h:124
unsigned __int64 uint64_t
Definition stdint.h:136
Definition verification_context.h:66
bool m_verifivation_failed
Definition verification_context.h:68
Definition cryptonote_basic.h:475
Definition cryptonote_core.h:61
Definition verification_context.h:41
bool m_verifivation_failed
Definition verification_context.h:45
bool generate(std::vector< test_event_entry > &events) const
Definition rct.cpp:394
Definition rct.h:245
bool generate(std::vector< test_event_entry > &events) const
Definition rct.cpp:488
bool generate(std::vector< test_event_entry > &events) const
Definition rct.cpp:506
bool generate(std::vector< test_event_entry > &events) const
Definition rct.cpp:303
bool generate(std::vector< test_event_entry > &events) const
Definition rct.cpp:313
bool generate(std::vector< test_event_entry > &events) const
Definition rct.cpp:280
bool generate(std::vector< test_event_entry > &events) const
Definition rct.cpp:293
bool generate(std::vector< test_event_entry > &events) const
Definition rct.cpp:403
bool generate(std::vector< test_event_entry > &events) const
Definition rct.cpp:526
bool generate(std::vector< test_event_entry > &events) const
Definition rct.cpp:536
bool generate(std::vector< test_event_entry > &events) const
Definition rct.cpp:547
bool generate(std::vector< test_event_entry > &events) const
Definition rct.cpp:557
bool generate(std::vector< test_event_entry > &events) const
Definition rct.cpp:461
Definition rct.h:233
bool generate(std::vector< test_event_entry > &events) const
Definition rct.cpp:470
Definition rct.h:214
bool generate(std::vector< test_event_entry > &events) const
Definition rct.cpp:443
bool generate(std::vector< test_event_entry > &events) const
Definition rct.cpp:421
bool generate(std::vector< test_event_entry > &events) const
Definition rct.cpp:376
Definition rct.h:251
bool generate(std::vector< test_event_entry > &events) const
Definition rct.cpp:497
Definition rct.h:264
bool generate(std::vector< test_event_entry > &events) const
Definition rct.cpp:516
Definition rct.h:151
bool generate(std::vector< test_event_entry > &events) const
Definition rct.cpp:346
Definition rct.h:157
bool generate(std::vector< test_event_entry > &events) const
Definition rct.cpp:356
Definition rct.h:139
bool generate(std::vector< test_event_entry > &events) const
Definition rct.cpp:323
Definition rct.h:145
bool generate(std::vector< test_event_entry > &events) const
Definition rct.cpp:336
bool generate(std::vector< test_event_entry > &events) const
Definition rct.cpp:412
bool generate(std::vector< test_event_entry > &events) const
Definition rct.cpp:568
bool generate(std::vector< test_event_entry > &events) const
Definition rct.cpp:579
bool generate(std::vector< test_event_entry > &events) const
Definition rct.cpp:590
bool generate(std::vector< test_event_entry > &events) const
Definition rct.cpp:601
bool generate(std::vector< test_event_entry > &events) const
Definition rct.cpp:385
Definition rct.h:239
bool generate(std::vector< test_event_entry > &events) const
Definition rct.cpp:479
bool generate(std::vector< test_event_entry > &events) const
Definition rct.cpp:366
Definition rct.h:220
bool generate(std::vector< test_event_entry > &events) const
Definition rct.cpp:452
Definition rct.h:207
bool generate(std::vector< test_event_entry > &events) const
Definition rct.cpp:432
bool generate(std::vector< test_event_entry > &events) const
Definition rct.cpp:612
Definition rct.h:108
bool generate(std::vector< test_event_entry > &events) const
Definition rct.cpp:272
bool generate(std::vector< test_event_entry > &events) const
Definition rct.cpp:256
Definition rct.h:102
bool generate(std::vector< test_event_entry > &events) const
Definition rct.cpp:264
Definition rct.h:35
gen_rct_tx_validation_base()
Definition rct.h:36
bool check_block_verification_context(const cryptonote::block_verification_context &bvc, size_t event_idx, const cryptonote::block &)
Definition rct.h:52
size_t m_invalid_tx_index
Definition rct.h:82
bool check_tx_verification_context(const cryptonote::tx_verification_context &tvc, bool tx_added, size_t event_idx, const cryptonote::transaction &)
Definition rct.h:44
bool mark_invalid_block(cryptonote::core &, size_t ev_index, const std::vector< test_event_entry > &)
Definition rct.h:60
size_t m_invalid_block_index
Definition rct.h:83
bool generate_with_full(std::vector< test_event_entry > &events, const int *out_idx, int mixin, uint64_t amount_paid, size_t second_rewind, uint8_t last_version, const rct::RCTConfig &rct_config, bool use_view_tags, 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:43
bool mark_invalid_tx(cryptonote::core &, size_t ev_index, const std::vector< test_event_entry > &)
Definition rct.h:66
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:246
const cryptonote::test_options test_options
Definition rct.h:281
const std::pair< uint8_t, uint64_t > hard_forks[5]
Definition rct.h:280
const std::pair< uint8_t, uint64_t > hard_forks[5]
Definition rct.h:297
const cryptonote::test_options test_options
Definition rct.h:298
const std::pair< uint8_t, uint64_t > hard_forks[5]
Definition rct.h:314
const cryptonote::test_options test_options
Definition rct.h:315
const std::pair< uint8_t, uint64_t > hard_forks[5]
Definition rct.h:331
const cryptonote::test_options test_options
Definition rct.h:332
const std::pair< uint8_t, uint64_t > hard_forks[5]
Definition rct.h:342
const cryptonote::test_options test_options
Definition rct.h:343
const std::pair< uint8_t, uint64_t > hard_forks[4]
Definition rct.h:88
const cryptonote::test_options test_options
Definition rct.h:89
get_test_options()
Definition chaingen.h:730
Definition rctTypes.h:308
cryptonote::transaction tx
Definition transaction.cpp:40