Merkle trees have a wide number of uses in computer systems today, and we'll talk about some of them here.
The use of Merkle trees in technology blockchain it is vital. Thanks to its use, the client software can download the entire history of the blockchain and verify it hot. In fact, its use facilitates the process by allowing “prune”(Take only part of the history) the history and reduce the size of the download.
For example, a user who wants to install a Bitcoin client does not have to download all the history of the blockchain. Instead, you can reduce your download to just a few hundred or thousands of blocks behind. This way, you have access to a lighter version of the history that better meets your requirements.
Contrary to what you may think, this does not detract from the client's security. Well, thanks to the Merkle tree, it is possible to download a specific "root hash" and from there start creating a history. Since that "root hash" is related to the blocks before it, all you have to do is verify it. To do this, you can go to a series of complete Bitcoin nodes (with all the history) and verify that the "root hash" taken matches. Having absolute consensus on this point, the "root hash" is given as valid. And from that point on, the user can perfectly use their new Bitcoin client node.
Another utility that we can see from Merkle trees is reflected in file systems. A file system is a data structure that an operating system uses to keep track of the files it stores. Normally this structure is applied on a hard disk and even inside the memory cards that our smartphones use.
Some of these peculiar creations make use of Merkle trees in order to manage and guarantee the correct use of the stored data. Special cases of mention in this group are file systems ZFS y Btrfs.
ZFS known as Zettabyte File System, is considered in the computer world as the best filing system. His abilities far exceed his best-known opponents as NTFS, FAT:, exFAT o ext3 / 4. It has resistance to failures, recovery and correction of errors, de-duplication of data, replication, copy-on-write (CoW) and high scalability. All this makes it a perfect option to be deployed in critical environments. Designed by Sun Microsystems and introduced in 2004, it is currently the leader in computer file systems.
But to achieve this ZFS has a secret tool in the middle of all its code: the extensive and intensive use of Merkle trees. All this in order to have a system that allows rapid verification of the data stored within its structures. Its error recovery, de-duplication, CoW (Copy-On-Write) and replication properties strongly depend on this technique, otherwise it would entail a high computational cost that would undermine its advantages.
Version control systems
Another use of Merkle trees can be seen in software versioning systems, well-known cases of Go y Mercurial. Of both, the most widely known in Git, the same that enables the operation of platforms such as Gitlab y Github, or the development of the Linux kernel, the latter was the first project to use it in production, since the creator of Git is Linus Torvalds.
The use of Merkle trees in this type of software is related to the change tracking system within the repository or workspace where the files are stored. In this way, each change made (new blocks of data) goes through a hashing process that, when going through all the content of the repository, generates a unique hash of said workspace, which is called commit.
This marking system allows us, for example, to go to a specific commit to see what the status of the project's code was at a certain time, while the general status of the project remains intact. Seeing it in a simpler way, Merkle trees in Git allow us to create a kind of time machine, which allows us to navigate through the different commits of the project, keeping the files and their changes as they were at that particular moment.
A utility that is very useful when designing software in high traffic and distributed work environments, as Linus Torvalds has not demonstrated in his great Linux kernel project.