SHA , stands for Secure Hash Algorithm and was developed by the National Institute of Standards and Technology (NIST) in association with the National Security Agency(NSA) both USA based entities and first published in May 1993 as the Secure Hash Standard.
WHAT IS A HASH
I would like to break this blog down into a more simple, layman type of explanation. The reason behind this is that Hash algorithms are a very complex and difficult subject matter to understand and grasp. This is true if you are reading a wiki explanation on this, or trying to attempt to grasp a technical blog.
I myself have had difficulty in trying to understand the majority of blog sites when it comes to SHA 256 Hash Algorithm. So let’s break it down, by using an analogy of a human beings fingerprint.
Fingerprints are a unique trait to every single human being on this planet. Fingerprints distinguish us from each other – it’s a unique identifier. We therefore can apply this concept and visualize that each digital document would have its own unique fingerprint.
A SHA 256 hash is made of up 256 bits of memory and is 64 characters long, known as the hash value. I would like you to click on the following link, as we are now going to see practically how the Hash value looks and works.
So please open up a separate browser and navigate to – https://demoblockchain.org/hash
Now notice under the block we have a unique code which represents the Hash of that block.
Take note of the first 5 and last 5 characters of the hash. Now start typing any random word/s into the block above it. Notice that as you start type, the hash function starts changing after each input of a letter.
Once you have finished typing your short sentence, notice now how you are left with a unique hash 64 character code the hash value, which is like a fingerprint to that sentence you have just typed. Now just remove one word from that sentence. What do you notice? The hash changes completely. There is no limit to the size of the document that you can input into the block either.
THE 5 REQUIREMENTS
So keeping with this practical example lets break down the five requirements for a Hash to be considered valid in the blockchain –
1. One Way
Hash is a one way function – it cannot be decrypted back.
This simply means that you can place a document inside the block and it will generate a unique hash. Remove the document and replace it with the exact same document again and notice the hash value is the same. So try this practically now on your demo hash page.
3. Fast computation
The hash function should be capable of returning the hash of an input quickly. If the process isn’t fast enough then the system simply won’t be efficient, meaning that as you type the hash is changing instantly in your practical example.
4. The Avalanche Effect
So we looked at earlier taking a sentence or even a paragraph and inputting it into the block. Notice how the hash changes completely when you say add a punctuation mark or take away a word in the document. Its analogy can be compared to an avalanche. It’s the changes made within the algorithm itself where a small change in the input results in a vast change of the output.
5. Must withstand Collisions
A Hash Collision Attack is an attempt to find two input strings of a hash function that produce the same hash result. Because hash functions have infinite input length and a predefined output length, there is inevitably going to be the possibility of two different inputs that produce the same output hash.
The hash function contains a 64 character hash value which does not have an infinite number of combinations. So with our fingerprint example, one in 60 million people would have the same fingerprints. That being said, for comparison, as of January 2015, Bitcoin was computing 300 quadrillion SHA-256 hashes per second. There still has not been a collision on the SHA 256 hash.
As mentioned in my previous blog past – The Origins of blockchain, the hash value will be adopted from the previous block and then generate its new hash for the current block, thus linking the blocks together cryptographically. Hash algorithms are a complex subject matter and by no means is this article going to satisfy those seeking a more complex explanation. Should you want to delve technically more into SHA 256, then I suggest this paper,
Chapter 1 – On the secure Hash Algorithm Family.