# Blockchain Cryptography – History | Cryptosystem

FREE Online Courses: Click for Success, Learn for Free - Start Now!

One important question that pops in our head is, what makes blockchain so secure? On what basis do the makers as well as the users claim that blockchain is incorruptible? Well, we have the answer for you! Blockchain security is built on two concepts i.e., *Cryptography *and *Hashing*. In this tutorial, we will only focus on the concept and technique of cryptography in Blockchain. There is going to be a separate topic for discussing Blockchain security and hashing.

So, let’s start with learning how cryptographic techniques work to keep the transactions in the blockchain secure.

### Cryptography in Blockchain

Cryptography is the method of securing important data from unauthorized access. In the blockchain, cryptographic techniques are a part of security protocols. It secures a transaction taking place between two nodes in a blockchain network. As we know from our previous discussions, blockchain technology is based on three main pillars; *Distributed ledger*, *Peer-to-peer network, *and *Cryptographic security*.

The successful and safe working of a distributed ledger system and the point-to-point network is impossible without a robust security technique in place. Blockchain uses two types of security approaches i.e. *Cryptography *and *Hashing*. The basic difference between these two is that cryptography is used to encrypt messages in a P2P (Point-to-Point) network. Whereas, hashing is used to secure block information and link blocks in a blockchain.

So, in this discussion, we keep our focus on how we can use these cryptographic techniques, keys, and algorithms. How we can use them to secure a message or information at one node and sent to the other.

We can break down the word cryptography into two parts; *Crypto *meaning “hidden” and *Graphy *meaning “writing”. Therefore, cryptography is a method of converting plaintext into unreadable coded text.

Two main concepts behind cryptography are *Encryption *and *Decryption*. Encryption is coding information in such a way that you and I cannot understand what it means just by looking at it. Decryption is the reverse of encryption, i.e. decoding of the coded information.

The encrypted text or information is also known as *ciphertext*. And this ciphertext is deciphered through specific techniques known as a cipher (steps of encoding). Therefore, cryptography is a security method that secures a transition or exchange of information between two nodes and prevents it from third-party intervention.

We have discussed the Byzantine generals’ problem earlier in the Blockchain security lesson. Blockchain’s solution to the Byzantine generals’ problem is cryptography. A blockchain network uses cryptographic techniques at two levels that keep the data secure. One is the *key-encryption* method and another is *hashing*.

Technology is evolving rapidly!

Stay updated with DataFlair on WhatsApp!!

Key encryption is a cryptographic method that ensures safe transmission of information from point A to point B. This is like an external layer of protection. The internal layer is hashing. Hashing is a process of irreversible encryption of data in a block. All the data present in the block is encrypted using the SHA256 hashing algorithm which is irreversible. Thus, applying cryptography at two levels in a blockchain network makes it absolutely secure.

### History of Cryptography

Before we move on with learning more about cryptography, let us walk you through the history of cryptography. The tale of cryptography traces back to ancient times. One of the earliest signs of using cryptographic methods was seen in ancient Egypt to exchange important information. During that time, generals of the Roman empire used a popular cryptographic technique; “*Caesar cipher*”.

Then came the age of encryption methods in cryptography which was around the 16th century. This method of key encryption codes a message into a single keyword. The receiving party then decrypts the message using the key. This method was popularly known as “*Vigenere cipher*”.

Later in the 20th century came the age of rotor driven encryption machines like the *Enigma *machine used by the Germans during World War II. These machines would generate a ciphertext by making particular settings for the multiple rotors present in it.

For a significant time, this method of cryptography was considered successful and unhackable. But, in 1932 Polish and British armies (with the help of the famous Alan Turing) found the hack to this method and was able to decrypt the messages encrypted by Enigma code.

With the war phase receding came the computer age where the need for more robust cryptographic techniques arose. During this time, there was a realization that we can use cryptography not only in war but in other crucial domains such as business and commerce as well.

So, in the 1970s IBM created a cryptographic algorithm named “*Data Encryption Standards*” (DES) to encrypt important data. But soon it became obsolete as it was easy to hack or brute force this algorithm. After DES, in 2000 came the* Advanced Encryption Standard* (AES).

Apart from cryptography existing in our lives on a day-to-day basis such as in Emails, messages, Login IDs and passwords, etc. it is especially useful in the operation of cryptocurrency systems like Bitcoin. In these, cryptographic techniques are mainly used for hashing and key encryption or digital signatures in order to keep the data safe.

### Key Cryptography

Key encryption or cryptography is a method of securing a point to point transition using a key. This key is a unique series of numbers and letters which is like a password used to facilitate a transaction between two parties. Key encryption codes the message or information to be sent to the other node in an unreadable format. The other node will have to use the same or a different key (depending on asymmetric or symmetric) to decode the message to bring it in a readable format.

Thus, we use key cryptography method to ensure the identity of the sender and receiver and to secure the information from attack and misuse. Key cryptography is of two types based on the number of keys used by the nodes to carry out a secure exchange of information between them.

The first is “*Symmetric cryptography*” and “*Asymmetric cryptography*” also known as *Public-key cryptography*. Let us learn about how these work to secure a transition in the sections below.

#### 1. Symmetric cryptography in blockchain

The symmetric cryptography technique was the first key cryptography that was put to use in a blockchain network. In this method, both the nodes use the same key to encode and decode (or encrypt and decrypt). Refer to the image given below for a better understanding.

Suppose Node A wants to send some confidential information to Node B. To facilitate this transition using the symmetric key method, Node A will encrypt the information into an unreadable ciphertext using a key k1 and send it to Node B. Node B will receive the ciphertext and decrypt it using the same key i.e. k1. This means both Node A and Node B need to have the same key k1. In the same way, if Node A wants to communicate with Node C, they both will need a new key k2 between them. Or Node B and Node C will need yet another new key k3 to carry out a transaction.

Thus, one major drawback of this method despite being the fastest method is that a node will need to have a lot of keys to interact with different nodes in the network. Also, the nodes need to make sure that they share the key securely otherwise a third node might know the key. Due to these drawbacks there came another method of asymmetric key cryptography.

#### 2. Asymmetric cryptography in blockchain

As the name suggests, Asymmetric cryptography does not involve sharing the same key between two nodes. Instead, in this type of key encryption, there are two keys for a node; *Private key* and a *Public key*. These keys always exist in a pair as they work in tandem. That is, we use the public key to encrypt the message and the corresponding private key to decrypt the message.

Suppose we have a network of three nodes; A, B, and C. Each node will have its separate pair of private and public keys. The public key is made public i.e. every other node in the network knows this key. Whereas, a private key must not be shown to others and kept private by the node like a password.

Now let us take an example of how a transaction takes place using the pair of keys between two nodes. Let’s say Node A has to send confidential information like bank account details to Node B. Now, Node A will first encrypt the text using its own i.e. A’s private key and then again encrypt it using B’s public key. When this encrypted text reaches Node B, it will first decrypt it using its own i.e. B’s private key and then again using A’s public key.

What we need to understand here is that the first layer of encryption where Node A uses its own private key to encrypt the message. It is for Node B to verify that the message is actually coming from Node A.

The next layer of encryption ensures the safety of the message in a way that only Node B’s public key can code it and only Node B’s private key can decode it. By this, the information is protected from any malicious third party attack. This is how the two key system works in asymmetric key cryptography. This technique is popularly known as *Public Key Cryptography*.

### Wallets and Digital signatures

Now that we have understood the concept of key cryptography and especially public-key cryptography, we can understand another concept related to it i.e. *Wallets *and *Digital signatures*. These words aren’t really new to us, we use a wallet to keep our money in it and each one of us has unique signatures to prove the authenticity of our identity. However in the relevance of blockchain, the wallet and signature hold a slightly different meaning.

A blockchain wallet is a software (e.g. *Electrum*, *Bitcoin *core) or even a special hardware device (e.g. *Trezor*, *Ledger*) that is used to keep transaction information and personal information (private and public key) of the user. It is important to know that such wallets do not contain actual currency in it (e.g. Bitcoin, Ethereum).

These wallets are just used as a secure place to keep one’s keys (especially private keys) and maintain a transaction balance. Also, we can say that we require a blockchain wallet to carry out transactions with other users. That is, a wallet is only a communication tool and the blockchain stores the real information/data/currency in blocks.

Similarly, the digital signature is like proof that we give to the receiver and the entire network that you are a legitimate node in the blockchain network. Whenever you initiate a transaction with another node, you have to create a unique digital signature by combining your transaction data and your private key using a special algorithm. This will guarantee the authenticity of your node and the integrity of the information you are sending.

When the receiving node gets the signature message they can verify the transaction by using the public key of the sending node.

### Cryptographic Hashing

Hashing is another crucial factor in securing the blockchain and making it immutable. Cryptographic hashing refers to coding the information or data on blockchain into an unreadable, unhackable text. This is done using a special kind of hashing algorithm known as SHA-256 (Secure Hash Algorithm). It creates a 32-byte long hash value.

The hash is always of a fixed length no matter what the length of the input value was. But it is impossible to have the same hash values for different inputs. For instance, if our input data is “** dataflair**” the hash value will be

“07e42324292ec3bfc150958da854dd8d0357b021dc5e4cfd75e65eed43bfe382”

But if we change our input to “** DataFlair**” with two letters made capital, the hash will be:

“64a5c3aade499eabcc677bd5445c84636ea64fbf0c7c01a49e469ff05da179ef”

This is how specific the process of hashing is, if there is any minute change of even a letter in the input, the output will be different. This makes detection of threats on data and security very quick and easy.

### Summary

This completes our lesson on “Cryptography in Blockchain”. Here, we learned about the concept of cryptography, different types of key cryptography; Symmetric and Asymmetric key cryptography. Then we advanced by learning about wallets and digital signature. And finally came to understanding cryptographic hashing. We will learn more about what role does hash play in blockchain security. And extend our knowledge on *Public Key Cryptography*.

**Did you like our efforts? If Yes, please give DataFlair 5 Stars on Google **