Bitcoin is broken. And not just superficially so, but fundamentally, at the core protocol level. We're not talking about a simple buffer overflow here, or even a badly designed API that can be easily patched; instead, the problem is intrinsic to the entire way Bitcoin works. All other cryptocurrencies and schemes based on the same Bitcoin idea, including Litecoin, Namecoin, and any of the other few dozen Bitcoin-inspired currencies, are broken as well.
Specifically, in a paper we placed on arXiv, Ittay Eyal and I outline an attack by which a minority group of miners can obtain revenues in excess of their fair share, and grow in number until they reach a majority. When this point is reached, the Bitcoin value-proposition collapses: the currency comes under the control of a single entity; it is no longer decentralized; the controlling entity can determine who participates in mining and which transactions are committed, and can even roll back transactions at will. This snowball scenario does not require an ill-intentioned Bond-style villain to launch; it can take place as the collaborative result of people trying to earn a bit more money for their mining efforts.
Conventional wisdom has long asserted that Bitcoin is secure against groups of colluding miners as long as the majority of the miners are honest (by honest, we mean that they dutifully obey the protocol as prescribed by pseudonymous Nakamoto). Our work shows that this assertion is wrong. We show that, at the moment, any group of nodes employing our attack will succeed in earning an income above their fair share. We also show a new bound that invalidates the honest majority claim: under the best of circumstances, at least 2/3rds of the participating nodes have to be honest to protect against our attack. But achieving this 2/3 bound is going to be difficult in practice. We outline a practical fix to the protocol that is easy to deploy and will guard against the attack as long as 3/4ths of the miners are honest.
We need the Bitcoin community's help in deploying this fix so that the Bitcoin ecosystem can be made more robust, at least against attackers whose mining power is below the 25% threshold. Even with our fix deployed, however, there is a problem: there are mining pools at the moment that command more than 25% of the mining power, and, in the past, there have been mining pools that commanded more than 33% of the mining power. We need the Bitcoin community's awareness and concerted effort to ensure that no mining pool reaches these thresholds. The mere possibility that the system can get into a vulnerable state will be an impediment to greater adoption of Bitcoin.
Those of you who want a precise and full explanation of the attack can cut straight to the research paper, though it may be a bit terse and dry. In the rest of this blog entry, we will outline the attack for the non-hard-core practitioner, such that by the end of the blog entry, anyone should understand the intuition behind our attack, be equipped to earn higher revenues through mining, and possess the tools required to usurp the currency. To get to this point, we need a little bit of background on how Bitcoin works. If you're familiar with Bitcoin mining, you can skip to the next section that describes how the attack works. If you are a non-techie Bitcoin user, you can skip straight to the Implications section.
The key idea behind Bitcoin's success is a decentralized protocol for maintaining a global ledger, called a blockchain. The blockchain records transactions between Bitcoin addresses, tracking the movement of every Bitcoin as it changes hands. This tracking ensures that no one can double-spend a coin, as the ledger makes it all too apparent whether a user sent out more Bitcoins from his account than he earned. The particular way in which Bitcoin tracking is performed makes sure that the record is also immutable; once a Bitcoin transaction is committed and buried in the blockchain, it is difficult for an attacker to reverse the transaction, so that a merchant can ship goods in good conscience, assured that the transaction will later not be reversed.
This protocol works through a process called mining. In essence, the ledger is organized into a single, ordered sequence of blocks, each of which records a set of transactions. Each block contains a crypto-puzzle, a computationally difficult challenge akin to a CAPTCHA. Miners organize themselves into a loosely-organized, distributed network, and they all concurrently try to add a new block to the ledger. To do this, they need to discover the solution to a crypto-puzzle, formed by the contents of the ledger until the point where the new block is being added. Solving a crypto-puzzle is hard work; a computer has to plug in many different values and see if they solve the crypto-puzzle posed by the new block. The puzzles are such that a home computer working alone will take many years to solve a crypto-puzzle. Some people use GPUs to speed up this process, while others have invested in custom ASICs designed to solve Bitcoin crypto-puzzles.
Of course, this process is not free, as the process of solving these crypto-puzzles consumes power and requires cooling. For the currency to be viable, the miners need to be compensated for their efforts. Bitcoin miners are compensated through two mechanisms: they collect the transaction fees from the transactions recorded in the new block they contributed to the block chain, and they also collect a lump sum fee. This lump sum fee creates new Bitcoins, according to a time-varying formula. Hence, "mining" is similar to digging for gold -- every now and then, a miner is rewarded with a nugget. The difficulty of crypto-puzzles are automatically adjusted such that a new block is added to the ledger approximately every 10 minutes, which ensures a predictable coin generation rate for the system, which stems inflation and makes the currency supply more predictable than it would be otherwise.
The nice thing about having crypto-puzzles that are so difficult is that it is not practical for an attacker to modify the ledger. Someone who wants to, say, buy something from a Bitcoin merchant, get the goods shipped, and then later change that block to erase the transfer of money to the merchant, faces a very difficult task: they need to find alternative solutions to cryptopuzzles for that block and every subsequent block. What makes this difficult is that the main bulk of the miners will be working hard on adding new blocks at the tail end of the ledger, so an attacker, with limited resources, cannot hope to find alternative solutions for all the past blocks and catch up to the rest of the miners.
Miners today organize themselves into groups known as pools. A pool will typically consist of a set of cooperating nodes that share their revenues whenever they find blocks. Mining pools are kind of like the shared tip jar at a restaurant: on occasion, a miner will hit the potluck, discover a good solution to a cryptopuzzle, and rake in some revenues, kind of like a waiter who lands a big table that runs a large tab. Since this occurs relatively infrequently from the point of view of any given miner, sharing the proceeds enables the miners to have more predictability in their lives.
The honest Bitcoin protocol assumes that all miners engage in a benign strategy where they quickly and truthfully share every block they have discovered. Until now, everyone assumed that this was the dominant strategy; no other strategy was known that could result in higher revenues for miners.
Our work shows that there is an alternative strategy, called Selfish-Mine, that enables a mining pool to make additional money at the risk of hurting the system. In Selfish-Mining, miners keep their block discoveries private to their own pool, and judiciously reveal them to the rest of the honest miners so as to force the honest miners to waste their resources on blocks that are ultimately not part of the blockchain.
Here's how this works in practice. Selfish miners start out just like regular miners, working on finding a new block that goes at the end of the blockchain. On occasion, like every other miner, they will discover a block and get ahead of the rest of the honest miners. Whereas an honest miner would immediately publicize this new block and cause the rest of the honest miners to shift their effort to the newly established end of the chain, a selfish miner keeps this block private.
From here, two things can happen. The selfish miners may get lucky again, and increase their lead by finding another block. They will now be ahead of the honest crowd by two blocks. They keep their new discovery secret as well, and work on extending their lead. Eventually, the honest miners close the gap. Just before the gap is closed, the selfish pool publishes its longer chain. The result is that all the honest miners' work is discarded, and the selfish miners enjoy the revenue from their previously secret chain.
The analysis of revenues gets technical from here, and the only way to do it justice is to follow along the algorithm and state machine provided in our paper. But the outcome is that the selfish mining pool, on the whole, nullifies the work performed by the honest pool through their revelations.
The success of the attack, and the amount of excess revenue it yields, depends on the size of the selfish mining pool. It will not be successful if the pool is below a threshold size. But this threshold is non-existent in the current implementation -- selfish mining is immediately profitable. Our proposed fix raises the threshold to 25% if universally adopted. And, while there may be other fixes, no fix can raise it above 33%. So, at least 2/3rds of the Bitcoin miners have to be honest. All three of these findings are a far cry from the 50% previously (and falsely) believed to protect the currency.
The selfish mining strategy has significant implications for the Bitcoin system:
Some frequently asked questions:
- What happens when a selfish mining group is formed?
Once a group of selfish miners appear on the horizon, rational miners will preferentially join that mining group to obtain a share of their higher revenues. And their revenues will increase with increasing group size. This creates a dynamic where the attackers can quickly acquire majority mining power, at which point the decentralized nature of the Bitcoin currency collapses, as the attackers get to control all transactions.
- When a single pool controls the currency, does the value of a Bitcoin go to $0?
No. It all depends on how the controlling group runs the currency. But the decentralization, which in our view is so critical to Bitcoin's adoption, is lost. It would not be at all healthy for the Bitcoin ecosystem.
- Does this affect X, where X is another cryptocurrency?
Probably. It affects every currency system that is inspired by Bitcoin's blockchain. That includes Litecoin, PPcoin, Novacoin, Namecoin, Primecoin, Terracoin, Worldcoin, and a host of other currencies that share the same global ledger concept.
- What's the core discovery here?
We're the first to discover that the Bitcoin protocol is not incentive-compatible. The protocol can be gamed by people with selfish interests. And once the system veers away from the happy mode where everyone is honest, there is no force that opposes the growth of really large pools that command control of the currency.
- Is selfish mining happening now?
We cannot know for sure, but we suspect not. Ours is the first work to publicly investigate an alternative mining strategy.
- What's with these two separate thresholds? Do 2/3rds of the nodes have to be honest? Or 3/4ths? Why is there a gap between the two?
At the moment, the threshold is non-existent. With our proposed fix, which is practical and easy to deploy, it gets raised to 25%; i.e. 3/4ths of the network must be honest. Perhaps someone can propose a fix that raises this threshold further, but we have shown that they cannot raise it above 2/3rds.
- Would we be able to tell a selfish mining pool from any other pool?
Not easily. A selfish mining pool can hide behind throwaway addresses to mask its identity. And while the timing of block revelations does look different for selfish miners, it's difficult to tell who was genuinely first, as near-concurrent revelations will arrive in different orders at hosts.
- Is there a danger associated with making this attack public?
The only way to protect the system against selfish mining attacks is to get everyone to change their implementations. So the only way we can protect the system is by publicizing the potential attack. We have chosen not to launch the attack ourselves, because we care about the long-term viability of the currency.
- Can Bitcoin remain a viable currency?
Probably. We have shown that as long as selfish miners are below a certain threshold, they will not succeed. And while this threshold does not exist yet (i.e. selfish mining will immediately yield benefits for any sized pool), we have a proposed fix that raises the threshold to 25%.
Followup post on frequently-asked questions
Followup post on the novelty of the selfish mining attack
Followup post on altruism among capitalists
Followup post on response to feedback on selfish mining
Haldane says that there are four stages of acceptance to new ideas:
- This is worthless nonsense.
- This is an interesting, but perverse, point of view.
- This is true, but quite unimportant.
- I always said so.
The comments below, coming from "Bitcoin entrepreneurs", organized into a brigade, exhibit all four of these stages at the same time. I have preserved them as they are (except for deleting profanity-laced comments), to shame the community. In some cases, the commenters edited their own comments when proven wrong, so reading the comment chains may seem non-sensical at times as a result.