txscript: Add new flag ScriptVerifyMinimalData

The ScriptVerifyMinimalData enforces that all push operations use the
minimal data push required.  This is part of BIP0062.

This commit mimics Bitcoin Core commit
698c6abb25c1fbbc7fa4ba46b60e9f17d97332ef
This commit is contained in:
David Hill
2015-02-12 12:27:27 -05:00
parent 63c1172aa8
commit 5a4312d9ca
6 changed files with 242 additions and 2 deletions

View File

@@ -403,6 +403,102 @@
["0 0x01 VER", "HASH160 0x14 0x0f4d7845db968f2a81b530b6f3c1d6246d4c7e01 EQUAL", "P2SH,STRICTENC", "OP_VER in P2SH should fail"],
["0x00", "'00' EQUAL", "P2SH,STRICTENC", "Basic OP_0 execution"],
["MINIMALDATA enforcement for PUSHDATAs"],
["0x4c 0x00", "DROP 1", "MINIMALDATA", "Empty vector minimally represented by OP_0"],
["0x01 0x81", "DROP 1", "MINIMALDATA", "-1 minimally represented by OP_1NEGATE"],
["0x01 0x01", "DROP 1", "MINIMALDATA", "1 to 16 minimally represented by OP_1 to OP_16"],
["0x01 0x02", "DROP 1", "MINIMALDATA"],
["0x01 0x03", "DROP 1", "MINIMALDATA"],
["0x01 0x04", "DROP 1", "MINIMALDATA"],
["0x01 0x05", "DROP 1", "MINIMALDATA"],
["0x01 0x06", "DROP 1", "MINIMALDATA"],
["0x01 0x07", "DROP 1", "MINIMALDATA"],
["0x01 0x08", "DROP 1", "MINIMALDATA"],
["0x01 0x09", "DROP 1", "MINIMALDATA"],
["0x01 0x0a", "DROP 1", "MINIMALDATA"],
["0x01 0x0b", "DROP 1", "MINIMALDATA"],
["0x01 0x0c", "DROP 1", "MINIMALDATA"],
["0x01 0x0d", "DROP 1", "MINIMALDATA"],
["0x01 0x0e", "DROP 1", "MINIMALDATA"],
["0x01 0x0f", "DROP 1", "MINIMALDATA"],
["0x01 0x10", "DROP 1", "MINIMALDATA"],
["0x4c 0x48 0x111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111", "DROP 1", "MINIMALDATA",
"PUSHDATA1 of 72 bytes minimally represented by direct push"],
["0x4d 0xFF00 0x111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111", "DROP 1", "MINIMALDATA",
"PUSHDATA2 of 255 bytes minimally represented by PUSHDATA1"],
["0x4f 0x00100000 0x11111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111", "DROP 1", "MINIMALDATA",
"PUSHDATA4 of 256 bytes minimally represented by PUSHDATA2"],
["MINIMALDATA enforcement for numeric arguments"],
["0x01 0x00", "NOT DROP 1", "MINIMALDATA", "numequals 0"],
["0x02 0x0000", "NOT DROP 1", "MINIMALDATA", "numequals 0"],
["0x01 0x80", "NOT DROP 1", "MINIMALDATA", "0x80 (negative zero) numequals 0"],
["0x02 0x0080", "NOT DROP 1", "MINIMALDATA", "numequals 0"],
["0x02 0x0500", "NOT DROP 1", "MINIMALDATA", "numequals 5"],
["0x03 0x050000", "NOT DROP 1", "MINIMALDATA", "numequals 5"],
["0x02 0x0580", "NOT DROP 1", "MINIMALDATA", "numequals -5"],
["0x03 0x050080", "NOT DROP 1", "MINIMALDATA", "numequals -5"],
["0x03 0xff7f80", "NOT DROP 1", "MINIMALDATA", "Minimal encoding is 0xffff"],
["0x03 0xff7f00", "NOT DROP 1", "MINIMALDATA", "Minimal encoding is 0xff7f"],
["0x04 0xffff7f80", "NOT DROP 1", "MINIMALDATA", "Minimal encoding is 0xffffff"],
["0x04 0xffff7f00", "NOT DROP 1", "MINIMALDATA", "Minimal encoding is 0xffff7f"],
["Test every numeric-accepting opcode for correct handling of the numeric minimal encoding rule"],
["1 0x02 0x0000", "PICK DROP", "MINIMALDATA"],
["1 0x02 0x0000", "ROLL DROP 1", "MINIMALDATA"],
["0x02 0x0000", "1ADD DROP 1", "MINIMALDATA"],
["0x02 0x0000", "1SUB DROP 1", "MINIMALDATA"],
["0x02 0x0000", "NEGATE DROP 1", "MINIMALDATA"],
["0x02 0x0000", "ABS DROP 1", "MINIMALDATA"],
["0x02 0x0000", "NOT DROP 1", "MINIMALDATA"],
["0x02 0x0000", "0NOTEQUAL DROP 1", "MINIMALDATA"],
["0 0x02 0x0000", "ADD DROP 1", "MINIMALDATA"],
["0x02 0x0000 0", "ADD DROP 1", "MINIMALDATA"],
["0 0x02 0x0000", "SUB DROP 1", "MINIMALDATA"],
["0x02 0x0000 0", "SUB DROP 1", "MINIMALDATA"],
["0 0x02 0x0000", "BOOLAND DROP 1", "MINIMALDATA"],
["0x02 0x0000 0", "BOOLAND DROP 1", "MINIMALDATA"],
["0 0x02 0x0000", "BOOLOR DROP 1", "MINIMALDATA"],
["0x02 0x0000 0", "BOOLOR DROP 1", "MINIMALDATA"],
["0 0x02 0x0000", "NUMEQUAL DROP 1", "MINIMALDATA"],
["0x02 0x0000 1", "NUMEQUAL DROP 1", "MINIMALDATA"],
["0 0x02 0x0000", "NUMEQUALVERIFY 1", "MINIMALDATA"],
["0x02 0x0000 0", "NUMEQUALVERIFY 1", "MINIMALDATA"],
["0 0x02 0x0000", "NUMNOTEQUAL DROP 1", "MINIMALDATA"],
["0x02 0x0000 0", "NUMNOTEQUAL DROP 1", "MINIMALDATA"],
["0 0x02 0x0000", "LESSTHAN DROP 1", "MINIMALDATA"],
["0x02 0x0000 0", "LESSTHAN DROP 1", "MINIMALDATA"],
["0 0x02 0x0000", "GREATERTHAN DROP 1", "MINIMALDATA"],
["0x02 0x0000 0", "GREATERTHAN DROP 1", "MINIMALDATA"],
["0 0x02 0x0000", "LESSTHANOREQUAL DROP 1", "MINIMALDATA"],
["0x02 0x0000 0", "LESSTHANOREQUAL DROP 1", "MINIMALDATA"],
["0 0x02 0x0000", "GREATERTHANOREQUAL DROP 1", "MINIMALDATA"],
["0x02 0x0000 0", "GREATERTHANOREQUAL DROP 1", "MINIMALDATA"],
["0 0x02 0x0000", "MIN DROP 1", "MINIMALDATA"],
["0x02 0x0000 0", "MIN DROP 1", "MINIMALDATA"],
["0 0x02 0x0000", "MAX DROP 1", "MINIMALDATA"],
["0x02 0x0000 0", "MAX DROP 1", "MINIMALDATA"],
["0x02 0x0000 0 0", "WITHIN DROP 1", "MINIMALDATA"],
["0 0x02 0x0000 0", "WITHIN DROP 1", "MINIMALDATA"],
["0 0 0x02 0x0000", "WITHIN DROP 1", "MINIMALDATA"],
["0 0 0x02 0x0000", "CHECKMULTISIG DROP 1", "MINIMALDATA"],
["0 0x02 0x0000 0", "CHECKMULTISIG DROP 1", "MINIMALDATA"],
["0 0x02 0x0000 0 1", "CHECKMULTISIG DROP 1", "MINIMALDATA"],
["0 0 0x02 0x0000", "CHECKMULTISIGVERIFY 1", "MINIMALDATA"],
["0 0x02 0x0000 0", "CHECKMULTISIGVERIFY 1", "MINIMALDATA"],
["Order of CHECKMULTISIG evaluation tests, inverted by swapping the order of"],
["pubkeys/signatures so they fail due to the STRICTENC rules on validly encoded"],
["signatures and pubkeys."],