Bitcoin is not "unregulated;" it is regulated by algorithm instead of being regulated by government bureaucracies. Uncorrupted.
_Andreas M. Antonopoulos_
In this module, we take a closer look at the technical side of Bitcoin. We explain in simple terms the cryptography that secures the protocol and how transactions work. Some concepts may seem technical, but don’t worry. Many people use the internet every day without fully understanding how it works.
Learning Bitcoin’s technical side is a long journey that not everyone needs to take. While we encourage continued learning, this module focuses on the key basics.
The Bitcoin network is a shared record of transactions stored across many computers called nodes. This record, known as the Bitcoin ledger, is pseudonymous. It does not include personal details like names or ages, only transaction data and Bitcoin addresses. The ledger tracks every transaction since the blockchain began.
What Bitcoin gives us is a hard promise: the program will execute exactly as specified.
_Andreas M. Antonopoulos_
Public/Private Key Cryptography
Definition – Definition of Cryptography
Cryptography is the practice of turning information into a secret that only the right people can read.
Encryption is the process of turning information into a coded form so that only someone with the correct key can read it.
Decryption is the process of turning that coded information back into something readable.
In traditional cryptography, two people who want to communicate privately must first share the same secret key, similar to a shared password. One person uses this key to encrypt the message before sending it, and the other person uses the same key to decrypt and read it.
The problem with this system is that both people must already share the secret key. If someone else gets access to that key, they can read any intercepted messages.
Bitcoin solves this problem using a different approach called public-key cryptography, where users do not need to share secret keys in advance.
Public/private key cryptography solves the problem of sharing secrets. Instead of sharing a password, each person has two keys: a public key and a private key.
The public key can be shared with anyone.
The private key must always be kept secret.
If John wants to send something to Arel, he can use Arel’s public key. Only Arel can unlock it using his private key. Even if someone intercepts the message, they cannot read or use it without the private key.
In Bitcoin, this system is used to create digital signatures. A digital signature proves that the owner of a private key approved a transaction, similar to signing your name on a document. This is what allows Bitcoin transactions to be secure and verifiable without trusting a third party.
Info
Each user has two keys: a private key, which is kept secret, and a public key that can be shared with others.
The private key serves as a form of identification and proof of ownership, confirming: “This address belongs to me and I have control over it.”
Digital signatures are created to identify unique transactions.
Bitcoin transactions involve transferring the ownership of a certain amount of bitcoin from one address to another.
Encryption is used to ensure that only the real holder of the bitcoin has the authority to send their money to someone else. It ensures their property is guarded against malicious actors.
As an additional measure of protection, each Bitcoin transaction automatically gets a UNIQUE digital signature. This unique digital signature is powered by tamper-proof technology that helps the network verify that the real owner of the bitcoin, and not someone else, has sent them.
How a Bitcoin Transaction Works
Creating the Transaction: A user initiates a Bitcoin transaction by specifying details such as the recipient's address and the amount of bitcoin to be sent.
Digital Signature Generation: The sender generates a unique digital signature using their private key. This signature is a unique cryptographic code that verifies the transaction's authenticity.
Broadcasting the Transaction: The signed transaction is broadcast to the Bitcoin network, indicating the intent to transfer ownership of bitcoin from the sender to the recipient.
Verification on the Network: Nodes on the Bitcoin network receive the transaction and use the recipient's public key to verify the authenticity of the signature. of the transaction. Simultaneously, they use the sender's public key to verify the digital signature.
Confirmation on the Bitcoin network: If the verification is successful, the transaction will be added to the ledger, which serves as a secure, transparent record of all transactions. Once confirmed, the ownership of the bitcoin is officially transferred from the sender to the recipient.
Callout – Summary
The digital signature, created with the sender’s private key, proves that the transaction was authorized by the owner of the bitcoin.
The Bitcoin network can then verify this proof and record the transaction.
Hashing Explanation
Please don’t be intimidated by the technical terms and mathematical concepts ahead. We understand that not everyone is crazy about math, but you might surprise yourself and see that even the most complex ideas can be grasped with a little bit of effort.
Definition – Definition of a function
A function is like a machine that takes some information and turns it into something new. The information you give the function is called the input. The new information the function creates is called the output. Functions help computers do tasks and solve problems.
What is a function?
A function is a set of instructions that takes an input and produces an output. You can think of it like a recipe: you follow the steps with certain ingredients, and you always end up with a predictable result.
In Bitcoin, functions are used to process and verify transactions. When someone sends bitcoin, cryptographic functions help check that the transaction is valid, confirm that the sender has enough funds, and update the balances on the Bitcoin ledger. Once verified and added to a block, the transaction becomes part of the permanent record on the blockchain.
What is a one-way function?
A one-way function is a special type of function that is easy to compute in one direction but extremely difficult to reverse.
For example, blending ingredients into a smoothie is easy, but you cannot separate the smoothie back into the original ingredients.
Bitcoin security relies on one-way functions. They are used in public and private key cryptography, allowing people to share a public key while keeping their private key secret. Even though the public key is visible, it is nearly impossible to derive the private key from it. This is what makes Bitcoin transactions secure.
What is a hash function?
Definition – Definition of a hash function
A hash function is like a secret code machine.
It takes in a message and turns it into a code.
How Hashing Works in Bitcoin Transactions
In Bitcoin, every transaction is turned into a hash before it is added to the blockchain. A hash is a unique digital fingerprint of the transaction. If anyone tries to change even a small part of the transaction, the hash will change completely. This makes it easy for the network to detect tampering.
The Role of Hashing in Bitcoin Security
Hashing helps protect the Bitcoin network by making transactions easy to verify and impossible to quietly modify. Because each transaction has its own unique hash, the network can quickly detect if something has been altered.
A hash function takes data and converts it into a fixed string of numbers and letters called a hash. The same input will always produce the same hash, but even a tiny change in the input will create a completely different result. This property allows computers to check that data has not been changed.
Definition – Definition of Hashing
Hashing is like creating a fingerprint for digital data. It is the process of taking a digital message and turning it into a fixed length code, which serves as a unique identifier. Just like a fingerprint can identify a person, a hash can identify a digital message. Hashes are used in many applications, including Bitcoin transactions.
The output, or hash, is always the same length, no matter how long the original information was. Bitcoin uses a few specific types of hash function called SHA-256 and RIPEMD160.
This input is a huge file yet the output is still the same fixed length
You can also think of hashing as a musical score that captures the essence of a piece of music. Just as a musical score is a unique representation of a tune, a hash value is a unique representation of a piece of data.
By comparing the score of a piece of music with the actual performance, a musician can determine if the performance is accurate. Similarly, by comparing the hash value of received data with the original hash value, one can determine if the data has been altered during transmission.
Just as a slight deviation in a musical performance can cause it to sound different, even the slightest change to the original data will result in a different hash value. This makes hashing a powerful tool for ensuring the integrity and authenticity of a Bitcoin transaction.
The process of encoding the public key through hashing is used to improve the security of information by converting it into a fixed-length, unreadable format. Bitcoin uses the SHA-256 and RIPEMD160 algorithms to produce public addresses. The resulting output serves as a unique identifier for the public key and helps to ensure the integrity and security of transactions stored in the ledger. By encrypting the information in this way, it becomes more difficult for unauthorized individuals to access and manipulate the data.
Properties of a hashing function
Deterministic: The same ingredients always produce the same smoothie. In the same way, the same data will always produce the same hash.
Pre-image resistance: If you only have the smoothie, you cannot figure out the exact fruits that were used. Similarly, if you only have a hash, you cannot determine the original data.
Avalanche effect: Changing even a tiny part of the ingredients creates a completely different smoothie. In hashing, a very small change in the data produces a completely different hash.
Collision resistance: It is extremely difficult to find two different sets of ingredients that produce the exact same smoothie. In the same way, it is extremely unlikely that two different pieces of data will produce the same hash.
Fast to verify: Making the smoothie is quick, and it is easy to check that the result is a smoothie. Hash functions are fast to compute and easy for anyone to verify.
Activity: Generate SHA 256 Hash
https://tools.keycdn.com/sha256-online-generator
Curious about how hashing works?
Scan the QR code to instantly generate a SHA256 hash from any word, sentence, or input you choose.
Hash functions are like digital fingerprints: they're one-way, meaning once something is hashed, it can't be reversed.
In this section, we’ll take a closer look at two very important parts (and participants) of the Bitcoin network that were first introduced in Module 5:
Bitcoin Nodes: Gatekeepers of validation whose main job is to keep a copy of the Bitcoin ledger, and to make sure that all transactions are valid and that everyone follows the same rules. By distributing this job among many people worldwide, Bitcoin stays strong against potential fraud without relying on a centralized authority. Nodes help keep the system trustworthy and true to its decentralized ethos, where no one person or group has too much power over the rest.
Bitcoin Miners: Architects of security who solve cryptographic puzzles by using powerful computers and electricity. They check and confirm transactions, making sure everything is secure. Their computational work helps make the ledger (or blockchain) resistant to any bad by making the alteration of the blockchain expensive in energy terms.
Together, Bitcoin nodes and miners work as a team to maintain a decentralized, secure, and strong system — a truly novel monetary system that people all around the world can rely on. Let's explore these roles in more detail to understand how they contribute to the Bitcoin protocol.
Bitcoin nodes may sound technical, but they are simply software that keeps a copy of the Bitcoin blockchain on a computer. The blockchain is a shared record of all Bitcoin transactions.
When you run your own node, you verify Bitcoin transactions yourself instead of trusting someone else. This gives you more independence and helps keep the Bitcoin network decentralized.
You can think of a Bitcoin node as a digital traffic officer with a few important jobs.
First, it keeps a copy of the blockchain, which is the history of all Bitcoin transactions.
Second, nodes connect with other nodes around the world and share information. One example is the list of new transactions waiting to be confirmed, which is called the mempool.
Third, nodes check that every transaction follows Bitcoin’s rules. If a transaction is invalid, the node rejects it.
Nodes also help new nodes join the network by sharing the blockchain with them. However, every new node still checks all the rules independently.
Anyone can run a node by installing software such as Bitcoin Core and downloading the blockchain. Once it is set up, the node continues to receive new blocks roughly every 10 minutes and verifies them before adding them to its copy of the blockchain.
Running a node helps make the Bitcoin network more secure and decentralized, because more people are independently verifying the system.
What Is a Bitcoin Node?
The purpose of mining is not the creation of new bitcoin; that’s the incentive system. Mining is the mechanism by which Bitcoin’s security is decentralized.
_Andreas M. Antonopoulos_
Callout
Miners collect unconfirmed transactions, form a block, and use energy to find a key that adds and secures the block.
Miners compete to add the next block of transactions to the blockchain. To do this, they must find a special number that creates a valid block hash. You can imagine it like searching for the right key among billions of possibilities. The first miner to find the correct hash wins the race and earns the right to add their block to the blockchain.
When a miner finds a valid hash, they share their block with the network. Other miners quickly verify that the solution is correct. If it is, the block is added to the blockchain, helping keep Bitcoin’s public ledger secure.
Miners earn bitcoin in two ways:
Block rewards: New bitcoin are created and given to the miner who successfully adds a block to the blockchain.
Transaction fees: When people send bitcoin, they include a small fee. The miner who adds the block receives the fees from the transactions included in that block.
Bitcoin Halvings
2009
2012
2016
2020
2024
50 BTC
25 BTC
12.5 BTC
6.25 BTC
3.125 BTC
Callout
Miners’ rewards for completing one block halve every 210,000 blocks, about every four years.
Bitcoin has a fixed maximum supply of 21,000,000 bitcoin, but all of them were not created when Bitcoin started. Instead, new bitcoin are gradually introduced into circulation through mining.
When miners successfully add a new block of transactions to the Bitcoin network, they receive a block reward in bitcoin. In the early days of Bitcoin, this reward was 50 bitcoin per block. This reward encouraged people to use computing power and electricity to help secure the network.
About every 210,000 blocks (roughly every 4 years), the block reward is cut in half. This event is called the halving. The halving slows down the creation of new bitcoin and helps ensure that the total supply will never exceed 21 million. Over time, this makes bitcoin increasingly scarce.
Definition – Circulating supply
Circulating supply refers to the total available amount of a currency. With Bitcoin, the total circulating supply is the number of coins that have been mined and are incirculation at any given time.
Definition – Bitcoin supply schedule
The Bitcoin supply schedule is the predetermined and public plan for the release of new bitcoin into circulation, designed to maintain Bitcoin’s scarcity over time.
After each halving event, the bitcoin reward that miners receive for adding a block is cut in half. This reduces the rate at which new bitcoins are created.
Miners still earn transaction fees from the transactions included in the block they mine. Over time, these fees are expected to become a larger part of miners’ income.
Halvings are built into the Bitcoin protocol and happen automatically about every four years. Because of this, Bitcoin’s supply schedule is predictable and transparent.
The table below shows upcoming halvings, including the approximate date, the block number when they occur, the new block reward, and the percentage of the total bitcoin supply that will have been mined.
Event
Date
Block
Reward
Mined
5th Halving
2028
1,050,000
1.5625 BTC
98.44 %
6th Halving
2032
1,260,000
0.78125 BTC
99.22 %
7th Halving
2036
1,470,000
0.390625 BTC
99.61 %
As more bitcoin are mined, the circulating supply keeps increasing until the maximum supply of 21,000,000 bitcoins is reached, which is expected around the year 2140. Because fewer new bitcoins are created over time, if demand increases, the price of Bitcoin can rise. This also encourages miners to keep securing the network by contributing their computing power.
What is a valid block hash in Bitcoin?
In Bitcoin, miners compete to find a special code called a block hash. This code identifies a block of transactions and allows it to be added to the blockchain.
Each block contains information about recent transactions and also includes the hash of the previous block. This links every block together, forming a chain from the very first block (the Genesis Block) to the most recent one.
A hash works like a digital fingerprint for the data in the block. If any information in the block were changed, the fingerprint would change as well. This makes it easy for anyone to verify that the blockchain’s transaction history has not been altered and helps keep the network secure.
Callout
Satoshi Nakamoto, the creator of Bitcoin, mined the Genesis Block, which unlocked a total of 50 bitcoin.
The Race to Mine a Block
Miners compete to find a valid block hash. The first miner to find one gets to add the new block to the blockchain and receive a bitcoin reward.
To be valid, the block’s hash must be lower than a number set by the network called the difficulty target. Because hashes are random, miners must keep trying different inputs until they find one that works.
If too many miners are competing, blocks would be found too quickly. If too few miners are participating, blocks would take too long to find. To keep the system running smoothly, Bitcoin automatically adjusts the difficulty every 2,016 blocks (about every two weeks).
This adjustment ensures that, on average, a new block is added to the blockchain about every 10 minutes.
Definition – Definition of difficulty level
The difficulty level in Bitcoin mining measures how hard it is to find a valid block hash. The network adjusts this difficulty every 2,016 blocks (about every two weeks) so that new blocks are added to the blockchain about every 10 minutes. The higher the difficulty, the harder it is for miners to find a valid block.
Info
By finding a valid block hash, a miner proves they have done the work required to add a new block to the blockchain. This process is called Proof of Work (PoW). It is the security mechanism that allows Bitcoin to confirm transactions and add new blocks to the blockchain. The miner who finds the valid hash first earns a reward in bitcoin, which includes the block reward and the transaction fees from the transactions included in that block.
Proof of Work (PoW) helps keep Bitcoin secure by making it extremely expensive for anyone to try to cheat or take control of the network. Instead, it is far more profitable to follow the rules.
Miners play four main roles:
Collect transactions: Miners choose transactions that have been sent to the network and place them into a candidate block.
Perform Proof of Work: Miners compete to solve a difficult mathematical puzzle by finding a valid block hash.
Broadcast the block: The first miner to find a valid solution shares the new block with the network.
Earn rewards: If the block is valid, it is added to the blockchain and the miner receives newly created bitcoin plus transaction fees.
Many miners around the world try to create the next block at the same time. When one miner finds a valid solution, the network checks the block. If everything is correct, it is added to the blockchain. Other competing blocks are discarded. This process keeps the network in agreement and prevents double-spending.
Miners are computers that help maintain and update Bitcoin’s ledger.
They collect transactions and group them into a block. Then they run the block’s data through a hashing algorithm to create a unique code called a hash.
Miners repeat this process many times, searching for a hash that meets Bitcoin’s rules. The first miner to find a valid hash gets newly created bitcoin as a reward, and their block is added to the blockchain.
Each block’s hash also connects it to the previous block. If someone tried to change a past transaction, the hashes would no longer match, and the network would reject the altered chain. This is what keeps Bitcoin’s ledger secure.
The mempool, short for “memory pool,” is like a waiting room for Bitcoin transactions. When you send bitcoin, your transaction is first broadcast to the network and placed in the mempool.
You can think of it like waiting in line at a restaurant. Your name goes on a list, and you wait until a table is available. In the same way, your transaction waits in the mempool until a miner includes it in a block.
Bitcoin nodes check each new transaction to make sure it is valid and that the bitcoin being spent has not already been used. If the transaction is valid, it stays in the mempool until it is confirmed.
Miners choose transactions from the mempool and include them in new blocks. Usually, transactions with higher fees are chosen first.
Once a transaction is included in a block, it becomes confirmed and is permanently recorded on the Bitcoin blockchain.
Activity: Exploring the Mempool
https://qr.myfirstbitcoin.org/mempool.pdf
This activity exposes students to a free and open-source tool that does not require technical skills to use. It is useful for Bitcoiners at all levels, from beginner to experienced.
Key Points
Mempool refers to the list of unconfirmed transactions maintained by each Bitcoin node, not a specific service or platform.
This is no single, universal mempool. Mempool.space is one of many.
Mempool.space is open-sourced and well known for being an easy-to-use visual block explorer. It provides real time data on unconfirmed transactions, fee rates, and other network activity.
Student Tip
Mempool.space does much more than visualize blocks. Explore other parts of the Bitcoin ecosystem: e.g., Lightning, mining, the hash rate, pools, and block space "goggles".
Now that you understand public and private keys, as well as the roles of nodes and miners, here’s how a Bitcoin transaction works from start to finish.
Adam wants to send bitcoin to Gerardo. He creates a transaction with Gerardo’s address, the amount to send, and a fee.
Adam signs the transaction with his private key to prove ownership.
He broadcasts the transaction to the Bitcoin network.
Nodes receive it and check that it follows the rules, including verifying the signature and that Adam has enough bitcoin.
If valid, the transaction is shared across the network and added to the mempool, where pending transactions wait.
Miners pick transactions from the mempool and include them in a block they try to mine.
When a miner successfully mines a block, it is shared with the network and checked by other nodes.
If valid, the block is added to the blockchain. Gerardo receives the bitcoin.
As more blocks are added, the transaction gains confirmations, making it more secure.
Once included in a block, the transaction is confirmed. Adam cannot spend that bitcoin again, and Gerardo can spend what he received in a new transaction.
Note
Transaction & fee selected → Signed by wallet and sent → Distributed by nodes → Miner adds transaction to block template → Miner wins Proof-of-Work contest → New block is validated → New block is distributed by nodes