Bitcoin: Permission, Access, and Proof-of-Work — What’s that about?
$135.816.003.617 USD — that is the current market cap of Bitcoin (21.11.2017). In Wikipedia’s list of country GDPs, Bitcoin would rank today as number 57 with a higher market cap than the GDP of Kazakhstan (roughly $133 billion USD according to 2016 IMF data), just one place after Qatar. Thus, it is high noon and time to take a closer look on how Bitcoin works under the hood. In this article I will talk about who can access the Bitcoin blockchain and how consensus is achieved among thousands of nodes.
The most popular blockchain
The most popular blockchain platform with the widest global network of nodes (currently about 11.000) is the Bitcoin blockchain. It is the first implementation of a blockchain and has originally been proposed by the anonymous author Satoshi Nakamoto in 2008 as a peer-to-peer electronic cash system. If you want to read the original Nakamoto Paper, see here.
Effectively, the Bitcoin blockchain is a time-stamping server that
“timestamps transactions by hashing them into an ongoing chain of hash-based proof-of-work, forming a record that cannot be changed without redoing the proof-of-work” — Satoshi Nakamoto
This basically means that in order to prove that a transaction exists at a certain point in time, validating nodes in the network, so called miners, collect the transaction, add it to a block of transactions, and validate the block through proof-of-work (PoW). PoW will be explained in detail below. For now, this mechanism enables widely decentralized nodes to agree on a single state of the world, or on a single ledger of records.
There is no restriction on which nodes are allowed to validate transactions as everyone can run the open-source mining protocol.
To get a better understanding of the Bitcoin blockchain and how it differs from other blockchains, I will talk about the first three of the eight most important blockchain characteristics as presented in the previous post.
1. Permission restrictions (permissioned vs. permissionless)
Bitcoin is a permissionless blockchain. It is characterized by its open access. Everyone can download the open-source bitcoin client and connect to the network. Every user thus maintains a copy of the blockchain and can broadcast transactions without requiring permission to do so. Also, every user can decide to run the open-source mining protocol and participate in transaction validation.
On the contrary, in a permissioned blockchain, such as in Hyperledger Fabric, users need to be authorized in order to add transactions or validate the ledger.
2. Access to blockchain data (private vs. public)
As seen in the table of the previous post, being a permissionless blockchain does not automatically imply that public access to data cannot be restricted.
That is why it is important to point out that the Bitcoin blockchain is a public instance of the permissionless Bitcoin protocol. Everyone can connect to the network and view all transaction data. This means that, if you download a Bitcoin client on your computer, it will download the whole blockchain with all transactions ever made on your hard-drive. To get a feeling for this, the current size of the Bitcoin blockchain is nearly 142 GB (November 2017).
Since the Bitcoin blockchain is not only public but also permissionless, everyone can participate in transaction validation. You can run the open-source mining protocol and become a miner.
However, it is always possible to copy the open-source Bitcoin protocol, adapt the access policy and deploy a private instance of the permissionless blockchain protocol. In such a private instance, access for viewing data can be restricted, but once a user is accepted he can also participate in data validation.
So how does transaction validation work in the public permissionless Bitcoin blockchain?
3. Proof-of-Work consensus mechanism
In a widely distributed network such as the Bitcoin blockchain, massive numbers of transactions are flooded through the network. Every node maintains its own copy of the ledger. Since propagation delay of new transactions occurs in a globally distributed network, it can happen that some validators (miners) collect different transactions than other validators, due to their geographic position in the network.
Consequently, different validators might hold different sets of transactions in new blocks and thus have different views of the state of the system. In order to arrive at a consensus about the state of the ledger and effectively about the order in which transactions are processed, the Bitcoin protocol combines a time-stamping server with a proof-of-work consensus mechanism. In brief, the mechanism works as follows:
In order to validate transactions, each mining node collects transactions and performs proof-of-work.
This means that a validator uses the BlockHash of the preceding transaction block, all new transactions that it receives (in the compressed form of a MerkleRoot), a random number, called “nonce”, and a timestamp, as input to a the SHA-256 hash algorithm.
The output is a 256-bit BlockHash that is unique to the input parameters. If only one input parameter in this algorithm is changed, a completely different BlockHash is the result. By incrementing the nonce, miners can find millions of different BlockHashes for the same transaction inputs.
For instance, finding the hash of block #492004 could have looked like this:
- The first time a miner processes the input data in the hash algorithm led to this BlockHash:
1234 5678 9123 4567 895666edad5db003095dd4956f7669da6e710b6902129187 (example)
2. Changing one input parameter, e.g. incrementing the nonce, might have changed the output of the hash algorithm to a completely different BlockHash:
0000 1293 0404 2390 905666edad38de03095dd4939393949da6e71hdhdhfk9187 (example)
3. After miners increment the nonce as input parameter over and over again and solve the algorithm millions of times one of them finally finds a hash that starts with x number of zeros, such as this one starting with 18 zeros:
0000 0000 0000 0000 005666edad5db003095dd4956f7669da6e710b6902129187
This hash has actually been the valid BlockHash for block #492004 because it meets the required difficulty level of 18 zeros. The number of zeros defines the difficult level for miners to find valid blocks. It is automatically adjusted by the Bitcoin protocol once block finding becomes too easy. Currently, a valid BlockHash needs to start with 18 zeros. As a result, blocks are generated about every 10 minutes.
Finding a valid BlockHash among millions of possibilities can be understood like a lottery. The more a miner invests in computing power (hardware & energy consumption) or analogously in lottery tickets, the more likely he will find the required BlockHash before other miners do.
This can also be understood as tying costs to a “vote” for a valid block. Thus, the higher the computing power of a miner, the higher the number of “votes” he has.
Once a miner finds a valid BlockHash, he “proves” that he has invested money into power and computing hardware and performed work to find the BlockHash. We call this the “Proof-of-Work”. This mechanism ties real monetary costs to “voting” for a valid block of transactions.
So what is the benefit of such an artificial mathematical puzzle?
In a globally distributed virtual network, a malicious single node could replicate “votes” for a valid block at low costs by setting up virtual nodes without physical computing hardware. That way it could insert faulty transactions and for instance double-spend the same coins. This would be the case in a so called Sybil attack.
Under Proof-of-Work however, a malicious node can only insert faulty transactions if it invests heavily into computing power, such that it owns more than 50% of the network’s total computing power. As this is very costly in a globally distributed network with thousands of nodes, the PoW-mechanism prevents these Sybil attacks by tying real costs to voting.
But why should miners invest money and mine at all?
Miners are incentivized by a reward in bitcoin for each block they validate. This reward is composed of a transaction fee and a newly minted number of coins.
After finding the required BlockHash, the miner broadcasts the block data to the network. The protocol allows him to add another transaction to the block. This transaction allocates a fixed amount of new bitcoins to his wallet address. These are referred to as “newly minted coins”.
Currently, the amount a miner receives for a new block is set to 12.5 bitcoins (which at a price of roughly $7,500 USD/bitcoin amounts to $93,750 USD, 05.11.2017). The protocol will halve this reward every 210,000 blocks. The next cut will be in roughly 960 days (For current info check: http://www.bitcoinblockhalf.com/).
Once a miner broadcasts his block through the network, other nodes in the network can verify whether the BlockHash meets the required difficulty level of 18 initial zeros. If so, the node adds the block to its copy of the ledger.
The currently used PoW consensus mechanism is only one of several possible consensus mechanisms. Others include Proof-of-Stake or Practical Byzantine Fault Tolerance. They will be explained when outlining the characteristics of Ethereum and Hyperledger Fabric.
For developers that want to build decentralized applications on Bitcoin, PoW and Bitcoin’s openness are the foundation to realize their ideas. However, as more and more nodes enter the network, transaction fees increase together with transaction processing times. This leads to scalability challenges.
How will Bitcoin deal with scalability challenges? To find out more, see here.
To see an overview of all articles, go here.