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

Function EvalTapScriptCheckSigFromStack

src/script/interpreter.cpp:478–517  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

476}
477
478static bool EvalTapScriptCheckSigFromStack(const valtype& sig, const valtype& vchPubKey, ScriptExecutionData& execdata, unsigned int flags, const valtype& msg, SigVersion sigversion, ScriptError* serror, bool& success)
479{
480 // This code follows the behaviour of EvalCheckSigTapscript
481 assert(sigversion == SigVersion::TAPSCRIPT);
482
483 /*
484 * The following validation sequence is consensus critical. Please note how --
485 * upgradable public key versions precede other rules;
486 * the script execution fails when using empty signature with invalid public key;
487 * the script execution fails when using non-empty invalid signature.
488 */
489 success = !sig.empty();
490 if (success) {
491 // Implement the sigops/witnesssize ratio test.
492 // Passing with an upgradable public key version is also counted.
493 if (!update_validation_weight(execdata, serror)) return false; // serror is set
494 }
495 if (vchPubKey.size() == 0) {
496 return set_error(serror, SCRIPT_ERR_PUBKEYTYPE);
497 } else if (vchPubKey.size() == 32) {
498 if (success) {
499 if (sig.size() != 64)
500 return set_error(serror, SCRIPT_ERR_SCHNORR_SIG_SIZE);
501 const XOnlyPubKey pubkey{vchPubKey};
502 if (!pubkey.VerifySchnorr(msg, sig))
503 return set_error(serror, SCRIPT_ERR_SCHNORR_SIG);
504 }
505 } else {
506 /*
507 * New public key version softforks should be defined before this `else` block.
508 * Generally, the new code should not do anything but failing the script execution. To avoid
509 * consensus bugs, it should not modify any existing values (including `success`).
510 */
511 if ((flags & SCRIPT_VERIFY_DISCOURAGE_UPGRADABLE_PUBKEYTYPE) != 0) {
512 return set_error(serror, SCRIPT_ERR_DISCOURAGE_UPGRADABLE_PUBKEYTYPE);
513 }
514 }
515
516 return true;
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{

Callers 1

EvalScriptFunction · 0.85

Calls 5

update_validation_weightFunction · 0.85
VerifySchnorrMethod · 0.80
set_errorFunction · 0.70
emptyMethod · 0.45
sizeMethod · 0.45

Tested by

no test coverage detected