区块链的嘻哈算法是什么,区块链的嘻哈算法有哪些
区块链技术是一种分布式数据库技术,它利用节点之间的分布式记账来保护网络中的数据,无论是安全性还是可信度都比传统的中心化模式更强。而嘻哈算法是区块链技术的一种重要应用,它是一种新型的共识算法,可以更好地解决区块链系统中的安全性、可信度和可扩展性等问题。
嘻哈算法是一种分布式共识算法,它可以解决区块链系统中的安全性、可信度和可扩展性等问题。它是一种基于证明的共识算法,可以在分布式网络中实现安全的共识。与传统的共识算法相比,嘻哈算法具有更高的安全性和可信度,也更加可靠。
嘻哈算法的拓展有三种:联盟链共识算法、可信网络共识算法和智能合约共识算法。
联盟链共识算法是一种基于嘻哈算法的拓展,它是一种针对特定领域的分布式共识算法,主要用于在特定的联盟成员之间实现共识。它可以实现有效的数据共享和安全的数据存储,可以有效地解决关键业务问题。
可信网络共识算法是一种基于嘻哈算法的拓展,它是一种基于网络的共识算法,它可以利用网络结构来实现共识,可以有效地解决网络安全性和可信度的问题。它可以通过构建一个可信的网络结构来实现安全的数据存储和共享。
智能合约共识算法是一种基于嘻哈算法的拓展,它是一种基于智能合约的共识算法,它可以利用智能合约来实现共识,可以有效解决智能合约的安全性和可信度问题。它可以通过构建智能合约的可信网络结构来实现安全的数据存储和共享。
区块链的嘻哈算法是一种新型的共识算法,它可以解决区块链系统中的安全性、可信度和可扩展性等问题。它的拓展包括联盟链共识算法、可信网络共识算法和智能合约共识算法,可以有效地解决关键业务问题,提高数据安全性和可信度。
请查看相关英文文档
Ⅰ What is the role of the hash algorithm in the blockchain?
The blockchain uses the hash algorithm to encrypt the transaction information in a transaction block and The information is compressed into a hashed string consisting of a sequence of numbers and letters.
Jinwowo Group analyzes the role of its hash algorithm as follows:
The hash value of the blockchain can uniquely and accurately identify a block. Any node in the blockchain can calculate it through a simple hash All have received the hash value of this block, and the calculated hash value has not changed, which means that the information in the blockchain has not been tampered with.
Ⅱ The most straightforward explanation of blockchain
In recent years, the term "blockchain" has become a hot topic, and news media have been reporting on it, but everyone may not be familiar with the concept of blockchain. The understanding of chain is still at the stage of looking at flowers in the fog. Today we will unveil its mystery.
In fact, the essence of blockchain is very simple and can be explained in one sentence: decentralized distributed database.
The main function of the blockchain is to store information. Anyone can write information and read it at the same time, so it is a public database.
Characteristics of blockchain
Distributed database technology has long existed in the market, but the difference is that although blockchain is also a distributed database , but it has no administrator and is completely decentralized.
Decentralization is a disruptive feature of blockchain technology. It does not require a centralized agent and realizes a direct point-to-point interaction, enabling high-efficiency, large-scale, and information interaction without a centralized agent. way becomes reality.
However, without an administrator, everyone can write data into it. How can we ensure that the data is trustworthy? What should I do if I am changed by a bad person? The designers have already thought of this, which proves that blockchain is a truly epoch-making product.
Block
The blockchain is composed of blocks. Blocks are much like database records. Every time data is written, a block is created.
Each block contains two parts:
Block header (Head): records the characteristic value of the current block
Block body (Body): actual Data
The block header contains multiple characteristic values of the current block.
Generation time
Hash of the actual data (i.e. block body)
Hash of the previous block
...
Every time in the system Each node has the latest complete database copy. Modifying the database of a single node is invalid because the system will automatically compare and consider the same data record that appears the most times to be true. At the same time, every step of the data record will be retained on the blockchain, and the information at each step can be traced.
Here, you need to understandWhat is a hash? It is necessary to understand the blockchain.
The so-called "hash" means that the computer can calculate a characteristic value of the same length for any content. The hash length of the blockchain is 256 bits, which means that no matter what the original content is, a 256-bit binary number will be calculated in the end. And it can be guaranteed that as long as the original content is different, the corresponding hash must be different.
For example, the hash of the string 123 is (hexadecimal), which is 256 bits when converted to binary, and only 123 can get this hash. (Theoretically, it is possible for other strings to get this hash, but the probability is extremely low and can be approximately considered impossible.)
Therefore, there are two important inferences.
Corollary 1: The hash of each block is different, and the block can be identified by the hash.
Corollary 2: If the content of the block changes, its hash will definitely change.
The immutability of hashes
Blocks and hashes have a one-to-one correspondence, and the hash of each block is for the "block header" (Head) computational. That is to say, the characteristic values of the block header are connected together in order to form a very long string, and then the hash is calculated on this string.
Hash = SHA256 (block header)
The above is the calculation formula of block hash. SHA256 is the hash algorithm of the blockchain. Note that this formula only includes the block header and not the block body. In other words, the hash is uniquely determined by the block header.
As mentioned earlier, the block header contains a lot of content, including the hash of the current block body and the hash of the previous block. This means that if the content of the current block body changes, or the hash of the previous block changes, it will definitely cause the hash of the current block to change.
This is of great significance to the blockchain. If someone modifies a block, the hash of the block changes. In order for subsequent blocks to still be connected to it (because the next block contains the hash of the previous block), the person must modify all subsequent blocks in sequence, otherwise the modified block will be removed from the blockchain . Due to the reasons mentioned later, hash calculation is very time-consuming, and it is almost impossible to modify multiple blocks in a short period of time, unless someone controls more than 51% of the computing power of the entire network.
It is through this linkage mechanism that the blockchain ensures its own reliability. Once the data is written, it cannot be tampered with. This is just like history, what happened happened, and it can’t be changed from now on.
III What is the hash algorithm in blockchain technology
1.1. Introduction
Practitioners in the computer industry should be very familiar with the word hash.It is known that hashing can map data from one dimension to another. Hash functions are usually used to achieve this mapping. Usually, the industry uses y = hash(x) to represent it. This hash function implements operations on x to calculate a hash value y.
Characteristics of hash functions in blockchain:
Function parameters are string type;
Fixed size output;
Efficient calculation;
collision-free means that the probability of conflict is small: Verification of transactions only requires verifying the information entropy of the transaction, without comparing the original information. There is no need to transmit the original data of the transaction between nodes, only the hash of the transaction. Common algorithms include the SHA series and MD5 algorithms
1.2. Usage of hash
Hash is widely used in blockchain, one of which is called Hash Pointer
Ha The hash pointer means that the value of the variable is calculated based on the actual data and points to the location of the actual data, that is, it can represent both the actual data content and the storage location of the actual data. The picture below is a schematic diagram of Hash Pointer
IV Tutorial for getting started with blockchain
However, there are very few simple and easy-to-understand introductory articles. . What exactly blockchain is and what makes it special is rarely explained.
Next, I will try to write a best-understood blockchain tutorial. After all, it is not difficult. The core concept is very simple and can be explained clearly in a few sentences. I hope that after reading this article, you will not only understand the blockchain, but also understand what mining is, why mining is getting more and more difficult, and other issues.
It should be noted that I am not an expert in this area. Although I have been paying attention to it for a long time, my detailed understanding of blockchain started at the beginning of this year. You are welcome to correct any errors or inaccuracies in the article.
1. The essence of blockchain
What is blockchain? In a word, it is a special distributed database.
First of all, the main function of blockchain is to store information. Any information that needs to be saved can be written to the blockchain and read from it, so it is a database.
Secondly, anyone can set up a server, join the blockchain network, and become a node. In the world of blockchain, there is no central node. Every node is equal and stores the entire database. You can write/read data to any node, because all nodes will eventually be synchronized to ensure that the blockchain is consistent.
2. The biggest features of blockchain
Distributed databases are not a new invention, and there have been such products on the market for a long time. However, blockchain has a revolutionary feature.
Blockchain has no administrator, it is completelycentral. Other databases have administrators, but blockchain does not. If one wanted to add auditing to the blockchain, it would not be possible because it is designed to prevent the emergence of a central authority.
It is precisely because it is unmanageable that blockchain can be uncontrollable. Otherwise, once big companies and large groups control the management, they will control the entire platform, and other users will have to take orders from them.
However, without the administrator, everyone can write data into it. How can we ensure that the data is trustworthy? What should I do if it is modified by bad people? Please read on, this is the wonderful thing about blockchain place.
3. Block
Blockchain is composed of blocks. Blocks are much like database records. Every time data is written, a block is created.
Each block contains two parts.
Head: records the characteristic values of the current block
Body: actual data
The block header contains multiple characteristic values of the current block.
Generation time
Hash of the actual data (i.e. block body)
Hash of the previous block
...
Here, you need to understand what a hash is , which is necessary to understand blockchain.
The so-called hashing means that the computer can calculate a characteristic value of the same length for any content. The hash length of the blockchain is 256 bits, which means that no matter what the original content is, a 256-bit binary number will be calculated in the end. And it can be guaranteed that as long as the original content is different, the corresponding hash must be different.
For example, the hash of the string 123 is (hexadecimal), which is 256 bits when converted to binary, and only 123 can get this hash. (Theoretically, it is possible for other strings to get this hash, but the probability is extremely low and can be approximated as impossible.)
Therefore, there are two important inferences.
Corollary 1: The hash of each block is different, and the block can be identified by the hash.
Corollary 2: If the content of the block changes, its hash will definitely change.
4. The non-modifiable nature of Hash
Blocks and hashes have a one-to-one correspondence, and the hash of each block is calculated based on the block header (Head). That is to say, the characteristic values of the block header are connected together in order to form a very long string, and then the hash is calculated on this string.
Hash = SHA256 (block header)
The above is the calculation formula of block hash. SHA256 is the hash algorithm of the blockchain. Note that this formula only contains the block header and not the block body. In other words, the hash is uniquely determined by the block header.
As mentioned before, the block header contains a lot of content, including the hash of the current block body. , and the hash of the previous block. This means that if the content of the current block body changes, or the hash of the previous block changes, it will definitely cause the hash of the current block to change.The first change of direction.
This point has great significance for blockchain. If someone modifies a block, the hash of the block changes. In order for subsequent blocks to still be connected to it (because the next block contains the hash of the previous block), the person must modify all subsequent blocks in sequence, otherwise the modified block will be removed from the blockchain . Due to the reasons mentioned later, hash calculation is very time-consuming, and it is almost impossible to modify multiple blocks in a short period of time, unless someone controls more than 51% of the computing power of the entire network.
It is through this linkage mechanism that the blockchain ensures its own reliability. Once the data is written, it cannot be tampered with. This is just like history, what happened happened, and it can’t be changed from now on.
Each block is connected to the previous block, which is where the name blockchain comes from.
5. Mining
Since synchronization between nodes must be ensured, the adding speed of new blocks cannot be too fast. Just imagine, you have just synchronized a block and are preparing to generate the next block based on it, but at this time, another node generates a new block, and you have to give up half of the calculations and synchronize again. Because each block can only be followed by one block, you can only generate the next block after the latest block. So, you have no choice but to sync as soon as you hear the signal.
So, the inventor of the blockchain, Satoshi Nakamoto (this is a pseudonym, and his true identity is still unknown) deliberately made it difficult to add new blocks. His design is that on average, the entire network can generate a new block every 10 minutes, which is only six per hour.
This output speed is not achieved through commands, but by deliberately setting up massive calculations. In other words, only through an extremely large amount of calculations can the effective hash of the current block be obtained and the new block added to the blockchain. Because the amount of calculation is too large, it cannot be done quickly.
This process is called mining, because the difficulty of calculating a valid hash is like finding a grain of sand that meets the conditions among the sand in the world. The machine that calculates hashes is called a mining machine, and the person who operates the mining machine is called a miner.
6. Difficulty coefficient
After reading this, you may have a question. People say that mining is difficult, but isn’t mining just about using a computer to calculate a hash? This is the strength of computers. How could it be? It becomes very difficult, why can’t it be calculated?
It turns out that not just any hash can be used, only hashes that meet the conditions will be accepted by the blockchain. This condition is particularly harsh, causing most hashes to fail to meet the requirements and must be recalculated.
It turns out that the block header contains a difficulty coefficient (difficulty), which determines the difficulty of calculating the hash. For example, the difficulty coefficient of the 100,000th block is 14484.16236122.
The blockchain protocol stipulates that the target value (target) can be obtained by dividing the difficulty coefficient by a constant. Obviously, the greater the difficulty coefficient, the smaller the target value.
The effectiveness of the hash is closely related to the target value, only hashes smaller than the target value are valid, otherwise the hash is invalid and must be recalculated. Since the target value is very small, the chance that the hash is smaller than this value is extremely slim, and it may be calculated 1 billion times before it is considered a hit. This is the fundamental reason why mining is so slow.
As mentioned earlier, the hash of the current block is uniquely determined by the block header. If the hash of the same block needs to be calculated repeatedly, it means that the block header must keep changing, otherwise it is impossible to calculate different hashes. All feature values in the block header are fixed. In order to make the block header change, Satoshi Nakamoto deliberately added a random item called Nonce.
Nonce is a random value. The role of the miner is actually to guess the value of Nonce so that the hash of the block header can be smaller than the target value so that it can be written to the blockchain. Nonce is very difficult to guess. At present, we can only use trial and error one by one through exhaustive methods. According to the protocol, Nonce is a 32-bit binary value, which can reach a maximum of 2.147 billion. The Nonce value of the 100,000th block is 274148111. It can be understood that the miner started from 0 and calculated 274 million times before obtaining a valid Nonce value so that the calculated hash can meet the conditions.
If you are lucky, you may find Nonce in a while. If you are unlucky, you may have calculated it 2.147 billion times without finding the Nonce, that is, it is impossible to calculate a hash that meets the conditions for the current block body. At this time, the protocol allows miners to change the block body and start a new calculation.
7. Dynamic adjustment of difficulty coefficient
As mentioned in the previous section, mining is random, and there is no guarantee that a block will be produced in exactly ten minutes. Sometimes it can be calculated in one minute, and sometimes it may take several hours. No result. Overall, with the improvement of hardware equipment and the increase in the number of mining machines, the computing speed will definitely become faster and faster.
In order to keep the output rate constant at ten minutes, Satoshi Nakamoto also designed a dynamic adjustment mechanism for the difficulty coefficient. He stipulated that the difficulty factor should be adjusted every two weeks (2016 blocks). If the average block generation speed in these two weeks is 9 minutes, it means that it is 10% faster than the legal speed, so the next difficulty factor will be increased by 10%; if the average block generation speed is 11 minutes, it means It is 10% slower than the legal speed, so the difficulty factor of the next step must be lowered by 10%.
The difficulty coefficient is adjusted higher and higher (the target value is getting smaller and smaller), which makes mining more and more difficult.
8. Forks of the blockchain
Even if the blockchain is reliable, there is still an unresolved problem: if two people write data to the blockchain at the same time, that is to say, two people write data to the blockchain at the same time. Blocks join because they are connected to the previous block, forming a fork. Which block should be adopted at this time?
The current rule is that new nodes always adopt the longest blockchain. If there is a fork in the blockchain, it will look at which branch is behind the fork to reach 6 new blocks first (called six confirmations). according toOne block is calculated in 10 minutes and can be confirmed in one hour.
Since the generation speed of new blocks is determined by computing power, this rule means that the branch with the most computing power is the authentic blockchain.
9. Summary
Blockchain, as an unmanaged distributed database, has been running for 8 years since 2009 without major problems. This proves it works.
However, in order to ensure the reliability of data, blockchain also has its own price. The first is efficiency. You have to wait at least ten minutes to write data to the blockchain. All nodes synchronize the data, which requires more time. The second is energy consumption. The generation of blocks requires miners to perform countless meaningless calculations. This is Very energy consuming.
Therefore, the applicable scenarios of blockchain are actually very limited.
There is no management authority that all members trust
The written data does not require real-time use
The benefits of mining can make up for its own costs
If the above conditions cannot be met, then the traditional database is Better solution.
Currently, the largest application scenario (and possibly the only application scenario) of blockchain is the cryptocurrency represented by Bitcoin.
IV What are the characteristics of the hash algorithm in the blockchain
The hash algorithm can be viewed as a small computer program, regardless of the size and type of input data However, it can convert input data into fixed-length output. The hash algorithm can only accept the input of a single piece of data at any time and rely on the input data to create a hash value.
There are different hashing algorithms depending on the length of the final hash value.
The cryptographic hash algorithm used in the blockchain has the following characteristics:
1. Able to quickly create hash values for any type of data
2. Deterministic
3. Pseudo-random
4. One-way function
5. Anti-collision
VI What is the blockchain cryptographic algorithm?
Blockchain as an emerging technology It is receiving more and more widespread attention and is a new application of traditional technology in the Internet era, which includes distributed data storage technology, consensus mechanism and cryptography. With the creation of various blockchain research alliances, related research has received more and more funding and personnel support. Hash algorithm, zero-knowledge proof, ring signature and other cryptographic algorithms used in the blockchain:
Hash algorithm
Hash algorithm is the basic technology of the blockchain. The essence of the Hash function is to A set of data of arbitrary length (finite) is mapped into a set of data streams of defined length. If this function satisfies both:
(1) The calculation of the Hash value of any input set of data is very simple;
(2) Think It is computationally difficult to find 2 different data with the same hash value.
Hash that satisfies the above two propertiesThe function is also called a cryptographic Hash function. Unless there is any contradiction, the Hash function usually refers to the cryptographic Hash function. For the Hash function, finding such a value is called a collision. Currently popular Hash functions include MD5, SHA1, SHA2, and SHA3.
Bitcoin uses SHA256, and most blockchain systems use the SHA256 algorithm. So here we will introduce SHA256 first.
1. SHA256 algorithm steps
STEP1: Add padding bits. The message is padded so that the message length is congruent with 448 mod 512 (length = 448 mod 512). The number of padding bits ranges from 1 to 512. The highest bit of the padding bit string is 1 and the remaining bits are 0.
STEP2: Additional length value. Append the bit length of the initial message (before padding) expressed in 64-bit to the result of step 1 (low-order byte first).
STEP3: Initialize the cache. Use a 256-bit cache to store the intermediate and final results of the hash function.
STEP4: Process 512-bit (16 words) message packet sequence. The algorithm uses six basic logic functions and consists of 64 steps of iterative operations. Each step takes a 256-bit cache value as input and then updates the cache content. Each step uses a 32-bit constant value Kt and a 32-bit Wt. Where Wt is the message after grouping, t=1,2,...,16.
STEP5: After all 512-bit packets are processed, the output generated by the last packet of the SHA256 algorithm is a 256-bit message.
2. Ring signature
In 2001, three cryptographers, Rivest, Shamir and Tauman, proposed the ring signature for the first time. It is a simplified group signature, with only ring members and no managers, and does not require cooperation among ring members. In the ring signature scheme, the signer first selects a temporary set of signers, which includes the signer. The signer can then use his own private key and the public keys of others in the signature set to generate signatures independently without the help of others. Members of a set of signers may not be aware that they are included.
The ring signature scheme consists of the following parts:
(1) Key generation. Generate a key pair (public key PKi, private key SKi) for each member in the ring.
(2) Signature. The signer uses his own private key and the public keys of any n ring members (including himself) to generate signature a for message m.
(3) Signature verification. The verifier verifies the signature based on the ring signature and message m.Whether the name is signed by a member of the ring, if it is valid, it is received, otherwise it is discarded.
The properties that ring signatures satisfy:
(1) Unconditional anonymity: The attacker cannot determine which member of the ring generated the signature, even after obtaining the ring member’s private In the case of key, the probability does not exceed 1/n.
(2) Correctness: The signature must be verified by all others.
(3) Unforgeability: Other members in the ring cannot forge the signature of the real signer. Even if an external attacker obtains a valid ring signature, he cannot forge a signature for message m.
3. Comparison between ring signature and group signature
(1) Anonymity. It is a system in which individuals sign on behalf of a group. The verifier can verify that the signature is signed by a member of the group, but cannot know which member, so as to achieve the anonymity of the signer.
(2) Traceability. In group signatures, the existence of the group administrator ensures the traceability of the signature. Group administrators can revoke signatures to reveal the true signer. The ring signature itself cannot reveal the signer unless the signer himself wants to reveal or add additional information to the signature. A verifiable ring signature scheme is proposed. In the scheme, the real signer hopes that the verifier knows his identity. At this time, the real signer can confirm his identity by revealing the secret information he holds.
(3) Management system. Group signatures are managed by the group administrator, while ring signatures do not need to be managed. The signer only has to select a possible set of signers, obtain its public key, and then publish the set. All members are equal.
The Xueshuo Innovation Blockchain Technology Workstation under Lianqiao Education Online is the only approved "Smart Learning Factory 2020- Xueshuo Innovation Workstation" launched by the School Planning and Construction Development Center of the Ministry of Education of China. "Blockchain Technology Professional" pilot workstation. The professional base is based on providing students with diversified growth paths, promoting the reform of the training model integrating professional degree research, production, and research, and building an applied and compound talent training system.
Ⅶ What is the difference between the hash values of currency withdrawals from exchanges and wallet withdrawals
Hash functions play a vital role in the blockchain. Its approach is to encrypt and compress complex transaction information into a simple fixed-byte hash value, which becomes the identifier of the blockchain and ensures that the transaction information in the blockchain is not tampered with. This algorithm is also used in some important links, such as connecting adjacent blocks, building merkle trees, transaction verification, digital signatures, etc.
1. Concept
Hash: Hash, generally translated as "Hash", Or directly transliterated as "Hash", it uses a hash algorithm to convert input of any length into a fixed-length output, and the output is a hash.Value. Simply put, it is a function that compresses a message of arbitrary length into some fixed-length message digest. The hash algorithm and hash function we often say usually mean the same thing.
2. Principle
Based on a one-way hash function in cryptography, y=hash(x) is usually used in the industry express. This hash function can calculate a hash value Y by operating x. This function is easy to verify, but difficult to crack. It is easy to calculate Y from x, but it is difficult to derive x from Y. That is, only Encryption process, no decryption process.
3. Characteristics
(1) The encryption process is irreversible, that is Say we can't deduce what the original plaintext was from the hash value of the output.
(2) The input plaintext and the output hash value are in one-to-one correspondence. Any change in input information will inevitably lead to changes in the final output hash value.
(3) For any size input, the length of the final calculated hash value is small and fixed length.
(4) It is difficult to make the hash value of two plaintexts with different contents the same. That is, it is extremely unlikely that any two different blocks of data will have the same hash value.
4. SHA256 algorithm
Commonly used hash algorithms include MD5, SHA-1, SHA-256, SHA-384 and SHA- 512. In blockchain, the SHA-256 algorithm is commonly used for block encryption. For any message of any length, SHA-256 will generate a 256-bit hash value, which is called the message digest. This abstraction is equivalent to an array of length 32 bytes, usually with length 64 in hexadecimal The string representation is the 64 characters we see.
Blockchain uses this algorithm to encrypt transaction information in a transaction block and convert the compressed information into a hash consisting of a string of numbers and letters (haha Greek) string. The hash value of the blockchain can uniquely and accurately identify a block, and any node can obtain the hash value of this block through simple hash calculation. The calculated hash value is unchanged, which means the information in the block has not been tampered with.
The following is an example of encrypting plaintext into a hash value.
Then change the period to an exclamation point, and the hash value changes completely.
5. Hash Pointer
Hash pointer means that the value of this variable is calculated from the actual data and points to the location of the actual data. That is to say, the hash pointer can represent both the storage location of the actual data and the actual data content (the data hash value of a certain timestamp).
To sum up, looking at the structure of the blockchain from the perspective of hash pointers, it can be said that the blockchain is a linked list that uses hash pointers to connect data blocks in chronological order. The pointer is actually a hash value of a string of data. The hash value of a string of data is the "fingerprint" and abstraction of the string of data, so you can use this hash value to point to this string of data.
Each block in the blockchain has a hash pointer corresponding to its own block. Except for the creation block (i.e. the first block), each other block stores the information of the previous block. hash pointer, thus forming a chain as shown below, that is, a blockchain.
Such a data structure can ensure that the data is not tampered with, because once the data in any block is tampered with, the corresponding hash pointer will be An error will occur, so the hash pointer of the subsequent block cannot match the hash pointer generated by the block after the data is tampered with, so it can be checked out once malicious tampering occurs.
Ⅷ How can a novice understand the hash calculation in the blockchain in seconds
How can a novice understand the hash calculation in the blockchain in seconds
When I was learning about blockchain, I found that there was a word that appeared repeatedly like a ghost, "Hash", written in English as "HASH".
That classmate who said he had diarrhea, get out of here! !
This "hash" is said to be a function derived from cryptography. Try searching and you will find a bunch of papers, either horizontal or vertical, tables or pictures, and another Hei doesn't understand xyzabc. Brother, I just want to understand the basic knowledge of blockchain. Why is it so difficult for me? ! My longest password is 123456, and the more complicated one is 654321. When it is the most complicated, add an a at the end. The complicated password you wrote to me obviously feels like my brain power is being drained, and my only brain cells are dying in batches! In order to let novice students like me understand this, I reluctantly tried to explain hash calculation in a fool's language, not seeking the most accurate but the simplest and easiest to understand. Let’s start:
# 1. What is a hash algorithm
## 1. Definition: A hash algorithm converts a string of any length into a fixed-length character string.
It can be seen from here that it can be understood as giving "hash luck" to **"Calculation" inputs a string of numbers, and it will output a string of numbers**.
If we define the "increment by one algorithm" ourselves, then if we input 1, it will output 2; if we input 100, it will output 101.
/>
If we define the "uppercase algorithm" ourselves, then input "abc" and output "ABC".
Haha, don't hit me yet! This is indeed just a function Concept.
## 2. Features:
What are the characteristics of this hash algorithm compared with my "increment by one algorithm" and "uppercase algorithm"?< br />
1) **Deterministic, fast calculation**: No matter how the calculation result is the same, the calculation efficiency is high.
2) **Irreversible**: It means knowing the output inference The input value is not output.
3) **The result is unpredictable**: Even if the input changes a little, the result will be completely irregular.
In short, this hash operation is A black box is a good helper for encryption! You say "11111" and it encrypts it into "" for you. When you say "11112" it encrypts it into "" for you. Anyway, the input and output are in the sky and the earth. Even if the input is related, the two The outputs are irrelevant.
# 2. Use of hash operations in blockchain
## 1. Data encryption
* *Transaction data is encrypted through hashing and the corresponding hash value is written into the block header**. As shown in the figure below, a block header contains the hash value of the previous block and the hash value of the next block. Hash value.
1), **Identify whether the block data has been tampered with**: The hash value of the blockchain can uniquely and accurately identify a block, and any node in the blockchain can pass Simple hash calculation can obtain the hash value of this block. The calculated hash value has not changed, which means that the information in the blockchain has not been tampered with.
2), * *Connect each block into a blockchain**: Each block contains the hash value of the previous block and the value of the next block, which is equivalent to linking to the hash value of the previous block. The tail of a block is linked to the head of the next blockchain through the hash value of the next block, naturally forming a blockchain with a chain structure.
## 2. Encrypted transactions Address and Hash
In the block header above, there is a hash value of the Merkle root. What is it used for?
First of all, understand what Merkle root is? It is the root of a binary tree structure. What is a binary tree? What is a root? Look at the picture below.knew. One can be divided into two, two can be divided into four, and four can be divided into eight. It is called a binary tree. The root is the topmost node and is called the root.
Where does this root data come from? After the hash value of each transaction in a block is obtained, the hash values are then hashed, and then hashed, and then hashed again, until the top value is reached.
What’s going on after hashing like this for a long time? What does it do?
1), **Quickly locate each transaction**: Since transactions are stored linearly, locating a transaction requires traversal, which is inefficient and time-consuming. Such a binary tree can quickly Locate the deal you are looking for.
To give an inappropriate example: How to find an arbitrary integer between 0-100? (Assuming the answer is 88) A better way is to ask: 1. Is it larger or smaller than 50? 2. Is it larger or smaller than 75? 3. Is it larger or smaller than 88? You can quickly locate the answer with just a few questions.
2), **Verify whether the transaction data has been tampered with**: From the transaction to the hash value of each binary tree, any change in any number will cause the Merkle root value to change. At the same time, if an error occurs, you can quickly locate the error.
## 3. Mining
There is a parameter in our block header called **random number Nonce. The process of finding this random number is called "mining" **! Any machine on the network only needs to find a suitable number to fill in the Nonce position of its own block, so that the hash value of the data in the 6 fields (80 bytes) of the block header is more than 18 Starting with 0, whoever found "the gold"! Since there is no way for us to write a number that satisfies 18 zeros in advance and then infer Nounce, the only way is to try one by one starting from 0 to see if the result meets the requirements. If not, try the next one until it is found.
What are you looking for this number for? What's the use of doing this?
1), **Fairly find the computer with the strongest computing power**: This is a bit like I have a sand here, and let me tell you that it is the same as a grain of sand on that beach, you Find the same ones. The feasible way is to pick up each pill and compare them! Then the person with the fastest speed is most likely to reach the sand first. This is the so-called "proof of work POW". If you find this sand first, I think you will compare the most and do the most work.
2), **Dynamic adjustment of difficulty**: In order to ensure that a block is produced in 10 minutes, Bitcoin will calculate and find this non-block every 2016 blocks (2 weeks).The difficulty of the ce number. If the average time of these 2016 blocks is less than 10 minutes, the difficulty will be increased. If it is more than ten minutes, the difficulty will be decreased. In this way, no matter how the mining computing power of the entire network changes, the random number nonce can be calculated within 10 minutes.
# 3. What are the hash operations?
Having said so many hash operations, it seems that hash operations are just one type, but in fact they are not! As hash operations in cryptography, many schools have been derived from the continuous development. After watching "Man Tou Bao", I still feel that the internal mechanism is too complicated. I will list it as follows for now, so that novices can have an impression and know what is going on.
It can also be seen from the table below that hash operations are also constantly developing. There are various algorithms, and various applications are also flexibly applying single or multiple algorithm. In the Bitcoin system, hash operations basically use the SHA256 algorithm, while Litecoin uses the SCRYPT algorithm. Quark and Dash use many algorithms in series layer by layer. Heavycoin (HAV) However, the following algorithms are connected in parallel, and parts from each are mixed together for use. The POW phase of Ethereum uses the ETHASH algorithm, and ZCASH uses EQUIHASH.
It should be noted that various algorithms for hash operations are constantly being upgraded and improved, and the algorithms used by various currencies are not static and are also being continuously optimized.
**Summary**: Hash operations are widely used in various blockchain projects. Taking Bitcoin as an example, we can see that in **data encryption and transaction data positioning , mining, etc. all play an extremely important role**. As a branch of cryptography, hashing continues to develop and extend. As ordinary novices, if we want to understand some basic concepts of blockchain, understanding this level is enough.
Ⅸ Read this article to understand the cryptography and blockchain theoretical terms you must master in XFS
People’s deep understanding of things is not like “how to put an elephant in the refrigerator” ?" It's as simple as "open the refrigerator, put the elephant in, and close the refrigerator." Everything requires a cognitive process of peeling off the cocoons and breaking them into parts. Especially an emerging concept or thing requires a more detailed understanding.
The XFS system is a distributed file system, but it is not a single framework structure. It is an organic whole that combines cryptography, blockchain, the Internet and other technical means. Therefore, I would like to To understand it in more detail, we must know the concepts of some professional terms.
1. Encrypted network
An encrypted network is simply a public blockchain. Before the birth of blockchain technology, data transmission on the Internet network was actually without any encryption.In terms of means, once a hacker intercepts the data, unless the data itself is ciphertext, the data will be directly exposed to the hacker.
The encrypted network uses blockchain technology and is maintained by each node of the blockchain. Anyone can join without permission. More importantly, the data running in the entire network is encrypted. The XFS system is a typical encrypted network.
2. Hash algorithm
The hash algorithm is a special program in the blockchain to ensure data integrity and security. The hash algorithm uses a mathematical relationship called a "hash function" and the resulting output is called a "cryptographic digest". The characteristic of the encrypted digest is that after inputting data of any length, a unique and fixed-length value is returned.
A hash function has:
Based on these properties, it is also used to be tamper-proof when ensuring cryptographic security, because even small changes to the data input to the hash function will results in completely different output. This has also become the workhorse of modern cryptography and blockchain.
3. Distributed ledger
Blockchain is a distributed ledger, but this ledger can not only record transaction information, but also record any data interaction. Each ledger transaction is an encrypted digest, so entries cannot be changed without detection. This allows blockchain to enable participants to audit each other in a decentralized manner.
4. Private key and public key
Private key and public key are a set of "keys" generated for decryption after the blockchain is encrypted through a hash algorithm. By encrypting the private key, a public key is formed. At this time, the original information can only be viewed through the private key and is saved by the user. The public key is like a house address, which is used for data interaction and can be made public. On the contrary, if the public key is encrypted to form a private key, an immutable digital signature will be formed, because only the owner of the private key can create a signature on this public key.
1. Node
Node is the most basic construction of a blockchain network, and it is also the physical device that connects the blockchain network to reality. A single node has many functions, such as caching data, validating information, or forwarding messages to other nodes.
2. Point-to-point (P2P) network
What the blockchain builds is the data interaction between nodes after decentralization. Traditional Internet data transmission is a client-server-client hub-and-spoke model. A point-to-point network is more consistent with the word "network". In this network, each node runs under a single communication protocol to transmit data between them, avoiding network collapse caused by a single point failure of the server.
3. Consensus verification
The consensus verification of blockchain solves many problemsThe problem of inconsistent opinions among dispersed nodes is based on the philosophical basis of "the minority obeys the majority". In the blockchain network, more node recognition means "consensus". Generally speaking, more than 51 nodes in the blockchain network Those approved by % of the nodes will be adopted and recognized.
4. Replication proof and space-time proof
These two proofs can be collectively called storage proofs in the XFS system. One of the core functions of the XFS system is data storage. Therefore, in order to prove the effectiveness of storage, replication proof is used to verify whether the data exists in the node storage space, and space-time proof is used to verify the persistence in time. If the storage provider can continue to submit storage certificates during the storage validity period, then he will receive rewards provided by the XFS system.
5. Redundancy strategy and erasure coding
These are two ways that XFS uses to balance the amount of data storage. The redundancy strategy backs up data through multiple copies to ensure that data can be retrieved if it is damaged or lost.
Erasure coding ensures that excessive backups will not be generated during data copying and transmission, saving storage space and improving transmission efficiency.
6. File fragmentation protocol
XFS divides the file into N small fragments and stores them in the nodes. As long as there are any M fragments of these fragments, the data can be recovered. In this way, as long as N-M+1 nodes do not fail at the same time, data integrity can be ensured without loss.
7. Smart Contract
The smart contract in XFS is a piece of program code. Since it is generated based on the blockchain, it also inherits the non-tampering, traceability, etc. of the blockchain. Features, it can ensure the certainty of the execution results of both parties, which also makes data interaction in the XFS network more trustworthy.
8. Dapp
It is a decentralized APP, which has a more convenient and faster network access port like an ordinary APP. The only difference is that it abandons the centralization of traditional APPs. characteristics, which makes the data in the Dapp belong to the users themselves, without having to worry about privacy leaks, big data maturity and other issues.
The XFS system is an open platform where users can freely use, design, and create various Dapps.
Conclusion
It is difficult to elaborate on the theoretical terminology in XFS due to space reasons, which involves more Internet and blockchain expertise. But through the above simple explanations, I believe everyone has a more three-dimensional understanding of the XFS system. Then, we look forward to breaking the shortcomings of traditional centralized storage and launching a new generation of XFS distributed file system in a new storage era.