Quantum Bitcoin mining

There has been some writing done about the implications of quantum computing to Bitcoin, the most popular peer-to-peer cryptocurrency. Here is the story:

  • To send an amount to Bob, Alice digitally signs the message “Alice gives money to Bob” and sends it out to miners. But the Elliptic Curve Digital Signature Algorithm (ECDSA) is broken by a version of Shor’s algorithm. Now anybody with a large enough quantum computer can forge Alice’s digital signature. This is the part of the story that gets the most attention.
  • SHA-256 hashes are used to timestamp previous blocks, and also in mining new blocks. Classically, it takes on the order of 2256 operations to invert an SHA-256 hash. Grover’s algorithm takes that down to about 2128. That’s still a large number, so SHA-256 is not generally considered “broken” by quantum algorithms.

    y43_re

    Fig. 1 The real part of the ℓ = 4, m = 3 spherical harmonic. This is what I picture when I hear the word “quantum.”

It’s tempting to end the story there, and some writers do. But it doesn’t end there! While SHA-256 is not “broken” by Grover’s algorithm, Bitcoin mining is made much faster. That’s because the Bitcoin proof-of-work is not inverting an SHA-256 hash, but rather, finding any one of many possible inputs producing a hash less than a threshold t.

(I encourage you to read the original paper. It’s very accessible, and most of the second-hand summaries fall severely short. For the record, the original paper requires a certain number of leading zeros instead of a threshold t. They’re not strictly equivalent, but they’re similar. The Bitcoin Wiki indicates that the actual network uses the threshold.)

The threshold changes periodically to keep the block generation rate roughly constant. For a particular t, though, there are t possible outputs that are less than that value. Thus, the fraction of possible outputs satisfying the requirement is t/2256. The input parameter that must be varied to produce these zeros in the hash is called the nonce, and it consists of 32 bits. The function we’re interested in isn’t one-to-one, then, but I’ll assume it’s fairly uniform. Then there are about t 232–256 nonces constituting a valid proof-of-work. That could be a lot more than just one, which there would be if we were trying to break SHA-256 altogether.

In fact, there is a modified version of Grover’s algorithm in the case where there are multiple special inputs. Say there are N possible inputs and we want to find any of the m special ones. That takes O(\sqrt{N/m}) iterations (so long as m/N is very small, according to Mermin). That comes out to O(\sqrt{2^{256}/t}).

That is a big deal! Note in particular that there appears to be no dependence on the size of the nonce. As of the time of writing, the current mining difficulty is about 238, which corresponds to a threshold of 2256–32–38 = 2186. So the number of operations comes down to about 235, which is something like 34 billion. For comparison, the classical number of hashes required is the square of that.

Punchline: A full-scale quantum computer may be able to mine Bitcoin tens of billions times faster than GPUs.

Implications: Unlike ECDSA, SHA-256 does not need to be replaced entirely in post-quantum cryptocurrencies. The hash-based crypto puzzle will still be a useful proof-of-work, but the difficulty parameter must be increased to the point where classical computers can no longer compete. Grover search brings the current O(270) down to O(235). So if everybody had a quantum computer and we wanted to keep the O(270) runtime for quantum computers, we might require t = 2116. At that threshold, a classical computer working on the same problem would face O(2140) hashes, which as I mentioned above is tens of billions times more than are required today.

Leave a Reply

Your email address will not be published. Required fields are marked *