fbpx

H for Hashing

Anna Flach 25 February 2020

One of the key features of blockchain technology is being able to record large amounts of data in a compact form, and linking these pieces of information to one another in a chain.

These ties ensure the immutability of the network, as changes in any element would reflect on the full chain. The cornerstone of this function is hashing technology.

What is hashing?

A one-way hash function, also known as a message digest, fingerprint or compression function takes any data of arbitrary size and transforms it into a data of fixed size via a mathematical algorithm. For example, on the Bitcoin chain transactions go through a hashing algorithm (SHA-256) which gives an output of fixed length- 256 bits. If the data is smaller, the hashing algorithm packs it to reach the desired length, and if it is longer it cuts it down to this size.

Blockchain uses cryptographic hash functions, which have three properties that make them secure to use:

  1. X input creates to X hash value: it is not possible to make two different hashes from the same input, neither to have the same hash from two different inputs
  2. Changing the input changes the hash itself: as the input becomes different, the hashes automatically changes as well. This is called an avalanche effect.
  3. Hashes are irreversible: it is impossible to determine the original message from the encrypted format.

All of these qualities make hashes a safe and private cryptographic identifier of any data.

Hashes in blockchain seal each block of information and represent the current state of the chain. Each block is connected with the hash of the previous block. As the hash represents all the blocks connected before, it includes, by connection, the whole chain.

Merkle trees

In most blockchains, hashes are connected in a data structure called Merkle-tree. Merkle-trees are created by making pairs of hashes repeatedly, until there is only one hash left. They are made bottom-up from the hashes of individual transactions, or leaves.

The Merkle root is the one hash summarizing all of the data, at the top of the tree, and contains all of the hashes under it. The individual branches can be downloaded, but if modified the whole Merkle-tree, and root, changes.

Merkle-trees provide an efficient way to verify data, prove validity and requires little memory and computational power. They allow us to verify information just with a small portion of a dataset, without having to check all the other records. Therefore, Merkle-trees help to prove that all previous transactions from the blockchain are recorded, and the shared ledger is complete, unchanged, and in chronological order.

 

Blockchain and hashing

Hashing in blockchain technology fulfils 3 most important functions:

  • Fingerprint information in a secure, private and verifiable form
  • Connect data in an organized and immutable manner: hashing connects each block in a chronological order and adds tamper-evidence to the data
  • Provide additional security and privacy through cryptography: One-way hashes are infeasible to break by brute force and hide information.

Outside of blockchain, the one-way hash function is used often to effectively fingerprint information. This could be for later verification on hard-drives or online data, or for generating shared secrets like a Diffie-Hellman handshake. The one-way hash function can have other practical applications as well, such as secure password storage, file identification and message authentication code (MAC).

For some more mathematical background on hashing, we recommend you check out this step-by-step explanation from Blockgeeks: What is Hashing?.

Stay up to date with our latest insights on emerging tech, financial markets and blockchain - delivered straight to your inbox.

We promise - no spam. By submitting your details, you consent to your personal data being stored in our database.