After entering the Web3.0 era, we urgently need a form of currency that is created, owned, and controlled by users.

There is a mechanism for "credit" endorsement, allowing people to reach a "consensus" on this currency at the transaction level.

As people spend more online, it should still be able to meet the demand for digital transactions.

It should be decentralized and the data stored should belong to everyone who created it.

It should be safe and verifiable, the trading system needs to be able to run smoothly and continuously, and no one can change the amount of currency in their hands at will.

Electronic signatures and distributed ledgers

In order to facilitate understanding of the subsequent series of concepts related to Bitcoin and blockchain, let us create a virtual scenario, simulate the actual operation of currency, and think about existing problems and solutions.

Scenario: Xiaoming, Xiaohong, Xiaogang and Xiaoli are four good friends who have frequent financial transactions with each other, so they set up a public electronic ledger to record the transactions between each other's accounts and settle them uniformly at the end of the month.

Now let’s look at the problems that arise with such a simple transaction system and how Bitcoin solves them.

Electronic signatures: public and private keys

The first question is how to ensure that the transaction records are accurate?

Because the electronic ledger is public, anyone can secretly add records to it. What if Xiao Ming adds a non-existent record to the public ledger without Xiao Gang’s permission, saying “Xiao Gang wants to transfer 10 yuan to Xiao Ming”?

The simplest idea is that every transaction requires an unforgeable electronic signature of the person to confirm that the person has authorized the transaction. (Private key signature, public key verification signature)

But how to achieve an unforgeable electronic signature? This involves the research results of cryptography: public key and private key. Each person's account has a pair of strings, one is called the public key and the other is called the private key. The public key is the public account address that everyone can see, while the private key is equivalent to the account password. Only you know this string of numbers, and each public key corresponds to only one private key. In order to achieve electronic signatures, two functions are needed:

Signature function and verification function.

Signature function (transaction record, private key) = electronic signature for the transaction

Verification function (transaction record, signature, public key) = True/False

Difficulty

Because the function is irreversible, there is no other way to obtain the public key to match the private key to forge a signature except to try enumerating one by one, and a complete enumeration requires 2256 attempts. In other words, if you want to find this number by enumeration, assuming that you use 100 trillion Chinese "Tianhe-1" supercomputers with a peak performance of 1.206 quadrillion times per second, even if it takes 100 trillion years, it will not even reach a fraction of this enumeration amount. This huge amount of calculation fundamentally guarantees the unforgeability of electronic signatures.

Electronic ledgers and cryptocurrency

To avoid this situation, it is necessary to make everyone who participates in this system deposit a certain amount of money into their account and record it in the ledger, just like using Alipay, before they can make transactions. For example, "Xiaoming deposited 100 yuan into his account." Every time a transaction record is added, it is necessary to determine whether the other party has that much money in their account. If the deposited amount is not enough, the transaction needs to be declared invalid.

So far, the above are the most basic functions of a payment system.

Distributed Ledgers and Broadcast Networks

Electronic signatures and electronic ledgers have successfully solved the problem of how to enable mechanisms to conduct credit endorsements and digital transactions. However, in order to realize the concept of "user creation, user ownership, and user control" in the Web3.0 era, we need to make the ledger distributed and store it with every user in the network.

And because "the sum of historical transaction information is currency", the ledger in everyone's hands should be the same. At this time, a broadcast network is needed.

For example, if Xiao Ming wants to give Xiao Gang 100 yuan, Xiao Ming needs to "yell" along the network cable to pass this message to Xiao Hong, Xiao Gang and Xiao Li, so that they can also add this information to the account book to ensure that everyone's account book is consistent. Of course, this is just a figurative metaphor, and this process is actually completed by the cryptocurrency system itself.

Consensus Mechanism and Blockchain

Consensus Mechanism

When we use electronic signatures and distributed ledgers, we use a set of mechanisms to solve the problem of credit endorsement. However, with such a system, can we really reach a complete consensus at the transaction level?

Imagine a scenario where Xiao Ming wants to give Xiao Gang 100 yuan. Xiao Ming "shouted" along the network cable to send this message to everyone. But at this time, Xiao Hong's network failed and she lost the message record. Xiao Gang had this information in his account book, so he thought he could use this "100 yuan" for the transaction. But when he contacted Xiao Hong, Xiao Hong did not have this record in her account book, so she naturally did not recognize the value of this "100 yuan", and could not reach a "consensus" on the transaction.

Therefore, in order to reach a "consensus" at the transaction level, a mechanism needs to be established to ensure that everyone receives the same message records in the same order. This is called a "consensus mechanism." The consensus mechanism designed by Bitcoin at the beginning of its establishment is called proof of work. In addition, there are proof of stake, delegated proof of stake (DPoS), practical Byzantine Fault Tolerance (PBFT), participation Proof of Participation (PoP) and other forms of consensus mechanisms. The following is a description of the Byzantine picture:

Proof of Work (PoW)

The core idea of ​​proof of work is that if you want to get a "consensus" recognized by everyone, you need to do enough work. In the Internet world, this workload is computing. In this case, the computing power and time resources consumed by the calculation are the basis of everyone's trust.

So how do you prove your computational effort? This is where you need to use a famous encryption tool - the hash function. This type of function has a very peculiar nature. You can input characters of any length, and it will output a string of characters in a fixed format. Interestingly, although any input will only have one output, the arrangement of the outputs looks completely random, and any slight adjustment to the input may cause a huge change in the output.

For example, if you input "Xiao Ming gave Xiao Gang 100 yuan", the result is 256 zeros, but if you input "Xiao Ming gave Xiao Gang 101 yuan" or "Xiao Ming gave Xiao Gang 101 yuan" (remove the word "了"), dozens or hundreds of random digits may change. This means that this function is similar to the signature function mentioned above. It is almost impossible to reversely infer the input through the output. The only way to crack it is to try one by one. Take the hash function "SHA256" as an example. For any input, it will output a 256-bit binary sequence, which means that it takes 2 to the power of 256 to enumerate it. It has been mentioned in the previous article how astronomical this is. Because of this unique property, hash functions are also widely used in the field of cryptography. The passwords that people usually fill in when registering on websites and bank deposits may be encrypted by this type of function.

With such a function, a "proof of work" mechanism can be established, and everyone can give a question to the person who wants to prove his or her workload. For example, specify a string of 20 binary 0-1 characters, and ask the answerer to find an input value so that 20 of the 256-bit output value are exactly the same as the specified string. For those who want to prove their workload, they can only try one by one, and after enumerating about 220 times (about 1 million times), they can calculate the result. The way to verify the result is very simple for the questioner, and there is no need for repetitive work such as enumeration. You only need to input the answer into the hash function and see if the first 20 bits are exactly the same as the question. This can prove that the answerer has put in about "220" of workload.

Example

A classic example of proof of work is the mining process of the Bitcoin network. Here is a simplified description of the steps:

A transaction occurs: When someone makes a transaction on the Bitcoin network, for example, Alice wants to transfer 1 Bitcoin to Bob.

Transaction broadcast: This transaction information is encrypted and broadcast to all nodes in the entire Bitcoin network.

Transaction confirmation: After receiving the transaction information, the miners in the network will package it into a new block together with other transactions waiting for confirmation.

Computational work: Each miner starts by trying to find a specific numeric nonce by combining this nonce with other information of the new block (including the hash of the previous block, the new transaction list, etc.) and running it through the SHA-256 hash function.

Meeting the difficulty target: The Bitcoin network dynamically adjusts the difficulty of mining so that miners need to perform a certain number of hash operations (usually millions or billions) on average to find a nonce that meets the conditions. This condition usually requires that the first few bits of the hash result be zero.

Finding the nonce: When a miner finds a satisfying nonce through a large number of computational attempts, they have completed the proof of work.

New block generation: The miner broadcasts the new block containing the correct nonce to the entire network.

Verification and confirmation: When other nodes receive a new block, they independently verify all the transactions in it and whether the nonce actually meets the requirements of the proof of work. If the verification is successful, they will accept the new block and add it to their own copy of the blockchain.

Rewards and Fees: Miners who successfully generate a new block will receive a certain amount of Bitcoin as a reward (currently 6.25 BTC), and can also charge transaction fees for all transactions in the block.

Through this process, the proof of work ensures that only miners who pay actual computing resources can create new blocks, and because tampering with historical blocks requires re-completing all previous proofs of work, this makes the Bitcoin network highly secure. However, this also leads to a lot of energy consumption, because miners need to constantly run high-performance computers to compete to solve these complex mathematical problems.

2024-2025 is destined to be an extraordinary year for blockchain

💸If you are interested in trading technology and want to have your own trading system like me, whether it is a long-term or short-term transaction, you can handle it with ease! Come to my community to communicate and let us have more Bitcoin together💸

💕 Remember to follow me💕 Your attention gives me more motivation to share useful information with everyone! I will share the wealth code at any time💸 Remember to check it out💰#热门话题 #Web3Wallet #Web3Pay $BTC