## What exactly is Cryptography?

The science of keeping communication secrets is known as cryptography. Cryptanalysis is the study of cracking an encrypted message, or extracting the plaintext without knowing the key. Cryptographers do cryptography, whereas cryptanalysts perform cryptanalysis.

The original message is referred to as plaintext in cryptography terminology. Encryption is the process of changing the original text such that it is hidden from other material. The encrypted communication is referred to as ciphertext. Decoding refers to the process of obtaining ciphertext from plaintext. Typically, a method employed in the encryption and decryption key and the algorithm ensures that decryption can be performed only with the key.

- Encryption is the process of applying a cipher to protected information using the cipher's rules.
- Decryption is the process of transforming an encrypted communication into protected information by applying particular rules specified in the cipher.

Typically, a method employed in the encryption and decryption key and the algorithm ensures that decryption can be performed only with the key.

Assume you need to send a message to the recipient. You don't want anyone other than the recipient to be able to read the information you've sent. However, there is always the potential that the package will be opened or the email may be intercepted.

In essence, cryptography is the technique of communicating securely in the midst of potential third-party malicious entities. There are two fundamental components to safe communication:

- Data confidentiality is protected against interception.
- Protection against data manipulation: information integrity, which implies that no one can modify the data you communicate, forcing the receiver to accept the damaged data as legitimate.

Encryption, which can be symmetric or asymmetric, is used to ensure data privacy.

- Symmetric encryption: encryption that employs a single key that must be shared by all communication parties.
- Asymmetric encryption: encryption that uses private keys. Each participant has a public and private key combination to encrypt and decode messages.

## Cryptography Model Flow

A generic cryptographic model is shown in the following diagram:

In the preceding diagram, **P**, **E**, **C**, and **D **represent plaintext, encryption, ciphertext, and decryption, respectively. This model utilizes concepts such as entities, senders, receivers, adversaries, keys, and channels. These concepts are explained as follows:

**Entity**: Either a person or system that sends, receives, or performs operations on data**Sender**: This is an entity that transmits the data**Receiver**: This is an entity that takes delivery of the data**Adversary**: This is an entity that tries to circumvent the security service**Key**: A key is data that is used to encrypt the plaintext and also to decrypt the ciphertext**Channel**: A channel provides a medium of communication between entities

## How does Proof of Work use Cryptography?

Proof of Work is a consensus algorithm that uses a cryptographic hashing puzzle to make sure that a certain amount of work has been done before a block is created. Bitcoin's Proof of Work uses the SHA-256 hash function to create a hashing puzzle.

Blocks in a blockchain network are created by a special type of validator node called a miner. These miner nodes compete with each other to solve the hashing puzzle in order to produce a block to be appended to the ledge

Blockchain miners will start to solve the hashing puzzle whenever they have data (often, a set of transactions) that needs to be included in a block. The following image shows the basic structure of a block header used in a Proof of Work-based blockchain application.

Using a hash function to perform Proof of Work turns out to be a good approach because it is difficult to fraudulently compute a hash value due to its cryptographic characteristics. Hash functions make sure that a certain amount of CPU effort has been used to compute hash values, and that the hash rate of the computer is the Proof of Work during this process.

## Basic encryption algorithms

Cipher is a method of encryption and decoding. Some encryption techniques are predicated on the fact that the encryption method is kept secret. Such approaches are now solely of historical curiosity and have no practical application. To manage encryption and decryption, all current algorithms utilize a key; the message can only be successfully decoded if the key is known. Although the key used for decryption may differ from the key used for encryption, in most algorithms, the keys are the same.

There are two types of key algorithms:

- symmetric or secret key algorithms
- asymmetric or public key algorithms

The major distinction between symmetric and asymmetric algorithms is that they employ the same key for encryption and decryption. Asymmetric algorithms, on the other hand, employ distinct keys, and the decryption key cannot be computed from the encryption key.

Stream ciphers and block ciphers are two types of symmetric algorithms. Streaming encrypts information bit by bit, whereas blocking encrypts a certain group of data bits, typically a block size of 64 bits, and then encrypts this set as a whole.

Asymmetric ciphers make the public key available to everyone (for example, by publishing it in a newspaper). This makes it possible for anyone to encrypt the message. This communication, however, can only be decrypted by the proper individual. The encryption key is referred to as the "public key," whereas the decryption key is referred to as the "private key" or "secret key."

In general, symmetrical algorithms are quicker than asymmetrical ones. In fact, both types of algorithms are frequently used in conjunction: a public key algorithm is used to send a randomly generated secret key, which is subsequently used to decode the message.

## Digital Signature

A digital signature can be generated using any of the asymmetric techniques. A digital signature is a block of data created with a secret key. You may then use the public key to verify that the data was created with this secret key. The method for producing a digital signature must ensure that no signature can be created without a secret key that, when validated, proves to be correct.

Digital signatures are used to verify that a communication came from a certain sender. Signatures are also used to affix the time stamp on documents; the party we trust to sign a document with a timestamp with the assistance of its secret key verifies that the document actually existed at the time specified in time stamps.

When producing a digital signature, cryptographic hash functions are typically employed to construct a message digest. Hash functions map a message with a fixed length hash value (hash value) so that the whole set of potential messages is fairly spread among a number of hash values. In this example, the cryptographic hash function does it in such a way that fitting a document to a particular hash result is nearly impossible.

Cryptographic hash functions often generate values of 128 bits or more. This figure is far more than the quantity of messages that will ever exist on the globe.

Many good cryptographic hash functions are freely available. MD5 and SHA are two popular ones.

## Cryptographic random number generators

Random numbers generated by cryptographic random number generators are utilized in cryptography applications such as key creation. Conventional random number generators, which are accessible in many programming languages and software environments, are unsuitable for cryptographic purposes since they were designed to produce a statistically random distribution, and cryptanalysts can forecast their behavior.

Random numbers should ideally be based on a true physical source of random information that cannot be anticipated.

## Attacks on cryptosystems

**Ciphertext-only attack:**This occurs when the attacker has no knowledge of the message's content and only works with known ciphertext.**Known-plaintext attack:**The attacker knows or can estimate the contents of all or part of the ciphertext. The task is to decipher the remainder of the message. This may be accomplished by either calculating or bypassing the encryption key.**Chosen-plaintext attack:**The attacker has received an encrypted document containing any text required for it, but does not know the key. The goal at hand is to locate the key.**Man-in-the-middle attack:**This type of attack targets the exchange of encrypted messages, specifically the key exchange protocol. When two parties exchange keys for a secret communication, an enemy is added to the message channel between them. Furthermore, the opponent distributes keys to each side. As a result, each side will have unique keys, each of which the adversary is aware of. The adversary will now decode each communication with his own key before encrypting it with a new key and forwarding it to the recipient. The parties will have the appearance of private correspondence while the opponent reads all messages.**Timing attack****:**A type of side-channel attack in which the attacker attempts to compromise a cryptosystem by evaluating the time required to run cryptographic algorithms.

There are several different cryptographic assaults and cryptanalytic methods. The ones listed above, however, are most likely the most critical for practical system design. If someone is planning to design their own encryption method, they must first grasp these concerns much more thoroughly.

## Summary

Cryptanalysis is the study of cracking an encrypted message, or extracting the plaintext without knowing the key. Cryptographers do cryptography, whereas cryptanalysts perform cryptanalysis.

## Further Reading

He is the founder of **GoLinuxCloud** and brings over a decade of expertise in Linux, Python, Go, Laravel, DevOps, Kubernetes, Git, Shell scripting, OpenShift, AWS, Networking, and Security. With extensive experience, he excels in various domains, from development to DevOps, Networking, and Security, ensuring robust and efficient solutions for diverse projects.