| 20 | } |
| 21 | |
| 22 | static bool CheckProofGeneric(const CBlockHeader& block, const uint32_t max_block_signature_size, const CScript& challenge, const CScript& scriptSig, const CScriptWitness& witness) |
| 23 | { |
| 24 | // Legacy blocks have empty witness, dynafed blocks have empty scriptSig |
| 25 | bool is_dyna = !witness.stack.empty(); |
| 26 | |
| 27 | // Check signature limits for blocks |
| 28 | if (scriptSig.size() > max_block_signature_size) { |
| 29 | assert(!is_dyna); |
| 30 | return false; |
| 31 | } else if (witness.GetSerializedSize() > max_block_signature_size) { |
| 32 | assert(is_dyna); |
| 33 | return false; |
| 34 | } |
| 35 | |
| 36 | // Some anti-DoS flags, though max_block_signature_size caps the possible |
| 37 | // danger in malleation of the block witness data. |
| 38 | unsigned int proof_flags = SCRIPT_VERIFY_P2SH // For cleanstack evaluation under segwit flag |
| 39 | | SCRIPT_VERIFY_STRICTENC // Minimally-sized DER sigs |
| 40 | | SCRIPT_VERIFY_NULLDUMMY // No extra data stuffed into OP_CMS witness |
| 41 | | SCRIPT_VERIFY_CLEANSTACK // No extra pushes leftover in witness |
| 42 | | SCRIPT_VERIFY_MINIMALDATA // Pushes are minimally-sized |
| 43 | | SCRIPT_VERIFY_SIGPUSHONLY // Witness is push-only |
| 44 | | SCRIPT_VERIFY_LOW_S // Stop easiest signature fiddling |
| 45 | | SCRIPT_VERIFY_WITNESS // Witness and to enforce cleanstack |
| 46 | | (is_dyna ? SCRIPT_VERIFY_NONE : SCRIPT_NO_SIGHASH_BYTE); // Non-dynafed blocks do not have sighash byte |
| 47 | return GenericVerifyScript(scriptSig, witness, challenge, proof_flags, block); |
| 48 | } |
| 49 | |
| 50 | bool CheckProof(const CBlockHeader& block, const Consensus::Params& params) |
| 51 | { |
no test coverage detected