Hash function refers to a kind of mathematical operation process. 해시게임 It accepts input values of any size. Hash Functions: The Digital Fingerprint of Blockchain Hash Future.

After some operations, it can quickly give a certain output value of a fixed length.

### This output value can be used as the digital fingerprint of the input value.

Just as twins have unique fingerprints,

hash functions are designed to have the same properties:

even very small differences in input values can result in very large differences in the results of the hash function.

In addition, the hash function does not have any heuristic algorithm,

and the relationship between input and output looks completely random.

For example, given a certain output result, the corresponding input value is required to be,

### or the output result is required to be less than a certain value. value,

and ask what a qualified input value should be.

There are no skills and methods to solve these problems.

You can only try constantly.

The more times you try, the more likely you will find the answer.

There are many things we can do with these properties of hash functions.

For example, in data protection: the content of the data and the hash value of the data are sent together,

the receiver performs a hash operation on the received data, and the comparison can be used to know whether the data has been tampered with.

For another example, when a website is logging in a user,

it can store the hash value of the user’s password in the database, and compare

### it with the hash value of the password entered by the user to verify the identity.

The advantage is that if the database is leaked,

hackers cannot pass these It is relatively safe to deduce the user’s password by using the Greek value.

It is worth noting that the input set of the hash function is infinite,

and because the output length is fixed, all possible sets of the output are limited.

According to the pigeon cage principle: n + 1 elements are put into n sets, which must be There is a set with at least two elements.

### Therefore, it is theoretically possible for two different input values to have the same hash value,

but fortunately, the probability of such a thing happening is very small,

and the hash function is constantly improving. The SHA1 function was once discovered by cryptanalysts.

In order to find an effective attack method,

the current system including Bitcoin adopts a more advanced SHA2 series algorithm,

and the good operation of Bitcoin for many years shows that at least so far the SHA256 algorithm has been tested.

Also, using the hash function multiple times in a row is a safer option.

## The hash function is used in many places in Bitcoin,

## and it can be said that it plays a very crucial role. Hash Functions: The Digital Fingerprint of Blockchain Hash Future

- Compress and verify transaction information
- Due to the huge amount of transaction information to be processed by the blockchain,
- it would be very inefficient and time-consuming to store all the data in each block directly in a sequence,
- but the information can be compressed and verified by using a hash function.
- Using the Merkle tree can quickly verify whether a transaction belongs to a certain block.
- Its simplified schematic diagram is as follows.
- For all transactions packaged into a block, first divide them into several parts, as shown in the following figure.
- Transaction information
- 1. Transaction information
- 2… and calculate the corresponding hash value 1, hash value 2… After that, the hash operation is performed in combination with each other,
- and finally, the root hash value of the Merkle tree is obtained. If the data recorded in a certain transaction information changes,
- the final calculated Merkle root hash value will also be different.

Figure 1 Merkle tree in Bitcoin

### So why use such an algorithm, instead of directly stringing all the transaction information into one big block and hashing it?

### The reason is that such a binary tree structure can allow only a small amount of data to be verified,

### and at the same time if the data information of the transaction is wrong,

### it can quickly locate the wrong position. Hash Functions: The Digital Fingerprint of Blockchain Hash Future

- Used for proof of work to form a consensus
- Why do they say that the blockchain is immutable?
- First, consider a simple hash chain as follows: each time it is packaged, it contains the hash value of the previous block and the relevant information of this block.
- If the information of a certain block is tampered with, the hash value of all subsequent blocks will be tampered with.
- There will be a change, and others will notice the change.
- But the problem with this design is that anyone can modify the information on a block,
- recalculate all the information on the remaining chain, and claim that this is the correct chain.

The subtlety of Bitcoin’s design is that it makes such a process expensive to implement.

It adopts the consensus mechanism of proof of work, and everyone competes to prove that they have completed a certain amount of work,

### and the first to complete the work gets the right to book.

The workload refers to the requirement to find a random number such that the hash value calculated after adding a given string is less than a certain value.

In Bitcoin, the given string contains the version number, the hash of the previous block,

the transaction information stored in the Merkle root hash, the timestamp, and the difficulty value.

When miners find random numbers that meet the requirements, they not only “legally” declare their accounting rights,

### but also complete the encoding of transaction information through a hash function and store them in an immutable manner.

If someone tries to change the transaction information,

he must be very lucky to be able to quickly and successfully find the correct random number of each block in the chain,

so that the chain after he tampered with the information becomes the current longest chain,

such as The situation is theoretically possible,

but in the case of limited computing power, the probability is relatively small.

- 3 used to generate a bitcoin wallet address
- In the Bitcoin transaction, the information that everyone can see is as follows,
- the upper left corner is the transaction number, and the string of two letters and numbers connected by green arrows is the Bitcoin address,
- indicating that Bitcoin is between the two addresses.
- With transfer. This address is generated by converting the wallet’s public key through a hash function.
- The public key is a private key composed of random numbers formed by asymmetric encryption.
- Both the public key and the bitcoin address need to be publicly released during the transaction so that the blockchain system can verify the validity of the payment transaction.

## Figure 2 Schematic diagram of Bitcoin transfer Hash Functions: The Digital Fingerprint of Blockchain Hash Future

The role played by the hash function here is quite clever:

a quantum computer can easily deduce the private key from the public key,

but it is difficult for a quantum computer to find two different input values with the same hash value when faced with a hash algorithm.

it can be said that this design of Satoshi Nakamoto makes it possible for Bitcoin to resist the threat of quantum computers through some operations:

for example, each Bitcoin address is only used once,

### and each payment is transferred to someone else’s address and its own change address middle.

It can be seen from the above that Satoshi Nakamoto made good use of the characteristics of the hash function through ingenious design,

and finally formed a well-functioning system,

which involved a variety of interdisciplinary disciplines, and also revealed that we need abstraction in technological innovation.

To find out the essence of a thing, pay attention to the integration with other fields. With the advancement of technology,

new hash functions are constantly being designed and tested by everyone. never-ending”.