The State memory is divided into two sections: Bitrate and the remaining part the Capacity. Pad appends enough bits to the input string so that the length of the padded input is a whole multiple of. The padded input can thus be broken into -bit blocks.
This process "absorbs" all blocks of the padded input string. The sponge function output is now ready to be produced as follows:
the Bitrate portion of the state memory is output
repeat until enough bits are output:
* State is replaced by f
* the Bitrate portion of the state memory is output
If less than bits remain to be output, then Bitrate will be truncated. Another metaphor describes the state memory as an "entropy pool", with input "poured into" the pool, and the transformation function referred to as "stirring the entropy pool". Note that input bits are never XORed into the Capacity portion of the state memory, nor are any bits of Capacity ever output directly. The extent to which Capacity is altered by the input depends entirely on the transformation function f. In hash applications, resistance to collision or preimage attacks depends on Capacity, and its size is typically twice the desired resistance level.
Duplex construction
It is also possible to absorb and squeeze in an alternating fashion. This operation is called the duplex construction or duplexing. It can be the basis of a single pass authenticated encryption system.
The State is initialized to zero
Bitrate is XORed with the first -bit block of the input
State is replaced by f
Bitrate is now the first bits of the output.
Bitrate is XORed with the next -bit block of the input
State is replaced by f
Bitrate is now the next bits of the output.
…
Overwrite mode
It is possible to omit the XOR operations during absorption, while still maintaining the chosensecurity level. In this mode, in the absorbing phase, the next block of the input overwrites the Bitrate part of the state. This allows keeping a smaller state between the steps. Since the Bitrate part will be overwritten anyway, it can be discarded in advance, only the Capacity part must be kept.
Applications
Sponge functions have both theoretical and practical uses. In theoretical cryptanalysis, a random sponge function is a sponge construction where f is a random permutation or transformation, as appropriate. Random sponge functions capture more of the practical limitations of cryptographic primitives than does the widely used random oracle model, in particular the finite internal state. The sponge construction can also be used to build practical cryptographic primitives. For example, Keccak cryptographic sponge with a 1600-bit state has been selected by NIST as the winner in the SHA-3 competition. The strength of Keccak derives from the intricate, multi-round permutationf that its authors developed. The RC4-redesign called Spritz refers to the sponge-construct to define the algorithm. For other examples, a sponge function can be used to build authenticated encryption with associated data, as well as a password hashing schemes.