| 517 | } |
| 518 | |
| 519 | static bool EvalChecksigTapscript(const valtype& sig, const valtype& pubkey, ScriptExecutionData& execdata, unsigned int flags, const BaseSignatureChecker& checker, SigVersion sigversion, ScriptError* serror, bool& success) |
| 520 | { |
| 521 | assert(sigversion == SigVersion::TAPSCRIPT); |
| 522 | |
| 523 | /* |
| 524 | * The following validation sequence is consensus critical. Please note how -- |
| 525 | * upgradable public key versions precede other rules; |
| 526 | * the script execution fails when using empty signature with invalid public key; |
| 527 | * the script execution fails when using non-empty invalid signature. |
| 528 | */ |
| 529 | success = !sig.empty(); |
| 530 | if (success) { |
| 531 | // Implement the sigops/witnesssize ratio test. |
| 532 | // Passing with an upgradable public key version is also counted. |
| 533 | if (!update_validation_weight(execdata, serror)) return false; // serror is set |
| 534 | } |
| 535 | if (pubkey.size() == 0) { |
| 536 | return set_error(serror, SCRIPT_ERR_PUBKEYTYPE); |
| 537 | } else if (pubkey.size() == 32) { |
| 538 | if (success && !checker.CheckSchnorrSignature(sig, pubkey, sigversion, execdata, serror)) { |
| 539 | return false; // serror is set |
| 540 | } |
| 541 | } else { |
| 542 | /* |
| 543 | * New public key version softforks should be defined before this `else` block. |
| 544 | * Generally, the new code should not do anything but failing the script execution. To avoid |
| 545 | * consensus bugs, it should not modify any existing values (including `success`). |
| 546 | */ |
| 547 | if ((flags & SCRIPT_VERIFY_DISCOURAGE_UPGRADABLE_PUBKEYTYPE) != 0) { |
| 548 | return set_error(serror, SCRIPT_ERR_DISCOURAGE_UPGRADABLE_PUBKEYTYPE); |
| 549 | } |
| 550 | } |
| 551 | |
| 552 | return true; |
| 553 | } |
| 554 | |
| 555 | /** Helper for OP_CHECKSIG, OP_CHECKSIGVERIFY, and (in Tapscript) OP_CHECKSIGADD. |
| 556 | * |
no test coverage detected