In proof of work, a cryptographic hash function is used on a block (group) of transactions. Bitcoin miners then use computing devices to find part of that hash in what's called a partial hash inversion. The first miner to accomplish that is chosen to validate the transactions and receives a reward for their efforts.
Cryptographic hash functions are also used to generate addresses for blockchain wallets. Each blockchain wallet has a public key that is used to receive transactions. A wallet address is generated by hashing the public key. Instead of giving out a lengthy public key, the user can instead share their wallet address.
Cryptographic hash function vs. hash function
Cryptographic hash functions and hash functions both refer to functions that convert a data input into a fixed-length output. A cryptographic hash function refers to a specific type of hash function that aims to provide specific security properties. That means all cryptographic hash functions are hash functions, but not all hash functions are cryptographic.
An ideal cryptographic hash function will provide the following security properties:
- It's deterministic, meaning a given input will always produce the same hash.
- It can quickly compute a hash for any input.
- It's non-reversible. The original data input shouldn't be decipherable from the hash.
- Any small change to the input should change at least half of the hash. This is referred to as the avalanche effect.
- It shouldn't produce collisions, which are when two or more inputs generate the same hash.
- It should be resistant to pre-image attacks, which involve attempting to find an input from a specific hash value.
If a cryptographic hash function is found to have flaws that attackers can exploit, it's demoted to a non-cryptographic hash function.
How cryptographic hash functions work
When you use a cryptographic hash function, you're running a data input through an algorithm. The algorithm then provides a hash value. Both the hash provided and its length depend on the cryptographic hash function that you use.
Let's say you're using a cryptographic hash function that provides outputs that are 40 characters long. No matter the size of the input, the resulting output will be 40 characters whether you're hashing one word or this entire article.
Related investing topics