justry_ deng 2022-01-14 15:39:38 阅读数:640
Tips : The currency , Just by using
Blockchain Technology
YesE-cash ( Digital currency ) System
Just the realization of .
2008 year 11 month 1 Japan , Nakamoto
Published papers describe a new E-cash ( Digital currency ) System
—— The currency . From the perspective of technicians , To achieve a E-cash ( Digital currency ) System
Is to achieve a Account book
. To put it simply , Electronics cash ( Digital currency ) System
It's the ledger .
We know , Like RMB 、 Currencies such as the US dollar can only be accepted by the people under the endorsement of a powerful national machine , And circulating in daily production and life . Obviously , Bitcoin is not endorsed by any country or institution , Nakamoto
The challenge is how to use technical means to endorse the bitcoin it releases .
Nakamoto wants to realize bitcoin , Or to say ** Implement an e-cash system
( From the perspective of technicians , namely To achieve an account book
), We need to solve the following four problems :**
The ledger cannot be tampered with .
The ledger cannot be lost or damaged .
Prove that you are .
The same money , Can't spend 2 Times or times ( namely : There can be no double flower problem ).
Double flower problem description : For paper money , When paper money comes from A Give to the B when , The whole deal is over ; But there are some differences for digital money , hypothesis A Yes 10 Bitcoin , He chose to transfer all the money to B, When the transaction is executed on the network but has not been confirmed , He chose to give C turn 10 Bitcoin , For the system , Both transactions are legal , Can be broadcast to the network through authentication , But actually , This is obviously problematic , This is the double flower problem ( Double flower attack ).
In short , Distributed ledger , namely : The ledger allows multiple people to keep accounts at the same time , That is, the ledger keeps multiple backups . So you don't have to worry about the loss or damage of the ledger , At the same time, it also makes the account book less easy to be tampered with , Because the ledger is backed up in many places , What anyone can directly modify is the local ledger , In case of disagreement of other account book depositors , Can't change the overall ledger , In other words, its modification is not recognized by others .
Prove that you are , The original meaning of this sentence is A The balance of the account can only be A To manage ,A You can choose transfer or other transactions , But when making these deals ,A You must prove that this account is his . Obviously , use cryptography Knowledge , Design digital signature You can do that . There are two requirements for the details of digital signature :
The blockchain technology we often refer to generally refers to digital currency technology , there
Blockchain data structure
It refers to the specific structure for storing data .notes : Because so far 2021-08-08, Blockchain technology is still the only known and relatively reliable implementation of digital currency technology , Therefore, blockchain technology is used to refer to digital currency Technology , It includes cryptography 、 The Internet 、 Data structure, etc .
Nakamoto's solution to the double flower problem is very simple , Is to design a Strong temporal data structure ( This is the blockchain structure )
. He packaged several transactions to form a block block , And impose constraints : When there are two or more transactions in the double flower attack in the same block Time in block , The block The block will be verified as illegal
, In the end, only one of the two transactions can be packaged into block block . Then the system hangs the newly generated block behind the previously generated block , In this way, a linked list structure is formed as a whole . Transactions that have been packaged in blocks are confirmed by the system , At this time, there is no problem when you receive the second transaction in the double flower attack , System ( Considering the previous transaction volume ) Confirm the balance of the current transaction , If the balance is insufficient , Then the system will recognize the current transaction as illegal .
This constant collection of transactions is packaged into pieces , Then hang it on the previous block to form a structure , Is called chain of blocks
, Later, it was called blockchain( Blockchain )
.
SHA-256 Algorithm hash function :y=hash(x), For different inputs x, You can get a fixed length (256bit) It's binary y value .
hash Characteristics of functions :
Anti collision
Not to say that hash It is absolutely anti-collision , It's just that the probability of collision is very low , So I think hash It can prevent collision .
give an example : When hash And what you get is 22 Characters long ,300 In trillions of calculations , The probability of collision 1000 1/100000000 . With hash The increase of value space , This probability will be lower ,SHA-256 Of hash The value is actually a 64 Bit string . So we use SHA-256 Algorithm hash function , We think it is anti-collision at this level .
Information hiding
y=hash(x) in , You can go through x obtain y, But it's hard for you to pass y obtain x.
notes : In the blockchain network , Each user will get a public key and private key when applying for an account , The private key is used to indicate your management right of this account , The public key is passed by using the private key
Elliptic curve algorithm secp256k1
Encryption generated , And this algorithm is also irreversible . The bitcoin address we often see is passed by the public key 2 Time hash Get a string , This also well protects the information of the public key itself .
Easy to solve problems
Tips : Mentioned in the blockchain field hash Functions refer to specific SHA-256 The algorithm supports hash function .
We mentioned earlier that the blockchain data structure is a block by block linked list , It is also mentioned that the formation is through the latter block Hang the block to the previous block Formed on a block , But I didn't mention how to hang it , actually , Hang this action through hash Functionally implemented
.
For each block, you need to fill in hash value , This hash The input values include :
P2P The Internet , That is to say peer to peer The Internet .
P2P The network first came from Napster, This is a free service for users MP3 Downloaded Web Services .Napster The server does not store MP3 file , But it has an index server , To record what each user has MP3 Song list information , So when users need to download , You can directly find the corresponding host, establish a connection and download files .
When Nakamoto invented bitcoin , Also standing on the shoulders of predecessors . Every new node in the network , Through the built-in nodes DNS The seed node queries the network IP list , Some seed nodes return a set of statically reliable bitcoin nodes IP, Some seed nodes return dynamic bitcoin nodes IP Set . New node selection 8 Connect nodes , And compare each other , Synchronize blockchain data . If there is a new transaction , A node sends a transaction broadcast to all its neighboring nodes , Then continue to broadcast to lingju , Until the whole network receives the transaction information .
What is a consensus algorithm
The blockchain system adopts decentralized design , Network nodes are scattered and independent , Therefore, systems composed of different nodes must rely on a system to maintain the data consistency of the system , And reward nodes providing blockchain services , And punish malicious nodes . The establishment of this system depends on a set of methods and rules , That is, who gets the packaging right of a block ( Or bookkeeping right ), And get the reward of the block or how to define who is the perpetrator , How to punish him , This set of methods and rules is the consensus algorithm ( Consensus mechanism ).
Common consensus algorithms
PoW
: Proof of workload (Proof of Work) Algorithm PoS
: Proof of interest (Proof of Stake) Algorithm DPoS
: Share authorization certificate (Delegated Proof of Stake) Algorithm PBFT
: Practical Byzantine fault tolerance (Practical Byzantine Fault Tolerance) Algorithm RAFT
: Consensus algorithm UTXO namely Unspent Transaction Outpou, Transaction output not spent .
Bitcoin system doesn't really exist " Account ", And only " Address ". This address is mentioned above , Pass through with a public key 2 Time hash Calculated address . Only those who master the private key can master the address , You can use the... In this address " balance ".
A person's bitcoin balance actually depends on how many bitcoins are contained in his address , The way to calculate the number of bitcoins or its data structure is called UTXO.
^_^ Collated from 《Go Language blockchain application development from entry to mastery 》 Takano Huang,
^_^ This article has been included in 《 Programmer growth notes 》 , The author JustryDeng
版权声明:本文为[justry_ deng]所创,转载请带上原文链接,感谢。 https://netfreeman.com/2021/12/202112122019390390.html