Subject: [Bitcoin-development] Opcode whitelist for P2SH?

From: John Dillon <[email-masked]>
Date: Sun, 28 Jul 2013 19:39:08 +0000

Peter Todd recently came up with two related, and IMO very good, uses for
non-standard transactions to implement both oracles and one-time-password
protection of wallet funds. While the wallet fund case could be implemented as
only a single standard type, at the cost of generality, the oracle case would
be most useful with more arbitrary rules. More generally it is also useful to
be able to have scriptPubKeys like the following:

    n <pubkey>...<pubkey> m CHECKMULTISIG <master pubkey> CHECKSIG BOOLOR

and many other similar constructions.

What are your thoughts on creating a whitelist for specific opcodes that would
apply to scripts serialized using P2SH, retaining the existing standard
whitelist for scriptPubKeys? (I would still recommend dropping pay-to-pubkey
and pay-to-multisig due to their potential for dumping data in the UTXO set)

I'm thinking it should contain the following opcodes, picked for either being
already used, or having simple semantics:

0 to 75 byte pushdata
PUSHDATA1

1NEGATE
OP 1 to OP16 (numbers are allowed through pushdata anyway)

IF
NOTIF
ELSE
ENDIF
VERIFY
RETURN

TOALTSTACK
FROMALTSTACK (the alt-stack makes stack manipulation in complex ways possible)
DROP
DUP
SWAP

EQUAL
EQUALVERIFY

0NOTEQUAL
BOOLAND
BOOLOR

RIPEMD160
SHA1
SHA256
HASH160
HASH256

CHECKSIG
CHECKSIGVERIFY
CHECKMULTISIG
CHECKMULTISIGVERIFY

Note how this list allows for complex logic, but does not allow for arithmetic,
thus not exposing us to a source of problems in the past.