How Bitcoin Solves the Double Spending Problem and Creates Sound Money

James Bayley
9 min readJul 23, 2018

--

Photo by Thought Catalog on Unsplash

Bitcoin is a step forwards because for the first time in the history of mankind someone has written a computer programme that solves the double spending problem in a decentralised network. This means that we can now create electronic cash that works just like the coins in your pocket but cannot be stolen or devalued by banks or governments.

A few words about cash

We use dollar bills and gold coins to buy and sell things and as a store of value. Early in history people would barter, for example Eve might exchange a goat for a bushel of wheat from Alice.

Pretty soon people found it was inconvenient to carry a goat to the shops and created goat tokens that they could exchange for wheat tokens. Then some clever chap thought “why do we need a different token for each commodity?” and created a common token and coinage (cash) was born.

People found these new “coins” very useful because they were much easier to carry than goats and you did not have to feed them in winter. Because you could sell a goat today in exchange for a coin and buy wheat with the coin next month they became a store of value.

Inflation is bad for coin holders

Alexas_Fotos / Pixabay

For coins to be a store of value the number must be strictly controlled because there are only a certain number of goats and bushels of wheat in existence. If the number the coins suddenly double then the cost (in coins) of goats will double.

The cost of the technology required to make coins and the need to forcibly discourage counterfeiters by cutting off their private parts resulted in kings to control coinage.

Double spending is not possible with physical coins

schuldnerhilfe / Pixabay

One feature of coins that is so obvious that we never think about it is that when you spend a coin you don’t have it any more and cannot spend it again. Double Spending is not allowed.

This really matters. Imagine a world where you were allowed to make a photocopy of a dollar bill before you used it and then spend it twice. Each person would do this and soon there would trillions of dollar bills in circulation and each one would be worth nothing.

Double spending is the biggest problem affecting electronic cash

Central Authorities solve the double spending problem but at what cost?

Consider the (imaginary) computer game “Goat of Thrones”, in this game there are 1m Goat Dollars and players can buy and sell digital goods. When a Eve uses a Goat Dollar to buy a bushel of wheat the computer game’s central server debits her account by 1 Goat Dollar and credits Alice’s account by 1 Goat Dollar.

Double Spending is not allowed because the central server that maintains the Ledger (record of all transactions) will not allow it. Providing the Central Server (Mint) is honest then everything works well.

Unfortunately the Mint in Goat of Thrones is controlled by Bad Government Limited who own the game and one day they sell another 1m Goat Dollars to new players to raise money. Suddenly the price of wheat and goats in the game doubles and existing players are much poorer.

This happens in the real world as well. Governments around the world will devalue their coinage to pay debts and savers suffer.

We can see that savers who want the utility of storing value as money rather than goods have to accept the risk of the central authority cheating them.

Preventing Double Spending requires us to trust a central authority

Bitcoin solves the double spending problem without a central authority

In 2008 Satoshi Nakamoto (not his real name) showed us how to solve the double spending problem without using a central authority. The original paper is here and if you have a mathematical bent a few hours study will suffice to give you a really good understanding of how Bitcoin works. However, if you are too busy to do that, read on and I will provide a simple explanation.

The Ledger

cpastrick / Pixabay

Satoshi noted that if every player in Game of Goats had a complete copy of the Ledger they could easily verify for themselves that a Goat Dollar had not been spent before. If Eve presents a Goat Dollar to Alice then Alice can follow THAT dollar all the way back through every transaction to the day it was minted. This would be completely impractical with physical cash when buying a loaf of bread in Walmart but is easy online using modern computers. This is the first step in building a decentralised authority to approve transactions.

Every Bitcoin user can have a copy of the entire Ledger and verify payments to themselves. This is called running a Full Node.

There are currently over 10,000 Full Nodes on the Bitcoin network and they are spread all over the world and so we can can have great confidence that the Ledger is safe against even very large disasters.

A conventional accountancy ledger is a big book with pages for each account and lines for each entry. Since we are using computers we could store all the transactions in a database or in Excel but Bitcoin uses a data structure called a “blockchain”. We will talk more about this later one but first;

Spending a Bitcoin

When Eve wants to pay Alice she uses a Private Key to sign a transaction. A Private Key is a password that unlocks her account on the Ledger. Only Eve knows it so her account is much safer than it would be with a bank where the trusted central authority can access her funds. This key is kept in a “Wallet” which is a computer program on her computer, phone or a USB key. Her coins are not in the Wallet, they are stored in her account on the blockchain (Ledger).

Eve signs a transaction sending 1 Bitcoin from her own account to Alice’s account and sends it to Alice. Alice verifies that Eve owns this coin and has not spent it. Alice will not trust the payment until she sees it in the Ledger and it has been confirmed.

How is the Ledger updated?

A decentralised network has one big problem

How do we keep all 10,000 copies of the Ledger synchronised?

Satoshi solved this problem. He suggested,

  • The Transactions would be batched up into Blocks of a few thousand.
  • The Ledger should be updated every 10 min (on average)
  • The person who updates the Ledger should be paid a big reward in Bitcoin
  • The person who updates the Ledger is chosen by lottery
  • It should cost a lot of money to enter the lottery

Satoshi called these Ledger updaters “Miners” because like gold miners they had to expend resources to get their reward.

Updating the Ledger every 10 mins gives time for the Ledger to propagate around the network and helps ensure that everyone has the same version.

Choosing the computer who updates the Ledger by lottery makes it difficult for any one person to subvert the network. Potential attackers must pay a entry fee to get into the lottery and are very unlikely to win. To be sure of winning to win they would have to buy millions of tickets and most attackers simply could not afford to do this.

How does the lottery work?

Hermann / Pixabay

After a Miner has assembled a few thousand transactions into a block they must calculate a special Hash (a hash is number made by “adding up” all the characters in document) for the block that starts with a certain number of zeros. This is very difficult to do and the computer will use a lot of electricity. This electricity cost is called “Proof of Work” and is the cost of entering the lottery. All Miners race to find this number. The first one to succeed wins the lottery and is allowed to update the Ledger. When they update the Ledger they add a special transaction to mint new Bitcoins and pay them to themselves. This is called the Block Reward.

The Block Reward is currently 12.5 Bitcoin ~ $100,000 dollars. So $100,000 dollars is up for grabs every 10 mins. This has encouraged a lot of people to buy computers and mine for Bitcoin. It is likely that the global electricity cost of mining the Bitcoin network is about $300,000 hour.

The Blockchain

Pixabay

We have seen that the Ledger actually consists of blocks of transactions. Each block includes the Hash of the previous block and so they are chained together. “chain of blocks” = Blockchain.

Consistent Eventually

The Ledger is the history of all transactions on the blockchain. In a centralised system only one history can exist but in a decentralised system there can be competing histories that eventually become consistent.

We know that this is true in real world. My parent’s generation used to ask “What were you doing when you heard that JFK was dead”, for my generation it was “Princes Diana”. The point is that until you heard they were dead you had a different view of history from your neighbour but after a few days everyone in the world could agree on the same version of history. In decentralised systems it takes time to get an agreed version of history.

In the Bitcoin system this Consensus is achieved by miners always working the longest block chain. If two miners simultaneously discover different blocks and publish them then the first block be built on by another miner will be the winning version of history. To be certain that they have the right version of history, recipients typically require six new blocks to be added to the block containing their payment. This is known as six “confirmations”.

Is double spending by miners possible?

This consensus mechanism is very simple and Eve spots a flaw. If she could generate the longest block chain and publish it to the network she could remove all her own payments from it (she can’t affect other people’s payments because she does not know their Private Keys). This would let her double spend.

Alice is going to wait for 6 confirmations so Eve will need to generate 7 blocks but she needs to do this quicker than the rest of the network is generating blocks otherwise she will never catch up and have the longest blockchain.

To be sure of catching up Eve will need to control 51% of the Bitcoin networks computing power. This means that she will have to spend over $150,000 PER HOUR on electricity and have billions of dollars worth of computers.

It is neither physically practical or economically feasible for Eve to attack the network in this way.

Conclusion

Bitcoin is a digital analogue to cash but is a superior store of value.

Savers’ coins are stored in a blockchain ledger that is distributed to computers all over the world which make them very resistant to natural disasters. A decentralised network of computers called Miners ensures that savers have quick access to their money. There is a strong incentive for miners to stay honest and any attempt to falsify the ledger would cost them billions of dollars.

We have seen that Bitcoin provides a better store of value than fiat currencies such as the US dollars or Euros because there is no central authority that can erode savers’ funds by inflation or seize them. The decentralised nature of Bitcoin makes it very difficult for banks and governments to deny savers access to their funds.

--

--

James Bayley

I am an very experienced project manager specialising in IT technology projects. I founded the startup CRYPTOSTAR.MONEY.