Keys and Security

The Setup

Everyone agrees on:

  • A curve equation (like y2=x3+7y^2 = x^3 + 7)
  • A prime pp (defines the finite field)
  • A generator point GG
  • The order nn (how many points GG generates)

These are public parameters. Bitcoin’s secp256k1 curve has all these standardized.


Key Generation

Step 1: Pick a random private key dd.

This is just a random number between 11 and n1n-1.

For secp256k1, dd is a 256-bit number.


Step 2: Compute the public key QQ.

Q=d×GQ = d \times G

Multiply the generator GG by your private key dd.

The result is a point on the curve.


What the Keys Look Like

KeyWhat It IsSize (secp256k1)
Private key ddA random number256 bits (32 bytes)
Public key QQA point (x,y)(x, y)512 bits (64 bytes)

The public key can be compressed to 257 bits by storing only xx and one bit indicating if yy is even or odd (since there are two possible yy values).


Why Is This Secure?

An attacker knows:

  • GG (public)
  • Q=dGQ = dG (public)

To find dd, they need to solve:

Given GG and QQ, find dd such that Q=dGQ = dG.

This is the Elliptic Curve Discrete Logarithm Problem (ECDLP).


Why ECDLP Is Hard

You might think: “Just keep subtracting GG from QQ until you reach O\mathcal{O}.”

But dd can be as large as 22562^{256}.

Even at 1 billion operations per second, checking all possibilities would take longer than the age of the universe. Much longer.


No Known Shortcuts

For regular discrete log (like in Diffie-Hellman), there are sub-exponential algorithms.

For ECDLP, the best known attacks are fully exponential. There’s no mathematical shortcut.

This is why ECC can use smaller keys than RSA for the same security.


The One-Way Function

DirectionOperationDifficulty
ForwardCompute Q=dGQ = dGEasy (double-and-add)
BackwardFind dd from QQ and GGPractically impossible

This asymmetry is the foundation of ECC security.