Inspiration

On public blockchains, every pending trade is visible in the mempool. This creates a massive MEV problem — bots front-run large orders, institutional strategies leak instantly, and traders are forced to choose between privacy and trustlessness.

Centralized dark pools offer privacy, but they require trusting a black-box operator. We wanted both: true privacy + full trustlessness.

What it does

Shade is a privacy-preserving intent-matching engine built on Midnight. Traders submit shielded order commitments. Matching is performed using zero-knowledge proofs that verify:

  • Orders are on opposite sides
  • Sizes match exactly
  • Prices cross

…without ever revealing the actual price, size, or trader identity on-chain.

How we built it

  • Compact smart contract with three core circuits: submit_order, match_orders, and cancel_order
  • Local ZK proof generation (private data never leaves the user’s device)
  • Next.js frontend with Lace wallet integration
  • Lightweight WebSocket relay for order discovery (the relay never sees private order details)
  • Full CLI for deployment, funding, and testing

We heavily leveraged Midnight’s Kachina dual-state model — private witnesses stay local, while only cryptographic commitments and status (OPEN / MATCHED / CANCELLED) are written to the public ledger.

Challenges we ran into

  • Correctly handling Midnight SDK + WASM module resolution in the browser
  • Designing matching logic that only discloses boolean results (disclose(a.size == b.size)) without leaking actual values
  • Coordinating the local proof server, frontend, and relay service

Accomplishments that we're proud of

  • Fully working zero-knowledge order matching on Midnight
  • Ownership proven via knowledge of the commitment pre-image (not by address)
  • Clean separation of private and public state
  • Complete full-stack experience (contract + CLI + frontend + relay)

What we learned

Deep practical experience with Compact, witnesses, persistentCommit, selective disclosure, and building real privacy-preserving DeFi primitives on the Midnight stack.

What's next for Shade

  • Phase 2: Trustless atomic settlement using native shielded tokens
  • Phase 3: Partial fills via nullifier-based state splitting
  • Phase 4: Decentralized matchmaker nodes

Built With

  • compact
  • dark
  • defi
  • docker
  • knowledge
  • lace
  • mev
  • midnight
  • next.js
  • pool
  • privacy
  • proofs
  • react
  • typescript
  • wallet
  • websocket
  • zero
  • zk
Share this project:

Updates