Free 30-min Web3 Consultation
Book Now
Smart Contract Security Audits
Learn More
Custom DeFi Protocol Development
Explore
Full-Stack Web3 dApp Development
View Services
Free 30-min Web3 Consultation
Book Now
Smart Contract Security Audits
Learn More
Custom DeFi Protocol Development
Explore
Full-Stack Web3 dApp Development
View Services
Free 30-min Web3 Consultation
Book Now
Smart Contract Security Audits
Learn More
Custom DeFi Protocol Development
Explore
Full-Stack Web3 dApp Development
View Services
Free 30-min Web3 Consultation
Book Now
Smart Contract Security Audits
Learn More
Custom DeFi Protocol Development
Explore
Full-Stack Web3 dApp Development
View Services
LABS
Glossary

Keccak-256

Keccak-256 is the specific cryptographic hash function used as the core primitive within the Ethereum protocol for generating addresses, signing transactions, and creating unique identifiers like contract addresses.
Chainscore © 2026
definition
CRYPTOGRAPHIC HASH FUNCTION

What is Keccak-256?

Keccak-256 is the specific hash function used as the core cryptographic primitive in the Ethereum protocol, known for its security and efficiency in generating a unique 256-bit (32-byte) fingerprint from any input data.

Keccak-256 is a cryptographic hash function that belongs to the SHA-3 family, which was selected as the winner of the NIST hash function competition in 2012. It is a variant of the original Keccak algorithm, configured to produce a fixed 256-bit output. The function is a sponge construction, absorbing input data of any length and then "squeezing" out a deterministic, seemingly random hash. Its key properties are pre-image resistance (cannot find the input from the hash), collision resistance (two different inputs are extremely unlikely to produce the same hash), and avalanche effect (a tiny change in input creates a completely different hash).

In the blockchain context, Keccak-256 is most famously implemented as KECCAK256 in the Ethereum Virtual Machine (EVM). It is the engine behind critical operations: generating Ethereum addresses from public keys (address = last_20_bytes_of(KECCAK256(public_key))), creating smart contract addresses, and forming the nodes of the Merkle Patricia Trie that secures Ethereum's state. The function keccak256() is also a built-in opcode and a precompiled contract in Solidity, allowing developers to compute hashes directly within smart contracts for verification, commitment schemes, and data integrity checks.

While part of the SHA-3 family, it is crucial to note that Ethereum's Keccak-256 uses the original Keccak parameters proposed by its designers, Guido Bertoni, Joan Daemen, Michaël Peeters, and Gilles Van Assche. The standardized NIST FIPS 202 SHA3-256 uses slightly different padding rules. Therefore, SHA3-256 and Keccak-256 as used in Ethereum are not directly interchangeable; they produce different outputs for the same input. This distinction is vital for developers to ensure compatibility when interfacing with external libraries or other systems.

etymology
TERM ORIGINS

Etymology and Origin

The name Keccak-256 is a compound term derived from its cryptographic family and its specific output length, reflecting its technical lineage and core specification.

The term Keccak-256 is a portmanteau of Keccak, the name of the underlying cryptographic hash function family, and 256, denoting the 256-bit length of its output digest. The Keccak algorithm was developed by Guido Bertoni, Joan Daemen, Michaël Peeters, and Gilles Van Assche. It was selected as the winner of the NIST SHA-3 competition in 2012, a multi-year process to find a new, secure cryptographic hash standard to complement the older SHA-1 and SHA-2 families. The competition's goal was to diversify the cryptographic toolkit, providing a structurally different alternative to the Merkle–Damgård construction used by SHA-2.

A crucial distinction lies in the fact that while Keccak is the foundation, the official NIST FIPS 202 standard for SHA-3 introduced slight padding changes. The version originally submitted to the competition, which the Ethereum protocol adopted, retains the original Keccak padding parameters. Therefore, Keccak-256 specifically refers to this pre-standardization, competition-submission version with a 256-bit output, not the finalized NIST SHA3-256. This makes Keccak-256 a cryptographic primitive distinct from its standardized cousin, a detail critical for developers working at the protocol level.

The algorithm's core innovation is the sponge construction, a versatile framework that absorbs input data of any length and "squeezes" out a hash of the desired size. This design provides inherent resistance to length-extension attacks and offers great flexibility. Within the sponge, a permutation function, Keccak-f, operates on a state array, applying multiple rounds of substitution and permutation. The '256' in its name specifies the capacity and output parameters of this sponge, ensuring a high security level. Its adoption by Vitalik Buterin and the Ethereum founders for the platform's hashing needs cemented its prominence in the blockchain lexicon, making it synonymous with Ethereum's cryptographic backbone for creating addresses, signing transactions, and generating proofs.

key-features
CRYPTOGRAPHIC HASH FUNCTION

Key Features

Keccak-256 is the cryptographic hash function that serves as the core engine for Ethereum's security and data integrity. These cards detail its fundamental properties and critical applications.

01

Cryptographic Foundation

Keccak-256 is a cryptographic hash function from the SHA-3 family, selected by NIST after a public competition. It produces a deterministic, fixed-size 256-bit (32-byte) output, known as a hash or digest, from an input of any size. Its design is based on a sponge construction, providing strong resistance to collision and pre-image attacks.

02

Ethereum's Native Hash

While part of the SHA-3 standard, Ethereum uses the original Keccak-256 parameters, which differ slightly from the finalized NIST SHA3-256. It is the primary hash function for the protocol, used to generate:

  • Account addresses from public keys
  • Transaction and block hashes (e.g., txid)
  • State root in the Merkle Patricia Trie
  • Digital signatures via ECDSA recovery
03

Deterministic & One-Way

The function's core properties are essential for blockchain consistency:

  • Deterministic: The same input always produces the identical 32-byte hash.
  • One-Way (Pre-image Resistance): It is computationally infeasible to reverse the process and derive the original input from the hash.
  • Avalanche Effect: A tiny change in input (one bit) results in a completely different, unpredictable hash output.
04

Proof-of-Work (Ethash) Core

In Ethereum's original Proof-of-Work consensus, Keccak-256 was the fundamental component of the Ethash mining algorithm. Miners repeatedly hashed block headers with a nonce using Keccak-256, seeking a result below a dynamic target difficulty. This provided the cryptographic puzzle securing the network before The Merge.

05

Data Integrity & Verification

Keccak-256 enables efficient and secure data verification without storing the full data. Key uses include:

  • Merkle Tree Roots: Compressing large datasets (like a block's transactions) into a single hash in the block header.
  • Smart Contract Storage: Generating unique identifiers for contract code and storage slots.
  • Digital Fingerprinting: Creating a unique identifier for any piece of data or code deployed on-chain.
how-it-works
CRYPTOGRAPHIC HASH FUNCTION

How Keccak-256 Works

An in-depth look at the cryptographic algorithm that secures the Ethereum blockchain, from its sponge construction to its role in generating addresses and verifying data integrity.

Keccak-256 is a cryptographic hash function that produces a fixed 256-bit (32-byte) output, known as a digest or hash, from an input of any size. It is the specific instance of the SHA-3 standard (Secure Hash Algorithm 3) selected by the National Institute of Standards and Technology (NIST) after a public competition. While SHA-3 is a family of functions, Ethereum and several other blockchain protocols use the original Keccak parameters, which differ slightly from the final NIST-standardized version of SHA3-256. This function is deterministic, meaning the same input always yields the identical 256-bit hash, and it is designed to be preimage-resistant and collision-resistant.

The core of Keccak-256 is its sponge construction, a versatile framework for processing data. The sponge operates in two phases: absorbing and squeezing. During the absorb phase, the input message is broken into blocks, which are "absorbed" into a large internal state through a XOR operation. This state is then transformed by the Keccak-f permutation, a complex series of bit manipulations performed over multiple rounds. After all data is absorbed, the squeeze phase "squeezes" out the desired length of output hash from the final internal state. This construction provides exceptional flexibility and security properties.

Within the sponge, the Keccak-f[1600] permutation works on a 1600-bit state arranged as a 5x5x64 three-dimensional array of bits. Each round of the permutation applies five step functions: Theta (mixes columns), Rho (rotates bits within lanes), Pi (rearranges lanes), Chi (a non-linear substitution), and Iota (adds a round constant). For Keccak-256, this permutation is executed for 24 rounds. The high number of rounds and the complex bit-diffusion properties make it computationally infeasible to reverse the hash or find two different inputs that produce the same output.

In Ethereum, Keccak-256 is fundamental to nearly every operation. It is used to generate Ethereum addresses from public keys, create the unique identifiers for smart contracts, and build the nodes in Merkle Patricia Tries that secure the blockchain's state and transaction history. The function's properties ensure that even a tiny change in input—like a single bit—produces a completely different, unpredictable hash. This avalanche effect is critical for verifying data integrity and enabling cryptographic proofs, such as proving a transaction is included in a block without downloading the entire chain.

While often used interchangeably, Keccak-256 is not identical to NIST SHA3-256. The difference lies in a padding rule; Keccak-256 uses the 0x01 suffix in its padding scheme, while the NIST standard uses 0x06. This results in different hash outputs for the same input. Ethereum's adoption of the pre-standardization version has made Keccak-256 a de facto standard in the blockchain space, distinct from the government-certified SHA-3. Developers must ensure they are using the correct implementation (keccak256 in Solidity or web3.js) and not a generic SHA3 library to interact with Ethereum systems.

code-example
KECCAK-256

Code Example

A practical demonstration of the Keccak-256 cryptographic hash function, commonly used for generating Ethereum addresses and verifying data integrity on-chain.

The following Python code uses the pysha3 library to compute a Keccak-256 hash of a simple string input. This one-way function produces a deterministic, fixed-length 256-bit (32-byte) hexadecimal digest from any arbitrary data. The example shows the core operation: importing the library, encoding the input string into bytes, and calling the keccak_256() function.

python
import sha3
# Encode the input string to bytes
input_data = "Hello, Blockchain".encode('utf-8')
# Create a Keccak-256 hash object
k = sha3.keccak_256()
# Update the hash object with the data
k.update(input_data)
# Get the hexadecimal digest
hash_result = k.hexdigest()
print(f"Keccak-256 hash: {hash_result}")
# Output: Keccak-256 hash: 5d6a... (a 64-character hex string)

In blockchain contexts, this hash is fundamental. Ethereum uses Keccak-256 to derive public addresses from public keys (the last 20 bytes of the hash) and to generate digital fingerprints for transactions and blocks in its Merkle Patricia Trie. The function's properties—collision resistance, pre-image resistance, and avalanche effect (where a small input change produces a vastly different output)—make it ideal for securing distributed ledgers. It is also the core of the SHA-3 standard, though Ethereum uses the original Keccak parameters.

When working with smart contracts in Solidity, developers interact with Keccak-256 via the global keccak256() function. It is frequently used for creating commit-reveal schemes, verifying Merkle proofs, and implementing signature recovery with ecrecover. Understanding this code example is the first step to grasping how data integrity and cryptographic commitments are enforced on-chain, forming the bedrock of trustless verification in decentralized systems.

ecosystem-usage
KECCAK-256

Ecosystem Usage in Ethereum

Keccak-256 is the cryptographic hash function at the core of Ethereum, providing the essential security properties for addresses, transaction integrity, and state verification.

02

Transaction & State Root Hashing

Keccak-256 is used to compute the Merkle Patricia Trie roots that secure Ethereum's state. Key structures hashed with Keccak-256 include:

  • stateRoot: Hash of the entire world state.
  • transactionsRoot: Hash of all transactions in a block.
  • receiptsRoot: Hash of all transaction receipts. These roots are stored in the block header, allowing for efficient and secure verification of any piece of data without needing the entire dataset.
03

Smart Contract Function Selectors

The first 4 bytes of a transaction's data field specify which function to call in a smart contract. This function selector is the first 4 bytes of the Keccak-256 hash of the function's signature (e.g., transfer(address,uint256)). This compact identifier allows the EVM to uniquely and efficiently route contract calls.

04

Proof-of-Work (Ethash) & RNG

In Ethereum's original Proof-of-Work (PoW) consensus, the Ethash algorithm heavily relied on Keccak-256 for its memory-hard hashing process. Furthermore, Keccak-256 is a common source of pseudo-randomness in smart contracts, where developers hash a combination of blockhash, timestamp, and other data, though this practice requires careful consideration of security implications.

05

Event Logging & Signatures

Ethereum event logs use Keccak-256 to create unique identifiers. The topic[0] of a log is the Keccak-256 hash of the event signature (e.g., Transfer(address,address,uint256)). This allows clients and indexers to efficiently filter and query for specific events emitted by contracts across the blockchain.

security-considerations
KECCAK-256

Security Considerations

Keccak-256 is a cryptographic hash function, most notably adopted as the core hashing algorithm for the Ethereum protocol. Its security properties are fundamental to blockchain integrity.

01

Pre-Image & Collision Resistance

Keccak-256 provides strong pre-image resistance (infeasible to find an input from its hash) and collision resistance (infeasible to find two different inputs with the same hash). These properties are critical for securing blockchain data structures like Merkle Patricia Tries and ensuring transaction and state root integrity.

02

Avalanche Effect & Determinism

A tiny change in input (e.g., one character) produces a completely different, unpredictable hash output. This avalanche effect ensures data uniqueness. Simultaneously, the function is deterministic: the same input always yields the same 256-bit (32-byte) output, which is essential for consensus and verification across all network nodes.

03

Resistance to Length Extension Attacks

Unlike older hash functions like SHA-256, Keccak-256, based on the sponge construction, is not vulnerable to length extension attacks. This prevents an attacker from taking H(message) and computing H(message || extension) without knowing the original message, a key security advantage for message authentication.

04

Ethereum's Specific Implementation

Ethereum uses a specific variant of Keccak-256, defined in FIPS-202. It is used for:

  • Generating Ethereum addresses from public keys (keccak256(pubKey)[12:32]).
  • Creating transaction and receipt hashes.
  • Computing state roots and storage slots in smart contracts (e.g., keccak256(abi.encodePacked(key, slot))).
05

Quantum Computing Threat Profile

Like all current hash functions, Keccak-256's security is reduced in a post-quantum context. Grover's algorithm could theoretically find a pre-image in ~2^128 operations, halving its effective security from 256 to 128 bits. While still formidable, this necessitates long-term planning for post-quantum cryptography in blockchain systems.

06

Verification & Tooling

Always verify hash outputs using standard, audited libraries. Common pitfalls include:

  • Incorrect padding: Ethereum's keccak256 hash in Solidity/Solidity scripts uses the standard Keccak-256, not SHA3.
  • String encoding: Hashing "hello" vs. abi.encodePacked("hello") yields different results. Use trusted tools like the Ethereum Foundation's pycryptodome or OpenZeppelin's Strings.toHexString for correct implementation.
CRYPTOGRAPHIC HASH FUNCTION COMPARISON

Keccak-256 vs. SHA-256

A technical comparison of the two dominant cryptographic hash functions in blockchain and Web3.

Feature / MetricKeccak-256 (SHA-3)SHA-256 (SHA-2)

Cryptographic Family

SHA-3 (Keccak)

SHA-2

Underlying Construction

Sponge Function

Merkle-Damgård Construction

NIST Standardization

FIPS 202 (2015)

FIPS 180-4 (2012)

Primary Blockchain Use

Ethereum, Solana, Polkadot

Bitcoin, Bitcoin Cash, Litecoin

Pre-image Resistance

Collision Resistance

Length Extension Attack Vulnerability

Internal State Size (bits)

1600

256

Common Output Format

0x-prefixed hex (64 chars)

Hex (64 chars)

common-misconceptions
KECCAK-256

Common Misconceptions

Keccak-256 is often conflated with other hashing standards, leading to confusion in blockchain development and security audits.

01

Keccak-256 is NOT SHA-3

The most critical misconception is that Keccak-256 and the NIST-standardized SHA-3-256 are identical. While both derive from the Keccak sponge function, NIST made subtle but significant changes to the padding rule before finalizing SHA-3. Ethereum and other early adopters implemented the original Keccak specification. Using a SHA-3 library for Ethereum address generation or signature verification will produce incorrect results.

  • Keccak-256: Uses the 0x01 padding rule (also called Keccak-256).
  • SHA-3-256: Uses the SHA3-256 padding rule (0x06).
02

It's Not an Encryption Function

Keccak-256 is a cryptographic hash function, not an encryption algorithm. This means it is a one-way process designed for data integrity and fingerprinting, not for secrecy with a decryption key.

  • Hash Function: Produces a fixed-size digest from variable input. The process is deterministic but irreversible.
  • Encryption: Transforms data using a key, with the intent of later decryption. Confusing these can lead to security flaws, such as mistakenly "hashing" sensitive data thinking it is protected from disclosure, when a reversible encryption algorithm is actually required.
03

Collision Resistance vs. Pre-image Resistance

Not all hash function properties are equal. A common error is assuming collision resistance guarantees all other security properties.

  • Collision Resistance: It is computationally infeasible to find two different inputs that produce the same hash output.
  • Pre-image Resistance: Given a hash output, it is infeasible to find any input that produces it.
  • Second Pre-image Resistance: Given one input, it is infeasible to find a different input with the same hash. Keccak-256 is designed to be strong in all three areas, but understanding the distinction is crucial for proper cryptographic protocol design and threat modeling.
04

Hash Output is Not a Random Number

The 256-bit output of Keccak-256, while appearing random, is a deterministic checksum. The same input will always produce the same hexadecimal string. This property is fundamental for:

  • Verifying data integrity (e.g., checking downloaded software against a published hash).
  • Creating deterministic identifiers (e.g., Ethereum addresses from public keys, transaction IDs).
  • Proof-of-Work consensus, where miners search for a nonce that results in a hash with specific leading zeros. Treating it as a source of randomness, without careful cryptographic construction, can introduce vulnerabilities.
05

Not All '256' Hashes Are Created Equal

The '256' refers to the bit-length of the output, but the security and properties depend entirely on the underlying algorithm. Keccak-256 is structurally and security-wise distinct from other 256-bit hashes like SHA-256 (used in Bitcoin) or BLAKE2b-256.

  • SHA-256: Merkle-Damgård construction, different internal compression function.
  • Keccak-256: Sponge construction, different internal permutation (Keccak-f[1600]). They are not interchangeable. A system designed for one will break if another is substituted, even though the output length is the same.
KECCAK-256

Frequently Asked Questions

Keccak-256 is the cryptographic hash function at the heart of the Ethereum blockchain. These questions address its core functions, differences from SHA-256, and its critical role in blockchain security.

Keccak-256 is a cryptographic hash function that takes an input of any size and deterministically produces a fixed 256-bit (32-byte) output, known as a hash or digest. It works by using a sponge construction, which absorbs the input data in blocks and then squeezes out the final hash. This process involves bitwise operations within a large internal state, making it highly resistant to collisions and pre-image attacks. In Ethereum, it is the core function for creating unique identifiers like account addresses (from public keys) and transaction hashes, and for verifying data integrity within the Merkle Patricia Trie that structures the blockchain's state.

ENQUIRY

Get In Touch
today.

Our experts will offer a free quote and a 30min call to discuss your project.

NDA Protected
24h Response
Directly to Engineering Team
10+
Protocols Shipped
$20M+
TVL Overall
NDA Protected direct pipeline