Bitcoin. How does it work?

Other articles in this series:
Bitcoin: What is it?
Bitcoin: What is its core value proposition?

Individual Bitcoins (or multiples and fractions of a Bitcoin) are in fact tiny computer programs recorded on an open ledger and controlled by private cryptographic keys.

Wallets store, send and receive Bitcoin. Miners compete with one another to secure the blockchain by bundling these transactions into blocks and adding blocks on top of one another. This process requires huge amounts of computing power and electricity and for their efforts miners are rewarded with new Bitcoin. Nodes can be operated by anyone with a basic laptop and they keep miners honest by checking that they mine according to the rules. Nodes also send information to wallets so that wallets can verify who owns how much Bitcoin and they check that no one spends Bitcoin that they don’t own.

Broadly speaking there three different elements that make up the Bitcoin network: Miners. Nodes. Wallets. Together these three form the backbone of Bitcoin.

First, anyone with an Internet connection and a basic laptop can download any of the Bitcoin software. Whether they want to run a node, a miner or a wallet. There is no permission required. No application process. No documents that need to submitted. Nothing. It’s a simple as visiting a website and downloading software which is legally available for download to anyone.

It is also legally allowed to modify and distribute this software, meaning the software can be modified and people are free to choose which version of the software they choose to run.

While some jurisdictions prohibit the ownership of Bitcoin as a financial asset, there’s nothing that prevents people from downloading and running the software.

NODES:

A Bitcoin node can be run on any home computer. But more basic computers will have to dedicate very large parts of their computing resources toward running the Bitcoin node software, so generally nodes are set up to run on dedicated computers, or some other Internet connected device, that serves no other purpose.

I run a full node on an old second-hand laptop with a standard Dual-Core 2.3 GHz CPU, 4 GiB of RAM and a 500 GB Hard drive. Nothing spectacular. The operating system I use is Ubuntu 18.04 LTS. The laptop easily handles the task of running the node, but I don’t use it for anything else because the Bitcoin software slows the computer down, to the point where opening a word processor (while the node software is running) can take up to a minute. If I did want to use the computer for something else, I couldn’t simply close the Bitcoin program and open it again when I’m done.

There is no financial reward for running a node, in fact it runs at a cost. There’s the fractional cost of electricity, to keep the laptop running, preferably 24 / 7, and there’s bandwidth costs, which involves downloading and uploading new transactions and blocks as they are created and propagated throughout the network.

Bandwidth costs can be mitigated by limiting the download and upload targets and / or the number of peers (other nodes or wallets) your node is connected to, but that can affect the contribution it makes to the network.

Without any pre-set limits, to run a full node, you would need to download about 20 Gigabytes per month and upload between 100 – 300 Gigabytes per month. Depending on your internet service provider and your type of connection, these costs obviously aren’t negligible.

But even strictly limited nodes still contribute and support the network, as long as they can upload and download at least 144 megabytes and run for at least six hours every day, they’re supporting the network to some extent.

Nodes are essential in order to secure the network and they are run mostly by enthusiast such as myself with a vested interest, or by businesses that use Bitcoin and benefit from having a healthy network.

Personally, I don’t mind the costs of running my node, even at full capacity, not in the slightest, not considering the value I gain simply from storing Bitcoin safely on the blockchain.

And there are more than enough people who feel the same way. In 2015 the node count was just over 5,000 nodes, today that number has gone up to 10,000. Even around the Dec 2018 low, when the mainstream media declared Bitcoin “dead” the number of nodes never dropped below 9,000.

Nodes do several things. They store a copy of the entire Bitcoin blockchain, which, at the moment (April 2020) measures just under 275 Gigabytes. The blockchain holds a record of every single transaction ever made on the Bitcoin network, since its inception in January 2009. Transaction are stored in blocks that are added to the blockchain in a linear and sequential manner. The genesis block (block no. 0) was created when Bitcoin was launched in January 2009, it was followed by block no.2, block no.3 and block no.4, and so and so forth, until by April 2020 just under 630,000 blocks had been added to the blockchain.

Each block has a maximum capacity of 1 megabyte and can hold up to 3000 transactions, depending on the size of each transaction, which isn’t measured in terms of its value, but it’s actual data size. This size varies, because there are different types of transactions.

Because Bitcoin is programmable money, transactions can be programmed to do different things, not just transfer value from person A to person B. As a simple example you could transfer value from person A to B, but put a time-lock on the transaction, making it impossible for person B to spend the money until after a certain point in time.

These special transactions are also referred to as ‘smart contracts’ and were essentially invented with the creation of Bitcoin. These special transactions require more data than a regular transaction, even if the value being transferred remains the same.

All transactions, whether simple or complex, are added into blocks and new blocks are created approximately every ten minutes. Thus the 275 Gigabyte blockchain grows bigger by about 1 megabyte every ten minutes, or 144 megabytes per day.

In another ten years from now, around the year 2030, we can therefore expect the blockhain to have reached a size of approximately 775 Gigabytes. And it will continue growing by about 500 Gigabytes every ten years. Which, with the ongoing improvements in digital storage technology, should remain well within range of average home computers. Already today it is common for new laptops and PC’s to have a pre-installed hard drive measuring a Terabyte or more.

My full node, along with approximately 10 000 other full nodes running all around the world, validate every single transaction broadcast to the network. Making sure, for example, that the same Bitcoin isn’t spent twice by someone trying to cheat the system.

Nodes also validate every block of bundled transactions added to the blockchain, making sure, for example, that the blocks are joined end-to-end in the same order on every copy of the blockchain stored by all the nodes, so that all nodes agree on the state of the blochchain and its record of transactions, at all times.

Full nodes also send information to the millions of wallets that request certain parts of the blockchain when conducting transactions between one another.

And full nodes validate that the monetary policy of Bitcoin is not breached, in other words, that new Bitcoins are not created outside the parameters set forth by the protocol.

WALLETS:

Every node can be a wallet, if so desired. But not every wallet can be a full node. As described above, running a full node is quite a task and there are countless wallets that simply hold, send and receive Bitcoin, but do not perform the function of a full node.

Wallets that do not function as a full node are known as light wallets in reference to the fact that they do not validate the full weight of the 275 Gigabyte blockchain. Light wallets represent the majority of wallets on the network and can be operated using negligible computing resources. Even the most basic smart phone can function as a wallet, with which unlimited amounts of Bitcoin can be safely stored, sent and received.

Technically the most secure way of storing Bitcoin is in the form of a full node wallet, as this is the only way to be absolutely 100% certain (beyond any measure of doubt) that your Bitcoin is secure. In theory it is possible to fool a light wallet, but with the amount of development that has gone into making wallets user friendly and secure, this has become unlikely to the point where large sums of Bitcoin can be safely stored in them, provided that you choose a good wallet and maintain good security practices.

Because it is a cumbersome process to operate a full node the design of Bitcoin allows for the use of light wallets and does not need every wallet to function as a full node. There are enough full nodes on the network to ensure that light wallets can source the information they need to function. And people who store significant amounts of value on the blockchain have incentive to run a full node, meaning that if Bitcoin continues to grow, the node count will take care of itself. Light wallets are therefore not discouraged and a lot of good development by Bitcoin experts go into making these wallets highly secure.

It is very difficult to estimate the total number of wallets in existence, because wallets themselves are not uniquely identifiable. Public addresses stored within wallets are uniquely and publicly identifiable, but there is no limit to how many addresses a wallet can hold, and one person may use any number of addresses to store their Bitcoin, spread throughout any number of wallets.

Furthermore, some people store their Bitcoin within centralized services. This isn’t advisable, unless you’re trading, which itself isn’t advisable, but these people none the less own Bitcoin which is stored in a virtual wallet of sorts, and those services may store thousands of individuals’ Bitcoin on one blockchain address.

However, through a combination of public surveys and blockchain analysis it is estimated that there are approximately 100 million people worldwide who own Bitcoin, stored either on a centralized service or exchange, or in a wallet of their own.

Anyone can write software that can interact with the Bitcoin blockchain, thus anyone is free to create their own wallet and offer it to others, sometimes for a fee, but mostly free of charge. Some of the best wallets available are open source and free to use.

Wallets come in thousands of different flavours. Some are built by large highly profitable companies, who may also offer other financial services within their wallets, while other wallets are built by individuals, as a hobby.

A wallet, as the name implies, is where Bitcoin is stored and from where it is sent and received to other wallets.

Some wallets also offer the option to buy and sell Bitcoin within the wallet, or to exchange Bitcoin for any number of other crypto currencies. In this case the wallet is linked with an external exchange and you will likely have to register and provide personal details to sign up for their exchange services.

In order to transact in Bitcoin (and in most other crypto currencies) you only need to download a wallet. Some Bitcoin wallets only work with Bitcoin, while others cater for multiple crypto currencies.

Essentially there is nothing that resembles a digital coin that exists anywhere on the Bitcoin network. All Bitcoins (or rather, fractions or multiples of a Bitcoin) are actually tiny computer programs that run on the network and are broadcast between computers.

If I own 1.5 BTC and I paid you 0.75 BTC a series of tiny programs are written and executed by our two corresponding wallets and subsequently recorded onto the blockchain. Our wallets may differ vastly in their design, we don’t need to use the same wallet, so long as both interact with the Bitcoin blockchain, we can transact with one another.

Stored on the blockchain there is a tiny program (technically known as an Unspent Transaction Output, UTXO) which tells the entire network that my wallet owns the balance of 1.5 BTC specified by that particular UTXO.

And in essence, all Bitcoins are nothing more than Unspent Transaction Outputs. Those tiny program are then also linked to a specific and completely unique set of public-private keys.

When I send you 0.75 BTC my wallet takes the UTXO that specifies I own 1.5 BTC, and uses it as an input to create a transaction. As an output it creates two completely new UTXOs and broadcasts both to the network, to be included in the blockchain. One of the new UTXOs specifies that my wallet now owns 0.75 BTC and your wallet owns the other 0.75 BTC.

Importantly the second UTXO is now no longer linked to my private keys, but instead it is linked to yours.

Before I can send you Bitcoin I need to know your public key, that is how my wallet knows where to send the Bitcoin. And that is the only thing I need to know about you. I don’t need to know where in the world you are, I don’t need to know your name, and I don’t need to know anything else about you.

This is why the creator(s) of Bitcoin called their invention an electronic cash system, because like a cash transaction, the only thing that gets exchanged is the asset of value. And unlike the legacy financial system, no extra information is attached to the transaction, unless you want it to be.

Your wallet’s public key looks something like this:

16FEJJVoFNtqyN4H4eZtdiFTRiQ1tg2oVg

When sending you Bitcoin I enter your wallet’s public key and the amount I want to send.

That public key is unique and the number of possible combinations characters are so large that no two keys will ever look exactly the same. That public key is also cryptographically linked to a private key, which is equally unique, and which is only known to your wallet, and to no one else.

Not even the person who wrote the wallet software knows your private keys because all keys are generated randomly when the software is installed, this is also why it is important to use open source software, because in doing so it is possible to verify that there is no built-in back-door.

Through cryptography a specific public key is linked to its private key counterpart (without the private key ever being revealed) in such a way that way no other public key can be linked to that particular private key. So when I enter your public key into the transaction input, my wallets assigns control of the newly created UTXO to the corresponding private key, without having to know what that private key is.

Public-key cryptography, or asymmetric cryptography, is a cryptographic system that was first invented in the 1970’s and which only requires keeping the private key private. The public key can be openly distributed without compromising security because any person can encrypt information using the public key, however, that encrypted information can only be decrypted with the private key

Thus, when I send you Bitcoin, my wallet encrypts the Bitcoin UTXO using your public key, in such a way that only your private key can now control that UTXO. You are now the new owner of that UTXO and only a wallet controlling your private keys will be able to use that UTXO as an input to create a new transaction, meaning only you can spend that Bitcoin.

MINERS:

Unlike nodes, miners participate in the Bitcoin network for financial reward. Theoretically miners do have incentive to mine dishonestly, though the potential cost outweighs the reward.

The protocol creates strong incentive to mine honestly and nodes keep miners in check by verifying that all blocks added to the blockchain are mined correctly. Blocks that are rejected by nodes will not be added to the blockchain. And because nodes do not participate for financial reward, but for the sake of keeping the network healthy, there is no incentive for nodes to accept incorrectly mined bocks. Thus mining a rejected block will only waste time and resources that a miner could have spent mining an honest block and receiving the reward.

Miners listen for and gather transactions that are broadcast over the network by wallets. Nodes also receive these new transactions, but they only check transactions for irregularities. Miners on the other hand bundle these transactions into blocks. Correctly mined blocks are then propagated throughout the network and added to the blockchain.

Every time a miner ‘finds’ a new block they are rewarded with newly created Bitcoin, which they will probably sell into the market to cover operational costs, chief among which is electricity.

Miners also earn transaction fees, which is a fee paid by the sender or receiver of every Bitcoin transaction. Transaction fees are low when there’s little demand, but blockspace is limited because the blocksize is limited to one megabyte per block, and so transactions with higher fees will be included in blocks before transactions with lower fees.

Transaction fees will also play an important role in the incentive structure, motivating miners to continue mining when block rewards decrease. At the moment the vast majority of a miner’s revenue comes from the block reward. But Bitcoin’s monetary policy cuts the supply of new Bitcoin in half every four years. Until eventually, around the year 2140, no new Bitcoins will be created. Leading up to, and beyond that point, transaction fees will be what motivate miners to continue committing their computational power to the network.

At the height of the 2017 bull market fees spiked as more people wanted to move Bitcoin around, but generally fees are low compared to what it costs when transferring money using a traditional bank. While high fees are generally acceptable when moving large amounts of money, Bitcoin developers have been working on solutions to make smaller transactions cheaper.

One such solution is called the Lighting Network, which is essentially a second layer that sits on top of the Bitcoin network. While it is still in beta, it is already usable. And it promises to not only make small transactions virtually free of charge, but to scale the capacity of the network.

Mining ensures that new Bitcoin isn’t simply created and that the blochcain is secured by a vast amount of computational power. However, partly as a result of this resource intensive mining process the Bitcoin network can only handle about 7 transactions per second. While payment processors like Visa and Mastercard handle thousands of transactions. The lighting network will increase the capacity of the Bitcoin network to handle an infinite number of transactions, without sacrificing the security provided by the process of mining.

However, in order to ‘find’ a new block, miners must compete against one another in a race to solve a very complex mathematical equation which involves hashing functions that scramble the contents of the block to produce a single string of characters (a hash) that must comply with certain prerequisites.

The only way to do this is to use a brute force approach, producing as many hashes as possible in the shortest time possible. The miner with the most computing power (and consuming the most electricity) has the highest chance of finding the correct hash first.

Mining difficulty, which is to say the difficulty of finding the right hash for a particular block, is adjusted so that when more computer power joins the network correct hashes are still produced at approximately ten minute intervals, meaning new blocks are created approximately every ten minutes.

In the beginning it was possible to mine using a home computer with a strong graphics card. But as a result of Bitcoin’s increased value attracting more miners to mine on the network, today Bitcoin mining requires thousands of very powerful computers that are built specifically for mining Bitcoin. These computers are known as ASIC (Application Specific Integrated Circuit) Computers and they can only perform one function: mine Bitcoin. These machines also consume massive amounts of electricity.

Bitcoin mining has nothing to do with digging tunnels in the ground, but instead involves work performed by computers that fill entire warehouses and burn up enough electricity to power a mid size country like Belguim, Chile, Finland or the Philippines.

Miners produce all new Bitcoin coming into circulation. It is only by mining, by performing millions of random algorithmic hash functions per second, until the correct hash is produced, that new Bitcoin can be created.

Currently the combined mining power connected to the Bitcoin network is over 100 million tera hashes per second. The rate fluctuates as older machines are disconnected and newer ones are added. But despite cyclical ups and downs (similar to price movements) the hash rate has steadily been climbing and reached a new all time high on the 1st of March 2020.

100 million tera hashes basically means that all the miners on the network combined are capable of repeating the algorithmic hash function (required to find the correct hash) 100,000,000,000,000,000,000 times per second. As a comparison, a home computer with a fast graphics card (used for gaming and video editing) might give you 100,000,000 hashes per second, a trillion times slower than the Bitcoin network hash rate.

This does not mean that there are a trillion computers connected to the network, because Bitcoin miners use machines that are far more powerful and which are optimized specifically for mining Bitcoin. It simple means that the network has a computational power equivalent to a trillion top end video editing or gaming computers. While it is difficult to get an exact number, it is estimated that between one and two million individual computers (ASICs) are mining on the Bitcoin network.

This is important to understand because miners secure the network. In order for a bad actor to attack the network, for example to reverse transactions and send any number of Bitcoin to themselves instead of to the intended recipient, they would essentially have to redo the work performed by the miners.

This is also why, the more blocks are added to the chain the more unlikely it becomes that past blocks can be compromised as each individual block is also cryptographically linked to the one before it and the one after it.

If the last block to be mined and added to the chain is block number 100 and I wanted to reverse a transaction bundled into block number 96, I would have to redo all the work it took to produce block number 100, 99, 98, 97 and 96.

This is also referred to as confirmations. The number of confirmations for any particular transactions refers to the number of blocks that have been mined on top of and in addition to the block containing your transaction. If a transaction has 1 confirmation it means it’s included in the latest block. If it has 4 confirmations it means that 3 additional blocks have been mined on top of the block containing that transaction.

And while it is theoretically possible for a bad actor to muster enough computing power and electricity to reverse perhaps one block, it becomes exponentially more difficult going back in the blockchain, to such an extent that experts agree that any transaction with 3 or more confirmations is as secure as can be.

The process of Bitcoin mining is also referred to as a proof-of-work system, as a miner must show proof of work in order to mine a block and be rewarded with Bitcoin.

The creator(s) of Bitcoin built upon the efforts of many programmers that came before, they were not the first to attempt creating a decentralized and digital form of money. But it is this system of proof-of-work that is generally accepted as Bitcoin’s key innovation.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s