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

Sponge Construction

A versatile cryptographic framework for building hash functions and pseudorandom number generators, operating by absorbing input data and then squeezing output.
Chainscore © 2026
definition
CRYPTOGRAPHIC PRIMITIVE

What is Sponge Construction?

Sponge construction is a versatile cryptographic framework for building hash functions, pseudorandom number generators, and authenticated encryption schemes from a fixed permutation or transformation.

Sponge construction is a cryptographic mode of operation that processes input data of arbitrary length to produce an output of a desired length, using a fixed internal state and a permutation function. It operates in two distinct phases: an absorbing phase, where input data is XORed into the state and processed by the permutation, and a squeezing phase, where output bits are extracted from the state. This design, introduced by Guido Bertoni, Joan Daemen, Michaël Peeters, and Gilles Van Assche, is the foundation of the Keccak algorithm family, which includes the SHA-3 standard hash function.

The construction's security and flexibility stem from its internal state, divided into a rate (r) and a capacity (c). The rate determines how many bits of data are processed per permutation call, while the capacity represents the hidden, unmanipulated part of the state that provides security against collisions and preimage attacks. The security level is fundamentally bounded by the capacity (c/2 bits). This separation allows the sponge to be a duplex construction for interactive protocols, where absorbing and squeezing can be interleaved, enabling authenticated encryption modes like Ketje and Keyak.

A key advantage of the sponge paradigm is its simplicity and resistance to generic attacks. Unlike the Merkle-Damgård construction used in SHA-2, it is inherently immune to length extension attacks and can naturally produce outputs of any length. Its security proofs are based on the indifferentiability of the construction from a random oracle, assuming the underlying permutation is secure. This makes it a robust and future-proof design, capable of supporting a wide range of cryptographic functions from a single core component.

how-it-works
CRYPTOGRAPHIC PRIMITIVE

How Sponge Construction Works

An explanation of the sponge construction, a versatile framework for building cryptographic hash functions and other primitives.

Sponge construction is a cryptographic model that processes an input data stream of any length to produce an output of a desired length, operating in two distinct phases: absorbing and squeezing. It uses a fixed-size internal state, often visualized as a sponge that soaks up liquid (data) and then wrings it out (output). This design is the foundation for the SHA-3 family of hash algorithms, including Keccak, which was selected by NIST as the standard. Its flexibility allows it to be used not only for hashing but also for pseudorandom number generation, authenticated encryption, and more.

The process begins in the absorbing phase, where the input message is broken into blocks and sequentially XORed into a portion of the internal state, followed by the application of a fixed permutation function. This permutation, a core component of the algorithm's security, thoroughly mixes and transforms the entire internal state after each block is absorbed. Once all input data has been processed, the construction switches to the squeezing phase. Here, output bits are extracted from the state, and if more output is needed, the permutation is applied again to generate the next block, allowing for arbitrary-length output.

A key parameter of the sponge construction is its bitrate and capacity, which define the security and efficiency trade-off. The internal state is divided into two parts: the rate (r), the portion of the state involved in absorbing and squeezing data, and the capacity (c), the portion that remains hidden and untouched during these operations, providing the security margin. The security level against collisions and preimage attacks is fundamentally linked to the capacity c, making it a critical design choice. A larger capacity increases security but reduces the processing speed per block.

Beyond standard hashing, the sponge's duplex construction extends its utility for interactive protocols. In this mode, the sponge can alternate between absorbing input and squeezing output in a single pass, enabling functions like authenticated encryption (e.g., in the Ketje and Keyak ciphers) and reseedable pseudorandom number generators. This makes the sponge a unified cryptographic tool, contrasting with older designs that require separate algorithms for hashing, MACs, and stream ciphers. Its simplicity and provable security under the random sponge model are major advantages.

The most prominent real-world implementation is the Keccak algorithm, which won the NIST SHA-3 competition. Its permutation operates on a 1600-bit state, offering configurations like SHA3-256 (with a 1088-bit rate and 512-bit capacity). The sponge construction's resistance to length extension attacks—a vulnerability in the Merkle-Damgård construction used by SHA-2—and its elegant design have cemented its importance in modern cryptography, providing a secure and efficient foundation for the next generation of cryptographic protocols.

key-features
CRYPTOGRAPHIC PRIMITIVE

Key Features of Sponge Construction

Sponge construction is a versatile cryptographic framework for building hash functions, pseudo-random number generators, and authenticated encryption schemes. Its defining characteristic is its ability to absorb input data and then 'squeeze' out output of any desired length.

01

Absorb and Squeeze Phases

The sponge operates in two distinct phases. In the absorbing phase, input data is broken into blocks and XORed into a fixed-size internal state. In the squeezing phase, output bits are extracted from this state. This allows for a single-pass operation on variable-length input and output.

02

Internal State and Permutation

At its core is a fixed-size internal state, divided into a rate (r) and a capacity (c). A cryptographic permutation function (like Keccak-f) is applied to this state after each block of input. The capacity provides security against collisions and preimages, while the rate determines processing speed.

03

Variable-Length Output

Unlike traditional hash functions with fixed output (e.g., SHA-256), a sponge can produce an output of any desired length by repeatedly applying the permutation and reading from the state during the squeeze phase. This makes it ideal for applications like extendable-output functions (XOFs).

04

Security Proofs and Capacity

The security level is primarily determined by the capacity (c). The sponge's security is proven to be equivalent to a random oracle, up to a bound of approximately 2^(c/2) operations. A larger capacity provides higher security against attacks like collisions and preimages.

05

Keccak and SHA-3

The most prominent real-world example is the Keccak algorithm, which won the NIST hash function competition. The standardized SHA-3 family (SHA3-224, SHA3-256, etc.) is built using the Keccak-f[1600] permutation with a sponge construction.

06

Versatility Beyond Hashing

The sponge framework is not limited to hashing. It can be configured to create:

  • Duplex construction for authenticated encryption (e.g., Ketje, Keyak).
  • Pseudo-random number generators (PRNGs).
  • Message authentication codes (MACs). This makes it a foundational, multi-purpose cryptographic tool.
visual-explainer
CRYPTOGRAPHIC PRIMITIVE

Visualizing the Sponge

An intuitive breakdown of the sponge construction, a versatile cryptographic framework that absorbs and squeezes data, powering algorithms like Keccak/SHA-3.

The sponge construction is a cryptographic model that processes input data of any length to produce an output of a desired size, operating in two distinct phases: absorbing and squeezing. Imagine a sponge: it first soaks up (absorbs) water (data) and then can be wrung out (squeezed) to release it. In cryptographic terms, the sponge's internal state, defined by a bitrate (r) and capacity (c), is repeatedly transformed by a fixed-length permutation function f. During absorption, input blocks are XORed into the r-bit portion of the state, interleaved with applications of f. Once all data is absorbed, the squeezing phase extracts output blocks from the r-bit portion, again applying f between extractions.

The security of the construction is fundamentally tied to its capacity c, which represents the hidden, unmanipulated portion of the internal state. A larger c provides greater resistance against collisions and preimage attacks. This design elegantly unifies hashing, message authentication codes (MACs), and pseudorandom number generation under one paradigm. For hashing, the sponge absorbs the message and then squeezes out a digest. For a keyed hash or MAC, the secret key is absorbed first. To generate a stream of pseudorandom bits, the sponge can be seeded and then squeezed indefinitely. The duplex construction, a related mode, enables authenticated encryption by allowing interleaved absorption and squeezing in a single session.

The most famous implementation is Keccak, which was selected as the SHA-3 standard by NIST. Its permutation function f operates on a 1600-bit state (with common parameters r=1088, c=512 for a 256-bit hash). Visualizing the state as a 5x5x64 array of lanes helps understand Keccak's internal theta, rho, pi, chi, and iota operations. The sponge's flexibility is its strength: its indifferentiability from a random oracle under ideal permutation assumptions provides strong security proofs. Unlike the Merkle-Damgård construction used in SHA-2, the sponge is inherently resistant to length-extension attacks and naturally handles arbitrary-length output, making it a cornerstone of modern symmetric cryptography.

examples
SPONGE CONSTRUCTION

Examples & Implementations

The sponge construction is a cryptographic framework for building hash functions and authenticated encryption schemes. Its core principle is absorbing input data into a large internal state and then squeezing output from it, providing flexibility and provable security.

03

Zero-Knowledge Proofs (ZK-SNARKs)

Sponge functions are used as a cryptographic sponge within ZK proof systems like Groth16 and PLONK. They serve as a collision-resistant hash and a Fiat-Shamir transform component to make interactive protocols non-interactive, ensuring security against malicious provers.

04

Rescue & Stark-Friendly Hashes

Designed for efficiency in STARK proofs, the Rescue hash function uses a sponge construction with a permutation based on arithmetic in a prime field. It is optimized for the constraints of AIR (Algebraic Intermediate Representation), making it significantly faster in ZK circuits than SHA-3.

05

Sponge-Based MACs

The sponge construction naturally creates Message Authentication Codes (MACs). By absorbing a key and a message, then squeezing a tag, it forms a secure MAC. This is simpler than HMAC constructions and is used in lightweight cryptography protocols.

06

Poseidon Hash

A zk-SNARK-friendly hash function using a sponge construction with a poseidon permutation over a prime field. It is designed for minimal constraints in R1CS circuits, making it the de facto standard for hashing in ZK rollups (e.g., zkSync, StarkNet) and privacy applications.

ecosystem-usage
SPONGE CONSTRUCTION

Ecosystem Usage in Blockchain

Sponge construction is a cryptographic framework for building hash functions and authenticated encryption schemes, characterized by its ability to absorb input data and then squeeze out output of arbitrary length. In blockchain, it's the foundation for the Keccak hash function used in Ethereum and other protocols.

01

Core Cryptographic Primitive

Sponge construction is a versatile cryptographic mode of operation that defines a sponge function. It operates in two phases:

  • Absorbing Phase: Input data is XORed into a fixed-size internal state.
  • Squeezing Phase: Output bits are extracted from the same state. Its security is based on the indifferentiability from a random oracle, making it suitable for hashing, pseudorandom number generation, and authenticated encryption.
02

Keccak & Ethereum's SHA-3

The most prominent implementation is the Keccak family of hash functions, which won the NIST SHA-3 competition. Ethereum uses Keccak-256 (often called SHA-3 in Ethereum contexts) for:

  • Generating addresses from public keys.
  • Creating transaction and block hashes.
  • Powering the Ethash proof-of-work algorithm (pre-Merge). Its sponge-based design provides resistance to length-extension attacks, a vulnerability in Merkle-Damgård constructions like SHA-2.
03

Arbitrary-Length Output

A key advantage of the sponge construction is its ability to produce an output (digest) of any desired length by simply continuing the squeezing phase. This is crucial for:

  • Extendable-Output Functions (XOFs): Like SHAKE128 and SHAKE256, used in post-quantum cryptography (e.g., Dilithium signatures).
  • Stream encryption: The squeezed output can serve as a keystream.
  • Custom cryptographic protocols that require non-standard hash lengths without additional complexity.
04

State & Permutation Function

The security of a sponge function hinges on its internal permutation, f. This is a fixed transformation applied to the state during each absorption and squeezing step.

  • In Keccak, this is the Keccak-f permutation, which operates on a state of 1600 bits arranged in a 5x5x64 3D array.
  • The permutation provides diffusion and confusion, making the function resistant to cryptanalysis. The bitrate (r) and capacity (c) parameters, where r + c = state size, trade between speed and security.
05

Beyond Hashing: Duplex Construction

The Duplex construction is an extension of the sponge, enabling authenticated encryption and interactive protocols. It allows for interleaved absorption and squeezing, making it stateful. This is used in:

  • Authenticated Encryption: Modes like Ketje and Keyak.
  • Zero-Knowledge Proof Systems: Some ZK-SNARK and STARK protocols use sponge/duplex constructions as a Fiat-Shamir transform to make interactive protocols non-interactive, critically relying on their random oracle properties.
06

Comparison to Merkle-Damgård

Sponge construction addresses several limitations of the older Merkle-Damgård structure (used in MD5, SHA-1, SHA-2):

  • No Length-Extension Attacks: Appending data to a hash is not feasible without the secret internal state.
  • Built-in Domain Separation: Easier to create different functions from the same permutation.
  • Flexible Security Level: The security parameter (capacity c) can be tuned independently of output size. This makes it a more modern and resilient foundation for cryptographic standards.
security-considerations
SPONGE CONSTRUCTION

Security Considerations

While the sponge construction provides a robust cryptographic framework, its security depends on the underlying permutation function, capacity size, and implementation details. These cards outline the primary security properties and potential vulnerabilities to assess.

01

Indifferentiability from a Random Oracle

A core security goal for sponge functions is indifferentiability from a Random Oracle (RO). This means that, given a secure underlying permutation, the sponge construction behaves like an ideal random function for any adversary with bounded computational resources. This property is crucial for ensuring the hash function's security in protocols that assume a RO model.

  • Proof Framework: Security is formally proven under the assumption that the internal permutation is a public random permutation.
  • Implication: Any attack on the sponge hash function implies an attack on the underlying permutation.
02

Capacity & Security Strength

The capacity (c) of the sponge state directly determines its collision resistance and preimage resistance security levels.

  • Collision Resistance: Security is c/2 bits. For a 256-bit capacity, collision resistance is 128 bits.
  • Preimage & Second Preimage Resistance: Security is c bits. For a 256-bit capacity, resistance is 256 bits.
  • Key Rule: The rate (r) absorbs input/output speed but does not contribute to these core security bounds. The internal state size is r + c, but only c is hidden from the adversary.
03

Sponge-Duplex & State Corruption

When used in duplex mode for authenticated encryption or reseedable PRNGs, the construction is vulnerable to state recovery attacks if an adversary can manipulate or observe the internal state.

  • Threat: If an attacker learns the full internal state, they can forge messages or predict future outputs.
  • Mitigation: Use a sufficiently large capacity and ensure proper domain separation between phases (absorbing, squeezing) to prevent state leakage through outputs.
04

Length Extension & Its Irrelevance

Unlike Merkle-Damgård constructions (e.g., SHA-256), the basic sponge is not vulnerable to length extension attacks. This is because the output is a truncation of the internal state after finalization.

  • Key Difference: An attacker cannot take a hash output H(M) and compute H(M || pad || X) without knowing the full internal state at the end of processing M.
  • Note: Some variants (e.g., SHAKE256) are extendable-output functions (XOFs), allowing arbitrary-length output, which is a feature, not a vulnerability.
05

Side-Channel & Implementation Attacks

Real-world security depends on a leak-resistant implementation of the permutation (e.g., Keccak-f).

  • Timing Attacks: The permutation should execute in constant time to prevent data-dependent timing variations.
  • Power Analysis: Hardware implementations must be resistant to Differential Power Analysis (DPA).
  • Fault Attacks: Resistance to glitching or inducing computational errors to reveal state information is critical for hardware security modules.
06

Genericity & Permutation Security

The sponge's security proof is generic; it assumes the internal permutation is ideal. Therefore, the security of a specific sponge hash (like SHA3-256) reduces to the cryptographic strength of its permutation (Keccak-f[1600]).

  • Primary Risk: If a cryptanalytic breakthrough finds weaknesses in the permutation (e.g., non-random properties, efficient distinguishers), the security guarantees of the sponge construction degrade proportionally.
  • Defense: Use permutations with large, well-analyzed state sizes (e.g., 1600-bit for SHA-3) to provide a large security margin.
HASH FUNCTION COMPARISON

Sponge vs. Merkle-Damgård Construction

A technical comparison of the two primary iterative structures used in modern cryptographic hash functions.

Feature / PropertySponge ConstructionMerkle-Damgård Construction

Underlying Principle

Absorb-Squeeze phases on a finite state (sponge)

Compression function chaining with fixed-length output

Internal State Size

Larger than output (e.g., 1600-bit for SHA-3)

Typically equal to output (e.g., 256-bit for SHA-256)

Length Extension Attack

Built-in Resistance

Resistant by design

Requires specific padding (e.g., HMAC)

Output Flexibility

Variable-length output from squeezing phase

Fixed-length output (requires truncation)

Parallel Processing

Supports parallel absorption (duplex mode)

Inherently sequential

Primary Example

SHA-3 (Keccak)

SHA-256, MD5

Provable Security

Based on random sponge model

Based on random oracle model (ideal compression)

etymology
CRYPTOGRAPHIC FOUNDATIONS

Etymology and Origin

The term 'sponge construction' originates from a specific analogy in cryptography, describing a function's ability to absorb and later squeeze out data.

The sponge construction is a cryptographic mode of operation for building hash functions and other cryptographic primitives, first formally introduced by Guido Bertoni, Joan Daemen, Michaël Peeters, and Gilles Van Assche in their 2007 paper Sponge Functions. The name is a direct analogy to a physical sponge: the function first absorbs input data into its internal state, and then squeezes out output data of a desired length. This two-phase process is the core of its operation and the source of its distinctive name.

The development of the sponge construction was a pivotal moment in post-SHA-1 cryptography, emerging from the Keccak team's research that would later win the NIST hash function competition to become SHA-3. Its design was a deliberate departure from the Merkle–Damgård construction used in earlier standards like SHA-2, which was vulnerable to length-extension attacks. The sponge's elegant, variable-output-length design offered inherent resistance to such attacks and provided a unified framework for hashing, authenticated encryption, and pseudorandom number generation.

The internal components of a sponge are defined by a permutation function (denoted f), a bitrate (r), and a capacity (c). During the absorbing phase, input blocks are XORed into the r-bit portion of the state, interleaved with the permutation f. In the squeezing phase, output blocks are taken from the same r-bit portion after each application of f. The security level is primarily determined by the hidden c-bit capacity, which remains untouched by direct input or output. This clear separation of interface (r) and security (c) is a foundational principle of the design.

Beyond its theoretical elegance, the sponge construction's origin story is deeply practical. It was designed for simplicity and flexibility in both hardware and software implementations. The Keccak permutation at its heart operates on a fixed-size state, allowing for efficient, constant-time operations. This design philosophy made the resulting SHA-3 standard not just secure, but also highly performant across a wide range of computing environments, from embedded systems to high-speed servers, cementing the sponge's legacy as a modern cryptographic workhorse.

SPONGE CONSTRUCTION

Frequently Asked Questions

Sponge construction is a cryptographic framework used to build hash functions and other primitives. This section answers common questions about its role in blockchain protocols like Ethereum and its security properties.

A sponge construction is a cryptographic framework for building functions that can absorb an arbitrary amount of input data and then squeeze out an arbitrary amount of output, such as a hash or a key stream. It operates in two phases: an absorbing phase, where input data is processed in blocks, and a squeezing phase, where output is generated. The core of the construction is a fixed-width permutation function (like Keccak-f) applied to an internal state, which is divided into a rate (r) and a capacity (c). The security level is primarily determined by the capacity parameter, which remains hidden from direct manipulation.

further-reading
SPONGE CONSTRUCTION

Further Reading

Dive deeper into the cryptographic primitives, protocols, and applications that build upon or relate to the sponge construction.

02

Duplex Construction

The duplex construction is an extension of the sponge model for authenticated encryption and other modes. It enables interleaved data absorption and squeezing within a single session, maintaining state between calls. This is fundamental to protocols like Ketje and Keyak, and forms the basis for the sponge-based pseudo-random function (PRF) used in many cryptographic suites.

03

Zero-Knowledge Proofs (ZKPs)

Sponge functions are a cornerstone in modern zero-knowledge proof systems, particularly zk-SNARKs and zk-STARKs. They serve as the cryptographic sponge for building collision-resistant hash functions within arithmetic circuits. Their efficiency and security properties make them ideal for creating the Fiat-Shamir transform, which converts interactive proofs into non-interactive ones, and for generating public parameters.

04

Rescue & Poseidon Hashes

Rescue and Poseidon are families of arithmetic-friendly hash functions designed using a sponge construction. They are optimized for efficiency in ZK-SNARK and STARK proof systems, where operations are performed over finite fields. Their design uses fewer multiplicative constraints than earlier designs like MiMC, making them significantly faster to prove in circuits like those used by zkSync and StarkNet.

05

Sponge-Based PRNGs

The sponge construction naturally lends itself to creating cryptographically secure pseudo-random number generators (CSPRNGs). By seeding the sponge's internal state and then repeatedly squeezing it, a deterministic, unpredictable stream of random bits is produced. This is used in various deterministic key derivation functions and within the internal state management of some blockchain clients for entropy generation.

06

Security Proofs & Indifferentiability

A key theoretical result for the sponge construction is its proven indifferentiability from a random oracle when the underlying permutation is assumed to be ideal. This proof, formalized in the Random Sponge model, provides strong security guarantees. It means a sponge hash can securely replace a random oracle in most cryptographic protocols, a critical foundation for its adoption in post-quantum and advanced protocol design.

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