research: Poseidon/Merkle constraint-contribution breakdown - #35
Open
alexandre-mrt wants to merge 1 commit into
Open
research: Poseidon/Merkle constraint-contribution breakdown#35alexandre-mrt wants to merge 1 commit into
alexandre-mrt wants to merge 1 commit into
Conversation
…stance Isolates each gadget transfer.circom instantiates (Poseidon(2/3/4), the 20-level MerkleProof chain, non-Poseidon range-check scaffolding) in standalone circuits and sums the measured R1CS constraint counts against the real whole-circuit total (13,611) — exact match, 0 delta. Finds the 20x Poseidon(2) Merkle authentication path is 76.4% of transfer.circom's constraints (81.6% of compliance.circom's by inspection), an order of magnitude more than the three domain-tagged commitment/nullifier/amount-hash Poseidon(4)/(3) calls combined (20.7%). Reprioritizes any future Poseidon2 port toward the Merkle chain specifically, and re-ranks the experiment queue accordingly. Also re-attempts queue item #1 (on-chain gas): confirms the fullnode JSON-RPC path is a hard sandbox network-policy block, but finds git-clone + cargo-build for the sui CLI does work here (unlike the prior "impractical" assessment) — left running past this session's budget, documented with a procedural fix for the next run. Full suite green: 108/108 circuit tests, 109/109 converter, 67/67 compliance-utils, 19/19 frontend, 6/6 fuzz properties. Move contract tests still NOT RUN (sui CLI unavailable, same pre-existing gap as 2026-07-22, unrelated to this diff).
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 (option b): decomposes
transfer.circom's 13,611 R1CSconstraints into the sum of its isolated gadgets, exactly reconciled (0 delta), to answer the open
question left at the end of the 2026-07-22 baseline report — which Poseidon calls actually dominate
constraint count.
Finding: the 20-level Merkle authentication path (
MerkleProof(20), 20xPoseidon(2)) is76.4% of
transfer.circom's constraints (10,400/13,611) and 81.6% ofcompliance.circom's— an order of magnitude more than the three domain-tagged commitment/nullifier/amount-hash
Poseidon(4)/Poseidon(3)calls combined (20.7%). This reprioritizes any future Poseidon2 worktoward the Merkle chain specifically, rather than the whole circuit.
Rejected actually porting to Poseidon2 tonight:
circomlib2.0.5 (this repo's dependency) ships noPoseidon2 implementation, and hand-deriving round constants for a soundness-critical permutation in
one night, with no reference test vectors, was judged too risky — exactly the kind of "invented
benchmark" the loop is supposed to avoid.
Also re-attempted queue item #1 (on-chain gas, still blocked): confirmed the fullnode JSON-RPC path
is a hard sandbox network-policy block, but found
git clone+cargo buildfor thesuiCLI dowork here (unlike the 2026-07-22 "impractical" assessment) — left a background build running past
the session's budget and documented a procedural fix for the next run that picks it up.
Verdict: KEEP.
BASELINE.mdupdated with the new decomposition.Full report:
docs/research/2026-08-17-poseidon-merkle-constraint-breakdown.mdWhat changed
scripts/bench/poseidon-constraint-breakdown.mjs— new reusable benchmark: compiles standalonePoseidon(2)/(3)/(4),MerkleProof(20), and range-check-scaffolding circuits and tabulates theirR1CS constraint counts against the real
transfer.circomtotal.docs/research/2026-08-17-poseidon-merkle-constraint-breakdown.md— the full writeup (hypothesis,threat/privacy model, approach + rejected alternatives, raw command output, verdict, where this
generalizes, open questions).
docs/research/BASELINE.md— new "Poseidon / Merkle constraint decomposition" section; updatedon-chain-gas row with fresh blocker evidence.
docs/research/LEDGER.md— appended tonight's row.docs/research/EXPERIMENTS.md— re-ranked: added a cheapcompliance.circomfull-reconciliationitem and narrowed the Poseidon2 item to "Merkle chain specifically, gated on finding a trustworthy
reference implementation"; updated item feat: Veil privacy payment protocol — full stack MVP #1 with the procedural fix for unblocking the
suiCLIbuild.
No circuit, Move module, or frontend proving code was modified — this is a measurement/diagnostic
experiment, not a protocol change, so no soundness argument / leakage analysis / negative test is
needed (consistent with how the 2026-07-22 baseline report was scoped).
Test plan
Full suite run, all green except a pre-existing, unrelated gap:
node --experimental-vm-modules test/transfer.test.mjs— 43/43 passnode --experimental-vm-modules test/compliance.test.mjs— 30/30 passnode --experimental-vm-modules test/withdraw.test.mjs— 35/35 passcd scripts && bun run src/test-converter.ts— 109/109 passcd scripts && bun run src/test-compliance-utils.ts— 67/67 passcd frontend && bunx vitest run— 19/19 passcd scripts && bun run src/fuzz-tests.ts— 6/6 properties pass (500 cases each)cd contracts && sui move test— NOT RUN, nosuiCLI available in this sandbox (samepre-existing blocker as 2026-07-22; no contract code touched by this PR)
Generated by Claude Code