Blockchain circle

One stop hot information platform

About us:

Blockchain circle provides the latest information about blockchain, digital currency, digital wallet, exchange, metauniverse, bitcoin, Ethereum, contract, financial management and so on, and always pays attention to the latest market...

[Sanyan] Introduction to blockchain Technology (II), hash function

Time : 28/02/2022 Author : zpky38 Click : + -
        Hash function is a kind of mathematical operation process, which accepts input values of any size, and can quickly give a fixed length output value after some operation,. Just as for twins, their fingerprints are also unique. The design of hash function makes it have the same characteristics: for example, for a certain output result, what should the corresponding input value be, or what should the output result be less than a certain value, and what should a qualified input value be? There are no skills and methods to solve these problems, Only by constantly trying, the more times you try, the more likely you are to find the answer.
        We can use these features of hash function to achieve many functions. For example, data protection: send the content of the data together with the hash value of the data, and the receiver will hash the received data, and then compare it to know whether the data has been tampered with. For another example, when the website logs in the user, it can store the hash value of the user's password in the database and verify the identity by comparing it with the hash value of the password entered by the user. The advantage is that if the database is leaked, hackers can't reverse deduce the user's password through these hash values, which is relatively safe. It is worth noting that the input set of hash function is infinite, and because the output length is fixed, all possible sets of output are limited. According to the pigeon cage principle: n + 1 elements are put into N sets, and there must be at least two elements in one set.
        Therefore, it must exist theoretically that two different input values have the same hash value, but fortunately, the probability of such a thing happening is very small, and the hash function is constantly improving. SHA1 function has been found an effective attack method by cryptoanalysts. At present, bitcoin and other systems adopt more advanced Sha2 series algorithms, The good operation of bitcoin for many years shows that sha256 algorithm has been tested at least so far. In addition, using hash functions multiple times in a row is also a safer option. Due to the huge content of transaction information to be processed by blockchain, it will be very inefficient and time-consuming to store all the data in each block directly in sequence, but the information can be compressed and verified by using hash function.
        Using Merkle tree can quickly verify whether a transaction belongs to a block. Its simplified schematic diagram is as follows. For all transactions packaged into a block, first divide them into several parts, such as transaction information 1, transaction information 2&hellip in the figure below& hellip; And calculate the corresponding hash value 1, hash value 2 & hellip& hellip; After that, the root hash value of the Merkle tree is finally obtained by combining two hashes. If the data recorded in a transaction information changes, the final calculated Merkle root hash value will also be different.
        So why use such an algorithm instead of directly string all transaction information into a large block and calculate its hash value? The reason is that such a binary tree structure can allow the verification of only a small amount of data. At the same time, if the data information of the transaction is wrong, it can also quickly locate the wrong location. Why is it said that blockchain cannot be tampered with? First, consider a simple hash chain as follows: each packaging contains the hash value of the previous block and the relevant information of this block. If the information of a block is tampered with, the hash values of all blocks will change in the future, and others will also notice this change. But the problem with this design is that anyone can modify the information on a block, recalculate all the information of the remaining chain, and claim that this is the right chain.
        The subtlety of bitcoin design is that it makes such a process expensive. It adopts the consensus mechanism of workload proof, and everyone competes to prove that they have completed a certain workload, and the one who completes it first gets the right to keep accounts. Workload refers to the requirement to find a random number so that the hash value calculated after adding a given string is less than a certain value. In bitcoin, this given string contains the version number, the hash value of the previous block, the transaction information stored in the Merkle root hash value, the timestamp, and the difficulty value. The miners found a random number that met the requirements, which not only "legally" announced their accounting rights, but also encoded the transaction information through the hash function, and stored it in an tamper proof way.
        If someone tries to change the trading information, he must be very lucky to be able to quickly and successfully find the correct random number of each block of the chain in the future, so that the chain after he tampers with the information becomes the longest chain at present. Such a situation may indeed happen in theory, but the probability is relatively small in the case of limited computing power. In the bitcoin transaction, the information you can see is shown in the figure below. The transaction number is in the upper left corner, and the string composed of two letters and numbers connected by the green arrow is the bitcoin address, indicating that bitcoin has been transferred between the two addresses. This address is generated from the public key of the wallet through hash function conversion.
        The public key is a private key composed of random numbers, which is formed by asymmetric encryption. The public key and bitcoin address need to be published publicly during the transaction, so that the blockchain system can verify the effectiveness of the payment transaction. The role of hash function here is quite clever: quantum computers can easily deduce the private key from the public key, but quantum computers are difficult to find two different input values with the same hash value when facing the hash algorithm. It can be said that Nakamoto's design makes it possible for bitcoin to resist the threat of quantum computers through some operations: for example, each bitcoin address is used only once, Each payment is transferred to others' addresses and their own change addresses.
        It can be seen from the above that Nakamoto has made good use of the characteristics of hash function through ingenious design, and finally formed a well functioning system, which involves a variety of interdisciplinary disciplines, and also enlightens us that we need to abstract the essence of a thing in technological innovation and pay attention to the integration with other fields. With the progress of technology, new hash functions are constantly being designed and tested by everyone. The development of hash functions can be said to be "one foot higher, one foot higher, the more progress, the more resistance, and never-ending".
Previous:A number of blockchain companies jointly denounced a certain we media for fabricating false information and claiming to delete the royalties
Next:No more

Related articles:

© 2005-2032 | Blockchain Circle & & All Rights Reserved    Sitemap1 Sitemap2 If there is infringement, please contact us at: