Inspiration
Enterprises are eager to adopt AI and LLMs to streamline internal operations. However, when it comes to sensitive documents like HR payrolls, financial records, or PII, they hit a wall. Trusting third-party LLMs with raw, confidential data is a massive security risk. We wanted to build a bridge that allows companies to use powerful AI without compromising data privacy or violating access controls.
What it does
Midnight-Confidential-RAG is a secure AI assistant. It intercepts user queries and documents before they reach the language model.
- If a standard employee queries the RAG, our local Privacy Shield dynamically redacts sensitive entities (salaries, national IDs, bank accounts), replacing them with
[CLASSIFIED]tags. - If an executive (e.g., HR Director) requests access, the system requires a Zero-Knowledge proof. We simulate a Midnight Compact smart contract that mathematically verifies their role clearance without revealing their underlying identity. Only upon successful verification is the unredacted context sent to the AI.
How we built it
We split the architecture into two main layers:
- Frontend & AI Core: Built with Python and Streamlit. We used LiteLLM to route queries to open-source models hosted on Groq (
gpt-oss-20b,qwen3.8-27b). We also built a regex-based Privacy Shield to handle on-the-fly text sanitization. - Zero-Knowledge Gateway: Built using TypeScript to interface with simulated Midnight zk-SNARK circuits (Plonk/Compact Engine). A Python-to-NodeJS bridge executes the TS scripts and parses the JSON proof payloads directly into the UI.
Challenges we ran into
Integrating two different runtime environments (Python and modern Node.js/TypeScript) under a tight hackathon deadline was tricky. We ran into compatibility issues with ts-node missing built-in filesystem features in Node v24, which forced us to quickly pivot to tsx for our ZK script execution. Ensuring the RAG context remained strictly synchronized with the UI's state management also required careful debugging.
Accomplishments that we're proud of
We successfully merged Zero-Knowledge cryptography with generative AI. Seeing the Streamlit UI instantly flip from denying access ([CLASSIFIED]) to rendering full records based on a verified on-chain proof was incredibly satisfying. We also built a live "Security Inspector" dashboard that tracks exact redaction metrics in real-time.
What we learned
We deepened our understanding of stateless ZK circuits and Role-Based Access Control (RBAC). We also learned how to effectively prompt an LLM to respect strict security boundaries and handle redacted context windows smoothly without hallucinating missing data.
Hackathon Development Disclosure
- All code for this project was developed entirely during the hackathon weekend.
- AI assistants were utilized as pair-programming and debugging tools to accelerate development during the event.
Built With
- groq
- litellm
- llm
- midnigth
- privacy
- python
- rag
- streamlit
- typescript
- zk-snarks
Log in or sign up for Devpost to join the conversation.