Cryptography in Blockchain


What is Cryptography in Blockchain?

Cryptography is a growing phenomenon in the realm of modern data security and efficient information exchange. Cryptography represents the age-old pursuit of secure communication. It has evolved from ancient cryptic manuscripts to the complex algorithms of modern science and technology.

This chapter will delve into the interconnected disciplines of cryptography and encryption. In addition to exploring the histories and complexities of this technology, we will also gain insight into routes, keys, mechanisms and many more concepts.

Routes of Cryptography

Traces of cryptography can be found far back in history, when simple encryption methods like ciphers were utilized for securing important information. Encrypting messages used to be an enjoyable activity during childhood, often involving swapping messages with close friends. Many people have employed various techniques to keep their messages private, such as using invisible ink or wax seals. The need to conceal messages has existed since the transition from primitive living to organized societies and the development of civilization. As different groups and tribes emerged, competition arose, leading to hierarchical aggression, covert communication, and manipulation of the masses. The earliest forms of encryption were discovered in regions associated with the birthplace of civilization, including Egypt, Greece, and Rome.

Ancient Egypt is credited with the earliest known form of cryptography, using hieroglyphs to encode sensitive information. Over time, different encryption methods have been employed, including substitution ciphers, transposition ciphers, and polyalphabetic ciphers.

The Caesar cipher, named after Julius Caesar, a Roman military general from 100 BCE who utilized it to secure his military communications, is one of the simplest and oldest known substitution ciphers. The Vigenre cipher and the Playfair cipher, developed in the 16th and 19th centuries respectively, are examples of polyalphabetic ciphers. However, these traditional encryption techniques are no longer considered secure for safeguarding sensitive data, as they can be easily deciphered by modern computers.

Types of Ciphers

There are two types of ciphers which are most commonly used in the field of cryptography and cybersecurity, which are as follows −

  1. Monoalphabetic Cipher
  2. Polyalphabetic Cipher

1. Monoalphabetic Cipher

In a monoalphabetic cipher, every letter in a message is consistently swapped with a single= letter. For example, in a Caesar cipher, each occurrence of the letter A could always be transformed into a G, resulting in a straightforward pattern. Due to the simplicity of this technique, these ciphers are prone to techniques like frequency analysis, where the occurrence of letters in the encoded message is calculated to decipher the encryption.

In this type of cipher, each letter in the original message is shifted by a fixed number of positions in the alphabet.

For instance, with a shift of 2, the following alterations can be observed −

  • Original − HEY
  • Encrypted − JGA

In this scenario, every letter is substituted with the letter that is two positions ahead in the alphabet.

2. Polyalphabetic Cipher

On the contrary, a polyalphabetic cipher increases complexity by employing various substitutions for the same letter based on a confidential key.

An illustration of this is the Vigenre cipher, where each letter in the key corresponds to a distinct shift in the alphabet. This dynamic substitution enhances the complexity for cryptanalysts to decode the message, offering better protection in comparison to monoalphabetic ciphers.

The term "poly" means "many", indicating numerous methods of encrypting each letter, hence adding an additional layer of security to the encoded message. Within this cipher, a keyword is utilized to establish multiple shift values for every letter.

For instance −

  • Original − TRUST
  • Key − KEY
  • Encrypted − DVSCX

In the above example, the key is repeated till the length of the word, hence TRUST->KEYKE. Then, we refer to the corresponding values of each row and column from the table to encrypt the message. Hence, under row T and column K, we get D. Similarly, under row R and column E, we get V, and so on.

Basic Terms of Cryptography

Before deep diving into related concepts and further links of cryptography. Let us step out and familiarize ourselves with a few basic concepts and terminologies −

  • Encryption − The process of converting plaintext into ciphertext, making it unreadable to unauthorized parties.
  • Decryption − The act of deciphering the encoded message (ciphertext) back to its original form (plaintext) so that it can be read and understood by those who are authorized to do so.
  • Cipher − The algorithm used for encryption and decryption.
  • Key − A private value utilized in combination with an encryption algorithm to scramble and unscramble information.
  • Symmetric Key − A solitary private key utilized for both the procedures of encoding and decoding.
  • Asymmetric Key − A pair of keys, one for encryption and one for decryption, that are mathematically related but not identical.
  • Plaintext − The original, unencrypted data.
  • Ciphertext − The encrypted data.
  • Hash Function − A one-way function that takes an input (or message) and returns a fixed-size string of characters, which is typically a digest that is unique to the unique message.
  • Digital Signature − A digital code that is attached to an electronically transmitted document to verify its contents and the senders identity.
  • Public Key Infrastructure (PKI) − A collection of hardware, software, individuals, protocols, and protocols necessary for the establishment, administration, dissemination, utilization, storage, and revocation of digital certificates.
  • Certificate Authority (CA) − An organization that issues digital certificates and manages the PKI.
  • Non-repudiation − The ability to prove that a specific individual was responsible for a particular action or message.
  • Authentication − The process of verifying the identity of an individual or entity.
  • Key Management − The process of creating, distributing, storing, and protecting keys.

We will be looking at the above concepts in detail in the coming sections of this tutorial.

Principles of Cryptography

Cryptography is the technique of securing information by converting it into a code that can only be read by those who are permitted to do so. The core ideas and rules of cryptography encompass −

  • Confidentiality − Ensuring that confidential information is protected from those who are not authorized to access it.
  • Integrity − The information is sensitive so its nature should not be tampered with or altered in any way.
  • Authentication − Confirming the identity of the sender and receiver of the packet of information.
  • Non-repudiation − Ensuring that the sender of the info cannot deny the origin of the content.
  • Key Management − Managing the generation, distribution, storage, and use of keys for encryption and decryption in a secure manner.
  • Algorithms − Algorithms are math functions that help secure information by converting it into an unreadable form and making it readable again through decryption.
  • Public Key Cryptography − Public key cryptography involves using a publicly accessible key to encrypt data and a privately held key to decrypt it. On the other hand, symmetric key cryptography employs a single secret key to encrypt and decrypt data.
  • Hash Functions − Mathematical functions that take an input (or message) and produce a fixed-length output, used to confirm the integrity of the original message

We will delve into these topics extensively as we progress forward. These notions and precepts are put into practice in diverse encryption techniques, including symmetric-key encryption, asymmetric-key encryption, and hash functions.

Types of Cryptography

There are mainly two types of cryptography used in modern networks and communication systems −

  1. Public Key Cryptography
  2. Elliptic Curve Cryptography

1. Public Key Cryptography

Public key cryptography utilizes a set of keys, with one being public (accessible to all) and the other private (known solely by the owner).

Let us take an example of two people- Alice and Bob. Alice wants to send a message to Bob but in a secure way. In order to transmit a message to Bob, Alice employs Bob's public key for encryption. Bob, in possession of his private key, is able to decrypt and access the message.

This works in the following way −

  • Encryption − Bobs public key is like a special lock, and Alice uses it to lock her message.
  • Decryption − Bobs private key is like the unique key that opens the lock to read the message.

2. Elliptic Curve Cryptography

ECC is a powerful and innovative encryption method, revolutionizing the modern cryptographic techniques. It enhances security while requiring smaller key sizes compared to traditional cryptographic algorithms. Let us learn different aspects of ECC.

Key Generation

Public Key (Q) − Bob picks a curve and a point on it. He calls this point (G). His public key (Q) is a result of multiplying (G) by a secret number (d).

Example − Q = d . G

Encryption

  • When Alice wants to send Bob a secret message, she picks a random number (k).
  • She computes a point (C) on the curve by multiplying (G) by (k).
  • The x-coordinate of (C) is part of the encrypted message.
  • The shared secret is derived by Bob multiplying (C) by his secret number (d).
  • Example − s = k . Q

Decryption

  • Bob, with his private key, multiplies (C) by (d) to get the same shared secret (s).
  • Using a key derivation function, both Alice and Bob derive a symmetric key from (s).
  • The symmetric key is used to decrypt the message.
  • Example − S = d . C