research: Poseidon constraint attribution across all three circuits - #43
Open
alexandre-mrt wants to merge 1 commit into
Open
research: Poseidon constraint attribution across all three circuits#43alexandre-mrt wants to merge 1 commit into
alexandre-mrt wants to merge 1 commit into
Conversation
Measures the exact non-linear R1CS constraint contribution of every Poseidon arity, the depth-20 Merkle-tree level, and every range-check/comparator gadget via isolated micro-circuits (circuits/bench-gadgets/), cross-validated by reconstructing each real circuit's constraint total from sum(gadget cost x call count) against docs/research/BASELINE.md. Poseidon accounts for 78-95% of non-linear constraints across all three circuits; the 20-level Merkle path alone (76-81% in transfer/compliance) outweighs every direct commitment/nullifier/leaf hash combined. Re-ranks EXPERIMENTS.md accordingly. Also confirms queue item #1 (on-chain gas) is blocked by a confirmed organization network policy (403 on github.com and fullnode.testnet.sui.io), not a toolchain gap, and validates circom2 (an npm-published WASM circom build) as a GitHub-free toolchain alternative. No protocol circuit was modified. Full writeup in docs/research/2026-08-25-poseidon-constraint-attribution.md.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Nightly research loop, queue item #2 (
docs/research/EXPERIMENTS.md). Measures the exactnon-linear R1CS constraint contribution of every Poseidon arity, one depth-20 Merkle-tree level,
and every range-check/comparator gadget Veil's circuits are built from, via isolated micro-circuits
under
circuits/bench-gadgets/, then cross-validates the attribution by reconstructing each realcircuit's total (
sum(gadget cost × call count)) against the independently-measured baseline indocs/research/BASELINE.md.transfer.circom,compliance.circom, andwithdraw.circom.have one — bigger than every direct commitment/nullifier/credential-leaf hash combined.
(compliance) — fully explained by top-level glue constraints the isolated gadgets don't include.
from the npm registry, and the reference material to hand-write one safely (round constants,
round structure) lives on GitHub/IACR ePrint — both blocked by this environment's egress policy.
policy (403 on
github.comandfullnode.testnet.sui.io, verified via directcurl), not atoolchain gap — re-ranked down in
EXPERIMENTS.mdaccordingly.circom2(an npm-published WASM build of the circom compiler) as aGitHub-free toolchain — reproduces the existing baseline byte-for-byte, used to rebuild and
re-run the full circuit test suite.
No protocol circuit was modified. All new gadgets live in
circuits/bench-gadgets/, neverwired into the build, deployment, or frontend — so this PR carries no soundness/leakage/negative-test
obligation (nothing new enters the protocol).
Full writeup:
docs/research/2026-08-25-poseidon-constraint-attribution.mdWhat changed
circuits/bench-gadgets/*.circom— 12 single-gadget micro-circuits (Poseidon arities 2–5,Num2Bits(64/8), comparators,MultiMux1(2), one Merkle-tree level).scripts/bench/gadget-attribution.mjs— reusable benchmark: compiles every gadget, reconstructseach real circuit's constraint total from the parts, and (
--prove) times real Groth16 proofsfor a representative subset.
docs/research/BASELINE.md— new "Constraint attribution (by gadget)" section.docs/research/LEDGER.md— new row (KEEP).docs/research/EXPERIMENTS.md— re-ranked: Merkle-depth-vs-anonymity-set moved above thePoseidon2 swap; on-chain gas demoted with an explicit "don't re-attempt without a policy change"
note; added an item for adopting
circom2as the documented toolchain.circuits/package-lock.json— incidental lockfile sync (snarkjsrange already pinned inpackage.json;npm installcorrected a stale entry in the lock).Test plan
node --experimental-vm-modules test/transfer.test.mjs— 43/43 passnode --experimental-vm-modules test/withdraw.test.mjs— 35/35 passnode --experimental-vm-modules test/compliance.test.mjs— 30/30 passbun run src/test-converter.ts— 109/109 passbun run src/test-compliance-utils.ts— 67/67 passbunx vitest run(frontend) — 19/19 passsui move test— NOT RUN,suiCLI unavailable in this environment (confirmed networkpolicy block, same as queue item feat: Veil privacy payment protocol — full stack MVP #1 — pre-existing, unrelated to this change)
node scripts/bench/gadget-attribution.mjsand--prove— reproduced live, output matchesthe report
Generated by Claude Code