diff --git a/src/pubkey.cpp b/src/pubkey.cpp index 11e1b4abb51afd..e1781aea63d66d 100644 --- a/src/pubkey.cpp +++ b/src/pubkey.cpp @@ -217,12 +217,12 @@ bool XOnlyPubKey::IsFullyValid() const return secp256k1_xonly_pubkey_parse(secp256k1_context_static, &pubkey, m_keydata.data()); } -bool XOnlyPubKey::VerifySchnorr(const uint256& msg, Span sigbytes) const +bool XOnlyPubKey::VerifySchnorr(const Span msg, Span sigbytes) const { assert(sigbytes.size() == 64); secp256k1_xonly_pubkey pubkey; if (!secp256k1_xonly_pubkey_parse(secp256k1_context_static, &pubkey, m_keydata.data())) return false; - return secp256k1_schnorrsig_verify(secp256k1_context_static, sigbytes.data(), msg.begin(), 32, &pubkey); + return secp256k1_schnorrsig_verify(secp256k1_context_static, sigbytes.data(), msg.data(), msg.size(), &pubkey); } static const HashWriter HASHER_TAPTWEAK{TaggedHash("TapTweak")}; diff --git a/src/pubkey.h b/src/pubkey.h index 2b655c3f73b572..37240dff37368a 100644 --- a/src/pubkey.h +++ b/src/pubkey.h @@ -258,7 +258,7 @@ class XOnlyPubKey * * sigbytes must be exactly 64 bytes. */ - bool VerifySchnorr(const uint256& msg, Span sigbytes) const; + bool VerifySchnorr(const Span msg, Span sigbytes) const; /** Compute the Taproot tweak as specified in BIP341, with *this as internal * key: diff --git a/src/script/interpreter.cpp b/src/script/interpreter.cpp index 8423459fb4af3c..6f00c46d107acf 100644 --- a/src/script/interpreter.cpp +++ b/src/script/interpreter.cpp @@ -343,6 +343,67 @@ static bool EvalChecksigPreTapscript(const valtype& vchSig, const valtype& vchPu return true; } +static bool EvalChecksigFromStack(const valtype& sig, const valtype& msg, const valtype& pubkey_in, ScriptExecutionData& execdata, unsigned int flags, SigVersion sigversion, ScriptError* serror, bool& success) +{ + assert(sigversion == SigVersion::BASE || sigversion == SigVersion::WITNESS_V0 || sigversion == SigVersion::TAPSCRIPT); + /* + * The following validation sequence is consensus critical. Please note how -- + * upgradable public key versions precede other rules; + * the script execution fails when using empty signature with invalid public key; + * the script execution fails when using non-empty invalid signature. + */ + success = !sig.empty(); + if (success && sigversion == SigVersion::TAPSCRIPT) { + // Implement the sigops/witnesssize ratio test. + // Passing with an upgradable public key version is also counted. + assert(execdata.m_validation_weight_left_init); + execdata.m_validation_weight_left -= VALIDATION_WEIGHT_PER_SIGOP_PASSED; + if (execdata.m_validation_weight_left < 0) { + return set_error(serror, SCRIPT_ERR_TAPSCRIPT_VALIDATION_WEIGHT); + } + } + if (pubkey_in.size() == 0) { + return set_error(serror, SCRIPT_ERR_PUBKEYTYPE); + } else if (pubkey_in.size() == 32) { + if (!success) return true; + if (sig.size() != 64) return set_error(serror, SCRIPT_ERR_SCHNORR_SIG_SIZE); + + XOnlyPubKey pubkey{pubkey_in}; + + if (!pubkey.VerifySchnorr(msg, sig)) return set_error(serror, SCRIPT_ERR_SCHNORR_SIG); + } else if (pubkey_in.size() == 33 && (pubkey_in[0] == 0x02 || pubkey_in[0] == 0x03) && (sigversion == SigVersion::BASE || sigversion == SigVersion::WITNESS_V0)) { + // Pubkeys of length 33 are only constrained in legacy and segwitv0. In these script types only those beginning + // with 0x02 or 0x03 are constrained. Others are unknown pubkey types. + if (!success) return true; + + // Add sighash flag to pass format validation + valtype vchSig{sig.begin(), sig.begin() + sig.size()}; + vchSig.emplace_back(SIGHASH_ALL); + if (!CheckSignatureEncoding(vchSig, flags | SCRIPT_VERIFY_LOW_S, serror)) { + // serror is set + return false; + } + + if (msg.size() != 32) return set_error(serror, SCRIPT_ERR_INVALID_DATA_LENGTH); + + CPubKey pubkey(pubkey_in); + if (!pubkey.IsValid()) return set_error(serror, SCRIPT_ERR_PUBKEYTYPE); + + if (!pubkey.Verify(uint256(msg), sig)) return set_error(serror, SCRIPT_ERR_SIG_NULLFAIL); + } else { + /* + * New public key version softforks should be defined before this `else` block. + * Generally, the new code should not do anything but failing the script execution. To avoid + * consensus bugs, it should not modify any existing values (including `success`). + */ + if ((flags & SCRIPT_VERIFY_DISCOURAGE_UPGRADABLE_PUBKEYTYPE) != 0) { + return set_error(serror, SCRIPT_ERR_DISCOURAGE_UPGRADABLE_PUBKEYTYPE); + } + } + + return true; +} + static bool EvalChecksigTapscript(const valtype& sig, const valtype& pubkey, ScriptExecutionData& execdata, unsigned int flags, const BaseSignatureChecker& checker, SigVersion sigversion, ScriptError* serror, bool& success) { assert(sigversion == SigVersion::TAPSCRIPT); @@ -626,7 +687,7 @@ bool EvalScript(std::vector >& stack, const CScript& } break; - case OP_NOP1: case OP_NOP5: + case OP_NOP1: case OP_NOP6: case OP_NOP7: case OP_NOP8: case OP_NOP9: case OP_NOP10: { if (flags & SCRIPT_VERIFY_DISCOURAGE_UPGRADABLE_NOPS) @@ -1259,6 +1320,44 @@ bool EvalScript(std::vector >& stack, const CScript& break; } + case OP_CHECKSIGFROMSTACK: + case OP_CHECKSIGFROMSTACKVERIFY: { + // if flags not enabled; treat OP_CHECKSIGFROMSTACKVERIFY as a NOP5 + if (opcode == OP_CHECKSIGFROMSTACKVERIFY && !(flags & SCRIPT_VERIFY_LNHANCE)) { + break; + } + // OP_CHECKSIGFROMSTACK is only available in Tapscript + if (opcode == OP_CHECKSIGFROMSTACK && (sigversion == SigVersion::BASE || sigversion == SigVersion::WITNESS_V0)) { + return set_error(serror, SCRIPT_ERR_BAD_OPCODE); + } + if (flags & SCRIPT_VERIFY_DISCOURAGE_LNHANCE) { + if (opcode == OP_CHECKSIGFROMSTACKVERIFY) return set_error(serror, SCRIPT_ERR_DISCOURAGE_UPGRADABLE_NOPS); + return set_error(serror, SCRIPT_ERR_DISCOURAGE_OP_SUCCESS); + } + + // sig message pubkey + if (stack.size() < 3) + return set_error(serror, SCRIPT_ERR_INVALID_STACK_OPERATION); + + const valtype& vchSigIn = stacktop(-3); + const valtype& vchMsg = stacktop(-2); + const valtype& vchPubKey = stacktop(-1); + + bool fSuccess = true; + if (!EvalChecksigFromStack(vchSigIn, vchMsg, vchPubKey, execdata, flags, sigversion, serror, fSuccess)) return false; + + if (opcode == OP_CHECKSIGFROMSTACKVERIFY) { + if (!fSuccess) return set_error(serror, SCRIPT_ERR_CHECKSIGVERIFY); + break; + } + + popstack(stack); + popstack(stack); + popstack(stack); + stack.push_back(fSuccess ? vchTrue : vchFalse); + break; + } + default: return set_error(serror, SCRIPT_ERR_BAD_OPCODE); } @@ -1933,7 +2032,7 @@ static bool ExecuteWitnessScript(const Span& stack_span, const CS // Note how this condition would not be reached if an unknown OP_SUCCESSx was found return set_error(serror, SCRIPT_ERR_BAD_OPCODE); } - if ((flags & SCRIPT_VERIFY_LNHANCE) && opcode == OP_INTERNALKEY) { + if ((flags & SCRIPT_VERIFY_LNHANCE) && (opcode == OP_CHECKSIGFROMSTACK || opcode == OP_INTERNALKEY)) { continue; } // New opcodes will be listed here. May use a different sigversion to modify existing opcodes. diff --git a/src/script/script.cpp b/src/script/script.cpp index bd1f66fab0dc28..bb3cfb91885828 100644 --- a/src/script/script.cpp +++ b/src/script/script.cpp @@ -136,7 +136,7 @@ std::string GetOpName(opcodetype opcode) case OP_CHECKLOCKTIMEVERIFY : return "OP_CHECKLOCKTIMEVERIFY"; case OP_CHECKSEQUENCEVERIFY : return "OP_CHECKSEQUENCEVERIFY"; case OP_CHECKTEMPLATEVERIFY : return "OP_CHECKTEMPLATEVERIFY"; - case OP_NOP5 : return "OP_NOP5"; + case OP_CHECKSIGFROMSTACKVERIFY: return "OP_CHECKSIGFROMSTACKVERIFY"; case OP_NOP6 : return "OP_NOP6"; case OP_NOP7 : return "OP_NOP7"; case OP_NOP8 : return "OP_NOP8"; @@ -146,7 +146,9 @@ std::string GetOpName(opcodetype opcode) // Opcode added by BIP 342 (Tapscript) case OP_CHECKSIGADD : return "OP_CHECKSIGADD"; + // Tapscript expansion case OP_INTERNALKEY : return "OP_INTERNALKEY"; + case OP_CHECKSIGFROMSTACK : return "OP_CHECKSIGFROMSTACK"; case OP_INVALIDOPCODE : return "OP_INVALIDOPCODE"; @@ -165,7 +167,8 @@ unsigned int CScript::GetSigOpCount(bool fAccurate) const opcodetype opcode; if (!GetOp(pc, opcode)) break; - if (opcode == OP_CHECKSIG || opcode == OP_CHECKSIGVERIFY) + if (opcode == OP_CHECKSIG || opcode == OP_CHECKSIGVERIFY || + opcode == OP_CHECKSIGFROMSTACK || opcode == OP_CHECKSIGFROMSTACKVERIFY) n++; else if (opcode == OP_CHECKMULTISIG || opcode == OP_CHECKMULTISIGVERIFY) { diff --git a/src/script/script.h b/src/script/script.h index b65189c0e6cc3d..bc420444fa8776 100644 --- a/src/script/script.h +++ b/src/script/script.h @@ -198,7 +198,8 @@ enum opcodetype OP_NOP3 = OP_CHECKSEQUENCEVERIFY, OP_CHECKTEMPLATEVERIFY = 0xb3, OP_NOP4 = OP_CHECKTEMPLATEVERIFY, - OP_NOP5 = 0xb4, + OP_CHECKSIGFROMSTACKVERIFY = 0xb4, + OP_NOP5 = OP_CHECKSIGFROMSTACKVERIFY, OP_NOP6 = 0xb5, OP_NOP7 = 0xb6, OP_NOP8 = 0xb7, @@ -207,7 +208,10 @@ enum opcodetype // Opcode added by BIP 342 (Tapscript) OP_CHECKSIGADD = 0xba, + + // Tapscript expansion OP_INTERNALKEY = 0xbb, + OP_CHECKSIGFROMSTACK = 0xbc, OP_INVALIDOPCODE = 0xff, }; diff --git a/src/script/script_error.cpp b/src/script/script_error.cpp index f33994d0b3b437..57004667b3387d 100644 --- a/src/script/script_error.cpp +++ b/src/script/script_error.cpp @@ -51,6 +51,8 @@ std::string ScriptErrorString(const ScriptError serror) return "OP_RETURN was encountered"; case SCRIPT_ERR_UNBALANCED_CONDITIONAL: return "Invalid OP_IF construction"; + case SCRIPT_ERR_INVALID_DATA_LENGTH: + return "Invalid data length for operation"; case SCRIPT_ERR_NEGATIVE_LOCKTIME: return "Negative locktime"; case SCRIPT_ERR_UNSATISFIED_LOCKTIME: diff --git a/src/script/script_error.h b/src/script/script_error.h index 74d7041533d24e..ba36e0060a2335 100644 --- a/src/script/script_error.h +++ b/src/script/script_error.h @@ -37,6 +37,7 @@ typedef enum ScriptError_t SCRIPT_ERR_INVALID_STACK_OPERATION, SCRIPT_ERR_INVALID_ALTSTACK_OPERATION, SCRIPT_ERR_UNBALANCED_CONDITIONAL, + SCRIPT_ERR_INVALID_DATA_LENGTH, /* CHECKLOCKTIMEVERIFY and CHECKSEQUENCEVERIFY */ SCRIPT_ERR_NEGATIVE_LOCKTIME, diff --git a/src/test/data/script_tests.json b/src/test/data/script_tests.json index b4b3724d713cee..5838300a06996e 100644 --- a/src/test/data/script_tests.json +++ b/src/test/data/script_tests.json @@ -244,8 +244,8 @@ ["'abcdefghijklmnopqrstuvwxyz'", "HASH256 0x4c 0x20 0xca139bc10c2f660da42666f72e89a225936fc60f193c161124a672050c434671 EQUAL", "P2SH,STRICTENC", "OK"], -["1","NOP1 CHECKLOCKTIMEVERIFY CHECKSEQUENCEVERIFY CHECKTEMPLATEVERIFY NOP5 NOP6 NOP7 NOP8 NOP9 NOP10 1 EQUAL", "P2SH,STRICTENC", "OK"], -["'NOP_1_to_10' NOP1 CHECKLOCKTIMEVERIFY CHECKSEQUENCEVERIFY CHECKTEMPLATEVERIFY NOP5 NOP6 NOP7 NOP8 NOP9 NOP10","'NOP_1_to_10' EQUAL", "P2SH,STRICTENC", "OK"], +["1","NOP1 CHECKLOCKTIMEVERIFY CHECKSEQUENCEVERIFY CHECKTEMPLATEVERIFY CHECKSIGFROMSTACKVERIFY NOP6 NOP7 NOP8 NOP9 NOP10 1 EQUAL", "P2SH,STRICTENC", "OK"], +["'NOP_1_to_10' NOP1 CHECKLOCKTIMEVERIFY CHECKSEQUENCEVERIFY CHECKTEMPLATEVERIFY CHECKSIGFROMSTACKVERIFY NOP6 NOP7 NOP8 NOP9 NOP10","'NOP_1_to_10' EQUAL", "P2SH,STRICTENC", "OK"], ["1", "NOP", "P2SH,STRICTENC,DISCOURAGE_UPGRADABLE_NOPS", "OK", "Discourage NOPx flag allows OP_NOP"], @@ -457,7 +457,7 @@ ["NOP", "CHECKLOCKTIMEVERIFY 1", "P2SH,STRICTENC", "OK"], ["NOP", "CHECKSEQUENCEVERIFY 1", "P2SH,STRICTENC", "OK"], ["NOP", "CHECKTEMPLATEVERIFY 1", "P2SH,STRICTENC", "OK"], -["NOP", "NOP5 1", "P2SH,STRICTENC", "OK"], +["NOP", "CHECKSIGFROMSTACKVERIFY 1", "P2SH,STRICTENC", "OK"], ["NOP", "NOP6 1", "P2SH,STRICTENC", "OK"], ["NOP", "NOP7 1", "P2SH,STRICTENC", "OK"], ["NOP", "NOP8 1", "P2SH,STRICTENC", "OK"], @@ -870,12 +870,11 @@ ["2 2 LSHIFT", "8 EQUAL", "P2SH,STRICTENC", "DISABLED_OPCODE", "disabled"], ["2 1 RSHIFT", "1 EQUAL", "P2SH,STRICTENC", "DISABLED_OPCODE", "disabled"], -["1", "NOP1 CHECKLOCKTIMEVERIFY CHECKSEQUENCEVERIFY CHECKTEMPLATEVERIFY NOP5 NOP6 NOP7 NOP8 NOP9 NOP10 2 EQUAL", "P2SH,STRICTENC", "EVAL_FALSE"], -["'NOP_1_to_10' NOP1 CHECKLOCKTIMEVERIFY CHECKSEQUENCEVERIFY CHECKTEMPLATEVERIFY NOP5 NOP6 NOP7 NOP8 NOP9 NOP10","'NOP_1_to_11' EQUAL", "P2SH,STRICTENC", "EVAL_FALSE"], +["1", "NOP1 CHECKLOCKTIMEVERIFY CHECKSEQUENCEVERIFY CHECKTEMPLATEVERIFY CHECKSIGFROMSTACKVERIFY NOP6 NOP7 NOP8 NOP9 NOP10 2 EQUAL", "P2SH,STRICTENC", "EVAL_FALSE"], +["'NOP_1_to_10' NOP1 CHECKLOCKTIMEVERIFY CHECKSEQUENCEVERIFY CHECKTEMPLATEVERIFY CHECKSIGFROMSTACKVERIFY NOP6 NOP7 NOP8 NOP9 NOP10","'NOP_1_to_11' EQUAL", "P2SH,STRICTENC", "EVAL_FALSE"], ["Ensure 100% coverage of discouraged NOPS"], ["1", "NOP1", "P2SH,DISCOURAGE_UPGRADABLE_NOPS", "DISCOURAGE_UPGRADABLE_NOPS"], -["1", "NOP5", "P2SH,DISCOURAGE_UPGRADABLE_NOPS", "DISCOURAGE_UPGRADABLE_NOPS"], ["1", "NOP6", "P2SH,DISCOURAGE_UPGRADABLE_NOPS", "DISCOURAGE_UPGRADABLE_NOPS"], ["1", "NOP7", "P2SH,DISCOURAGE_UPGRADABLE_NOPS", "DISCOURAGE_UPGRADABLE_NOPS"], ["1", "NOP8", "P2SH,DISCOURAGE_UPGRADABLE_NOPS", "DISCOURAGE_UPGRADABLE_NOPS"], diff --git a/src/test/data/tx_invalid.json b/src/test/data/tx_invalid.json index bd8366d2d93396..0e5066966e1e9d 100644 --- a/src/test/data/tx_invalid.json +++ b/src/test/data/tx_invalid.json @@ -488,5 +488,21 @@ "020000000297e5046ea9335a2ce209f677f0d0a303cd266461ff42316f73c53360a92f52a2000000000151000000000b4c12e6dbe974dadd18ca139e6bce183817ac609f73213aa8aaeae5f123d6b6000000000151000000000ae80300000000000017a9143f163a8747557345ce2e6fe00c1894f2f281795e87d00700000000000017a9144cf13dfda93a7413b7e646611735656e5457657087b80b00000000000017a914868998b49df649c37a88d48c9d4a5b37290e507287a00f00000000000017a914034f9914a77571a6396482e9881745c92c3037c687881300000000000017a914a8238003e1732e2baf4334a8546d72be99af9bae87701700000000000017a91491dbac5d67d5941115a03fc7eaec09f31a5b4dfc87581b00000000000017a914e0c0f19fec3b2993b9c116c798b5429d4515596687401f00000000000017a914d6b40d98d94530f1a1eb57614680813c81a95ccd87282300000000000017a914fb0bfb072bb79611a4323981828108a3cf54b0a687102700000000000017a9149e2d11f06ba667e981b802af10be8dabd08eafff8700000000", "LNHANCE"], +["Test OP_CHECKSIGFROMSTACK, fails with sig for wrong data"], +[[["a2522fa96033c5736f3142ff616426cd03a3d0f077f609e22c5a33a96e04e597", + 0, + "1 0x20 0x2fb0c361166d694c1fa1a9955518170c89d51d5debad1e53a2478dd2207d0e0a", + 155000]], +"0200000000010197e5046ea9335a2ce209f677f0d0a303cd266461ff42316f73c53360a92f52a20000000000ffffffff01f0490200000000002251202ca3bc76489a54904ad2507005789afc1e6b362b451be89f69de39ddf9ba8abf034079001cd9669b1a54c67ee61dc2ef980a1d5feeb4c677978b05c9de26d7533f9f9ac4f526c7fdfd65351f0a4756d05d79a91639290fea8669d2bebf86ff351e0d4320feadbeefdeadbeefdeadbeefdeadbeefdeadbeefdeadbeefdeadbeefdeadbeef20f4b16c96ad395b47dd9079faf553a0d9e8ce1da8729da811b8a93954a756b883bc21c050929b74c1a04954b78b4b6035e97a5e078a5a0f28ec96d547bfee9ace803ac000000000", + "P2SH,WITNESS,TAPROOT,LNHANCE"], +["Test OP_CHECKSIGFROMSTACKVERIFY, fails immediately with changed sig"], + [[["a2522fa96033c5736f3142ff616426cd03a3d0f077f609e22c5a33a96e04e597", + 0, + "1 0x20 0x53af700e9733abe9f4b8518fcec7a1814f723b78329da6a46d14b5bb9a106baf", + 155000]], +"0200000000010197e5046ea9335a2ce209f677f0d0a303cd266461ff42316f73c53360a92f52a20000000000ffffffff01f0490200000000002251202ca3bc76489a54904ad2507005789afc1e6b362b451be89f69de39ddf9ba8abf0340f7d74789c5aff9168c2f174d14535a99755aeada9efe1ad130489cdb32d922192aac7564831dabd0e5be832ec102b9a43db2a1f1020660648869ebde3e9f69484520deadbeefdeadbeefdeadbeefdeadbeefdeadbeefdeadbeefdeadbeefdeadbeef205dba240412eeea155985ac48a7dc1250e5d8d1bbe0368dbf137ab1173f801764bc008721c150929b74c1a04954b78b4b6035e97a5e078a5a0f28ec96d547bfee9ace803ac000000000", + "P2SH,WITNESS,TAPROOT,LNHANCE"], + + ["Make diffs cleaner by leaving a comment here without comma at the end"] ] diff --git a/src/test/data/tx_valid.json b/src/test/data/tx_valid.json index f931a7613097ab..b75b10dcc423d1 100644 --- a/src/test/data/tx_valid.json +++ b/src/test/data/tx_valid.json @@ -676,5 +676,76 @@ "02000000000101d58631133c4d4f6188abbd0fa0a7aa64bfde05ce4297e3349b38599ceebaf2e20000000000ffffffff01f0490200000000002251202ca3bc76489a54904ad2507005789afc1e6b362b451be89f69de39ddf9ba8abf0223bb2050929b74c1a04954b78b4b6035e97a5e078a5a0f28ec96d547bfee9ace803ac08721c150929b74c1a04954b78b4b6035e97a5e078a5a0f28ec96d547bfee9ace803ac000000000", "DISCOURAGE_LNHANCE"], + ["Test OP_CHECKSIGFROMSTACK"], + [[["e2f2baee9c59389b34e39742ce05debf64aaa7a00fbdab88614f4d3c133186d5", + 0, + "1 0x20 0x87e1bbe335f839e858dce8a383509f3904c102e100688c73abcbfe92eb1b9cff", + 155000]], +"02000000000101d58631133c4d4f6188abbd0fa0a7aa64bfde05ce4297e3349b38599ceebaf2e20000000000ffffffff01f0490200000000002251202ca3bc76489a54904ad2507005789afc1e6b362b451be89f69de39ddf9ba8abf0340dcc19ae125ab4ca27c0d78e0bfec86238dd85e508d6ab4c566b825213f955acd38b98847d6804d08690c734333d6f2dbd40f96b61ecc9a5e2a20bcfa7c67a81f4320deadbeefdeadbeefdeadbeefdeadbeefdeadbeefdeadbeefdeadbeefdeadbeef20f37bc3b26e03286fd90c64f15449b99dff2d9cd7eb8e0eddc214dd00e4141b88bc21c050929b74c1a04954b78b4b6035e97a5e078a5a0f28ec96d547bfee9ace803ac000000000", + "DISCOURAGE_LNHANCE"], + ["Test OP_CHECKSIGFROMSTACK succeeds with unknown key type"], + [[["e2f2baee9c59389b34e39742ce05debf64aaa7a00fbdab88614f4d3c133186d5", + 0, + "1 0x20 0xfff536966916a9b63374b973851d835261f7075a1af23646276b8174afd06866", + 155000]], +"02000000000101d58631133c4d4f6188abbd0fa0a7aa64bfde05ce4297e3349b38599ceebaf2e20000000000ffffffff01f0490200000000002251202ca3bc76489a54904ad2507005789afc1e6b362b451be89f69de39ddf9ba8abf034730450221009b156de9b23fd95c9b8334edd071d99f05406d9745dde45c9f864feed72e7d8f022022daae11b32e2d0ae9c6baff95c15fc9974ffcd9b2dcc7153d8e688d11f3d72c4420deadbeefdeadbeefdeadbeefdeadbeefdeadbeefdeadbeefdeadbeefdeadbeef2102310509d8304e4991d30ae9f69cd77b34390828f98e63bc82fb8e4cd919a7cc11bc21c050929b74c1a04954b78b4b6035e97a5e078a5a0f28ec96d547bfee9ace803ac000000000", + "DISCOURAGE_LNHANCE,DISCOURAGE_UPGRADABLE_PUBKEYTYPE"], + ["Test OP_CHECKSIGFROMSTACK yields 0 for 0-sig"], + [[["e2f2baee9c59389b34e39742ce05debf64aaa7a00fbdab88614f4d3c133186d5", + 0, + "1 0x20 0x042c6b34ee658e55f9673e5e6b17485ee7b59181ef4c71279d87f60576771235", + 155000]], +"02000000000101d58631133c4d4f6188abbd0fa0a7aa64bfde05ce4297e3349b38599ceebaf2e20000000000ffffffff01f0490200000000002251202ca3bc76489a54904ad2507005789afc1e6b362b451be89f69de39ddf9ba8abf03004520deadbeefdeadbeefdeadbeefdeadbeefdeadbeefdeadbeefdeadbeefdeadbeef2044b54b04016f2b60db1aeb3a43d591677a7a8458338381446d1d37068e34cb22bc008721c050929b74c1a04954b78b4b6035e97a5e078a5a0f28ec96d547bfee9ace803ac000000000", + "DISCOURAGE_LNHANCE"], + ["Test OP_CHECKSIGFROMSTACK, shorter message"], + [[["e2f2baee9c59389b34e39742ce05debf64aaa7a00fbdab88614f4d3c133186d5", + 0, + "1 0x20 0x153a9792b2a5e3df88662b8e0dfbd6d824933cc5f7febf966061b8264282c069", + 155000]], +"02000000000101d58631133c4d4f6188abbd0fa0a7aa64bfde05ce4297e3349b38599ceebaf2e20000000000ffffffff01f0490200000000002251202ca3bc76489a54904ad2507005789afc1e6b362b451be89f69de39ddf9ba8abf034095071a2e3dcf050eea4b137a50eafdc8ea4fe222320f0f40f29ad7cf4267a645a00dd78cd9a59553eedcf63f54be5f116a74dd323376dd751817d74f7ba970972704617364662060c02b73c0d38fb2e4cf48ec1ba0a4c7e83f26aac42219d3c5b86032f981b9ecbc21c150929b74c1a04954b78b4b6035e97a5e078a5a0f28ec96d547bfee9ace803ac000000000", + "DISCOURAGE_LNHANCE"], + ["Test Taproot OP_CHECKSIGFROMSTACKVERIFY"], + [[["e2f2baee9c59389b34e39742ce05debf64aaa7a00fbdab88614f4d3c133186d5", + 0, + "1 0x20 0x14827b13c0d4bfd1d831e2091bf249e4851459a9e170955cf9bede89ca408232", + 155000]], +"02000000000101d58631133c4d4f6188abbd0fa0a7aa64bfde05ce4297e3349b38599ceebaf2e20000000000ffffffff01f0490200000000002251202ca3bc76489a54904ad2507005789afc1e6b362b451be89f69de39ddf9ba8abf034069a63c5cd7e96228e3b930a40e1a07cb3358aeae1b15fdca5c0a66330c285f2ebcfbcbdd3944f99f355752b7aaa8efe46c41a9515d8eeae0251bdf4a39e9c39f4420deadbeefdeadbeefdeadbeefdeadbeefdeadbeefdeadbeefdeadbeefdeadbeef206e4953e81af479de5f3caa0de70e9a5c75972306a287935f6fbc41a3143aca5fb46d21c150929b74c1a04954b78b4b6035e97a5e078a5a0f28ec96d547bfee9ace803ac000000000", + "DISCOURAGE_LNHANCE"], + ["Test P2WSH OP_CHECKSIGFROMSTACKVERIFY"], + [[["e2f2baee9c59389b34e39742ce05debf64aaa7a00fbdab88614f4d3c133186d5", + 0, + "0 0x20 0x95ca0ad3775123ed942b8204e796b1df42d9dc186739d261f85a9413e9c52230", + 155000]], +"02000000000101d58631133c4d4f6188abbd0fa0a7aa64bfde05ce4297e3349b38599ceebaf2e20000000000ffffffff01f0490200000000002251202ca3bc76489a54904ad2507005789afc1e6b362b451be89f69de39ddf9ba8abf0246304402207aeb86b78057b605317d521d25b78c7cfa15bd3207b9a1734dca48ffc161b1c0022035d6da7225779eaad0ff1f46b1c07739a9cb7918349887eb9d1cff25403403644520deadbeefdeadbeefdeadbeefdeadbeefdeadbeefdeadbeefdeadbeefdeadbeef2102050ebdfd72f62a84b8dadac2463093fd9adcf287d5b2f9398d974e013e63c9b2b46d00000000", + "DISCOURAGE_LNHANCE"], + ["Test P2WSH OP_CHECKSIGFROMSTACKVERIFY BIP340"], + [[["e2f2baee9c59389b34e39742ce05debf64aaa7a00fbdab88614f4d3c133186d5", + 0, + "0 0x20 0x03bb5be436bd8620d2ba8b51e4aa07d55c610d204cbc6f39dd5f7e67a56e8a30", + 155000]], +"02000000000101d58631133c4d4f6188abbd0fa0a7aa64bfde05ce4297e3349b38599ceebaf2e20000000000ffffffff01f0490200000000002251202ca3bc76489a54904ad2507005789afc1e6b362b451be89f69de39ddf9ba8abf024067d6def5c22b4184f8a2b4d882bcdd39a494c68f2605d8580a21d4c77052d89b48b4394b9d48d4e04f578a1ed030826670ac9168ec8976b3dd806328e28f41994420deadbeefdeadbeefdeadbeefdeadbeefdeadbeefdeadbeefdeadbeefdeadbeef203641b0f037b985cd83add9488822ecb8e6c547cd3f2e5ed71e836b53c0e82123b46d00000000", + "DISCOURAGE_LNHANCE"], + ["Test P2WSH OP_CHECKSIGFROMSTACKVERIFY BIP340 shorter message"], + [[["e2f2baee9c59389b34e39742ce05debf64aaa7a00fbdab88614f4d3c133186d5", + 0, + "0 0x20 0xaf4e76d12eac5502d0f24ef0666ae4dcf0e39f07ffbfd1c5f60fd64f7486e6f8", + 155000]], +"02000000000101d58631133c4d4f6188abbd0fa0a7aa64bfde05ce4297e3349b38599ceebaf2e20000000000ffffffff01f0490200000000002251202ca3bc76489a54904ad2507005789afc1e6b362b451be89f69de39ddf9ba8abf024006c8d9ef150f88e6983e089c8671e0789a7d466564543b62abe37be6b0c43495a9676691e9179a153df9c5e9b734a8bfaa8ee4085fa0bc5b5da050a66d6b000a2804deadbeef2007017b19a7b1ace3c60446ffbf6473ae70c99bb6a9550c220568732123e49ce8b46d00000000", + "DISCOURAGE_LNHANCE"], + ["Test P2SH OP_CHECKSIGFROMSTACKVERIFY"], + [[["e2f2baee9c59389b34e39742ce05debf64aaa7a00fbdab88614f4d3c133186d5", + 0, + "OP_HASH160 0x14 0xd211422fef21b1336495b3d9a20a1c2ca553cb7f OP_EQUAL", + 155000]], +"0200000001d58631133c4d4f6188abbd0fa0a7aa64bfde05ce4297e3349b38599ceebaf2e2000000008d463044022046b9abc584ad1e04419e8f2e7e9ab1bdac5c42fa0936b488525289135d347e1802206117872a3da184fc4b43ea50c33426bb8f01dd8102eff7a596b7063c6625a8d64520deadbeefdeadbeefdeadbeefdeadbeefdeadbeefdeadbeefdeadbeefdeadbeef2103193c33954240709ded920960a9f7a740baac76a947ab75ea7ad52ae0e7756043b46dffffffff01f0490200000000002251202ca3bc76489a54904ad2507005789afc1e6b362b451be89f69de39ddf9ba8abf00000000", + "DISCOURAGE_LNHANCE"], + ["Test bare OP_CHECKSIGFROMSTACKVERIFY"], + [[["e2f2baee9c59389b34e39742ce05debf64aaa7a00fbdab88614f4d3c133186d5", + 0, + "0x20 0xdeadbeefdeadbeefdeadbeefdeadbeefdeadbeefdeadbeefdeadbeefdeadbeef 0x21 0x03193c33954240709ded920960a9f7a740baac76a947ab75ea7ad52ae0e7756043 OP_CHECKSIGFROMSTACKVERIFY OP_2DROP", + 155000]], +"0200000001d58631133c4d4f6188abbd0fa0a7aa64bfde05ce4297e3349b38599ceebaf2e20000000047463044022046b9abc584ad1e04419e8f2e7e9ab1bdac5c42fa0936b488525289135d347e1802206117872a3da184fc4b43ea50c33426bb8f01dd8102eff7a596b7063c6625a8d6ffffffff01f0490200000000002251202ca3bc76489a54904ad2507005789afc1e6b362b451be89f69de39ddf9ba8abf00000000", + "DISCOURAGE_LNHANCE"], + ["Make diffs cleaner by leaving a comment here without comma at the end"] ] diff --git a/test/functional/test_framework/script.py b/test/functional/test_framework/script.py index 6706d37f0766ff..14d0f78e07dcae 100644 --- a/test/functional/test_framework/script.py +++ b/test/functional/test_framework/script.py @@ -925,4 +925,4 @@ def taproot_construct(pubkey, scripts=None, treat_internal_as_infinity=False): return TaprootInfo(CScript([OP_1, tweaked]), pubkey, negated + 0, tweak, leaves, h, tweaked) def is_op_success(o): - return o == 0x50 or o == 0x62 or o == 0x89 or o == 0x8a or o == 0x8d or o == 0x8e or (o >= 0x7e and o <= 0x81) or (o >= 0x83 and o <= 0x86) or (o >= 0x95 and o <= 0x99) or (o >= 0xbc and o <= 0xfe) + return o == 0x50 or o == 0x62 or o == 0x89 or o == 0x8a or o == 0x8d or o == 0x8e or (o >= 0x7e and o <= 0x81) or (o >= 0x83 and o <= 0x86) or (o >= 0x95 and o <= 0x99) or (o >= 0xbd and o <= 0xfe)