Skip to content

Commit 362001c

Browse files
committed
Move CHECKMULTISIG order tests out of automatically generated block
1 parent f67a9ce commit 362001c

File tree

2 files changed

+42
-43
lines changed

2 files changed

+42
-43
lines changed

src/test/data/script_invalid.json

Lines changed: 19 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -496,6 +496,25 @@ nSequences are max.
496496
["0 0x02 0x0000 0", "CHECKMULTISIGVERIFY 1", "MINIMALDATA"],
497497

498498

499+
["
500+
Order of CHECKMULTISIG evaluation tests, inverted by swapping the order of
501+
pubkeys/signatures so they fail due to the STRICTENC rules on validly encoded
502+
signatures and pubkeys.
503+
"],
504+
[
505+
"0 0x47 0x3044022044dc17b0887c161bb67ba9635bf758735bdde503e4b0a0987f587f14a4e1143d022009a215772d49a85dae40d8ca03955af26ad3978a0ff965faa12915e9586249a501 0x47 0x3044022044dc17b0887c161bb67ba9635bf758735bdde503e4b0a0987f587f14a4e1143d022009a215772d49a85dae40d8ca03955af26ad3978a0ff965faa12915e9586249a501",
506+
"2 0x21 0x02865c40293a680cb9c020e7b1e106d8c1916d3cef99aa431a56d253e69256dac0 0 2 CHECKMULTISIG NOT",
507+
"STRICTENC",
508+
"2-of-2 CHECKMULTISIG NOT with the first pubkey invalid, and both signatures validly encoded."
509+
],
510+
[
511+
"0 0x47 0x3044022044dc17b0887c161bb67ba9635bf758735bdde503e4b0a0987f587f14a4e1143d022009a215772d49a85dae40d8ca03955af26ad3978a0ff965faa12915e9586249a501 0",
512+
"2 0x21 0x02865c40293a680cb9c020e7b1e106d8c1916d3cef99aa431a56d253e69256dac0 0x21 0x02865c40293a680cb9c020e7b1e106d8c1916d3cef99aa431a56d253e69256dac0 2 CHECKMULTISIG NOT",
513+
"STRICTENC",
514+
"2-of-2 CHECKMULTISIG NOT with both pubkeys valid, but first signature invalid."
515+
],
516+
517+
["Automatically generated test cases"],
499518
[
500519
"0x47 0x3044022053205076a7bb12d2db3162a2d97d8197631f829b065948b7019b15482af819a902204328dcc02c994ca086b1226d0d5f1674d23cfae0d846143df812b81cab3391e801",
501520
"0x41 0x0479be667ef9dcbbac55a06295ce870b07029bfcdb2dce28d959f2815b16f81798483ada7726a3c4655da4fbfc0e1108a8fd17b448a68554199c47d08ffb10d4b8 CHECKSIG",
@@ -616,25 +635,6 @@ nSequences are max.
616635
"STRICTENC",
617636
"P2PK with undefined hashtype"
618637
],
619-
620-
["
621-
Order of CHECKMULTISIG evaluation tests, inverted by swapping the order of
622-
pubkeys/signatures so they fail due to the STRICTENC rules on validly encoded
623-
signatures and pubkeys.
624-
"],
625-
[
626-
"0 0x47 0x3044022044dc17b0887c161bb67ba9635bf758735bdde503e4b0a0987f587f14a4e1143d022009a215772d49a85dae40d8ca03955af26ad3978a0ff965faa12915e9586249a501 0x47 0x3044022044dc17b0887c161bb67ba9635bf758735bdde503e4b0a0987f587f14a4e1143d022009a215772d49a85dae40d8ca03955af26ad3978a0ff965faa12915e9586249a501",
627-
"2 0x21 0x02865c40293a680cb9c020e7b1e106d8c1916d3cef99aa431a56d253e69256dac0 0 2 CHECKMULTISIG NOT",
628-
"STRICTENC",
629-
"2-of-2 CHECKMULTISIG NOT with the first pubkey invalid, and both signatures validly encoded."
630-
],
631-
[
632-
"0 0x47 0x3044022044dc17b0887c161bb67ba9635bf758735bdde503e4b0a0987f587f14a4e1143d022009a215772d49a85dae40d8ca03955af26ad3978a0ff965faa12915e9586249a501 0",
633-
"2 0x21 0x02865c40293a680cb9c020e7b1e106d8c1916d3cef99aa431a56d253e69256dac0 0x21 0x02865c40293a680cb9c020e7b1e106d8c1916d3cef99aa431a56d253e69256dac0 2 CHECKMULTISIG NOT",
634-
"STRICTENC",
635-
"2-of-2 CHECKMULTISIG NOT with both pubkeys valid, but first signature invalid."
636-
],
637-
638638
[
639639
"0x47 0x304402207409b5b320296e5e2136a7b281a7f803028ca4ca44e2b83eebd46932677725de02202d4eea1c8d3c98e6f42614f54764e6e5e6542e213eb4d079737e9a8b6e9812ec05",
640640
"0x41 0x048282263212c609d9ea2a6e3e172de238d8c39cabd5ac1ca10646e23fd5f5150811f8a8098557dfe45e8256e830b60ace62d613ac2f7b17bed31b6eaff6e26caf CHECKSIG NOT",

src/test/data/script_valid.json

Lines changed: 23 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -664,7 +664,30 @@ nSequences are max.
664664
["0 0 0x02 0x0000", "CHECKMULTISIGVERIFY 1", ""],
665665
["0 0x02 0x0000 0", "CHECKMULTISIGVERIFY 1", ""],
666666

667+
["
668+
CHECKMULTISIG evaluation order tests. CHECKMULTISIG evaluates signatures and
669+
pubkeys in a specific order, and will exit early if the number of signatures
670+
left to check is greater than the number of keys left. As STRICTENC fails the
671+
script when it reaches an invalidly encoded signature or pubkey, we can use it
672+
to test the exact order in which signatures and pubkeys are evaluated by
673+
distinguishing CHECKMULTISIG returning false on the stack and the script as a
674+
whole failing.
675+
See also the corresponding inverted versions of these tests in script_invalid.json
676+
"],
677+
[
678+
"0 0x47 0x3044022044dc17b0887c161bb67ba9635bf758735bdde503e4b0a0987f587f14a4e1143d022009a215772d49a85dae40d8ca03955af26ad3978a0ff965faa12915e9586249a501 0x47 0x3044022044dc17b0887c161bb67ba9635bf758735bdde503e4b0a0987f587f14a4e1143d022009a215772d49a85dae40d8ca03955af26ad3978a0ff965faa12915e9586249a501",
679+
"2 0 0x21 0x02865c40293a680cb9c020e7b1e106d8c1916d3cef99aa431a56d253e69256dac0 2 CHECKMULTISIG NOT",
680+
"STRICTENC",
681+
"2-of-2 CHECKMULTISIG NOT with the second pubkey invalid, and both signatures validly encoded. Valid pubkey fails, and CHECKMULTISIG exits early, prior to evaluation of second invalid pubkey."
682+
],
683+
[
684+
"0 0 0x47 0x3044022044dc17b0887c161bb67ba9635bf758735bdde503e4b0a0987f587f14a4e1143d022009a215772d49a85dae40d8ca03955af26ad3978a0ff965faa12915e9586249a501",
685+
"2 0x21 0x02865c40293a680cb9c020e7b1e106d8c1916d3cef99aa431a56d253e69256dac0 0x21 0x02865c40293a680cb9c020e7b1e106d8c1916d3cef99aa431a56d253e69256dac0 2 CHECKMULTISIG NOT",
686+
"STRICTENC",
687+
"2-of-2 CHECKMULTISIG NOT with both pubkeys valid, but second signature invalid. Valid pubkey fails, and CHECKMULTISIG exits early, prior to evaluation of second invalid signature."
688+
],
667689

690+
["Automatically generated test cases"],
668691
[
669692
"0x47 0x3044022053205076a7bb13d2db3162a2d97d8197631f829b065948b7019b15482af819a902204328dcc02c994ca086b1226d0d5f1674d23cfae0d846143df812b81cab3391e801",
670693
"0x41 0x0479be667ef9dcbbac55a06295ce870b07029bfcdb2dce28d959f2815b16f81798483ada7726a3c4655da4fbfc0e1108a8fd17b448a68554199c47d08ffb10d4b8 CHECKSIG",
@@ -761,30 +784,6 @@ nSequences are max.
761784
"STRICTENC",
762785
"1-of-2 with the second 1 hybrid pubkey"
763786
],
764-
765-
["
766-
CHECKMULTISIG evaluation order tests. CHECKMULTISIG evaluates signatures and
767-
pubkeys in a specific order, and will exit early if the number of signatures
768-
left to check is greater than the number of keys left. As STRICTENC fails the
769-
script when it reaches an invalidly encoded signature or pubkey, we can use it
770-
to test the exact order in which signatures and pubkeys are evaluated by
771-
distinguishing CHECKMULTISIG returning false on the stack and the script as a
772-
whole failing.
773-
See also the corresponding inverted versions of these tests in script_invalid.json
774-
"],
775-
[
776-
"0 0x47 0x3044022044dc17b0887c161bb67ba9635bf758735bdde503e4b0a0987f587f14a4e1143d022009a215772d49a85dae40d8ca03955af26ad3978a0ff965faa12915e9586249a501 0x47 0x3044022044dc17b0887c161bb67ba9635bf758735bdde503e4b0a0987f587f14a4e1143d022009a215772d49a85dae40d8ca03955af26ad3978a0ff965faa12915e9586249a501",
777-
"2 0 0x21 0x02865c40293a680cb9c020e7b1e106d8c1916d3cef99aa431a56d253e69256dac0 2 CHECKMULTISIG NOT",
778-
"STRICTENC",
779-
"2-of-2 CHECKMULTISIG NOT with the second pubkey invalid, and both signatures validly encoded. Valid pubkey fails, and CHECKMULTISIG exits early, prior to evaluation of second invalid pubkey."
780-
],
781-
[
782-
"0 0 0x47 0x3044022044dc17b0887c161bb67ba9635bf758735bdde503e4b0a0987f587f14a4e1143d022009a215772d49a85dae40d8ca03955af26ad3978a0ff965faa12915e9586249a501",
783-
"2 0x21 0x02865c40293a680cb9c020e7b1e106d8c1916d3cef99aa431a56d253e69256dac0 0x21 0x02865c40293a680cb9c020e7b1e106d8c1916d3cef99aa431a56d253e69256dac0 2 CHECKMULTISIG NOT",
784-
"STRICTENC",
785-
"2-of-2 CHECKMULTISIG NOT with both pubkeys valid, but second signature invalid. Valid pubkey fails, and CHECKMULTISIG exits early, prior to evaluation of second invalid signature."
786-
],
787-
788787
[
789788
"0x47 0x304402201c215cb13e4954e60ce4f6de74941904c771f998de7b1d9627e82a1949fde517022031c2197455f3dbecbb78321201308d7b039424e38d480772d7cd4eb465a083f405",
790789
"0x41 0x048282263212c609d9ea2a6e3e172de238d8c39cabd5ac1ca10646e23fd5f5150811f8a8098557dfe45e8256e830b60ace62d613ac2f7b17bed31b6eaff6e26caf CHECKSIG",

0 commit comments

Comments
 (0)