Skip to content
CryptoAcademy logo CryptoAcademy
Menu
Lesson Beginner

Public and Private Keys: Your Digital Identity Explained

Every blockchain account is built on a key pair: a public key you can share and a private key you must protect. Think of the public key as your account number and the private key as the PIN that authorises spending. In this lesson you will learn exactly what each key does, how a wallet address is derived, how a digital signature proves you approved a transaction without revealing your secret, and why losing a private key means losing access to your funds forever.

In this lesson

  • Distinguish a public key, a private key and a wallet address
  • Explain how a digital signature proves authorisation without revealing the private key
  • Describe why losing a private key means losing access to your assets
  • Recognise safe practices for storing and backing up keys

What Is a Key Pair?

A blockchain identity is a key pair generated together by mathematics:

  • A private key is a secret number. It is the authority to spend or sign.
  • A public key is derived from the private key. It is safe to share and is used to verify signatures.

The relationship is one-way: you can compute the public key from the private key, but you cannot realistically compute the private key from the public key. This is the same idea behind the padlock-and-key analogy: anyone can snap a padlock (public key) shut, but only the key holder (private key) can open it.

A wallet address is a shorter, human-friendly string derived from the public key. It is what you share to receive funds. Crucially:

  • Address = where funds go
  • Public key = used to verify signatures
  • Private key = used to create signatures

If someone asks for your address, that is fine. If someone asks for your private key or seed phrase, that is a red flag — they are asking for full control of your funds.

Example · A Real-World Analogy: The Mailbox

Imagine a mailbox on a street:

  • The address is public. Anyone can drop a letter in.
  • The lock is like the public key: it lets people send to you, but not open the box.
  • The key to the mailbox is the private key. Only you can open it and take the letters out.

If you lose the mailbox key, the letters are still there, but you cannot retrieve them. If someone copies your key, they can take everything. Blockchain keys work the same way — but there is no locksmith and no customer support to reset them.

How Keys Are Generated and Used

A private key is a very large random number. For Bitcoin and Ethereum, it is 256 bits, which means there are about (2^{256}) possibilities — far more than the number of atoms in the observable universe. Because it is random, guessing is effectively impossible.

The flow from private key to address is a one-way pipeline:

  1. Generate a random private key.
  2. Derive the public key using elliptic curve multiplication (a one-way function).
  3. Hash the public key to produce the address.

Because each step is one-way, publishing your address and public key does not reveal your private key. This is why blockchains can be public and transparent while still keeping spending authority secret.

From Private Key to Public Key to Address
Symmetric encryption uses one shared key; asymmetric uses a public and a private key Symmetric — AES-GCM Same key encrypts and decrypts Plaintext pay 1 BTC Ciphertext a9f3…1c Shared key K secret, 256-bit Fast · problem: how to share the key safely? Asymmetric — RSA / ECDSA A public key and its private key are a pair Public key shared with everyone Private key never leaves the owner mathematically linked (trapdoor) Anyone encrypts → only owner decrypts Slower · solves key distribution and signatures How the web combines both (TLS) 1. Your browser fetches the site's public key inside a certificate. 2. Both sides derive a temporary symmetric session key (key exchange). 3. Everything after that is encrypted fast with AES-GCM — signatures only prove who you are.
The private key derives the public key, which derives the address. Each arrow is one-way: you cannot reverse the process to recover the private key.

Address derivation

\text{address} = \text{hash}(\text{public key})

The address is a hash of the public key, which is itself derived from the private key. Reversing either step is computationally infeasible.

Digital Signatures: Proving Without Revealing

When you send crypto, you do not send your private key. Instead, your wallet uses it to create a digital signature over the transaction details. The network then checks the signature against your public key.

A valid signature proves three things:

  1. Authenticity — the transaction was signed by the holder of the private key.
  2. Integrity — the transaction data has not been altered since it was signed.
  3. Non-repudiation — the signer cannot later deny authorising it.

This is powerful: the network can verify your authority using only public information, without ever seeing your secret. It is like signing a cheque — the signature proves you authorised it, but it does not reveal your identity or your bank PIN.

sign_and_verify.py python
# Simplified demonstration using the cryptography library
# pip install cryptography

from cryptography.hazmat.primitives.asymmetric import ec
from cryptography.hazmat.primitives import hashes, serialization

# 1. Generate a private key (KEEP THIS SECRET)
private_key = ec.generate_private_key(ec.SECP256K1())

# 2. Derive the public key (SAFE TO SHARE)
public_key = private_key.public_key()

# 3. Sign a message with the private key
message = b"Send 1 BTC to Alice"
signature = private_key.sign(message, ec.ECDSA(hashes.SHA256()))

# 4. Anyone can verify with the public key
try:
    public_key.verify(signature, message, ec.ECDSA(hashes.SHA256()))
    print("Signature is VALID: authorised by the private key holder")
except Exception:
    print("Signature is INVALID")

# 5. Tampering breaks verification
public_key.verify(signature, b"Send 100 BTC to Alice", ec.ECDSA(hashes.SHA256()))
# Raises InvalidSignature — the message changed after signing

Try Signing and Verifying

Generate a key pair, sign a message, then tamper with the message to see verification fail. Notice that the private key never leaves your side.

Try it yourself

Comparing the Three Identifiers

Identifier Secret? Purpose Safe to Share?
Private key Yes — never share Signs transactions, proves ownership No — sharing means losing funds
Public key No Verifies signatures Yes
Wallet address No Receives funds Yes — like an email address
Public Key / Address
  • Can be shared freely
  • Used to receive funds
  • Verifies signatures
  • Derived from the private key
  • Safe in a public profile
Private Key
  • Must be kept secret
  • Used to spend funds
  • Creates signatures
  • The root of your identity
  • Never type into a website or chat

Why Losing Your Private Key Means Losing Access

Blockchains have no account recovery. There is no password reset, no support line, no bank manager who can restore access. Ownership is cryptographic, not legal: whoever holds the private key controls the funds.

This creates two symmetric risks:

  • Loss — if you lose your private key and have no backup, the funds are permanently inaccessible. They remain on the blockchain, visible to everyone, but unspendable forever.
  • Theft — if someone else obtains your private key, they can sign transactions and drain your wallet. You cannot reverse it.

Most wallets use a seed phrase (12 or 24 words) that encodes the master private key. Anyone with the seed phrase can regenerate all your keys and access all your accounts. Treat it like the master key to a vault.

Never Share Your Private Key or Seed Phrase

No legitimate wallet, exchange, or support agent will ever ask for your private key or seed phrase. Requests for these are always scams. Store your seed phrase offline, ideally on paper or metal, in a secure location — never in email, cloud notes, screenshots, or chat apps.

  1. 1

    Generate

    A wallet creates a random private key and derives the public key.

  2. 2

    Receive

    You share your address so others can send you funds.

  3. 3

    Sign

    When spending, your wallet signs the transaction with your private key.

  4. 4

    Verify

    The network verifies the signature using your public key and includes the transaction.

  5. 5

    Settle

    Once confirmed, the transfer is final and irreversible.

Can someone steal my funds with just my public key or address?

<p>No. The public key and address are designed to be shared. Stealing funds requires the private key to create a valid signature.</p>

What is the difference between a private key and a seed phrase?

<p>A private key controls a single account. A seed phrase is a human-readable backup that encodes the master key from which many private keys (and addresses) can be regenerated.</p>

If I lose my private key, can I recover my funds?

<p>Only if you have a backup (such as a seed phrase or an exported private key). Without a backup, the funds are permanently inaccessible — there is no recovery mechanism on the blockchain.</p>

Is a hardware wallet safer than a software wallet?

<p>Generally yes. A hardware wallet keeps the private key offline and signs transactions internally, so the key never touches an internet-connected device.</p>

Does signing a transaction reveal my private key?

<p>No. A digital signature proves you hold the private key without revealing it. Mathematically, recovering the key from a signature is infeasible.</p>

Check your understanding

Practice · server-graded
  • Which of the following is safe to share publicly when someone wants to send you crypto?

    1 pt

Share this page

Send this link to a friend, or scan the QR code to open it on your phone.