ISheep

ISheep

Badminton | Coding | Writing | INTJ
github

Elliptic Curve Cryptography

How to generate an address? What is asymmetric encryption?

Steps to Generate an Address#

  1. Randomly generate a 256-bit private key (32 bytes).
  2. Obtain the public key through elliptic curve encryption.
  3. Apply two hash functions to the public key to generate a 20-byte address.

Elliptic Curve#

y2=x3+ax+by^{2} =x^{3} +ax+b

Animation

Where K is the private key and P is the public key.

Take a random point A(x, y) on the curve and calculate Kx+Ky equals P. That is, KA=P, and P is actually a coordinate point on the curve. In Bitcoin, there is a recognized point G that plays the role of point A, which means the random point is public, and G is like a constant.

Message Encryption#

NP problem: It is difficult to find out K given P and G, but it is easy to verify that P is correct based on K and G.

There are two people, Alice and Bob, each with their own public and private keys.

  • Alice: Pa Ka
  • Bob: Pb Kb

Pa = Ka * G

Pb = Kb * G

The public key is public. That is, the two parties can also know the other person's information.

  • Alice: Ka * Pb = Ka * Kb * G
  • Bob: Kb * Pa = Kb * Ka * G

These two pieces of information are equal, which means they have the same key. This key can be considered as a symmetric key that belongs only to these two individuals.

When Alice wants to write a letter to Bob, she encrypts the information with Pb, and Bob decrypts it with Kb, which is a reversible operation.

Digital Signature#

m: message

Alice signs m with Ka, m * Ka = N, similar to generating a public key with a private key (m is G).
The other party wants to verify that this statement was made by Alice.

m * Pa = m * G * Ka, which is equal to G * N. Since G is public, it can be quickly verified whether m is what Alice said.

Reference Video

Loading...
Ownership of this post data is guaranteed by blockchain and smart contracts to the creator alone.