4

So, somebody asked me about MAST yesterday.

Apparently, it's formalized in BIP114 – Merkelized Abstract Syntax Trees.

I couldn't explain what it was and what advantages it'll bring us.

What are MAST, and how will they help with scaling?

3

From what I've read and heard about MAST, it's an alternate version of pay-to-script-hash that uses a Merkle root instead of a regular hash digest. It combines this idea with that of an abstract syntax tree, which is a data structure that compilers use to parse source code. By "Merkelizing" a syntax tree, it allows redeemers to only expose the parts of the script being used for redemption.

This means that you can have more complicated scripts than are currently allowed by the 10,000 byte or 201 OP code limit. Let's say there's a redemption script whose conditions look something like this:

A OR (B AND (C OR D)) OR ((E OR F OR (G AND H)) AND NOT I)

Right now, this script would be too complicated to fit inside the limit. By forming it into a syntax tree and Merkelizing it, a redeeming transaction would only have to expose the conditions that were met. For example, just A would redeem it, and so would just B and C. This fits inside the size limit, while also never revealing the unused conditions that could have been used to redeem the UTXO. There's a complexity gain without introducing the risk of DOS attacks, as well as a privacy gain.

I'm unsure how this will directly help with scaling, but since it allows for more complex scripts without a transaction size increase, it certainly won't hurt. It's just another building block at the disposal of a developer, which they can then hopefully use to solve some future problem.

| improve this answer | |
  • Nit: a NOT condition in a script directly below an AND/OR tree makes no sense. If I is not allowed to sign, he just won't sign :) – Pieter Wuille Nov 3 '16 at 19:18
  • @PieterWuille, you caught me! I just thought I needed a NOT in there somewhere ;-b – Jestin Nov 3 '16 at 19:20
  • @PieterWuille, also, for the record, nobody would ever have to know that particular branch was there...which is sort of the point :) – Jestin Nov 3 '16 at 19:23

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.