Public key encryption "Diffie-Hellman key exchange", color mixing trick

Prelude:
Diffie-Hellman key exchange is a security protocol. It allows two parties to create a key through an insecure channel without any prior information from the other party. This key can be used as a symmetric key to encrypt the communication content in subsequent communications.
Color mix:
Insert image description here

As shown in the figure, the snake and the mouse need to exchange a shared key. The two parties use the pig's color red as the basis (public). The mouse uses its own yellow (private) plus red and then makes the mixed color public. The snake uses its own The blue (private) plus red then public this mixed color.
At this time, the public colors that snakes, mice, and pigs can see are red, red mixed with yellow, and blue mixed with red. The mouse gets the snake's mixed color blue and red, and then adds its own yellow, and gets another mixed color blue, red, and yellow. Similarly, the snake gets the mouse's public color yellow and red, and then adds its own blue, and gets Mix colors yellow red blue.
A litter of snakes and rats ended up with the same mix of colors, but the pigs had no way of knowing the final mix. Because of the color difference, the pig cannot infer that the mouse uses yellow from the mixed color yellow and red of the mouse, and can only use brute force to crack it (which may take N years).
Multiply numbers:
Insert image description here

As shown in the picture, the snake and mouse pass the shared secret key again, and instead of playing the color trick, this time they play the numbers game. To make the number 12 public, the rat multiplies its private number 7 by 12 and then makes the result 84 public. The snake multiplies its private number 5 by 12 and then makes the result 60 public.

At this time, the numbers that snakes, rats, and pigs can see are 12, 84, and 60. The mouse takes the snake's public number 60 and multiplies it by the private number 7 to get the result 420. In the same way, the snake gets the mouse's public number 84, and then multiplies it by the private number 5 to get the result 420.

The snake and rat nest finally obtained the same number 420, but the pig was unable to get the final number from the three public numbers. It is assumed that the pig cannot divide and can only use multiplication to brute force the solution. Here we just use simple multiplication operations, which will be upgraded below.

Clock sums and powers:

There are 12 numbers on the clock, from 1 to 12, and then back to 1 after 12, so 13 o'clock is 1 o'clock (13-1=12), and 20 o'clock is 8 o'clock (20-12=8). The size of the clock can be set arbitrarily, usually starting from 0. For example, if the clock size is 11, it means from 0 to 10, and the clock calculation is (20) = 9.

Insert image description here

As shown in the figure, the snake and the mouse pass the shared secret key again. The bell size is publicly selected as 11, and the base is publicly selected as 2. The mouse uses its own private number 7 to exponentiate the base according to the base 2, and the result is calculated by the clock. The calculation result 7 is made public. In the same way, the snake uses its own private number 6 to perform a power operation on the base based on the base 2. The result is calculated by a clock, and the result of the clock calculation is 9. It is made public.
At this time, the snake, mouse, and pig can all know the clock size 11, the base 2, and the public numbers 9 and 7. The mouse obtains the snake's public number 9, then uses its own private number to exponentiate 9, and performs a clock calculation on the result to finally get the result 4. In the same way, the snake obtains the mouse's public number 7, then uses its own private number 6 to exponentiate 7, and performs clock calculation on the result to finally get the result 4.

A litter of snakes and rats eventually obtained the same number 4. Even though the pigs knew the size and base of the clock, they had no way of knowing which number clock 7 and 9 were calculated from. The numbers here are still relatively small. If you take a very large number, violent solutions will be ineffective.
Supplementary knowledge:
1. The choice of the bell size must be a prime number, and the base must be the primitive root of the bell size.
2. Primitive roots: Expand the base number and perform a clock calculation. The result will cycle through 1~ (clock size - 1).
3. Relatively prime, the common divisor of two numbers is only 1.
4. Euler function, the number of numbers that are relatively prime to n among positive integers less than n.

Guess you like

Origin blog.csdn.net/weixin_43275277/article/details/131770008