Skip to content

feat(zk): ZK-011 add explicit domain separation tags to note commitments - #467

Draft
s6pa1rta3n-lab wants to merge 1 commit into
ANAVHEOBA:mainfrom
s6pa1rta3n-lab:fix-issue-255
Draft

s6pa1rta3n-lab wants to merge 1 commit into
ANAVHEOBA:mainfrom
s6pa1rta3n-lab:fix-issue-255

Conversation

@s6pa1rta3n-lab

Copy link
Copy Markdown

Summary

Implements ZK-011 (Wave 1): Add explicit domain separation tags to note commitments.

Closes #255

Cryptographic Specification

  • Domain Tag: "commitment_domain_v1"
  • ASCII Hex (20 bytes): 636f6d6d69746d656e745f646f6d61696e5f7631
  • Field Representation (left-padded to 32 bytes):
    0x000000000000000000000000636f6d6d69746d656e745f646f6d61696e5f7631
  • Hash Function: Poseidon2 4-element sponge hash
    poseidon2_hash_4(COMMITMENT_DOMAIN_SEP, nullifier, secret, pool_id)

Scope of Changes

  • Noir Circuits (circuits/lib/src/hash/commitment.nr):
    • Defined COMMITMENT_DOMAIN_SEP constant.
    • Implemented 4-element sponge hashing with the domain separator prepended.
    • Added unit tests for domain separator non-zero validation, deterministic hashing, and cross-domain isolation against nullifiers, Merkle pairs, and legacy undomain-separated hashes.
  • Commitment Circuit (circuits/commitment/src/main.nr):
    • Added negative regression tests rejecting legacy undomain-separated hashes and nullifier hashes.
  • Vectors & Fixtures:
    • Updated scripts/generate_commitment_vectors.mjs to prepend COMMITMENT_DOMAIN_SEP_HEX.
    • Regenerated test vectors and fixtures across artifacts/zk/commitment_vectors.json, artifacts/zk/v1/commitment_vectors.json, and circuits/commitment/src/fixtures.nr.
    • Baseline constraints updated (withdraw: 1596, commitment: 6).
  • TypeScript SDK (sdk/src/):
    • Defined and exported COMMITMENT_DOMAIN_SEP_HEX and COMMITMENT_DOMAIN_SEP in zk_constants.ts and index.ts.
    • Updated computeNoteCommitmentField in poseidon.ts to prepend the domain separator and validate canonical BN254 field inputs.
    • Added full test suite in sdk/test/commitment_domain.test.ts verifying format, determinism, cross-domain isolation, and test vector conformance.

Validation

  • node scripts/zk_ticket_check.mjs --issue-key ZK-011 --run -> All checks passed
  • nargo check --workspace -> Clean compilation
  • nargo test --workspace -> All 131 Noir tests passed
  • node scripts/check_circuit_constraints.mjs -> ACIR opcode baselines verified
  • npm run build in sdk -> Clean build (exit code 0)
  • SDK Jest tests (commitment_domain.test.ts, commitment_corpus.test.ts, note_commitment_denomination.test.ts) -> 49/49 tests passed

Payout Routing

  • EVM (Base/Arbitrum/Polygon/ETH): 0xF46C9F6d70C50BF81ef3588AB523a90a594a2F89
  • Stellar: GCL6OXAMLD75BMTINA6EMRUDWK5THQUSHMYNLSNBCJAPZJHNYJTUNIBC

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.

ZK-011: Add explicit domain separation tags to note commitments

1 participant