diff options
author | Riccardo Spagni <ric@spagni.net> | 2017-01-15 14:56:39 -0500 |
---|---|---|
committer | Riccardo Spagni <ric@spagni.net> | 2017-01-15 14:56:39 -0500 |
commit | 1207d8ad0d043dc9473011733368533fae60a681 (patch) | |
tree | 5ea303b66e292cd8a4a8a9d6efd2caa9da06676b /src/cryptonote_core | |
parent | Merge pull request #1575 (diff) | |
parent | rct: split rct checks between semantics and other (diff) | |
download | monero-1207d8ad0d043dc9473011733368533fae60a681.tar.xz |
Merge pull request #1576
ba3968f6 rct: split rct checks between semantics and other (moneromooo-monero)
Diffstat (limited to 'src/cryptonote_core')
-rw-r--r-- | src/cryptonote_core/blockchain.cpp | 9 | ||||
-rw-r--r-- | src/cryptonote_core/cryptonote_core.cpp | 44 |
2 files changed, 47 insertions, 6 deletions
diff --git a/src/cryptonote_core/blockchain.cpp b/src/cryptonote_core/blockchain.cpp index acaab374a..535eb1a2d 100644 --- a/src/cryptonote_core/blockchain.cpp +++ b/src/cryptonote_core/blockchain.cpp @@ -2335,10 +2335,7 @@ bool Blockchain::expand_transaction_2(transaction &tx, const crypto::hash &tx_pr CHECK_AND_ASSERT_MES(false, false, "Unsupported rct tx type: " + boost::lexical_cast<std::string>(rv.type)); } - // outPk - CHECK_AND_ASSERT_MES(rv.outPk.size() == tx.vout.size(), false, "Bad outPk size"); - for (size_t n = 0; n < tx.rct_signatures.outPk.size(); ++n) - rv.outPk[n].dest = rct::pk2rct(boost::get<txout_to_key>(tx.vout[n].target).key); + // outPk was already done by handle_incoming_tx return true; } @@ -2643,7 +2640,7 @@ bool Blockchain::check_tx_inputs(transaction& tx, tx_verification_context &tvc, } } - if (!rct::verRctSimple(rv)) + if (!rct::verRctSimple(rv, false)) { LOG_PRINT_L1("Failed to check ringct signatures!"); return false; @@ -2701,7 +2698,7 @@ bool Blockchain::check_tx_inputs(transaction& tx, tx_verification_context &tvc, } } - if (!rct::verRct(rv)) + if (!rct::verRct(rv, false)) { LOG_PRINT_L1("Failed to check ringct signatures!"); return false; diff --git a/src/cryptonote_core/cryptonote_core.cpp b/src/cryptonote_core/cryptonote_core.cpp index 3330fa257..ede7ed748 100644 --- a/src/cryptonote_core/cryptonote_core.cpp +++ b/src/cryptonote_core/cryptonote_core.cpp @@ -49,6 +49,7 @@ using namespace epee; #if defined(BERKELEY_DB) #include "blockchain_db/berkeleydb/db_bdb.h" #endif +#include "ringct/rctSigs.h" DISABLE_VS_WARNINGS(4355) @@ -497,6 +498,22 @@ namespace cryptonote return false; } + // resolve outPk references in rct txes + // outPk aren't the only thing that need resolving for a fully resolved tx, + // but outPk (1) are needed now to check range proof semantics, and + // (2) do not need access to the blockchain to find data + if (tx.version >= 2) + { + rct::rctSig &rv = tx.rct_signatures; + if (rv.outPk.size() != tx.vout.size()) + { + LOG_PRINT_L1("WRONG TRANSACTION BLOB, Bad outPk size in tx " << tx_hash << ", rejected"); + return false; + } + for (size_t n = 0; n < tx.rct_signatures.outPk.size(); ++n) + rv.outPk[n].dest = rct::pk2rct(boost::get<txout_to_key>(tx.vout[n].target).key); + } + if(!check_tx_semantic(tx, keeped_by_block)) { LOG_PRINT_L1("WRONG TRANSACTION BLOB, Failed to check tx " << tx_hash << " semantic, rejected"); @@ -587,6 +604,33 @@ namespace cryptonote return false; } + if (tx.version >= 2) + { + const rct::rctSig &rv = tx.rct_signatures; + switch (rv.type) { + case rct::RCTTypeNull: + // coinbase should not come here, so we reject for all other types + LOG_PRINT_RED_L1("Unexpected Null rctSig type"); + return false; + case rct::RCTTypeSimple: + if (!rct::verRctSimple(rv, true)) + { + LOG_PRINT_RED_L1("rct signature semantics check failed"); + return false; + } + break; + case rct::RCTTypeFull: + if (!rct::verRct(rv, true)) + { + LOG_PRINT_RED_L1("rct signature semantics check failed"); + return false; + } + break; + default: + LOG_PRINT_RED_L1("Unknown rct type: " << rv.type); + return false; + } + } return true; } |