What is Hash Cryptography?
Hash Cryptography is one of the main pillars of blockchains. SHA256, the cryptographic hash function in the Bitcoin blockchain makes it what it is, a securely linked chain of blocks. And in this two part series, we’re going to learn why. But before that.
What is the easiest way for us to uniquely identify humans?
“Just by looking at them” is not the answer. There are too many people with the same hairstyle, similar facial structure, skin tone and almost all other visual factors.
I’m going to save your time, and tell you the answer.
The easiest way to uniquely identify humans is by their fingerprints. Almost every human has a unique fingerprint. And this can (and is) used to uniquely identify us.
Fingerprints of Digital Documents?
What about digital documents? Or a text string. Or an Operating System? How to identify these uniquely?
The answer is same. Digital fingerprint.
Hash Cryptography helps us to find these digital fingerprints. You take a piece of information (could be a pdf, a text, or a movie), pass it through a cryptographic hash function and the output you will receive is the hash (or digital fingerprint) of that document.
In our previous post, we studied how the chain of blocks is linked using the Previous Hash field in the Bitcoin Blockchain. The Previous Hash and the Hash field are computed using a cryptographic hash function.
The cryptographic hash function used in this case is SHA256. SHA stands for Secure Hash Family, a family of many cryptographic hash functions like SHA256, SHA512, SHA1, etc.
SHA256 was developed by the NSA (National Security Agency) and the code was later made open source. The 256 in the name denotes the number of bits it takes in memory. It is a 64 character long hexadecimal hash where 4 bits represent each hexadecimal number.
In the Bitcoin Blockchain, the current hash is computed by giving the Data Field and the Previous Hash field as input to the SHA256 function, and the function returns the output i.e. the hash or fingerprint of the given data.
You can use the SHA256 or any modern cryptographic hash functions to find the hash (fingerprint) of any piece of information. You can find the hash of documents, strings, executables, binaries, movies, entire Operating Systems, etc. Play around with SHA256 hash function here.
An important property of cryptographic hash functions is that they are one way. That means, you can go from a document to a hash, but not recover a document from the hash. This is what makes hashes secure and protects the immutability of blockchains.
A good cryptographic hash function should have five important properties. We will cover these five properties in detail in Part 2, but you can watch a brief introduction to these properties in the video below.