Match Validity Circuit
Match Validity Circuit
Constraint Logic for Bidirectional Intent Symmetry
At the core of SnarkSide’s private perpetual matching architecture is the Match Validity Circuit — a zero-knowledge proof circuit designed to validate the compatibility of two encrypted trade intents while preserving bidirectional symmetry, constraint satisfaction, and user anonymity.
This circuit ensures that a pair of matched intents satisfy all trading constraints (size, slippage, direction, expiry, collateral) without revealing any sensitive trade information. It verifies the internal soundness of both intents, their agreement as a trading pair, and that the result of their match is cryptographically deterministic.
This document explores the technical underpinnings of the Match Validity Circuit, including its symmetric constraint system, Poseidon commitment structure, and output guarantees.
Purpose
The Match Validity Circuit enforces that:
Both submitted intents are individually valid.
The intents are complementary: one long, one short.
Their notional sizes fall within a defined match window (ε tolerance).
Their slippage windows are compatible for execution.
Their expiry windows are valid at match time.
Both nullifiers are distinct and unused.
The final
match_commitmenthash is symmetric and non-malleable.
It is the central cryptographic mechanism for trustless, invisible counterparty resolution in SnarkSide.
Symmetric Intent Compatibility
Since SnarkSide intentionally avoids wallet-based identities, addresses, or transaction sequencing, intent matching must be symmetric — either party in the match could have submitted first, and the outcome should not change. The circuit must:
Treat
(IntentA, IntentB)and(IntentB, IntentA)as functionally identical.Canonicalize intent ordering internally using deterministic logic.
Prevent proof manipulation through reordering.
To accomplish this, all hash commitments in the circuit are generated with sorted inputs:
This ensures ordering-invariant proof generation.
Constraint Logic
Inputs
intent_commitment_A,intent_commitment_Bnullifier_A,nullifier_Bdirection_A,direction_B(0 = short, 1 = long)notional_A,notional_Bslippage_A,slippage_Bexpiry_A,expiry_Bvault_commitment_A,vault_commitment_Bmatch_salt
Core Constraints
1. Opposite Trade Directions
Enforces one long, one short.
2. Notional Compatibility
Allows matching intents within ±ε units of each other.
3. Slippage Compatibility
Ensures mutual price tolerance agreement.
4. Expiry Validity
Verifies both intents are still valid at match time.
5. Distinct Nullifiers
Protects against self-matching or replay.
6. Vault Binding (Optional for Settlement Circuit)
If vaults are committed into the match circuit, we enforce margin validity:
This ensures user funds are valid and committed before match.
Match Commitment Generation
Final output from the circuit is a match commitment hash used as the trade identifier:
This is the only public signal required to settle the trade. It contains no user data and is impossible to reverse.
Output Signals
The circuit produces:
match_commitment: Poseidon hash used on-chainnullifier_A,nullifier_B: published and burned at settlementproof: Groth16 artifact that proves all constraints above
No size, slippage, leverage, or user metadata is included on-chain.
Summary
The Match Validity Circuit in SnarkSide is the cryptographic equivalent of a perpetual futures matching engine — but with:
No orderbook
No visibility
No leakage
No trust assumptions
It defines the rules of trade resolution in pure logic, enforced by SNARKs and validated publicly. All matching is privacy-preserving, constraint-bound, and symmetric — a radical reimagination of what it means to match orders in a decentralized world.
Last updated

