This article is for those who would like to understand the technical angle to everything. We have taken a stab at making this topic simple and uncomplicated.
What is a Cryptographic Hash Function?
A cryptographic hash function is at the heart of cryptocurrency. It is a mathematical equation used for encryption. It is also the science behind encryption.
To understand cryptographic hash functions, it’s important that we first take a look at encryption and what it means.
Encryption is a method that’s adopted to protect information from hackers, criminals and just about anyone who might want to harm you on the internet. That’s why you have passwords for example.
How It Works
Encryption was used even before the advent of the internet. It dates way back to when kings in ancient times would want to send a message from one kingdom to another kingdom, but wouldn’t want an enemy kingdom to know what the message was if they were to lay their hands on it. To protect these messages, they’d use riddles, dabbled words or anything else that ensured that only the recipient kingdom was able to decode it.
There are two types of encryption: symmetric (passwords) and asymmetric encryption also known as public key encryption. We’ll get right down to that soon.
How Encryption Works in Cryptocurrency
Here’s a perfect scenario.
Jane wants to send a message to Daniel but does not want this message to be intercepted by a third party.
They decide to use asymmetric or public key encryption to protect their message. In this light, they both have a set of keys. Jane has a public and private key and Daniel also has a public and private key.
The public key can be known to anyone. However, as “private” implies, the private key is meant for the knowledge of only each person. It is one that they each must keep securely hidden.
Keep in mind that data that is encrypted with a public key can only be opened with a private key while data encrypted with a private key can only be opened using a public key.
So, when sending a piece of information to Daniel, Jane uses Daniel’s public key to encrypt her message which means that Daniel can only open it with his private key. But, there is a small problem with this method. The problem is that anyone could as well have sent the message to Daniel.
How would Daniel know that this message was particularly sent by Jane?
For Jane to assure Daniel of this, she would have to use both her public and her private keys to encrypt the message. This way, Daniel uses Jane’s public key and his private key to access the information.
So, where does a Cryptographic Hash Function come into play in all of these?
A cryptographic Hash function is an algorithm / mathematical equation that enables encryption. It is used both in cryptocurrency and outside of it to ensure that data is secure and inaccessible to hackers or scammers. It is used to a great degree in blockchain technology to secure data.
What cryptographic hash function does is that it takes the information and creates a fixed-sized result known as the hash. This makes it impossible to decipher the original information. It is also impossible to find two pieces of information with the same hash.
So, in simple terms, a cryptographic hash function is a mathematical algorithm that transforms information from plain text to masked data.
The message to be hashed is called input, the mathematical algorithm used to hash this piece of information is called a hash function while the result made up of a string of letters and numbers is called the hash value. In this process, the same input always provides the same value but it is impossible for two different inputs to provide the exact same value.
It is also impossible to decipher the input through the hash value.
Important Properties an ideal cryptographic Hash Function should Possess
- Deterministic: What this simply means is that every time an input is taken through the hash function, it should always provide the same hash value.
- Quick Computation: This refers to speed. A cryptographic hash function should process input to hash value at a fast rate.
- Pre-image Resistance: It should be extremely difficult to decipher the input from the hash value. It is not an impossible feat, but the chances should be extremely slim.
In a nutshell, a cryptographic hash function makes transactions on the blockchain network secure. It is why someone cannot access your bitcoin wallet and steal your bitcoins.