MCPcopy Create free account
hub / github.com/ElementsProject/elements / EvalChecksigTapscript

Function EvalChecksigTapscript

src/script/interpreter.cpp:519–553  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

517}
518
519static 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 *

Callers 1

EvalChecksigFunction · 0.85

Calls 5

update_validation_weightFunction · 0.85
set_errorFunction · 0.70
emptyMethod · 0.45
sizeMethod · 0.45
CheckSchnorrSignatureMethod · 0.45

Tested by

no test coverage detected