What is MAST?

By Casey Burgwald/

While blockchain technology, the underlying framework of almost every cryptocurrency project, is very impressive and useful by itself, it’s still in its infancy both in terms of adoption and development. Many newer projects boast additional features beyond the basic security and immutability of blockchain tech, some with enhanced security, extremely low transaction times, or something called smart-contracts.

Traditional currencies have always been limited by their nature. Even when managing fiat currencies in a bank account via a phone or computer, the underlying transactions are still movements of digital representations of physical funds. For this reason, any escrow-based transactions (where a third party keeps a set amount of funds in custody until completion of an agreement or “contract”) require the involved parties to trust a third-party holding the escrow account. The escrow-holding party acts as a centralized, trusted entity to first verify that the paying party has relinquished the promised amount, then to disburse the promised amount to the payee(s) upon verification of fulfillment of the contract (and they invariably take a small fee for this service).

Escrow companies exploit this fundamental flaw in the capabilities of traditional money. With blockchain technology, centralized third-parties for executing agreements and transferring funds are no longer required. With so called “smart contracts” two parties can enter an agreement written into the publicly verified ledger, wherein the funds can be locked in a decentralized, trustless “escrow account” until the requirements of the agreement are fulfilled, when the funds are released to the appropriate party or parties. All without the need of a “trusted” third part or escrow fees.

Several newer blockchain-based projects already have complex smart contract capability built into their platforms, but many of the original projects (Bitcoin and Litecoin among them) weren’t developed with complex contracts as a specific intention. Fortunately, one of the best features for entirely digital currency ecosystems is that they can be upgraded with little to no impact on the users (when done correctly).  MAST is one of those upgrades – one that will aid in the implementation of smart-contract capabilities on the Litecoin blockchain.

MAST stands for Merkelized Abstract Syntax Trees. The idea behind the implementation of these “abstract” or “separated” syntax trees is to allow more complicated and more private contracts to be written on the blockchain while taking up less size on an individual block.

To accomplish this, the Merkle tree combines multiple sets of data into a single, smaller output called a Merkle root. As with other cryptographic hash functions (including the technology that keeps blockchains secure and the basis of proof-of-work mining), the submitted contract data along with everyone else’s data is combined into hash function input (a Merkle tree) and processed through the cryptographic function to create the output (Merkle root). The key feature of Merkle trees is that the output or “Merkle root” can be used to verify any given portion of the input without knowing the entire Merkle tree.

As an example, say the following smart contract is submitted to the Merkle tree: “Jane sends Dave 10 LTC IF Dave finishes condition X first OR Jane sends Bob 10 LTC IF Bob finishes condition X first. If neither Dave or Bob finish condition X by time Y, 10 LTC is refunded to Jane.” This data is combined with dozens or hundreds of other sets of data and hashed through a Merkle tree, resulting in a much smaller Merkle root that is published in the blockchain. This means that both parties can verify the transaction since, as stated previously, the Merkle root can be used to validate a portion of the input data provided input data is known, but the rest of the input data would be, for all intents and purposes, undecipherable for anyone who didn’t know a specific section of the Merkle tree. This provides both immutability and a certain level of anonymity for Jane, Dave and Bob. All without needing a trusted third party and while occupying less size on a given block.

It is important to understand that Bitcoin and Litecoin transactions are already very simple contracts. Essentially, when one party sends some amount of coins to another, those coins are locked into the payee address using a script. The specific transaction type that will be used for MAST is Pay to Script Hash, or P2SH, where the original script is omitted from the transaction output – only the hashed, seemingly random output of the script is included. For base P2SH, the only way to verify the output is to re-hash the original script (or a portion of a complex script) and check it’s hasha against the originally submitted output. Continuing the example provided above, any one of the following three results can occur:

  1. Dave completes condition X before Bob and before time Y. 10 LTC are sent to Dave.
  2. Bob completes condition X before Dave and before time Y. 10 LTC are sent to Bob.
  3. Neither Dave nor Bob complete condition X before time Y. 10 LTC are sent to Jane.

To be clear, MAST is not what allows for the implementation of smart contracts, but it does leverage the benefits of P2SH and Merkle trees to allow for larger, more complex scripts to be recorded on the blockchain in smaller Merkle roots. With the MAST upgrade, multiple and complex conditions can be defined for spending coins in the effective “escrow account”, and not all of the conditions have to be met for the network to confirm a valid transaction order, all while the Merkle root significantly reduces the size required for recording on the blockchain.

Overall, MAST allows complicated smart contracts to be scaled down significantly and published in a more private manner, contributing significantly to the usability, scalability, and anonymity of the already impressive Litecoin platform.

Scroll to top