Foundations of Blockchain
上QQ阅读APP看书,第一时间看更新

Classical cryptography

In this section, we'll look at a number of cryptographical techniques that have been used in historical ciphers. These ad hoc ciphers are not secure enough to be used in modern applications, but because of their simplicity, they can encourage us to learn more about cryptography. Exploring the weaknesses of classical cryptography also helps us to learn more about some of the principles of cryptography. Take a look at the following diagram:

Figure 2.1: Model of conventional encryption

Figure 2.1 shows the conventional encryption model used to encrypt a plaintext using a secret key that is shared with the other user over a secure channel. The user who wants to read the text will decrypt the ciphertext using the secret key, which will return the original plaintext. The key is private, and the encryption and decryption algorithms are made public because it is impossible to decrypt the ciphertext without the key.

Two types of operation are used to transform plaintext to ciphertext: substitution and transposition. Both of these techniques ensure that the operation is reversible, and therefore they could be used in encryption algorithms.

A substitution cipher is an encryption method in which the characters in plaintext are replaced by other characters in a fixed manner. The simplest example of a substitution cipher is Caesar's cipher, where plaintext letters are substituted by shifting the alphabet by three places: the letter A is replaced with D, B with E, and so on. The obvious problem with this cipher is that the method is fixed and that there is no key involved. A variant of Caesar's cipher, called the Shift cipher, was introduced, where the amount of shift from the plaintext to the ciphertext varies, and this amount of shift can act as a key. Although this solved the immediate problem, it wasn't practical enough as the key could be guessed with a brute-force or an exhaustive search attack. The polyalphabetic cipher was the next stage in the evolution of ciphers. This cipher introduced a number of substitutions at different positions in the message.

A transposition cipher is an encryption method where the positions of plaintext letters are shifted according to a known system. Only the order of plaintext is altered. All the letters of the plaintext remain the same. The Rail Fence cipher and the Route cipher are two well-known transposition ciphers. This kind of cipher technique could be decrypted by finding the transposition patterns using anagramming.