> For the complete documentation index, see [llms.txt](https://hub.bsvblockchain.org/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://hub.bsvblockchain.org/higher-learning/bsv-academy/bitcoin-primitives-hash-functions/what-are-hash-functions/the-three-important-properties-of-hash-functions.md).

# 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="https://3421145409-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FRTEKu4E7Fvtss3GI9CYU%2Fuploads%2FXjBnM7loqC05FuuYFMh8%2Fdata%20hashing.png?alt=media&amp;token=4adc926b-40e2-446d-96ed-6d366e998aba" 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
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

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

Perform an HTTP GET request on the following URL with the `ask` and `goal` query parameters:

```
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>&goal=<user_goal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is what the user is ultimately trying to achieve, the reason they need the answer. Sharing it helps GitBook give you a better, more relevant answer. A goal is most helpful when it describes the outcome the user wants rather than restating the question. For example, with `ask=how do I create an API token`, a goal like `automate deployments from our CI pipeline` lets GitBook tailor the answer to that use case.

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.
