Compare commits
247 Commits
Author | SHA1 | Date |
---|---|---|
wowario | 589efde6b3 | 2 weeks ago |
jeffro256 | cb63c922f8 | 2 weeks ago |
jeffro256 | eeec04520d | 2 weeks ago |
selsta | 3605ec6419 | 2 weeks ago |
dsc | dad8e3cadd | 3 weeks ago |
wowario | c2d9ac9d16 | 3 weeks ago |
wowario | e707dafd04 | 3 weeks ago |
dsc | aa19aa8fc3 | 3 weeks ago |
dsc | 269fd51d34 | 3 weeks ago |
dsc | ea1ff89671 | 3 weeks ago |
wowario | a46db6fbf9 | 3 weeks ago |
wowario | 1fb180a69b | 3 weeks ago |
wowario | cf5bfd0cc4 | 3 weeks ago |
wowario | 6a5303f21b | 3 weeks ago |
wowario | 5a127e006e | 3 weeks ago |
wowario | 93e542dc55 | 3 weeks ago |
wowario | cae358334e | 3 weeks ago |
_XxFedexX_ | f0e9542c06 | 3 weeks ago |
wowario | 2f3f3b7a6e | 3 weeks ago |
wowario | b414a0659d | 3 weeks ago |
thotbot | 3f78176f3d | 3 weeks ago |
moneromooo-monero | f438928ed8 | 3 weeks ago |
wowario | b07e533a8f | 3 weeks ago |
hinto-janaiyo | 8ccfd46a41 | 3 weeks ago |
thotbot | e60954b619 | 3 weeks ago |
thotbot | 1ed861bff8 | 3 weeks ago |
thotbot | 8b467e98a4 | 3 weeks ago |
thotbot | 4f8ad5bfac | 3 weeks ago |
thotbot | 3234b5fe62 | 3 weeks ago |
thotbot | e6cc37e9b0 | 3 weeks ago |
thotbot | fcffffdd5d | 3 weeks ago |
wowario | 77ca74ba54 | 3 weeks ago |
wowario | 8d78cedaec | 3 weeks ago |
wowario | e8bec95650 | 3 weeks ago |
wowario | 36dc60fdfd | 3 weeks ago |
wowario | f742aed6a3 | 3 weeks ago |
wowario | b602ab02ee | 3 weeks ago |
wowario | f409249b78 | 3 weeks ago |
wowario | 0bb22452ac | 3 weeks ago |
wowario | 8337a81ef5 | 3 weeks ago |
wowario | 6ca2369b67 | 3 weeks ago |
wowario | 934cd71608 | 3 weeks ago |
wowario | b2906602a4 | 3 weeks ago |
wowario | df381eaa84 | 3 weeks ago |
wowario | 83a0e91e23 | 3 weeks ago |
wowario | 26d039db0a | 3 weeks ago |
wowario | 662a2993d3 | 3 weeks ago |
wowario | 65570252f2 | 3 weeks ago |
wowario | eff55d073c | 3 weeks ago |
wowario | d1441bc034 | 3 weeks ago |
wowario | 5e50141c4a | 3 weeks ago |
wowario | 8c081b4b02 | 3 weeks ago |
wowario | 917970cebf | 3 weeks ago |
wowario | c7190cdd0f | 3 weeks ago |
wowario | a177241046 | 3 weeks ago |
wowario | e224b4af93 | 3 weeks ago |
wowario | 0c4915d707 | 3 weeks ago |
wowario | ff34adf8b7 | 3 weeks ago |
wowario | 48841789cb | 3 weeks ago |
wowario | 2ddaa7835c | 3 weeks ago |
wowario | aa7564806d | 3 weeks ago |
wowario | a0a90ada1a | 3 weeks ago |
wowario | 7b9bfb73b1 | 3 weeks ago |
wowario | 642beba4af | 3 weeks ago |
wowario | cf8e878869 | 3 weeks ago |
wowario | 6afdd7894a | 3 weeks ago |
wowario | 7f01ebbf29 | 3 weeks ago |
wowario | 6fee906b1c | 3 weeks ago |
wowario | 0fd82de0be | 3 weeks ago |
wowario | 68f1f2b2c3 | 3 weeks ago |
wowario | ddf990f394 | 3 weeks ago |
wowario | 196a3756d6 | 3 weeks ago |
wowario | 4ed9b68d59 | 3 weeks ago |
wowario | 37195f2128 | 3 weeks ago |
wowario | e71bef4496 | 3 weeks ago |
wowario | a04690c66b | 3 weeks ago |
wowario | 9c3fb6c243 | 3 weeks ago |
wowario | 463de38ef5 | 3 weeks ago |
wowario | c474334f41 | 3 weeks ago |
wowario | ce3a67ed21 | 3 weeks ago |
wowario | fb39891031 | 3 weeks ago |
wowario | 1c44d89030 | 3 weeks ago |
wowario | da6a2dc2c5 | 3 weeks ago |
wowario | d6a3511d59 | 3 weeks ago |
wowario | 6b8e245aea | 3 weeks ago |
wowario | 917edfbec9 | 3 weeks ago |
wowario | 5964374c4b | 3 weeks ago |
wowario | a5d50332ca | 3 weeks ago |
wowario | 73f52ea6b9 | 3 weeks ago |
wowario | 1cae37348a | 3 weeks ago |
wowario | 2b78ff8117 | 3 weeks ago |
wowario | e5016a6f8e | 3 weeks ago |
wowario | a93dcc1962 | 3 weeks ago |
wowario | a25032cc1e | 3 weeks ago |
wowario | 2a4e1c6913 | 3 weeks ago |
wowario | 3271844ab5 | 3 weeks ago |
wowario | 7af83ced4c | 3 weeks ago |
luigi1111 | ef3e18b51b | 3 weeks ago |
SChernykh | b5b72ae05c | 3 weeks ago |
luigi1111 | 5eb3fc29bb | 3 weeks ago |
luigi1111 | c225a1f25b | 3 weeks ago |
luigi1111 | ff15cb2f04 | 3 weeks ago |
jeffro256 | eeb7c7c546 | 3 weeks ago |
SChernykh | 36ee12bd8d | 3 weeks ago |
selsta | 32b3a56313 | 3 weeks ago |
luigi1111 | b23116424d | 3 weeks ago |
jeffro256 | 7807f569e4 | 3 weeks ago |
luigi1111 | 68e40ea2a7 | 1 month ago |
luigi1111 | c6ff0d3820 | 1 month ago |
luigi1111 | 0d2f515ecc | 1 month ago |
luigi1111 | 522d82276e | 1 month ago |
luigi1111 | 4f6f6d9e27 | 1 month ago |
luigi1111 | 3872753202 | 1 month ago |
luigi1111 | 13ed9d501b | 1 month ago |
luigi1111 | b335433204 | 1 month ago |
luigi1111 | 8a1e49664e | 1 month ago |
luigi1111 | 2f912f8a58 | 1 month ago |
luigi1111 | 81f113dd8c | 1 month ago |
luigi1111 | f9a7f2a136 | 1 month ago |
selsta | c97c2ec01c | 1 month ago |
jeffro256 | 51d7a6921c | 1 month ago |
selsta | f2360a725e | 1 month ago |
selsta | 0cc8f7aaa3 | 1 month ago |
tobtoht | b987870553 | 1 month ago |
tobtoht | 3aabfcfce5 | 1 month ago |
tobtoht | 8322f9c4f5 | 1 month ago |
woodser | fbd0b19fc8 | 2 months ago |
jeffro256 | 33e3f72d24 | 2 months ago |
Lee *!* Clagett | 052df1b28c | 2 months ago |
Lee Clagett | 98ee46f249 | 2 months ago |
Lee *!* Clagett | f5b86342e8 | 2 months ago |
jeffro256 | dfb990e8bb | 2 months ago |
luigi1111 | 8eab181fe1 | 2 months ago |
luigi1111 | 9a70f43440 | 2 months ago |
Lee Clagett | 47d8899c90 | 4 months ago |
luigi1111 | c09062087e | 5 months ago |
luigi1111 | 9a5f8431b4 | 5 months ago |
luigi1111 | 79107ff68f | 5 months ago |
luigi1111 | 646c3fb0d9 | 5 months ago |
luigi1111 | c193c5e85d | 5 months ago |
luigi1111 | d5c667a5ad | 5 months ago |
luigi1111 | 2fe5a5e073 | 5 months ago |
luigi1111 | 95e4fc3602 | 5 months ago |
SChernykh | e7d51e5583 | 5 months ago |
Lee *!* Clagett | fe746dca4e | 5 months ago |
jeffro256 | fe47806afb | 5 months ago |
moneromooo-monero | 6c38c21dfd | 5 months ago |
Jeffrey Ryan | 5435202450 | 5 months ago |
luigi1111 | d9b765a3af | 5 months ago |
luigi1111 | 72d2a610cd | 5 months ago |
luigi1111 | 2e9542d01a | 5 months ago |
jeffro256 | 0f75585f64 | 5 months ago |
luigi1111 | eb4df0aa1c | 5 months ago |
jeffro256 | eae62a07e0 | 5 months ago |
jeffro256 | 14ae81246d | 5 months ago |
selsta | 5b0c27430f | 5 months ago |
tevador | 09a88cc00e | 5 months ago |
j-berman | bdebf680bd | 6 months ago |
jeffro256 | e0b2123c32 | 6 months ago |
luigi1111 | 2656cdf505 | 6 months ago |
luigi1111 | 1c12d305d6 | 6 months ago |
luigi1111 | 83d0d2338f | 6 months ago |
Boog900 | 69de381526 | 6 months ago |
Boog900 | 810f6a6cd2 | 6 months ago |
selsta | fbcd8da082 | 6 months ago |
selsta | 03d51b7cc4 | 6 months ago |
luigi1111 | f9b81a589e | 6 months ago |
luigi1111 | 41157dbc82 | 6 months ago |
j-berman | 9a89e2d9e4 | 6 months ago |
Crypto City | 1df5630f23 | 6 months ago |
selsta | 3f9140e754 | 6 months ago |
jeff | 205c80427b | 6 months ago |
tobtoht | 0c04018718 | 6 months ago |
luigi1111 | 533bbc3208 | 7 months ago |
luigi1111 | 6e7bd68b18 | 7 months ago |
luigi1111 | 031d318ca2 | 7 months ago |
luigi1111 | 61e664a258 | 7 months ago |
selsta | 64ed9385a2 | 7 months ago |
jeffro256 | ba98269ca5 | 7 months ago |
jeffro256 | 7dbb14b02a | 7 months ago |
moneromooo-monero | 356e6877dc | 8 months ago |
moneromooo-monero | 633e1b7359 | 8 months ago |
luigi1111 | eac1b86bb2 | 8 months ago |
luigi1111 | 3bebcc4a7d | 8 months ago |
luigi1111 | 9d5c5b5634 | 8 months ago |
luigi1111 | 894adef295 | 8 months ago |
luigi1111 | 6c7640eb74 | 8 months ago |
jeffro256 | 78348bcddd | 8 months ago |
j-berman | b51f4a9244 | 8 months ago |
jeffro256 | ed05ac6872 | 9 months ago |
j-berman | f137a35984 | 9 months ago |
rbrunner7 | 23f782b211 | 9 months ago |
luigi1111 | ab826008d6 | 9 months ago |
luigi1111 | 4dc727b3f6 | 9 months ago |
luigi1111 | 1eb1162923 | 9 months ago |
luigi1111 | 3be6c1389e | 9 months ago |
luigi1111 | 5a99b2dfbe | 9 months ago |
luigi1111 | bd962882d1 | 9 months ago |
luigi1111 | f173bf6e72 | 9 months ago |
luigi1111 | a41453c256 | 9 months ago |
jeffro256 | 842478c5a9 | 9 months ago |
luigi1111 | 17ea7665d7 | 9 months ago |
luigi1111 | 9f8ae9649a | 9 months ago |
luigi1111 | 11b5139506 | 9 months ago |
luigi1111 | 54f0f9eb96 | 9 months ago |
luigi1111 | 5c900bb69f | 9 months ago |
luigi1111 | 60e9426ef2 | 9 months ago |
Crypto City | 835896ea24 | 9 months ago |
Crypto City | 62bb95b25f | 9 months ago |
moneromooo-monero | 1924c170d4 | 9 months ago |
Lee *!* Clagett | aed36a25d6 | 10 months ago |
Lee Clagett | c6530d2f5d | 10 months ago |
jeffro256 | dc24312bc3 | 10 months ago |
j-berman | 438554e1ab | 10 months ago |
SChernykh | 26025cb294 | 10 months ago |
jeffro256 | cfc62277c0 | 10 months ago |
jeffro256 | aa139f0334 | 10 months ago |
tobtoht | a4a58eb886 | 10 months ago |
tobtoht | 8dc4abdafe | 10 months ago |
luigi1111 | 1ce32d8536 | 11 months ago |
Crypto City | 1fad8cc919 | 11 months ago |
tobtoht | f983ac7780 | 11 months ago |
SChernykh | 1d1d5fb74c | 11 months ago |
luigi1111 | 2f45d5c615 | 11 months ago |
luigi1111 | e06129bb4d | 1 year ago |
luigi1111 | a371e60a30 | 1 year ago |
luigi1111 | 2f62dd5b78 | 1 year ago |
jeffro256 | 059b975388 | 1 year ago |
SChernykh | c742fa4c6e | 1 year ago |
selsta | 4f1262bae9 | 1 year ago |
luigi1111 | 4f47fd2626 | 1 year ago |
Crypto City | 132804811d | 1 year ago |
luigi1111 | 25645e5d23 | 1 year ago |
luigi1111 | 0e2c2ddd9c | 1 year ago |
moneromooo-monero | c4cfaa4567 | 1 year ago |
moneromooo-monero | f0e326be58 | 1 year ago |
luigi1111 | 225e5ba571 | 1 year ago |
luigi1111 | 66f57299a2 | 1 year ago |
luigi1111 | d7821a02c4 | 1 year ago |
luigi1111 | b4519c6bbd | 1 year ago |
selsta | cdeb286359 | 1 year ago |
tevador | 5900ed3706 | 1 year ago |
Jeffrey Ryan | c59e0096b6 | 1 year ago |
Francois Beutin | 14de562a6f | 1 year ago |
j-berman | 65e13dbef1 | 1 year ago |
almalh | ad80f1b357 | 1 year ago |
selsta | 77d883e507 | 1 year ago |
@ -1 +1 @@
|
||||
Subproject commit 607bad48f3687c2490d90f8c55efa2dcd7cbc195
|
||||
Subproject commit 27b099b6dd6fef6e17f58c6dfe00009e9c5df587
|
Binary file not shown.
@ -0,0 +1,167 @@
|
||||
// Copyright (c) 2023, The Monero Project
|
||||
//
|
||||
// All rights reserved.
|
||||
//
|
||||
// Redistribution and use in source and binary forms, with or without modification, are
|
||||
// permitted provided that the following conditions are met:
|
||||
//
|
||||
// 1. Redistributions of source code must retain the above copyright notice, this list of
|
||||
// conditions and the following disclaimer.
|
||||
//
|
||||
// 2. Redistributions in binary form must reproduce the above copyright notice, this list
|
||||
// of conditions and the following disclaimer in the documentation and/or other
|
||||
// materials provided with the distribution.
|
||||
//
|
||||
// 3. Neither the name of the copyright holder nor the names of its contributors may be
|
||||
// used to endorse or promote products derived from this software without specific
|
||||
// prior written permission.
|
||||
//
|
||||
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY
|
||||
// EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
|
||||
// MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL
|
||||
// THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||
// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
|
||||
// PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
||||
// INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
|
||||
// STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF
|
||||
// THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
|
||||
#include "cryptonote_core/blockchain.h"
|
||||
#include "cryptonote_core/tx_verification_utils.h"
|
||||
#include "ringct/rctSigs.h"
|
||||
|
||||
#undef MONERO_DEFAULT_LOG_CATEGORY
|
||||
#define MONERO_DEFAULT_LOG_CATEGORY "blockchain"
|
||||
|
||||
#define VER_ASSERT(cond, msgexpr) CHECK_AND_ASSERT_MES(cond, false, msgexpr)
|
||||
|
||||
using namespace cryptonote;
|
||||
|
||||
// Do RCT expansion, then do post-expansion sanity checks, then do full non-semantics verification.
|
||||
static bool expand_tx_and_ver_rct_non_sem(transaction& tx, const rct::ctkeyM& mix_ring)
|
||||
{
|
||||
// Pruned transactions can not be expanded and verified because they are missing RCT data
|
||||
VER_ASSERT(!tx.pruned, "Pruned transaction will not pass verRctNonSemanticsSimple");
|
||||
|
||||
// Calculate prefix hash
|
||||
const crypto::hash tx_prefix_hash = get_transaction_prefix_hash(tx);
|
||||
|
||||
// Expand mixring, tx inputs, tx key images, prefix hash message, etc into the RCT sig
|
||||
const bool exp_res = Blockchain::expand_transaction_2(tx, tx_prefix_hash, mix_ring);
|
||||
VER_ASSERT(exp_res, "Failed to expand rct signatures!");
|
||||
|
||||
const rct::rctSig& rv = tx.rct_signatures;
|
||||
|
||||
// Check that expanded RCT mixring == input mixring
|
||||
VER_ASSERT(rv.mixRing == mix_ring, "Failed to check ringct signatures: mismatched pubkeys/mixRing");
|
||||
|
||||
// Check CLSAG/MLSAG size against transaction input
|
||||
const size_t n_sigs = rct::is_rct_clsag(rv.type) ? rv.p.CLSAGs.size() : rv.p.MGs.size();
|
||||
VER_ASSERT(n_sigs == tx.vin.size(), "Failed to check ringct signatures: mismatched input sigs/vin sizes");
|
||||
|
||||
// For each input, check that the key images were copied into the expanded RCT sig correctly
|
||||
for (size_t n = 0; n < n_sigs; ++n)
|
||||
{
|
||||
const crypto::key_image& nth_vin_image = boost::get<txin_to_key>(tx.vin[n]).k_image;
|
||||
|
||||
if (rct::is_rct_clsag(rv.type))
|
||||
{
|
||||
const bool ki_match = 0 == memcmp(&nth_vin_image, &rv.p.CLSAGs[n].I, 32);
|
||||
VER_ASSERT(ki_match, "Failed to check ringct signatures: mismatched CLSAG key image");
|
||||
}
|
||||
else
|
||||
{
|
||||
const bool mg_nonempty = !rv.p.MGs[n].II.empty();
|
||||
VER_ASSERT(mg_nonempty, "Failed to check ringct signatures: missing MLSAG key image");
|
||||
const bool ki_match = 0 == memcmp(&nth_vin_image, &rv.p.MGs[n].II[0], 32);
|
||||
VER_ASSERT(ki_match, "Failed to check ringct signatures: mismatched MLSAG key image");
|
||||
}
|
||||
}
|
||||
|
||||
// Mix ring data is now known to be correctly incorporated into the RCT sig inside tx.
|
||||
return rct::verRctNonSemanticsSimple(rv);
|
||||
}
|
||||
|
||||
// Create a unique identifier for pair of tx blob + mix ring
|
||||
static crypto::hash calc_tx_mixring_hash(const transaction& tx, const rct::ctkeyM& mix_ring)
|
||||
{
|
||||
std::stringstream ss;
|
||||
|
||||
// Start with domain seperation
|
||||
ss << config::HASH_KEY_TXHASH_AND_MIXRING;
|
||||
|
||||
// Then add TX hash
|
||||
const crypto::hash tx_hash = get_transaction_hash(tx);
|
||||
ss.write(tx_hash.data, sizeof(crypto::hash));
|
||||
|
||||
// Then serialize mix ring
|
||||
binary_archive<true> ar(ss);
|
||||
::do_serialize(ar, const_cast<rct::ctkeyM&>(mix_ring));
|
||||
|
||||
// Calculate hash of TX hash and mix ring blob
|
||||
crypto::hash tx_and_mixring_hash;
|
||||
get_blob_hash(ss.str(), tx_and_mixring_hash);
|
||||
|
||||
return tx_and_mixring_hash;
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
namespace cryptonote
|
||||
{
|
||||
|
||||
bool ver_rct_non_semantics_simple_cached
|
||||
(
|
||||
transaction& tx,
|
||||
const rct::ctkeyM& mix_ring,
|
||||
rct_ver_cache_t& cache,
|
||||
const std::uint8_t rct_type_to_cache
|
||||
)
|
||||
{
|
||||
// Hello future Monero dev! If you got this assert, read the following carefully:
|
||||
//
|
||||
// For this version of RCT, the way we guaranteed that verification caches do not generate false
|
||||
// positives (and thus possibly enabling double spends) is we take a hash of two things. One,
|
||||
// we use get_transaction_hash() which gives us a (cryptographically secure) unique
|
||||
// representation of all "knobs" controlled by the possibly malicious constructor of the
|
||||
// transaction. Two, we take a hash of all *previously validated* blockchain data referenced by
|
||||
// this transaction which is required to validate the ring signature. In our case, this is the
|
||||
// mixring. Future versions of the protocol may differ in this regard, but if this assumptions
|
||||
// holds true in the future, enable the verification hash by modifying the `untested_tx`
|
||||
// condition below.
|
||||
const bool untested_tx = tx.version > 2 || tx.rct_signatures.type > rct::RCTTypeBulletproofPlus;
|
||||
VER_ASSERT(!untested_tx, "Unknown TX type. Make sure RCT cache works correctly with this type and then enable it in the code here.");
|
||||
|
||||
// Don't cache older (or newer) rctSig types
|
||||
// This cache only makes sense when it caches data from mempool first,
|
||||
// so only "current fork version-enabled" RCT types need to be cached
|
||||
if (tx.rct_signatures.type != rct_type_to_cache)
|
||||
{
|
||||
MDEBUG("RCT cache: tx " << get_transaction_hash(tx) << " skipped");
|
||||
return expand_tx_and_ver_rct_non_sem(tx, mix_ring);
|
||||
}
|
||||
|
||||
// Generate unique hash for tx+mix_ring pair
|
||||
const crypto::hash tx_mixring_hash = calc_tx_mixring_hash(tx, mix_ring);
|
||||
|
||||
// Search cache for successful verification of same TX + mix ring combination
|
||||
if (cache.has(tx_mixring_hash))
|
||||
{
|
||||
MDEBUG("RCT cache: tx " << get_transaction_hash(tx) << " hit");
|
||||
return true;
|
||||
}
|
||||
|
||||
// We had a cache miss, so now we must expand the mix ring and do full verification
|
||||
MDEBUG("RCT cache: tx " << get_transaction_hash(tx) << " missed");
|
||||
if (!expand_tx_and_ver_rct_non_sem(tx, mix_ring))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
// At this point, the TX RCT verified successfully, so add it to the cache and return true
|
||||
cache.add(tx_mixring_hash);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
} // namespace cryptonote
|
@ -0,0 +1,78 @@
|
||||
// Copyright (c) 2023, The Monero Project
|
||||
//
|
||||
// All rights reserved.
|
||||
//
|
||||
// Redistribution and use in source and binary forms, with or without modification, are
|
||||
// permitted provided that the following conditions are met:
|
||||
//
|
||||
// 1. Redistributions of source code must retain the above copyright notice, this list of
|
||||
// conditions and the following disclaimer.
|
||||
//
|
||||
// 2. Redistributions in binary form must reproduce the above copyright notice, this list
|
||||
// of conditions and the following disclaimer in the documentation and/or other
|
||||
// materials provided with the distribution.
|
||||
//
|
||||
// 3. Neither the name of the copyright holder nor the names of its contributors may be
|
||||
// used to endorse or promote products derived from this software without specific
|
||||
// prior written permission.
|
||||
//
|
||||
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY
|
||||
// EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
|
||||
// MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL
|
||||
// THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||
// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
|
||||
// PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
||||
// INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
|
||||
// STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF
|
||||
// THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "common/data_cache.h"
|
||||
#include "cryptonote_basic/cryptonote_basic.h"
|
||||
|
||||
namespace cryptonote
|
||||
{
|
||||
|
||||
// Modifying this value should not affect consensus. You can adjust it for performance needs
|
||||
static constexpr const size_t RCT_VER_CACHE_SIZE = 8192;
|
||||
|
||||
using rct_ver_cache_t = ::tools::data_cache<::crypto::hash, RCT_VER_CACHE_SIZE>;
|
||||
|
||||
/**
|
||||
* @brief Cached version of rct::verRctNonSemanticsSimple
|
||||
*
|
||||
* This function will not affect how the transaction is serialized and it will never modify the
|
||||
* transaction prefix.
|
||||
*
|
||||
* The reference to tx is mutable since the transaction's ring signatures may be expanded by
|
||||
* Blockchain::expand_transaction_2. However, on cache hits, the transaction will not be
|
||||
* expanded. This means that the caller does not need to call expand_transaction_2 on this
|
||||
* transaction before passing it; the transaction will not successfully verify with "old" RCT data
|
||||
* if the transaction has been otherwise modified since the last verification.
|
||||
*
|
||||
* But, if cryptonote::get_transaction_hash(tx) returns a "stale" hash, this function is not
|
||||
* guaranteed to work. So make sure that the cryptonote::transaction passed has not had
|
||||
* modifications to it since the last time its hash was fetched without properly invalidating the
|
||||
* hashes.
|
||||
*
|
||||
* rct_type_to_cache can be any RCT version value as long as rct::verRctNonSemanticsSimple works for
|
||||
* this RCT version, but for most applications, it doesn't make sense to not make this version
|
||||
* the "current" RCT version (i.e. the version that transactions in the mempool are).
|
||||
*
|
||||
* @param tx transaction which contains RCT signature to verify
|
||||
* @param mix_ring mixring referenced by this tx. THIS DATA MUST BE PREVIOUSLY VALIDATED
|
||||
* @param cache saves tx+mixring hashes used to cache calls
|
||||
* @param rct_type_to_cache Only RCT sigs with version (e.g. RCTTypeBulletproofPlus) will be cached
|
||||
* @return true when verRctNonSemanticsSimple() w/ expanded tx.rct_signatures would return true
|
||||
* @return false when verRctNonSemanticsSimple() w/ expanded tx.rct_signatures would return false
|
||||
*/
|
||||
bool ver_rct_non_semantics_simple_cached
|
||||
(
|
||||
transaction& tx,
|
||||
const rct::ctkeyM& mix_ring,
|
||||
rct_ver_cache_t& cache,
|
||||
std::uint8_t rct_type_to_cache
|
||||
);
|
||||
|
||||
} // namespace cryptonote
|
File diff suppressed because it is too large
Load Diff
Binary file not shown.
Binary file not shown.
Binary file not shown.
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in new issue