How Does a Blockchain Prevent Double-Spending of Bitcoins?
By: Team Innerquest Online
Tags: Blockchain, Bitcoin, Cryptocurrency

The bitcoin white paper, published in 2008, introduced the world to the first working peer-to-peer electronic cash system. The document’s pseudonymous author, Satoshi Nakamoto, delivered the first bitcoin client via SourceForge in 2009 and bitcoin was born. At the heart of bitcoin’s success was its ability to solve the problem of double-spending that had plagued all previous attempts at creating digital currencies. In this article, we’ll explain exactly what double-spending is and how the blockchain that underpins bitcoin prevents it.

Before Bitcoin, there was Bit Gold

Bitcoin wasn’t the first attempt to create a functioning system of digital cash. In 1998, digital currency pioneer Nick Szabo proposed Bit Gold and fully outlined his ideas in a 2005 blog post. With the benefit of hindsight, it is possible to imagine that Szabo may have developed Bitcoin from Bit Gold. However, Szabo’s post-2008 writings about Bitcoin reveal that his views about bitcoin differed from those of bitcoin’s anonymous creator, Satoshi Nakamoto. Crucially, Szabo’s writings show that he still viewed Bitcoin as a store of value, not as a means of exchange. One of the reasons why previous attempts at creating digital currencies (such as Bit Gold) failed was that they didn’t solve the problem of double-spending.

What is double-spending?

As the term suggests, double-spending means spending the same money twice. With physical cash such as coins and notes, this simply isn’t possible and therefore isn’t an issue.

Let’s look at this example:

You go to Walmart and buy groceries worth $20. You pay in cash and hand over a $20 bill. As soon as the cashier puts the cash in the register, you can’t re-spend it unless you physically steal it.

Why is double-spending an issue for digital money?

Digital money is different from cash. When you make a transaction with digital cash, you are broadcasting the transaction to all the ‘nodes’ in the network (nodes are computers that run the software on which the currency is supported). These nodes need to receive and confirm the transaction, which takes time. Hence the problem: what’s to stop someone copying a transaction and rebroadcasting it before it’s been confirmed on the network?

How would the network know which transaction was genuine?

Bitcoin doesn’t have a central bank to mediate disputes

Prior to the invention of bitcoin, digital money flowed across the internet. It was all monitored and controlled by banks and financial institutions, just as the majority of it is to this day. The problem with banks acting as mediators in financial disputes is that transactions can be reversed if a dispute occurs. This leads to higher fees and slower transaction times. Bitcoin aimed to solve these limitations by creating a system based entirely on cryptographic proof, instead of trust. In effect, it offered a way to do banking without the banks.

Every bitcoin shows the chain of ownership

To begin to understand how this system of cryptographic proof works, it’s essential to understand what a bitcoin actually is. In the bitcoin white paper, a bitcoin is defined as a ‘chain of digital signatures’. It can move from one owner to the next via digital wallets. Each wallet has a public key (an address) and a private key (a confidential password that only the owner knows). When one bitcoin owner transfers a coin to someone else, they sign a hash of the previous transaction and the public key of the next owner. This hash is then added to the end of the bitcoin. Therefore, every bitcoin is like the log book for a car — it contains a record of all previous owners.

Cryptographic hash functions explained

A cryptographic hash function is a mathematical algorithm that accepts a string of data (such as ‘What is bitcoin’) and returns a fixed sized arbitrary string (such as ‘3af4aceb81bc42fd81117e1’). It’s a one-way function meaning that the same input always returns the same output and you can’t reverse engineer the input. Importantly, no two inputs will return the same output so every output is unique. Every time a bitcoin is transferred, a new hash is added. The chain of ownership of each bitcoin can be verified simply by looking at the signatures that make up the coin.

But this alone doesn’t solve the problem of double-spending. A payee can’t verify that one of the past owners of a bitcoin didn’t double-spend the coin. One solution would be to have a central bank or mint to check each transaction for double-spending but this would defeat the purpose of bitcoin. Remember, bitcoin was created to solve the shortcomings of having central banks in the first place. Why would you just replace one central bank for another?

Bitcoin’s blockchain is a universal ledger

To manage the double spending problem, bitcoin relies on a universal ledger called a blockchain.

To prove that no attempts to double-spend have occurred, the blockchain provides a way for all nodes to be aware of every transaction. With bitcoin, all transactions are publically announced to all nodes. They can then agree on a single history of the order in which they were received. Bitcoin’s solution to double-spending is that if the majority of the nodes agree on which transaction was first to be received, later attempts to double-spend are irrelevant.

Bitcoin’s timestamp server explained

Satoshi Nakamoto’s white paper proposed the use of a timestamp server as a solution to the double-spending problem. This server takes a hash of a block of transactions and then broadcasts this hash to all the nodes in the bitcoin network. This timestamp proves that all the data in the hash couldn’t have been created after the hash was published (obviously). As each timestamp includes the previous timestamp in its hash, this forms an immutable (unchangeable) record of the order in which transactions took place. Each timestamp reinforces the ones before it.

There’s a record of every bitcoin transaction ever made

To fully understand how the blockchain prevents double-spending, you need to know that from the delivery of the very first bitcoin client in 2009, bitcoin’s blockchain has maintained a complete record of every transaction ever made. As all transactions are cryptographically hashed to the previous blocks, you can’t simply change the record. This record is known as a blockchain because a new group of transactions, known as a block, is added every ten minutes.

An example of the bitcoin network in action

Let’s say that you have one bitcoin that you want to try to double-spend.

Imagine that you make a purchase worth one bitcoin with a merchant that accepts bitcoin, such as Microsoft. Now, what if you tried to send the same bitcoin to another bitcoin address?

You could. Or more accurately, you could try!

You see, there’s no mechanism in place to prevent someone from broadcasting two transactions in this way. In such a scenario, both transactions would go into a ‘pool’ of unconfirmed transactions. What would happen next?

Your first transaction (to Microsoft) would be confirmed by bitcoin miners and verified in the next block. As this transaction would be stored as a cryptographic hash that included the timestamp from the previous block, your second transaction would be judged invalid. It would be pulled from the network and wouldn’t be confirmed.

A ‘confirmation’ simply means that blocks containing more transactions have been added to the blockchain. As each block is linked to the previous ones, provided that a merchant waits to receive at least six confirmations, they can be certain that the bitcoin they receive wasn’t double-spent.

Conclusion

In summary, the blockchain prevents double-spending by timestamping groups of transactions and then broadcasting them to all of the nodes in the bitcoin network. As transactions are time-stamped on the blockchain and mathematically related to the previous ones, they are irreversible and impossible to tamper with.

As we strive to provide you the best relevant and most informative content, getting your feedback is crucial to us. Please let us know below if you agree, disagree or have an opinion we may not have included. Don’t forget to like and share with those who could benefit from what we provide.