Podcast
Root Causes 348: What Is a Merkle Tree?
Hosted by
Jason Soroko
Fellow
Original broadcast date
December 15, 2023
One foundational element of modern cryptographic systems is the Merkle tree. Merkle tree is an enabler of blockchain and CT logs, among other things. We explain this data structure, its properties, and its use cases.
Podcast transcript
Lightly edited for flow and brevity.
TCTim CallanWe have spoken in the past on a number of episodes about blockchain. And one of the aspects of blockchain from a technology or I don’t know if want to say a mathematical perspective is that it is based on a structure called a Merkle Tree. And today, we thought we would explain what is a Merkle Tree.
TCTim CallanYes. You’re right. It is more than blockchain for sure. CT logs are another example and just Merkle, just if anybody is looking it up, that is M‑e‑r‑k‑l‑e. It’s a data structure. And go ahead, Jay. Tell us about Merkle Trees.
It’s not used for the same thing. It is essentially a one-way tree. It is a one-way data structure. You only really ever add to it. So, that’s true. Same thing for blockchains, etc., but it’s used for kind of different purposes and it’s ideal when you have a large, large - what will eventually become a large dataset. So, a Merkle Tree needs to have this property - - if you are trying to solve the problem of a very large dataset that will grow through time, large and complex, and you need for every data item stored in the data structure, if you need to ensure that those blocks of data within the data structure have to be guaranteed to be received undamaged, unaltered and to also make sure that people who are adding – when I say people I mean systems – that are adding data to the Merkle Tree cannot be lying and sending fake blocks of information into the data structure and so how do achieve that? And the way to achieve that, Tim, is we gotta go back to a good ‘ol cryptographic primitive – hashing.
Hashing is really at the heart of the Merkle Tree. And, in fact, a Merkle Tree is in a data structure sense a hash tree. Right? And what the means is that every single block of data within this data structure has been hashed with something and what that hash is depends on what kind of a data block we are talking about here. Because when you are talking about a tree structure, there’s obviously a root to the data structure. There’s an initial block and then every single other block after that will typically have another two blocks assigned to it as children and then on and on and on like that. And so, this is essentially a way for the labeling of every single one of these blocks of information. There’s an associated label which is a hash of the actual block itself and those blocks are basically added upon. Right? So, in other words, every single hash after that is related to the parent within the tree.
TCTim CallanRight.
And that’s why you call it a hash tree is because essentially you are hashing through a set of parents and children all the way up to a root.
TCTim CallanSo there is unalterability as part of this. Presumably there is some kind of trustworthy mechanism where things are added to the Merkle Tree and so, there also is an aspect of the fact that the new blocks that are added are themselves coming from a known source for want of a better word. I’d say a trusted source. And all of that is sort of built into the structure. Is that correct?
But, let’s just talk about the use cases for a moment because I think those are what are most interesting.
TCTim CallanSure.
One of the other important aspects of a Merkle Tree is it can be made public. Because it is unalterable, it can be made public so other people can read it and the ability to glean information off of that non-stop stream of truth can get you a lot of good things such as, hey, were any domains that I own issued with a certificate in the past year or two? Well, you can look up the Merkle Tree CT log and see whether that was true or not. And if something does pop up that you don’t expect, you can raise the alarm bells and do what you need to do to help protect yourself. Whether it’s revoking a certificate or just investigate what the heck is going on.
I would say, Tim, that I would imagine that for other PKI issuance topics in the future, I don’t think we’ve seen the end of the usage of Merkle Trees.
TCTim CallanIt’s interesting that it’s got those properties that turn out to be very valuable in certain aspects and your CT log example is such a great one. Are there other places that people use Merkle Trees in production systems that we would understand?
TCTim CallanSure. IPFS. We’ve discussed that in the past. Is that a Merkle Tree-based strategy?
If you are going to put a trusted stream of data and I’m talking about a growing data structure, a data structure that is going to grow through time and that needs to be publicly available and trusted amongst peers, this kind of data structure just is kind of ideal.
TCTim CallanYeah. I also found it interesting what you threw out in the beginning which is that there is a patent on this.
TCTim CallanSo, I don’t know if that patent is just not being enforced because you would think that you wouldn’t build massive entire strategies like things on CT logs on something where there is some kind of potential patent liability.
TCTim CallanWell, anyway. So, that’s probably good for today. A nice, short and sweet explanation. You know, it is a thing that comes up. People talk about it; we throw around this word Merkle Tree and we thought it would be worth our while to explain what does that mean when we say that.
TCTim CallanProbably will.