The birth of bitcoin and blockchain involves two long-standing problems in digital currency: the Double-Spending Problem and the Byzantine Generals Problem
Compared with the physical currency in daily life, the biggest difficulty in developing electronic cash is how to overcome the âtrust problemâ. The reason why the earliest shells and precious metals can be used as general equivalents is that they have a certain scarcity, and the later physical banknotes rely on the credibility of the state to solve the trust problem.
These physical currencies had value and were able to complete the transfer of value instantly. In the digital era, any content is essentially a combination of 0 and 1 codes, and digital money can be copied into two copies and released to two different recipients at the same time, which is the so-called âdouble spending problemâ. The Internet itself does not have the ability to represent value, so people previously had to use a centralized account system with a centralized server, such as a bank, in order to use credit cards and other types of electronic money.
But whether there is a truly trusted third party is a question. There is a risk of single point of failures, such as attacks on centralized servers, and even governments may collect a âSeigniorageâ by over-issuing money. Bitcoinâs proposed solution is to abandon third-party intermediaries and build a distributed ledger where everyone is at the center of the ledger.
Consider a village where there is only one âchiefâ in charge of keeping the ledger, and all of the village membersâ expenses are registered with the village chief, who is the hub of the ledger system. The system can work well if the village chief is trustworthy; however, if the chief, who is the center of the system, is a thief, it may be difficult for others to detect.
Consider a âdecentralizedâ village in which each member holds an identical ledger. When a member wants to make a change to the ledger, he or she must notify the other members via âbroadcastâ so that they can confirm the entries and copy them to their own ledgers. The transaction process is not complete until all members have confirmed and updated their ledgers. This is essentially how the Bitcoin network operates.
Bitcoin invented a new type of digital system for recording the transaction of assets known as the distributed ledger. In contrast to centralized recording, where data is stored on centralized servers, the blockchain is a decentralized database, with each node in the network acting as the databaseâs holder and maintainer.
Bitcoin was the first large-scale application of blockchain, and blockchain is the underlying foundation of Bitcoin.
The Bitcoin system can be divided into three layers: the data Layer, the protocol layer, and the application layer. Letâs start with the âledgerâ (data layer) that each Bitcoin system member possesses.
A blockchain is essentially a distributed ledger maintained by all nodes in the network, with each node storing the entire blockchain data. The block âchainâ stored by a node is an ordered chain of blocks connected together, and the block itself is an unalterable structure of data maintained by the Cryptographic Hash algorithm.
The hash function (SHA-256 and RipeMD160) is a critical cryptographic algorithm in Bitcoin that can convert an arbitrary-length input value into a fixed-length value output with randomness, collision-free features.And itâs difficult to guess the input value for a hash function from its output. A small change in the input can result in a drastically different output. The output of a hash function can be easily derived from the input, but inferring the input from the output requires brute-force enumeration, which takes a significant amount of time and computing power. The repeated use of hash functions simplifies and defines Bitcoinâs data structure.
A Bitcoin block consists of two parts: the block body and the block header. The block body contains all the transaction information on that block, which is hashed several times to form a structure known as a Merkle tree, which makes up the block body. The first transaction message on each of these blocks is also known as the coinbase transaction and is the transaction that generates new bitcoins and rewards them to the miner, while all other transactions are transfers between users to each other.
These transactions undergo multiple hashing operations to finally arrive at a value called Merkle Hash, which is the sum of all the transaction data. The Merkle Hash, together with Nunce, timestamps, parent block hashes, and other data, constitute the block header, and calculating the hash value of the block header can get the Block Hash of this block. Since the block header of each block contains the hash value of the parent block, all blocks are connected into a chain. The blocks are interlocked, and any change to the block data will result in a change to the block hash, which will break the chain.
After introducing the âledgerâ (data layer) held by each node, letâs move on to the Bitcoin consensus layer, which is responsible for network security.
Before delving into distributed consensus, it is critical to understand the âByzantine Generalsâ problem.
The Byzantine Generals problem dates back to the medieval period when the Byzantine army relied on messengers to transmit information due to Byzantiumâs vast territory. If a traitor deliberately misrepresented the operational information of the higher-ups, it would lead to inconsistent operational plans, resulting in the âByzantine Generals Problemâ.
The Bitcoin network consists of a number of decentralized nodes, each of which is an independent, autonomous, and equal âcorpsâ. Every node in the network has its own unique copy of the blockchain data, and they all want to be the first to package transactions and earn the bitcoin rewards. So, which node will be successful in gaining the ledger rights and convincing the entire network to reach a consensus to modify the blockchain data?
Bitcoinâs answer is the Proof-of-Work (PoW) consensus mechanism, commonly known as âminingâ, which is a digital computing process performed by nodes, where the first node to find the âanswerâ gets the ledger rights. Specifically, the node needs to keep trying to change the Nunce of the block header, calculating the block hash, and finally get a block hash where the first few bits are zero.
At this point, the Nunce value is the answer to the question. After finding the answer, the node will broadcast it to other network nodes, and after verifying the answer, the other nodes will quickly take the block as the new parent node and continue the next round of mining operations.
That presents a problem in that the data take time to broadcast between nodes, and it is entirely possible that two or more nodes discovered the answer to the puzzle at the same time before the community as a whole come to an agreement. However, because two nodes pack different coinbase transactions, this results in two distinct valid blocks. Because of the different signaling sequences, miner nodes will operate on both forks chain. At this point, the Bitcoin network will follow the âlongest chain rule,â treating the fork chain with the most blocks as the only recognized blockchain. This fork competition is typically completed in less than 6 blocks, and all transactions on the other abandoned chain are voided.
Bitcoin nodes can synchronize updates to the distributed ledger by mining and the longest chain rule to reach consensus. This consensus-based distributed ledger also makes peer-to-peer digital currencies like Bitcoin possible.
Traditional electronic currencies use a centralized account system where accounts are created for each user on a central server, and balance data is stored for all accounts. After each transaction, the account balance is increased or decreased in chronological order. Bitcoin, on the other hand, uses a UXTO model, which represents the output of unspent transactions.
Asymmetric cryptography is used to secure bitcoin transactions. Each Bitcoin user must have a pair of public and private keys, similar to a account and password. The user must sign the transaction data with the private key, and publish the transaction data, signature, and public key together. However, in each transaction, the user does not transfer the account balance directly but uses the âunspent amountâ of the multiple previous transactions, i.e. UTXO.
In the Bitcoin system, there is no concept of an account or account balance, only the UTXO of all transactions in the historical record. Bitcoin wallets can scan the data of all previous transactions and calculate the total UTXO of a specific address (i.e., public key) to determine the account balance. Furthermore, when a transaction is initiated, bitcoin wallets can automatically match the UTXO with the correct balance to complete the transfer.
The birth of bitcoin and blockchain involves two long-standing problems in digital currency: the Double-Spending Problem and the Byzantine Generals Problem
Compared with the physical currency in daily life, the biggest difficulty in developing electronic cash is how to overcome the âtrust problemâ. The reason why the earliest shells and precious metals can be used as general equivalents is that they have a certain scarcity, and the later physical banknotes rely on the credibility of the state to solve the trust problem.
These physical currencies had value and were able to complete the transfer of value instantly. In the digital era, any content is essentially a combination of 0 and 1 codes, and digital money can be copied into two copies and released to two different recipients at the same time, which is the so-called âdouble spending problemâ. The Internet itself does not have the ability to represent value, so people previously had to use a centralized account system with a centralized server, such as a bank, in order to use credit cards and other types of electronic money.
But whether there is a truly trusted third party is a question. There is a risk of single point of failures, such as attacks on centralized servers, and even governments may collect a âSeigniorageâ by over-issuing money. Bitcoinâs proposed solution is to abandon third-party intermediaries and build a distributed ledger where everyone is at the center of the ledger.
Consider a village where there is only one âchiefâ in charge of keeping the ledger, and all of the village membersâ expenses are registered with the village chief, who is the hub of the ledger system. The system can work well if the village chief is trustworthy; however, if the chief, who is the center of the system, is a thief, it may be difficult for others to detect.
Consider a âdecentralizedâ village in which each member holds an identical ledger. When a member wants to make a change to the ledger, he or she must notify the other members via âbroadcastâ so that they can confirm the entries and copy them to their own ledgers. The transaction process is not complete until all members have confirmed and updated their ledgers. This is essentially how the Bitcoin network operates.
Bitcoin invented a new type of digital system for recording the transaction of assets known as the distributed ledger. In contrast to centralized recording, where data is stored on centralized servers, the blockchain is a decentralized database, with each node in the network acting as the databaseâs holder and maintainer.
Bitcoin was the first large-scale application of blockchain, and blockchain is the underlying foundation of Bitcoin.
The Bitcoin system can be divided into three layers: the data Layer, the protocol layer, and the application layer. Letâs start with the âledgerâ (data layer) that each Bitcoin system member possesses.
A blockchain is essentially a distributed ledger maintained by all nodes in the network, with each node storing the entire blockchain data. The block âchainâ stored by a node is an ordered chain of blocks connected together, and the block itself is an unalterable structure of data maintained by the Cryptographic Hash algorithm.
The hash function (SHA-256 and RipeMD160) is a critical cryptographic algorithm in Bitcoin that can convert an arbitrary-length input value into a fixed-length value output with randomness, collision-free features.And itâs difficult to guess the input value for a hash function from its output. A small change in the input can result in a drastically different output. The output of a hash function can be easily derived from the input, but inferring the input from the output requires brute-force enumeration, which takes a significant amount of time and computing power. The repeated use of hash functions simplifies and defines Bitcoinâs data structure.
A Bitcoin block consists of two parts: the block body and the block header. The block body contains all the transaction information on that block, which is hashed several times to form a structure known as a Merkle tree, which makes up the block body. The first transaction message on each of these blocks is also known as the coinbase transaction and is the transaction that generates new bitcoins and rewards them to the miner, while all other transactions are transfers between users to each other.
These transactions undergo multiple hashing operations to finally arrive at a value called Merkle Hash, which is the sum of all the transaction data. The Merkle Hash, together with Nunce, timestamps, parent block hashes, and other data, constitute the block header, and calculating the hash value of the block header can get the Block Hash of this block. Since the block header of each block contains the hash value of the parent block, all blocks are connected into a chain. The blocks are interlocked, and any change to the block data will result in a change to the block hash, which will break the chain.
After introducing the âledgerâ (data layer) held by each node, letâs move on to the Bitcoin consensus layer, which is responsible for network security.
Before delving into distributed consensus, it is critical to understand the âByzantine Generalsâ problem.
The Byzantine Generals problem dates back to the medieval period when the Byzantine army relied on messengers to transmit information due to Byzantiumâs vast territory. If a traitor deliberately misrepresented the operational information of the higher-ups, it would lead to inconsistent operational plans, resulting in the âByzantine Generals Problemâ.
The Bitcoin network consists of a number of decentralized nodes, each of which is an independent, autonomous, and equal âcorpsâ. Every node in the network has its own unique copy of the blockchain data, and they all want to be the first to package transactions and earn the bitcoin rewards. So, which node will be successful in gaining the ledger rights and convincing the entire network to reach a consensus to modify the blockchain data?
Bitcoinâs answer is the Proof-of-Work (PoW) consensus mechanism, commonly known as âminingâ, which is a digital computing process performed by nodes, where the first node to find the âanswerâ gets the ledger rights. Specifically, the node needs to keep trying to change the Nunce of the block header, calculating the block hash, and finally get a block hash where the first few bits are zero.
At this point, the Nunce value is the answer to the question. After finding the answer, the node will broadcast it to other network nodes, and after verifying the answer, the other nodes will quickly take the block as the new parent node and continue the next round of mining operations.
That presents a problem in that the data take time to broadcast between nodes, and it is entirely possible that two or more nodes discovered the answer to the puzzle at the same time before the community as a whole come to an agreement. However, because two nodes pack different coinbase transactions, this results in two distinct valid blocks. Because of the different signaling sequences, miner nodes will operate on both forks chain. At this point, the Bitcoin network will follow the âlongest chain rule,â treating the fork chain with the most blocks as the only recognized blockchain. This fork competition is typically completed in less than 6 blocks, and all transactions on the other abandoned chain are voided.
Bitcoin nodes can synchronize updates to the distributed ledger by mining and the longest chain rule to reach consensus. This consensus-based distributed ledger also makes peer-to-peer digital currencies like Bitcoin possible.
Traditional electronic currencies use a centralized account system where accounts are created for each user on a central server, and balance data is stored for all accounts. After each transaction, the account balance is increased or decreased in chronological order. Bitcoin, on the other hand, uses a UXTO model, which represents the output of unspent transactions.
Asymmetric cryptography is used to secure bitcoin transactions. Each Bitcoin user must have a pair of public and private keys, similar to a account and password. The user must sign the transaction data with the private key, and publish the transaction data, signature, and public key together. However, in each transaction, the user does not transfer the account balance directly but uses the âunspent amountâ of the multiple previous transactions, i.e. UTXO.
In the Bitcoin system, there is no concept of an account or account balance, only the UTXO of all transactions in the historical record. Bitcoin wallets can scan the data of all previous transactions and calculate the total UTXO of a specific address (i.e., public key) to determine the account balance. Furthermore, when a transaction is initiated, bitcoin wallets can automatically match the UTXO with the correct balance to complete the transfer.