> 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/hash-functions-crash-course/three-important-properties-of-hash-functions.md).

# Three Important Properties of Hash Functions

### 1. Preimage Resistance: One-way

<figure><img src="https://3421145409-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FRTEKu4E7Fvtss3GI9CYU%2Fuploads%2FzVQYTkmD9aIFV6yThMUI%2Fone.gif?alt=media&amp;token=f51457da-38e2-49f8-bf61-979e1d608fc5" alt=""><figcaption></figcaption></figure>

Hash functions are **computationally infeasible to reverse** -- in the same sense as trying to unscramble an egg or put toothpaste back into its tube. Said in another way, hash functions are one-way 'trap-door' functions; they make it easy to find a message digest from an input, but so difficult to find an input from a message digest, that it would either take longer than human beings are capable of waiting (sometimes longer than the age of the universe) or the cost of marshalling the necessary computing power to reverse them is so high, it's not worth doing it.

To be considered preimage resistant, it should take 2^*m* hash attempts (where m is the length of the output in bits) to find the corresponding input message for a particular message digest. If a preimage can be found using fewer than 2^*m* hash attempts, the hash function is no longer considered preimage resistant and is no longer secure.

### 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%2F5OmZQ6QST8x3vdsLiN1A%2F2.gif?alt=media&amp;token=a32d0775-ba76-4b9d-bbed-15b587449cee" alt=""><figcaption></figcaption></figure>

The **message digest of a hash function is consistent given the same input value**. In other words, hash functions are deterministic -- the same input produces the same output hash every time. Furthermore, if even a single bit of the input message is changed, the resulting output hash is significantly different, unique, and preimage resistant.

### 3. Collision Resistance

<figure><img src="https://3421145409-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FRTEKu4E7Fvtss3GI9CYU%2Fuploads%2FHghknfXZEODu2M743ffk%2F3.gif?alt=media&amp;token=ecafea97-80cd-4716-9592-955c0f0c0e0f" alt=""><figcaption></figcaption></figure>

It’s **computationally infeasible to find two different input values that produce the same output value for a hash function**. Although the fixed length of their output means a hash function has a collision risk, an ideal hash function produces message digests with a length large enough that the risk of finding a collision is so small, it’s safe to ignore in most situations.

Ideally, a hash function with an output value of bitlength *m* should require at least 2^(*m*/2) operations to find a collision. In a **birthday attack**, given a set of *m* equally probable values, roughly 2^(*m*/2) random samples are needed to find a single collision. This means if a collision is found in fewer than 2^(*m*/2) random samples, the collision resistance property of the hash function is “broken”, and it’s no longer considered secure.

This is particularly important with respect to Bitcoin's proof-of-work process.


---

# 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 dynamically by asking a question.

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

```
GET https://hub.bsvblockchain.org/higher-learning/bsv-academy/hash-functions-crash-course/three-important-properties-of-hash-functions.md?ask=<question>&goal=<endgoal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is optional and describes the broader end goal you are ultimately trying to accomplish on behalf of the user. GitBook uses it to tailor the answer towards what is most useful for that goal.

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.
