> For the complete documentation index, see [llms.txt](https://mvc-dao.gitbook.io/mvc-dao/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://mvc-dao.gitbook.io/mvc-dao/knowledge-base/basic-bitcoin-concepts/cryptography/public-key.md).

# Public Key

Introduction to what a public key is, how it is generated, and how it is represented.

## Introduction to Public Keys

A public key is essentially a set of coordinate values on an elliptic curve, which can be calculated from a private key.

## Elliptic Curve

An elliptic curve is a type of curve used in cryptographic systems. Point multiplication on the curve is used for encryption and decryption. A key characteristic of elliptic curves is that adding two points results in another point on the curve, allowing encryption through repeated addition.

<figure><img src="https://3872324389-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fy4gNPZSNO766WE54DILO%2Fuploads%2Fkgx9CY6sNMUlo2aDwrYJ%2Fimage.png?alt=media&amp;token=e0694818-9f67-41f9-a338-4a069352b74e" alt=""><figcaption></figcaption></figure>

### Definition of Elliptic Curve

An elliptic curve is usually represented by an equation of the form: $$y^2 = x^3 + ax + b$$ For secp256k1, the specific form of the equation is: $$y^2 = x^3 + 7$$ where (a = 0) and (b = 7).

The elliptic curve used by Bitcoin is a mathematical structure used for cryptography. Specifically, Bitcoin uses the elliptic curve secp256k1, defined over a finite field, commonly used in public key encryption.

## How to Calculate a Public Key

### Calculating a Public Key from a Private Key

1. **Choose the Base Point (G)**: The elliptic curve secp256k1 defines a base point ( G ), which is a fixed point with specific coordinates.
2. **Calculate the Public Key**: Using the private key (( k )) and the base point (( G )), the public key (( K )) is calculated through point multiplication on the elliptic curve. This process is similar to scalar multiplication: $$K = k \cdot G$$ Here, ( k ) is the private key, ( G ) is the base point, and ( K ) is the public key.

### Point Multiplication

Point multiplication is not ordinary multiplication but is achieved through a series of point addition and point doubling on the elliptic curve. The brief steps are as follows:

1. **Point Addition**: If there are two points ( P = (x\_1, y\_1) ) and ( Q = (x\_2, y\_2) ), their sum ( R = (x\_3, y\_3) ) is calculated as follows:
   * Calculate the slope ( m ): $$m = \frac{y\_2 - y\_1}{x\_2 - x\_1}$$
   * Calculate the coordinates of the new point: $$x\_3 = m^2 - x\_1 - x\_2$$ $$y\_3 = m(x\_1 - x\_3) - y\_1$$
2. **Point Doubling**: When ( P = Q ), the calculation is similar but with a different formula for the slope:
   * Calculate the slope ( m ): $$m = \frac{3x\_1^2 + a}{2y\_1}$$
   * Calculate the coordinates of the new point: $$x\_3 = m^2 - 2x\_1$$ $$y\_3 = m(x\_1 - x\_3) - y\_1$$

By repeatedly applying point addition and point doubling operations, the base point ( G ) can be transformed into the public key ( K ).

## Security of Elliptic Curve Encryption

The security of elliptic curve encryption relies on the difficulty of the Elliptic Curve Discrete Logarithm Problem ( ECDLP). It is extremely difficult to deduce the private key ( k ) from the public key ( K ), ensuring the security of the encryption.
