Understanding Keccak256: The Cryptographic Hash Function Behind Ethereum
Keccak256 is a cryptographic hash function based on the sponge construction, a family of cryptographic algorithms.
Keccak256 is a cryptographic hash function based on the sponge construction, a family of cryptographic algorithms.
It was developed as part of the Keccak family of hash functions by Guido Bertoni, Joan Daemen, Michaël Peeters, and Gilles Van Assche in 2008. Keccak256 was later standardized as SHA-3 (Secure Hash Algorithm 3) by the National Institute of Standards and Technology (NIST) in 2015 after winning the NIST hash function competition.
How does Keccak256 work?
The sponge construction consists of two main components:
- The state: This is a fixed-size array of bits, often visualized as a grid of squares, where each square holds a single bit. The state is divided into the bitrate (r) and the capacity (c).
- The permutation function (f): a fixed, non-linear transformation applied to the state.
The sponge construction operates in two phases: the absorbing and squeezing phases.
During the absorbing phase, input data is divided into chunks of r bits and XORed with the bitrate part of the state. The permutation function is then applied to the entire state. This process is repeated until all input chunks have been processed.
In the squeezing phase, the output hash is extracted from the bitrate part of the state. The permutation function is applied again if more output bits are required.
Key features of Keccak256
- Variable output length: Keccak256 can produce output hashes of varying lengths, making it versatile for different applications.
- Resistance to collision attacks: Keccak256 is designed to be resistant to collision attacks, which occur when two distinct inputs produce the same hash output. This resistance is critical for the security of the hash function.
- Resistance to pre-image attacks: Pre-image attacks attempt to find an input that maps to a specific hash output. Keccak256’s design makes these attacks computationally infeasible, contributing to its robust security.
- Resistance to length extension attacks: Unlike many other hash functions, Keccak256 is not susceptible to length extension attacks, which exploit the properties of a hash function to forge a valid hash for an altered message.
Keccak256 in the Ethereum blockchain
Keccak256 is an essential component of the Ethereum blockchain, serving as its primary hash function. It is used for various purposes, including:
- Generating unique identifiers for transactions and blocks.
- Computing the addresses of smart contracts.
- Creating digital signatures for verifying transactions.
Follow me on Medium, LinkedIn, and Twitter.
All the best,
Luis Soares
CTO | Head of Engineering | Cyber Security | Fintech & Blockchain SME | NFT | Web3 | DeFi
#blockchain #solidity #assembly #smartcontracts #ethereum #nft #ethereum evm #solidity #web3 #cryptography #softwareengineering #softwaredevelopment #coding #software