Skip to content

research: poseidon-constraint-decomposition - #54

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

research: poseidon-constraint-decomposition#54
alexandre-mrt wants to merge 1 commit into
mainfrom
claude/intelligent-cannon-80x3v7

Conversation

@alexandre-mrt

Copy link
Copy Markdown
Owner

Summary

Nightly research loop, one experiment: decompose the R1CS non-linear-constraint cost of every
Poseidon arity and range-check component Veil's three circuits use, via isolated single-component
circom fixtures, and reconcile against the existing BASELINE.md totals — the fallback framing
EXPERIMENTS.md item #2 explicitly offered ("re-deriving the exact non-linear-constraint
contribution per Poseidon instance from the current baseline") in place of a full Poseidon2 swap.

Headline finding: the 20-level Merkle path (MerkleProof(20)) is 76.0% of
transfer.circom's and 81.2% of compliance.circom's non-linear constraints — 4–5.7x the
identity-binding Poseidon calls a same-arity Poseidon2 swap would target. This re-prioritizes the
queue toward a wider-arity Merkle accumulator over a same-arity hash swap.

  • Reconciled 95.6–99.0% of each circuit's non-linear constraints using only measured, isolated
    components — no estimates.
  • New reusable script: scripts/bench/poseidon-constraint-cost.mjs + fixtures under
    scripts/bench/fixtures/poseidon-cost/.
  • No circuit, Move, or frontend source changed — a measurement night, like 2026-07-22.
  • Toolchain note: no native circom binary was installable this session (GitHub and
    static.crates.io both network-policy-denied); found and verified circom2 (npm, WASM build) as
    an exact-output substitute, and generated powers-of-tau fully offline instead of downloading.
    Documented in BASELINE.md and added as a circuits devDependency, so this doesn't have to be
    rediscovered on a future night.
  • On-chain gas (EXPERIMENTS.md item feat: Veil privacy payment protocol — full stack MVP #1) reconfirmed BLOCKED early in the session (GitHub,
    static.crates.io, and a direct fullnode.testnet.sui.io JSON-RPC read all return policy 403)
    before pivoting to this experiment.

Full writeup: docs/research/2026-09-05-poseidon-constraint-decomposition.md. Ledger, queue, and
BASELINE.md updated accordingly.

Test plan

  • node scripts/bench/poseidon-constraint-cost.mjs — reproduces the decomposition table in
    the report (95.6–99.0% reconciliation across all three circuits)
  • Circuits: node --experimental-vm-modules test/{transfer,compliance,withdraw}.test.mjs
    108/108 pass (re-run unmodified, using the circom2 substitute, as a sanity check that it's
    a safe drop-in — byte-identical constraint counts to the existing baseline)
  • Proof converter: cd scripts && bun run src/test-converter.ts — 109/109 pass
  • Frontend: cd frontend && bun run test — 19/19 pass
  • Move contracts (sui move test) — NOT RUN, sui CLI unavailable this session (unrelated
    pre-existing gap, same as 2026-07-22; no contract code touched)

🤖 Generated with Claude Code

https://claude.ai/code/session_01Pm9sks5VQ2kPoytPxeR1Ev


Generated by Claude Code

… path dominates

Queue item #2's fallback framing: measure the exact non-linear-constraint
contribution of each Poseidon arity and range-check component Veil's three
circuits use, via isolated circom fixtures, and reconcile against BASELINE.md
(95.6-99.0% of each circuit's total accounted for).

Headline finding: the 20-level Merkle path (MerkleProof(20), real template)
is 76-81% of transfer.circom's and compliance.circom's non-linear
constraints - 4-5.7x the identity-binding Poseidon calls a same-arity
Poseidon2 swap would target. Re-ranks EXPERIMENTS.md toward a wider-arity
Merkle accumulator as the higher-leverage next experiment.

Also: no native circom binary was installable this session (GitHub and
static.crates.io both network-policy-denied). Found and verified circom2
(npm, WASM build) as an exact-output substitute, and generated powers-of-tau
fully offline instead of downloading - unblocks the whole circuit toolchain
for future nights, not just this experiment. Documented in BASELINE.md and
added as circuits' devDependency.

Full existing suites re-run unmodified as a sanity check: circuits 108/108,
proof-converter 109/109, frontend 19/19 all pass. Move contracts NOT RUN
(sui CLI still unavailable - reconfirmed, not this experiment's scope). No
circuit, Move, or frontend source changed.

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