Blockchain uses asymmetric encryption technology
From the perspective of technology and architecture, I will tell you my understanding of blockchain in common language
what is blockchain? In a word, blockchain is a storage system. To be more specific, blockchain is a distributed storage system without an administrator and each node has all the data
What are the common storage systems like
first, how to ensure high availability
the common storage system usually uses "rendancy" to solve the problem of high availability. As shown in the figure above, if the data can be copied into several copies and rendant to multiple places, high availability can be guaranteed. The data in one place is hung, and there is data in other places. For example, the master-slave cluster of MySQL is the same principle, and the raid of disk is also the same principle
two points need to be emphasized in this place are: data rendancy often leads to consistency problems
1. For example, in the master-slave cluster of MySQL, there is actually a delay in reading and writing, which means there is a inconsistency in reading and writing in a short period of time. This is a side effect of data rendancy
The second point is that data rendancy often reces the efficiency of writing, because data synchronization also consumes resources. If you add two slave libraries, the write efficiency will be affected. The common storage system is to use rendancy to ensure the high availability of dataso the second question, ordinary storage system, can write more
the answer is yes, for example, take this graph as an example:
in fact, MySQL can do a master-slave synchronization of al masters, master-slave synchronization of al masters, two nodes can be written at the same time. If you want to do a multi room multi live data center, in fact, multi room multi live data synchronization. What we should emphasize here is that multi-point writing often leads to the consistency problem of writing conflicts. Take MySQL as an example, suppose that the attribute of a table is self incrementing ID, then the data in the database is 1234 now. If one of the nodes writes and inserts a piece of data, it may become 5, and then these 5 pieces of data are synchronized to another master node, Before synchronization, if another write node inserts a piece of data, a piece of data with self incrementing ID of 5 will be generated. Then, after the generation, synchronize to another node, and the synchronized data will conflict with the two local 5's after it arrives, which will lead to synchronization failure and write consistency conflict. This problem will occur in the case of multi-point writing
how to ensure consistency in multi-point writing
the reform "Swan class" gives you more technical work
in fact, blockchain uses the basic principles of modern cryptography to ensure its security mechanism. The knowledge system involved in the field of cryptography and security is very complicated. Here, I only introce the basic knowledge of cryptography related to blockchain, including hash algorithm, encryption algorithm, information digest and digital signature, zero knowledge proof, quantum cryptography, etc. Through this lesson, you can learn how to ensure the confidentiality, integrity, authentication and non repudiation of the blockchain using cryptography technology
basic course lesson 7 basic knowledge of blockchain security
1. Hash algorithm (hash algorithm)
hash function (hash), also known as hash function. Hash function: hash (original information) = summary information. Hash function can map any length of binary plaintext string to a shorter (generally fixed length) binary string (hash value)
a good hash algorithm has the following four characteristics:
1. One to one correspondence: the same plaintext input and hash algorithm can always get the same summary information output
2. Input sensitivity: even if the plaintext input changes slightly, the newly generated summary information will change greatly, which is greatly different from the original output
3. Easy to verify: plaintext input and hash algorithm are public, anyone can calculate by themselves, and whether the output hash value is correct
4. Irreversibility: if there is only the output hash value, the hash algorithm can never dece the plaintext
5. Conflict avoidance: it is difficult to find two plaintexts with different contents, but their hash values are the same (collision)
for example:
hash (Zhang San lent Li Si 100000 yuan for 6 months) = 123456789012
such a record as 123456789012 is recorded in the account book
it can be seen that hash function has four functions:
simplify information
it is easy to understand, and the information after hashing becomes shorter
identification information
you can use 123456789012 to identify the original information, and summary information is also called the ID of the original information
hidden information
the account book is a record like 123456789012, and the original information is hidden
verification information
if Li Si cheated that Zhang San only lent Li Si 50000 when repaying, both parties can verify the original information with the hash value of 123456789012 recorded before
hash (Zhang San lent Li Si 50000 for 6 months) = 987654321098
987654321098 is completely different from 123456789012, which proves that Li Si lied, Then the information can't be tampered
common hash algorithms include MD4, MD5 and Sha series algorithms, and Sha series algorithms are basically used in mainstream fields. Sha (secure hash algorithm) is not an algorithm, but a group of hash algorithms. At first, it was SHA-1 series, and now the mainstream applications are sha-224, SHA-256, sha-384 and sha-512 algorithms (commonly known as SHA-2). Recently, Sha-3 related algorithms have been proposed, such as keccak-256 used by Ethereum
MD5 is a very classic hash algorithm, but unfortunately, both it and SHA-1 algorithm have been cracked. It is considered by the instry that its security is not enough to be used in business scenarios. Generally, sha2-256 or more secure algorithm is recommended
hash algorithm is widely used in blockchain. For example, in blocks, the latter block will contain the hash value of the previous block, and the content of the later block + the hash value of the previous block will jointly calculate the hash value of the later block, which ensures the continuity and non tamperability of the chain< Encryption and decryption algorithm is the core technology of cryptography, which can be divided into two basic types: symmetric encryption algorithm and asymmetric encryption algorithm. According to whether the key used in the encryption and decryption process is the same or not, the two modes are suitable for different needs, just forming a complementary relationship, and sometimes can be combined to form a hybrid encryption mechanism
symmetric cryptography (also known as common key cryptography) has the advantages of high computational efficiency and high encryption strength; Its disadvantage is that it needs to share the key in advance, which is easy to leak and lose the key. The common algorithms are des, 3DES, AES and so on
asymmetric cryptography (also known as public key cryptography) is different from the encryption and decryption key, and its advantage is that it does not need to share the key in advance; Its disadvantage is that it has low computational efficiency and can only encrypt short content. Common algorithms include RSA, SM2, ElGamal and elliptic curve series. Symmetric encryption algorithm is suitable for the encryption and decryption process of a large number of data; It can't be used in signature scenario: and it often needs to distribute the key in advance. Asymmetric encryption algorithm is generally suitable for signature scenario or key agreement, but it is not suitable for large amount of data encryption and decryption< Third, information digest and digital signature
as the name suggests, information digest is to hash the information content to obtain a unique digest value to replace the original and complete information content. Information digest is the most important use of hash algorithm. Using the anti-collision feature of hash function, information digest can solve the problem that the content has not been tampered
digital signature is similar to signing on paper contract to confirm contract content and prove identity. Digital signature is based on asymmetric encryption, which can be used to prove the integrity of a digital content and confirm the source (or non repudiation)
we have two requirements for digital signature to make it consistent with our expectation for handwritten signature. First, only you can make your own signature, but anyone who sees it can verify its validity; Second, we want the signature to be only related to a specific file and not support other files. These can be achieved by our asymmetric encryption algorithm above
in practice, we usually sign the hash value of information instead of the information itself, which is determined by the efficiency of asymmetric encryption algorithm. Corresponding to the blockchain, it is to sign the hash pointer. In this way, the front is the whole structure, not just the hash pointer itself< Zero knowledge proof means that the verifier can make the verifier believe that a certain conclusion is correct without providing any additional information to the verifier
zero knowledge proof generally meets three conditions:
1. Completeness: authentic proof can make the verifier successfully verify
2. Soundness: false proof can not make the verifier pass the verification
3. Zero knowledge: if you get proof, you can't get any information other than the proof information from the proof process< With more and more attention paid to the research of quantum computing and quantum communication, quantum cryptography will have a huge impact on the information security of cryptography in the future
the core principle of quantum computing is that qubits can be in multiple coherent superposition states at the same time. Theoretically, a large amount of information can be expressed by a small number of qubits and processed at the same time, which greatly improves the computing speed
in this way, a large number of current encryption algorithms are theoretically unreliable and can be cracked, so the encryption algorithm has to be upgraded, otherwise it will be broken by quantum computing
as we all know, quantum computing is still in the theoretical stage, which is far from large-scale commercial use. However, the new generation of encryption algorithms should consider the possibility of this situation.
Digital encryption technology is the key to the application and development of blockchain technology. Once the encryption method is cracked, the data security of the blockchain will be challenged, and the non tamperability of the blockchain will no longer exist
recently, Xunlei, Renren and other Internet enterprises have applied blockchain technology to their own technology or proct system, and Meitu has also recently posted the information of recruiting senior blockchain architects. In the U.S. stock market, Xunlei, Renren, Meitu and other companies ushered in a surge
1. Lianzhuang data block structure based on blocks
2. Network wide shared ledger
3. Asymmetric encryption
4. Source code open source
blockchain 2.0 era technical basis:
1. Smart contract; It is an application in the blockchain system. It is a business logic that can run automatically by coding. It usually has its own token and special development language
2. DAPP: it includes the user's applications, including but not limited to various cryptocurrencies, such as Ethereum wallet
3. Virtual machine: used to execute the compiled code of smart contract. Virtual machine is Turing complete
with the application and deepening of blockchain technology, the era of blockchain 3.0 has come. The mode of blockchain cooperation can be seen from behind the operation of all walks of life. Therefore, blockchain will change the way of human life widely and profoundly, so the whole life service will enter the era of blockchain. In the process of Internet development, blockchain + physical instry, blockchain e-commerce and blockchain community operation can be applied to blockchain technology
of course, 3.0 came into being with the development of modern cryptography. Today's applied cryptography is the result of cryptography 20 years ago. Therefore, in order to apply blockchain technology to more participation scenarios, especially in Internet economy and other aspects, more verification is needed to verify whether the existing encryption technology can meet the demand, and more in-depth integration of cryptographic frontier technology and continuous innovation are needed.
asymmetric encryption algorithm is a function that converts the original plaintext file or data into a series of unreadable ciphertext codes by using an encryption key. The encryption process is irreversible. Only holding the corresponding decryption key can the encrypted information be decrypted into readable plaintext. Encryption enables private data to be transmitted through the public network under the condition of low risk, and protects the data from being stolen and read by the third party
the core advantage of blockchain technology is decentralization, which can realize point-to-point transaction, coordination and cooperation based on decentralized credit in a distributed system without mutual trust by means of data encryption, time stamp, distributed consensus and economic incentive, so as to solve the high cost and low cost of centralized institutions Low efficiency and data storage insecurity provide solutions
the application fields of blockchain include digital currency, token, finance, anti-counterfeiting traceability, privacy protection, supply chain, entertainment, etc. with the popularity of blockchain and bitcoin, many related top domain names have been registered, which has a great impact on the domain name instry.
The way in which people keep accounts together is also known as "distributed" or "decentralized", because everyone keeps accounts, and the accuracy of the account book is determined by the program algorithm, not by an authoritative organization
this is the blockchain, the core is finished, blockchain is so simple, a common account book
six core algorithms of blockchain Technology:
blockchain core algorithm 1: Byzantine agreement
the story of Byzantine is like this: the Byzantine Empire has great wealth, and the surrounding 10 neighbors have been around for a long time, but the Byzantine walls stand tall and firm, No single neighbor has been able to successfully invade. Any single neighbor's invasion will fail, and at the same time, it may be invaded by other nine neighbors. Byzantine Empire's defense ability is so strong that at least more than half of its ten neighbors attack at the same time before it can be broken. However, if one or several of the neighbors agree to attack together, but betray in the actual process, then the invaders may be annihilated. So each side was careful and could not easily trust its neighbors. This is the question of Byzantine Generals
blockchain core algorithm 2: asymmetric encryption technology
in the above Byzantine agreement, if several of the 10 generals send messages at the same time, it is bound to cause confusion in the system, resulting in different attack time schemes and inconsistent actions. Anyone can send the message of attack, but who will send it? In fact, it only needs to add a cost, that is, only one node can spread information in a period of time. When a node sends a unified attack message, each node must sign and seal to confirm its identity when receiving the message from the initiator
blockchain core algorithm 3: fault tolerance problem
we assume that in this network, messages may be lost, damaged, delayed and sent repeatedly, and the order of receiving is inconsistent with the order of sending. In addition, the behavior of nodes can be arbitrary: they can join or exit the network at any time, they can discard messages, forge messages, stop working and so on, and they may also have all kinds of human or non-human failures. Our algorithm provides fault tolerance for consensus system composed of consensus nodes, which includes both security and availability, and is suitable for any network environment
blockchain core algorithm 4: Paxos algorithm (consistency algorithm)
the problem solved by Paxos algorithm is how a distributed system can reach an agreement on a certain value (decision). A typical scenario is that in a distributed database system, if the initial state of each node is consistent, and each node performs the same operation sequence, then they can finally get a consistent state. In order to ensure that each node executes the same command sequence, it is necessary to execute a "consistency algorithm" on each instruction to ensure that the instructions seen by each node are consistent. A general consistency algorithm can be applied in many scenarios, which is an important problem in distributed computing. There are two models of node communication: shared memory and message passing. Paxos algorithm is a consistency algorithm based on message passing model
blockchain core algorithm 5: consensus mechanism
blockchain consensus algorithm is mainly workload proof and equity proof. Take bitcoin as an example. In fact, from a technical point of view, POW can be regarded as a reusable hashcash, and the generation workload proves to be a random process in probability. When mining a new secret currency and generating a block, the consent of all participants must be obtained, and the miner must obtain the pow work proof of all data in the block. At the same time, miners have to constantly observe and adjust the difficulty of this work, because the requirement for the network is to generate a block every 10 minutes on average
blockchain core algorithm 6: distributed storage is a kind of data storage technology, which uses the disk space of each machine through the network, and forms a virtual storage device with these scattered storage resources, and the data is stored in every corner of the network. Therefore, distributed storage technology does not store complete data in each computer, but stores the data in different computers after cutting. It's like storing 100 eggs, not in the same basket, but separately in different places. The total number is 100. Want to learn more, you can make more use of network search, network search results - small knowledge
In today's era of high development of the Internet, we are using the Internet more and more frequently, which has become an indispensable and important tool in our life. In particular, the mobile phone used for Internet communication has been used as a medium. In today's era, we are using mobile payment more and more, There are more and more ways to move. So what is digital currency? What do you know about it{ But generally speaking, it is a form of money< p> Finally, for such a form of transaction, it's all for the convenience of our daily life, and it's also for serving our own broad masses of people, so we don't have to worry about the advantages and disadvantages of digital currency and mobile payment
Take subway line 1, transfer to line 2 at people's Square Station, get off at Century Avenue station, and then transfer to line 6
the line identification color of Shanghai Rail Transit Line 6 is magenta
development information: Shanghai Metro Line 6 runs through the whole Pudong New Area, starting from Gangcheng road of Gaoqiao Town in the north and reaching Sanlin area in the south, and is operated by Shanghai Metro No.4 Operation Co., Ltd
Shanghai Rail Transit Line 6 is based on the rail transit network fare system approved by the municipal price department, that is, the multi-level fare based on mileage is implemented for rail transit, which is 3 yuan for 0-6 km, and 1 yuan for every 10 km after 6 km. The fare calculation of line 6 adopts the shortest route method, that is, when there is more than one transfer route between two stations, the shortest route is selected as the basis for fare calculation between two stations
about 110m
Metro Line 1 - (Gongfu Xincun Xinzhuang)
starting point: Shanghai Circus City
0.9km
destination: Yanchang Road
walking to 42, Lane 1700, Gonghexin Road, Zhabei District, Shanghai
about 192m
In Shanghai Metro, the ticket price is calculated according to the shortest distance from the starting station to the terminal station in all exchange multiplication
for people who have a traffic card, no matter how they transfer from one station to another, the ticket price is the same. For people who do not have a traffic card but use one-way ticket, there are only three different stations at this stage, that is, line 1 of Shanghai railway station changes to line 3 / 4, line 3 of Hongkou Football Stadium changes to line 8, and line 4 of Yishan Road changes to line 3 / 9, If you use a one-way ticket, you have to go out of the station and then buy a ticket to enter the station. For all stations except these three stations, you need to transfer in the station and do not need to go out and buy a ticket again
Shanghai Metro can enter the station by using the all-in-one card or the disposable magnetic card purchased from the window machine
if you use the traffic card, you can transfer directly in the station. When you leave the station, you can automatically dect the fee from the balance of the traffic card according to the distance between the exit and the entrance
If a one-time ticket is used, it is better to confirm the exit before buying the ticket, and then buy the ticket according to the price given by the automatic ticket purchasing machine. When you transfer in the station, you don't need to buy a ticket. You can transfer directly and recycle the one-time ticket when you leave the station
if the cost exceeds the ticket value, you need to go to the manual guard box at the exit to make up the ticket