What makes Blockchain so reliable? Let us discuss the role of cryptography in it.
Blockchains have a core principle of being decentralized. They are a product of a collective consensus. For a blockchain to uphold its features of security, provenance, and trust, it needs to be tamper-proof. Here, we take the help of cryptography. After reading this article, you will get aware of how cryptography sustains Blockchain.
Before entering the usefulness of cryptography in the blockchain domain, we will try to understand cryptography first. From the earliest history of humans, when we humans started to group ourselves up into kingdoms and went to war for resources and power, we formed coalitions against the common enemies. We needed information to be transferred to our allies in far-flung places with messengers. But always, there remained a fear of enemy attack in the middle of the journey. Hence, humans started converting the message into a cryptic form. The cryptic message could read by only the intended receivers, who knew how it was encoded.
Cryptography, or cryptology (from Ancient Greek: κρυπτός, romanized: kryptós “hidden, secret”; and γράφειν graphein, “to write” or -λογία -logia, “study” respectively), is the practice and study of techniques for secure communication in the presence of third parties called adversaries. (Source: Wikipedia)
As human civilization evolved in mathematical fields and developed complex mechanical aids, we started creating more elaborate encryption methods. For example, during world war II, the Germans developed the infamous Enigma machine, considered unbreakable. However, English cryptanalyst Alan Turing broke that code by finding some flaws in it. After the advent of computers and the evolution of computation theory, we have entered the age of modern cryptography.
There are mainly three different ways in which we can perform cryptographic algorithms, namely, symmetric-key cryptography, asymmetric key cryptography, and hash functions.
In Symmetric Key Cryptography (also called Secret-Key Cryptography), we have a single key for encryption and decryption. The key is transferred separately to the receiver. It is different from classical cryptography, where the encryption algorithm is only the security measure, and that also could be obtained with cryptanalysis. A key gives an additional layer of security over the algorithm. An adversary now needs to know both the key and algorithm.
The modern technique is Asymmetric Key Cryptography (also called Public Key Cryptography). Here, different keys get generated by mathematical algorithms, and every node has a key pair. One is the public key that is known to all participants of the network. The sender uses it to encode the message. Now, the intended receiver can only decode the message by using its private key. Private keys are personal and not shared with others. Only the receiver can use its private key to decrypt the message encoded by its public key. Asymmetric Key Cryptography provides the following features: confidentiality, non-repudiation, the integrity of information exchange, and authenticity using digital signatures.
“A cryptographic system should be secure even if everything about the system, except the key, is public knowledge.” — Auguste Kerckhoffs, a Dutch linguist and cryptographer from the late 19th century.
Hash functions are different from what we discussed previously. They do not have keys; one can assume them as magic machines that produce a fixed-sized hash(or string) from an arbitrary size of data. It is a one-way system that is there is no way to retrieve the original data from the hash. It is used mainly in authentication and for password storage. In a worst-case situation, two data inputs may give the same hash output; this is called a collision. Still, for all practical reasons, it is not viable to find a collision.
Enough for the background of cryptography, now let us discuss its use-case in Blockchain technology. Hashing, public-private key pairs, and the Merkle trees together constitute the foundation for the Blockchain.
With Asymmetric key cryptography, we have distinct pairs of keys for each participant on the Blockchain, and they are vital for creating a wallet on Blockchain. The private key associated with a wallet proves ownership and control of the wallet. A transaction is an entry in the ledger of transfer from one wallet to another. This transfer is verified by the block validators using the public-private keys of the participants. Here, Digital signatures are easily verifiable and provide integrity to the process. They are similar to the signatures in the real world because they possess the quality of non-repudiation.
Cryptographic Hashing is directly responsible for producing immutability in a blockchain. Hashing is deterministic that are on the same input same output is obtained each time. It is irreversible so, no one can guess the original input from the hash. Every block contains a hash output of all the data in the previous block. Due to this, a chain of blocks gets created. When anyone alters any block, then all the blocks that come after it becomes invalid. Bitcoin uses a cryptographic hash function called SHA-256 and Ethereum uses keccak256.
Merkle Trees stores Blockchain data using a hierarchical tree-like structure where bits of data are called nodes. It utilizes cryptographic hash functions to store hash outputs instead of raw data in each node. Parent nodes contain the hash of a combination of the hashes of child nodes. The Merkle root is the top node of a Merkle tree. It represents a hash output of the combined hashes of all the data. Even in any node, a small change reflects a change in Merkle root. Merkle root is present in the transaction header of each block. So, it guarantees that with less amount of space, it provides exceptional security.
We conclude that cryptography has its dominant use case in the promising field of Blockchain, and cryptography is the main reason for its assuring security. Knowledge of cryptography is always a plus point for blockchain learners.
Originally this article was published in “The Developers Quest” the monthly digital tech magazine from the eduAlgo organization. Visit the official site here: http://www.edualgoacademy.com/