Getting started with blockchain | Hope the blockchain "talking words" friends, you can understand here

Source: Orange Book

Joining the Orange Book for 7 months and 22 days, I have experienced many stories of magical realism, such as:

From the non-mainstream, even the blockchain is considered to be cx, and overnight, under the double assistance of Xiaozha and gj, it became the headline of the mainstream media.

Every time I go home to give me a mom, let her buy some Bitcoin, and when they start to learn to use the exchange, they will ridicule me.

From An'an's steady compilation of the economics of the certificate or a little bit of technical articles, to the focus on the application of the alliance chain under the call of news broadcast.

Has the blockchain really entered the public eye? I often think that readers or the masses who want to talk about the blockchain will understand the concept under what circumstances.

Related to your own interests (such as investment)? Indeed, before attending many friends and class reunions, everyone will care about asset allocation. "Please give us some good investment advice." So the cryptocurrency is logically introduced, but well, I only cx bitcoin, and first of all, we must know that BTC is not necessarily a sale, his smallest unit is 0.00000001 (one hundred millionth), called a Cong .

(Recommended for the high-tech science https://mp.weixin.qq.com/s/XzAx8PkfLPTHtDaYh5WVVg )

Empathy? I remember an article about the Syrian decentralized revolution that I had previously sent about the story of the northern part of Syria trying to transform into a bitcoin-based economy after the war destroyed the government, causing a lot of forwarding. There are a lot of friends who are not in the circle who run and say, "It’s really endless."

Today, our world has given a third answer… The appeal of this signal looks very strong.

In fact, I am also the majority. From the first day of the Orange Book, it was also a process of learning the blockchain from the Average Consumer. Whether you are studying economics, understanding diversified investments, curious decentralized organizations, or passively responding to higher levels calling for "blockchain spirit," or just want to see what marginalized survival and resistance the world has. ..

Therefore, we plan to organize the articles of the Orange Book in the past year, and present them in a simple way to more friends who want to understand the “blockchain”. So the first one, let everyone know what "bitcoin is."

This article is written for friends who want to understand what Bitcoin is, but can't read the white paper. This is not a cool text, but it is not difficult to understand. It is enough to have a junior high school mathematics foundation. After spending 10 minutes reading, you will have your own answers to many questions, such as:

"What is the use of Bitcoin?"

“Is the blockchain a bubble?”

"Would you like to go there?"

(The following is the full text, Enjoy)

What exactly is Bitcoin? 99.99% of people say this question is not clear

This article is written for friends who want to understand what Bitcoin is, but can't read the white paper.

In the past month, there has been a lot of discussion about Bitcoin, but for the most basic question, "What exactly is Bitcoin?" Many people still have no concept. There are some articles that explain the principles of Bitcoin in various metaphors, which I think is not enough. To really understand, you need to understand the core mechanics and mathematical principles of Bitcoin.

Faced with a whole new concept and thing, to answer "why what it is", the answer is usually very embarrassing. Let's change our mind and go around. Imagine what would happen if you were to reinvent Bitcoin step by step from scratch?

Assume that the group of the Westward Journey crosses into modern life, and everyone eats and sings together.

It is too cumbersome to use cash to divide each meal after eating, and the eight rings often forget to bring money. Wukong proposed: In the future, the economic exchanges between the two will be recorded on a book, and the wages will be settled at the end of the month. For example, everyone is drinking together today, and the master pays for it and spent 400. Old rules, AA, the three books are recorded on the books:

Wukong has to pay the master 100 yuan

Ba Jie will pay the master 100 yuan

Satay will pay the master 100 yuan

Tomorrow everyone will pinch their feet together, Shabu pays the bill, and spent 800, also remembered:

Wukong has to pay Shaying 200 yuan

Eight precepts must be paid to Shaying 200 yuan

The master has to pay Sha Fei 200 yuan

By the end of the month, everyone will summarize the records on the books and settle them in cash. If you have two pens this month (this is not possible), the cash settlement is like this:

In order to be fashionable, Wukong made this account a website. All four of them can go to the website to write a note. They are brothers, rest assured. This system rule can be summarized as:

1. Everyone can write a transaction on the ledger

2. Set a cash settlement at the end of the month

The first few months went well. But humanity can't stand the test, and soon the account can't be matched. Goku checked the background and found that the Eight Rings sneaked and wrote several false accounts:

The master has to pay the Bajie 200 yuan

Satay must pay Bajie 300 yuan

Under the cross-examination of the people, the Eight Precepts admit that they are wrong, saying that they have lost too much money in recent purchases and want to make some money back.

In order to cope with possible cheating, Wukong thought of another way, electronic signature.

Handwritten signatures are familiar to everyone. You buy a card by hand. Your signature means that you know and recognize the transaction. You can't deny it, and others can't fake your handwriting. This ensures that the deal is true. .

The electronic signature is different. In theory, an electronic signature is a string of 0 and 1 characters. The computer can be copied directly, and others can copy your signature.

How to do it? Cryptography gives a clever way. We first send each person a pair of passwords, one is for others to see, the public key, one is never for others to see, called the private key.

If you want to sign your name on a transaction, indicating that you approve it, you need to do the following: enter the signature function with the information contained in the transaction and your private key as two variables, and the result is Corresponding to the signature of this transaction, a 256-bit binary number.

This signature cannot be forged because other people don't know your private key, and missing a variable naturally can't produce results.

Don't worry about someone else calculating your private key based on the signature, because this signature function is irreversible.

At the same time, this signature cannot be directly copied and used on other transactions, because once the transaction information changes slightly, the corresponding signature is completely different.

That is to say, the specific private key, transaction information and signature are tightly coupled, and if any one is changed, this combination will be problematic.

Another question is, how can others determine that this signature is indeed the correct signature that you calculated based on the private key and transaction information? Have the public key come out, anyone can verify this: use the information, signature and public key contained in this transaction as three variables, enter the verification function, the result is true, the signature is correct, and vice versa .

In theory, this verification function provides a chance to forge a signature. You can try all kinds of possible combinations, enter them into the verification function, and hit the result to be true, then the signature is correct.

The problem is that this is a 256-bit binary number signature. The possible combination number is 2 to the 256th power, which is about 10 to the 80th power. Almost the atomic number of the universe is an order of magnitude. Try it 10,000 times a second. You can't count on the demise of the universe.

So, if the signature is verified to be true, the person who gave the signature must have been the owner of the transaction (or God himself).

Wukong said that with an electronic signature, it is only effective for the owner of the transaction to sign his own signature for each transaction in the future.

For example, this transaction: Sasha wants to pay the bait to the 1000 yuan. The owner of the transaction is Shaying. Then Sasha takes his own private key to generate a signature for the transaction information and signs it. This transaction is valid. Others can use the public key of Satay to verify that the signature is true. This way no one can cheat.

In addition, in order to urge the eight precepts to change their evil spirits, Wukong also added one. Everyone pays the deposit of 1000 first. After the account balance has dropped to zero, the transaction cannot be continued, that is, it cannot be overdrawn.

The problem was solved. After a few months, everyone found that under the new rules, it is not necessary to settle the cash every month. This account book becomes a small bank. The balance on the ledger is the money of everyone in the bank account. As long as you don't overdraw, you don't need cash, you can trade with each other, and you can rely on bookkeeping to borrow money. It may be worthwhile to call the money on this account book as the West Tourcoin, which is 1 yuan = 1 West Tourcoin.

At this point, you will find that the books have played a role in the currency to some extent. System rules have also evolved into version 2.0:

1. Everyone can record a transaction on the ledger, but it must be signed by the owner to be valid.

2. Can not overdraft

One day, the master suddenly gave Wukong a problem. Now the system is good, but there are hidden dangers. If the person who controls the website where the book is located wants to cheat, who will supervise him? Is it possible for everyone to have a book, remember each other, and then synchronize with each other and supervise each other?

The Eight Precepts questioned, if everyone remembers that the accounts are different, who is the subject?

The people fell into meditation. Everyone can actually save the reliance on a particular center, but if someone cheating, causing inconsistencies in their books, how can the dispute be resolved?

I saw a piece of purple gas coming to the east, and Nakamoto appeared. He dropped an eight-page paper and floated away. Wukong picked up the book, but read the book and wrote:

Who is the most powerful, who speaks and counts.

Wukong was awakened in an instant and began to tell everyone new ways:

Let's start with separate accounts. Every once in a while, we will meet and check the books. How to check it? To play a math game is to find a lucky number corresponding to the ledger. The only way is to guess, whoever is more computationally competent is more likely to guess, and there is a reward in the guess. After guessing, the account book that was checked this time is confirmed. Everyone will take this account book as the standard.

If you check it, you will find that the account book written by Ba Jie has a place different from everyone else. What should I do? It doesn't matter, or play this guessing game. As long as the cheating party has no more than half of the computing power, the party without cheating will win because it has more computing power. In the end, everyone will still be based on the winner of the game, which is the correct account book.

This is roughly the case, what is the specific details? Here, we are ready to go deep into the core idea of ​​Bitcoin. In order to fully understand, we need to introduce a few less common but very useful concepts.

Let's first introduce the key killer: SHA256 algorithm.

SHA256 is a password hash function. Enter any piece of information and run the SHA256 function. The output will be a string of 256-bit binary numbers. This number is the hash value or summary of this information. It can be understood as this. The specific ID of the segment information.

All the information in the world has its own unique hash value, one-to-one correspondence, and never repeat.

Another feature of SHA256 is that there is no way to reverse the operation. The hash value of the information can only be calculated from the information, and the information itself cannot be calculated based on the hash value of the information. If you give a hash value, you want to know the corresponding information, the only way is to try one by one, yes, it is another chance of 2 256th power. Trying to destroy the universe may not be able to try it out.

This big killer is the basis of the math game just mentioned. As long as it is still strong and has not been cracked, bitcoin is mathematically reliable.

Let's take a closer look at how this math game works.

We assume that only ten transactions can be recorded on each page of the ledger. After recording a page, we must find a lucky number at the end of the page. This number must make the hash of all the information on this page (including the number itself). The value satisfies a feature, such as the first 30 bits are 0. This page is valid only if you sign this number.

As a result, due to the characteristics of SHA256, finding this number can only rely on trial and error, and the chance of success is particularly low. One of the 30th power points of 2, that is, it may take a billion times to be successful. Five million in the lottery is a replica of this game, but the odds of five million are good.

Once someone finds this number, other people want to verify that the number is correct, just need to count it again, it is very simple. This is very similar to buying a lottery ticket. If you have won a prize, check it.

This lucky number is called Proof of work , proof of workload. If you can find this particular number, it means that you have invested enough time and power (because there is no other way), and others can easily verify the matter without having to re-calculate it. So why would anyone be willing to invest time, machine and electricity to play this game? Because we have designed a reward mechanism, people who guess this number will receive a certain amount of bitcoin as a reward, and one page will add one, who gets 2 bitcoins.

With this game, people will spontaneously verify that the transactions in the Bitcoin network are valid, and the only way is to invest time and computing power to guess. At first glance, it may not be clever. Is it a waste of so much resources to play digital games? Don't worry, you will find that there is a hole in the sky.

The last thing to introduce is the blockchain, blockchain. How did the word come from? Bitcoin divides the ledger into a number of blocks, each of which records a certain number of transactions, each block being called a block, block. The bottom of each block will be accompanied by the corresponding lucky number, proof of workload. At the same time, at the top of the block, the hash value of the information contained in the previous block is also attached. Then the block is connected into a chain. In fact, the blockchain is a kind of account with a special structure. If you change one of the pages, the whole book will have problems.

Connecting the blocks into a chain is a very delicate design.

First, changing the information of any block will result in a change in the hash value of this block. It will also change the information of the next block (because it is an inclusion relationship), and then all the blocks will change, the whole The blockchain will become invalid, and you have to recalculate it again to find the corresponding POW. This guarantees the rigorous accuracy of the entire book.

Second, the position between different blocks represents the order in which different transactions occur. If the position of the block is changed, the entire chain will become invalid for the same reason. This guarantees the accuracy of the transaction time record.

After the most difficult part is introduced, we can take a rest and review:

A big killer:

The SHA256 algorithm allows us to enter any piece of information and get a corresponding number. This number is the hash of this piece of information, just as unique as a personal ID. Conversely, calculating the corresponding information through the hash value can only be guessed, and it is difficult to guess.

A number game:

For each page book, we can find a lucky number so that the first 30 bits of its hash value are 0. This number is hard to guess, and guessing will get Bitcoin as a reward. It is very similar to buying a lottery ticket.

A subtle structure of design:

The blockchain divides the entire book into a number of blocks. The hash value of the previous block is written to the top of the next block, so that all the blocks are associated into one chain, and the information or position of any block is changed. Affect the entire chain.

After talking about these three things, we can take a closer look at how Bitcoin works.

For ordinary users, when a transaction is completed, the information of the transaction is broadcasted. At the same time, some users will continue to listen to the transaction information in the entire network, package the transaction information into blocks, and quickly guess the lucky number. Once a person guesses this lucky number, he will get a few bitcoins as a reward. This block has also been proven effective and has been broadcast to the entire network again and has been recorded by everyone. These users who constantly guess the numbers are the "miners" we often hear. The process of guessing numbers is called "mining."

Considering what they are doing, it is a bit like the process of digging hard to dig gold. But the real bitcoin miners don't have to go to the ground in person, just use a lot of computers to play this guessing game crazy.

Miners and ordinary users are a node in the Bitcoin network. The difference is that the verification block requires a lot of computational power, so the miners usually have professional equipment such as ASIC or high-end graphics cards. Ordinary users use ordinary computers, so they can't participate in the verification transaction, but it is still possible to broadcast their own transaction information. Miners are more like administrators in this system, and can do more things that ordinary users can't do, such as verifying blocks and getting rewards.

Miners need to listen to the broadcast information of the whole network. Ordinary users only need to listen to the verified blocks broadcast by the miners and synchronize them to the blockchain they have saved. If you hear the inconsistency between the two blocks, who is it to listen to? The method given by Nakamoto is that the computing power is king, which block is more computational, or which block is longer, and whoever listens.

Why is this effective? We went around again to solve this problem from the opposite side. Think about it, what if you want to cheat in the Bitcoin network? What conditions are needed to achieve this?

Assume that Ba Jie wants to cheat, everyone eats together, the master pays the bill, according to the reason, the bastard should give the master 100 pieces. Other miners have recorded this in the block:

Ba Jie will pay the master 100 yuan

The same miner, the Eight Precepts erased the account in the block, packaged a "different" block, and sent it to the honest Satay after verification.

The news received by Satay began to split on this node. The block that the Eight Rings sent to him formed a separate chain, and the other miners' blocks formed another chain.

So which chain will extend faster? Considering that this is a completely random guessing number process, in the long run, the speed of the two-party chain extension is proportional to the amount of computing power that they have mastered. Perhaps the first few of the Eight Rings can hit the dog, which is faster than others, but over time, it will naturally be outnumbered. The blockchain of other miners will be rapidly extended. Based on the rule of "Whoever listens to the blockchain length," Satay will give up the chain of the Eight Rings and save the chain of other miners to their own district. In the blockchain, the consensus is reached.

In other words, when you receive two different blocks, don't rush to decide who to listen to, let the blockchain fly for a while, wait until one of them leads another block of at least six, basically Studded on the board.

Of course, if Ba Jie himself masters more than half of the world's computing power and becomes a majority, then the system will collapse. However, due to various complicated practical reasons, this condition is difficult to achieve.

This power of bitcoin is the king's mechanism, a bit like voting. When everyone disagrees, they will reach an agreement by voting. The votes are king and the minority is subject to the majority. If you want to cheat, it is not impossible, but you must get a majority of the votes.

Here, the complete body of Bitcoin was born, System Rules version 3.0:

1. Everyone can count and verify as long as they invest in computing power and time

2. When the blockchain splits, keep the chain with great power

The above is the basic operating principle of Bitcoin. From the original cash transactions, to electronic signatures and centralized ledgers, to the more advanced distributed ledger + POW+ blockchain, we have completed the evolution of human currency in just ten minutes. How will the future human monetary and financial system evolve, and how the fate of the son of the bitcoin son, maybe you and I have a vague answer.

A lot of technical details are not mentioned in this article because I want to make the skeleton principle of Bitcoin clear with as short a space as possible. Want to know more friends can see here:

Https://www.bilibili.com/video/av12465079/?t=381

Https://bitcoin.org/bitcoin.pdf

Http://www.michaelnielsen.org/ddi/how-the-bitcoin-protocol-actually-works/

“Human being driven by stories and consensus.” Bitcoin and blockchain perfectly interpret this sentence. If you believe in this story, help me to help you, let more people see this article, believe this story.

Together, we will…