Cryptography 2: Irreversibility and Cryptographic Hashing on the Blockchain

Carla Gatt
BLOCK6
Published in
5 min readMay 28, 2022

Cryptographic hash functions have many variations and are strong barriers to outside attacks. Blockchain requires complex cryptography to make sure that keys and digital wallets are kept safe from hackers.

A private key and a public key and a bitcoin address together with the principle of irreversibility

In the previous blog post, we looked at the history of cryptography as well as symmetric and asymmetric cryptography. So how do cryptographic hashes work?

Let’s consider the example of colour mixing below and the principle of irreversibility. This principle is also behind the way blockchain functions.

Mixing Colours and Irreversibility: Leading the way to Cryptographic Hashing!

So Anna needs to send Billy a transaction. They both choose the colour blue as the base key.

base key-the colour blue

The Base Key- Blue

Anna needs to pick a colour for her private key. Anna puts on a blindfold and randomly picks a pallet. A random choice makes it harder for the attacker to guess what she has chosen. Her random choice falls on the colour red. So red is the choice of her private key. Her private key is to be shared with no one — not Billy, not her mother, and not even her husband. She needs to keep it secret.

Anna’s private key- Red

Anna’s private key- Red

Anna now needs the public key, which is generated from the base and private keys. She mixes the colour of the base key and the private key, which generates a brown colour.

So, the brown colour is the public key. This key can be seen by external viewers. More importantly, there is no way that the public key can help identify Anna’s private key. Why is this so?

Red and Blue- Brown

Anna mixes her private key with the base key and the result is the public key.

Brown= The Public Key

It is not possible to unmix colours. And this is precisely how the blockchain works. The system can only move forward but it is irreversible. It is unable to move backward. Even though the attacker might have the base colour and the public key, there is no way they can identify Anna’s private key.

Anna prepares a message. The colour of the message is yellow, and she signs this message using her private key and the colour of the message. Thus, she signs it by mixing red and yellow. The colour of the signature is orange. She then sends the message in yellow and the signature in orange over to Billy.

Yellow is the colour of the message

Colour of the message- Yellow

Yellow and Red = Orange

Colour of the message + Colour of Anna’s private key= Signature

Colour of Signature = Orange

What does Billy do? Billy first verifies the signature against the message. There are two ways to do this more securely. First, he mixes the message with the public key: Yellow and brown. This yields a lightish brown colour. He then mixes the signature with the base key- orange and blue. The result is the same lightish brown colour. Since these are both equal, it means they are valid. If they are not equal, Bob would have to discard the message.

Colour of Public Key + Colour of Message= Verification

Colour of Signature+ Base key= Verification

If someone tries to mess or tamper with the message, for example; by changing the yellow colour to another colour whilst the message is ‘en’ route to Billy from Anna, the yellow would be different and the two colours would not match. Thus, Anna would receive a denial of service but won’t lose her money.

If you still find all this confusing, you can watch this Foo Café’ video where engineer, Amadeusz Pawlik, explains the concept of key encryption through colour mixing.

Cryptographic Hashing and The Blockchain

A cryptographic hash is also irreversible. Any plain text information can be put through a hashing algorithm and turned into a unique string of text. It is not legible though, and more importantly, it has no meaning.

Example: “Hello” can be turned into the sha1 hash that reads: “f7ff9e8b7bb2e09b70935a5d785e0cc5d9d0abf0.”

Since the cryptographic hash is irreversible, you cannot look at a hash you haven’t seen before and conclude what the original data was.

Just like the verification of colour at the end, if data is changed along the way, users can tell by comparing it to the final hash. However, hackers have found ways to grab a lot of hashes and then compare them to hashes from common words and phrases. If they find a match, then they know what the hash represents.

With cryptographic hashing, a hash algorithm can take data of any length or size and record it as a limited, uniform set of text. When a transaction is verified, it goes through a hash algorithm, and the new hash is then added to the blockchain. This new unique hash goes through the hash algorithm and another new unique hash is then added that records both hashes from the original transactions.

This way, hashes continue to be combined into new hashes where the footprint of the original is still accessible. Thanks to cryptographic hashing, security is added to the blockchain as blockchains record root hashes with each transaction securely coded within them. If the data is tampered with from any part of the blockchain, this will result in a completely different hash at the root. Users can realise that the data has been compromised by comparing that root hash to the root hash on their computer.

Limitless transactions can take place because of cryptographic hashing. Therefore, blockchains can be scalable.

Just like colour mixing, cryptographic hashing is irreversible so no one can undo transactions. This process ensures their safety from adversarial attacks and ascertains those users can rely on the accuracy of the digital ledger.

Conclusion

Blockchain is built on cryptography. It allows users to encrypt their data, send cryptocurrency safely and record transactions over time. It enables decentralisation and ensures more blocks can be added without limit.

It allows scalable transactions while keeping them safe from attackers, thus making them verifiable.

Contents distributed by Learn.Block6.tech

👉 Telegram — Fresh ideas

👉 Twitter — Latest articles

👉 LinkTr.ee

--

--

Carla Gatt
BLOCK6
Writer for

A content writer who is passionate about fintech, Defi, and blockchain. Check out my portfolio: https://carlafgatt.journoportfolio.com