diff options
author | moneromooo-monero <moneromooo-monero@users.noreply.github.com> | 2016-08-08 13:49:42 +0100 |
---|---|---|
committer | moneromooo-monero <moneromooo-monero@users.noreply.github.com> | 2016-08-28 21:30:14 +0100 |
commit | 3ab2ab3e7691dadf91ef39ed477e12f0144b8278 (patch) | |
tree | 4ca65b04438221bc8398f0ae8b5f40b95abfaad2 /src/cryptonote_core | |
parent | rct: avoid the need for the last II element (diff) | |
download | monero-3ab2ab3e7691dadf91ef39ed477e12f0144b8278.tar.xz |
rct: change the simple flag to a type
for future expansion
Diffstat (limited to 'src/cryptonote_core')
-rw-r--r-- | src/cryptonote_core/blockchain.cpp | 12 | ||||
-rw-r--r-- | src/cryptonote_core/cryptonote_basic.h | 11 | ||||
-rw-r--r-- | src/cryptonote_core/cryptonote_boost_serialization.h | 10 |
3 files changed, 22 insertions, 11 deletions
diff --git a/src/cryptonote_core/blockchain.cpp b/src/cryptonote_core/blockchain.cpp index 91a9d5d6f..c81445f1d 100644 --- a/src/cryptonote_core/blockchain.cpp +++ b/src/cryptonote_core/blockchain.cpp @@ -2464,8 +2464,9 @@ bool Blockchain::check_tx_inputs(const transaction& tx, tx_verification_context // from version 2, check ringct signatures // obviously, the original and simple rct APIs use a mixRing that's indexes // in opposite orders, because it'd be too simple otherwise... - if (tx.rct_signatures.simple) + switch (tx.rct_signatures.type) { + case rct::RCTTypeSimple: { rct::ctkeyM reconstructed_mixRing; std::vector<rct::keyV> reconstructed_II; rct::ctkeyV reconstructed_outPk; @@ -2568,9 +2569,9 @@ bool Blockchain::check_tx_inputs(const transaction& tx, tx_verification_context LOG_PRINT_L1("Failed to check ringct signatures!"); return false; } + break; } - else - { + case rct::RCTTypeFull: { rct::ctkeyM reconstructed_mixRing; rct::keyV reconstructed_II; rct::ctkeyV reconstructed_outPk; @@ -2674,6 +2675,11 @@ bool Blockchain::check_tx_inputs(const transaction& tx, tx_verification_context LOG_PRINT_L1("Failed to check ringct signatures!"); return false; } + break; + } + default: + LOG_PRINT_L1("Unsupported rct type: " << tx.rct_signatures.type); + return false; } } return true; diff --git a/src/cryptonote_core/cryptonote_basic.h b/src/cryptonote_core/cryptonote_basic.h index e5a5cc6f5..b68040597 100644 --- a/src/cryptonote_core/cryptonote_basic.h +++ b/src/cryptonote_core/cryptonote_basic.h @@ -231,18 +231,21 @@ namespace cryptonote else { FIELD(rct_signatures) - if (rct_signatures.simple) + switch (rct_signatures.type) { + case rct::RCTTypeSimple: if (rct_signatures.mixRing.size() && rct_signatures.mixRing.size() != vin.size()) return false; - } - else - { + break; + case rct::RCTTypeFull: for (size_t i = 0; i < rct_signatures.mixRing.size(); ++i) { if (rct_signatures.mixRing[i].size() != vin.size()) return false; } + break; + default: + return false; } } END_SERIALIZE() diff --git a/src/cryptonote_core/cryptonote_boost_serialization.h b/src/cryptonote_core/cryptonote_boost_serialization.h index 8a82aa7a7..7a7cf8588 100644 --- a/src/cryptonote_core/cryptonote_boost_serialization.h +++ b/src/cryptonote_core/cryptonote_boost_serialization.h @@ -248,15 +248,17 @@ namespace boost template <class Archive> inline void serialize(Archive &a, rct::rctSig &x, const boost::serialization::version_type ver) { - a & x.simple; + a & x.type; + if (x.type != rct::RCTTypeFull && x.type != rct::RCTTypeSimple) + throw boost::archive::archive_exception(boost::archive::archive_exception::other_exception, "Unsupported rct type"); // a & x.message; message is not serialized, as it can be reconstructed from the tx data a & x.rangeSigs; - if (x.simple) + if (x.type == rct::RCTTypeSimple) a & x.MGs; - else + if (x.type == rct::RCTTypeFull) a & x.MG; // a & x.mixRing; mixRing is not serialized, as it can be reconstructed from the offsets - if (x.simple) + if (x.type == rct::RCTTypeSimple) a & x.pseudoOuts; a & x.ecdhInfo; serializeOutPk(a, x.outPk, ver); |