# 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 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
Bitcoin "miners" combine newly created transactions from wallets and exchanges into a block, and because Bitcoin uses the proof-of-work (PoW) algorithm, miners must solve a mathematical puzzle (see illustration below). The first to do so earns the right to add the new block to the blockchain and collect fees and new coins. This proof-of-work (PoW) system was also used by Ethereum prior to switching to proof-of-stake (PoS) in 2020. See proof-of-work algorithm, Ethash and 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 large miners and mining pools use hundreds of machines (see miner hardware and pool mining). So much hash processing takes place mining Bitcoin worldwide that the electricity could power a small country (see 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 output of a hash algorithm is fixed in size; 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 a target number of leading zeros. Generating new numbers trillions of times per second, the miner hardware attempts to find the hash with the desired result.