The Origin of Cryptography——From [Caesar Encryption] to [One Time Pad]
猎豹区块链安全
2018-12-27 13:49
本文约1806字,阅读全文需要约7分钟
"You have to know the rules of the game to play better than anyone else - Albert Einstein."


As we all know, cryptography is the basis of digital cryptocurrency, it ensures the security of our assets, and it is also the underlying rule of mining. However, most of them know little about cryptography, so it is difficult to understand the encryption method of blockchain projects. If they don’t understand, they can’t talk about their belief in the project, and they can only follow the trend to speculate in coins.

In order to solve everyone's confusion, Cheetah Blockchain will produce a series of cryptography articles, starting from the oldest encryption method, and going deeper to help you understand many concepts in cryptography and judge the security of blockchain projects.

Caesar encryption

The first well-known cipher, the Caesar cipher, was used by Julius Caesar around 58 BC. In his military orders, Caesar shifted every letter to prevent his enemies from intercepting Caesar's military orders. , and directly obtained his real information.

Caesar encryption is the simplest encryption method. The two sides of the encryption must first reach a consensus on the displacement number of the letter. For example, the encrypted displacement number we agreed is 3. Then, every letter I send must go through 3 displacements. (A becomes D, B becomes E, C becomes F...)

Assuming my plaintext is "attack", after Caesar encryption with a displacement of 3, it will become "dwwtfn".

Then send the encrypted text to the other party through the messenger. In this way, even if the enemy captures the messenger, they will get a bunch of incomprehensible text, and the generals who successfully obtained the ciphertext will pass the ciphertext The real plaintext information can be obtained by subtracting 3 from each letter, and this process is called decryption.

The Caesar cipher is the earliest encryption method and has been used by Western military generals for hundreds of years. Finally, after 800 years, an Arab mathematician named AI-Kindi cracked the Caesar cipher:

If you scan the text of any English book and calculate the frequency of each letter, you will find an amazing secret, that is, in English text, the most frequently used letter is always e, which is the English text It is determined by the nature, and the person who wrote the ciphertext will not realize it. In cryptography, this is called a fingerprint.

Therefore, as long as we find the most frequently used letter in the ciphertext and compare it with the letter e, we can find the encrypted displacement of the Caesar cipher. For example, in the ciphertext, the most frequently used letter is h, then we can infer that the encrypted displacement It is 3. With the encrypted displacement, all plaintext can be deduced.

This method is called frequency analysis, and its appearance is a very big blow to the security of the Caesar cipher.

However, a strong password can mask this fingerprint, and the way to mask the fingerprint is to make the frequency distribution of letter usage even.

multi-table password

Around the 15th century, someone proposed a multi-table cipher to achieve this purpose. The difference between the multi-table cipher and the Caesar cipher is that it does not use a single number for displacement encryption, but refers to a displacement word.

The first step in this encryption method is to determine the displacement word, assuming it is "world", and then convert the word into a number according to the position of the word in the alphabet, "world" → "21, 15, 18, 12, 4". Next, this sequence of numbers is repeated in the process of information encoding, and the plaintext information is shifted according to this sequence of numbers.

Suppose the plaintext is "abcde fghij", and the encrypted ciphertext is "vrvqj bwavo"

The Origin of Cryptography——From [Caesar Encryption] to [One Time Pad]

In this way, when the ciphertext is sent to the partner, the partner can decrypt the information by subtracting the corresponding displacement according to the secret word agreed in advance.

If the ciphertext was intercepted, the eavesdropper would have found a flatter distribution by counting the frequency of letters used.

So how will he crack it?

In fact, it is very simple. Please remember that crackers are looking for information leakage, that is, looking for partial fingerprints. As long as there is a difference in the frequency of letters, the information leakage will be found. This difference is caused by the repetition in the ciphertext.

In this example, the publisher's password utilizes a repeated word. In order to break the encryption, the stealer first needs to determine the length of the shifted word used, not the word itself. He needs to make statistics on the entire information and check the frequency of different intervals. distribution, and when he examined the frequency distribution with a period of 5 letters, the fingerprint showed itself.

Therefore, this encryption method using multiple displacements, compared with the single displacement encryption method used by Caesar, is stronger in the time it takes to determine the length of the displacement word. Therefore, the longer the displacement word, the more secure the information.

Although the multi-table cipher is much more secure than the Caesar cipher, in theory, it can be cracked as long as it takes time.

one time pad

Is there any encryption method to ensure the absolute security of information? The answer is randomness encryption.

Imagine if the encryptor throws a 26-sided dice to generate a long sequence of randomly shifted numbers, and then share it with the decryptor to replace the shifted words, and use this random number sequence to shift letters, the length of the sequence is the same as the information The length is consistent, which is very important to avoid any repetition, and then he sends the ciphertext to the receiver, and the receiver uses a column of random displacement numbers she gave to decrypt the message.

If this method is adopted, it will be very difficult for third-party eavesdroppers to unravel. First, the displacement will never fall into a repeated pattern. Second, the ciphertext will have a uniform frequency distribution, because there is no frequency difference, so There is no information leakage, so cracking the encryption is basically impossible.

This is the strongest encryption method, it appeared in the late 19th century, and it is now known as one-time pad.

About how the one-time pad is realized, I will reveal to you in the next article, so stay tuned.

猎豹区块链安全
作者文库