fix old bulletproof conditional branches

This commit is contained in:
fuwa 2019-06-06 09:05:39 +08:00 committed by wowario
parent 4265df1460
commit 1fa73fa684
5 changed files with 16 additions and 4 deletions

View File

@ -166,7 +166,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)
{
@ -432,6 +432,12 @@ namespace cryptonote
const rct::rctSig &rv = tx.rct_signatures;
if (!rct::is_rct_bulletproof(rv.type))
return blob_size;
const size_t n_outputs = tx.vout.size();
if (n_outputs <= 2)
return blob_size;
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);
uint64_t bp_clawback = get_transaction_weight_clawback(tx, n_padded_outputs);
CHECK_AND_ASSERT_THROW_MES_L1(bp_clawback <= std::numeric_limits<uint64_t>::max() - blob_size, "Weight overflow");

View File

@ -833,7 +833,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");

View File

@ -1104,7 +1104,7 @@ namespace rct {
tools::threadpool::waiter waiter;
std::deque<bool> 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]); });
@ -1237,7 +1237,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");

View File

@ -250,6 +250,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)

View File

@ -575,6 +575,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; }