Jiang Yong | Vernacular blockchain technology stack and application

Jiang Yong Mesozoic Technology

Contents summary

Now when it comes to bitcoin , I believe many friends are familiar with it , Especially in the past two years, with its price soaring , Even more than gold , More than real estate , The major financial media and even CCTV have paid attention to reports ;
In the eyes of many friends , Bitcoin seems to be a game currency 、 Post money card is the subject of speculation , In addition to marveling at the speed of its price rise , I don't know much about it .
However , Behind all this , What on earth supports , Now, except for bitcoin , There are many other similar systems , Like the Wright coin 、 The etheric fang 、 Bitstocks and so on , There are so many , Any soft text that introduces these contents , Generally speaking, there is a noun : Blockchain
Everything seems to be caused by blockchain , that , Let's cut through the fog , Uncover the mystery , Let's see what's at the top of this , What are its characteristics , What's the use of it .

Vernacular blockchain technology stack and application

Reading guide : This chapter mainly introduces the meaning of blockchain itself and its representative technical composition , And how bitcoin came into being through this technology .

1. What is a blockchain

1.1 An interesting data record format

Blockchain , Take it apart “ block + chain ”, It's actually a data recording format , When software processes data , Always need to read and write in a certain format , For example, we usually use the relational database , The data is kept according to one record by one , Or in a more popular way , It's like bookkeeping , Record every business in the account book , The accounting of each record is called voucher , In a month , Summarize the record of a pile of voucher data into An account book , Every month, it's monthly . The format of blockchain , It's very similar to the accounting method , The so-called block means a large amount of data , We can regard the bookkeeping vouchers of all accounting records every month as blocks one by one , Between blocks through the year The moon is in series , It looks like a data link , Blockchain is actually such a simple format , Let's look at a diagram :
 Jiang Yong | Vernacular blockchain technology stack and application
As shown in the figure , This is what the blockchain format looks like , In bitcoin , Instead of storing a chunk every month , It's about every 10 One block per minute ( Note that it's just about , Not exactly 10 minute ), The data stored in the block is recent 10 Within minutes The raw trade Business ( Current 10 In fact, the term "minutes" is not rigorous , Now that's it Explain , There is another explanation below ), It can be understood as a running account .

When you see this format , I don't know if there are some familiar associations , In fact, such a data format , There are many similarities in life ;

For example, the warehouse in and out records of the factory , This is similar to the accounting book , And genealogy or genealogy , The relationship between generations is a block , To the next generation Another block , Between the blocks is father and son The relationship between women , wait ; And if you are a computer professional friend , At a glance , This is a linear table ? Yes , This is the main data storage format of bitcoin software , It's also the data access format of all other systems based on blockchain technology .

This is a very interesting data format , It divides the data that happens continuously into one A single block of data , So each block has its own number , You can also have your own ID number ( It is calculated by hash algorithm ), When downloading and synchronizing the data , It can be obtained from each node in parallel , Regardless of the data sequence , When you arrive at the local level, you will assemble it according to the block number or ID number .

in addition , This format is a chain Format , The most important feature of the chain is that it links one link at a time , It's hard to destroy from the middle , For example, someone tampered with the middle 5 Block No , So if you want the data to look complete , You have to synchronize 5 Block number, all subsequent blocks have to be changed , This is more difficult , This is also one of the reasons why blockchain data formats cannot be tampered with ( Yes, of course , If it's just local data , There's nothing that can't be tampered with , The real anti tampering ability of blockchain system is realized through the node network and consensus algorithm of countless blockchain systems , This one will be introduced next ).

There's another beauty to this format , If this data is always recorded by one person , Of course it's nothing , But if you put it on the Internet , Let's record this data together , That's interesting , Who records or packages the data of each block , You can set a rule of the game , Like rolling the dice Son , We agreed who could continue 3 The first throw 6, Let him remember the data , To compensate Let's look at his labor input , Reward him with some income , Bitcoin is using this principle to continuously issue new bitcoin , The bitcoin awarded to the person who packed it is the new bitcoin .

Speaking of this , You think it's a little interesting ?

1.2 A representative of a group of technologies

We just talked about that , Blockchain is a data recording format , But if that's all , It's not really a big innovation , in fact , Technically, blockchain is synonymous with a group of technologies , We usually say that we use blockchain technology, which means , So since it's a set of technologies , Which technologies are combined ? Let's look at a set of keywords :

  • Public key algorithm
  • Network consensus algorithm ( dig )
  • Merkel's data prove that
  • Programmable script contract
  • Blockchain ledger

1. Public key algorithm

It belongs to computer cryptography ⾥ Face traditional technology , The public key algorithm is ⼀ An asymmetric encryption algorithm , Have two keys , They can encrypt and decrypt each other , Usually one of the keys is public, which is called public key , The other key is secret, which is called private key ;

2. The hash algorithm

It is also a traditional technology in computer cryptography , Should be ⽤ It's more extensive , The main ⽤ Come on ⼀ Segment data for calculation , obtain ⼀ A summary , Generally speaking, it means giving a piece of data ⽣ become ⼀ An ID number ; The summary data generated by different messages is not ⼀ What kind of ( Some hash algorithms with weak anti-collision ability may be here ⽅ There will be some problems with noodles , But make ⽤ Extensive ⼀ Some famous hash algorithms , Hair ⽣ The probability of collision is very low ), It is equivalent to giving ⼀ Segment data ⽣ It's an ID number , In the blockchain system , Hash algorithm makes ⽤ quite a lot ,⽐ Such as between blocks , It is associated by the hash of the block header ,⽽ Every... In the block ⼀ Every transaction will be ⽣ become ⼀ A hash value is used as the ID, You can pass these ID number ⽅ It's easy to retrieve or associate blocks , Can also ⽅ It is necessary to appoint someone ⼀ This is a transaction .

Hash algorithm can also be used to generate Merkel tree , Now let's talk about it in detail , We say that the , The characteristic of hash algorithm is , As long as the target data has even ⼀ A little bit of change , The generated hash will be completely different , So you can ⽤ It is used to verify whether the data has been changed .

3.⽹ Network consensus algorithm

A long time ago, computer scientists studied , And put forward some models ,⽐ Such as Byzantine fault tolerance algorithm and so on , The currency 、 Ethereum uses ⼀ A workload proof algorithm , Some other blockchain systems use other kinds of derivatives ⽣ The algorithm of ,⽽ The principle of the algorithm is very simple , It's an agreement ⼀ A rule , By jointly enforcing this rule , Keep the data of each distributed node consistent ;

4.梅 Kerr's data prove that

This is using hash algorithm to ⼀ Group data is created as ⼀ A hash tree structure ,⽤ A structure for verifying data integrity , At the same time ⽤ In a lightweight wallet . The response of different blockchain systems to Merkel tree ⽤ It's different , In bitcoin, it's ⼆ The cross Merkel tree , Relatively simple , The hash value of the transaction is used to generate a tree , Ethereum is much more complicated , Call it Merkel . Pat ⾥ Summer trees , I won't go into details here .

5. Programmable script contract
What is a contract ? Namely ⼀ The rules of group agreement ,⽐ Such as the bank's settlement system ,⼩ It's a transfer 100 To Xiao Wang , In this way ⼀ In a process , silver ⾏ The system will ⼀ Automatic execution of group rules , Rule contains ⽐ Such as testing ⼩ Is Ming's password correct , Is the balance ⾜ enough ,⼩ Is Wang's account number correct , If the test is passed, the accounts of the two will be changed respectively ⾦ And write ⼊ Business ⽇ Records . Yes , That's what the contract means , Of course , If the scope is more ⼴ More general , All kinds of business contracts have the same meaning , So there's nothing strange about a programmable script contract , however ⽽, If this kind of programming contract is put into the blockchain environment , Just ⽐ More interesting , Look at two characteristics :
The first ⼀ individual , Blockchain system is ⽆ in ⼼ Distributed ⽹ Collateral , There is no boundary
The first ⼆ individual , Blockchain system through ⼀ Series of technologies to achieve a trusted ⽹ Collateral
Add up , Namely ⽆ The trustworthiness of borders ⽹ Collateral , In this way ⼀ individual ⽹ In the network ⾏ An established contract , The cost is low ⽽ And it's safe ,⽐ In essence, the special currency belongs to the same category ⼀ A script contract , But in ⽐ Special currency software , The deal in the contract is ⽐ Transfer of special currency , If you expand the concept , Crowd-funding 、 guarantee 、 Various types of contracts such as fenrun can cope with ⽤ On this ⾯,⽤ You can also ⾃ Write contract rules , Ethereum is this ⽅ Face ⼀ A typical representative , And this brings out the application of smart contract ⽤.
Specific explanations of these technologies , We are in the next ⾯⼀ A detailed description of .
Among them 【 Blockchain ledger 】 We have already introduced , I won't repeat , So what do other technologies mean , How they are combined with blockchain ledger ? Let's explain one by one :

1.3 Genesis applications “ The currency ”

Said so much , We know , Blockchain technology is a set of software development technology anyway , With our usual website development technology 、 Game development technology 、 mobile phone APP Development technology is similar to , It's just , Unlike other development technologies , It can develop a piece of software , This kind of software can make “ currency ” come out , It's kind of incredible , Bitcoin is the first application of blockchain technology , So we call it “ Genesis applications ”.
It is bitcoin that brings the technical concept of blockchain to our vision , although ⽐ Tsung Nakamoto, the founder of teken ⼀ It's all ⼀ It's a mystery , It's not clear who he is ⼀ individual ⼈ People or ⼀ Organizations , But none of this matters , It is important to ⽐ The special currency system is based on ⼀ It's an extremely talented innovative design , Solved people's problems ⼀ Problems that have been difficult to solve all along , That's asynchronous ⽹ To realize the trusted consensus of data in network environment ⽅ case . Let's get rid of ⽐ The concept of special currency , Just standing on the software or ⽹ It's complicated ⻆ Let's see ⼀ Next , Suppose we were the original Nakamoto , simulation ⼀ What I thought at that time ,⾸ First , Hope to achieve ⼀ Systems , You can connect ⽹, And transmit data through the network , If it is to make ⽤ Central Services 器 With this structure , It's obviously not safe enough , As long as the data on the server is corrupted or ***, The system is paralyzed , therefore , Decided to take ⽤ Distributed structure , But there are several problems with distributed architecture ;

first , These distributed system nodes run ⾏ Where to? , Who is willing to provide computer facilities to transport ⾏ That's ok , by ⾃ I've come to deploy , That's the end of the cost ;

The first ⼆ individual , Distributed nodes , So the data ⼀ Consistency is a problem , Without the server , There is no authoritative guarantee of data source ;

Third , How to verify ⽹ The data in the network ?

For the first ⼀ A question , In the economy ⻆ degree , If the system provides ⼀ Two incentives , Transportation ⾏ Node ⼈ If it's profitable, it should be solved , So design this system , You have to have ⼀ It's a reward or incentive rule , stay ⽐ In the special coin , The mines in the packing block ⼯ Workers can get ⼀ A certain amount of ⽐ Special currency reward , That's the incentive .
For the first ⼆ individual , This is a difficult problem , Bitcoin has to be shipped ⾏ In public ⽹ On , There are all kinds of situations , Data can be tampered with ,⽹ The collaterals may be unstable , Even when the node will be transported ⾏ It's not under control , How to solve these problems ? You have to have ⼀ A mechanism , This mechanism has to be fair , Since the network may be unreliable and unstable , Then there can't be too much dependence on other nodes in this mechanism , It has to be ⼀ It mainly depends on this machine ⾏ Of ⼀ One way .
It's me , It's really hard to think of ⼀ It's a good way , Conventional ⼀ There are some technical problems , If it's in ⼀ A node is clear , The Internet is also a good occasion , It's also very reasonable ⼀ some , But ⽐ The situation of special currency should be ⽐ This is much more complicated . The famous CAP principle , It's about ⼀ A conclusion : Distributed computing systems can't guarantee at the same time ⼀ Sexual nature 、 can ⽤ Sex and zone tolerance . Let's see what these three terms mean :
【⼀ Sexual nature 】: this ⾥ It means strong ⼀ Sexual nature , Hair ⽣ After ⾯ You can see before ⾯ The incident happened ⽣ Result of
【 can ⽤ sex 】: In a limited time , whatever ⾮ All failed nodes can respond to requests
【 Zone tolerance 】: in other words ⽹ The collaterals may develop ⽣ Partition , That is to say, the communication between nodes cannot be guaranteed and cannot be guaranteed at the same time , Then we have to weaken something ⼀ One or two characteristics ,⽽ And enhance it ⼀ It's a feature .

When Nakamoto came true , Designed ⼀ A proof of the amount of work , It is interesting to , Set up ⼀ Two difficulty values , Everybody passed ⼀ It's like a roll of dice ⼦ To hit ⼀ results , If the results meet the expected requirements , Just succeed , The winner can get the right to record the data, that is, to package the block data , After packing ⼴ Broadcast to others ⼈, other ⼈ Write after verification ⼊⾃ In our data .
In the process , Because of make ⽤ The algorithm is ⼀ An algorithm similar to brute force cracking , In addition to relying on ⾼ There is no better way for computers to be clever ( This is ⼀ To some extent ⼀ A certain degree of justice , Yes, of course ,⼟ Hao Youneng ⼒ Buy higher performance computer facilities , from ⽽ Better than average ⽤ Users have the ability to seize the right to package , This is also ⼀ A question , however ⼀ One technology can only solve ⼀ The technical problem of scope ), But what we need to pay attention to is , Can figure out ⼀ A hit value of , It's not ⼀ There must be only ⼀ individual ⼈, If there are more than one ? Then you can only enter ⾏ block ⼴ There's no competition , Who is received more by other nodes , Who is finally recognized ,⽽ Other successful mines will be discarded , from ⽽ No reward .
therefore , This kind of data in bitcoin ⼀ The algorithm of consistency is the final ⼀ It's about sex, not real time ⼀ Sexual nature , This is everybody ⼀ Be careful .
For the third question , How to verify ⽹ The data in the network , stay ⽐ Special currency ⽹ Collateral , Each node is unique ⽴ Of the validation data , In the verification process, there is no need to ⽹ Other nodes in the network provide dependent services .

2. Blockchain technology stack

2.1 Record format — block . chain

see 【1.1 An interesting data record format 】

2.2 Network structure -P2P

Today, ,⼤ Probably very few software is a stand-alone version , Just lose ⼊ Law ⽐ If Sogou loses ⼊ Law 、 IFLYTEK lost ⼊ The law also needs to pass the couplet ⽹ To update the thesaurus and provide other ⼀ Some intelligent functions , that , Since it's Lian ⽹ Software for , I can't avoid it ⼀ A question , That's it ⽹ Collateral structure , Just fine ⽐ We're going to build houses ⼦, You have to design the structure of the house , Brick structure or frame structure , A single flat ⽅ Or even ⽚ Of ⼩ District .
So far ⽌,⽆ On what kind of ⽹ Collateral structure , In general ⼀ Next words , There are two : client - Server structure 、P2P structure .

P2P That is to say peer to peer It means , in ⽂ Point to point , It means equivalence .

One of the characteristics of blockchain ⼀ It's distributed , Each node maintains complete ledger data , You can be alone ⽴ Advance ⾏ data validation , Send data independently, receive data , The data can not be tampered with and ⼀ Sexual nature ,⽽ Each node is unique ⽴ Do it by the rules ⾃ My own business . whatever ⼀ The damage of a node or the exit of the graph are not ⾜ To influence the whole ⽹ Normal collaterals make ⽤, Especially when there are a lot of nodes , This avoids a single point of failure .
Because there is no ⼀ Servers , So it's equivalent ⽹ Nodes in the network structure , It needs to have ⼀ It's a mechanism to know each other , This is it. ⽹ Network routing function , Simply speaking , Each node is responsible for providing address information for other nodes , At the same time, it will also ask for and update the valid node address .

Just one ⼈ To understand , reciprocity ⽹ The core of the complex structure is ⼼ is ⽹ Network consensus mechanism , Each node acts as both a client and a server , Through the consensus mechanism to coordinate .

2.3 Synchronization mechanism - Consensus algorithm

Blockchain system is peer-to-peer ⽹ Collateral structure , Every day ⾏ Each node has its own ⾃ preservation ⾃⼰ Data copy of , So here's the problem , How to ensure the data consistency between each other ⼀ Well , Since there is no ⼀ Among them ⼼ The server ,⾃ But there is no ⼀ It's a traditional authoritative data source ,⽽ And equal ⽹ Every node in the network is equal , So if each other's data doesn't ⼀ Cause , Whose is the standard ? This will make ⽤ To ⼀ A synchronization mechanism , Consensus algorithm .

The main idea of consensus algorithm is ⽬ The best way is through ⼀ Species mechanism , bring ⽹ Network middle class ⽣ It's the data that makes ⼤ The so-called consensus is that the family can recognize it ,⽽ For those who ⾮ French ⽆ Effective data will be discarded , so to speak , The consensus algorithm is to ensure that the blockchain ⽹ It is an important part of network data synchronization and data security . Every time ⼀ Different blockchain systems will have ⾃⼰ Of ⼀ A consensus algorithm ,⽐ Such as PoW(proof of work,⼯ Work quantity 量 prove )、PoS(proof of stake, Proof of interest )、DPoS(Delegated proof of stake, Share authorization certificate )、PBFT(Practical Byzantine Fault Tolerance, Byzantine fault tolerant algorithm ) wait , quite a lot , Each algorithm has its own characteristics and advantages and disadvantages .

Before we go into details , Some friends may have questions , Even if it's equal ⽹ Collateral , No, ⼀ A server to provide authoritative data sources , But as long as the nodes are connected to each other , Always keep ⼀ If not, just ⾏ 了 , If it's in ⼀ individual ⽹ Good local network ⽹ in , And I'm lucky ⾏ Our nodes are strictly managed , that ⼤ Maybe there's no problem , But the truth is , similar ⽐ A blockchain system such as tecoin is run by ⾏ On the Internet ⽹ Upper ,⽽ And no one can guarantee ⽹ What's the state of collaterals , what ⾄ Even luck ⾏ I don't know when to start and when to shut down ,⽐ If we make ⽤ WeChat chat , Suppose there is no ⼀ A wechat server exists , When ⼩ Send a message to ⼩ Wang Shi ,⼩ Wang just didn't open wechat , perhaps ⼩ Wang just stopped underground ⻋ site , no ⽹ Collateral , What to do with that ? All sorts of situations , There is no guarantee that nodes can be connected at any time ⼀ rise , So the consensus algorithm in the blockchain , The solution is this ⼀ It's a very complicated situation ⽹ Data synchronization in network environment .

In order to make ⼤ home ⽐ Can understand more vividly , We still use ⽐ Take the special coin as an example ,⽐ The special currency is used to make ⽤ Yes. ⼀ Kind of ⼯ Work quantity 量 Proof algorithm , The principle is simple , as follows :

We still use ⽐ Special currency as an example to illustrate ,⽐ In the special coin ⽹ The process principle of network consensus algorithm is relatively simple , Understand this part , Understanding other consensus algorithms will ⽐ More basic .
stay ⽐ In the special coin , send ⽤ Our consensus algorithm is ⼀ Kind of ⼯ Work quantity 量 Proof algorithm , Let's talk about it ,⼤ Home passes ⼀ A competitive algorithm is proposed to seize the right to pack block data , Whoever gets it will get it ⽣ Transactions 易 Data is packaged into blocks , also ⼴ Broadcast to , After other nodes are verified, they are saved to ⾃⼰ In the blockchain ledger of , The principle of this competitive algorithm is very simple , System accounting calculates ⼀ It's a difficulty ⽬ Standard value , then ⼤ Home through the block into ⾏⼀ Hash calculation with random number added , Until the calculated value ⼩ It depends on the difficulty ⽬ Standard value , That's the right to keep accounts , It's like rolling dice , Who threw ⼀ The group that meets the criteria wins .
A friend may ask , If not ⽌⼀ individual ⼈ It worked out that ⼀ It's a number , Whose is the standard ? ha-ha , This is the time , It depends on luck ⽓ 了 , If A and B All got qualified ⽬ Bid data , All packed , all ⼴ On the , It depends on who at this time ⼴ The range of broadcasting is the most ⼤, The impact is most ⻓ Far away , Last ⽐ Special currency ⽹ The network will keep ⼴ The coverage is the most ⼤ the .

⼤ Home see in this ⼩ There's a... On the title of the section “ dig ” The words... , Is consensus algorithm all called mining algorithm ? The answer is No . Here ⾥ The reason why ⼀ individual “ dig ” The words... , Because in many public chain systems ,⽐ Such as ⽐ Special currency 、 Wright coin 、 The etheric workshop etc. , It's all through ⼀ A consensus algorithm 行 New currency , How to send ⾏ Well , It's the reward ⼀ Fixed quantity 量 To the successful mining of the block ⼯.

2.4 Complete proof - Merkel tree

A Merkel tree is a data structure , It's the same as the blockchain ledger data format , It's for maintenance A kind of data , The account book format of blockchain is a chain , Merkel tree , As the name suggests A tree structure , The purpose of Merkel tree is to realize the integrity proof , In different blockchain systems , An envoy to the Merkel tree It's not the same , The one used in bitcoin is called a binary Merkel tree , For example, Merkel is used in Ethereum system - Patricia tree , relatively speaking , A binary Merkel tree is much simpler , Let's start with a brief introduction , Take bitcoin as an example .

Since it's a tree structure , Then there are tree nodes , So what data are in the tree nodes of bitcoin ? actually , In bitcoin , Each block contains a plum Kerr tree , Let's see , How is this tree planted .

There are many transactions in each block , Each transaction has an ID number , This is calculated by hash algorithm , It can uniquely represent a transaction record , Let's say there are 6 Transaction records , Then we'll take out 6 The ID number of the transaction record is Hashige , Pairing , Then, the pairing transaction hash values are calculated , Up in turn , Until a root hash is finally calculated , Let's take a look at a diagram :
 Jiang Yong | Vernacular blockchain technology stack and application
 Jiang Yong | Vernacular blockchain technology stack and application
stay ⽐ In the special coin , Every block can ⽣ become ⼀ A Merkel tree , Through what ⽣ Yes ? It's through transactions , stay ⼀ In one block , Every transaction is calculated ⼀ Hash values , Suppose a block has 4 This is a business , As shown in the figure ,Hash1 To Hash4 This is the 4 Hash value of transaction , Next, hash the hash value of the transaction in pairs again , Until the last ⽣ become ⼀ A root hash , such ,⼀ A Merkel tree is ⽣ a . that , In this way ⼀ tree ⽣ What's there after that ⽤ Well ?

⾸ First ,⽐ The node of special currency is entering ⾏ Data synchronization , Data will be downloaded to multiple nodes , This is the time , There will be a problem , How to verify the data is complete or incomplete , Is there a problem or no problem ? Point to point ⽹ In the middle of the collaterals ⾏ When data is transmitted , Obviously, it's not just from ⼀ Download data from one server ,⽽ And one of them ⼀ Some machines can also be unstable , what ⾄ It's not credible , This is the time , Through the above ⼀ individual ⼤ file ⼀ A hash of ⽅ It doesn't work very well ⽤ 了 .

And then through the Merkel tree , Suppose that 2 There is something wrong with the download of transaction data , Then we calculate Hash12 It must be different from other nodes ⼀ To , You'll soon be able to locate the problem block , In addition to being able to quickly locate data blocks , also ⼀ A work ⽤, That's right SPV(Simplified Payment Verification, Simple ⽀ Pay verification ) Support for , We know ,⽐ Special coin core ⼼ Wallet is to match with complete blockchain data to make ⽤ Of , Including all the hair ⽣ My business , Therefore , The transaction received or initiated can be ⾏ Complete verification ,⽐ If it contains ⾜ Enough balance , Whether Shuanghua, etc , But there is also a very ⼤ The problem of , It has to be taken with it ⼀ It's a huge amount of data ⼤ A copy of your account book , That's the limit ⽐ The special coin purse is used for ⽤, Sometimes we just want to verify ⼀ Next ⽀ Whether to pay ⽣ Once in a while ⾏ 了 , The complete transaction can be handed over to the core node , Then what shall I do? ? It can be realized through the following process :

  1. ⾸ Download the full block data first , Note that the block header is not all the blockchain data , The block head contains the merkelgen of the block

  2. If you want to verify a stroke ⽀ Pay transaction , The hash value of the transaction is calculated txHash

  3. find txHash In the block , verification ⼀ Whether the block head of the next block is included in the blockchain ledger

  4. Get the hash value needed to calculate the Merkel root in the block , Note that we don't need all transaction hashes , As shown in the figure , If you want to check Hash1 Words , We just need to collect more Hash2、Hash34 that will do

  5. Figure out merkelgan

  6. If the calculated result is equal to the Merkel root of the block , be ⽀ Payment transactions exist .

  7. According to the block header Where it is , You can also determine how many confirmations the deal has received

From which we can see , The Merkel tree is very important .⼤ Home can imagine ⼀ Next , This structure can also respond to ⽤ In which scenarios .

2.5 Account management - Public key algorithm

When we use the usual network services , Will register a user name , Whether it's using Taobao 、 JD.COM 、 WeChat, etc. , Or play online games and so on , Will register a user name , How to register the user name in the blockchain system ? In fact, in the blockchain system Generally, there is no concept of user name , And there's only one account address concept , Whether it's bitcoin or Ethereum or something , It's basically represented by an address , For blockchain systems that support digital currency, this address is also called a wallet address , So where does this address come from ? Let's look at the public key algorithm first :

This is a ⼀ Encryption algorithm , The usual encryption algorithm , The key is just ⼀ individual , for instance , We hope that ⼀ String numbers into ⾏ Line encryption , It is agreed that every ⼀ Add... To every number 2,⽐ Such as 1,2,3,4,5 It becomes 3,4,5,6,7, If anyone knows about this encryption ⽅ Law , Then we also know the decryption algorithm , such ⼀ It's called symmetric cryptography ;

If you want to encrypt ⽅ Law and decryption ⽅ The law can be alone ⽴ And ⽆ You can't just push each other out , that , This algorithm is called asymmetric encryption algorithm , In other words, the public key algorithm , Why a public key , Because this one has two keys ,⼀ It's a private key ,⼀ One can be made public , Call it public key , send ⽤ Data encrypted with the private key can be decrypted with the public key , In turn make ⽤ Data encrypted by public key can be decrypted by private key ,⽬ At present, this algorithm should ⽤ More of them are RSA Algorithm and ECC Elliptic curve algorithm , The former uses ⼤ The principle of the difficulty of prime number decomposition , The latter takes advantage of the computational difficulty of elliptic curve discrete logarithm , The details are based on the length ⾥ Don't expand , In the blockchain system , In general, the elliptic curve algorithm should ⽤ Most of the .

With ⽐ Take the special coin as an example ,⽤ You can go to ⾃ Create an address in your wallet , This address is similar to silver ⾏ account number , We can ⽐ The token comes from ⼀ Send it to another address ⼀ An address , that , Where does this address come from ⽽ What about it? , actually , essentially , did not ⽐ The special currency address is ⼀ The East ⻄ There is , Why do you say that? ?⽤ When creating a wallet address , It's actually the creation of ⼀ For public and private keys ,⽽ The address is just a public key ⼀ A formatted representation . ⽤ The private key signature proves ⾃ Own a pen ⽐ Special currency ,⽽ It can be verified by public key ⾃ My identity , as long as ⾃ Signed by private key ⼀ A deal or a signature ⼀ A message , whatever ⼈ People can confirm whether they are legal users through public key . in other words , The public key algorithm is not only ⽤ To identify an address user , It's also ⽤ To complete the transaction , Not only ⽐ Special currency , The same principle applies to other blockchain systems .

2.6 Intelligent contract - Programmable state logic

This is a blockchain system ⾮ It's a very important feature , We know , Blockchain systems can create ⼀ A trustworthy ⽹ Collateral , In this way ⼀ In a trusted network, you can safely pass through ⼀ The established rules of group coding , Transfer ownership of data , Change the state of the data .⽐ Special currency ⽹ It can be transferred in the collaterals ⽐ Special currency , The etheric fang ⽹ Ethereum can also change the state according to the rules through other smart contracts .

What do these really mean ?

Usually , stay ⼀ In a traditional system ,⽐ Like silver ⾏ Bank's account system , How to show ⼀ Whose is the money ? By account and password ,⽐ Such as ⼩ Ming has changed 100 Yuan to ⼩ king , this 100 Of ⾦ The value of the gold amount will be written ⼊ To ⼩ Wang's account , And then deduct ⼩ Name the account ⾥100,⼩ Wang's account can only be opened through ⼩ king ⾃ Your password can be verified ⽤, This logic seems normal ,⼀ We've been here all the time . however ⽽ and , In the blockchain system, it is not realized in this way .

Let's stand on ⼀ individual ⽐ a ⾼ Of ⻆ From the perspective of ⼀ Next , With silver ⾏ Account as an example ,⽆ On transfer , Save or deduct ⽤ etc. , No matter what kind of business it is , For an account , Standing in the data layer ⾯, nothing ⾮ It's the constant change of data state ,⽽ Every time ⼀ Every change was made through ⼀ A series of rules verify , such ⼀ Come on , We can think of this account as ⼀ A state machine , as follows :
 Jiang Yong | Vernacular blockchain technology stack and application
This picture is easy to understand , Then we can see , The main thing is not the state itself ,⽽ It's the trigger for state change , In this picture , Every change between States is conditional , How to achieve this in blockchain system ⼀ The trigger of two conditions ? Let's make it clear by transfer :

  1. send out ⽅ launch ⼀ A transfer transaction , It's like opening up ⼀ Zhang ⽀ ticket , And sign ⾃⼰ Name ( Private key signature )

  2. stay ⽀ The ticket says yes ⽅ The account address of ( Yes ⽅ The address of your wallet , We know that the wallet address is converted by public key ⽽ To the )

  3. towards ⽹ Send this transaction to , Each node can verify whether the transaction is valid (⽐ If sent ⽅ Is the balance of ⾜ enough , Whether the private key signature is legal, etc )

  4. If the node has no problem in verification, it can pass , This transaction will eventually be abandoned ⼯ Package into blocks ( It's equivalent to a formal account )

  5. receive ⽅ Can pass ⾃⼰ To verify ⾃⼰ Ownership of this transfer transaction ( this sentence ⼀ Understand ⼀ Next ), adopt ⾃⼰ The private key and ⽀ The public key on the ticket matches the address , If it works , That means ⾃⼰ Ownership of this transaction transfer , that ⾃⼰ That's the money .

In this way ⼀ What is the realization of this process , It's through ⼀ Group scripts , stay ⽐ In the special coin is ⼀ For lock and unlock scripts , In Ethereum, there are more complex programming scripts , All in all , It is through this program logic that the trigger condition of state change is realized , As long as the script is written , Trigger condition reached , The procedure will be strictly enforced ⾏, upright and outspoken , No love left ⾯ Noodles ^_^.
that , We can find out , This procedure , It's actually equivalent to ⼀ A contract , It's agreed that ⼀ A rule , If it's in line with the rules, follow the rules ,⽽ What are the specific rules , This can be written in advance (⽐ The function of the special currency is ⽐ More limited ,⼀ In general, transfer transactions can also be realized , Ethereum can ⾃ Define and write various contract rules ), It will be like this ⼀ A contract is placed in this ⼀ One goes to China ⼼, In a distributed environment , from ⽹ We need a consensus to make sure we don't tamper with it , How innovative it is ⼀ There's a way of thinking , This idea of programmable contract can ⼴ Universal response ⽤ In a variety of business environments, including the financial sector .

3. Application features

3.1 Distributed network

P2P⽹ The collaterals themselves are ⼀ Distributed ⽹ Collateral , Blockchain ⽹ There's no ⼀ A real server , Internal transport ⾏ Logic does not assume that there is a server . Before blockchain , There's been a lot of distributed ⽹ Collateral system ,⽐ Such as ⼤ Home is very familiar with the electric donkey download 、BT download , interconnection ⽹ In the early days ,⼤ Home is to ⽹ Stop at the server to download , Download the ⼈ More , The speed will be slow , Because of the traffic, or the server is busier , However BT Download this , It did download ⼈ The more , The faster the speed. , Let's not analyze it in detail BT Download the specific technical details , Just from ⽹ In terms of network structure , A distributed ⽹ Collateral structure , Make each node both make ⽤ Service providers are also providers of services , And that's what makes ⼈ More power ⼤ The effect of .

Distributed ⽹ Collateral , primary ⼀ The problem is , How to ensure that the data ⼀ Sexual nature , Some of the data ⼀ To ask for No ⾼⽐ Such as ⽹⻚ resources ,⽂ A service , Early or late doesn't matter ⼤; Some hope to be in ⼀ Within a tolerable time frame ⼀ Cause ,⽐ This is the special coin , It's usually suggested to send ⼀ After this transaction , wait for ⾄ Less 6 Block , The reason is that 6 Two blocks later , The data is basically ⼤ The probability of some nodes receiving is very high ⼤ 了 , also ⼀ That's right ⼀ The request for sex is immediate ,⽐ Like silver ⾏ Settlement , It's impossible to say it's going to take a while , Books can ⼀ Cause , That pair of silver ⾏ It's not acceptable for me to .

For different purposes ⽤ scene , Distributed ⽹ The network will expand differently ,⼤ What we should pay attention to at home is , Distributed ⽹ It's not that there's no center at all , It's about the whole ⽹ The complex is structurally dispersed , A distributed , But it's still possible that each unit will exist in the future ⼼ Of , After all, in some efficiency requirements ⾼ The occasion of , in ⼼ The efficiency of structure is the most ⾼ Of , The two are not opposed to each other ,⽽ It's complementary .

3.2 Data can't be tampered with

We can look back ⼀ Next , When data can be tampered with .
⽐ Such as data management in ⼀ On each server , that ⾃ But it can be tampered with , How to set up authentication and so on , As long as you break in ⼀ Ma Pingchuan ;

Again ⽐ For example, although the data is not available ⼀ On each server , But the validation of the data is ⼀ It's up to the individual ,⽐ Like many of them now ⽹ Station service ,⽐ Such as all kinds of e-commerce ⽹ Stand , what ⾄ Including bank ( Of course , It's not that these systems will be modified at will , this ⾥ It's just a reference ⼀ An example ), The right to manage data lies in ⼀ An administrator ⼿ in , How to change the data doesn't need to get other information ⾃⼰ System verification of control ; The right to record data is in ⼀ An administrator ⼿ in , Similar to the second point ,⾃⼰ The final say ;

How does the blockchain system ensure that the data cannot be tampered with , For the first ⼀ spot , Blockchain systems are distributed , So there is no ⼀ An obvious server target ; Second point , Block data needs to be ⽹ Other nodes in the network verify ,⼤ It's only with the approval of the family that it's recorded in the account book, so that a consensus can be reached , Unless you control most of the nodes , Otherwise, it is unrealistic ;

For the third point , Blockchain system enables ⽤ Various consensus algorithms , The bookkeeping right will not be in the hands of ⼀ home ⼿ in ,⽐ Such as ⽐ The mining algorithm of special currency .

This feature is useful for ⼀ It makes sense to record some public data ,⽐ Such as notarization data ,⽐ Such as crowdfunding accounting , Charity money, etc .

3.3 Enforcement of rules

  • Code is law
  • The execution of smart contract conditions

3.4 Borderless value transfer

Blockchain networks can create a trusted network , Trustworthiness means trustworthiness , And faith Use is the foundation of all financial transmission

The blockchain system can bring its own financial attributes , We can also see through the example of bitcoin , It can transfer money all over the world through the Internet , By this principle , Not only can it pass money , It can also transfer any other digital asset .

Traditional ones like game currency , Game props , The integral of a certain platform, etc , To some extent, it can also transfer value , But it's very difficult to deliver without boundary , And its own credit level is not high , Blockchain ⽹ Collateral ⽆ Borderless , And can maintain ⼀ A trusted network , This constructs a relatively low-cost and widely spread system for the transmission of assets or values ⽹ Network infrastructure .

3.5 Autonomous network system

This is actually a vision for the future , A fundamental model of the programmable society

4. Application scenarios

4.1 Digital token

The currency 、 Wright coin 、 Ethereum and various contract tokens based on Ethereum

4.2 Crowdfunding contracts

It's a smart contract A kind of

4.3 Cross-border payment

Boundaryless value transfer capability and the characteristics of smart contracts , It's very suitable for cross-border payment in finance , The current cross-border payment procedures are complicated , The waiting time is also very long , Efficiency is not high , We can consider establishing a payment system based on blockchain among banks in various countries .

R3 union
swift Apply super original fabric Set up a payment network

4.4 Proof of identity

Use blockchain to build identity management system

4.5 Go to the center to trade

The current case ,Bitshares as well as Openledger
Trading system based on blockchain , Create assets on the chain through Oracle , Running open and transparent transaction logic through code rules

5. Mainstream technology platform

5.1 The currency

The first blockchain system in history , The first cryptocurrency system , Other systems are basically based on bitcoin

5.2 The etheric fang

Digital currency + Intelligent contract , It's a digital currency system , It's also a development platform for smart contracts

5.3 Super ledger

Contains a series of projects
The more famous is fabric, Is a business oriented blockchain system development framework , In fact, it is not a running blockchain system, but a set of development framework , A semi-finished infrastructure for development , By Linux Projects led by foundations .