Skip to content

research: Poseidon2 vs Poseidon at Veil's actual arities — REJECT - #44

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

research: Poseidon2 vs Poseidon at Veil's actual arities — REJECT#44
alexandre-mrt wants to merge 1 commit into
mainfrom
research/2026-08-26-poseidon2-arity-gap

Conversation

@alexandre-mrt

Copy link
Copy Markdown
Owner

Summary

  • Queue item feat: Tier 3 — KYC compliance circuit + ElGamal auditor pattern #2: measured whether swapping Veil's Poseidon(n) (circomlib) for Poseidon2 (@taceo/circom-lib, audited-lineage) reduces R1CS constraints / Groth16 proving time at Veil's real call arities (n=2,3,4,5). Built 8 isolated single-hash-call benchmark circuits + a domain-separation sanity check under circuits/bench-poseidon2/, with a reusable scripts/bench/ harness (real Groth16 setups, 10-run proving-time benchmarks, raw command output in the report).
  • Finding: @taceo/circom-lib's Poseidon2 only ships round constants for state sizes t ∈ {2,3,4,8,12,16} — no t=5/6. Veil's two heaviest arities (n=4: transfer/withdraw commitment+nullifier hashes; n=5: compliance credential leaf) must over-provision to t=8, costing +927/+828 constraints per call, vs. +63/+247 for n=2/n=3 (exact-width support, measurably faster proving). A computed (not measured, clearly labeled) projection onto the production circuits shows transfer.circom and withdraw.circom would likely cross a Groth16 QAP domain-size doubling under a naive swap — working against the goal.
  • Verdict: REJECT the off-the-shelf Poseidon2 swap. No production circuit changed. BASELINE.md unchanged (nothing to KEEP). A narrower, security-sensitive follow-up (generating custom t=5/t=6 round constants) is queued rather than attempted tonight.
  • Re-checked queue item feat: Veil privacy payment protocol — full stack MVP #1 (on-chain gas) first, per the queue's note — still blocked; now confirmed via the sandbox's proxy status endpoint as an organization egress-policy denial (403 on github.com/MystenLabs/sui/releases and fullnode.testnet.sui.io), not a toolchain gap. Did not retry further per proxy policy.
  • Bonus toolchain finding: circom2 (npm, WASM build of the circom compiler) reproduces transfer.circom's exact documented constraint counts with no build step and no GitHub access — a simpler alternative to last night's cargo-build-from-a-clone workaround, if the native-build path keeps needing blocked GitHub access.

Full writeup: docs/research/2026-08-26-poseidon2-arity-gap.md

Test plan


Generated by Claude Code

Queue item #2 for tonight's research loop. Built 8 isolated single-hash-call
circuits comparing circomlib's Poseidon(n) (what transfer/withdraw/compliance
circuits call today) against @taceo/circom-lib's audited-lineage Poseidon2Sponge,
at n=2,3,4,5 (Veil's real call arities), plus a domain-separation sanity check.
Real Groth16 setups and 10-run proving-time benchmarks for each, via a reusable
scripts/bench/ harness.

Finding: the off-the-shelf Poseidon2 library only ships round constants for
state sizes t in {2,3,4,8,12,16} — no t=5/6 — so Veil's two heaviest arities
(n=4, n=5) must over-provision to t=8, costing +927/+828 constraints per call
versus +63/+247 for n=2/n=3 (which have exact-width support and measurably
prove faster). A computed projection onto the production circuits shows
transfer.circom and withdraw.circom would likely cross a Groth16 domain-size
doubling under a naive swap — the opposite of the intended win.

No production circuit changed. Verdict: REJECT the off-the-shelf swap;
PARKed a custom-round-constants follow-up in EXPERIMENTS.md. Re-checked
on-chain gas (queue #1) first — still blocked, now confirmed as an org
egress-policy denial rather than a toolchain gap.

Full suite green: 108 circuit + 109 converter + 19 frontend tests pass.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_019kWTZvNUFZxTk9XjrEJPzi
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