sol_poseidon2 — a faster Poseidon2 hash syscall on BN254 #569
TypiCal25
started this conversation in
SIMD Discussions
Replies: 3 comments 4 replies
-
|
Do you think we could just reuse the existing |
Beta Was this translation helpful? Give feedback.
3 replies
-
|
Do we have concept ack from @samkim-crypto and @0x0ece? |
Beta Was this translation helpful? Give feedback.
1 reply
-
|
Yes, I am in support of this as well.
|
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
-
sol_poseidon2— a faster Poseidon2 hash syscall on BN254Add a new syscall,
sol_poseidon2, exposing the Poseidon2 hash function over the BN254 (alt_bn128) scalar field — the direct successor tosol_poseidon. It is purely additive and feature-gated (enable_poseidon2_syscall);sol_poseidonis untouched. Aparametersflag selects between two editions of the same permutation that differ only in their partial-round count.Problem
Every program that recomputes a ZK-friendly hash on-chain — Merkle-path verification, commitment checks, public-input digests — pays for it in CU, which is why
sol_poseidonexists. Butsol_poseidonruns the original Poseidon, and the ecosystem has since moved on:x⁵S-box, identical security analysis, with only the linear layer redesigned. It cuts permutation multiplications by up to ~90% and Plonk/R1CS constraints by up to ~70% (up to ~4× faster). On-chain, that is a direct CU reduction on the hashing every ZK program already does.t=3sponge makes on-chain cost linear and predictable in input length (ceil(n/2)fixed-width permutations) instead of growing with a per-width round schedule.Proposed Approach
One syscall, ABI-identical to
sol_poseidonso it reuses the audited slice-translation path and keeps tooling familiar:p = 21888…495617, S-boxx⁵, widtht=3; external matrixM_E = circ([2,1,1]), internal matrixM_Iwith diagonal[1,1,2]; round orderM_E→R_F/2full →R_Ppartial →R_F/2full.[0, 0, n](the capacity lane carries input length as a domain tag, so different arities can't collide); absorb 2 per block, squeezestate[0]. Cost is linear inn.parametersflag, differing only in the partial-round countR_P:M0, default)1)R_Pconstant table.base + ceil(n/2)·C_edition, withC_256 ≈ 1.7·C_128, pinned in the SIMD.Why Two Editions
This is the part most worth scrutinising, because it is easy to over-claim. The
parametersflag is purely an algebraic-cryptanalysis margin. It does not change generic or post-quantum security.The "128"/"256" is the Poseidon2 design security level
M— the bound below which algebraic attacks (Gröbner-basis / interpolation) must fail. For these instancesR_F=8covers statistical attacks identically, so the difference lives entirely inR_P. It is not a data-security claim: a sponge's generic security here is capped by the BN254 field, and is identical for both editions:So Poseidon2-128 is the right default for essentially everything, including long-lived secret data. Harvest-now-decrypt-later on both commitments (
H(secret, rand)) and additive/sponge ciphertexts (ct = pt + H(key, nonce…)) reduces to preimage/one-wayness, never collision — and that is ~2¹²⁷ quantum for both editions.The only thing Poseidon2-256 buys is headroom in the algebraic margin, and that margin is a live, moving research target: the 2025 subspace-trail Gröbner analysis (ToSC 2025/954, follow-up 2026/967) found the original round-count model mis-estimates rounds — without breaking 128-bit prime-field Poseidon. A quantum adversary doesn't get a clean √ speedup either: the Grover+Gröbner hybrid (2017/1236) accelerates only the variable-guessing dimension, not the dominant Gröbner linear algebra. For irreversible, indefinitely-lived secrets that can never be re-hidden once written, a caller may rationally want margin that survives those revisions; for everything else it is wasted CU. A per-call flag lets each site pay exactly for the margin it wants — at zero cost to callers that don't. (Reasonable people may prefer to ship 128 only; see Feedback.)
Use Cases
sol_poseidongets cheaper, predictable hashing and stays aligned with Poseidon2-native provers (Plonky3, RISC Zero, Circom).Future Work
Out of scope for this SIMD but enabled or complemented by it:
Draft SIMD
Full proposal with the complete ABI, permutation/sponge specification, KATs, CU model, alternatives, and a detailed security analysis (two-lever model, Grover/BHT/Gröbner, and harvest-now-decrypt-later):
https://drive.google.com/file/d/1nK9BZpBMSPo3Ypoj8YH1x6EYE8IkHAeo/view?usp=sharing
Feedback Welcome
sol_poseidonwith newParametersvariants (the SIMD-0388 enum-discriminated pattern)? I lean new — it's a different permutation and a different construction (fixedt=3sponge vs.t=n+1).N_max— does the linearbase + ceil(n/2)·C_editionmodel work for cross-client determinism/cost reviewers (Anza, Firedancer), and what input cap do clients want.Beta Was this translation helpful? Give feedback.
All reactions