Skip to content

Commit

Permalink
Passing CSFS tests
Browse files Browse the repository at this point in the history
  • Loading branch information
reardencode committed Dec 22, 2023
1 parent ae29240 commit 0031a6a
Show file tree
Hide file tree
Showing 3 changed files with 70 additions and 0 deletions.
4 changes: 4 additions & 0 deletions src/script/interpreter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1270,6 +1270,10 @@ bool EvalScript(std::vector<std::vector<unsigned char> >& stack, const CScript&
if (opcode == OP_CHECKSIGFROMSTACK && (sigversion == SigVersion::BASE || sigversion == SigVersion::WITNESS_V0)) {
return set_error(serror, SCRIPT_ERR_BAD_OPCODE);
}
if (flags & SCRIPT_VERIFY_DISCOURAGE_CTVCSFSINTERNALKEY) {
if (opcode == OP_CHECKSIGFROMSTACKVERIFY) return set_error(serror, SCRIPT_ERR_DISCOURAGE_UPGRADABLE_NOPS);
return set_error(serror, SCRIPT_ERR_DISCOURAGE_OP_SUCCESS);
}

// sig data pubkey
if (stack.size() < 3)
Expand Down
16 changes: 16 additions & 0 deletions src/test/data/tx_invalid.json
Original file line number Diff line number Diff line change
Expand Up @@ -488,5 +488,21 @@
"020000000297e5046ea9335a2ce209f677f0d0a303cd266461ff42316f73c53360a92f52a2000000000151000000000b4c12e6dbe974dadd18ca139e6bce183817ac609f73213aa8aaeae5f123d6b6000000000151000000000ae80300000000000017a9143f163a8747557345ce2e6fe00c1894f2f281795e87d00700000000000017a9144cf13dfda93a7413b7e646611735656e5457657087b80b00000000000017a914868998b49df649c37a88d48c9d4a5b37290e507287a00f00000000000017a914034f9914a77571a6396482e9881745c92c3037c687881300000000000017a914a8238003e1732e2baf4334a8546d72be99af9bae87701700000000000017a91491dbac5d67d5941115a03fc7eaec09f31a5b4dfc87581b00000000000017a914e0c0f19fec3b2993b9c116c798b5429d4515596687401f00000000000017a914d6b40d98d94530f1a1eb57614680813c81a95ccd87282300000000000017a914fb0bfb072bb79611a4323981828108a3cf54b0a687102700000000000017a9149e2d11f06ba667e981b802af10be8dabd08eafff8700000000",
"CTVCSFSINTERNALKEY"],

["Test OP_CHECKSIGFROMSTACK, fails with sig for wrong data"],
[[["a2522fa96033c5736f3142ff616426cd03a3d0f077f609e22c5a33a96e04e597",
0,
"1 0x20 0x2fb0c361166d694c1fa1a9955518170c89d51d5debad1e53a2478dd2207d0e0a",
155000]],
"0200000000010197e5046ea9335a2ce209f677f0d0a303cd266461ff42316f73c53360a92f52a20000000000ffffffff01f0490200000000002251202ca3bc76489a54904ad2507005789afc1e6b362b451be89f69de39ddf9ba8abf034079001cd9669b1a54c67ee61dc2ef980a1d5feeb4c677978b05c9de26d7533f9f9ac4f526c7fdfd65351f0a4756d05d79a91639290fea8669d2bebf86ff351e0d4320feadbeefdeadbeefdeadbeefdeadbeefdeadbeefdeadbeefdeadbeefdeadbeef20f4b16c96ad395b47dd9079faf553a0d9e8ce1da8729da811b8a93954a756b883bc21c050929b74c1a04954b78b4b6035e97a5e078a5a0f28ec96d547bfee9ace803ac000000000",
"P2SH,WITNESS,TAPROOT,CTVCSFSINTERNALKEY"],
["Test OP_CHECKSIGFROMSTACKVERIFY, fails immediately with changed sig"],
[[["a2522fa96033c5736f3142ff616426cd03a3d0f077f609e22c5a33a96e04e597",
0,
"1 0x20 0x53af700e9733abe9f4b8518fcec7a1814f723b78329da6a46d14b5bb9a106baf",
155000]],
"0200000000010197e5046ea9335a2ce209f677f0d0a303cd266461ff42316f73c53360a92f52a20000000000ffffffff01f0490200000000002251202ca3bc76489a54904ad2507005789afc1e6b362b451be89f69de39ddf9ba8abf0340f7d74789c5aff9168c2f174d14535a99755aeada9efe1ad130489cdb32d922192aac7564831dabd0e5be832ec102b9a43db2a1f1020660648869ebde3e9f69484520deadbeefdeadbeefdeadbeefdeadbeefdeadbeefdeadbeefdeadbeefdeadbeef205dba240412eeea155985ac48a7dc1250e5d8d1bbe0368dbf137ab1173f801764bc008721c150929b74c1a04954b78b4b6035e97a5e078a5a0f28ec96d547bfee9ace803ac000000000",
"P2SH,WITNESS,TAPROOT,CTVCSFSINTERNALKEY"],


["Make diffs cleaner by leaving a comment here without comma at the end"]
]
50 changes: 50 additions & 0 deletions src/test/data/tx_valid.json
Original file line number Diff line number Diff line change
Expand Up @@ -676,5 +676,55 @@
"02000000000101d58631133c4d4f6188abbd0fa0a7aa64bfde05ce4297e3349b38599ceebaf2e20000000000ffffffff01f0490200000000002251202ca3bc76489a54904ad2507005789afc1e6b362b451be89f69de39ddf9ba8abf0223bb2050929b74c1a04954b78b4b6035e97a5e078a5a0f28ec96d547bfee9ace803ac08721c150929b74c1a04954b78b4b6035e97a5e078a5a0f28ec96d547bfee9ace803ac000000000",
"DISCOURAGE_CTVCSFSINTERNALKEY"],

["Test OP_CHECKSIGFROMSTACK"],
[[["e2f2baee9c59389b34e39742ce05debf64aaa7a00fbdab88614f4d3c133186d5",
0,
"1 0x20 0x87e1bbe335f839e858dce8a383509f3904c102e100688c73abcbfe92eb1b9cff",
155000]],
"02000000000101d58631133c4d4f6188abbd0fa0a7aa64bfde05ce4297e3349b38599ceebaf2e20000000000ffffffff01f0490200000000002251202ca3bc76489a54904ad2507005789afc1e6b362b451be89f69de39ddf9ba8abf0340dcc19ae125ab4ca27c0d78e0bfec86238dd85e508d6ab4c566b825213f955acd38b98847d6804d08690c734333d6f2dbd40f96b61ecc9a5e2a20bcfa7c67a81f4320deadbeefdeadbeefdeadbeefdeadbeefdeadbeefdeadbeefdeadbeefdeadbeef20f37bc3b26e03286fd90c64f15449b99dff2d9cd7eb8e0eddc214dd00e4141b88bc21c050929b74c1a04954b78b4b6035e97a5e078a5a0f28ec96d547bfee9ace803ac000000000",
"DISCOURAGE_CTVCSFSINTERNALKEY"],
["Test OP_CHECKSIGFROMSTACK yields 0 for 0-sig"],
[[["e2f2baee9c59389b34e39742ce05debf64aaa7a00fbdab88614f4d3c133186d5",
0,
"1 0x20 0x042c6b34ee658e55f9673e5e6b17485ee7b59181ef4c71279d87f60576771235",
155000]],
"02000000000101d58631133c4d4f6188abbd0fa0a7aa64bfde05ce4297e3349b38599ceebaf2e20000000000ffffffff01f0490200000000002251202ca3bc76489a54904ad2507005789afc1e6b362b451be89f69de39ddf9ba8abf03004520deadbeefdeadbeefdeadbeefdeadbeefdeadbeefdeadbeefdeadbeefdeadbeef2044b54b04016f2b60db1aeb3a43d591677a7a8458338381446d1d37068e34cb22bc008721c050929b74c1a04954b78b4b6035e97a5e078a5a0f28ec96d547bfee9ace803ac000000000",
"DISCOURAGE_CTVCSFSINTERNALKEY"],
["Test OP_CHECKSIGFROMSTACK, shorter message"],
[[["e2f2baee9c59389b34e39742ce05debf64aaa7a00fbdab88614f4d3c133186d5",
0,
"1 0x20 0x153a9792b2a5e3df88662b8e0dfbd6d824933cc5f7febf966061b8264282c069",
155000]],
"02000000000101d58631133c4d4f6188abbd0fa0a7aa64bfde05ce4297e3349b38599ceebaf2e20000000000ffffffff01f0490200000000002251202ca3bc76489a54904ad2507005789afc1e6b362b451be89f69de39ddf9ba8abf034095071a2e3dcf050eea4b137a50eafdc8ea4fe222320f0f40f29ad7cf4267a645a00dd78cd9a59553eedcf63f54be5f116a74dd323376dd751817d74f7ba970972704617364662060c02b73c0d38fb2e4cf48ec1ba0a4c7e83f26aac42219d3c5b86032f981b9ecbc21c150929b74c1a04954b78b4b6035e97a5e078a5a0f28ec96d547bfee9ace803ac000000000",
"DISCOURAGE_CTVCSFSINTERNALKEY"],
["Test Taproot OP_CHECKSIGFROMSTACKVERIFY"],
[[["e2f2baee9c59389b34e39742ce05debf64aaa7a00fbdab88614f4d3c133186d5",
0,
"1 0x20 0x14827b13c0d4bfd1d831e2091bf249e4851459a9e170955cf9bede89ca408232",
155000]],
"02000000000101d58631133c4d4f6188abbd0fa0a7aa64bfde05ce4297e3349b38599ceebaf2e20000000000ffffffff01f0490200000000002251202ca3bc76489a54904ad2507005789afc1e6b362b451be89f69de39ddf9ba8abf034069a63c5cd7e96228e3b930a40e1a07cb3358aeae1b15fdca5c0a66330c285f2ebcfbcbdd3944f99f355752b7aaa8efe46c41a9515d8eeae0251bdf4a39e9c39f4420deadbeefdeadbeefdeadbeefdeadbeefdeadbeefdeadbeefdeadbeefdeadbeef206e4953e81af479de5f3caa0de70e9a5c75972306a287935f6fbc41a3143aca5fb46d21c150929b74c1a04954b78b4b6035e97a5e078a5a0f28ec96d547bfee9ace803ac000000000",
"DISCOURAGE_CTVCSFSINTERNALKEY"],
["Test P2WSH OP_CHECKSIGFROMSTACKVERIFY"],
[[["e2f2baee9c59389b34e39742ce05debf64aaa7a00fbdab88614f4d3c133186d5",
0,
"0 0x20 0xd6769c2859b8c5e35d27f2aa78bbdd1d63fba4ea89b0e2e91d89d34e6ae87608",
155000]],
"02000000000101d58631133c4d4f6188abbd0fa0a7aa64bfde05ce4297e3349b38599ceebaf2e20000000000ffffffff01f0490200000000002251202ca3bc76489a54904ad2507005789afc1e6b362b451be89f69de39ddf9ba8abf02463044022068c3eda1c657570ddcff16618c1903845db2fa808754dab422c555f426891a9802202872b0ce193e2a8fc712ca40367c9a077c13bbcdefe2e4b6c022a50afffc60054520deadbeefdeadbeefdeadbeefdeadbeefdeadbeefdeadbeefdeadbeefdeadbeef210382fb5cf8ba70cca6bd89b033e14ff131bfd953a7657d9ff2d53005a95da581b6b46d00000000",
"DISCOURAGE_CTVCSFSINTERNALKEY"],
["Test P2SH OP_CHECKSIGFROMSTACKVERIFY"],
[[["e2f2baee9c59389b34e39742ce05debf64aaa7a00fbdab88614f4d3c133186d5",
0,
"OP_HASH160 0x14 0x095b5b8266073cfa2394f2509a69bd215868b0be OP_EQUAL",
155000]],
"0200000001d58631133c4d4f6188abbd0fa0a7aa64bfde05ce4297e3349b38599ceebaf2e2000000008d46304402201b509e09a8fac0dc7c955e5b2501bb7e5009d4162c79a663cfbb735319f7e58302205f0516fbd5307f681ec38d25b27bd09c5bd0464d1b8c89af6bacdea3c769dd284520deadbeefdeadbeefdeadbeefdeadbeefdeadbeefdeadbeefdeadbeefdeadbeef2102b4832db92ab21a0d5ced6303fed60ab0f14ca9642f21d1b14d8cfbcad8881631b46dffffffff01f0490200000000002251202ca3bc76489a54904ad2507005789afc1e6b362b451be89f69de39ddf9ba8abf00000000",
"DISCOURAGE_CTVCSFSINTERNALKEY"],
["Test bare OP_CHECKSIGFROMSTACKVERIFY"],
[[["e2f2baee9c59389b34e39742ce05debf64aaa7a00fbdab88614f4d3c133186d5",
0,
"0x20 0xdeadbeefdeadbeefdeadbeefdeadbeefdeadbeefdeadbeefdeadbeefdeadbeef 0x21 0x02b4832db92ab21a0d5ced6303fed60ab0f14ca9642f21d1b14d8cfbcad8881631 0xb4 0x6d",
155000]],
"0200000001d58631133c4d4f6188abbd0fa0a7aa64bfde05ce4297e3349b38599ceebaf2e2000000004746304402201b509e09a8fac0dc7c955e5b2501bb7e5009d4162c79a663cfbb735319f7e58302205f0516fbd5307f681ec38d25b27bd09c5bd0464d1b8c89af6bacdea3c769dd28ffffffff01f0490200000000002251202ca3bc76489a54904ad2507005789afc1e6b362b451be89f69de39ddf9ba8abf00000000",
"DISCOURAGE_CTVCSFSINTERNALKEY"],

["Make diffs cleaner by leaving a comment here without comma at the end"]
]

0 comments on commit 0031a6a

Please sign in to comment.