Skip to content

research: poseidon-constraint-attribution - #77

Open
alexandre-mrt wants to merge 1 commit into
mainfrom
claude/intelligent-cannon-jzyul8
Open

alexandre-mrt wants to merge 1 commit into
mainfrom
claude/intelligent-cannon-jzyul8

Conversation

@alexandre-mrt

Copy link
Copy Markdown
Owner

Summary

Tonight's nightly research-loop run. Queue item #1 (on-chain gas per entry point) was re-attempted first and re-confirmed BLOCKED — this sandbox's egress proxy returns 403 for both github.com (needed for a sui CLI release) and fullnode.testnet.sui.io (a fallback JSON-RPC read), an org-level allowlist denial rather than a per-tool prompt this time. Per the sandbox's own proxy docs, that's not retried or routed around, so the run moved to the next un-settled queue item.

That turned into this experiment: the depth-20 Merkle membership proof, not the "four named Poseidon instances" README credits, is the dominant non-linear-constraint cost in transfer.circom and compliance.circom.

  • Built 10 isolated single-gadget probe circuits (scripts/bench/circuit-probes/*.circom) and a reusable script (scripts/bench/constraint-attribution.mjs) that compiles each probe plus fresh copies of all three production circuits, then reconciles a hand-written per-circuit "recipe" against the real compiled total.
  • Result: Merkle path = 76.0% of transfer.circom's and 81.2% of compliance.circom's non-linear constraints, vs. only 18.0%/14.1% for the named domain-tagged Poseidon calls. withdraw.circom (no Merkle path) is the one place the README's original claim holds (78.0%).
  • Attribution reconciles to the constraint: 0/3/0-constraint deltas across the three circuits (the compliance delta is fully explained — two boolean-enforcement constraints + one AND gate not present in the isolated comparator probes).
  • Per-Merkle-level cost is exactly 246 non-linear constraints (243 for Poseidon(2) + 2 for MultiMux1(2)'s selection + 1 boolean check), architecture-fixed — a real number for the queue's Merkle-depth-vs-anonymity-set item to compute against instead of guessing.
  • Toolchain note: used circom2 (npm-bundled WASM build of the real Rust circom compiler) since github.com/cargo's crate host are blocked here — it reproduces the 2026-07-22 baseline's native-circom constraint counts exactly, a useful fallback for future nights hitting the same block.

Docs updated: README.md and docs/research/BASELINE.md corrected (the "four Poseidon instances dominate" claim was materially misleading for two of the three circuits), docs/research/EXPERIMENTS.md re-ranked (Merkle-depth work promoted ahead of a Poseidon2 swap; Poseidon2 re-targeted at the Merkle-path arity, not the named hashes), docs/research/LEDGER.md appended, full write-up in docs/research/2026-09-27-poseidon-constraint-attribution.md.

No circuit, Move module, or frontend proving code was modified — this is a measurement/attribution night only.

Test plan

  • node --experimental-vm-modules test/{transfer,compliance,withdraw}.test.mjs — 108/108 pass (fallback/simulated mode — real-proof mode needs the pot15 ptau file, and storage.googleapis.com is also blocked in this sandbox; a new, previously-unseen blocked host, recorded honestly in BASELINE.md)
  • cd scripts && bun run src/test-converter.ts — 109/109 pass
  • cd scripts && bun run src/test-compliance-utils.ts — 67/67 pass
  • cd frontend && bun run test — 19/19 pass
  • cd contracts && sui move test — NOT RUN, sui CLI unavailable (same blocker as queue item feat: Veil privacy payment protocol — full stack MVP #1); no contract code changed
  • cd scripts/bench && npm install && node constraint-attribution.mjs — reproduces the numbers in this PR's report exactly

🤖 Generated with Claude Code

https://claude.ai/code/session_016Kg1ZFhKEHbxyx3JwiqEh5


Generated by Claude Code

…seidon calls

Measures where transfer.circom's and compliance.circom's non-linear
constraints actually come from, gadget by gadget, instead of relying on
README's "four Poseidon instances dominate" claim. The depth-20 Merkle
membership proof (20x Poseidon(2), not counted among the "four") turns out
to be responsible for 76.0% / 81.2% of non-linear constraints respectively
- the named domain-tagged Poseidon calls are only 18.0% / 14.1%.

Isolated single-gadget probe circuits (scripts/bench/circuit-probes/) sum
against each circuit's real recipe to reconcile exactly (0/3/0-constraint
deltas) with a fresh compile, via circom2 (npm-bundled WASM circom), which
this sandbox's github.com/cargo egress block made necessary and which
reproduces the 2026-07-22 native-circom baseline numbers exactly.

Corrects README.md and BASELINE.md, re-ranks EXPERIMENTS.md (Merkle-depth
work promoted ahead of a Poseidon2 swap, which should now target the
Merkle-path arity, not the named hashes), and re-confirms on-chain gas
(queue item 1) still BLOCKED - now precisely, both github.com and the Sui
RPC host return 403 from the sandbox's egress allowlist.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_016Kg1ZFhKEHbxyx3JwiqEh5

Copy link
Copy Markdown
Owner Author

CI is red on this PR (3 of 4 jobs), but both failures are pre-existing and unrelated to this PR's diff — this PR touches only scripts/bench/, docs/research/, README.md, and .gitignore, none of which either failing job's steps depend on.

1. Frontend (vitest + biome + tsc) and Proof converter + compliance utils — fail at "Set up job", before any repo code runs:

##[error]Unable to resolve action `oven-sh/setup-bun@735343b667d3e6f658f44e0a462d63b48e3324cb`, unable to find version `735343b667d3e6f658f44e0a462d63b48e3324cb`

Confirmed this is not caused by this PR: the exact same failure, on the exact same two jobs, reproduces on main's current HEAD (f942fca, this PR's own base) — run 30348614126. The pinned SHA for oven-sh/setup-bun no longer resolves (upstream likely force-pushed or deleted that ref). I don't have GitHub access outside this repo (alexandre-mrt/veil) to look up a current valid SHA for oven-sh/setup-bun, and re-pinning .github/workflows/ci.yml blindly is outside this PR's scope (a circuits-research PR touching CI config for an unrelated action would be guessing at a fix I can't verify). Proposed fix for whoever picks this up: re-pin oven-sh/setup-bun in .github/workflows/ci.yml to a current release commit SHA (check https://github.com/oven-sh/setup-bun/releases) — both jobs should go green immediately once that's done, no code change needed.

2. Circom circuits (real Groth16 proofs) — fails downloading the Powers of Tau file:

curl -fsSL -o build/pot15_final.ptau https://storage.googleapis.com/zkevm/ptau/powersOfTau28_hez_final_15.ptau
curl: (22) The requested URL returned error: 403

This same URL also returns 403 from my own sandbox tonight (see this PR's report, docs/research/2026-09-27-poseidon-constraint-attribution.md) — for me that's my sandbox's egress allowlist, but here it's GitHub's own hosted runner getting 403 directly from storage.googleapis.com, a different network entirely. That points at the object/bucket itself (possibly rate-limited or access-restricted), not a one-off network blip. I don't have permission to re-run the job to confirm (rerun_failed_jobs returned 403 Resource not accessible by integration), and this PR doesn't touch circuits/scripts/compile*.sh or the CI workflow, so there's nothing in this PR's diff to fix here either. Flagging for visibility — the same host also blocks a step of tonight's own research (see the report's Open Questions).

No production code, circuit, or CI config was touched by this PR, so I'm not pushing a fix for either — both are infrastructure/CI-config issues that predate and are independent of this change. Will keep watching this PR.


Generated by Claude Code

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