Bitcoin has existed as a peer-to peer electronic cash system since 2009. Lately however, the red-hot digital currency has gained lots of interest due to its surge in value. At the start of 2017, one bitcoin was worth around $1,000. On November 2, following CME’s announcement of launching bitcoin futures, the price of the largest cryptocurrency by market cap hit another all-time high as it shattered the $7k barrier.

But what exactly is a bitcoin and how it works. As bitcoin’s increasing integration in mainstream finance continues to accelerate, one thing that baffles the average person are the currency’s principles which seem too technical to comprehend. Indeed, the system is quite complex and sophisticated. However, when you really think of it-these features are what make it extremely hard to hack. Although, with the looming arrival of quantum computers that may change. According to Dival Aggarwal and colleagues at the National University of Singapore, quantum computers could pose a real threat to Bitcoin’s security.

Bitcoin Basics

Before we delve into Bitcoin’s security features, let’s look at its basics. Bitcoin is a virtual currency, and it is best to view it from this perspective. Unlike any other currency in the world, it is decentralized – and more importantly, it’s not regulated by any government.

The bitcoins that a person owns are stored directly on his/her computer. When doing a transaction, the virtual currency is transferred from one computer to another between “peers” within the bitcoin network. While there are merchants that already accept bitcoins in exchange for products or services, the typical way of earning money is by exchanging bitcoins for dollars or any real cash.

As bitcoins are stored in computers, there’s a misconception that computer hackers can easily gain access to bitcoins that can be exchanged for real money. But this is nearly impossible to pull off as the system relies on mathematics that gives Bitcoin its reputed security.

Private and Public Keys

Hackers though can use quantum computers in the future and could take advantage of two security holes in the Bitcoin system.

First, the encryption scheme used to verify a sender’s identity can be exploited. Every user generates two numbers whenever they do a transaction—a private key that is known only to the sender and a public key that is open to the public. Whenever a user sends bitcoins to another user, it has to do so through digital signatures. (Like check deposits in banks, signatures are required to complete the transaction.)

Through digital signatures, a receiver can verify that the sender is not an impostor, that the sender is the real holder of the private key (without revealing the actual key), and that the sender indeed has the right to spend bitcoins on that account. This technique is called “elliptic curve signature”.

The only way to hack signatures is to calculate the sender’s private key through the public key. This process is hard to do with current computers, but not with quantum computers which have way higher processing capacity.

Blockchain, Hash and Nonce

Second, hackers can undermine the “mining” process. While signatures are used to verify the sender, mining is used to verify transactions. Users who signed in to work on these verifications are called “miners”. Why would a user like to become a miner? It’s because whenever a miner successfully verifies transactions, that miner gets paid with some bitcoins for letting their computers do the work.

New bitcoins are made out of thin air through this mode. As a matter of fact, this is the only way to create them. By the manner the system is designed, the maximum amount of bitcoins that can be mined is 21 million; this is expected to be reached by the year 2140.

To further understand how mining works, let’s discuss the basic concepts of blockchain, hash, and nonce.

All transactions are recorded in a ledger and, with Bitcoin being a decentralized currency, every user has access to this ledger. Transactions are grouped into “blocks”, and an average of ten minutes is spent before a block is declared valid. A validated block is then appended to a long list of previously validated blocks, forming a “blockchain”. The blockchain looks like a lengthy record of all verified transactions in Bitcoin’s history.

Each validated block contains a header. It serves as the “proof of work” that the block has been worked on by miners. The header is produced by a hash.

A hash is a mathematical formula that turns a set of data of varying lengths to a single set with a specific length. For example, if you have a sample datum of 1234, one way to hash this is by adding the individual digits to get 10. Other data like 7111 or 82, when hashed in the same manner, will also result in 10. So to make the block’s header, three elements are needed for the header’s hash: the root hash produced from transactions contained in that block; the hash of the preceding block; and a nonce.

A nonce is a number that has a special property and is also one of the three elements hashed to form the block’s header. The final hash of the header must be less than some target value specified by the system. This specification changes over time; as of July, a block’s header must have a 256-bit alphanumeric string that starts with 18 zeroes.

When a block is created, a miner can use a nonce (say 1) and see if the process will churn out a final hash that meets the system’s rule. If unsuccessful, the miner must input another nonce (say 100 or 7,000) until he (or another miner) has finally solved the puzzle. Several nonces are possible per block; as long as the system’s rule is met, any nonce is good.

The process of finding a nonce is what mining is all about. Miners rush to get a nonce, and it takes an average of 10 minutes to find a suitable number. A miner is deemed super lucky if he found a nonce on his first try.

But a miner’s computer is competing against other miners’ computers. One’s computer may end up doing loads of work, and it takes a long time before a miner receives a payout. That’s why miners congregate to form mining groups to divide the load. As several nonces are possible, it’s normal that two (or more) mining groups will find different nonces and declare different blocks. In effect, branching could occur here.

The Bitcoin system though does not allow branches—only one validated block will be added to the blockchain. Based on protocols, the block that has been worked on more will be the winner here while the rest will be discarded. In this light, if a mining group has 51% or more computational power, it has an overwhelming advantage in its favor.

At this point, quantum computers could help one mining group attain dominance. If one group has greedy intentions, it can spend bitcoins twice and then control the system so that the transaction will never go through other group’s scrutiny. With processing power on its side, the group can influence the appending of the blockchain into their favor, forever deleting the double spending in Bitcoin’s history. In the end, the group were able to spend less amount of bitcoins and get away with something more in return.

Can Quantum Computers Pose a Real Threat?

In relief, Aggarwal and his team said that current Nvidia-developed ASICs (application-specific integrated circuits) will still have the speed advantage over quantum computers in the next ten years and beyond.

“We find that the proof-of-work used by Bitcoin is relatively resistant to substantial speedup by quantum computers in the next 10 years, mainly because specialized ASIC miners are extremely fast compared to the estimated clock speed of near-term quantum computers,” the team stated.

However, the team is more concerned more on the security threat on finding the private key of a Bitcoin sender. “The elliptic curve signature scheme used by Bitcoin is much more at risk, and could be completely broken by a quantum computer as early as 2027.”

Luckily, not all public-key schemes are resistant to hacks. Bitcoin could incorporate these safer strategies into its complex system in the future.

The paper can be accessed here.

At last check, the greenback price of one bitcoin was $10100.00.