A cryptographic hash function is an algorithm with a repeatable sequence of specific actions. This sequence is used to transform a variable-length arbitrary data string into a fixed-length format called a hash.
For a hash function to perform properly, it needs certain qualities, including:
- Avalanche effect — If an individual were to change a single bit of data in the input, it would massively affect the output.
- Determinism — By entering a specific input in the algorithm, it will always produce the same output.
- Collision resistance — When using the algorithm, if there are two different inputs, there should rarely, if ever, be the same output.
One of the most common and important use cases for a cryptographic hash is with Bitcoin (BTC). A cryptographic hash is an important function in the Proof of Work (PoW) system of Bitcoin. For new blocks to be added to the Bitcoin blockchain, miners need to provide a hash value below a certain threshold. The hash used is known as SHA-256.
Cryptographic hashes are pseudorandom, meaning that deciphering the output of any input before putting it through a hash function is basically impossible. This ensures that miners cannot be malicious and try to produce BTC out of nowhere instead of contributing to the network.