# Definition: cryptographic hash function

An algorithm that transforms a given amount of data (the "message") into a fixed number of digits, known as the "hash," "digest" or "digital fingerprint." Hash functions are a fundamental component in digital signatures, password security, random number generation, message authentication and blockchains. A hash can also be used to avoid the risk of storing passwords on servers that could be compromised (see zero proof example). See RSA and hashing.

One-Way Processing
Also called a "one-way hash function" because it is nearly impossible to turn the digest back into the original data. It is also exceedingly rare that two different inputs can result in the same output.

Blockchain Integrity
This one-way processing guarantees that existing blockchain crypto balances and smart contract program code cannot be altered. All transactions in a block are hashed into the subsequent block creating a chained linkage, and any alteration to an existing block breaks the chain (for details, see blockchain). See Merkle tree, HMAC, digital signature, MD5 and hash.

Solve the Bitcoin Puzzle by Hashing
As transactions are combined in a block by Bitcoin miners, they must solve a mathematical puzzle to prove they did work (see illustration below). The first to do so earns the right to add the new block to the blockchain and collect the fees and new coins. This proof-of-work (PoW) system is also used by Ethereum (see Ethash); however, that is changing (see Ethereum 2.0).

With specialized hardware executing trillions of hash computations per second, it can take a single machine years to come up with the required hash, which is why mining pools use hundreds of machines (see miner hardware). So much hash processing takes place mining Bitcoin worldwide that the electricity used could power a small country (see proof-of-work algorithm and hash rate). See crypto mining.

Hashes Are Fixed in Size
The hash value guarantees only that it is mathematically equal to the data it has hashed. If the data are changed in any way, that same hash cannot be generated. No matter how large or small the input, the hash output is fixed; for example, Bitcoin hashes are 256 bits long. See SHA.

Solving the Bitcoin Puzzle
The puzzle is finding the random number that, when added to the block's header, generates a hash with some number of leading zeros. Trying a new number trillions of times per second, the miner algorithm attempts to find the one that generates the desired results.

AntPool Wins Block 753673
The Bitaps website shows new Bitcoin blocks in real time. Notice the 19 leading zeros, which was the difficulty level at 17:38 UTC on 9-11-2022. The number of zeros is adjusted every 2,016 blocks to keep transactions flowing at one new block approximately every 10 minutes. See crypto stats.