Preface: After writing this, I showed it to my programmer friends. 85% of them said their IQ was not high enough and that no normal person could read to the last paragraph. I can only say that I tried my best. If you are Satoshi NakamotoIf you are Satoshi Nakamoto in 2009, you have found a solution to the double payment problem, and now you have to design a transfer function for Bitcoin. What would you do? My design would be like this:
Simple and clear, right? I guess your design is probably similar to mine. Fortunately, neither you nor I are Satoshi Nakamoto. If it were such a design, the potential of Bitcoin would be greatly reduced, and we would not be able to see the booming development of the blockchain field today. Let's take a look at Satoshi Nakamoto's design:
At first glance, Satoshi Nakamoto's design seems very cumbersome and counterintuitive, but it makes a lot of sense. A script is a simple computer language, such as JavaScript. Bitcoin scripts can express very flexible content, far beyond the scope of one-to-one transfers. For example: A can stipulate that the recipient B and the guarantor C must sign at the same time to control a certain Bitcoin (secured transaction), or it can be controlled by any two signatures of B, C, and D (joint account); A can stipulate that B must wait one year before using a certain Bitcoin (delayed payment), or it can be stipulated that anyone can control it (spending money) or no one can control it (burning money). With this built-in script programming language, you can flexibly write a variety of agreements-which are actually simple smart contracts. The contract system written in Bitcoin script makes Bitcoin the first programmable currency in human history. The real Satoshi Nakamoto said thisIn 2010, after discovering Bitcoin’s built-in script system, someone posted on BitcoinTalk expressing surprise and confusion: “The Bitcoin script makes me a little nervous. It’s too complicated, and complexity is the enemy of security.” This person was none other than Gavin Andresen, who later became Satoshi Nakamoto’s successor. Satoshi Nakamoto responded to him like this: The general idea is: I hope that Bitcoin will have a stable architecture in version 0.1, and no underlying changes will be needed in the future. In the process of designing Bitcoin in the past few years, I found that only by using the script system can I complete the various complex transaction types I want to support - If it were today, perhaps Satoshi Nakamoto would directly say: "Bitcoin needs scripts, and with scripts, there are smart contracts." Let me digress. This post is only 9 sentences long, but it can be regarded as an important dialogue in the history of blockchain technology development. You will find someone on the 8th floor asking "Does Bitcoin's script system mean that users can issue custom assets?" This person's ID is bytemaster, and later he founded BitShares, which can issue user-defined assets. Gavin on the 9th floor replied:
This is probably the first time the concept of colored coins has been proposed. The True Face of Bitcoin Script After so much nonsense, let's get to the meat of the matter. Now please treat your brain as a stack-based interpreter and virtual machine to see how Bitcoin scripts actually work. The verification process of a typical Bitcoin standard transaction ( scriptPubKey: OP_DUP OP_HASH160 OP_EQUALVERIFY OP_CHECKSIG (scriptPubKey is the script “lock” on 1 BTC mentioned in the previous analogy) scriptSig: (scriptSig is the script "key" provided by sender A in the previous analogy) After the script is executed, if the result is true, it means that the verification is successful and A has the right to control the bitcoin. The Bitcoin network will add a "new lock" to the bitcoin according to A's instructions, and the transfer is completed. Limitations of Bitcoin ScriptIn order to keep Bitcoin forward-compatible and simple and stable, Bitcoin developers have imposed many restrictions on its scripts. For example, there are no loop statements in the scripts, and the Bitcoin core client currently only supports 5 fixed-mode scripts. This is partly due to historical baggage, and partly because the Bitcoin development team tends to be conservative and robust. Some of you may know that we are developing a blockchain protocol for registering, managing and trading equity - Antshares. Antshares reuses the main architecture of Bitcoin, including the script system. On this basis, Antshares refers to the Bitcoin Improvement Proposal BIP12 proposed by Gavin Andresen and adds an scriptPubKey: OP_DUP OP_HASH160 OP_EQUALVERIFY OP_EVAL scriptSig: redeemScript: OP_2 OP_3 OP_CHECKMULTISIG Bitcoin Script + BIP12 = Turing CompleteThe addition of the OP_EVAL instruction enables Ant to have a Turing-complete scripting system, which makes more complex smart contracts possible. Turing completeness refers to a computing system that can compute every Turing Every node in the Bitcoin network must execute the script in every transaction, which requires the design of the Bitcoin script system to be sufficiently streamlined. As a peer-to-peer electronic cash system, Bitcoin does not really need a more complex script system. Xiaoyi adopts Turing-complete scripting solution and avoids the problems caused by Turing-completeness through the following two methods:
After solving the problems caused by Turing completeness, Xiaoyi's script system can be applied to the following scenarios:
|
<<: Virtual currency pyramid scheme list revealed: "Baichuan Coin"
>>: Is Bitcoin on its last legs?
People with moles in different positions have dif...
Judging from a woman's face, she has good for...
Everyone is curious about the moles on their body...
Bitcoin has cleared yet another hurdle, breaking ...
There are always many palm lines on people's ...
A woman with a miserable life Most women have ova...
In palmistry, in addition to the palm lines, the ...
Almond eyes and peach blossom eyes are the two mo...
Bitcoin hit $40,000 only after starting the new y...
Love luck is of great concern to many single peop...
Hands are one of our most dexterous organs. We ca...
HYPR, a startup that aims to bridge blockchain te...
A person's social status is not only determin...
Each of us has moles on our face, which is a very...
The happiest women in married life often have the...