The basic principles of Bitcoin

in #bitcoin6 years ago

I read Bitcoin's Chinese introduction yesterday and I found it very interesting. However, the above article explained very badly. I took a night and went to Bitcoin's official website to study it carefully and finally understood the principle. It is very inspiring, especially for the circulation and distribution of virtual currency. Write this blog today to manage it.

What is currency? Money is the medium for the exchange of goods (including services). The currency we now pass is issued by reputable banks and is basically guaranteed by its reputation. As long as people use it, we can use it to trade. The currency has a certain degree of hedging. After I have replaced my labor/service/all commodities with money, the bank guarantees me that one day in the future, I can use it to exchange something that is almost equivalent. The premise of this guarantee is that banks will not spam new currencies and everyone will trust them.

Previously, we used precious metals as currency. Because the output of precious metals is not high, the rate of new currency increases is limited, and the economy is constantly increasing, the market needs more money to make the goods as much as possible. Demand is worthwhile. In this sense, the value that the precious metal itself produces has something of secondary importance. The demand for the economy to use currency to circulate commodities is the main one. While precious metal production is limited, and once circulated precious metal currency will exit the market for various reasons, even the new precious metal currency has the same or even higher value.

Why Bitcoin preserves value, BTC (Bitcoin's currency abbreviation) exists in a large p2p network. The group that uses Bitcoin recognizes an algorithm that, under current conditions, will only generate about 6 new BTCs per hour. The current group is 50. In other words, in this world, only about 300 BTCs will be generated per hour. This output will also be automatically adjusted by the network to limit production. You can't speed up money production by modifying everyone's Client's algorithms and parameters (the client is open source). Counterfeit currencies are discarded by the network (unless you can control most network nodes).

What is the value of BTC itself?

The value of BTC is the trading channel itself. A group of newly created BTCs provided mathematical assurance that the old BTC was transferred from one account to another. The price behind this security guarantee is a lot of computing power. The production of such a safe passage requires a lot of energy, so the whole BTC user group rewards the coin maker (currently 50 BTC).

To put it simply, my understanding is that all the BTCs in the world today are generated from the energy of running computers. Their total value (up to now, a total of about 12w BTCs have been produced, 50 in each group, the market The price of approximately 7.3 US dollars a) should be less than the total market value of energy consumed. However, I think that most of the energy used to produce BTC was originally used without wasting resources.

How does a "bank" without a central node make people trust and work?

The answer is that each node on this p2p network records a detailed list of each transaction since the birth of BTC, and from this it can be inferred who the unique BTC belongs to. In this way, when you accept a transaction, you will know if the money someone else gave you is legal.

From the basics:

Each account is actually a pair of public and private keys. The person who has the private key is the owner of the account. If A wants to transfer money to B, A adds the amount of money to B's public key and signs it with his own key. When B sees this signature, he can understand that it was indeed A who transferred him to the BTC.

Then the transaction requires a witness, guaranteeing the transaction has occurred. In this way, it will be legal for B to use the money later. The guarantor is the entire network that uses BTC.

A When launching this transaction, the signed transaction ticket must be broadcast to the p2p network as much as possible, and eventually each node will know about it. B constantly receives confirmation from others on the p2p network. When it receives enough confirmation information, it thinks that A indeed issued this transaction ticket. After this, B can freely use the money.

When B uses A to transfer its money to C, it also broadcasts to enough (and eventually everyone receives) the person to guarantee it. Each guarantor only confirms if B has enough money to pay. In essence, the BTC Network does not record who each dollar belongs to. It records every transaction from birth to the current time and deduces how much money is in each account. When anyone tries to confirm a transaction, it needs to confirm that there is not so much money on the transfer account.

The core problem that Bitcoin needs to solve is how to avoid spending a sum of money twice.

The entire billing sequence is a loop. Everyone needs to use the previous information to generate the next one when signing a new one on the complete global bill. This sequence of bills is called chain of blocks. Each block contains several transaction records that have been confirmed and hashed (hard to forge). Each block is associated with the previous block on the global table. Each bill will eventually be forwarded to the node that created the new block through the p2p network.

The process of creating a new block is called mining. Manufacturing a new block is to pack the newly received bill in the newly created block. This packaging process is the process of production, and only extremely rare chances are created. (You can think of it as putting together the newly received bills, one forming can't be modified, and if the manufacturing fails, it's going to come again.) Once the manufacturing is successful, you put the new block (which is considered to be the old global blockchain Continue) Broadcast.

Because it is a p2p network, many people may be creating new blocks at the same time, but there is a sorting mechanism that guarantees that only the new block that is optimal (the most difficult, which takes the most computing time) is accepted by the network community and hangs on the global block. On the chain. Once again, the entire BTC network has only one global billing table, and each node has a complete copy of it.

This list of global bills will grow bigger and longer, and the chain of blocks will grow longer. In the latest part, there must be many deliveries. This is because the mining process of the p2p network is performed separately and in parallel, and each new bill cannot be broadcast to all nodes at once. Each mining node has the responsibility of merging the new bill he received, which does not exist on the old global bill that he approves, into the new block he is preparing to manufacture. Once the new block is created, it will be broadcast immediately and it will win more people's approval. It is mainly the recognition of those who want to mine that these people will build a new block based on this block.

If the p2p network is too large, transaction bills cannot be broadcast as quickly as possible to the entire network. It will come out locally on the p2p network with a global bill that is collectively recognized by small groups. It is possible that branches of multiple global billings will develop at the same time. Because each small group may think that the part they see is longer and more effective. However, only if someone discovers that the other branch is longer, it will switch camps. So, there is a certain possibility that your bills are accepted by a small group, but after a while, they are abandoned by the bigger camp.

However, the algorithm parameters determine that the new block is slow to generate. If your bill is confirmed by as many as six people, it basically guarantees that the global bill that it is merged into is universally recognized by the p2p network.

Since it takes time and effort to generate a new block, the chance of creating a new block is like winning a lottery ticket. How many people execute the program to calculate a new block? The answer is that every person who creates a new block has the right to construct a bill statement to give me 50 BTC. This rule is commonly acknowledged by all BTC users. The equivalent of making a block to mining gold is just an image metaphor. In fact, no one can dig up gold and hoard it. Each new block must contain the hash value of the previous block on the global table. The BTC network is self-tuning, and it generates approximately one new block every 10 minutes. If you don't make a new block in 10 minutes, that means you've done 10 minutes in front of you. Continue with the latest version of the block.

So a more appropriate metaphor is to buy lotteries. A lottery ticket opened every 10 minutes. You are constantly spending money to buy. It is yours to open in 10 minutes. Anything you can't buy first will be void, and then the next round.

How can mathematics ensure that the mining process consumes a lot of CPU time? And only a small chance of success?

This uses a system called Hashcash. It was first invented to improve the email spam problem.

It is to add a specific hash header to a specific piece of information (such as who the email was sent to). This hash header requires a lot of CPU time to calculate. Spammers don't have as much CPU time calculating a qualified hash header for each email sent to the group, so emails that believe that this legal hash header is less likely to be a spam (have spent the CPU time)

The algorithm is to find a string of numbers for the information you want to protect. After adding it, use a well-known hash algorithm such as SHA-2 to calculate a hash value. If the hash value is preceded by a long string of 0s (how many determine the difficulty), then it succeeds.

For a piece of information, to find this series of figures, at present, there is no good way except violence. That is to say, change the numbers randomly and change them one at a time. After a predictable number of attempts, you can usually find the number you are looking for.

Everyone who wants to earn BTC mining constantly listens to information from the BTC network. If someone releases a new, legal block, he merges it into the local global table. And reset your own calculation process, starting with the newly obtained block. If there is a newly issued transaction ticket, it is also recorded. Constantly combine the hash value of the latest block, the new transaction ticket received, and the 50 BTC bonus card you have obtained. Calculate SHA-256 to see if the result meets the conditions. Once satisfied, the new block is broadcast.

When enough people recognize it (calculate the block behind it), he also gets the 50 BTC.

To match the economic scale of BTC. All Bitcoin clients are set to be every 210,000 blocks. The number of BTCs who get a new block is less than half that of the previous one. If this time, he still writes himself 50 BTC. Others do not Will confirm his block). This will slow the overall growth of BTC. The speed of the new block is adjusted by the difficulty. This difficulty is automatically adjusted by the p2p network based on the speed of the most recent production block. So even if the calculation capacity increases in the future, it can guarantee a speed of about 10 minutes.

Furthermore, fewer nodes will be willing to contribute their own CPU to mine as the benefits of producing new blocks decrease. (If you reduce too much, just reduce the difficulty)

In the end, the p2p network no longer creates new BTCs out of thin air. What is the driving force for creating new blocks at this time? That is the transaction tax. Because no one is willing to produce a new block, it is difficult to initiate a transaction. (No block can hold a transaction ticket.) The person who wishes to confirm the transaction can state that if someone creates a new block to accept his transaction ticket, he will pay him a small transaction tax. When many people do this, making blocks has become profitable. However, there is no longer a new BTC born directly, but only between these BTC users.

There will always be some BTCs disappearing, mainly because the private keys of those accounts are lost. No one can transfer the money from the account. Money that cannot be circulated is not money. But in the end BTC will generally reach a relatively large scale, which is exactly 21 million. But BTC itself can be cut, for example you can pay 0.01 BTC to someone else. Therefore, the BTC itself will appreciate and the total amount will still be sufficient.