Noob guide to MAST
Hey fellow noobs. I thought I'd write up a quick rundown of what MAST exactly is to the best of my knowledge so that we can all become more informed investors. Also all of you people smarter than me, please clue us in if I missed anything or want to add anything.
What Does MAST Stand For?
Merkelized Abstract Syntax Trees
How Will MAST Affect Litecoin?
It'll increase its speed, scalability, privacy.
What Will Mast Do Exactly?
MAST will allow nodes to interact with “Merkle Trees” created within the LTC blockchain. Below is a recreation from Jeremy Rubin’s paper (referenced in the source section) of what a Merkle Tree is:
Top Layer: ABCDz=ABz+CDz
Mid-Layer: ABz=A+B CDz=C+D
Bottom Layer: A B C D
*A, B, C, D are all data.
*z is called a Merkle Root
Nodes read the top of the Merkle Tree along with the Merkle Root. It can check the whole tree to see if the specific data that’s being requested is actually somewhere in the Merkle Tree. In other words, the Merkle Root “z” allows you to see that the transaction ABz occurred. The cool thing about Merkle Trees is that it ONLY reveals that information. It does not need to reveal that CDz was also part of the Merkle Tree. This is the increased privacy that MAST provides.
What's a Merkle Root?
Before we talk about the Merkle Root, let’s talk about what a hash is. “A hash is data that is scrambled and condensed into a short and seemingly random string of numbers. This string of numbers can’t be used to reproduce the original script. But if you have the original script, the hash can be reproduced.” -Aaron van Wirdum https://bitcoinmagazine.com/articles/the-next-step-to-improve-bitcoin-s-flexibility-scalability-and-privacy-is-called-mast-1476388597/ If this sounds familiar, it should. This is what Pay to Script Hash (P2SH or multisig wallets) use. Therefore, a Merkle Tree is a data structure that has hashed out different data into a single, compact hash called the Merkle Root. Merkle Root can’t recreate the data in the Merkle Tree but it does verify that the requested data is in fact somewhere in the Merkle Tree.
Why Is This Relevant?
MAST allows for smart contracts (midlayer stuff in the diagram above) to be created on the LTC blockchain without clogging it up. Normally all smart contracts would be readily visible on the blockchain and it would take up a lot of space. MAST allows for privacy by only revealing the smart contracts that have been completed and also saves space on the chain because nodes will only read the top layer of the Merkle Tree. This process is similar to the SegWit process.
Also here is an application of MAST in regards to multisig contracts from the github (shoutout to /u/wummm for the rec):
"With MAST, large and complex multi-signature constructs could be flattened to many simple CHECKMULTISIGVERIFY conditions. For example, a 3-of-2000 multi-signature scheme could be expressed as 1,331,334,000 3-of-3 CHECKMULTISIGVERIFY, which forms a 31-level MAST. The scriptPubKey still maintains a fixed size of 34 bytes, and the redemption witness will be very compact, with less than 1,500 bytes."
Tying It All Together
Let’s say Alice decides to deposit 1 LTC into an address with MAST. She can create several spending conditions (smart contracts) to be executed: 1) Alice signs transaction 2) Barry and Chels both sign it 3) If 5 hours pass and Chels signs it, it is valid.
All of these spending conditions are hashed (turned into a Merkle Root) and combined into a Merkle Tree. Now let’s say scenario 1 is executed. Only Scenario 1 will be included in the blockchain, not Scenario 2 or 3.
You will now be able to write and execute smart contracts on the LTC blockchain. If this sounds familiar, it should. This is Ethereum’s one of two distinguishing factors. The other one is its access to a Virtual Machine (VM). LTC will also obtain access to a VM through RootStock (RSK).
LTC will be faster, avoids scalability issues for the foreseeable future, and brings increased privacy to its users.