# The Three Important Properties of Hash Functions

## 1. Preimage Resistance: One-way

<figure><img src="https://hub.bsvblockchain.org/~gitbook/image?url=https%3A%2F%2F2147185133-files.gitbook.io%2F%7E%2Ffiles%2Fv0%2Fb%2Fgitbook-x-prod.appspot.com%2Fo%2Fspaces%252FWtK4ab0ntyPZBmGoKq4t%252Fuploads%252Fgit-blob-4b8bf1c03b855bbbb8bc6db753cfc0b67ac6b2e7%252FBSVA-HashFunctions_Ch1L3_DA2.gif%3Falt%3Dmedia&#x26;width=768&#x26;dpr=4&#x26;quality=100&#x26;sign=2c14158b&#x26;sv=2" alt=""><figcaption></figcaption></figure>

Hash functions are **computationally infeasible to reverse** — like trying to **unscramble an egg** or **put toothpaste back into its tube**.

* They are **one-way trap-door functions**: easy to compute a digest from an input, but practically impossible to find the original input from just the digest.
* To be considered **preimage resistant**, it should take about **2ᵐ hash attempts** (where *m* is the output length in bits) to recover the input.
* If an input can be discovered in fewer attempts, the hash function is **no longer secure**.

👉 **Key takeaway:** Preimage resistance makes it **impractical to reverse a hash back into its original data**.

## 2 .Second Preimage Resistance: Deterministic

<figure><img src="/files/0uAQuDKI3m5lwRMuXBqT" alt=""><figcaption></figcaption></figure>

Hash functions are **deterministic**: the **same input always produces the same output hash**.

* Even if you change just **one bit** in the input, the resulting hash is **completely different**.
* This ensures that an attacker cannot find a **different input** that produces the same hash as a given input.

👉 **Key takeaway:** Second preimage resistance ensures that a hash is a **unique fingerprint** of its input.

## 3. Collision Resistance

<figure><img src="https://hub.bsvblockchain.org/~gitbook/image?url=https%3A%2F%2F2147185133-files.gitbook.io%2F%7E%2Ffiles%2Fv0%2Fb%2Fgitbook-x-prod.appspot.com%2Fo%2Fspaces%252FWtK4ab0ntyPZBmGoKq4t%252Fuploads%252Fgit-blob-c4db9221d3dce1bd311644a7f3e6ea9abce54962%252FBSVA-HashFunctions_Ch1L3_DA4.gif%3Falt%3Dmedia&#x26;width=768&#x26;dpr=4&#x26;quality=100&#x26;sign=d6523213&#x26;sv=2" alt=""><figcaption></figcaption></figure>

It’s **computationally infeasible** to find **two different inputs** that hash to the **same output**.

* Because the output length is fixed, collisions are theoretically possible, but a **good hash function** makes them so unlikely they can be safely ignored.
* Ideally, with an output of length *m*, it should require about **2^(m/2) operations** to find a collision.
* The **birthday attack** illustrates this: in a set of 2ᵐ possible values, about 2^(m/2) random attempts are needed to expect a collision.
* If collisions can be found faster than this, the hash function is **broken**.

👉 **Key takeaway:** Collision resistance is **critical to security**, especially in **BSV’s proof-of-work system**, where trust depends on preventing duplicate results.


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://hub.bsvblockchain.org/higher-learning/bsv-academy/bitcoin-primitives-hash-functions/what-are-hash-functions/the-three-important-properties-of-hash-functions.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
