Block chain in the end is what? A story to tell you the principles and operation mechanism Bitcoin

A story to tell you the principles and operation mechanism Bitcoin
recommendation:
"Artificial Intelligence: AI era of French romantic"
"Claustrophobia, non-material objects, AI How can it abounds (AI)" given
"To us youth, a salute. "

Pictures may be lost, it is recommended [sic] read

Weekends to spend time watching some of the information related to Bitcoin principle, although not say to totally get to know every detail, but the main principle and a key part of the whole idea is quite clear. Write an article for everyone to share. Positioning of this article would be more science, try to use the method of analogy will speak out the basic principles of Bitcoin. This article does not involve section compares the details of the algorithms and protocols, the intention behind Bitcoin will write under the principle of a programmer's perspective, there will be from the perspective of technical personnel for Bitcoin system more critical data structures, algorithms and explain some agreement.

In this article I will give a virtual village called "bit-village", the entire article will be storytelling, and gradually tell you motivation Bitcoin proposed to solve the problem of what the goals and design as well as some of the key components .

The questions
we start with motivation Bitcoin generated.

Barter bits village
saying that in this world, there is a village called bit small village, the village a total of hundreds of families. The village almost isolated, living a self-sufficient life. In the absence of large-scale trade, barter bits villagers have been living a life, that is to say between the villagers did not use the common currency, trade between each other is basically old Zhang take home a bag of flour swap talk of the town a sheep, Wang sister take a basket of berries change Liu Aunt two feet of cloth. It's that simple villagers have been living with.

Physical currency
Finally one day, the villagers feel that has been so barter is too inconvenient, so the village full meeting to discuss how to solve this problem. It was suggested that, in order to split and rare things, such as gold, as a general equivalent, the corresponding relationship between gold and other items compiled a table, for example, one gram of gold corresponding to a sheep, a gram of gold corresponding to a sack of flour and so on At this time Zhang no longer carrying a sack of flour breathless talk of the town home to change the sheep, and he just took out one gram of gold from the house, you can go back to pull a sheep hear his home, and took the talk of the town one gram of gold can exchange for a sack of flour from anyone willing to sell flour, of course, you can exchange any and one gram of gold equivalent items.

At this village bit physical currency into the era.

Symbol currency
did not last long, over a period of time, the drawbacks of physical currency also appeared. Because gold is not much near the village of bits, mining and smelting of gold is too time-consuming and laborious. With the use of gold constantly because of wear, loss, or someone deliberately hoarding and losses occur. The village people once again sit together and began to discuss countermeasures. At this time, it was said, in fact, we do not have to really gold ah, casually looking piece of paper, write "one gram of gold", as long as the village people agree that this piece of paper is equivalent to one gram of gold, the problem is not solved . Other people have said that identity, but it also has a new problem: the real gold is need mining and smelting of gold is limited, the cost of mining and smelting need, so no one can make a lot of short-term gold out of thin air, you can write different , as long as I have enough paper pen enough, just like how much to write how to write, that it becomes more than a paper at home who fight when they might or ten thousand sheets of paper can change a sheep (which actually happened economy Studies on inflation).

I believe it is ah. But this time it was suggested a solution: who wrote this paper is not valid, we only recognize the village respected the old village written, we all know the old village of words. Old village some paper to write, while the same amount of paper distributed to you in accordance with various gold stocks, such as old Zhang two hundred grams of gold, the old village for the issue of two hundred Zhang says "one gram of gold," the paper, while the old Zhang took gold as collateral. In this way, the old village to village all the gold reverted to their homes, according to the number of gold sent to various handed in written equivalent of paper-word. At this time, the villagers can hold the paper when the gold trade, but we all know the old village of character, others forged out. In addition, if the paper who wear too serious, but also to get the old village where the exchange of new equivalent paper, in addition to the old village promised anyone who really wants to replace the gold, just take the paper back on the old village gold will return the equivalent of the man. Because the old village written paper and the real amount of gold on the amount of gold at home is the same, so long as strict accordance with the number of paper how much destruction a new paper written principles, each a valid paper can always exchange for the corresponding real gold .

In this case, the sign bit into the village of currency (paper money) era. The old village assumed the role of the government and banks.

Central system virtual currency
after a few years, the old village due to the large number of old banknotes to be checked every day, write a new bill, but also to various accounts carefully make a record. One to two to go, the old village overwork, unfortunately, riding a crane to the West.

Bits village general meeting again to discuss how to proceed. At this point the old village two Gouzi son volunteered to take over his father's pen, take responsibility currencies. The young mayor two Gouzi very smart, he made a few days and found it seems they do not really write so much paper. Can this: The villagers have to pay the bill up, destroyed, but two Gouzi will record the number of bills per household turned over under. If you later want to pay, such as Zhang bring one gram gold commutation talk of the town a sheep, it will be given two Gouzi call together, indicating that one gram of gold you want to hear his name under the name Zhang , two Gouzi out the books to see if there is one gram of gold under the name of Zhang, if you lose one gram in the name of Zhang, the talk of the town in the name plus one gram, thus completing the payment, this time on the phone to hear the talk of the town two Gouzi confirm the transfer is complete, you can rest assured that Zhang pulled by the sheep.

At this village bits into the central system virtual currency era. Each villager is not required to pay in kind, payment process into digital books on the side of maintaining two Gouzi changes.

Distributed virtual currency
this newly appointed two Gouzi is clever, but sometimes this man is clever wisdom wrong. One day two Gouzi stared at the books, I thought this village households who count how much money is what I said, that I not ....... So he a hot head, without permission from the charge of Zhang drew ten grams of gold to their own name.

I thought perfect, but Zhang did not expect to have the habit of accounting, one day he was going to pay but was told that two Gouzi account money. Zhang checked your own books, obviously there are ten grams ah, then took the books to find two Gouzi theory, this check found that Zhang pen without the consent of the transfers.

Unmasked! Bits village exploded pot. Two Gouzi impeachment was inevitable, but through it, we found books concentrated in the hands of a person's drawbacks:

The system is completely dependent on the books holders of personal credit, if this person does not follow the rules, tampering with the books, then the whole monetary system will collapse
if the person home fire or theft of books, will also devastating for the entire system blow
just when people know what to do, otaku scientists village called Satoshi took to the stage, to tell you he has designed a virtual currency called Bitcoin system does not rely on any of a central processing person, you can solve the problem . Then he slowly tells the story of their own programs.

Here we look at how fancy design students to Nakamoto this system.

Infrastructure build
books disclosure mechanism
Nakamoto First, to the following modifications to existing books:

All the villagers are no longer recorded on the balance books, but only records each transaction. That record payer, payee and payment amount for each transaction. As long as the initial state of the books is determined, each transaction record and have reliable timing, how much money is currently holding everyone can figure out.
Books by the public instead of private, as long as the villagers need any, you can get the current complete books, records created from the start to the current books of all transactions on the books.
His remark, immediately following the fryer. Article also does not matter, but the second is simply unacceptable, because the record books but all the villagers of transactions, so everyone's privacy incomplete exposure yet.

Nakamoto'd hurry, he took out a pair of strange things.

Identity and signature mechanisms (public key encryption system)
Nakamoto said, we do not panic. In his set of mechanisms that no one use the true identity of the transaction, but the use of a unique transaction code.

He showed the hands of the magical things that these two things are called confidential stamp and seal scanner. Later he will give every household in the village sent a confidential stamp and a stamp scanner. Role of the two as follows:

Confidential stamp on paper can cover a chapter, each chapter covers the seal of the village have implied a unique string of characters, but with the naked eye can not see out of. It can not be produced by the corresponding seal observation.
The scanner can scan a stamp already covered in chapters read implicit information and display a string of characters on the LCD screen.
With these two magical things, it can be traded in the case not to expose the true identity of, and implied that the seal is a string of characters that house code. Specifically, how clever use of privacy seals and seal scanner transactions, will be described in more detail below.

Miners set up a virtual organization (mining group)
Next, Nakamoto Recruitment virtual village for the miners, recruitment requirements are as follows:

Miners group as a unit, a group can be a separate one, may also be a few households jointly for a group
to be miners do not affect the normal use of the money
the miners to spend some time each day in Bitcoin "mining" activities, but different from the dig gold, miners do not need to hold virtual tools to field work, at home, to complete the work
of miners have a possibility to get paid, pay more in mining activities in efforts to obtain greater rewards possibility
miners can quit at any time you can also add to the mix at any time new miners
soon, the villagers Jiarubite about one-fifth of the money the miners organization, became divided into seven groups.

Establishing the initial books (Genesis block)
below, Nakamoto announced, based on the first book in the hands of two Gouzi, all gold refundable mortgage balance books and records to each villager, then the total elimination of this book.

Then, Nakamoto come up with a new book, a record number of transactions recorded on the first page of the book, specifically, the payer of these records are all column "system", and the recipient are each implicit stamp corresponding character, represents the initial moment, the system defaults for each household is allocated a certain number of Bitcoin, but very few in number, they have only fired several, and even some unfortunate village households did not get bitcoins.

Then Nakamoto said that due to the current market Bitcoin very little we can do to return to the era of monetary gold, because I am not the mayor, I have no right to force everyone must admit Bitcoin, you can decide to Do not accept bitcoin. But with the flow of Bitcoin miners and activities, Bitcoin will slowly increased recently.

Payment and transaction
done so much foreshadowing, and finally have a point, said the following about under such a system, how to complete the payment. Zhang paid to hear his credits Example 10 bits.

Single payer signed a deal
to pay 10 Bitcoin, we must first ask Lao Li Zhang identification string, eg "ABCDEFG", while Zhang also has an identification string, for example, "HIJKLMN", Zhang then write a list, says "HILKLMN pay 10 Bitcoin to ABCDEFG", and then use their own secret stamp change a chapter, this list will be handed over to talk of the town. In addition, to facilitate the source of the money retroactively, even in a single note in the house indicate the source of the money which page, such as this one-yard, 10-bit currency from Zhang presented the establishment of the system of books, record books The first page.

The payee to confirm the signing of the documents people
talk of the town after to get this list, need to make sure this list is indeed from "HIJKLMN" This man (ie Zhang) signed, this is not difficult. Because there must be secret chapter on the list, talk of the town seal to come up with a scanner, sweep chapter, if the LCD screen shows the character and the character payer is the same (here "HIJKLMN"), we can confirm that the list is indeed payer signed. This is because under confidential seal mechanism, no one else can be forged seal, as long as anyone scan the stamp, you can confirm the list of payers and stamp are the same person.

Confirm payee payer balance
the system so far it is still very problematic. By secrecy stamp, although the payee payer can confirm that indeed signed the list, but are themselves unable to confirm whether the payer has sufficient funds to pay. Before the central virtual currency system, two Gouzi responsible for checking the balance of the payer and payee is notified that the transaction is valid, and now the two Gouzi opened, who is responsible for billing and confirm the validity of each transaction it?

I said before, Nakamoto design of this system is distributed monetary system does not rely on any central character, so there will be one or a few people in charge of this matter, ultimately assume the job of miners mentioned earlier organization. Zhang villagers talk of the town and village use any other Bitcoin transactions are dependent on the work of the miners of the organization to complete the transaction.

Work miners
miners work is the core of the system is the most complex of the highest place. The following work gradually introduce the content and purpose of miners.

Miners tool
As the saying goes, we must first of its profits. Bitcoin miners, though not iron stick, shovels and other tools searchlight, but also there are some essential things.

The initial books. First, each group its own copy of the original books, only an initial books, recorded the first gift of the system

Empty paper books. Each group has a number of books and paper, books, only the structure of each sheet of paper, without filling the content, the specific content of the writing rules about later. The following books are like a blank paper, the meaning behind each field will talk

Code generator (hash function). Nakamoto ED miner tissue distribution of each group a number of code generator, this thing is amazing, the content of a book completed book paper in the machine, the machine paper books "of the present bill number" in a automatically print column number from "0" and "1" is composed of a series, a total of 256. The most amazing is that number generator has the following functions:

Generated number and content of the books on paper only fill about, people have nothing to do with fill, font, fill in the time and other factors
the same content of the books of paper generated number is always the same, but if the content even if only to change a character, number will unrecognizable
code generator will need to fill in all the paper books in print transactions into a single coding Shihai, the machine will scan a single transaction and fill in the consistency of a single transaction, especially the seal of confidentiality, privacy seal and if found inconsistent payer, will refuse to print coding
the books printed piece of paper into the machine will determine whether the number is valid machine print, and determine whether the number and content of the agreement, this number can not forge
a single transaction inbox. Each team needs to miners hung on the door a box for collecting a single transaction. Bulletin Board. Each group of miners also need some information about a public bulletin board.

With the above tools, miners organizations can start up!

Collect a single transaction
Nakamoto provisions, the promoters of each transaction, we want not only to a single transaction to the payee, would also have to copy exactly the same number of copies of a single transaction delivered to your inbox every miner group.

People miners team on a regular basis to a single transaction to their inbox collected and taken out.

Fill in the books
at this time a group of people come up empty paper books, to complete these transactions to "deal list" column, while the last page to find current books will be copied to the last page number "on a bill number Column". Note that there is a "lucky numbers", can easily fill a number, such as 12345. Then, this paper books into the number generator, a good number print, a book is complete.

If you think the miners work as simple as that, it would be wrong, Nakamoto has a metamorphosis of provisions: the first 10 numbers are only the number 0, this paper page book to be valid.

According to the description of the previous number generator, to modify the number, you can only modify the contents of books and papers, and "trading inventory" and "on a number of paper books" could not be changed, it can only change the lucky numbers. So in order to generate a valid paper books, small groups of miners continue copying paper books, but each sheet lucky numbers are different, then keep repeating the paper into the encoder, if the resulting number is not compliant, this piece of paper even waste, and repeat the process until a string of valid numbers.

We know that if every number is a random number, then write an average of more than 1,000 sheets of paper of different lucky numbers to get a valid number.

This is strange, why these miners driving through this seemingly meaningless things? Remember before said miners have paid it, this is the power of the miners. Nakamoto provisions: a list of transactions for each of the first books of paper transactions "system to that group to pay 50 Bitcoin." That is, if you generate a meaningful books and paper, and mining group accepted by all, then it means that this transaction is also accepted, your team won 50 mining bitcoins.

This is called the miners miners reason why also said before with the miners and trading activities, the number of Bitcoin will continue to increase. The following example is a mining process, this group accounts for the common currency bits "UVWXYZ".

When the lucky numbers to try to "533", the system generates an effective books.

Confirm the books
when a mining team lucky generate a meaningful books, in order to be rewarded, must immediately ask other groups to confirm their work. As mentioned above, currently seven mining village group, the group must be active so paper books full speed transcriptions to 6 parts other six groups request acknowledgment.

Nakamoto provides that when a team sent to the other group of paper books, you must immediately stop mining work of the hands of the books were confirmed.

Information needed to confirm there are three:

No valid books of
previous books books of effective
transaction list effective
first look at the first one, this confirmation is relatively simple. As long as the fed paper into books authenticate code generator, if the verification is passed, the number is valid.

The second part of the book needs to be effective "Previous book paper number" and the group is currently on the books pages saved the last page number comparison, if the same is confirmed, if different, the books need to follow the existing alignment forward until you find the number of pages. If the "Previous book paper number" corresponds to the specified page is not found, the team will lose this page. Not recognized.

Note that, from the above mechanism to ensure that if the hands of paper books each group is the same, then they can be bound in the same order the same books. Because the piece of paper behind the numbers is always dependent on number in front of the paper, mechanisms code generator ensures that all relative legal order books of paper in each group there are the same (there may be a branch, but will not appear ring, go into detail later).

How to confirm the final list of transactions is effective, in fact, is the current payer to confirm each transaction has sufficient funds to pay the money. Since the transaction contains information on how the money is to come, the bill also contains a number of transactions recorded source. For example, HIJKLMN give ABCDEFG10 bits coins, and indicate this 10 deal OPQRST paid to HIJKLMN before Bitcoin from before the first to confirm the existence of the deal is confirmed, before HIJKLMN Also check there is no money to pay these 10 bits to others. After all this confirmed the validity of the deal was confirmed.

The first pen is the reward system to generate a 50 page book of this team, the deal we all recognize the default, as long as traceability back as described above, it is possible to confirm whether or not the current HIJKLMN really have to pay 10 Bitcoin ABCDEFG.

If all the above validation and all through, the group endorsed the above books on paper is valid, then this book will be incorporated into the main paper books group, abandon ongoing work behind the mining work will be based on this Lord of the updated books.

Books acknowledgment feedback
for the mining group, when the books of paper sent out, if followed by other groups received books sent paper, the "number of paper books Previous" for their books before sending out the paper, then He said their work has been recognized success other teams, because there are already teams based on their paper books continue to work. At this point, we can roughly say can be considered've got 50 bitcoins.

In addition, a group of any valid when a new generation of paper books or paper books confirm the other team, it will be the latest to be written to recognize this group of trading on the bulletin board, so long as the recipient find the relevant transaction is recognized each group of , basically you can think the money has come to his own account, he will be back at the time of payment of the source of the money point to the deal.

The above is the entire bitcoin payment system. Let's analyze, as well as the risk of why this system can continue to work this system may face.

Work Mechanism
While the above describes the basic operating rules of Bitcoin, but the villagers still have a lot of questions. So Nakamoto students opened a special Q & A will, answers to frequently asked questions. The following summarize the issues most concentrated villagers concerned.

Q & A core issue
if both received two legal books page how to do?
Note that in the above operating mechanism, each mining team is working in parallel, thus completely such a situation may arise: a group received two different books page, which are based on the books of the last page of the main current of this group , and the contents are also perfectly legitimate, how do?

On this issue, Nakamoto said the students, the group should not be organized in a linear fashion books, and books should be organized in a tree, any time, all the current longest branch as the main books, but retain other branches. For example, a group also received A, B on page two books, the accounting are legitimate, then the two teams should be organized in the form of bifurcated up, as shown below:

Black represents the current books trunk. In this case, as the current page jump to a main branch, for example, Option A:

At this point if there is a new page book is based on A, then the trunk will continue:

If this has been such a backbone to continue, we basically represent the backbone of the A, B will be forgotten. But there may suddenly become longer B:

Then we need to branch B as the current trunk to follow up on this branch.

From the local point of view, although the trunk in the books of each team at some point there may be inconsistencies, but the general direction is the same, that sometimes due to the small branch of sync generated, will soon be submerged in history.

If someone forges mining group how to do books
on the subject, Nakamoto said the students, as long as the mining organization most people are honest, this system is reliable and specific in several aspects reply.

First, based on confidential seal mechanism, no one can forge another person's identity to make a payment, because the code generator when printing single coding will check all transactions confidential seal of the payer and inconsistencies would refuse to print.

And honest miners will not admit illegal transaction (such as a transaction payer balance is not enough).

So there is only one possible attacks, that is, after the payee to confirm payment, establish additional single transaction from another branch, before payment of the cancellation, and will pay the same amount of money again to another person (the so-called double-spending problem). Likewise with the following example illustrates this problem.

Assume that the attacker has a 10-bit coin, he was ready to pay the money at the same time two of the victims A and B, and have been recognized.

The first step, the attacker ready to buy gold coins of 10 bits from the hands of the victim A, he signed a deal to single-victim A, turn 10 bits currency to the victim A.

The second step, the deal is confirmed in the latest books page, and each mining group notice it. A victim saw the announcement, confirmed Bitcoin arrival, gave the gold coins attacker 10-bit equivalent.

The third step, the attacker find books, make a branch from a transaction that contains just the front page of a book, generate more page bill, more than just a branch. Since this time the branch attacker made just become the backbone of the branch, and the branch that contains A victim get the money into the offshoot, and therefore no longer recognized mining organization just transfer the victims to get 10-bit A currency is canceled a.

The fourth step, the attacker can sign a single transaction again, you will pay the same amount of money to the victim B. B confirms the money credited into account after the victim, the attacker paid to the equivalent of gold.

At this point, the attacker will be 10-bit money spent twice, from two of the victims where each bought the equivalent of gold. An attacker could also do the same, to cancel the transfer of the victim B, the same money to pay someone else ......

About this attack, the solution Nakamoto is given, it is recommended not immediately confirm the payee hang out at the time of completion of the transaction announcement, but should look for some time, waiting for each mining group and then hang out six books confirmation and previous books have not been canceled, only to confirm that the money has been credited into account.

Nakamoto explained the rules before setting metamorphosis of the number, it is to defend it. Based on the foregoing, to generate a valid page book is not so simple, it takes a lot of manpower repeatedly test different lucky numbers, and the process is completely luck. If a page contains books confirm you received the money, and later in turn, perpetuate 6, the attacker wanted in the case behind six of the current main branch is very difficult to catch up from another branch, unless the attacker has a lot of manpower, more than all the other honest human miners sum.

Moreover, if the attacker has so much manpower, instead of spending so much effort to engage in such an attack, not as good citizens to do the big mining to return. This put an end to form an attack from the motivation.

Bitcoin will always increase it, would not cause serious inflation
Nakamoto said that I thought of. Forgot to say earlier, I gave rules for the operation manual will explain the organization of miners, first we generate a per protocol books, reward team 50 Bitcoin, behind, every increase of 21,000 pages of books, awards will be halved, for example, when after 210,000 pages per book to generate a bitcoin reward 25, after 420,000 pages, each generating an award 12.5, and so on, and so on books reached 6,930,000 page, a new page is generated books there is no reward. At this point Bitcoin is about 21,000,000 a whole, which is the total amount of Bitcoin, so it will not increase indefinitely go on.

After no reward, no one miner, would not be no one to help confirm the deal
to the miners earnings will be changed from the resulting mining charges. For example, you can specify at the time of transfer group to pay 1% of the fee to generate the books pages, each team will choose a high priority single transaction fee to confirm.

If more miners, bit it will be faster to generate credits
not. Nakamoto explained, can be arbitrarily join and leave the organization miners, lead to changes in the number of miners, each miner will get a code generator, but I have joined the regulatory mechanism in the code generator, the current work of the code generator the more, the lower the efficiency of each machine to ensure that new books page generation rate unchanged.

Although each person's code is anonymous, but if someone leaked the code name, and the books are open, is it all of his accounts are checked out
it is indeed the case. For example, you want to deal with someone is bound to go to his code name to fill in a single transaction. Because payable to that person to fill in the code. But Nakamoto says can provide unlimited secrecy stamp, the proposed transaction each time with a different security seal, so check books to track down all of the accounts not the same person.

Q & A is completed.

Description
In this paper, the popular metaphor of the way to explain the operating mechanism of Bitcoin. There are several points should be noted:

For ease of understanding, I do a lot of simplification, so some details and the actual mechanisms of Bitcoin may not be identical. But the general idea and the key principle is the same.
Because many computer world things (such as public-key system, network transmission) in the real world and not particularly good for other things, so the story inevitably there are some blunt and irrational details.
This article describes the technical principles and operational mechanisms Bitcoin network itself, when Bitcoin transactions such as Mtgox trading market, middle market agents do not comply with the above mechanism
reference
Bitcoin: A Peer-to-Peer Cash System Electronic
https://bitcoin.it 
Bitcoin understand the working mechanism of the Detailed

|| Disclaimer: This article is a blogger Du Jinyang original articles, please indicate the source.


python2048 micro-channel public number

Author: Altman Superman Dujinyang

Source: CSDN

Original: dujinyang.blog.csdn.net/

Disclaimer: This article is a blogger Du Jinyang original article, reproduced, please attach Bowen link!

Guess you like

Origin www.cnblogs.com/python2048/p/11757740.html