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. In other words, KA = P, where P is a coordinate point on the curve. In Bitcoin, there is a recognized point G that plays the role of point A, meaning that the random point is public, and G is like a constant.

Message Encryption#

NP problem: Given P and G, it is difficult to find K, 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 keys are public. This means that both 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 message to Bob, she encrypts the message using Pb, and Bob decrypts it using Kb, performing 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 is easy to verify 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.