Skip to content

research: Poseidon2 arity benchmark — no native params for Veil's dominant hash arities - #37

Open
alexandre-mrt wants to merge 1 commit into
mainfrom
research/2026-08-19-poseidon2-arity-benchmark
Open

research: Poseidon2 arity benchmark — no native params for Veil's dominant hash arities#37
alexandre-mrt wants to merge 1 commit into
mainfrom
research/2026-08-19-poseidon2-arity-benchmark

Conversation

@alexandre-mrt

Copy link
Copy Markdown
Owner

Summary

Nightly research loop, queue item #2: measures the real constraint-count and proving-time delta
from swapping Veil's Poseidon calls for Poseidon2, at Veil's actual hash arities (2, 3, 4, 5
inputs), using a vendored, correctness-cross-checked circom implementation
(@taceo/circom-lib 0.6.0).

Verdict: REJECT the tested hypothesis. Poseidon(4) (Veil's commitment hash — called 2–3×
per circuit, its single most-used gadget) and Poseidon(5) (compliance leaf hash) have no
native Poseidon2 parameter set
in the library checked — only t ∈ {2,3,4,8,12,16} exist. The
practical fallback (pad to t=8) nearly doubles R1CS constraint count for those two arities
(+99–126%). The two natively-supported arities are a wash on constraint count (fewer non-linear,
more linear, net worse), despite a measured proving-time speedup I don't trust at this circuit
scale (500–1700 constraints, two orders of magnitude below transfer.circom's 13,611 — fixed
per-call overhead likely dominates).

No protocol circuit was touched — this is a standalone benchmark under
circuits/research/poseidon2/, not wired into transfer.circom/withdraw.circom/compliance.circom.
BASELINE.md is unaffected.

Also re-attempted queue item #1 (on-chain gas) first: re-confirmed BLOCKED, now attributed to
a standing organizational egress-policy denial (403 on fullnode.testnet.sui.io, MystenLabs
releases, and crates.io alike — see /root/.ccr/README.md's guidance not to retry policy
denials), not a transient/session-specific failure. Re-ranked in the queue as needing a policy
exception, not another retry.

Full writeup: docs/research/2026-08-19-poseidon2-arity-benchmark.md

What's in this PR

  • circuits/research/poseidon2/ — vendored Poseidon2 circuit (MIT, attributed), a
    circomlib-compatible hash wrapper, 8 standalone benchmark circuits at Veil's actual arities,
    and correctness/negative-test verification scripts.
  • scripts/bench/poseidon2-bench-setup.sh + poseidon2-prove-latency.mjs — reusable
    compile/setup and Groth16 timing scripts (local pot12 ptau, no network fetch needed).
  • docs/research/2026-08-19-poseidon2-arity-benchmark.md — full report (hypothesis, threat
    model, approach, results, verdict, where this could be used, open questions).
  • docs/research/LEDGER.md — new row.
  • docs/research/EXPERIMENTS.md — re-ranked; item feat: Tier 3 — KYC compliance circuit + ElGamal auditor pattern #2 replaced by a narrower follow-up.

Test plan

  • node --experimental-vm-modules test/{transfer,compliance,withdraw}.test.mjs — 108/108 pass (unchanged from 2026-07-22 baseline)
  • cd scripts && bun run src/test-converter.ts — 109/109 pass
  • cd frontend && bun run test — 19/19 pass
  • node circuits/research/poseidon2/verify/verify.mjs — both correctness cross-checks (t=3 vs. a from-scratch reimplementation of the primary HorizenLabs reference, t=4 vs. @zkpassport/poseidon2) pass
  • node circuits/research/poseidon2/verify/negative_test.cjs — tampered-output and tampered-internal-wire witnesses both rejected
  • cd contracts && sui move testNOT RUN, sui CLI unavailable in this session (same blocker as the 2026-07-22 baseline; no Move code changed in this PR)

Generated by Claude Code

…inant hash arities (REJECT)

Queue item #2: measures constraint-count and proving-time deltas from swapping Veil's Poseidon
calls for Poseidon2, using a vendored, correctness-cross-checked circom implementation
(@taceo/circom-lib), at Veil's four actual hash arities.

Result: Poseidon(4) and Poseidon(5) -- the commitment hash (2-3x per circuit) and compliance
leaf hash, Veil's most-used gadgets -- have no native Poseidon2 parameter set in the library
checked (only t in {2,3,4,8,12,16} exist); the practical t=8-padding fallback nearly doubles
their R1CS constraint count. The two natively-supported arities are a wash on constraint count.
No protocol circuit was touched -- this is a standalone research benchmark under
circuits/research/poseidon2/, not wired into transfer/withdraw/compliance.circom.

Also re-confirms on-chain gas measurement (queue item #1) as blocked by a standing
organizational egress-policy denial (403 on the testnet fullnode, MystenLabs releases, and
crates.io alike), not a transient failure -- reframed in the queue as needing a policy exception
rather than another retry.

Full writeup: docs/research/2026-08-19-poseidon2-arity-benchmark.md
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants