From 6f80bcedfedf030f31147d611dd2dc796227974b Mon Sep 17 00:00:00 2001 From: Tim Ruffing Date: Fri, 18 May 2018 17:40:22 +0200 Subject: [PATCH] Remove redundant checks of size of range proof and surjection proof The checks are redudant because too large range proofs and surjection proofs will be rejected by libsecp256k1. Furthermore, the checks are not precise, and they are anyway not present in other similar code locations. --- src/validation.cpp | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/src/validation.cpp b/src/validation.cpp index cf871f7dc3..93679ea74d 100644 --- a/src/validation.cpp +++ b/src/validation.cpp @@ -905,10 +905,9 @@ bool VerifyAmounts(const CCoinsViewCache& cache, const CTransaction& tx, std::ve { const CConfidentialValue& val = tx.vout[i].nValue; const CConfidentialAsset& asset = tx.vout[i].nAsset; - const CTxOutWitness* ptxoutwit = tx.wit.vtxoutwit.size() <= i? NULL: &tx.wit.vtxoutwit[i]; - if (!asset.IsValid() || (ptxoutwit && ptxoutwit->vchSurjectionproof.size() > 5000)) + if (!asset.IsValid()) return false; - if (!val.IsValid() || (ptxoutwit && ptxoutwit->vchRangeproof.size() > 5000)) + if (!val.IsValid()) return false; if (!tx.vout[i].nNonce.IsValid()) return false; @@ -977,7 +976,7 @@ bool VerifyAmounts(const CCoinsViewCache& cache, const CTransaction& tx, std::ve assert(ret != 0); secp256k1_generator_serialize(secp256k1_ctx_verify_amounts, &vchAssetCommitment[0], &gen); } - if (!ptxoutwit || ptxoutwit->vchRangeproof.size() > 5000) { + if (!ptxoutwit) { return false; } if (QueueCheck(pvChecks, new CRangeCheck(&val, ptxoutwit->vchRangeproof, vchAssetCommitment, tx.vout[i].scriptPubKey, cacheStore)) != SCRIPT_ERR_OK) { @@ -997,7 +996,7 @@ bool VerifyAmounts(const CCoinsViewCache& cache, const CTransaction& tx, std::ve } continue; } - if (!ptxoutwit || ptxoutwit->vchSurjectionproof.size() > 5000) + if (!ptxoutwit) return false; if (secp256k1_generator_parse(secp256k1_ctx_verify_amounts, &gen, &asset.vchCommitment[0]) != 1) return false;