π MIDNIGHT-NEXUS
A Cryptographic Compliance Shield for AI β Built at the Midnight Blockchain Hackathon
What We Were Trying to Solve
AI is useful. It's also, in most enterprise deployments, a privacy disaster waiting to happen. You upload a patient record or a financial filing to get an insight, and suddenly that raw data is somewhere in a cloud pipeline you don't control.
The problem isn't the AI. It's that we've built AI pipelines around a simple but flawed assumption: the model needs to see the data to reason about it.
That assumption is wrong. And MIDNIGHT-NEXUS is our attempt to prove it.
The idea: let AI reason over facts about data, not the data itself. A doctor doesn't need to hand over a patient file to prove that person is over 18. A bank doesn't need to expose an account balance to prove it clears a threshold. Zero-knowledge proofs have made this kind of attestation cryptographically sound for years. We just hadn't wired them to AI yet.
How the System Works
The core flow looks like this:
Raw Private Data (stays local)
β
βΌ
βββββββββββββββββββββββββββ
β Local ZK Prover β β Compact Language circuit runs on-device
β (sub-second compile) β
ββββββββββββββ¬βββββββββββββ
β Proof Token
βΌ
βββββββββββββββββββββββββββ
β Midnight Blockchain β β State commitment anchored on-chain
β (Consensus Register) β
ββββββββββββββ¬βββββββββββββ
β Anchored Hash
βΌ
βββββββββββββββββββββββββββ
β AI Verifier Layer β β Reads proof tokens, not raw data
β (Proof-Aware Inference)β
ββββββββββββββ¬βββββββββββββ
β
βΌ
Certified Compliance Insight
(zero raw bytes ever touched)
The math at the heart of this:
$$P(\text{statement} \mid \text{proof}) \implies \text{valid}$$
We generate a \(\text{proof}\) that a \(\text{statement}\) about private data holds β without exposing the underlying data at all. The AI consumes that proof token, verifies it against the blockchain anchor, and produces an insight. At no point does it see what the statement is about.
Architecture at a Glance
ββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
β MIDNIGHT-NEXUS β
β β
β Frontend (Next.js + TypeScript) β
β β β
β βββ ZK Circuit Layer (Compact Language) β
β β βββ Local WASM prover sandbox β
β β β
β βββ Blockchain Bridge (Midnight SDK) β
β β βββ State commitments β mainnet ledger β
β β β
β βββ AI Verifier (OpenAI inference layer) β
β β βββ Reads: proof tokens β
β β βββ Outputs: compliance insights β
β β β
β βββ UI (Spline 3D + Framer Motion + shadcn) β
ββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
Tech used:
Next.js+TypeScriptβ application shellCompact Languageβ ZK circuit definition and compilationMidnight SDKβ blockchain state anchoringopenaiβ proof-aware AI inference@splinetool/react-spline+framer-motionβ 3D and animationshadcn+lucide-reactβ UI components
Data Privacy: Traditional AI vs MIDNIGHT-NEXUS
Here's what actually changes:
TRADITIONAL AI PIPELINE
ββββββββββββββββββββββ
User β [Raw Data] β Cloud API β AI Model β Insight
β
Data leaves your hands here.
You have no idea where it goes.
MIDNIGHT-NEXUS PIPELINE
ββββββββββββββββββββββ
User β [Raw Data] β Local ZK Prover β [Proof Token] β Blockchain Anchor
β β
Data never leaves device. AI reads proof, not data.
β
Verified Insight
The key property: the proof token is computationally binding but semantically opaque. An observer can verify the proof is valid without learning anything about what it proves.
What We Learned
Three things genuinely surprised us during the build.
1. Compact Language is a different way of thinking. Writing ZK circuits in Compact isn't like normal programming. You're not describing what to compute β you're describing what constraints must hold. It took a while to stop thinking procedurally and start thinking in terms of witnesses and assertions.
2. The AI integration was the hardest part β and not for the reasons we expected. We assumed the blockchain integration would eat most of our time. It didn't. The hard problem was getting the AI layer to treat proof tokens as meaningful inputs rather than opaque blobs. We had to redesign how we represented the proof structure in the prompt context.
3. Sub-second local ZK compilation is genuinely achievable. WASM provers are fast now. We were surprised how close to interactive performance we got. The main cost is circuit size β keeping circuits lean pays off immediately.
What We Built, Step by Step
# 1. Compile ZK circuits locally
npx compact compile src/circuits/proof.compact
# 2. Run the local proving pipeline
npm run nexus-start
The flow from there:
- User supplies private data (locally, never transmitted)
- Compact circuit compiles and generates a proof token
- Proof token + minimalist state hash gets anchored to the Midnight mainnet
- AI verifier reads the token, cross-checks the chain anchor, returns an insight
- User gets a compliance result. No raw data ever left step 1.
Honest Challenges
The crypto-AI interface was messier than we expected. ZK circuits and AI inference engines don't speak the same language. Getting a proof token into a form the AI could actually reason about β not just acknowledge β meant going back to circuit design multiple times.
Time. 48 hours is not a lot of time to learn the Midnight SDK, design circuits, build an AI verifier, and ship a frontend with 3D visualizations. We cut a few features we wanted. The decentralized proof registry is rougher than we'd like.
Making this explainable. Zero-knowledge proofs are genuinely hard to explain. We used Spline and Framer Motion partly because we needed something visual to show what's happening without drowning people in math. It helped, but we still think the UX explanation layer has a lot of room to grow.
What's Next
The prototype proves the concept works. A few things we didn't finish that we want to:
- A richer proof registry UI with historical audit trails
- Support for more complex circuit types (range proofs, set membership)
- Formal benchmarking of circuit compilation time vs. proof complexity
- A developer SDK so others can build proof-aware AI features without re-implementing the whole stack
Team
Built at the Midnight Blockchain Hackathon in 48 hours.
Built With
- chart.js
- compact
- framer
- git
- lucide-react
- midnightblockchain
- midnightsdk
- next.js
- node.js
- openai
- pnpm
- react
- shadcn
- spline
- typescript
- vite
- zustand


Log in or sign up for Devpost to join the conversation.