When Satoshi Nakamoto published his groundbreaking whitepaper Bitcoin: A Peer-to-Peer Electronic Cash System in 2008, he introduced a number of important innovations. The most notable of which was blockchain technology and the consensus mechanism it utilizes.
Although the history of digital currencies stretches back to the 1980s, in which David Chaum published his seminal paper, nobody had yet found a good solution to the double-spending problem. Bitcoin changed that.
The double-spending problem describes the difficulty of verifying the ownership of a digital token. How can we be sure that a token is only spent once? With real cash, it's very simple. The physical bill changes hands and is now in your wallet. You now own that money.
If it wasn't for the double-spending problem, theoretically every digital asset could be used as a form of currency. Fortunately - or unfortunately depending on your perspective - digital files can be cloned, copied, replicated and shared infinitely. Measures to stop this either simply don't work or involve some central authority - like a government.
In the cryptocurrency-space we want everyone to enjoy as much freedom as possible, so how do we solve the double-spending problem?
Blockchain technology allows us to solve the double-spending problem by broadcasting each transaction to a network of nodes and verifying it through the use of a consensus mechanism. In the case of Bitcoin this consensus mechanism is called proof-of-work, but others - like proof-of-stake - are growing in popularity.
Crucially, all transactions are stored on a public ledger and are grouped into sequential blocks which are interlinked (hence the name "blockchain"). As a result, a time-stamped record of each transaction is available to all members of the network and incorrect (or fraudulent) transactions are checked and then rejected. In a nutshell, this is how the double-spending problem is solved.
If you're new to cryptocurrency this might sound confusing so here is the ELI5 version:
It's also worth keeping in mind that "the network is robust in its unstructured simplicity" and especially designed to prevent double-spending attacks. More specifically, blockchain technology provides a very strong topology which allows nodes to leave and rejoin the network at will.
Importantly, the nodes accept the proof-of-work provided by miners and accept valid blocks by working on extending them. Blocks that contain incorrect transactions are rejected, because the nodes refuse to add the block of transactions to the public ledger mentioned earlier. In more relatable terms: the nodes vote with their CPU power to accept and reject transactions.
Now comes the key piece of information. Each accepted block of transactions is linked to the previous block with a unique hash. As the number of blocks increases, so does the integrity of the blockchain and the hashing power required to break it.
This approach makes a lot of sense, but how well does it perform when attacked?
At its peak the combined market capitalization of all cryptocurrencies reached $800 billion. Although this number has come down recently, the value that is being generated and transferred in the industry is still vast. With so much money on the line, how can we be sure that the double-spending problem won't resurface and bring the industry tumbling down?
The short answer is that double-spending is not possible as long as the majority (51%) of nodes in the network act with integrity. If a malicious actor manages to somehow control 51% of the network, he controls the hashing power, giving him the opportunity to rewrite blocks and thus add fraudulent transactions to the ledger. The apparent cost of such an attack is so high as to be prohibitive.
Therefore, sophisticated cryptocurrencies with large networks are immune to double-spending because even a successful attack would be so expensive that it couldn't provide a positive outcome for the attacker.