Till now most of the people across different verticals know what blockchain is and how it is one of the most innovative technologies that has the potential to disrupt various industries. Blockchains are immutable, and forge-proof making them the best platform for data related transactions. Blockchain also happens to be a platform that prevents a diverse range of frauds including identity theft, financial forgery, data thefts and more. While collecting all the necessary information about Blockchain and its functions, most of us misunderstand the mechanism behind such a tamper-proof nature of this incredible technology. The secret of Blockchain security and tamper proof nature is ‘Cryptography’.
Cryptography contributes to maintain the security of the network. It makes data manipulation hard or impossible and offer high-level protection to each user. It is because of cryptography only that users enjoy transparent transactions while keeping their privacy intact.
Blockchains Cryptographic features:
It is because of the cryptographic features of Blockchain that users enjoy high-level integrity. Two primary elements that make Blockchain such a robust platform includes cryptographic hash functions and digital signatures. Though there is no correlation between your trade success and knowledge of these features as one can invest, buy, sell or store bitcoins without knowing anything about cryptography, but if you are interested in the technological aspect of this fantastic platform, cryptography or encryption is an interesting aspect that you must know.
Hash functions are the base of an encrypted network. They are the reasons Blockchain is a reality today and thus understanding them is important. While there is a lot of speculation about their origin, hash functions became popular in 1960’s when researchers and scientists first realised how their potential could prove revolutionary in the field of computing. In technical language, hash functions are a type of services that are responsible for returning a string of characters of a fixed size from a dataset of arbitrary size. Similarly, cryptographic hash functions are hash functions that have critical application in cryptography and contain features that are highly useful.
- Hash functions are deterministic: this means whenever you set any input, it will always produce the same results.
- They can be disruptive: This means that changing the information can bring considerable changes in the output.
- Easy and instant to compute.
- One way function: You can determine the output when given input but identifying the data when presented a piece of information is extremely difficult and often impossible.
The US National Institute of Standards and Technology published SHA (Secure Hash Algorithm), which is a family of hash functions. Mostly blockchains use SHA or any other similar cryptographic hash functions to ensure the flow of information. In case of bitcoin, the cryptocurrency uses SHA-256.
Cryptography and Passwords
Understanding cryptography and passwords can be difficult if not explained through an example. Let us take this easy example to help you understand the critical use cases of hash functions. Let us assume the Dereck and Jane are a member of a society where they need a secret password to prove their membership to each other.
Now in the first instance, Jane can merely ask Dereck if or not he has the secret password. In case he has, he must tell it to Jane to prove his membership. However, Dereck, not being sure about the association of Jane, is sceptical about sharing the password with her.
Here hash functions play as the problem solver.
Let us suppose that the password is: Jessica Alba is a phenomenal actress.
To prove their membership, both Dereck and Jane can use a hash function input (the passphrase of the password in Hash function) and see if it brings the same output.
They can also check and compare each other password and testify whether or not they both are the members of the same group. A minor change in the password Hash, the results will be drastically differ.
How cryptographic hash functions in Blockchain?
Any unconfirmed transaction broadcasted to the Blockchain network is directed to the unconfirmed cloud. In this unconfirmed cloud, hundreds and thousands of nodes in the network work vigorously sorting and solving a puzzle by rearranging the transactions. This process is similar to packaging unconfirmed transactions into a block and adding any random number to the end of the block. It is similar to inserting a row at the end of an excel spreadsheet where previous rows are getting locked.
The various part of the spreadsheets include:
Hash Of The Previous Block
It is a must for each block in the Blockchain to contain the hash function of the last block in the chain. In simpler terms, the output of the previous block of the hash function is present in the present block.
List of Unconfirmed Transaction
Miners have to add a different number of operation in the cloud of unconfirmed transaction cloud. For this, miners choose the activities that promise the highest transaction fees.
It also contains miner’s address, and all the mining rewards go to this address.
It is the number that completely changes the hash function of the block. It is one critical factor that contributes to solving the secret puzzle.
To solve the secret puzzle, miners have to find a hash with a certain number of zeroes at the starting of the Hash. The more numbers of zero in the starting, the smaller Hash is considered.
Wondering how miners get success in finding the smallest size of hash? Well, it is the real outcome of trial and error.
When the hash is small, only then it can be added to a Blockchain. Other nodes instantly cancel any large Hash added to the blockchain by any node. The complexity and difficulty level of the puzzles is continuously set and adjusted to ensure each problem takes a fixed amount of time to be solved. For bitcoin, the speculated time to solve a mystery is approximately 10 minutes, and for Ethereum, it is 15 seconds.
It occasionally happens that two nodes find two different solutions for the same puzzle at the same time. It occurs when a temporary split occurs in the blockchain wherein half of the nodes support one solution while the other half supports the other.
In such cases, to solve the ambiguity of the chain, the golden rule of blockchain is made active.
“The longest blockchain is the true blockchain.”
It eliminates the scope of arguments as the nodes accept the block that is allowed at the first moment and continues to build blockchain on that only. In this way, all the nodes on the network have to ditch old blockchain and join the new most extended chain as the official blockchain.
Digital signature acts as a filter and protector to check any unauthorised and suspicious activities on the network.
With digital signatures the recipient of a message is allowed to confirm two things:
- The message came from the right person
- The message arrived untampered throughout the transit
Checking the authentication of the transaction in a block is the first thing a node checks when it receives a new block from another node. The authentication happens through public and private keys. The private key allows you to have unique access to your account. It is the way how accounts differ in a blockchain. To gain access to your account and funds, assets and information stored in it, one needs this private key. Thus, it is mandatory to keep your private key. Each private key has a connected public key which in simpler terms is the hash of the private key.
The public key, also known as the address of the account is a generic number which is shared with anyone on the network or server. The public key is the address that they have to direct access to all the transactions to be paid to the people on the network.
Digital signatures, in this case, are used by someone, who has received the transaction, to confirm that the sender of the transaction or the message knew the corresponding private key.
It is a two-step process wherein the owner of the essential private or also known as the key needs to:
- Use a cryptographic hash function to feed the message
- Use the output of the hash function and feed it along with a private key using a signature algorithm.
After this, the recipient has to send out:
- Your public key
- Your message or transaction
- Your digital signature
A recipient to authenticate the same word or message has to:
- Use a cryptographic hash function to feed the incoming signal. Use signature verification algorithm to feed the incoming signature and public key; it will produce a hash
- Compare the two hashes, when the hashes are same, the message is authentic.
This way, the public key is used to verify that a message is authentic as it produces the same hash as your message.