# Preimage Resistance, Second Preimage Resistance, and Collision Resistance

## Preimage Resistance, Second Preimage Resistance, and Collision Resistance

Preimage resistance, second preimage resistance, and collision resistance are properties of the hash function.

What is a hash function?

The term hash function is a computer-science term referring to when a string of arbitrary length and a string of fixed length functions are compressed. A hash function serves to allocate and uniformly store a record of a file.

**Preimage Resistance**

Preimage resistance is one component of the hash function that is difficult to turn. If a hash function within the range of an element is given, it is expected to be computationally infeasible to locate the input that matches such element.

In 1976 Diffie and Hellman introduced the use of a one-way hash function in cryptography. A one-way function is a computation function wherein its direction is straight forward, but if the computation reverses in direction, it becomes more difficult. Preimage resistance is in line with a one-way function, which makes it relatively easy to protect a file.

For a hash function to be preimage resistance, it must result in a minimum requirement of 80 bits. Preimage resistance is different from its other hash function counterparts–second preimage resistance and collision resistance. Before a hash function can be said to be one-way, it must first be preimage resistance and second preimage resistance.

A hash function with preimage resistance satisfies the following three definitions:

*First Definition*

In the first definition, preimage resistance causes the the output value to repeat itself. Selecting the hash function will then ensure that it is uniform. An attacker is asked to make the selected hash function work. If the attacker is able to find the value in the preimage, the attacker wins.

This implies that the preimage hash function should be secure to the extent that the attacker will not be able to obtain the preimage of the output value. This is because the attacker does not have the secure variation knowledge of the hash function. That definition may not have practical meaning because even if the attacker does not have the basic knowledge of the variation, they may be able to guess the strings. The first thing to fix is the range point, but selecting the hash function uniformly and at random will make it difficult for the attacker to get it right.

*Second Definition*

In the second definition, there should be a request for all the possible hash functions that are selected. Once that is done, one of the hash functions will be fixed. For instance, after selecting the concrete instance, the next is to also pick a message uniformly and select the hash function randomly. Once that is done, the next step is to hand over the outcome to the attacker and request that the value is provided. Therefore, if the result is preimage, then the attacker won.

In practice, this definition is the nearest modeling of the hash functions because you will be the one to first fix the selection of the hash functions. Then you will invite the attacker to check for the preimage at a random message.

*Third Definition*

According to the third definition of preimage resistance, one of the hash functions is randomly selected first and also in a uniform manner. Then a message is selected uniformly from the strings of the given length. After that, the output value is computed and challenged by making use of the determined message formula and hash function selection. The last thing to do is to give the output value along with the hash function selection to the attacker for them to show the value. Thus, if the outcome indicates that the first is preimage resistance, the attacker won.

**Second Preimage Resistance**

Second preimage resistance, which is also one of the hash function properties, can be referred to as “weak collision resistance.” This property can be infeasible when it is computed, which makes it difficult to locate the input of the second distinct that has the same output as the given input.

Second preimage resistance has the same features as preimage resistance. It is also a one-way hash function. Nevertheless, second preimage resistance is developed for functions that have the same domain of input and output or that are similar.

Before a hash function can be considered to be second preimage resistant, it needs to have a minimum required length that is not less than 90 bits. Many times, second preimage resistance is mistaken as first preimage resistance because of the similarities they share. For instance, imagine a hash function is given and it is second preimage resistance, but the resistance is not preimage. The outcome of such a result might be contradictory which implies that you will have to get preimage resistance before you can get second preimage resistance.

**Collision Resistance**

Collision resistance also has similarities with the second preimage resistance, and because of this, collision resistance can also be called “weak collision resistance.” However, before a hash function can be referred to as collision resistance, it must have a minimum of 160 bits length.

Collision resistance is also a property of cryptographic hash function that is mostly designed to be collision-resistant. Nevertheless, some hash functions that have been assumed to be collision resistant were later broken. Particularly, MD5 and SHA-1 are proven published techniques that are more efficient than using brute force for finding a collision. Thus, most of the hash functions prove that finding a collision is as difficult as finding a solution to some of the difficult mathematical problems like integer factorization or discrete logarithms. Those hash functions are known as “provably secure.”

In conclusion, preimage resistance, second preimage resistance, and collision resistance are all properties of the hash function and all have similarities. Additionally, it will be difficult for one to get a second preimage resistance without first coming across preimage resistance. Both the second and collision preimage resistance also share similarities and that make it difficult to separate them which is why both of them are called “weak collision resistance.”