algebraic hashing for SNARK circuits
Poseidon and Poseidon2 — the algebraic hash that lives inside the SNARK.
Sponge-mode hashes built from an SPN round function over a prime field: every operation is a field operation, not a bitwise one. A single call compiles to roughly 50–300 PLONK constraints versus roughly 25 000 for SHA-256 — two orders of magnitude cheaper in-circuit.
Poseidon (2021) is the original construction. Poseidon2 (2023) is a faster revision with a streamlined linear layer and a different round schedule — drop-in compatible at the protocol level, not bit-identical.
the shape
Sponge on the outside, substitution-permutation network on the inside.
A sponge construction absorbs input field elements into the rate portion of the state, runs the permutation, then squeezes a digest. The permutation is a fixed number of rounds, each consisting of add round constants → α-power S-box → MDS matrix. Full rounds apply the S-box to every state element; partial rounds apply it to one element only — the asymmetry that drops constraint count without weakening the algebraic-attack margin.
The cheap part is that every box in this diagram is a field operation. The expensive part — for SHA-256, in a circuit — is that every box is a bitwise operation, which a PLONK arithmetization has to simulate from scratch.
why it's cheap — interactive comparator
In-circuit constraint count: Merkle path of depth .
A Merkle-membership proof hashes one node per tree level. Pick a depth; see what a PLONK circuit has to spend on the path for each hash family. Order-of-magnitude figures only — the headline ratio is what matters.
Figures are the source's order-of-magnitude estimates — not measurements from a specific gadget. Poseidon2's roughly 20–30% improvement over Poseidon at the same $t = 3 / \alpha = 5$ parameters comes from a streamlined linear layer and a tighter round schedule, not from a different security target.
parameters
Concrete numbers.
Pinned by the deployment. Parameter discipline matters here — different field × state-width × round-count tuples produce incompatible hashes.
wiring — Merkle hash · transcript hash · host function
Three places the same Poseidon2 instance shows up.
Same permutation, same parameters, three distinct call sites. Two off-chain inside the prover's circuit; one on-chain inside the verifier's host environment. Anything else is a parameter-set bug.
Cool/blue tint for the two in-circuit lanes — those run off-chain inside the prover. Amber for the on-chain lane — the only call site the chain pays for, on the verifier side. The red callout points at the cross-reference to PLONK's simulation-extractability requirement; the hash itself doesn't carry that risk, the way it's used does.
security
A hash that survives the curve break around it.
Two assumptions, two horizons — and unusually for this stack, both cards are green. The post-quantum card is the good news here: a Grover speedup halves the security level, it does not collapse it. The catch is that the system around the hash still falls.
Collision & (second-)preimage resistance of the permutation.
Instantiated with the Horizen Labs canonical round-constant and MDS matrix set. Published analysis covers the relevant algebraic-attack families with a safety margin against the best known cryptanalysis at $R_F = 8 / R_P = 56$.
- Algebraic attack families covered: Gröbner-basis, interpolation, higher-order differential.
- Safety margin chosen against the best known cryptanalysis — round counts have been adjusted twice since the 2021 publication.
- Sponge mode reduces to permutation security via the standard indifferentiability argument.
Grover's $\sqrt{N}$ — and nothing worse — is the relevant quantum speedup.
The hash is hash-based. A CRQC finds collisions at roughly half the classical bit-security level; 128-bit classical collision resistance becomes ~64-bit post-quantum collision resistance. The permutation itself survives.
- Grover is the only relevant quantum speedup; no Shor-style polynomial-time attack applies to a hash.
- But the system around it does not. KZG and PLONK on BLS12-381 fall under Shor regardless of which hash the Fiat-Shamir transcript uses.
- Migration headroom is in the state width $t$ and the digest size — not in the hash family. A wider Poseidon recovers the bit-security margin without changing the construction.
This is the opposite colour story from the BLS12-381 and PLONK sheets: there, the post-quantum card was the red one. Here both cards are green. The visual contrast — a dashed border on the post-quantum card — is between well-studied and younger: algebraic cryptanalysis of Poseidon is on a shorter timeline than half a century of analysis around SHA-256's design family.
poseidon vs poseidon2 vs sha-256
Where each hash is cheap, and where it isn't.
Three hashes, three trades. Algebraic structure is what makes Poseidon and Poseidon2 cheap inside a SNARK and slow outside it. SHA-256 is the opposite — fast on hardware, prohibitively expensive in a circuit.
Poseidon
- Family
- algebraic · sponge + SPN
- In-circuit cost
- ~50–300 constraints / call
- Native CPU cost
- slower than SHA-256 natively
- PQ stance
- conjectured PQ-secure
- Maturity
- USENIX Security 2021 · round count adjusted twice since
Poseidon2
- Family
- algebraic · sponge + SPN
- In-circuit cost
- ~20–30% cheaper than Poseidon at the same parameters
- Native CPU cost
- faster than Poseidon natively
- PQ stance
- conjectured PQ-secure
- Maturity
- IACR ePrint 2023 · drop-in compatible at the protocol level
SHA-256
- Family
- Merkle–Damgård · bitwise compression
- In-circuit cost
- ~25 000 constraints / call
- Native CPU cost
- fastest natively · decades of hardware acceleration
- PQ stance
- conjectured PQ-secure · ~64-bit Grover bound
- Maturity
- FIPS 180-2, 2002 · conservative default outside SNARKs
All three are conjectured PQ-secure under Grover; the difference is age. SHA-256's design family has decades of cryptanalysis behind it. Poseidon's algebraic-attack analysis is younger — treat it with proportional humility for protocols where the hash is the long-term bottleneck.
references
Primary literature.
Four sources. The two Poseidon papers, the Stellar CAP defining the host function, and the PLONK paper that consumes the hash on the transcript side.
- Poseidon: A New Hash Function for Zero-Knowledge Proof Systems. USENIX Security 2021.
- Poseidon2: A Faster Version of the Poseidon Hash Function. IACR ePrint 2023/323.
- CAP-0075: Cryptographic Primitives for Poseidon and Poseidon2 Hash Functions. Stellar Protocol 25.
- PLONK: Permutations over Lagrange-bases for Oecumenical Noninteractive arguments of Knowledge. IACR ePrint 2019/953.