Cryptography In Blockchain

Introduction

Cryptography has become essentially important as it allows us to securely protect data that we don’t want anyone else to have access to. It is used to protect corporate data, personal information, etc.

Blockchain is a network that works peer-to-peer, which means it does not need any central server. Whatever the network we work with, we have 4 big concerns, they are

  • Confidentiality
  • Integrity
  • Non-repudiation
  • Authentication

Confidentiality

Let’s take an example that we have four nodes (A,B,C,D). Now A wants to send data to B. The data may be simple or a confidential information. But node C can access the information which is shared by A and B and that’s something that we don’t want. We want our information to be secure irrespective of its state.

Integrity

Now, when A send some data to B and let’s take it as a simple message like “hello, let’s meet @6pm”. Now if node C modifies the data to “hello, let’s meet @5pm”, that’s where the problem arises. Someone is changing the data; the information sent from A is different from the information received by B. That’s where we have an issue of integrity.

Non-Repudiation

There should be some proof of the information sent and the information received from both nodes.

Authentication

Let’s say B has received the message from A. What is the guarantee that A is the sender. It may be C or someone would have sent the message in the name of A. So we don’t anyone else to send messages on someone’s else behalf and that’s why we have an issue of authentication.

Types of Keys

How do we solve all these concerns, that’s where we have a concept of Cryptography. The term cryptography has two terms, crypto and graphy. Crypto means Hidden/secret and graph means basically writing. It means that you are sending the message in such a way that someone else will not be able to read it. Like it should be read only by the receiver but not by anyone else. To achieve this, we use concepts called encryption and decryption.

Cryptography In Blockchain

When node A sends information to B, it is first encrypted in a non-readable format. If node B wants to read the message, he needs to decrypt it. In order to do so, he needs to have a key. Based on this key cryptography has two types of keys

  1. Symmetric key cryptography
  2. Asymmetric key cryptography

Symmetric Key Cryptography

Now if A wants to send message to B, they both would have the same key (let’s say k1). Now, what if A wants to send message to B? it has to use a different key (let’s say k2). If node C wants to send message to B, it has used a different key (let's say k3). So, as the number of user increases, we have to increase the keys.

Cryptography In Blockchain

So, if I want to interact with 50 people, I want to carry 50 keys and also it is very difficult to manage all those keys. This is one of the drawbacks of symmetric.

Asymmetric Key Cryptography

It is also known as public key cryptography. Basically we use two different keys here. One is private key and one is public key and, in a transaction, we need to use both keys.

Cryptography In Blockchain

If A encrypts the message with private key, it has to decrypt the message with public key and vice versa. We can’t use only private key or public key for both encryption and decryption.

How to achieve security?

A sends the encrypted message using B’s public key and it can only be decrypted using B’s private key. So, no one can access the information.

Cryptography In Blockchain