Cryptocurrency

Public Keys vs Private Keys

A clear technical guide to asymmetric cryptography: how elliptic curve math connects your private key, public key, and public address.

BlockchainCeylon Editorial Team
Updated:
4 min read
Public Keys vs Private Keys
Share:X (Twitter)LinkedIn
Educational Resource: This article is published for educational and conceptual study. Nothing in this document represents financial, investment, legal, or trading advice.

Introduction

At the heart of blockchain security lies asymmetric cryptography (also known as public-key cryptography).

In traditional symmetric cryptography, the same secret key is used to both encrypt and decrypt a message. While effective when two parties already share a secret, symmetric encryption fails in open peer-to-peer networks where strangers need to exchange verifiable value without meeting in advance.

Asymmetric cryptography solves this by generating a mathematically linked pair of keys: a Private Key and a Public Key.

In this article, we break down the mathematics, roles, and derivation pathways of public and private keys in blockchain systems.

The Mathematical Relationship

The two keys in a cryptographic pair serve inverse, complementary functions:

  • Private Key: A randomly generated, extremely large secret number that must never be revealed to anyone. It is used to generate cryptographic digital signatures that authorize transactions.
  • Public Key: Derived mathematically from the private key. It is shared publicly and enables anyone in the world to verify that a digital signature was genuinely produced by the owner of the private key.

Crucially, this mathematical derivation is strictly a one-way function:

[ Private Key ] ──(Elliptic Curve Multiplication: ECDSA)──► [ Public Key ]
      ▲                                                           │
      │                                                 (Cryptographic Hashing:
      │                                                   SHA-256 + RIPEMD160)
  IMPOSSIBLE                                                      │
  TO REVERSE                                                      ▼
                                                          [ Public Address ]

You can derive the public key from the private key in microseconds. However, calculating the private key from the public key would take all the supercomputers on Earth billions of years.

The Elliptic Curve Mathematics (secp256k1)

Both Bitcoin and Ethereum rely on a specific elliptic curve called secp256k1, defined by the mathematical equation:

$$y^2 = x^3 + 7 \pmod p$$

Where $p$ is a prime number equal to $2^{256} - 2^{32} - 977$.

The Private Key

A private key is simply a 256-bit integer chosen at random between $1$ and $1.1579 \times 10^{77}$ (approximately $2^{256}$).

To appreciate the scale of $2^{256}$, consider that the total number of atoms in the observable universe is estimated to be around $10^{80}$. Guessing someone's private key by brute force is statistically impossible.

The Public Key

To calculate the public key, the private key (a scalar number $k$) is multiplied by a predefined standard generator point on the curve ($G$):

$$K = k \times G$$

Because elliptic curve point multiplication is easy to compute forward but impossible to divide backwards (the Elliptic Curve Discrete Logarithm Problem), the public key can be safely broadcast to the world without ever exposing the private key.

Digital Signatures: Proving Ownership Without Revealing Secrets

How does a user spend funds on the blockchain?

When Alice transfers 1 BTC to Bob, she does not broadcast her private key. Instead, she creates a digital signature using the ECDSA (Elliptic Curve Digital Signature Algorithm) or Schnorr algorithm:

  1. Signing Phase (Alice): $$\text{Signature} = \text{Sign}(\text{Transaction Data}, \text{Private Key})$$ Alice combines the raw transaction data with her private key to produce a unique alphanumeric signature $(r, s)$.

  2. Verification Phase (Every Node): $$\text{Valid?} = \text{Verify}(\text{Transaction Data}, \text{Signature}, \text{Public Key})$$ Any node in the world can run the mathematical verification formula using only the public transaction data, the signature, and Alice's public key. If the math checks out, the node confirms Alice authorized the transaction.

How a Public Address Is Created

To improve privacy and minimize typing errors, blockchains do not use the raw public key as the user's destination address. Instead, they hash the public key further:

  • In Bitcoin: The public key is hashed using SHA-256, then hashed with RIPEMD-160, and finally encoded with checksum bytes into a Base58Check (e.g., 1A1zP1...) or Bech32 format (e.g., bc1q...).
  • In Ethereum: The public key is hashed using Keccak-256, and the last 20 bytes (40 hexadecimal characters) prefixed with 0x form the Ethereum address (e.g., 0x71C...).

Comparison Summary

Attribute Private Key Public Key Public Address
Visibility Strictly Confidential Publicly Shareable Publicly Shareable
Purpose Authorizes & signs transactions Verifies digital signatures Receives incoming transactions
Analogy Secret signature / Password Digital verification seal Bank IBAN or Account Number
Consequence of Loss Permanent loss of all funds Can be regenerated from private key Can be regenerated from private key

Summary

  • Public-key cryptography replaces centralized authentication with mathematical proof.
  • One-way elliptic curve functions guarantee that private keys cannot be reversed from public keys or addresses.
  • Digital signatures allow users to prove ownership and authorize transactions without ever exposing their secret keys to the network.
Topics Covered:
#Cryptography#Asymmetric Encryption#Security
Continue Learning

Related Guides

View all articles →