Merkle Trees – Data Representation in Bitcoin

Published by Mario Oettler on

Last Updated on 3. May 2023 by Martin Schuster

So far, we assumed a block consists of transaction data and some header data like timestamp, nonce, difficulty, etc.

Those data form the input of the hash function with which the block hash is calculated. However, the transaction data is packed in a data structure called Merkle tree. Instead of every transaction only the root of this tree (or top hash), the Merkle root, is taken as hash input.

For every block, a new Merkle tree is created taking those transaction into account that are part of the block.

In the figure above you can see that the Merkle root becomes part of the block header.

In the following, you will learn how to construct a Merkle tree. A Merkle tree is (typically) a binary hash tree where each node has two child nodes.

You can try out our tool for Merkle Trees here.

Construction starts from the bottom with the leaves. They contain the plain transaction data. Then they are individually hashed (H=H(TX1)). Those hashes are then concatenated pairwise. And each pair is the input for the next hash. This pairwise hashing goes up until only one hash is left. This is the Merkle root or top hash of the Merkle tree.

The figure below shows the construction of a Merkle tree with eight transactions.

Categories:

https://blockchain-academy.hs-mittweida.de/wp-content/uploads/2021/04/logo_bcam_rgb_gross.png

Welcome

Blockchain Academy

Continue with credential

No account yet?

Powered by Hidy

Register with Hidy


Register
Sign in

We need the following credential to register:

please select:

To create a new account, we need the following data from you:

We would appreciate the following additional information from you for the creation of your account:

Welcome

Blockchain Academy

Continue with credential

Already have an account?

Powered by Hidy

Sign in with Hidy


Register
Sign in

We need the following credential to log in:

please select: