In order for a message to be trustworthy, It needs to be verifiability secure without having to go back to the sender and check. Bitcoin found use in the SHA-256 Hashing Function for sending messages securely. SHA stands for Secure Hashing Algorithm, While there are a number of different variations on SHA such as SHA-1 and SHA-512 this explanation will focus on SHA-256 and its Hashing Algorithm.
What is a Hash Function and why does it help?
Simply put a hashing function is an equation which turns an input to an output and if it’s done right the output can be used as a digital signature. Let’s say we have a hashing function which reverses the input it receives. If we enter “Bitcoin” we get “nioctiB”. Pretty simple, however notice this is not encrypting the message, simply hashing it. Hashing and Encrypting are two distinct processes.
Hashing gets more complicated when we look at the requirements for a more secure and practical hashing function.
- The hashing function must be fast and produce an output that is easily verifiable by any computer but impossible for the computer to discover the input given the output.
Fixed size of output
- Regardless of the input the output must remain a fixed size. This is done by having a taking an input ( of any size ) and converting it into its 2 base ( binary ) counter part. Then it’s “Mathed” and a fixed output is produced.
Identical inputs should never produce the same output
- This is a security feature that stops reverse engineering the output and part of a preimage resistance measures.
The application of a hashing function is to be able to send messages from A to B securely even if a 3rd party can see what is being sent from A to B they will not be able to decipher it. SHA-256 utilises something called “asymmetric keys” or better known as Public and Private keys.
How SHA-256 works
- Each letter of the input is converted to binary
- The size of the binary phrase is calculated and added onto the end
- The binary block is then padded with 0s to make it the correct size of 512 bits
- This broken down into 16 words of 32 bits. 64 words are needed and the first 16 words are the base for this.
- w(17) or word 17 is generated by taking w(n-15) ( the word 15 places back from currently generating word ) and copying it 3 times shuffling them around and then repeating with w(n-2) and w(n-10), the the added combined result is w(17).
- Repeated until there are 64 words.
- The initial binary values are shuffled into the 64 “words” and then the result this is iterated over n amount of times.
- This is then the digital signature of the input!
If you want more details on how the hashing function works this video, starting at 2 minutes, will go into it in more depth. It’s the best brief explanation I could find on YouTube.
SHA-256 is very similar with its structure to other hashing algorithms like MD4, MD5 and SHA-1 as these are the predecessors of SHA-256.
I hope this has covered SHA-256 with enough depth. If you found yourself here I would highly recommend looking more into the cryptographic process and also feel free to let me know if I have miss stated or understood anything in this article.
List of Algorithms (1 Total)
List of SHA-256 Cryptocurrencies
Ethereum Classic (ETC)