MAST with OP_EVAL and OP_CAT

MAST with OP_EVAL and OP_CAT
From: jl2012 @ 2015-09-10 17:18 UTC (permalink / raw)
  To: bitcoin-dev

Inspired by Pieter's Tree Signatures, I believe Merkleized Abstract 
Syntax Trees (MAST) could be implemented with only OP_CAT and OP_EVAL 
(BIP12).

The idea is very simple. Using a similar example in Pieter's paper,

scriptSig = <sig> <serialized sub-script 10> Z1 0 1 1 X6 1 K9 0 
<serialized script>
scriptPubKey = DUP HASH160 <hash serialized script> EQUALVERIFY EVAL
serialized script = 8 PICK SHA256 (SWAP IF SWAP ENDIF CAT SHA256)*4 <R> 
EQUALVERIFY EVAL

This will run the 10-th sub-script, when there are 11 sub-scripts in the 
MAST

I think this is the easiest way to enable MAST since the reference 
implementation for BIP12 is already there. We could enable OP_CAT only 
inside OP_EVAL so this will be a pure softfork.

Ref:
Tree Signatures: https://blockstream.com/2015/08/24/treesignatures/
BIP12: https://github.com/bitcoin/bips/blob/master/bip-0012.mediawiki


 permalink raw reply	[|nested]