Mathematics encryption principle and process in blockchain

blocksight 2021-04-26 13:36:57 阅读数:158

本文一共[544]字,预计阅读时长:1分钟~
mathematics encryption principle process blockchain

Write it at the front

In the last section, we introduced Elliptic curve operations and security principles over discrete fields , With these foundations , This section describes how to use elliptic curves over discrete fields for encryption and decryption . If you find it difficult to read and understand this article , You can refer to some previous historical articles . In the future, the elliptic curve means by default Elliptic curves of modulo primes over discrete fields .

Encryption principle and process

Using the knowledge from the previous section , In the mold 𝑝(p It's a very large prime number ) On Finite Fields , The use of elliptic curves for encryption and decryption is also related to RSA A certain degree of similarity ( There will be a special article to explain RSA), Every user has his own public key and private key . The private key is the number selected by the user 𝑛( In the actual algorithm, it is an unpredictable value randomly generated by the random number generator ), The private key is kept secret by itself ; The public key is made up of 𝑃=𝑛𝐺(G Is the selected generator ), The calculated point , The public key is open to the public .

To sum up : The private key is an undisclosed number , The public key is a point on an elliptic curve .

Assume A And B Encrypted communication , The encryption process is as follows :

(1)A First, convert the plaintext message ( code ) by (𝑎,𝑏) Medium (𝑥,𝑦), Then randomly select a positive integer 𝑘( Also generated by the random number generator ), And make use of B The public key , Calculate the ciphertext as follows :

={𝑘𝐺,+𝑘} therefore , The ciphertext is actually composed of two points .

(2)B Received the ciphertext , Use your private key to do the following calculation , You can decrypt and get plaintext :

+𝑘−(𝑘𝐺)=+𝑘(𝐺)−(𝑘𝐺)=+𝑘(𝐺)−k(𝐺)= In the above formula , We use the commutative law of point multiplication :𝑘(𝐺)=(k𝐺) The decryption process is simply ,(1) In the ciphertext generated in , Second points +𝑘 Minus the first point 𝑘𝐺 With your own private key 𝑛 Product of .

Empathy ,B Encrypted information is sent to A,A So is the decryption process . Let's think about it ourselves .

Example drill

The parameters in the elliptic curve equation ( Do not understand the elliptic curve equation reference Last one ) Selected as :𝑎=0, 𝑏=−4,𝑝=199,𝐺=(2,2), The elliptic curve equation is :=−4,

hypothesis B The selected private key is =113, Its public key :=113𝐺=(192,161)

A I hope the news will be =(88,57)( notes : In general, the complete scene is that a piece of text is first transformed into a point on an elliptic curve , There are many ways of transformation , If necessary, we can introduce it separately , Here is an example of using the transformation point directly , Easy to explain ) Encrypted and sent to B, therefore A Randomly select positive integers 𝑘=103, And pass B The ciphertext is obtained by public key encryption :

={103(2,2),(88,57)+103(192,161)}={(96,66),(124,70)}B After receiving the ciphertext message , Use your own private key =119 To decrypt :

+𝑘−(𝑘𝐺)=(124,70)−113(96,66)=(124,70)−(190,62)=(88,57)=.

Be careful : there ‘+’ Is the mould p The point addition operation of , Previously introduced .

Come here ,B Decrypt smoothly and get clear text message ,A And B The encrypted communication between them is completed successfully . It should be noted that , Here is the elliptic curve, the parameter selection is relatively small , Easy to calculate and understand , The actual choice is a very large integer , Improve safety .

You can see the actual elliptic curve algorithm ( English abbreviation :ECC) Parameters ,p,g,n It's huge .ECC Recommended parameters :256k1

p=FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFEFFFFFC2F a=0000000000000000000000000000000000000000000000000000000000000000 b=0000000000000000000000000000000000000000000000000000000000000007 G=79BE667EF9DCBBAC55A06295CE870B07029BFCDB2DCE28D959F2815B16F81798 483ADA7726A3C4655DA4FBFC0E1108A8FD17B448A68554199C47D08FFB10D4B8 n=FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFEBAAEDCE6AF48A03BBFD25E8CD0364141————————————————

The next section talks about elliptic curve signature and its verification process . Welcome to your attention , If you have any questions, please leave a message !!

版权声明:本文为[blocksight]所创,转载请带上原文链接,感谢。 https://netfreeman.com/2021/04/20210425000405713p.html