A Bit of Cryptography

This chapter will cover all the basics of cryptography that are required for you to understand the vital role it plays in blockchain technology. We will delve deeply into all the aspects of cryptography that blockchain relies on. We will explain a few concepts in practical terms so that we can implement them with ease in later chapters. These include the following:

  • Cryptography in blockchain
  • Classical cryptography
  • Cryptographic primitives
  • Merkle trees
  • Encoding schemes

Modern cryptography is the study of private or secure communication. The fundamental objective of cryptography is to enable two people to communicate over an unsecure medium. This is achieved by encrypting a plaintext from the sender to form a ciphertext that can only be decrypted by the receiver, with whom the sender shares a secret. However, third parties can access the channel by which the ciphertext is transported, but the text doesn't have any meaning to it, so it doesn't matter whether the channel is secure or not. Cryptography has evolved and can now be applied in a wide variety of fields, including blockchain. We will start our overview of cryptography with an underlying and fundamental cipher implementation, and then we will move on to advanced and modern cryptography topics.

Cryptography is crucial for information security services such as authentication, confidentiality, and integrity. In the 19th century, Auguste Kerckhoffs outlined what has come to be known as Kerckhoffs's principle: A cryptosystem should be secure even if everything about the system, except the key, is public knowledge. The key is the only asset in cryptography that has to be kept secret and protected from intruder attacks.