From f3d415f7a09f4731ab385f237fc8ba0ea40fa6fd Mon Sep 17 00:00:00 2001 From: fuwa Date: Thu, 6 Jun 2019 09:05:39 +0800 Subject: [PATCH] fix old bulletproof conditional branches --- src/cryptonote_basic/cryptonote_format_utils.cpp | 4 ++-- src/cryptonote_core/cryptonote_core.cpp | 2 +- src/ringct/rctSigs.cpp | 4 ++-- src/ringct/rctTypes.cpp | 5 +++++ src/ringct/rctTypes.h | 1 + 5 files changed, 11 insertions(+), 5 deletions(-) diff --git a/src/cryptonote_basic/cryptonote_format_utils.cpp b/src/cryptonote_basic/cryptonote_format_utils.cpp index fca10dfca..fc33a7fb8 100644 --- a/src/cryptonote_basic/cryptonote_format_utils.cpp +++ b/src/cryptonote_basic/cryptonote_format_utils.cpp @@ -146,7 +146,7 @@ namespace cryptonote if (!base_only) { const bool bulletproof = rct::is_rct_bulletproof(rv.type); - if (bulletproof && rv.type == rct::RCTTypeBulletproof) + if (rct::is_rct_new_bulletproof(rv.type)) { if (rv.p.bulletproofs.size() != 1) { @@ -415,7 +415,7 @@ namespace cryptonote const size_t n_outputs = tx.vout.size(); if (n_outputs <= 2) return blob_size; - if (rv.type != rct::RCTTypeBulletproof) + if (rct::is_rct_old_bulletproof(rv.type)) return blob_size; const uint64_t bp_base = 368; const size_t n_padded_outputs = rct::n_bulletproof_max_amounts(rv.p.bulletproofs); diff --git a/src/cryptonote_core/cryptonote_core.cpp b/src/cryptonote_core/cryptonote_core.cpp index c17899c91..3175ad89c 100644 --- a/src/cryptonote_core/cryptonote_core.cpp +++ b/src/cryptonote_core/cryptonote_core.cpp @@ -808,7 +808,7 @@ namespace cryptonote if (tx.version >= 2) { rct::rctSig &rv = tx.rct_signatures; - if (rv.type != rct::RCTTypeBulletproof){ + if (!rct::is_rct_new_bulletproof(rv.type)){ if (rv.outPk.size() != tx.vout.size()) { LOG_PRINT_L1("WRONG TRANSACTION BLOB, Bad outPk size in tx " << tx_hash << ", rejected"); diff --git a/src/ringct/rctSigs.cpp b/src/ringct/rctSigs.cpp index 6b50e2a67..1f4cf3082 100644 --- a/src/ringct/rctSigs.cpp +++ b/src/ringct/rctSigs.cpp @@ -1099,7 +1099,7 @@ namespace rct { tools::threadpool::waiter waiter; std::deque results(bulletproof ? rv.p.bulletproofs.size() : rv.outPk.size(), false); DP("range proofs verified?"); - if (bulletproof && rv.type == RCTTypeBulletproof) + if (rct::is_rct_new_bulletproof(rv.type)) { for (size_t i = 0; i < rv.p.bulletproofs.size(); i++) tpool.submit(&waiter, [&, i] { results[i] = verBulletproof(rv.p.bulletproofs[i]); }); @@ -1232,7 +1232,7 @@ namespace rct { for (const rctSig *rvp: rvv) { const rctSig &rv = *rvp; - if (rv.type != RCTTypeBulletproof){ + if (!rct::is_rct_new_bulletproof(rv.type)){ if (!proofs.empty() && !verBulletproof_old(proofs)) { LOG_PRINT_L1("Aggregate range proof verified failed"); diff --git a/src/ringct/rctTypes.cpp b/src/ringct/rctTypes.cpp index 74bf7ff6b..be4ebec92 100644 --- a/src/ringct/rctTypes.cpp +++ b/src/ringct/rctTypes.cpp @@ -251,6 +251,11 @@ namespace rct { } } + bool is_rct_new_bulletproof(int type) + { + return is_rct_bulletproof(type) && !is_rct_old_bulletproof(type); + } + bool is_rct_borromean(int type) { switch (type) diff --git a/src/ringct/rctTypes.h b/src/ringct/rctTypes.h index 399f19f36..97ffe3f96 100644 --- a/src/ringct/rctTypes.h +++ b/src/ringct/rctTypes.h @@ -574,6 +574,7 @@ namespace rct { bool is_rct_simple(int type); bool is_rct_bulletproof(int type); bool is_rct_old_bulletproof(int type); + bool is_rct_new_bulletproof(int type); bool is_rct_borromean(int type); static inline const rct::key &pk2rct(const crypto::public_key &pk) { return (const rct::key&)pk; }