Merge #364: Non-malleable zero-knowlege proofs

6f80bce Remove redundant checks of size of range proof and surjection proof (Tim Ruffing)
7ad4d95 Reject issuances with explicit values but non-empty range proofs (Tim Ruffing)
This commit is contained in:
Gregory Sanders 2018-06-06 09:58:33 -07:00
commit 375c022308
No known key found for this signature in database
GPG key ID: F3F68E2D86A48FDB

View file

@ -719,6 +719,10 @@ static bool VerifyIssuanceAmount(secp256k1_pedersen_commitment& commit, secp256k
if (!MoneyRange(value.GetAmount()) || value.GetAmount() == 0) {
return false;
}
if (!vchRangeproof.empty()) {
return false;
}
ret = secp256k1_pedersen_commit(secp256k1_ctx_verify_amounts, &commit, explBlinds, value.GetAmount(), &gen);
// The explBlinds are all 0, and the amount is not 0. So secp256k1_pedersen_commit does not fail.
@ -901,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;
@ -973,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) {
@ -993,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;