Do you think that blockchain looks like the 200 yuan I borrowed from you?


Do you think that blockchain looks like the 200 yuan I borrowed from you?

In recent days, blockchain has appeared again, and the news media have been reporting a lot, claiming that it may set off a wave in the financial sector. Some even say that mahjong, the product of blockchain, appeared in China a long time ago. So what is the blockchain and what is the relationship between mahjong and blockchain?

The author has also read relevant literature and materials in the past two days. The figure below is a path for me to learn. This article is also a summary based on my own path of understanding blockchain. The length of this article is long. The purpose of writing this article is also to simply introduce blockchain technology to people who don’t know blockchain technology but want to know what blockchain is, because I am also in the aspect of blockchain A little white, if there is a mistake, please leave a message and correct it.

Do you think that blockchain looks like the 200 yuan I borrowed from you?

Blockchain – > bitcoin

First of all, we need to know that blockchain and bitcoin are not the same. If we talk about seniority, blockchain should be the father of bitcoin. Why? Let’s first understand what blockchain is and what it is used for.

What is blockchain? What does blockchain do?

When it comes to blockchain, I believe that many people will think of terms like decentralization, distribution, and non tamperability. To be honest, I was confused at the beginning when I saw these nouns due to the lack of posture level. The article “current situation and Prospect of blockchain technology development” gives the following definitions:

In a narrow sense, blockchain is a kind of decentralized shared ledger that combines data blocks into a specific data structure in a chain way according to the time sequence, and ensures that it can not be tampered with or forged in a cryptography way. It can safely store simple, sequential and verifiable data in the system.

Generalized blockchain technology is a new decentralized infrastructure and distributed computing paradigm, which uses encrypted block structure to verify and store data, uses distributed node consensus algorithm to generate and update data, and uses automated script code (smart contract) to program and operate data.

After all, the above words are too academic. In a word, blockchain is a kind ofdata structure(stack and queue are also data structures). Since they are data structures, the role of blockchain is self-evident:Organize and store data。 Some of the remaining attributes, such as “decentralization” and “distribution”, are nothing more than modifications to this data structure.Bitcoin is a digital currency made with this technology.

Block + Chain = blockchain?

Since it is a data structure like stack, we must know what the data structure looks like. We split the blockchain into“Block”and“Chain”You will understand what blockchain looks like.


Do you think that blockchain looks like the 200 yuan I borrowed from you?

The image above is aBlockSchematic diagram, each block consists of two parts:

  • Block header: record the characteristic value of the current block (we will talk about the contents stored in it later)
  • Block body: stored data

Therefore, a block is a kind of storage of data, which can be approximately understood as a node in a linked list.


Connect many blocks like the above figure together to form a blockchain, as shown in the following figure:

Do you think that blockchain looks like the 200 yuan I borrowed from you?

To form a chain, there must be a head. The block scientific name of the head of the chain isGenesis block。 The former block is called the parent block of the latter block, otherwise it is called the child block. So, in fact, the blockchain is as long as it is above, so there is no mystery.

At this time, I’m sure someone will ask, do you think they can connect by connecting blocks together? How do they connect?

How to link

Here, I don’t want to sell. The child block and the parent block pass through the parent blockHash (hash)Value to establish the link. Here we introduce a new concept, what is hash?

The so-called “hash” is that the computer can calculate a characteristic value of the same length for any content. The hash length of the blockchain is 256 bits, that is to say, no matter what the original content is, a 256 bit binary number will be calculated finally. And it’s guaranteed,As long as the original content is different, the corresponding hash must be different.So we can get two corollaries:

  • Corollary 1: the hash of each block is different. You can use the hashUnique identificationBlock.
  • Corollary 2: if the contents of a block change, its hashCertainWill change.

So we only need to store the hash value of the last block in the block head of each block. This is where the red line is shown below.

Do you think that blockchain looks like the 200 yuan I borrowed from you?

As for how to calculate the hash value, different blockchains have different calculation methods, which is not discussed here.

This article introduces how bitcoin calculates block hash. If you are interested, please read it. A kind of…

Why blockchain?

After reading the above content, I believe you should understand what blockchain is. But surely someone will say, in the final analysis, this is not a chain list. Why should the country vigorously develop the blockchain industry, or even rise to the strategic level?

It is true that the technical principle of blockchain is not complicated, but it’s not complicatedsocial meaningBut it’s huge.

Block chainessenceAbove is a kind ofSolve trust problem and reduce trust costIts purpose is toDe centralization

Well, here’s a new concept,De centralization? As soon as the term blockchain is mentioned, it will be mentioned, so you must want to know what decentralization is. Don’t worry. Before we talk about decentralization, let’s talk about another word——trust


Wikipedia defines the word trust as follows:

Do you think that blockchain looks like the 200 yuan I borrowed from you?

Maybe you still can’t understand it. Let’s take another common example:

Nearsighted people usually need an operation to remove their glasses, but you don’t know if they can recover their vision after the operation, so you go toexpert, this expert is a very famous ophthalmologist in the country. He told you that after the operation, your vision can be restored, so you went to the operation.

In another case, you asked the person who had the surgery beforeRelatives and friendsThey all said that after the operation, they can return to normal vision. You think they have all succeeded, so you went to the operation.

But if oneA doctor in a small clinicTell you, our clinic can also help you with this operation, and it can also help you recover your eyesight after it is done. Would you believe it? I think you may have to think about it.

This is the power of trust. You don’t trust an individual who doesn’t have enough credit, but you doA pile of individualsOr there areIndividual with sufficient credit

In the field of finance, what we usually have access toThe bank is an individual with enough credit

De centralization

Think about the example above. Why do we believe in ophthalmologists rather than doctors in small clinics? Because ophthalmologists have more credit costs than doctors in small clinics, we often pay more for ophthalmologists.

For the bank, as a credit intermediary, it also needs cost, and our ordinary people will pay for this huge credit cost. That’s why finance is the most profitable industry.

So if you want to remove the credit endorsement of central institutions such as banks? Then we can use what we mentioned above“A bunch of individuals”, which is also the core of blockchain Technology——De centralization

To use a very brainwashing slogan to describe decentralization is:No middlemen earn the difference

How to realize Decentralization — Distributed ledger

Let’s build a decentralized system first. For the convenience of understanding, let’s take a look at a simple decentralized lending model: if a borrows B 100 yuan, then a shouts in the crowd, “I’m a, I lent B 100 yuan!” B also shouted in the crowd, “I’m b, a lent me 100 yuan!” At this time, passers-by a, B, C and d heard the news, so everyone silently wrote down “a lent B100 yuan” in their hearts. You see, at this time, a decentralized system has been established. In this system, there is no need for banks, loan agreements and receipts. Strictly speaking, there is no need for a long-term trust relationship between people (for example, B suddenly said, “I don’t owe a money!”) At this time, the people will stand up and say, “no, my little book records that you borrowed A100 yuan one day!”).

Do you think that blockchain looks like the 200 yuan I borrowed from you?

In the above example, each of a Jun, B Jun and passer-by a, B, and B Bing Ding has a record of a lending 100 yuan to B. those small books are in the decentralized systemDistributed ledger

What if there are many transactions? Very simple, then add a record to the small book.

As time goes by, there will be a lot of transaction records on this small book. Do you think of anything? Yes, blockchain, aRecordIt’s just one.blockThis little book is aBlock chain。 You can understand why blockchain refers to distributed ledger.

How to operate blockchain?

As mentioned above, bitcoin is a digital currency made by using blockchain technology. Here, let’s take bitcoin transaction as an example to see how blockchain is operated. Before introducing the process, let’s first understand a concept:Node / miner

What is a node? In the previous example, passer-by a, B, C, D has a small account book for bookkeeping, each of which is anodeNicknameMiner

Operation process

1. mining

What is mining? The process of forming a block is the so-calledmining

2. broadcast

If we want to add a new transaction (that is, add a new block in the blockchain), we need to broadcast it to the whole blockchain network so that all nodes recognize this record. So how to realize broadcasting?

Broadcast mechanism of blockchain

The following figure shows a process of blockchain broadcast mechanism:

  1. Node a receives a block, validates it and broadcasts it to the block nearby;
  2. Node B receivedinvAfter the message, if he has not received the block before, send a message to node agetdataNews;
  3. Node a receivedgetdataAfter the message, the specific information of the block and the communication record will be sent to node B.
  4. At this time, node B also receives a block and repeats operations 1, 2 and 3 to the block nearby.

Do you think that blockchain looks like the 200 yuan I borrowed from you?

3. record

Once node a adds a record and broadcasts it to the network, other nodes in the network, such as B, C, D, will add the record in their own small book. Once recorded, it is irrevocable and cannot be destroyed at will. Why can’t it be modified?

Blockchain cannot be modified

This leads to the characteristics of a blockchain——Non modifiable。 The reason why we didn’t introduce this feature in the previous introduction of blockchain is to combine the above examples. Imagine that if someone wants to modify one of the records, they have to first modify this record in their own account book and all the records after this record, and then they have to modify others’ account books in the same way. The difficulty is conceivable.

Incentive mechanism of blockchain

In this section, we will introduce the incentive mechanism of the blockchain, because bitcoin is very mature. Here we will take bitcoin as an example.

Why mining?

The whole system seems to be very harmonious, but there is an inevitable problem: “why do you let me keep accounts? Don’t you want money for my little book? “

Taking bitcoin as an example, the miner will package the transactions generated every ten minutes (which is regulated by bitcoin system) into a block. Once the block is generated successfully, the miner will receiveTwo formsThe reward ofBlock rewardandService Charge, the reward process is automatically completed by the program.

Block reward

In order to encourage miners’ services, the system provides miners with 25 bitcoins as rewards for their recorded and confirmed transactions. (the number of awards is halved every 4 years)

Service Charge

Both sides of the transaction are recorded by the blockchain as early as possible in order to provide miners with a transaction fee as an incentive.

Who issues money?

Now that I can receive bitcoin rewards, how did the currency come out? Block bonus is the only way for the system to generate new currency. Bitcoin is generated and circulated through mining, which consumes a lot of power and hardware resources, similar to gold mining. The process of producing money is accompanied by the process of bookkeeping and chunking, which is why the bookkeeping process of bitcoin is called mining. Everyone will strive to generate blocks, because only the fastest people are most likely to get the power to produce this block, and also get economic incentives.

Who can receive rewards?

Now that we know that the purpose of mining is to obtain rewards and where the rewards come from, there will be new problems. Where are the rewards?

Because there is no center to allocate rewards, and every miner will add a new block, how to give rewards? Is it hard for everyone to have a share? The answer, of course, isno!

There is only one reward. If you want to determine the reward object (that is, the ownership of bookkeeping rights), you need to involve another concept in the blockchain——Consensus mechanism

Consensus mechanism

Consensus mechanism is the core secret of blockchain network. In short, the consensus mechanism is a mechanism for blockchain nodes to reach a consensus on blockchain information across the network, which can ensure that the latest blocks are accurately added to the blockchain, the blockchain information stored by the nodes is consistent and undivided, and even can resist malicious attacks. In practice, to achieve such an effect, two conditions need to be met: one is to select a unique node to generate a block; the other is to make the distributed data record irreversible.

Do you think that blockchain looks like the 200 yuan I borrowed from you?

The above figure shows the current mainstream consensus mechanisms, mainly including: proof of work / pow (proof of work), proof of equity / POS (proof of stake), mix of proof of work and proof of equity (POS + POW), share authorization certificate / dpos (delegated proof of stake), practical Byzantine fault tolerance (pbft), ripple consensus agreement, etc. Bitcoin usesWorkload certification mechanism

POW mechanism

Here is the workflow of pow mechanism:

  1. The node listens to the data records of the whole network, and the data records that pass the basic validity verification will be temporarily stored;
  2. Nodes consume their own computing power to try different random numbers (nonces), perform specified hash calculation, and repeat the process until a reasonable random number is found. This process is also called “mining”;
  3. After finding a reasonable random number, block information (block head + block body) is generated;
  4. Nodes broadcast new blocks to the outside. After other nodes pass the verification, they are connected to the blockchain. The height of the main chain is increased by one, and then all nodes switch to the new block to continue the next round of mining.

Although the workload proof mechanism solves the problem of the ownership of bookkeeping right, the above description is too complex. We can simply understand thatWhoever records fast will get the reward

What about recording as fast?

Because the whole system is distributed, there are many chances of the same speed, so in order to ensure the synchronization between nodes, the adding speed of new blocks cannot be too fast. Imagine that you have just synchronized a block and are going to generate the next block based on it, but at this time, other nodes have new block generation, so you have to give up half of the calculation and synchronize again. Because each block can only be followed by one block, you can always generate the next block after the latest block. So you have no choice but to synchronize as soon as you hear the signal.

Therefore, among the inventors of blockchain, bencong (this is a pseudonym whose real identity is still unknown) deliberately makes it difficult to add new blocks. His design is that every 10 minutes on average, the whole network can generate a new block, six in an hour.

This speed of output is not achieved by order, but byDeliberate settingMassive computing. That is to say, only throughAn extremely large number of calculationsTo get the effective hash of the current block and add the new block to the blockchain. Because of the large amount of calculation, it can’t get up quickly.

If two people upload at the same time, although the probability is very small, if it happens, we will see which one of the last blockchain is longer and which one is shorter will fail. This is the blockchain“Double flower problem”(the same money is spent twice).

What if you want to make a fake?

How to judge whether the transaction is true? What we follow isMinority is subordinate to majorityIn principle, to make a fake transaction, unless you persuade more than 51% of the miners in the whole network to change an account, your tampering will be invalid. The more participants in the network, the lower the possibility of fraud.

This is also the advantage of collective maintenance and supervision, and the forgery cost is maximized. It’s hard to convince 51% of the counterfeits. This is often mentioned51% attack

The brain hole suddenly opens. Isn’t everyone’s memory a blockchain, distributed accounting model. If something happens and more than 51% of people remember to write it in their own mind, it really happens and becomes a memory. On the contrary, if only a few people see this happening, even if it happens, it may be regarded as not happening.

Why did bitcoin succeed? Other Shanzhai coins failed?

In the past few years, the computing power of bitcoin network has increased to a very large scale quietly, which greatly increases the possibility of bitcoin success. On the contrary, it can also explain why Shanzhai coins are not reliable and are too easy to be attacked by 51%. In the field of digital currency which depends on cryptography, it is very obvious that the first mover is excellent. So 51% attack is not a big problem for bitcoin (as early as July 2013, bitcoin’s computing power on the whole network has reached 20 times the sum of the computing power of the top 500 supercomputers in the world). Even if a government gathers the power of the whole country to secretly build a supercomputer to defeat bitcoin to save its currency distribution system, it will find that it can use this ability to mine If we monopolize the issuing right of bitcoin, the profit will be far greater than that of defeating bitcoin, and the motivation will no longer exist.

Is bitcoin limited? What if the release is over?

Bitcoin is aNo inflationThe issue isUpper bound。 According to the system, bitcoin’s block bonus will be halved every four years. By 2140, when the total amount of bitcoin issued reaches 21 million, there will be no block bonus, and the handling fee will be the only form of reward. Many people worry that after the 21 million circulation of bitcoin, the handling fee alone will not be enough to make up for the miners’ mining expenses, which will bring a crisis to bitcoin. Is this really the case in practice?

First of all, the process of the disappearance of block bonus is very slow. Every four years, the number will be halved to 6.75 in 2020, and it will really disappear in 2140 more than 100 years. The community has decades to gradually adapt to this problem, and will not cause a huge network shock at once. Secondly, the holders of bitcoin will also be very motivated to promote bitcoin because they are looking forward to the appreciation of bitcoin, and then they will continue to generate fees and revenue.

An interesting example

In fact, it isminingI have sorted out the process and some problems of bitcoin mining. I saw a very interesting example of bitcoin mining on the Internet before, and I will share it here:

Singles want to find female tickets. My mother-in-law says I have many daughters. Let me give you some questions and solve a micro signal for one of them.

Single Wang people are crazy competition, want to break their heads to solve problems. As long as one of them solves a problem, he immediately proudly announces to the world that he is all single. This girl is mine. Give up. There is no way for other single Wang people to be dissatisfied. It’s not a matter of melancholy and chagrin. Let’s solve the next problem right away. The lucky little Wang, who likes to win, can get 25 money units after being recognized by his mother-in-law. He is a winner in life.

Mahjong and blockchain

After reading so much, you must be tired. Let’s go back to the question at the beginning of the article. What is the relationship between mahjong and blockchain?

<img” rel=”nofollow noreferrer”>…; style=”zoom:50%;” />

Mahjong is a traditional blockchain project in China. He has the following characteristics:

  1. Decentralization. Unlike bullfighting idle family can only win the money of the dealer, mahjong who can Hu card.
  2. Compete in mining. Four miners at a table, the first miners to correctly combine 13 cards will be rewarded.
  3. It cannot be tampered with. If you play the wrong card, you must not repent. Others will not agree.
  4. Open and transparent. It’s all cash transactions on the table, no secret operation.


Finally, we summarize the following core contents of blockchain:

1. Decentralization

This is a disruptive feature of blockchain. There is no central organization or central server. All transactions take place in the client application installed on everyone’s computer or mobile phone.

The realization of point-to-point direct interaction not only saves resources, makes the transaction autonomous and simple, but also eliminates the risk of being controlled by the centralized agent.

2. openness

Blockchain can be understood as a technical solution of public accounting. The system is completely open and transparent,

The account book is open to all and data sharing is realized. Anyone can check the account book.

3. Irrevocability, tamperability and encryption security

The blockchain adopts one-way hash algorithm, and each newly generated block advances strictly according to the time linear order. The irreversibility and irrevocability of time make any attempt to invade and tamper with the data information in the blockchain easy to be traced,

It leads to exclusion by other nodes and high cost of forgery, which can limit relevant illegal acts.

Do you think that blockchain looks like the 200 yuan I borrowed from you?