Popular Science | Hash Function Brief

Hash functions are an integral part of blockchain technology and can be used for a variety of purposes. It is a mathematical function that accepts input of any given length and produces a fixed length output. The output is usually called a hash value, a (hash) digest or a hash.

There are many hash functions, just like multiple online "calculators". The calculator allows you to hash any input you like using different kinds of algorithms at the same time. The size of the input can range from a single number to the entire file, but the size of the output will always be the same.

The cryptographic hash function must meet the following set of criteria in order to be used in the blockchain:

Unidirectional – It must be easy to calculate the output of a given input, but it is not possible to calculate the input for a given output. This will be an integral part of the cryptocurrency mining that we will discuss later in this chapter.

Pseudo-random – Input changes will produce unpredictable changes in the output. If the hash value of the input "2" is "4", the hash of the input "3" is preferably not 6.

Anti-collision – Finding the two inputs of the hash function results in the same output should be difficult (cannot be read).

Certainty – the same input always needs to produce the same output.

The most commonly used hash algorithm is SHA-256. SHA is an acronym for Secure Hash Algorithm. This number represents the output length in bits, for example, there are four different output lengths in the SHA series: 224, 256, 384 or 512 bits. Another algorithm related to blockchain technology is the RIPEMD series. RIPEMD160 is often used in many cryptocurrencies because you may have guessed that it produces 160-bit output.

Hash values ​​are used for multiple purposes in cryptocurrency and blockchain. The most significant use is to link blocks together to create a blockchain. We call the hash value a data fingerprint because it is anti-collision. If you want to send the file to someone else, you can include a hash digest when the file is hashed before the file is sent. The recipient can calculate the hash of the file after receiving the file and compare it to the hash value you provide to check the integrity of the file.

Each set of data entered can be easily identified by the unique hash it generates. Finding the two inputs of the hash function is almost impossible, which results in the same output (causing a conflict). It takes thousands of years for all supercomputers on Earth to create conflict. This is because there is no way to "calculate" the conflict. The only way to find one is through the brute force method, where you try different inputs until you happen to collide.

to sum up

The hash function is the first cornerstone of the blockchain technique. The hash of the file is like a fingerprint. It is easy to detect if two files are identical by comparing their hash values. The hash links the "blocks" together. If you do not include a hash of the previous block, you cannot change past data. If you try to change the data, the reference or link will not work.

About Horizen , one for money, information, and media. A secure and private platform.