Select Page

Understanding Blockchain Technology Part 2/4 – Cryptography

written by FuturisticLawyer
September 3, 2020

Bitcoin uses the SHA-256 cryptographic hash algorithm to encrypt information and keep it secure. SHA-256 was created by the US National Security Agency in 2001.[1] You can take input of any length through SHA-256 and the algorithm will almost instantly generate a unique hash, a hexadecimal number consisting of 64 digits. You can try it by clicking here: https://www.movable-type.co.uk/scripts/sha256.html.

SHA-256 uses the hexadecimal number system which uses the base of 16. This means that 0-9 is presented as we know the numbers from the base 10 number system, but 11-15 is presented with a-f. It is practical to use hexadecimal numbers, so e.g. 10 can be distinguished from 1 0. Just like an infinite combination of inputs can be put through SHA-256, the algorithm can produce a virtually infinite number of hashes. The number of possible hashes is 2256 or 1.16×1077, approximately 5 billion times bigger than the numbers of atoms in our galaxy. [2]

Four properties of the cryptographic hash function can be noticed. It is:

Deterministic: The same input will produce the same output every time.

Random: Even a slight change in the input to the algorithm, changes the output completely.

One-way function: There is no way of tracing the input value by its output.

Collision resistant: It is extremely unlikely to find two pieces of data with identical hash values.

The Use of Hashing in Blockchain Technology
As the name gives away, a blockchain consists of a chain of blocks. Each block contains transaction data. Hash numbers are used to make transactions uniquely identifiable – much like digital fingerprints.

Each block is also assigned a unique hash number and includes a reference to the previous block’s hash number as well. Because the output of the cryptographic hash algorithm is random – the output changes completely with even slight changes in the input – the network of nodes can easily detect if anyone tries to tamper with the data on the blockchain, as all the hashes will change. The hash function makes it practically impossible to “steal in broad daylight” by making any changes to the transaction history.

Every block consists of somewhere around 1.500 and 3.000 transactions.[3] When you sent bitcoins, the transaction is broadcasted on the blockchain network and verified by the nodes. The transaction is then assigned a hash value and grouped with other transactions by the nodes in a Merkle Tree. A Merkle Tree is created by repeatedly hashing the pairs and groups of transactions in the block until the Merkle root of the block is found.

The Merkle root then forms a part of the block header, which is a summary of all the data on the block. The block header contains the Merkle root, the previous block hash, a version number used to track software and protocol updates to the blockchain, along with a timestamp, a difficulty target, and a nonce[4], which we will take a closer look at in the next post. All this information is then hashed twice through SHA-256 to form the block hash, which is the unique identifier or the digital fingerprint of the block. Because the cryptographic hash algorithm is deterministic – the same input generates the same output every time – the block hash can easily be confirmed by other nodes by hashing the block header twice.

In this way, every bitcoin transaction beautifully forms a small part of the final block hash, which forms a part of the previous block hash in a long chain of all transactions that have ever occurred. If anyone tries to tamper with a transaction all the hash numbers would change all the way down to the genesis block, the initial opening block of the chain.

****************************

[1] http://billybitco.in/ (opened 06-08-2020).

[2] https://educationblog.oup.com/secondary/maths/numbers-of-atoms-in-the-universe (opened 06-08-2020).

[3] See e.g. https://www.blockchain.com/explorer?utm_campaign=dcomnav_explorer.

[4] https://www.oreilly.com/library/view/mastering-bitcoin/9781491902639/ch07.html (opened 30-08-2020).

Related Posts

Comments

0 Comments

Submit a Comment

Your email address will not be published. Required fields are marked *