What is blockchain?
In short, blockchain is equivalent to a decentralized digital ledger that records a series of data. These data are organized into blocks, protected by cryptography, and arranged in chronological order.
The earliest models of blockchain were built in the early 1990s. At the time, computer scientist Stuart Haber and physicist W. Scott Stornetta used encryption technology to protect data from tampering.
This achievement of Haber and Stornetta inspired many computer scientists and cryptography enthusiasts to study blockchain, which also promoted the birth of Bitcoin, the world's first decentralized electronic cash system (the first cryptocurrency). .
Although blockchain technology predates cryptocurrencies, it was not until 2008, when Bitcoin was created, that the former gained acceptance. Since then, public interest in blockchain technology has grown, and cryptocurrencies have also become popular.
Blockchain technology is primarily used to record cryptocurrency transactions, but it can also record a variety of digital data and has other applications. The oldest, most secure, and largest blockchain network is Bitcoin, which is carefully designed to balance cryptography and game theory.
How does blockchain work?
In the cryptocurrency world, we can think of blockchain as a chain of stable blocks, each of which stores a series of previously confirmed transactions. The blockchain network is maintained by countless computers, so its main function is to act as a decentralized database (or ledger). In other words, all participants in the blockchain (i.e. nodes) maintain a copy of the blockchain data and maintain good communication with each other to ensure that everyone is always on the same page (or block).
Therefore, blockchain transactions are conducted in a global peer-to-peer network, making Bitcoin a decentralized, borderless, and censorship-resistant cryptocurrency. However, most blockchains do not require any trust mechanism and are considered trustless systems. Bitcoin also has no independent regulatory body.
Almost all blockchains are centered around mining, which is inseparable from the hash algorithm. Bitcoin uses the SHA-256 algorithm (Secure Hash Algorithm 256-bit), which can produce an output of the same length for a string of any length. The output result can be called a "hash value", which is always 64 characters (256 bits).
Therefore, no matter how many times "mining" is repeated, the same input always produces the same output. However, if the input changes slightly, the output will be completely different. Therefore, hash functions are deterministic, and most cryptocurrencies are designed as one-way hash functions.
This type of function determines that users cannot reverse the input based on the output result. The only way is to guess, but the probability of guessing correctly is very small. This is one of the reasons why the Bitcoin blockchain is safe and reliable.
Now that we understand how the algorithm functions, let’s take a look at a simple transaction example to illustrate how blockchain works.
Assume that Alice and Bob are two bitcoin holders, and Alice owes Bob two bitcoins.
In order to repay Bob two bitcoins, Alice broadcast this transaction information to all miners in the network.
In this transaction, Alice tells the miner Bob's address and the amount of bitcoins in the transaction, and attaches a digital signature with her public key. The signature is generated by Alice's private key, and the miner can use it to verify that Alice is the actual owner of these bitcoins.
After confirming that the transaction is real and valid, the miner can put this transaction information together with other transaction information into a block and try to "mine" this block. The block is calculated by the SHA-256 algorithm, and the calculation result must start with a certain number of "0" to be judged valid. The number of "0" depends on the "difficulty" of the calculation, which will change with the change of the computing power of the entire network.
In order to correctly output the expected number of "0" hash values, miners will add a "nonce" to the block before running the encryption algorithm. A slight change in this value will completely change the result of the operation. Miners must try different random nonces until they get the correct hash value.
Each time a block is mined, the miner broadcasts the new block information to the entire network so that other miners can confirm the validity of the block. After that, they will add the valid block information to their own blockchain, indicating that the transaction is complete. However, the miner still needs to add the hash value of the previous block to the new block, and finally connect all the blocks to form a veritable "blockchain". This is very important and reflects the role of trust in the system.
Each miner stores a copy of the blockchain on his or her personal computer and reaches a consensus: the blockchain with the most computing power must be the longest. If someone wants to change the transaction information in the previous block, the hash value of this block will also change, causing the hash values of all blocks after this block to change. He or she must start all the previous calculations over again to convince others that his or her block information is correct. Therefore, if a miner attempts to tamper with the block information, he or she must invest more than 50% of the computing power of the entire network, which is almost impossible. Such network attacks are therefore called 51% attacks.
This model of requesting computer calculations to generate new blocks is called proof of work (PoW). In addition, there are other mechanisms, such as proof of stake (PoS), which do not require huge computing power support, consume less electricity, and attract more users to participate.

