Implement BIP 348 validation (CHECKSIGFROMSTACK)#87
Implement BIP 348 validation (CHECKSIGFROMSTACK)#87ajtowns merged 5 commits intobitcoin-inquisition:29.xfrom
Conversation
88cf0b0 to
92d41ec
Compare
src/binana/checksigfromstack.json
Outdated
There was a problem hiding this comment.
Should be 2024, 3, 2, since it's revision 2 you're implementing?
92d41ec to
3b25716
Compare
src/script/interpreter.cpp
Outdated
There was a problem hiding this comment.
Testing !sig.empty() or success_out only once seems cleaner:
} else if (size() == 32) {
if (success_out) {
if (sig.size() != 64) return SCRIPT_ERR_SCHNORR_SIG_SIZE;
XOnlyPubKey pubkey{pubkey_in};
if (!pubkey.VerifySchnorr(msg, sig)) return SCRIPT_ERR_SCHNORR_SIG;
}
}Implements script validation, but no exposure to any network as of yet.
3b25716 to
8a131e3
Compare
|
rebased |
8a131e3 to
5a7bf4f
Compare
ajtowns
left a comment
There was a problem hiding this comment.
$ ./feature_taproot.py --randomseed 8836805849730300108errors with "Data push larger than necessary" for me with this PR applied.
test/functional/feature_taproot.py
Outdated
There was a problem hiding this comment.
I believe you could use the five verification result=TRUE cases in test_framework/bip340_test_vectors.csv here to perhaps get a bit more coverage.
Not sure adding this to feature_taproot is a great idea? Seems like it makes it hard to test the behaviour when CSFS isn't activated, and it doesn't benefit from running multiple test cases at once to bring the total time down.
There was a problem hiding this comment.
I believe you could use the five verification result=TRUE cases in test_framework/bip340_test_vectors.csv here to perhaps get a bit more coverage.
I'll take another look at this soon.
If it were easier to activate softforks, then it's pretty simple to test prior-to-activation behavior. instagibbs@bfda78a#diff-5371490253f356bb2ddeb014bb570c5a422ac73ca6dcd8db0f16b81cafa3c786R1898 as an examplefor TEMPLATEHASH
There was a problem hiding this comment.
Set -vbparams=checksigfromstack:0:3999999999, mine a block with nVersion=0x62000302 (from getdeploymentinfo) using create_block, and mine 288 or so blocks on top?
There was a problem hiding this comment.
figured it out and pushed a couple examples
5a7bf4f to
fde0384
Compare
|
@ajtowns changed to have inputs push something that won't be non-minimalpush in non-witness land |
| return false; // serror set by EvalChecksigFromStack | ||
| } | ||
|
|
||
| popstack(stack); |
There was a problem hiding this comment.
By the specification of BIP348 these pops should happen before any logical evaluation
https://github.com/bitcoin/bips/blob/master/bip-0348.md#specification
There was a problem hiding this comment.
that's an implementation detail, not a semantic difference?
|
(lint checker has complaints) |
76f9913 to
fe286d0
Compare
|
ACK fe286d0 Manually checked behaviour with: $ cat ${BIPS}/bip-0340/test-vectors.csv | tail -n +2 | cut -d, -f3,5,6,7 | (export IFS=,; while read key msg sig succ; do
(./bitcoin-util -sigversion=tapscript -script_flags=STANDARD evalscript '0xCC' "$sig" "$msg" "$key" |
jq .success; echo $succ) | fmt; done) |
sort | uniq -c
10 false FALSE
9 true TRUECan't specify it as |
c40dbbb test: Move `script_assets_tests` into its own suite (Hennadii Stepanov) Pull request description: This PR ensures that the `script_assets_tests` test case is explicitly reported as "Skipped" when it is not run, making it clearer when running the test suite with `ctest`: - on the master branch @ 9355578: ``` $ env -u DIR_UNIT_TEST_DATA ctest --test-dir build -j 16 -R "^script_" Internal ctest changing into directory: /home/hebasto/git/bitcoin/build Test project /home/hebasto/git/bitcoin/build Start 87: script_tests Start 83: script_p2sh_tests Start 85: script_segwit_tests Start 86: script_standard_tests Start 84: script_parse_tests 1/5 Test bitcoin-inquisition#84: script_parse_tests ............... Passed 0.11 sec 2/5 Test bitcoin-inquisition#86: script_standard_tests ............ Passed 0.11 sec 3/5 Test bitcoin-inquisition#85: script_segwit_tests .............. Passed 0.12 sec 4/5 Test bitcoin-inquisition#83: script_p2sh_tests ................ Passed 0.12 sec 5/5 Test bitcoin-inquisition#87: script_tests ..................... Passed 0.36 sec 100% tests passed, 0 tests failed out of 5 Total Test time (real) = 0.37 sec ``` - with this PR: ``` $ env -u DIR_UNIT_TEST_DATA ctest --test-dir build -j 16 -R "^script_" Internal ctest changing into directory: /home/hebasto/git/bitcoin/build Test project /home/hebasto/git/bitcoin/build Start 83: script_assets_tests Start 88: script_tests Start 84: script_p2sh_tests Start 86: script_segwit_tests Start 87: script_standard_tests Start 85: script_parse_tests 1/6 Test bitcoin-inquisition#85: script_parse_tests ............... Passed 0.11 sec 2/6 Test bitcoin-inquisition#83: script_assets_tests ..............***Skipped 0.12 sec 3/6 Test bitcoin-inquisition#86: script_segwit_tests .............. Passed 0.11 sec 4/6 Test bitcoin-inquisition#87: script_standard_tests ............ Passed 0.11 sec 5/6 Test bitcoin-inquisition#84: script_p2sh_tests ................ Passed 0.12 sec 6/6 Test bitcoin-inquisition#88: script_tests ..................... Passed 0.36 sec 100% tests passed, 0 tests failed out of 6 Total Test time (real) = 0.37 sec The following tests did not run: 83 - script_assets_tests (Skipped) $ env DIR_UNIT_TEST_DATA=/home/hebasto/git/bitcoin/qa-assets/unit_test_data ctest --test-dir build -j 16 -R "^script_" Internal ctest changing into directory: /home/hebasto/git/bitcoin/build Test project /home/hebasto/git/bitcoin/build Start 83: script_assets_tests Start 88: script_tests Start 84: script_p2sh_tests Start 86: script_segwit_tests Start 87: script_standard_tests Start 85: script_parse_tests 1/6 Test bitcoin-inquisition#85: script_parse_tests ............... Passed 0.11 sec 2/6 Test bitcoin-inquisition#87: script_standard_tests ............ Passed 0.11 sec 3/6 Test bitcoin-inquisition#86: script_segwit_tests .............. Passed 0.11 sec 4/6 Test bitcoin-inquisition#84: script_p2sh_tests ................ Passed 0.12 sec 5/6 Test bitcoin-inquisition#88: script_tests ..................... Passed 0.35 sec 6/6 Test bitcoin-inquisition#83: script_assets_tests .............. Passed 1.58 sec 100% tests passed, 0 tests failed out of 6 Total Test time (real) = 1.58 sec ``` ACKs for top commit: maflcko: re-ACK c40dbbb 👈 ajtowns: ACK c40dbbb achow101: ACK c40dbbb Tree-SHA512: 25713e1c3b507b6f2a5fecc7b1ea285a6642b906c248769238a58fc0df48489ac5f7606778f9e3653b407b7f1d06563e1554d04321303b350c80eb888500cc5d
Re-applied logic from #72