Hash Function

A mathematical function that converts input data into a fixed-size string of characters.

A hash function is a mathematical algorithm that takes an input of any size and produces a fixed-size output (called a hash or digest). Hash functions are one-way โ€” given the output, it's computationally infeasible to determine the original input.

Properties

Deterministic: The same input always produces the same output.

Fixed Output: Regardless of input size, the output length is always the same (256 bits for SHA-256).

Avalanche Effect: A tiny change in input dramatically changes the output.

One-Way: Cannot reverse the output to find the input.

Collision Resistant: Extremely unlikely for two different inputs to produce the same output.

Hash Functions in Blockchain

SHA-256: Used by Bitcoin for mining and block linking.

Keccak-256: Used by Ethereum for addresses and state management.

Block Linking: Each block contains the hash of the previous block, creating an immutable chain.

Hash functions are the cryptographic glue that holds blockchains together, ensuring data integrity and enabling proof-of-work mining.

Frequently Asked Questions

What is a hash function?

A hash function is a one-way mathematical algorithm that converts input of any size into a fixed-size output. It's deterministic (same input = same output), irreversible, and collision-resistant, making it fundamental to blockchain security.

What hash functions do blockchains use?

Bitcoin uses SHA-256 for mining and block linking. Ethereum uses Keccak-256 for addresses and state management. Different blockchains choose hash functions based on their security properties and performance characteristics.

Related Terms