Inspiration

AI agents are increasingly trusted with sensitive data — financial records, personal information — but there's no easy way to prove they followed the rules they were supposed to follow, without exposing the underlying data itself. We wanted to explore how Midnight's zero-knowledge tooling could close that trust gap for AI-driven decisions.

What it does

Private AI Guardian is an AI agent that processes expense requests. It uses an LLM (via Groq) to categorize each expense, then checks the result against a spending policy — flagging blocked categories (like gambling) and over-limit amounts. The same policy logic is written as a Compact smart contract, so it can be verified on-chain using zero-knowledge proofs — meaning the policy check can happen without publicly exposing the actual expense data.

How we built it

  • The AI agent is built in Python, using Groq's free LLM API (openai/gpt-oss-120b) for fast inference.
  • The policy logic (spending limits, blocked categories) is defined once and mirrored in a Compact smart contract targeting Midnight's local "undeployed" network.
  • We set up the full local Midnight stack — node, indexer, and proof server — via Docker, and used the Compact toolchain (via WSL) to compile the contract into ZK circuits.

Challenges we ran into

  • Windows required running the Compact toolchain inside WSL, since it isn't natively supported.
  • We hit several version-compatibility issues along the way — an outdated Compact language pragma version, a deprecated Groq model, Docker DNS resolution failing inside containers (fixed by configuring custom DNS in Docker Desktop), and a runtime version mismatch (compact-runtime vs. the compiled contract) that we weren't able to fully resolve within the hackathon window.
  • As a result, the contract compiles successfully and generates valid ZK circuits, but full on-chain deployment and live verification is still a work in progress.

What we learned

  • How Compact separates public and private state, and how disclose() works to explicitly reveal circuit inputs.
  • The Midnight toolchain's versioning model — the devtools/compiler version and the Compact language version are tracked separately, which tripped us up more than once.
  • How to stand up a full local Midnight network (node + indexer + proof server) via Docker for local development.

What's next for Private AI Guardian

  • Resolve the compact-runtime version mismatch and complete full on-chain deployment.
  • Expand the policy model to support more nuanced, multi-condition rules.
  • Build a simple frontend so a user can submit expenses and see both the AI decision and the on-chain verification status.

Built With

Share this project:

Updates

Submission history