GitHub | 𝕏

Acknowledgments

Special thanks to Marco Besier, Emile , and 0x18a6 for reviewing the blog and providing valuable feedback. Your comments helped improve its clarity and accuracy.

<aside> 🧭

In this blog, you will learn:

Poseidon Hash (Sponge Construction)

Before going deeper, it is important to separate two things:

<aside> 🧽

Poseidon Hash ≠ Poseidon Permutation.

So:

$$ Poseidon \, Hash = Sponge \, construction + Poseidon \, permutation \, π $$

The permutation itself is not the full hash. It is the function used inside the hash.

Sponge Construction Basics

Sponge-based hash function has 4 main components:

  1. State memory (S)

  2. Permutation / compression function $Poseidon^π$ $( f )$

  3. Padding function

  4. Squeeze phase (output generation)

    image.png

    Poseidon Hash as a Sponge

    Now let’s see how Poseidon uses the sponge construction.

    Assume:

    $$ t = 3 \\ r = 2 \\ c = 1 $$

    So the state is:

    $$ [x₀, x₁ | x₂] $$


    1. Message Input

    Assume we want to hash:

    $$ m = [5, 7, 9] $$

    Since the rate is $r = 2$ we split the message into chunks of 2 elements:

    $$ m₁ = [5, 7] \\ m₂ = [9, pad] $$

    The second chunk needs padding because it only has one element.


    2. Initial State

    The sponge starts from the all-zero state:

    $$ S₀ = [0, 0 | 0] $$


    3. Absorb First Chunk

    First chunk:

    $$ m₁ = [5, 7] $$

    Add it into the rate part:

    $$ [0, 0 | 0] + [5, 7 | 0]

    [5, 7 | 0] $$

    Then apply the full Poseidon permutation:

    $$ π([5, 7 | 0]) = [a, b | cap₁] $$

    Important:

    $$ π = full \, Poseidon \, permutation $$

    It is not one round. It contains many internal Hades rounds.


    4. Absorb Second Chunk

    Second chunk:

    $$ m₂ = [9, pad] $$

    Current state:

    $$ [a, b | cap₁] $$

    Absorb the second chunk into the rate part:

    $$ [a, b | cap₁] + [9, pad | 0]

    [a + 9, b + pad | cap₁] $$

    Then apply the full Poseidon permutation again:

    $$ π([a + 9, b + pad | cap₁]) = [h₀, h₁ | cap₂] $$


    5. Squeeze Output

    The output is taken from the rate part:

    $$ [h₀, h₁] $$

    If we need one hash element:

    $$ hash = h₀ $$

    If we need two output elements:

    $$ hash = [h₀, h₁] $$

    If we need more output elements than the rate allows, we apply the permutation again and keep reading from the rate part.

    This is called squeezing.


    Sponge Flow Summary

    image.png


Meaning of $I_c \oplus m_1$

Many descriptions write:

$$ I_c \oplus m_1 $$