Inspiration

In 2025, MEV bots extracted $1.4 billion from public DEX trades — front-running orders, sandwiching positions, and fading prices against traders who had no way to hide their intent. Every large trade leaks information the moment it hits the mempool: token pair, direction, size. Bots see everything. Traders lose millions.

The crypto OTC market exceeds $100 billion annually, yet there is no privacy-preserving, non-custodial RFQ protocol that keeps sensitive trade data hidden while remaining mathematically verifiable. Midnight Network changes that. Its dual-state ledger — public state for verification, private state for sensitive data — combined with zero-knowledge proofs and selective disclosure, makes confidential DeFi possible.

We built nox to prove that private trading isn't just a whitepaper idea. It works. Right now.

What it does

nox is a private RFQ (request-for-quote) settlement protocol on Midnight Network.

  1. Post — a market maker commits to a quote by hashing the token pair, price, size, and a random salt together. Only the commitment hash and token pair touch the public ledger. The actual price and size stay in the maker's private witness — they never touch the chain.

  2. Lock — a taker discovers the quote by its commitment hash and locks it for settlement. The taker never sees the actual price — only a cryptographic proof that a valid quote exists.

  3. Settle — the maker proves they know the original price by recomputing the hash inside a zero-knowledge circuit. The Midnight chain verifies the hash matches — confirming the trade is valid — without ever learning the price or size.

Three phases. Zero price leakage. Settlement proof on-chain. Anyone can audit.

How we built it

Smart contract — written in Compact, Midnight's ZK-native language. Seven circuits: postQuote, lockQuote, settleQuote, cancelQuote, getQuoteState, getQuoteHash, getQuotePair. The contract uses persistentHash for commitment generation and selective disclose() to control exactly what data reaches the public ledger. Compiled via GitHub Actions CI (compactc 0.31.1) with prover and verifier keys generated for all seven circuits.

Backend — FastAPI + SQLite. Five REST endpoints handling the full quote lifecycle. The backend computes SHA-256 commitment hashes matching the Compact contract's persistentHash scheme, stores quotes with hidden price/size fields, and never exposes raw trade data in public query responses.

Frontend — React 19 + Vite 6 + TypeScript. Minimal dark theme with subtle fade-in animations, zero neon. The landing page walks through the problem, solution, and architecture. The live dashboard connects to the backend for real-time quote posting, locking, and settlement with state badges and a live feed.

Infrastructure — a dockerized proof server generates ZK proofs locally. GitHub Actions CI compiles contracts on push. Deployed to Vercel with SPA rewrite rules for client-side routing.

Challenges we ran into

Compact v0.23 map limitations — Midnight's Compact language lacks contains, lookup, and remove operations on Map<K, Enum> types. This forced us to design a sequential single-slot quote model and document it honestly rather than fabricate multi-quote support.

zkir SIGILL on AMD — the Compact compiler's ZK intermediate representation binary crashes with SIGILL on pre-Zen AMD CPUs due to missing ADX instructions. We worked around this by offloading compilation to GitHub Actions CI runners (ubuntu-latest) and downloading the managed artifacts.

Bech32m address encoding — Midnight uses a custom bech32m address format with network-specific prefixes (mn_addr_preprod vs mn_addr_preview). Reverse-engineering the correct encoding without Lace wallet reference docs took significant trial and error.

SDK maturity — the Midnight JavaScript SDK proved too complex for a full browser-based testnet deployment within 48 hours. We focused on what judges can verify: compiled contracts with artifacts committed to the repo, a running proof server, and a fully functional backend and frontend.

Accomplishments that we're proud of

  • All 7 ZK circuits compiled with prover + verifier keys committed to the repository
  • Backend processes the full RFQ lifecycle — post, lock, settle, cancel, query — with curl-tested endpoints
  • Frontend is minimal, functional, and deployed — no fake dashboards, no mock data
  • Honesty table tells judges exactly what's real vs what's pending — no hidden gotchas
  • 12 of 14 features complete in 48 hours
  • Hyperframes for Farcaster demo with interactive bento-grid frames

What we learned

Compact's disclose() primitive forces developers to think explicitly about what data touches the chain — Solidity cannot do this. The dual-state model (public ledger + private witness) is a genuine paradigm shift, not a gimmick.

Midnight's toolchain is young but the fundamentals — selective disclosure, ZK-enforced state transitions, domain-separated hashing via persistentHash — are genuinely new primitives for DeFi architecture.

Also: always verify bech32m address formats before clicking "request tokens." And never trust that window.cardano.midnight exists — Midnight lives under a UUID in window.midnight.

What's next for nox

  • Midnight testnet deployment (artifacts compiled, proof server running, wallet funded — pending Lace wallet approval)
  • Browser-based ZK proof generation via the Midnight SDK once it stabilizes
  • Multi-quote support when Compact's map operations mature
  • Integration with real market makers and DEX aggregators for production RFQ flows

Built With

Share this project:

Updates

Submission history