diff --git a/src/pow.cpp b/src/pow.cpp index 22dc6b9136..87be47a01a 100644 --- a/src/pow.cpp +++ b/src/pow.cpp @@ -61,7 +61,27 @@ bool CheckProof(const CBlockHeader& block, const Consensus::Params& params) { if (block.GetHash() == params.hashGenesisBlock) return true; - return GenericVerifyScript(block.proof.solution, block.proof.challenge, SCRIPT_VERIFY_P2SH, block); + + // Some important anti-DoS flags. + // Note: Blockhashes do not commit to the proof. + // Therefore we may have a signature be mealleated + // to stay valid, but cause the block to fail + // validation, in this case, block weight. + // In that case, the block will be marked as permanently + // invalid and not processed. + // NOTE: These have only been deemed sufficient for OP_CMS + // ANY OTHER SCRIPT TYPE MAY REQUIRE DIFFERENT FLAGS/CONSIDERATIONS + // TODO: Better design to not have to worry about script specifics + // i.e. exempt block header solution from weight limit + unsigned int proof_flags = SCRIPT_VERIFY_P2SH // Just allows P2SH evaluation + | SCRIPT_VERIFY_STRICTENC // Minimally-sized DER sigs + | SCRIPT_VERIFY_NULLDUMMY // No extra data stuffed into OP_CMS witness + | SCRIPT_VERIFY_CLEANSTACK // No extra pushes leftover in witness + | SCRIPT_VERIFY_MINIMALDATA // Pushes are minimally-sized + | SCRIPT_VERIFY_SIGPUSHONLY // Witness is push-only + | SCRIPT_VERIFY_LOW_S // Stop easiest signature fiddling + | SCRIPT_VERIFY_WITNESS; // Required for cleanstack eval in VerifyScript + return GenericVerifyScript(block.proof.solution, block.proof.challenge, proof_flags, block); } bool MaybeGenerateProof(CBlockHeader *pblock, CWallet *pwallet)