Principles of Modern Cryptography Encryption
猎豹区块链安全
2019-01-17 10:41
本文约1632字,阅读全文需要约7分钟
This article reveals to you the basics of modern cryptography encryption

Cryptography plays a very important role in blockchain technology, but in fact, in the Internet, a large number of cryptography technologies are also used. This article will introduce the early encryption methods in modern cryptography, which will help We understand complex algorithms in blockchain.

After World War II, the Internet, which evolved from the military, slowly entered the homes of ordinary people. We can process everything electronically, and transactions are no exception, so electronic banks also appeared, and all transactions can be processed through network carried out. With the increasing number of Internet users, new problems arise. Encryption requires both parties to share a secret random number, which is the secret key. However, how can two people who have never met each other agree on this shared key without letting Do you know about third-party monitoring? This would be the goal of modern cryptography.

In 1976, Whitfield and Martin Hermann came up with an ingenious solution, let's use the metaphor of color to explain how this trick is achieved:

First of all, to clarify our goal, the sender and receiver agree on the secret color without letting the eavesdropper know, so a technique needs to be adopted, which is based on two points:

1. It is easy to mix two colors to get a third color;

Second, after obtaining this mixed color, it is very difficult to know the original color on this basis.This is how locks work.

Going one direction is easy, going the other way is hard, which is called a one-way function. The solution is this, first they publicly agree on some color, let's say yellow, then the sender and receiver randomly pick their private color, mix it into the public yellow, thus masking their private color, and mix The color is sent to the receiver, the receiver knows its own private color, and sends its mixed color to the sender,

Then there is the key to the trick, the sender and the receiver add their own private color to the other person's mixed color, and then get a shared secret color. At this time, the eavesdropper cannot determine this color. She must have a private color. The color can be determined, the trick is like this, in the world of cryptography,first level title

discrete function problem

We need a numerical process that is easy in one direction and difficult in the opposite direction, so cryptographers have found modulo arithmetic, that is, the function of taking the remainder (for example, the remainder of 46 divided by 12 is 10).

Suppose we consider using a prime number as a model, such as 17, we find a primitive root of 17, here is 3, which has the following important properties, when taking different powers, the result will be evenly distributed on the clock, 3 is a generator, take 3 to the X power, the result will appear equally likely on any integer between 0 and 17.

But the opposite process is difficult. For example, given 12, what power of 3 is required? This is called a discrete logarithm problem. In this way, we have a one-way function. It is easy to calculate in one direction, but it is easy to calculate in the opposite direction. It is very difficult, given that 12 is known, we can only use trial and error to find the matching prime number.


first level title

Diffie Hellman key exchange

The solution is this. First, the sender and receiver disclose the prime modulus and generator, which in this case are 17 and 3. Then the sender chooses a private random number, such as 15, and calculates 315 mod 17 (the result is 6), and then publicly send this result to the receiver, and then the receiver chooses his own private random number, such as 13, calculates 313mod 17 (the result is 12), and then publicly sends this result to the other party.

The key is to take the recipient's public result to the power of her private number to obtain the shared key, here is 10, and the receiver takes the sender's public result to the power of her private number to obtain the same shared key The key may not be well understood by everyone, but they actually perform the same operation.

Consider the sender, she received 12 from the receiver, from 313 mod 17, so her calculation is actually 3∧13∧15 mod 17, and the receiver, he received 6 from the sender, from 315 mod 17, so His calculation is actually 3∧15∧13mod17. The results of the two calculations are the same, but the order of the exponents is different. If the order of the exponents is changed, the result will not change. Their results are both, 3 is taken to the power of the private number of two people, Without these private numbers, 15 or 13, a third party would not be able to come up with the result.

A third party will be stuck in the discrete logarithm problem, and when the number is large enough, in practice, it is almost impossible for her to break it within a reasonable time limit. This solves the problem of exchanging keys, which can be compared with pseudo-random number generators Used in conjunction to provide encrypted communications for people they have never met.

Now commonly used algorithms in the blockchain, such as sha256, inherit the design thinking of one-way functions. It is easy to calculate in one direction, and almost impossible to crack in the other direction, so as to ensure security.

猎豹区块链安全
作者文库