The Blockchain as a Data Structure
Learn blockchain as a data structure to comprehend the cryptographic background in this lesson.
We'll cover the following
Overview
In the previous lessons, we considered the blockchain as a suite of technologies in order to outline its basic behavior. This lesson will introduces the blockchain as a data structure to comprehend the cryptographic background.
We’ll show how transactions are collected and integrated into blocks. Furthermore, we’ll show the structure of blocks that serve as basic elements of the blockchain. We’ll then show how these blocks are linked together to form a chain that guarantees a chronological order of transactions. As we shall see, hash functions and Merkle trees play a key role in the construction of blockchain-based systems, as their change-sensitive behavior results in a structure that immediately detects any manipulations of transaction data, as we’ll show in this section (
Aggregating transactions
Until this step, we’ve seen that each node is able to aggregate transactions and place them in groups called blocks, but we did not describe how this is done. A naive approach could be to store the incoming transactions in a list and to include them in a block then. But this approach has many disadvantages, i.e., it would be computationally expensive to verify if a transaction is stored in the corresponding block. There is also the need to store the transactions in a change-sensitive manner, so any change in the transaction data can be detected instantly and easily, even if only a single transaction has been changed.
Therefore, the transactions are stored in a Merkle tree, as introduced in this lesson. Figure 1 shows four transactions that are stored in a Merkle tree of depth two. As we can see, the leaves , and are computed directly as hashes of the corresponding transactions. Any node further up in the binary tree is then computed by concatenating and hashing its respective children, for example, . The procedure is repeated until the root of the tree is computed, which is a single hash reference of the whole transaction data.
Figure 1
Get hands-on with 1200+ tech skills courses.