The sponge construction #
The sponge construction ([BDPVA08]; [KL20], Section 7.3.3
and Construction 7.6) builds a hash function from a single unkeyed permutation P on an
ℓ-bit state split into a rate part of r bits and a capacity part of c bits, r + c = ℓ.
Starting from the all-zero state, each r-bit message block is added (XORed) into the rate part
and the state is permuted (absorbing); afterwards the hash outputs part of the state, permutes,
and repeats (squeezing).
The executable definitions and deterministic collision implications only apply P; they do not
use its inverse or injectivity. Their parameter is therefore the underlying state function
R × C → R × C. Permutations coerce to this function, while concrete clients such as FIPS 202's
Keccak transformation need no unnecessary inverse wrapper.
We write the state as a pair (rate, capacity) : R × C, with the rate part R an additive group
(for bits, BitString r, where + is exclusive or). This is the source's ℓ-bit state with
y ⊕ (m ‖ 0^c) read as (y.1 + m, y.2). Each squeezing step outputs out y for an arbitrary
output map out; Construction 7.6 takes the first v bits of the state, and the results below
hold for every out.
Theorem 7.7 bounds the collision probability when P is a random permutation by splitting
collisions into three bad events on the attacker's permutation queries (Claim 7.8). We prove the
deterministic core of Claim 7.8 for permutation queries: if two distinct block sequences have
equal first output, then among the permutation inputs evaluated while hashing them either two
distinct inputs have images with equal output (event E1), some image has zero capacity part
(event E2), or two distinct inputs have images with equal capacity part (event E3). Inverse
queries and the probability bound of Claim 7.9 are not formalized here. Conversely, a collision
in the capacity part always extends to a full collision, which is why the capacity governs
security; we use this to solve [KL20], Exercise 7.26.
Main definitions #
Cslib.Crypto.Sponge.absorb,Cslib.Crypto.Sponge.squeeze,Cslib.Crypto.Sponge.hashBlocks: the absorbing and squeezing phases on block sequences.Cslib.Crypto.Sponge.hash: the hash of Construction 7.6, on the paddingm ↦ m ‖ 1 ‖ 0^*(Cslib.BitString.pad10star) parsed intor-bit blocks (Cslib.BitString.toBlocks).Cslib.Crypto.Sponge.IsInput: the permutation inputs evaluated while absorbing.Cslib.Crypto.Sponge.ImageCollision,Cslib.Crypto.Sponge.ZeroCapacity: the bad events of Claim 7.8 on a set of evaluated permutation inputs.
Main results #
Cslib.Crypto.Sponge.badEvent_of_hash_eq: every collision between distinct messages triggers one of the events E1, E2, E3 among the evaluated permutation inputs (Claim 7.8, forward queries).Cslib.Crypto.Sponge.take_squeeze,take_hashBlocks: requesting more squeezing blocks preserves every earlier block.Cslib.Crypto.Sponge.hash_eq_of_capacity_eq: a capacity collision between equal-length full-block messages extends to a hash collision.Cslib.Crypto.Sponge.hash_prodCongr_collision: a permutation that acts separately on the rate and capacity parts gives an explicit collision ([KL20], Exercise 7.26).
References #
- G. Bertoni, J. Daemen, M. Peeters, G. Van Assche, On the Indifferentiability of the Sponge Construction
- J. Katz, Y. Lindell, Introduction to Modern Cryptography, Section 7.3.3, Construction 7.6, Theorem 7.7, Claim 7.8 and Exercise 7.26.
Absorbing and squeezing #
Two distinct inputs in Q whose images under P agree under f. With f = out this is
event E1 of [KL20], Claim 7.8; with f = Prod.snd (the capacity part) it is
event E3.
Claim 7.8 for forward queries ([KL20], Section 7.3.3): if two distinct nonempty block sequences have equal first output, then among the permutation inputs evaluated while absorbing them, event E1 (two distinct inputs whose images have equal output), event E2 (an image with zero capacity part) or event E3 (two distinct inputs whose images have equal capacity part) occurs.
A capacity collision extends to a full collision. If a and a' reach states with
equal capacity part, then appending m to a and the corrected block
-(absorb P a').1 + ((absorb P a).1 + m) to a' reaches the same state, so any common
suffix gives equal hashes.
The sponge hash on messages #
The sponge hash of Construction 7.6 with k squeezing outputs: pad the message with
pad10star, parse it into r-bit blocks and run hashBlocks. The output is the list
[h₁, …, h_k]; with out the first v bits of the state, its flattening is h₁ ‖ ⋯ ‖ h_k.
Claim 7.8 for forward queries, on messages: a collision between distinct messages triggers event E1, E2 or E3 among the permutation inputs evaluated while absorbing their padded block sequences.
Generic capacity-collision attack: if distinct full-block messages u ≠ u' of equal
length reach states with equal capacity part, then extending them by one block each (m, and the
corrected block for u') gives two distinct messages with equal hashes, for every output map
and number of squeezing outputs.
Exercise 7.26 ([KL20], Section 7.3.3): if the permutation acts separately on
the rate and capacity parts, P = S × T, the capacity part after absorbing never depends on the
message, so the one-block messages 0^r and 1^r already have equal capacity part and extend
to an explicit collision. (The exercise's P = S₁ ‖ ⋯ ‖ S₈ with r = c = 4n is such a
product.)