Skip to content
We'll be introducing Bitcoin and blockchain in 30 minutes

We'll be introducing Bitcoin and blockchain in 30 minutes

The common introductory articles on bitcoin and blockchain can be divided into two categories: one is popular science books for non developers; The other is the technical guide for developers. The former is easy to be superficial and gives readers access to a pile of nouns and concepts, but they can't have an intuitive understanding of special currency and blockchain; The latter often directly into the details, so that developers can not understand the technical overview from the overall situation. This paper attempts to combine these two kinds of articles into one and avoid the above two defects at the same time. The first part of the article is suitable for non developers who want to understand bitcoin and blockchain, and the whole article is suitable for technicians who want to transfer to bitcoin and blockchain related development.

1、 What is bitcoin

  the quickest way to understand a strange thing is to compare it with a familiar thing, find out the differences and study the differences. Take transfer payment as an example to illustrate what happens in traditional currency transfer and bitcoin transfer. The traditional currency here refers to the legal tender issued by various countries, such as US dollar and RMB, and also includes the virtual forms of these currencies in the banking system, such as people's deposits in the bank. Hereinafter referred to as legal currency.

  the following table shows the steps of Zhang San's transfer to Li Si in French currency and bitcoin respectively:

step Legal currency Bitcoin remarks

one Zhang San and Li Si open accounts in the bank and set the corresponding password. Zhang San and Li Si each install a software called wallet and use the software to generate the account and the password of the corresponding account. The account and password generated by wallet software will not be known to any third-party organization before use, and only exists on the user's own mobile phone or USB drive.

two Zhang San should ensure that he has enough money in his bank account to transfer to Li Si. If not, he should deposit a sum in the bank first. Zhang San should ensure that the money in his bitcoin account is enough for transfer. If it is not enough, he will buy bitcoin through the bitcoin trading platform and deposit bitcoin into the account generated by the wallet software. In essence, he is exchanging the legal currency in the bank for bitcoin. The bitcoin trading platform transfers bitcoin to Zhang San's account, which is similar to the process of transferring Zhang San's bitcoin to Li Si's account discussed here. In addition, bitcoin can be obtained by mining, which is not easy for ordinary users. We will discuss this later.

three Zhang San authorized the bank to transfer a sum of money from his account to Li Si's account by entering a password. Zhang San uses the password of the corresponding account in his wallet software to authorize and transfer to Li Si's collection account, and notifies the blockchain network. The blockchain will be introduced later. Now all you need to know is that the blockchain can record authorized bitcoin transactions.

four The bank wrote down Zhang San's operation, deducted a sum of money from Zhang San's account, and added the same amount of money to Li Si's account. The blockchain network records Zhang San's transfer record. In the third step, bitcoin authorization and transfer occur at the same time, so this step only needs to record the transfer. Blockchain networks and banks perform the same function: bookkeeping.

five The bank informed Zhang San and Li Si that the transfer was successful. Both Zhang San and Li Si can confirm the successful transfer by querying the blockchain network. Blockchain networks and banks perform the same function: confirm transactions

  as can be seen from the above table, from the user's point of view, bitcoin has the same function as legal currency to complete transfer transactions, and even the steps are very similar, but each step is different.

  step 1: Although both accounts and passwords are required, the legal currency account is set in the bank, and the bank will save the user's account and password data; The account and password of bitcoin are not known by any third party except the user before use.

   step 2: recharge the bank account must be through the bank system. If the system of the deposit bank fails (if the optical fiber is cut off by the construction team), Zhang San cannot recharge during the failure; When recharging bitcoin, if a trading platform fails, Zhang San can change to another recharging platform at will, because the account generated by bitwallet is recognized by all trading platforms.

  step 3: the password authentication authorization of legal currency must go through a central system such as a bank; The password authentication authorization of bitcoin does not depend on any central system, but only on the algorithm provided by cryptography. As in step 2, bitcoin will not be affected by the fluctuation of a specific system.

  step 4 and step 5: bank intervention is required for legal currency bookkeeping and transaction confirmation; Bitcoin relies on the blockchain network. Later, we will talk about that the blockchain is jointly maintained by many companies or individuals. Even if the equipment of some companies or individuals fails, it will not affect the operation of the whole blockchain network.

  in addition to the above, the issuance methods of legal currency and bitcoin are also different: legal currency is generally issued by the state and its circulation and use is guaranteed in the form of law; The issuance method of bitcoin is mining. In theory, everyone can participate in mining to obtain bitcoin. This is very similar to gold, another currency on earth. Gold is rare and limited on earth, bitcoin is also limited, and the mining volume decreases year by year until it is mined out about 100 years later. Note that the word mining is actually just a metaphor. Mining is closely related to the operation of blockchain, which we will discuss in the next section.

  conclusion: each step of legal currency transaction needs a central institution to ensure, either the state or a bank recognized by the state; Bitcoin can complete all transactions without any centralized institutions and equipment. In addition, the transaction data stored in the blockchain is only anonymous account data (there is no information about Zhang San and Li Si, just a long digital string), which is generally considered anonymous. One sentence summary: bitcoin is a decentralized anonymous digital cryptocurrency, which uses blockchain for transaction bookkeeping.

   in order to facilitate understanding, many details have been omitted. In order not to cause confusion when actually contacting bitcoin, I think it is necessary to explain several points

   the account generated by bitcoin wallet software is usually called bitcoin address in bitcoin terminology. A bitcoin wallet can generate many addresses, which are used to accept other people's transfers, which is a little similar to the e-mail address, except that one address is only used to receive one transfer. An address corresponds to a password. In bitcoin terms, it is called a private key. The user's right to use the funds in the address is completely guaranteed by the key. Therefore, it is very important to save the key safely. Once it is lost, there is no saying to reset the password.

   in fact, wallet programs issued by many companies often require users to register in order to encrypt and store the account key data in the user's wallet software in the company's server. As long as users remember the account password in the company, even if they lose the data in the wallet program, they can still be retrieved through the backup stored in the company, but this is not the content of bitcoin itself. This is equivalent to the user having some gold bars (bitcoin) and opening a safe in a company to store these gold bars, but it is the same with the safe (encrypted USB drive) that puts these gold bars at home. Putting gold bars in a company means that you are very confident in the strength of the company. It will not be attacked by thieves or stolen by yourself.

2、 What is a blockchain

  in step 3 above, we said that the authorization of bitcoin use does not need to go through a central system such as a bank, but is authorized by the user through a cryptographic algorithm. Then why don't two users trade directly and take it out of their pockets like gold bars to each other? Why should the blockchain network be notified of every transaction like a bank? Although bitcoin is similar to natural currency gold in many ways, there is one big difference: gold cannot be copied; Bitcoin only exists in USB flash disk or computer mobile phone data, which can be copied indefinitely. This means that after Zhang San gives Li Si a gold bar, he can no longer give the same gold bar to others; After Zhang San gives Li Si a copy of bitcoin, he can copy it to others. How to solve this problem? This requires a blockchain.

  in short, blockchain is an account book maintained by many people or groups and accessible to all. The account book is used to record every bitcoin transfer. All users can query the account book to understand the balance in their wallet and whether the bitcoin transaction is successfully completed.

Figure 1 blockchain

  

As shown in the above figure, the blockchain account book is divided into blocks. Each block stores many transaction records. These blocks are connected in a certain way according to the generation time to form a chain structure, which is the origin of the blockchain name. The yellow part in the figure is the record formed in the blockchain in the above example.

  let's look at how blockchain solves the above multiple payment problem. The payee checks whether the transfer has arrived by querying whether the blockchain has a corresponding transfer record (for Li Si, it checks whether there is a transfer record from B to c); Before recording a transfer transaction, the blockchain will first query whether the same amount of money has been transferred to other accounts in the blockchain record (whether Zhang San's B account has been transferred out). If it has been transferred, it will be deemed that the current transfer is illegal and refuse to record the transfer, so that the recipient cannot find the corresponding transfer in the blockchain account book.

  there are similar ledger facilities in the traditional bank transaction system. What is special about the blockchain? It lies in the joint maintenance of multiple people or groups mentioned above, that is, decentralization. Joint maintenance means that all bookkeepers can keep accounts in the blockchain ledger, which brings new problems: how to ensure that each bookkeeper will keep accounts honestly? For example, how to prevent Zhang San from transferring the same money to Li Si as the bookkeeper? This should mention another mechanism of bitcoin, which is commonly referred to as mining.

   assuming that everyone involved in bookkeeping (mining) is mercenary and how to make money (regardless of any moral constraints), the blockchain has created an algorithm system so that everyone involved in bookkeeping would rather get paid through honest bookkeeping. Take chestnuts for example. There are two jobs: one is that it takes two days to rob a bank, the other is that it takes only one day to dig a gold mine. The reward for digging a gold mine is equal to or greater than robbing a bank. Rational people will choose the latter. The algorithm of blockchain makes every bookkeeper pay a certain price to keep accounts, and rewards bookkeepers at the same time. The price here is the calculation time. The reward includes two parts: one is the Commission drawn from each transaction, and the other is the bitcoin reward newly generated by the system. The second reward is why bitcoin calls bookkeeping mining.

   blockchain bookkeeping takes blocks as units and writes the latest transaction records into a block. The bookkeeper's computing equipment, such as mining machine (a computer specially used for mining), must complete a difficult puzzle before creating a block for bookkeeping. Whoever completes the puzzle first will get the bookkeeping right and remuneration. Everyone will add the block generated by him to the previous account book as the latest transaction record. Of course, the new block must meet some basic rules, For example, it does not conflict with the previous ledger and does not record transactions with incorrect authorization (this is guaranteed by the user address and private key authorization mentioned above).

  what kind of puzzle is this? There is a very vivid metaphor: when rolling dice, whoever rolls the combination of qualified dice first will win. Taking two dice as an example, the probability that the sum of two dice is no more than 6 is 41.6%, which is easy. It is satisfied once after an average of two to three times. Increase the difficulty. If the sum of the three dice is no more than 4, the probability is only 1.8%, that is, if you roll the dice more than 50 times on average, you can have one chance to meet the conditions. It takes some time to roll the dice. However, considering that many computers are rolling dice, and the speed is very fast, ordinary mining machines can easily roll tens of billions of times a second, we continue to increase the difficulty by increasing the number of dice and reducing the sum of the number of dice. Until all computers participating in dice all over the world play together, we can roll a combination that meets the requirements every ten minutes on average. What kind of combination is this big date: the sum of 100 million dice is no more than 100 million tens. Think about the probability of rolling 100 million dice, almost every one is 1.

  every mining machine competes to keep accounts first. Whoever works out the puzzle first will get the right to keep accounts and get remuneration. Even if a mining machine wants to make false accounts, it must do so. At the same time, due to the blockchain structure, if anyone wants to modify the transaction record of one of the blocks, it must re create the block and all the blocks that have been created in the future, and it takes a lot of time to solve the puzzle every time a block is created. The bitcoin encryption authorization mechanism mentioned above can ensure that the user can modify the transaction records transferred out of his account at most. For the money of a transaction, he needs to forge multiple blocks by himself. Since the correct blocks already exist before, the forged blocks are likely not to be recognized, resulting in the loss of mining revenue. Even if some Bookkeepers who are willing to do business at the expense of others and not for themselves can quickly generate blocks to modify the account book with their advanced computing equipment, it can not compete with the whole blockchain network, because the correct blockchain is growing, and the blockchain network always takes the longest blockchain as the correct account book. As long as 51% of bookkeepers (assuming that each bookkeeper has the same computing equipment) feel that mining is more reliable than robbing banks, the blockchain network can operate normally. For example, after Zhang San transferred the money to Li Si, he tried to modify the account book and transfer the money to himself:

Figure 2 forged blockchain

   the blocks of CDE in the figure are calculated by many bookkeepers, and c'd 'can only be calculated by the Zhang Sany family. His calculation speed can hardly catch up with the block generation speed of the whole network, and the blocks generated by him will not generate any revenue because they are not recognized by the whole network. In fact, Li Si's confirmation of the transfer is not confirmed immediately after block C is generated, but only after the formation of the following five blocks such as C, D and E (the larger the transaction amount, the more blocks are often waiting), which will further increase the difficulty of Zhang San's forgery of blocks.

3、 Data algorithm involved

   we went further and left at least these three questions:

   1. How does the user's transaction authorization proceed? Why doesn't a central organization be needed for password verification?

   2. Why is it necessary to modify all blocks behind a block when modifying a block? How?

  3. How did the puzzle of dice come true?

  before solving these problems, let's review some basic algorithms. There are two main types of algorithms involved in bitcoin / blockchain: 1. Hash algorithm 2. Asymmetric encryption. Readers who do not know much about these two types of algorithms can read the author's previous article "three basic algorithms constituting the information security technology system". Here we briefly list:

Hash or data digest:

byte[] hash(byte[] data);// In order to be consistent with bitcoin development documents, hash is used instead of digest

Asymmetric encryption:

Class keypair / / key pair {byte [] privatekey / / private key

Byte [] publickey; / / public key}; KeyPair generateKeyPair();// Used to generate a key pair byte [] asyencrypt (byte [] plaindata, byte [] publickey)// Encrypt data with private key byte [] asydecrypt (byte [] C)
Previous article Bitcoin mining pool registration website
Next article Bitcoin Mining With Pig Manure: From Organic Disposal to Digital Currency