The reference connections are as follows:
Note: to open the above link, you need to open ACC (a kind of VPN, you know)
Extract the fragments that feel easy to understand, as follows
Popular explanation of blockchain
To understand the blockchain, we must first accept a setting: there is an account book to record the public accounts between a group of people (such as the income and expenditure of class fees, property fees and public welfare donations). This account book is kept by everyone together. Select a person to record the details line by line on a page of the ledger. When a page is full, everyone will check the accounts. If it is correct, everyone will sign and approve all the accounts on this page. When one page is full, choose another person to start remembering the next page. Now something interesting has come. For a new page, first copy down some summary features of the previous page (such as page number, balance, number of people, number of items...) and put them at the top of the page for comparison, so as to avoid that the previous page has been changed or lost and there is no evidence to check. Then, keep accounts one by one. After one page is filled, check, sign and confirm... Repeat in turn. In this way, a "chain of evidence" is formed between one page and another.
More importantly, everyone will copy every page that has been signed and confirmed on the account book and put it in their own home to avoid a few people tampering, defacing and losing the account. In this way, each page of the ledger is a "block". A coherent chain of evidence is formed between each page, and a multi-point network is formed between each person. This is the outline prototype of the "blockchain". The key point here is that this account book must be the account of a group of people, not one person. If it's a person's account, just take a small book and write it down. Why is it so troublesome. It is because this group of people do not fully trust each other, and there may be mistakes in the accounting process, so we must use such cumbersome steps to let everyone participate equally, and work together to ensure the accuracy and fairness of the accounts. The results will never be lost or wrong.
The above example seems cumbersome. It also requires everyone to copy and save word for word, so technical means are needed to help you keep accounts. This goes back to the technical link. With the development of computer technology, technologies such as network, cryptography, data structure and distributed algorithm tend to be mature. The blockchain field combines these technologies to complete the whole process from accounting to distribution, verification to preservation. Using technology to serve the whole group is the magical blockchain technology.
At the transaction level, in a network where there is no strong trust relationship with each other and deals with transactions with high probability and "value", blockchain especially emphasizes the global transaction of transactions to ensure the consistency of the whole network. In order to avoid false data by evil nodes, all transactions will be sorted on all nodes driven by consensus mechanism and network synchronization Operation and verification. On the blockchain that supports smart contracts, when each smart contract is called by transaction, the contract code will be run through all nodes to ensure that the process of generating data on each node is recognized and the operation results are consistent.
Let's cite an example of counting money: there are a lot of money for ten people. There are two ways. Method 1: you can divide the money into ten parts, one for each person, so that you can count it quickly. The more people, the faster you can count. However, if there is a wrong number in it, or even steal money, there is a problem. Therefore, for the sake of capital security, change to method 2. Let one person sort out a pile of money, count it first, and then let the other nine people count it again. After everyone checks and keeps accounts, change another person to sort out the next pile of money, and repeat the above rhythm. In this way, the result will not be wrong and can be recognized by everyone. However, the increase in the number of people involved in counting money will not accelerate the counting, but may be slower due to a large number of people. The first method is the common Internet distributed system, and the second method is blockchain. It can be seen that different purposes lead to different design philosophy, system structure and final effect.
To sum up, as a "distributed system", the storage cost and the number of nodes increase linearly year-on-year, while the computing efficiency does not increase but decreases, making the whole system "expensive" and "heavy", which is contrary to the "lightness" of Internet services. Most importantly, it is difficult to significantly improve the parallel processing capacity and storage capacity by increasing the number of hardware, bandwidth and nodes. However, the "network scale effect" of blockchain is not reflected in hardware and computing, but in "consensus" and "trust". The blockchain builds a trusted network through complex algorithms and games, which makes more people willing to participate in the network, contribute data and maintain the network together, reflecting the value effect of "win-win cooperation". This also gives us an important enlightenment: since the computing and storage costs of the blockchain are very high and the purpose is to reach a consensus, we should let the blockchain do what it should do most.
1. What data can be "linked"?
Only the key data to be used and shared by multiple parties in the transaction process should be linked, such as the accounts of the public ledger.
Videos, files, pictures and large-scale business data can generate summaries and be associated with transaction data. Their ontologies are exchanged through other channels (such as FTP, distributed file system, etc.). For example, when playing chess, you only need to put the chess result on the chain, or calculate a summary of the data of each step on the chain, and you don't need to record every step on the chain (unless you think this is also very key information). After all, every piece of data placed on the "chain" will occupy the hard disk of all nodes.
2. What logic is written in the contract?
It should be the key logic for multi-party participation, collaborative bookkeeping and global consensus, rather than the logic involving intensive computing. For example, for complex query or modeling analysis, you can export the data on the chain and put it down the chain instead of writing it in the contract. It should be clear that each line of code you write will not run on your own service only once, but will run on the nodes of all participants in the chain. Writing one more line of code will consume a little more CPU. Therefore, there will be a mechanism like "Gas ceiling" on the blockchain to control the code size of the contract. The new generation of contract engine is considering only providing limited and customizable business rule implementation, rather than completely open programming. As a developer, whether to program for "your own computer" or "everyone's computer" is the biggest difference between the Internet massive service system and the blockchain. Developers must switch their thinking mode, avoid abusing valuable computing, storage and network resources on the blockchain, avoid intentional or unintentional "tragedy of the commons", but calculate carefully, find out the "maximum common divisor" in the cooperation mode and data sharing from the overall balance, and use good steel to the blade.
What does blockchain believe
Signal cryptography algorithm
Blockchain uses algorithms to achieve trust, and one of the most important algorithms is cryptography. The most basic Cryptography Application in blockchain is HASH Abstract, symmetric encryption and asymmetric encryption algorithms, as well as related signature verification algorithms. HASH The old version of the algorithm has been proved to be cracked and abandoned. It is currently in use SHA256 The algorithm is still unbreakable. HASH The characteristic of the algorithm is that a pile of data is unidirectionally generated into a fixed length of data, which basically does not collide, and can play the role of "fingerprint" of the original data. Its unidirectionality is irreversible, the original data can not be deduced, and it has certain quantum resistance,
It is the best way to hide the original data and provide verification credentials when necessary. Digital signature is generally based on public-private key system, using private key signature, public key signature verification or vice versa. Digital signature originates from the reliability of cryptography, which makes it impossible for someone to forge someone else's private key signature. Therefore, a person with a private key can sign and confirm the right of his assets through digital signature, or use the public key of the opposite party to initiate a transaction and transfer the assets to the other party during the transaction,
The other party can use its own private key to check the signature and unlock it to obtain ownership. AES,RSA,ECC Several symmetric and asymmetric algorithms such as elliptic curve are widely used in data encryption and decryption, secure communication and other scenarios. Their security level depends on the algorithm itself and key length AES Use 128~512 Bit key, RSA/ECC When using 1024 or 2048 bit keys, the protected data theoretically needs hundreds of millions of years of computing time for ordinary computers to be brutally cracked.
These algorithms have been tested in commercial, scientific and military fields. In the field of cryptography, there are new directions such as homomorphic encryption, zero knowledge proof, ring signature, group signature and lattice cipher. At present, they are in the stage of development from theory to engineering. They are rapidly optimized in terms of function, security intensity and efficiency, and the possibility of ground use can be seen. At the same time, we also realize that cryptography usually needs long-term development, verification and stability before it can be widely recognized,
Either experienced a lot of tests in practice, or through the audit and certification of authoritative institutions, can shine in the production field. From theory to engineering in cryptography, there is often a long time period. A basic philosophy of encryption algorithm is computing cost. When the asset value protected by an algorithm is far lower than the cost required to break the algorithm, it is safe. However, if an algorithm is used to protect a priceless treasure, naturally someone will attack and profit at no cost. Therefore, the security of cryptography is also dialectical and needs to be quantified. With the rise of quantum computer and other theories, classical cryptography may face some challenges, but the theoretical improvement and engineering implementation of quantum computer still need time. At present, we can basically "unconditionally" believe in the cryptography algorithms already adopted in blockchain. At the same time, practitioners in the field of blockchain are also introducing various anti quantum cryptography algorithms, This is a continuous game.
The data structure of a blockchain is nothing more than a block+Chain. The new block will its own block height, transaction list, and the previous block HASH，Generate another one together HASH As the identification of new blocks, such a cycle forms a linked data chain. Any byte or even one in this chain Bit It will be modified because HASH The characteristics of the algorithm are verified and found. At the same time, block data is broadcast to all participants in the whole network. The more participants, the stronger the scale effect. Even if a few people forcibly modify or delete their own block data, it is easy to be verified by others and rejected. Only the data recognized by the majority can be retained and circulated. In other words, the data is watched by people in the form of man to man, and there are multiple copies. Once it is landed, as long as the chain is still there,
Data can be retained forever. Based on the easily verified chain data structure, group redundancy preservation and joint authentication, the blockchain data is "difficult to tamper", the data obtained by everyone is consistent, the information is open and transparent, and the public knowledge can be highlighted and solidified. From another perspective, data can achieve trust, but whether it can achieve "credit" depends on the value of the data, that is, whether the information carried by the data itself can represent valuable assets and useful information, such as identity, transaction relationship, transaction behavior, big data, etc., can represent a certain commercial value. If these data are shared, it is enough to build a complete business foundation. However, if we are in a scene that places too much emphasis on privacy, we are willing to share very little information, so it is difficult to achieve the "maximum common divisor" of credit. However, in the current business environment, information isolation and privacy protection are hard demands. Information sharing and privacy protection have become a severe spear and shield relationship, unless the whole business relationship and business logic are innovated. Therefore, privacy protection related research has attracted a lot of attention, such as "multi-party secure computing" and "zero knowledge proof". Theoretically, it can be verified by publishing very little information, but its complexity and computational overhead are things to be solved at the engineering level.
Trust game theory
The most mysterious part of the blockchain is the "consensus algorithm". The definition of consensus algorithm is that in a group, a mechanism is used to coordinate everyone to keep accounts together or in turn, so as to obtain undisputed and unique results, and ensure that this mechanism can continue. In other words, let's maintain an account book together and choose who will be the bookkeeper? Why do you believe that the bookkeeper's action is correct? How to prevent bookkeepers from doing evil? How can bookkeepers be motivated if they keep accounts correctly? The consensus mechanism completely answers these questions. The logic of consensus is online, but in fact, behind it is the competitive game in the real world. POW(Proof of workload) use computing power to compete for bookkeeper's seat and obtain bookkeeper's reward. In real life, in order to build a competitive computing factory, miners usually need to develop or buy a large number of new mining machines, transport them to areas with stable and cheap power supply, consume a large amount of electricity, network fees and other operating expenses, and have to move their families around the world when they are supervised,
In fact, it has invested a lot of money, energy and great risks. If you want to POW We can obtain stable and considerable income from the competition, and the capital invested is often hundreds of millions, which is no less than running an enterprise. POS and DPOS It seems to be more environmentally friendly to use the proof of rights and interests instead of computational power consumption. On behalf of rights and interests token，In addition to those issued by the founding team, "miners" generally need to obtain digital coins through currency exchange or direct purchase of digital coins in legal currency. Even in currency exchange, the coins they take out are often purchased in legal currency, or at least these rights and interests can be priced in legal currency,
This is also the wealth injection and endorsement in the real world. However, compared with real business relationships, POW and POS Such consensus has no legal and regulatory mechanism, and is also vulnerable to the changing game situation, such as the scale of the community, the change of miners and the change of core technology operation team. Slowly, people who are rich and capable may become richer and more powerful. Decentralized networks may gradually become cartels,
The relationship between miners and the technical community will also constantly set off waves, resulting in bifurcation, rollback, price overturning, leek cutting and so on. Generally speaking, people still trust the "autonomy" on the blockchain. In this distributed autonomy, a single event (such as a transaction) is "probabilistic",At the same time, the whole network pursues "final consistency" (consistency of public account books). This short-term probability and long-term certainty can achieve a dynamic "Nash equilibrium" to a certain extent, support the ecology of the chain, and give people a mysterious sense of "belief". On the other hand, the bookkeeper of the alliance chain is generally an organization level role. The alliance chain requires the bookkeeper's identity to know that the participants can access the network only with permission. They are a cooperative game. The alliance chain introduces real-world identity information as credit endorsement, such as industrial and commercial registration information, business reputation, acceptance credit, working capital, or industry status, practice license, legal identity, etc,
All behaviors of participants in the chain can be audited and traced, which also enables relevant regulatory authorities to target, accurately punish and enforce when necessary, with high deterrence. In this environment, the participants of the alliance chain work together to maintain the network, share the necessary information, and carry out transactions in an equal, transparent, safe and reliable network. They only need to prevent the malicious operation risk of a small number of bookkeepers and avoid the availability risk on the system. Due to the introduction of the necessary trust endorsement in the real world, even if the business logic of the alliance chain is very complex, the trust model is more intuitive. Therefore, behind the so-called consensus mechanism is still the competition of financial and material resources and credit endorsement in the real world, as well as the corresponding effective incentive and punishment mechanism. There is no free lunch, nor love and hate for no reason. "Faith" is a bookkeeper who believes in the cost he has invested and paid in the real world, and considering that the whole mechanism has the punishment to deter him, he believes that the bookkeeper will not destroy the network without reason for sustainable income and value-added.
Trust smart contract
Smart contract was developed by Nick, a prolific interdisciplinary legal scholar·Saab( Nick Szabo)Proposed. In several articles published on his website, he mentioned the concept of smart contract, which is defined as follows: "A smart contract is a set of commitments defined in digital form( promises)，Including the agreement on which the contract participants can implement these commitments ". In short, it can be understood as the electronic version of the paper contract, which is implemented in code, runs indiscriminately on each node of the blockchain network, and executes the established contract rules under the action of consensus. Smart contracts are generally based on a special virtual machine and run in sandbox mode to shield some functions that may lead to inconsistency. For example, the operation of obtaining system time may have different clocks on different machines, which may lead to problems in time-dependent business logic. Another example is random numbers, external file systems, external website input, etc,
These may lead to different execution results of the virtual machine, which will be isolated by the virtual machine sandbox environment. If you want to use java Write a contract or cut it jdk The related functions (system time, random number, network, file, etc.) in the are either placed in a system with strict permission control and isolation settings docker Run inside. Or simply design a new language, such as Ethereum's Solidity，Implement only specific instructions. Or give up some "smart" features,
Complete the key verification and judgment logic with a simple stack instruction sequence. Therefore, the implementation of smart contracts on the blockchain is controlled based on the sandbox mechanism. With the consensus algorithm of the blockchain, it achieves the characteristics of consistency, hard to tamper with and non repudiation of the whole network. The output of the operation result is a contract recognized by the whole network, which is called by Jianghu people“ Code is Law". However, as long as it is code, it must appear bug Or the probability of vulnerabilities may come from the underlying virtual machine and network vulnerabilities, and more may come from the logical implementation. Casually search for "smart contract security vulnerabilities", there will be a pile of search results, including overflow, reentry, permission errors, and even low-level errors. In recent years, these vulnerabilities have caused various asset losses,
The most famous is DAO Project code vulnerabilities Parity Multiple SIGNATURE WALLET vulnerability, token transaction process overflow of an Internet company and return to zero For technical articles, please refer to: https://paper.seebug.org/601/ At present, the security of smart contracts in the industry is also different, including security companies and white hat review, formal certification, public testing, etc., which will improve the security problems to a certain extent. If there is another problem, either the hacker is too powerful, or the programmer can only be arrested for worship:) Therefore, the trust smart contract is conditional. It is a contract that has been strictly tested, runs stably for a long time, and can be remedied in case of an error (rather than desperate and can only wait for bifurcation). Smart contracts in the alliance chain are generally strictly tested. When they go online, they will implement the gray verification process, monitor the operation process during operation, and design post accountability according to the governance rules
Remedial measures (reversal, account adjustment, freezing...) are still relatively credible.
Letter intermediary (?)
Note that the title of this section is marked with a question mark. Blockchain advocates the operation mode of "decentralized or multicenter, disintermediation or weak intermediary". However, due to the current development is not perfect, intermediaries are actually introduced in many scenarios. For example, currency exchange usually needs to go through exchanges, especially centralized exchanges. Its trading principle is to require users to deposit assets into the account of the exchange,
In fact, transactions are recorded in the database of the exchange. Only when money is deposited or withdrawn can they interact with the blockchain network. The trust model of the exchange is decoupled from the blockchain to some extent. At this time, the qualification of the exchange itself, the technical ability, security protection ability, asset credit and acceptance ability of the operator are what users need to care about most. Once the exchange has problems, such as running away, bankruptcy, dark disk operation and self-theft, retail investors can only do leeks. See the famous "Mentougou incident" for more information:https://baike.baidu.com/item/Mt.Gox/3611884 Therefore, it is a matter of different opinions to believe in a trustee, but in the current model, roles such as exchanges are still operating in some areas. In 2018, there were more than 10000 virtual digital asset exchanges around the world, and how many of them could achieve high-standard security, standardized operation and cleanliness... It depends. Finally, one point: the alliance chain does not have the virtual digital asset exchange of the public chain by default.
There are many details in the blockchain field. The main points listed above are trust technology, trust consensus mechanism and trust large-scale community game, which surpass trust "people". "People" is an uncertain factor. You can trust a person you are familiar with and old fellow, and you can trust a large group of people with common ideas and perfect mechanism. But you can not trust a small number of people who are unintentioned or become leeks in minutes.
To sum up, in the blockchain world, people can build the following basic confidence:
- Only I can use or disclose the assets and information I hold
- I can participate in transactions, share information and transfer in and out assets according to fair rules
- The assets transferred to me by others must be effective and will not be invalidated by repeated spending
- Once the transaction is completed, it is a certainty
- Everything that has happened is verifiable and traceable
- Those who break the rules will lose more
- People who maintain the network will have appropriate rewards for their labor, and the whole model will be sustainable
Based on these confidence and trust, on the premise of legal compliance, it will be an ideal state for people to inject various assets into the network and carry out complementary and mutually beneficial, transparent rules, open, fair and just business behavior.