Cryptography is a method of developing techniques and protocols to prevent a third party from accessing and gaining knowledge of the data from the private messages during a communication process. There are several terms related to cryptography, including encryption, decryption, cipher, and key.
Cryptography in History
Cryptography is not a modern world invention. In fact, there are many different types of cryptography throughout history, with the first known evidence of cryptography can be traced to the use of ‘hieroglyph’. Some 4000 years ago, the Egyptians used to communicate by messages written in hieroglyphs. This code was the secret known only to the scribes who used to transmit messages on behalf of the kings.
Julius Caesar also used a form of encryption to convey secret messages to his army generals in the war front in 100 BC. This substitution cipher, known as Caesar cipher, is perhaps the most mentioned historic cipher in academic literature. During the 16th century, Vigenere designed a cipher that was supposedly the first cipher which used an encryption key.
Hebern Rotor Machine and the Enigma
At the start of the 19th century when everything became electric, Hebern designed an electro-mechanical contraption which was called the Hebern rotor machine. It uses a single rotor, in which the secret key is embedded in a rotating disc. The key encoded a substitution table and each key press from the keyboard resulted in the output of cipher text. This also rotated the disc by one notch and a different table would then be used for the next plain text character.
The Enigma machine is probably one of the most famous cryptography machines in history. Heavily used by the German forces during the Second World War and eventually lead to the invention of the Turing Machine.
Cryptography in Blockchain
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 known as secret-key cryptography, there is only one key. The key is used for both encryption and decryption. Using a common single key creates a security problem of transferring the key between the sender and the receiver.
Asymmetric-key cryptography, also known as public-key cryptography, uses a pair of keys, an encryption key and a decryption key, named public key and private key respectively. The key pair generated by this algorithm consists of a private key and a unique public key that is generated using the same algorithm.
Asymmetric-key cryptography is where the private key generally needs to be produced by a random number algorithm, and the public key is calculated by executing an irreversible algorithm. The asymmetric encryption algorithm has the advantage of having separate public and private keys, which can be transferred over unsecured channels. Since the Algorithm is irreversible, no one can decrypt the private key by using its public key.
Hash functions do not make use of keys. Instead, it uses a cipher to generate a hash value of a fixed length from the plaintext. It is nearly impossible for the contents of plain text to be recovered from the ciphertext.
Use of Cryptography in Blockchain
Blockchains make use of two types of cryptographic algorithms, asymmetric-key algorithms, and hash functions. Hash functions are used to provide the functionality of a single view of blockchain to every participant.
Cryptographic hash functions provide the following benefits to the blockchain:
- Avalanche effect – A slight change in the data can result in a significantly different output.
- Uniqueness – Every input has a unique output.
- Deterministic – Any input will always have the same output if passed through the hash function.
- Quickness – The output can be generated in a very small amount of time.
Hash functions have a major role in linking the blocks to one another and also to maintain the integrity of the data stored inside each block. Any alteration in the block data can lead to inconsistency and break the blockchain, making it invalid.
Asymmetric-key cryptography relies heavily on digital signatures to ensure the integrity and validity of data on the blockchain. Digital signatures, similar to real-world signatures, provide non-repudiation and cannot be corrupted. These signatures are used to approve transactions, and also for multi-signature contracts and digital wallets on the blockchain. To ensure security, these signatures can be securely signed offline using a hardware wallet or cold wallet, which keeps the private keys used for signing offline and away from potential online attacks. Crypto wallets are essential for managing and storing these private keys, ensuring that they are kept safe and secure. In summary, the use of digital signatures in the blockchain ecosystem highlights the importance of hardware wallets, cold wallets, and crypto wallets in providing a secure and trustworthy environment for all transactions.
Foundation of Blockchain
Hashing, public-private key pairs, and the digital signatures together constitute the foundation for the blockchain. These cryptographic features make it possible for blocks to get securely linked by other blocks, and also ensure the reliability and immutability of the data stored on the blockchain.