— —
Follow on X
LESSONS

Keys, hashes and signatures

Outputs are locked to keys. A signature proves the holder authorised one exact transaction without revealing the key. Hashes tie everything together.

6 MIN READ
An output locked to a public key hash is unlocked by a signature that nodes verify with the public key.
LEVEL · Intermediate
IN THIS LESSON · 3 OF 9
BY THE END YOU WILL BE ABLE TO ANSWER
  • What does a digital signature prove?
  • Can a public key be used to derive the private key?
  • What is a private key, in this lesson's terms?
  • Hash the word "bitcoin" with SHA-256 using any offline tool. How many hex characters is the result?

Then prove it: a 3-question quiz · a challenge. The lesson marks itself complete at 100%.

After this lesson you can: explain what a signature proves and what it does not.

Two pieces of cryptography do almost all the work in Bitcoin: hash functions and digital signatures. Neither is encryption; nothing on the chain is hidden.

Hashes

A hash function turns any input into a fixed-size fingerprint. Bitcoin uses SHA-256, which produces 256 bits (64 hex characters). Change one character of the input and the whole output changes. You cannot work backwards from a hash to its input. Hashes give every transaction and block an ID, link blocks together, and set the mining puzzle.

Three inputs that differ by one character and their completely different SHA-256 fingerprints.
Real SHA-256 output. Change one character and nothing in the fingerprint carries over.

Keys

A private key is a random 256-bit number. From it, elliptic-curve math (the curve is called secp256k1) produces a public key. The step is one-way: easy forward, infeasible backward. An address is a hashed, encoded form of the public key.

One-way chain from private key to public key to address.
Every arrow is one-way. Nobody can walk from an address back to the key.

Signatures

When you spend an output, your wallet signs the transaction with the private key. The signature is specific to that exact transaction: change one byte and it fails. Anyone can verify the signature using only the public key, which is why nodes can check your payment without knowing your key. Bitcoin used ECDSA from the start and added Schnorr signatures with Taproot in 2021.

A private key signs a transaction; anyone with the public key can verify the signature.
Sign with the secret, verify with the public part. The key never leaves your device.

Locks

Table of locking scripts: single signature, multisig, timelock, hash secret.
Four kinds of lock an output can carry.

Each output carries a small script, the locking script, that says how it may be spent. The common one says "whoever provides a signature matching this public key hash". Other scripts require several signatures, or a timelock, or a secret. Script is deliberately simple so nodes can always evaluate it quickly and predictably.

Bitcoin Explained Simply · Keys and signatures in contextWatch on YouTube ↗

Tap a card to flip it.

MINI CHALLENGEHash it

Hash the word "bitcoin" with SHA-256 using any offline tool. How many hex characters is the result?

characters
CHECK YOURSELF
1/3 What does a digital signature prove?
2/3 Can a public key be used to derive the private key?
3/3 What is a private key, in this lesson's terms?
pick an answer for each question

SOURCES

  1. Learn Me A Bitcoin: How does Bitcoin work?
Progress is saved in this browser only.