Advanced Bitcoin
How Bitcoin works
In this lesson
Bitcoin is the first decentralised cryptocurrency, launched in 2009 by an anonymous developer or group using the name Satoshi Nakamoto. Its central innovation is the ability to send digital payments directly between people without a bank or other financial intermediary.
How can that work without someone in charge? Bitcoin brings together a blockchain, a decentralised consensus mechanism called Proof of Work (PoW), and cryptography. Participants can verify transactions, send bitcoin and receive it, helping make the system secure and resistant to censorship.
Cryptography and decentralisation
Public-key cryptography is fundamental to Bitcoin. Receiving addresses are derived from public keys and spending conditions. Private keys sign transactions, proving the right to spend without revealing the keys themselves.
Cryptography and Proof of Work work together so participants can verify transactions and maintain a shared transaction history without a central authority.
1. Nodes
Bitcoin nodes are computers or other devices running Bitcoin software. They help keep the network decentralised by independently storing, checking and passing on transactions and blocks. Two important types are full nodes and lightweight nodes.
Full nodes
Full nodes are the backbone of the network. They independently check blocks and transactions against Bitcoin's rules. Archival full nodes retain the entire history; pruned full nodes can delete older blocks after verifying them to save storage space. Their main roles include:
- Validating transactions and blocks: checking that the sender has spendable funds, using the UTXO model, and that signatures are valid for the relevant public keys.
- Enforcing consensus rules: checking every new block, including its proof of work and the absence of double spending.
- Sharing information: passing valid blocks to other nodes, allowing the network to stay synchronised without a central coordinator.
How full nodes contribute to security
Full nodes track unspent outputs and verify the history to prevent the same funds from being spent twice in the accepted chain. If a transaction tries to spend an output that has already been spent, they reject it.
A valid new transaction can enter a node's mempool, its collection of unconfirmed transactions. Miners choose transactions from their mempools when building blocks.
Lightweight nodes: SPV, or Simplified Payment Verification
Lightweight nodes do not keep the whole blockchain. They store block headers and obtain transaction information from full nodes. Merkle proofs let them check that a transaction appears in a block without downloading every transaction.
- Lower resource use: reduced storage and bandwidth make this approach useful on mobile devices and in lightweight applications.
- Different trust assumptions: they depend on full nodes for information and do not independently check all consensus rules. Their security assumptions therefore differ from those of full nodes.
2. Miners and mining
Miners help secure Bitcoin by building new blocks and adding transactions to the blockchain. They use specialised machines called ASICs to perform the repeated cryptographic calculations required by Proof of Work.
The Proof of Work algorithm
Miners search for a value called a nonce that, combined with the other block-header data, produces a double SHA-256 hash meeting the network's current target. The header includes a reference to the previous block.
There is no shortcut to the search: miners repeatedly hash candidate headers. Finding a suitable result requires substantial computing work. The target is adjusted every 2,016 blocks.
ASICs and the evolution of mining hardware
Early Bitcoin miners used ordinary CPUs. As competition and difficulty grew, mining moved to GPUs, which are better suited to parallel calculations. Specialised Application-Specific Integrated Circuits (ASICs) became the industry standard because they perform SHA-256 hashing much faster and more efficiently than general-purpose processors.
Network difficulty and consensus
Miners play an important role in consensus, but every full node checks each new block independently. When valid competing chains exist, nodes follow the one with the most accumulated proof of work. There is no vote requiring every participant's approval.
Mining adds a protective economic barrier: attacking the network, including attempting a “51% attack”, requires substantial resources and can be extremely expensive.
3. The difficulty adjustment
Bitcoin automatically adjusts mining difficulty to target an average of one block every ten minutes. The adjustment happens every 2,016 blocks, roughly once every two weeks.
How difficulty is adjusted
The adjustment compares the time taken by the preceding difficulty period with the target time. If blocks arrived too quickly, difficulty rises. If they arrived too slowly, it falls. In simplified form:
New difficulty = old difficulty × (target time / actual elapsed time)
Target time: 2,016 × 10 minutes = 20,160 minutes. Each adjustment is subject to a limit.This adaptive mechanism is one of the protocol's most striking ideas. It helps keep block production on schedule even when the amount of mining power changes.
The relationship between hashrate and difficulty
Hashrate is the combined rate at which miners attempt hashes. When more mining power joins the network, more attempts are made each second, so valid blocks tend to be found more quickly. Difficulty then rises at the adjustment to bring the average interval back towards ten minutes.
If mining power falls, difficulty can fall at the next adjustment. The network adapts rather than relying on a fixed amount of computing power.
This adjustment maintains the approximate block schedule. The overall issuance limit comes from the separate rules governing the block subsidy.
Why this matters for consensus
Difficulty and Proof of Work make rewriting Bitcoin's history expensive. In a 51% attack, someone with a majority of the hashrate could try to reorganise recent blocks, censor transactions or double-spend their own funds. That does not let them sign for other people or create coins in violation of the rules.
Full nodes still reject invalid blocks. There is no automatic mechanism that simply disconnects an attacking miner; the distribution of mining power also matters for security.
4. Blocks and the blockchain
What is inside a block?
A Bitcoin block contains several key components:
- Block header: information including the previous block's hash, a timestamp, a nonce and the Merkle root.
- Merkle tree: a structure that makes it possible to prove a transaction is included without providing every transaction in the block. Transaction hashes are combined in pairs, repeatedly, until one root hash remains: the Merkle root.
- Transactions: the transactions the miner has selected and included in the block.
Block hashes and the chain
Each block refers to the hash of the preceding block's header. Those references form a chain stretching back to the first block, the genesis block.
Change the contents of an older block and its hash changes too, breaking the links to the blocks after it. Rewriting accepted history would therefore require rebuilding the affected proof of work and catching up with the chain the network follows. This is what makes tampering so difficult.
Confirmations
A transaction receives its first confirmation when included in a block. Each subsequent block adds another confirmation and more work on top of it.
Six confirmations are often used as a reference point for stronger assurance, but they are not an absolute guarantee. The appropriate number depends on the payment's value and the risk involved. Reorganisation becomes harder as more work accumulates above the transaction's block.
5. The UTXO model: unspent transaction outputs
Bitcoin tracks funds using unspent transaction outputs, or UTXOs. An output from a previous transaction that has not yet been spent can become an input to a future transaction.
This differs from a traditional bank's account-balance model. A wallet's balance is the total of the outputs it can spend.
How does the UTXO model work?
When you make a payment, your wallet chooses which UTXOs to spend. Each has a specific value. Together, the selected inputs must cover the payment and the transaction fee.
An input is spent in full. If its value exceeds the payment and fee, a new output returns the remainder to you as change.
A UTXO example
Imagine Georgi has three UTXOs: 1 BTC, 0.5 BTC and 0.2 BTC. He wants to send Petar 0.6 BTC and chooses to spend the 1 BTC output.
Petar receives an output worth 0.6 BTC. The remainder returns to Georgi as a new UTXO. Ignoring the fee for simplicity, the change is 0.4 BTC. In a real transaction, the fee is deducted from that remainder.
Advantages of the UTXO model
- Flexibility: outputs can be combined and split, making transactions flexible and straightforward to verify.
- Separation from identity: funds are represented by spendable outputs rather than a centrally maintained account tied to a user's identity.
6. Bitcoin issuance and the 21 million limit
Bitcoin's limited supply is one of its defining features. The issuance rules, introduced by Satoshi Nakamoto, set a limit of 21 million bitcoin and are checked by nodes.
Changing that would require accepting different consensus rules. Nodes following the existing rules reject blocks that create more coins than those rules allow.
How is new bitcoin created?
Each new block includes a reward for the miner who found a valid proof of work. It has two components:
- Block subsidy: initially 50 BTC per block. Every 210,000 blocks, roughly every four years, the subsidy is cut in half. This is the halving.
- Transaction fees: the miner also collects the fees from the transactions included in the block. As the subsidy falls, fees become increasingly important to the incentive to mine.
7. Cryptographic signatures in Bitcoin
Digital signatures allow the holder of a private key to authorise spending. Bitcoin uses ECDSA, the Elliptic Curve Digital Signature Algorithm, as well as Schnorr signatures, introduced through Taproot.
ECDSA: Elliptic Curve Digital Signature Algorithm
ECDSA creates and verifies digital signatures. Bitcoin uses the secp256k1 elliptic curve, whose mathematical properties make calculations efficient while making it practically infeasible to derive a private key from its public key.
How does ECDSA work?
Two components are central:
- Private key: a secret number used to create signatures. Anyone who obtains it can authorise spending for the corresponding key, so it must be protected.
- Public key: derived mathematically from the private key. It lets other people verify signatures without learning the secret.
A signature is bound to the data it signs. Changing those data invalidates the signature, and anyone with the public key can check this.
Limitations of ECDSA
- Multisignature arrangements: complex conditions requiring several signatures are less space-efficient.
- Signature size: the signatures take up space that contributes to transaction size on the blockchain.
Schnorr signatures
Schnorr is an alternative digital signature algorithm added to Bitcoin through Taproot. It offers compact signatures and supports appropriate schemes for combining several signers into one signature.
Advantages of Schnorr signatures
- Signature aggregation: with a suitable multisignature scheme, several parties can jointly produce one signature. This saves space and can make their payment look like an ordinary single-signature payment, improving privacy.
- Compact signatures: smaller signatures allow more efficient use of blockchain space.
- A linear mathematical structure: this makes useful constructions and efficient verification possible, including in more complex signing arrangements.
Schnorr signatures in Taproot
Taproot combines Schnorr signatures with a tree of possible spending scripts. This supports arrangements such as multisignature conditions and time locks.
When funds are spent through the shared key, the key path, the script conditions stay hidden. When a script path is used, only the executed branch needs to be revealed. The result combines greater flexibility with improved privacy.
8. Bitcoin addresses
A Bitcoin address encodes information about the conditions under which funds sent to it can be spent. Depending on its type, that may involve a public-key hash, a script hash or a public key.
Different address formats reflect improvements in efficiency, functionality and the experience of using Bitcoin.
Legacy addresses: P2PKH
These original-style addresses begin with 1. P2PKH means Pay to Public Key Hash and uses SHA-256 and RIPEMD-160 to hash a public key.
- Format: begins with
1, for example1A1zP1eP5QGefi2DMPTfTL5SLmv7DivfNa. - Trade-offs: spending from these addresses uses more block space than comparable SegWit transactions and can cost more in fees.
Wrapped SegWit addresses: P2SH-P2WPKH
Segregated Witness, or SegWit, changed how signature data are represented in blocks. Wrapped SegWit allows its benefits within an address format beginning with 3.
- Format: begins with
3. Other P2SH scripts also use this prefix, so the prefix alone does not prove an address uses SegWit. - Advantages: more efficient use of block space and lower fees for comparable transactions.
Native SegWit addresses: Bech32
Native SegWit addresses beginning with bc1q use the Bech32 format and improve efficiency compared with Legacy addresses.
- Format:
bc1q…, showing only the prefix. - Advantages: lower fees than comparable Legacy transactions, with a checksum to detect typing errors. Taproot uses a different encoding, Bech32m, with the prefix
bc1p.
Taproot addresses: P2TR
Taproot, or Pay to Taproot, uses addresses beginning with bc1p. It brings Schnorr signatures together with a tree of possible scripts, allowing flexible spending conditions while revealing less information when those conditions are not needed.
- Format:
bc1p…, showing only the prefix. - Advantages:
- Privacy: key-path spending can hide complex conditions behind one signature. Script-path spending reveals the branch used.
- Efficiency: Schnorr signatures support compact signing arrangements and transactions.
- Flexibility: a tree of scripts supports more complex conditions while using blockchain space efficiently.
Taproot builds on SegWit's foundations and opens new possibilities for spending conditions that remain private until they need to be revealed.
Sources and original material
The introduction, eight main sections and examples are preserved. The web edition corrects the difficulty formula and the UTXO example, and clarifies full nodes, 51% attacks, signatures and address formats. Last edited: 25 October 2026.
What did you discover?
Three questions to try.
Choose an answer, then explore the explanation.
One more step forward.
When you’re ready, mark this lesson as read.