Note

If you are new to the field of information technology, taking our Introduction to Information Technology and its Career Roadmaps and Introduction to Cloud Technology with DevOps, Docker and Kubernetes (free self-paced) courses is highly recommended. Also, for a comprehensive coverage of blockchain concepts and its use cases, taking our Introduction to Blockchain Technology course is highly recommended.

Recap

In our previous article (How blocks are added to the blockchain), we covered how a new block of data is added to the blockchain and how records stored in a blockchain will become immutable.
In this article, we move on discussing how cryptography works and what role it plays in a blockchain system. We also go over differences between public and private keys of cryptography.

 

Rehashing cryptography

Cryptography is the study of secure communication techniques that prevent third parties or the public from reading private messages and allow only the intended recipient of a message to view its contents. It is the cornerstone of information security, which serves as the basis for delivering secure business applications and services. Modern cryptography concerns itself with the following five objectives of information security:

  • Confidentiality: This is the concept of preventing sensitive data from being accessible by any unauthorized entities.
  • Integrity: This means protecting sensitive data from unauthorized changes during transit from one party to another party.
  • Authentication: This is the process of ensuring that user identity is truly what the user claims it to be, whether the user is human or a system.
  • Authorization: This is the concept of determining what actions an authenticated user is allowed to perform.
  • Non-repudiation: When a user performs an action on data, the action must be bound with the user so that it can’t deny performing such actions.

Cryptography deals with the design of algorithms for encryption and decryption, which are intended to ensure the secrecy and the authenticity of the messages or transactions. Let’s start with some key elements in modern cryptography:

  • Encryption: This is the process of converting plain text or data into an unintelligent form, typically using a mathematical algorithm.
  • Decryption: This is the process of reversing encryption—converting an encrypted message back into its original text and data.
  • Hash: This is the process of converting any data block (arbitrary size or message) into a fixed-length hash code. A cryptographic hash function is a deterministic mathematical function performing such a conversion using cryptography, and it always maps to the same result for a given data block.

Cryptography is a key cornerstone of blockchain technology, along with the consensus mechanism and decentralization. It is used in many different forms, including, for example, wallets (for proof of cryptocurrency ownership), transactions (for PoW consensus), and P2P communication. In this article, we will go over key blockchain-related cryptography topics, including public-key cryptography, digital signatures, cryptographic hashing, and Merkle trees.

Public key cryptography

Public-key cryptography is a form of cryptographic function in which encryption and decryption are performed using two different keys—one public and one private key. They are generated in pairs. It is also called asymmetric cryptography. The public key can be shared with the public, but the private key is meant to be a secret code only known by its owner.

The keys are used in tandem too. Either of the two keys can be used in encryption, with the other one used for decryption. It is computationally improbable to determine the private key given only knowledge of the cryptographic algorithm and the public key.
Public key cryptography is most used in three ways, to:

  • Secure the message transmission between two parties and ensure the confidentiality of messages or data.
  • Authenticate the sender and ensure the message is indeed sent from the sender.
  • Combine with the cryptographic hashing function and provide a digital signature on a document before sending it to the receiver.

We will go over the first two here and discuss digital signatures in the following article:

  • Public key cryptography for confidentiality: In this case, as depicted in the following diagram, the digital signature is used to encipher messages between two parties during transmission. The sender (Alice) uses the receiver’s public key to encrypt a message, and the receiver (Bob), who holds their own private key in secrecy, can decrypt the messages using their private key:

How Cryptography Works

  • Public key cryptography for authentication: In this case, as shown in the following diagram, the signature is used to authenticate the sender’s message. The sender uses its own private key to encrypt a message before sending it to the intended parties. The receiver can use the sender’s public key to confirm the message’s authenticity and decrypt it. The combination of this approach with the message’s cryptographic hashing function provides a digital signature, which we will discuss in the next article:

How Cryptography Works

Public key cryptography is an essential technology underpinning wallets and transactions in the blockchain.

Next Article

In the next article (What Is a Cryptographic Hash Function), we continue our discussion on cryptography by discussing how its hash function works.
This article is written in collaboration with Brian Wu who is a leading author of “Learn Ethereum: Build your own decentralized applications with Ethereum and smart contracts” book. He has written 7 books on blockchain development.

Resources

Free Webinars on Blockchain

Here is the list of our free webinars that are highly recommended:

 

Free Courses

Here is the list of our 10 free self-paced courses that are highly recommended:

 

Self-Paced Blockchain Courses

If you like to learn more about Hyperledger Fabric, Hyperledger Sawtooth, Ethereum or Corda, taking the following self-paced classes is highly recommended:

  1. Intro to Blockchain Technology
  2. Blockchain Management in Hyperledger for System Admins
  3. Hyperledger Fabric for Developers
  4. Intro to Blockchain Cybersecurity
  5. Learn Solidity Programming by Examples
  6. Introduction to Ethereum Blockchain Development
  7. Learn Blockchain Dev with Corda R3
  8. Intro to Hyperledger Sawtooth for System Admins

 

Live Blockchain Courses

If you want to master Hyperledger Fabric, Ethereum or Corda, taking the following live classes is highly recommended:

 

Articles and Tutorials on Blockchain Technology

If you like to learn more about blockchain technology and how it works, reading the following articles is highly recommended:

 

Articles and Tutorials on Ethereum and Solidity

If you like to learn more about blockchain development in Ethereum with Solidity, reading the following articles and tutorials is highly recommended:

 

Articles and Tutorials on Hyperledger Family

If you like to learn more about blockchain development with Hyperledger, reading the following articles and tutorials is highly recommended:

 

Articles and Tutorials on R3 Corda

If you like to learn more about blockchain development on Corda , reading the following articles and tutorials is highly recommended:

 

Articles and Tutorials on Other Blockchain Platforms

If you like to learn more about blockchain development in other platforms, reading the following articles and tutorials is highly recommended: