A hash is the result of a hash function, which is a cryptographic operation that generates unique and unrepeatable identifiers from a given information. Hashes are a key piece of blockchain technology and are widely used.

Ethe name of hash is used to identify a cryptographic function very important in the computer world. These functions are primarily intended to encode data to form a unique character string. All this regardless of the amount of data initially entered in the function. These functions serve to ensure data authenticity, securely store passwords, and sign electronic documents.

Hash functions are widely used in technology blockchain in order to add security to them. Bitcoin is a clear example of how hashes can be used to make possible the technology of cryptocurrencies.

History of Hash functions

The appearance of the first hash function dates from the year 1961. Back then Wesley peterson created the function Cyclic Redundancy Check. It was created to check how correct the data transmitted on networks (such as the Internet) and on the digital storage system were. Easy to implement and very fast, it gained acceptance and is today an industry standard. With the evolution of computing and computers, these systems became increasingly specialized.

This allowed creating new and better hash functions, among which we can highlight:

  1. MD2: It is one of the first cryptographic hash functions. Created by Ronald rivest, In the year of 1989. With a high level of efficiency and security for the moment, it was essential in Internet security. Its consequent evolution led to the creation of the hash function MD5. Which is still used in environments where safety is not a high priority.
  2. RIPEMD: is a cryptographic hash function created by the European project RIPE In the year of 1992. Its main function was to replace the current standard, the hash function MD4. Currently it is still considered very safe, especially in its versions. RIPEMD-160RIPEMD-256 y RIPEMD-320.
  3. SHA: the current standard for cryptographic hashes. Created by the NSA en 1993, as part of its internal project to authenticate electronic documents. SHA and its derivatives are considered the most secure hash functions so far. It is of special interest, SHA-256 for being fundamental in the technology that made Bitcoin possible.

Hash functions - How do they work?

Hash functions work thanks to a series of complex mathematical and logical processes. These processes are transferred to computer software in order to use them from the computer itself. From there, we can take any data series, enter it in the function and process it. This seeks to obtain a character string of fixed and unique length for the data entered. At the same time, it is practically impossible to carry out the opposite process. In other words, it is practically impossible to obtain the original data from an already formed hash. This is because the process of creating hashes is a one-way process.

A simple and everyday example of this process would be; making a cake. Each of the cake ingredients would be the equivalent of the data entry. The process of preparing and cooking the cake would be the process of encoding said data (ingredients) by the function. At the end, we obtain a cake with unique and unrepeatable characteristics given by its ingredients. While the opposite process (bringing the cake to its initial ingredient state) is practically impossible.

A visual example of the process can be shown using the MD5 and SHA-256 functions, in two different use cases.

  • Example of how to encode an MD5 function
  • Example of how to encode a SHA-256 function

A closer explanation

Observing both use cases we can notice the following:

The first data entry results in a unique hash, for the cases of MD5 and SHA-256. Results that are adjusted to the reality of each of these functions. In the second entry, a small modification has been made to the text. This although it is minimal, completely altered the result of the hashes for MD5 y SHA-256.

This proves that the hashes will be unique in any case. Which allows us to be sure that no malicious actor can easily force hashes. Although achieving this is not impossible, a hacker could spend hundreds of years processing data to accomplish its goal.

It is these two observations that give us the security of using this method in different sensitive areas. Digital certificates, unique signatures of sensitive or secret documents, digital identification and key storage are some use cases. But it does not stop there, since the flexibility and security of this technology makes it ideal in many areas.

Features of hash functions

Among the main characteristics of the hash functions, the following can be mentioned:

  1. They are easy to calculate. Hashing algorithms are very efficient and do not require large computing power to run.
  2. It is compressible. This means that regardless of the size of the data input, the result will always be a fixed-length string. In the case of SHA-256, the string will be 64 characters long.
  3. Avalanche type operation. Any slight change in data entry results in a different hash than the original data entry.
  4. Weak and strong resistance to collisions. It refers to the fact that it is impossible to calculate a hash, which allows finding another equal hash. Better known as pre-image y second preimage, is the basic concept of hash security.
  5. They are irreversible. Taking a hash and obtaining the data that gave rise to it, in practice it may not be possible. This is one of the principles that make hashes safe.

Security level of hash functions

The current hash functions have a high level of security, although this does not mean that they are infallible. A good example of this is; the MD5 hash function. In principle, the specifications of the same promised a very high security. Its use spread on the Internet due to the need for a hashing system to maintain its security. But in 1996, the security of the function could be broken. This made it obsolete and it was recommended to abandon its use.

On the other hand functions like RIPEMD-160 y SHA-256They are so complex that their safety is still guaranteed. For example, For SHA-256, it is estimated that it would take thousands of years to break its security using current supercomputers. The same applies in the case of RIPEMD-160 and its consequent evolutions. This means that both functions still provide a high level of security and can be used without problems.

But although these functions are very safe, it does not mean that more options are not investigated and developed. This constant evolution tells us that we will always have safe tools available to use in any case.

How much do you know, cryptonuta?

Are hashes safe to use?

TRUE!

Hash functions are built under the use of powerful mathematical and logical functions that guarantee high levels of security. Firstly, an already generated hash cannot be returned to a previous state. Secondly, each hash is unique and any slight change in the input data will generate a different new hash. Under these two premises, hashes therefore offer a very high level of security capable of dealing with any type of need.

Hash functions in the Blockchain world

Because they are fast, efficient, computationally economical, and unique, hash functions are widely used in blockchain technology. When Satoshi Nakamoto published his whitepaper de Bitcoin, explained why and how to use SHA-256 and RIPEMD-160 in Bitcoin. Since then, blockchain technology has evolved a lot, but the bases remain the same. Use cryptography Strong and hashes to make the technology very secure, private and even anonymous.

Of all the uses of hash functions in blockchain, the following cases can be highlighted:

Address creation (Address Wallet)

Cryptocurrency wallet addresses are a secure representation of the wallet's public keys. The public keysThey are generally very long and complex. It is for this reason; that blockchains use hashing functions to derive a shorter address. This process is used repeatedly to shorten the address and add an extra layer of security.

In Bitcoin, the process of creating a wallet address uses hash functions RIPEMD-160 y SHA-256. Both are used to improve process security and make them unique and unrepeatable.

Mining process

The marketing process includesseveral phases that are reflected below: mining is., is another important stage of blockchain technology where hash functions are used. In Bitcoin, mining makes intensive use of hash calculation SHA-256 distributed in each of its nodes. Miners are responsible for calculating millions of hashes to create new Bitcoin blocks. The process is also used to verify the transactions that are made in the network.

Although the process of calculating hashes is very fast, its intensive use makes the process drastically difficult. This leads miners to use high computing power to solve Bitcoin puzzles. By solving them, the miners are rewarded with 6,25 BTC per block. This is a value close to $ 96.875 (November 2020). This economic incentive is what maintains the operation and security of the entire Bitcoin network.

Smart Contracts

This is another area where hash functions are heavily used. Blockchains like Bitcoin, Ethereum, NEO o TRON make use of smart contracts to promote different applications. These applications are managed by a public contract between parties. Nevertheless, much of this data is very sensitive, or it is simply too much information to be stored on a blockchain. So the best way to solve these scenarios is through hash functions. In this way, the entire contract is public but information linked or that you want to keep private is not published. This data may include names, addresses, wallet addresses, data of third party participants. That is to say; privileged information and only of interest between parties.

The hashes too They are used to version contracts. That is, A public contract has a unique hash that is given by what the contract says. If the contract is modified, the old contract is terminated and a new one is generated with a new hash. In this way, the hash determines the correct contract to use within a decentralized application, facilitating its control. Another use of hashes in smart contracts is; to mark the validity and authenticity of it. An example may be; a contract made for the sale of a house with a payment made in cryptocurrencies. The completion of the contract and its hash will be unalterable witnesses of the sale made between the parties.