aboutsummaryrefslogtreecommitdiff
path: root/src/cryptonote_core
diff options
context:
space:
mode:
authormoneromooo-monero <moneromooo-monero@users.noreply.github.com>2017-01-14 13:29:08 +0000
committermoneromooo-monero <moneromooo-monero@users.noreply.github.com>2017-01-14 21:17:32 +0000
commitba3968f6ce0459f0c0a767e4f54e7cb2c48955d9 (patch)
tree0b851ed406daf1b9dbdcdf73fa72cd5a9628a73f /src/cryptonote_core
parentMerge pull request #1562 (diff)
downloadmonero-ba3968f6ce0459f0c0a767e4f54e7cb2c48955d9.tar.xz
rct: split rct checks between semantics and other
Semantics can be checked early
Diffstat (limited to 'src/cryptonote_core')
-rw-r--r--src/cryptonote_core/blockchain.cpp9
-rw-r--r--src/cryptonote_core/cryptonote_core.cpp44
2 files changed, 47 insertions, 6 deletions
diff --git a/src/cryptonote_core/blockchain.cpp b/src/cryptonote_core/blockchain.cpp
index de3af8e02..00068467e 100644
--- a/src/cryptonote_core/blockchain.cpp
+++ b/src/cryptonote_core/blockchain.cpp
@@ -2333,10 +2333,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;
}
@@ -2641,7 +2638,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;
@@ -2699,7 +2696,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 c63a08ee4..ea27df500 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)
@@ -494,6 +495,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");
@@ -584,6 +601,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;
}