HASH code: Convert a long character string into a fixed-length character string, and the conversion is irreversible, that is, it is impossible to guess the original character string from the HASH code. SHA256 is mainly used in the bitcoin protocol. Public key system: Corresponding to a public key and private key, keep the private key in the application, and make the public key public. When A transmits information to B, A’s private key can be used to encrypt the information, and A’s public key can be used to decrypt the information. This ensures that a third party cannot pretend to be A to send the information. At the same time, when A transmits information to B, use B’s public key. The key is encrypted and sent to B, and B uses his own private key to decrypt, which ensures that a third party cannot eavesdrop on the communication between the two. The most common public-key system is RSA, but the bitcoin protocol uses the elliptic Curve Digital Signature Algorithm.
What is the difference between cash and bank accounts?
Bitcoin is an electronic currency and the unit is BTC. In this article, it is also used to refer to the entire bitcoin system.
Just like opening an account in a bank, the corresponding concept in bitcoin is an address. Everyone can have one or several Bitcoin addresses, which are used to pay bills and receive money. Each address is a string of strings starting with 1. For example, I have two bitcoin accounts, 1911HhKdLbnsffT5cRSiHgK3mdzMiyspXf and 1JSUzrzMk7f6iymfVkvqLBJDBZXBopyfZK. A bitcoin account is uniquely determined by a pair of public and private keys. To save the account, you only need to save the private key file.
The difference from a bank account is that the bank keeps all transaction records and maintains the book balance of each account, while bitcoin transaction records are jointly maintained by the entire P2P network through a pre-agreed agreement.
How much money is in my account address?
Although you can see the balance of the current account using bitcoin’s software, unlike a bank, there is no place to maintain the book balance of each address. It can only use all historical transaction records to calculate the account balance in real-time.
How do I pay the bill?
When I pay from address A to address B of the other party, the payment amount is e. At this time, both parties will announce the transaction information to each network node, telling address A to pay address B, and the payment amount is e. In order to prevent a third party from forging the transaction information, the transaction information will be encrypted with the private key of address A. At this time, the network node that receives the transaction information can use the public key of address A to verify that the transaction information was indeed sent by A. Of course the trading software will help us do these things, we only need to enter the relevant parameters in the software.
What will the network node do after receiving the transaction information?
This is the most important part of the entire bitcoin system and needs to be elaborated. For the sake of simplicity, only the currently implemented bitcoin protocol is used here. In the current version, each network node will save all transaction information through synchronization.
All transaction information that has occurred in history is divided into two categories, one is “verified” transaction information, that is, transaction information that has been verified, which is stored in a series of “blocks”. The information of each “block” is the ID of the previous “bock” (the ID of each block is the HASH code of the block’s HASH code) and the new transaction information (see an actual block). The other category refers to transaction information that is still “unverified”, and the transaction information just paid above belongs to this category.
When a network node receives new unverified transaction information (maybe more than one), since the node saves all transaction information in the history, it can calculate the book balance of each address at that time, so that it can calculate Whether the transaction information is valid, that is, whether there is enough balance in the payment account. After removing invalid transaction information, it first takes out the ID of the last “block”, then combines this unverified transaction information with the ID, and adds a verification code to form a new “block”.
The above construction of a new block requires a lot of calculation work because it needs to calculate the verification code so that the above combination becomes a block, that is, the first few bits of the HASH code of the block’s HASH code are 1. Currently, the first 13 bits are required to be 1 (roughly so, not sure about the specific method), which means that if the block is generated by enumeration, the average number of enumerations is 16^13. Using CPU resources to generate a block is called “gold mining”, because the production of the block will get a certain reward, and the reward information has been included in this block.
When a network node generates a new block, it will be broadcast to other network nodes. But this network block will not necessarily be accepted by the network, because it is possible that other network nodes produced the block earlier, and only the block that was generated earliest or the block with the most subsequent blocks is valid, and the remaining blocks will no longer be the next block. The initial block.
How to confirm that the other branch pays a success?
After the payment information is distributed to the network nodes, the network nodes begin to calculate whether the transaction is valid (that is, whether the account balance is sufficient for payment), and try to generate blocks containing the transaction information. When a total of 6 blocks (1 direct block and 5 subsequent blocks) contain the transaction information, the transaction information is considered “verified”, so the transaction is formally confirmed, and the other party can confirm that the payment is successful.
One possible problem is that I will pay all the balance in address A to address B and at the same time to address C. If only the verification order is valid, the transaction is valid. At this time, my cheating method is to generate 6 blocks that only contain B and send them to B before the truth is revealed, and generate 6 blocks that only contain C and send them to C. Since the CPU time required for me to generate blocks is very long, compared with the entire network, the probability of my cheating is very small.
What is the motivation for network nodes to produce blocks?
As can be seen from the above description, in order to make the transaction information effective, the network node needs to generate 1 and 5 subsequent blocks to contain the transaction information, and the generation of such a block is very CPU-intensive. So how can other network nodes help produce blocks as soon as possible? The answer is simple. The agreement stipulates that the address that produces the block will be rewarded with BTC, and the transaction fee promised by both parties. At present, the reward for producing a block is 50 BTC, and it will be halved every four years in the future. For example, between 2013 and 2016, the reward is 25 BTC.
Is the transaction anonymous?
Yes, it is not. All BITCOIN transactions are visible, and we can check all transaction records of each account, such as mine. But the difference from the bank’s currency system is that everyone’s account is anonymous, and everyone can open many accounts. In general, the so-called anonymity is not as good as claimed.
But there is another advantage that Bitcoin is used for black market transactions. It cannot be frozen. Even if the police tracked down a bitcoin address, there would be no way unless the computer used by the exchange was tracked based on the network address.
How to ensure that Bitcoin does not depreciate?
Generally speaking, in the case of equivalent trading activities, the value of the currency is inversely proportional to the amount of currency issued. Unlike the traditional money market, the central bank can determine the amount of currency issuance. Bitcoin does not have a central issuing agency. Only by producing blocks can a certain amount of BTC currency be obtained. Therefore, the amount of new bitcoin currency is determined by:
1. The speed of block production: Bitcoin’s agreement stipulates that the difficulty of producing blocks is fixed at an average of 2016 every two weeks, about 10 minutes to produce one. Moore’s Law, which doubles the CPU speed every 18 months, does not speed up the production of blocks.
2. The number of rewards for producing blocks: Currently, every block produced is rewarded with 50 BTC, which is halved every four years. In 2013, the reward was 25 BTC, and in 2017, the reward was 12.5 BTC.
Combining the above two factors, the speed of bitcoin currency issuance is not controlled by any single node in the network node. Its protocol makes the stock of currency known in advance, and the maximum stock is only 21 million BTC (currently an increase of about 50,000 BTC per week)