Skip to content

research: poseidon-constraint-breakdown - #58

Open
alexandre-mrt wants to merge 1 commit into
mainfrom
research/2026-09-10-poseidon-constraint-breakdown
Open

research: poseidon-constraint-breakdown#58
alexandre-mrt wants to merge 1 commit into
mainfrom
research/2026-09-10-poseidon-constraint-breakdown

Conversation

@alexandre-mrt

@alexandre-mrt alexandre-mrt commented Sep 10, 2026

Copy link
Copy Markdown
Owner

Summary

Nightly research loop, 2026-09-10. Measures the isolated R1CS constraint cost of every circomlib
gadget Veil's three circuits instantiate (Poseidon(2..5), Num2Bits(8/64), three comparator
templates, MultiMux1(2), and the composite MerkleProof(20)) and reconciles those numbers
exactly against each circuit's measured total constraint count (both non-linear and linear),
accounting for circom's default --O1 signal-elimination behavior.

Finding: the 20-deep Merkle authentication path (Poseidon(2) called 20 times per proof), not
the "four Poseidon instances" the README and 2026-07-22 baseline call out, is the dominant
non-linear-constraint cost — 76.0% of transfer.circom and 81.2% of compliance.circom.
The domain-tagged commitment/nullifier/context hashes are only 14-18%. This re-scopes the queued
"Poseidon2" experiment toward the Merkle-path hash specifically, and re-ranks EXPERIMENTS.md to
put a Merkle-depth measurement (no new dependency needed) ahead of it.

Also re-attempted queue item #1 (on-chain gas per entry point) first, per the queue's own note.
Still BLOCKED, but for a confirmed, precise reason this time (see the report's addendum): this
session's GitHub access is scoped to alexandre-mrt/veil only (blocking github.com/
api.github.com/codeload.github.com for MystenLabs/sui), and the Sui testnet fullnode RPC is
blocked by egress policy — both verified directly with curl, not inferred from a denied tool call.

No circuit, Move, or frontend code was changed — this is measurement infrastructure
(scripts/bench/circuit-gadget-cost/) and documentation (a new report, plus updates to
LEDGER.md, EXPERIMENTS.md, and a new "Constraint cost by gadget" section in BASELINE.md).

Full report: https://github.com/alexandre-mrt/veil/blob/research/2026-09-10-poseidon-constraint-breakdown/docs/research/2026-09-10-poseidon-constraint-breakdown.md

Test plan

Nothing runnable was skipped or loosened. Everything that could run tonight is green; the two
NOT-RUN rows are pre-existing toolchain blockers unrelated to this change (no circuit/Move code
touched — same posture the 2026-07-22 baseline PR merged under).

  • bash scripts/bench/circuit-gadget-cost/run.sh — new gadget-isolation benchmark, output
    matches the report's tables exactly
  • Circuits, HASH-ONLY/fallback mode — 108/108 pass (node --experimental-vm-modules test/{transfer,compliance,withdraw}.test.mjs)
  • Proof converter — 109/109 pass (cd scripts && bun run src/test-converter.ts)
  • Compliance utils — 67/67 pass (cd scripts && bun run src/test-compliance-utils.ts)
  • Property-based fuzz — 6/6 properties pass, 500 runs each (cd scripts && bun run src/fuzz-tests.ts)
  • Frontend (vitest) — 19/19 pass (cd frontend && bunx vitest run)
  • Circuits, real Groth16 full-proof mode — NOT RUN: needs pot15_final.ptau from
    storage.googleapis.com, blocked by egress policy this session (403, confirmed via curl)
  • Move contracts (sui move test) — NOT RUN: sui CLI unavailable this session (see
    addendum in the report for exactly why)

🤖 Generated with Claude Code

https://claude.ai/code/session_019t4x7PtYcPbk9z5MEZiN8v

Measures the isolated R1CS constraint cost of every circomlib gadget
Veil's circuits instantiate and reconciles it exactly (non-linear and
linear counts, all three circuits) against the measured baseline totals,
accounting for circom's default --O1 signal-elimination behavior.

Finding: the 20-deep Merkle authentication path (Poseidon(2) x20), not
the domain-tagged commitment/nullifier/context hashes the README
highlights, is the dominant non-linear-constraint cost in
transfer.circom (76.0%) and compliance.circom (81.2%). Re-scopes the
queued Poseidon2 experiment toward that call specifically and re-ranks
EXPERIMENTS.md accordingly; the original Poseidon2 swap stays PARKed
on a missing dependency (no audited Poseidon2 circom implementation to
vendor).

Also re-attempts queue item #1 (on-chain gas): still BLOCKED, now for
a confirmed, precise reason (this session's GitHub access is scoped to
alexandre-mrt/veil only; Sui testnet RPC blocked by egress policy) —
see the report's addendum.

No circuit, Move, or frontend code changed. Full writeup:
docs/research/2026-09-10-poseidon-constraint-breakdown.md
Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_019t4x7PtYcPbk9z5MEZiN8v
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