Inspiration
Pharmaceutical companies spend billions trying to find eligible patients for clinical trials, but recruiting is notoriously difficult. The primary bottleneck? Privacy. Patients are rightfully terrified of uploading their entire raw medical history to public matching databases. If a pre-existing condition (like a heart defect or kidney disease) is leaked, it could result in increased insurance premiums or employer discrimination. We wanted to build a secure bridge where medical research can find eligible patients without the patient ever having to sacrifice their HIPAA data.
What it does
The Midnight Clinical Trial Matcher allows patients to locally screen their own medical documents for trial eligibility and generate an immutable, Zero-Knowledge proof of qualification on the Midnight Blockchain.
- Local AI Parsing: A patient uploads their medical lab results (PDF) locally. A secure AI agent parses the document to extract key biological markers (e.g., Hemoglobin A1C, cardiovascular history).
- Zero-Knowledge Assertions: Using Midnight's Compact smart contract language, the system mathematically verifies if the patient's markers meet the trial's strict criteria (e.g., \(\text{A1C} > 7.0\) and no history of CVD).
- Privacy-Preserving On-Chain Anchoring: The system generates a cryptographic ZK proof and submits it to the Midnight network. The blockchain only records
{"Eligible": PASS}, allowing the patient to claim their spot and receive compensation entirely anonymously. The underlying health data never touches the network.
How we built it
We utilized a robust, privacy-first tech stack to achieve this:
- Smart Contract Layer: We wrote the cryptographic constraints using Compact, Midnight's native ZK language, compiling it into zero-knowledge circuits.
- Midnight SDK: We integrated
@midnight-ntwrk/wallet-sdk-hdto handle the cryptographic seed derivations, Headless Wallet connections, and network broadcasting. - AI Engine: We utilized the Groq API (
llama-3.3-70b-versatile) to act as the screener that quickly extracts structured JSON clinical data from messy unstructured PDFs. - Frontend Layer: We built a highly aesthetic, responsive dashboard using React, Vite, and Tailwind CSS. The UI features a unique "Privacy Split-View" architecture that visually demonstrates the "What You See (Local)" vs. "What the Blockchain Sees (Network)" paradigm.
Challenges we ran into
Building ZK applications is inherently complex. Our biggest challenge was conceptualizing how to bridge off-chain AI parsing with on-chain deterministic math. We initially struggled with how to feed dynamic AI OCR data into a strict Compact circuit without exposing the data payload in the transaction. We overcame this by deeply studying Midnight's Headless Wallet architecture, realizing we could generate the proof entirely locally in the Node environment and only broadcast the hashed proof to the indexer.
Accomplishments that we're proud of
We are incredibly proud of tackling the Healthcare space to solve a massive, real-world HIPAA problem. Many blockchain projects stay safely within the DeFi/Finance bubble, but we are proud that we pushed the boundaries of Midnight into medical data. Furthermore, we are extremely proud of the stunning, premium clinical UI and the seamless integration of Groq's blazing-fast AI with Midnight's cryptography.
What we learned
We learned a tremendous amount about Zero-Knowledge primitives and how the Midnight Blockchain fundamentally differs from traditional transparent chains. We also learned how to write mathematical constraints in Compact and how to effectively prompt LLMs to extract exact, deterministic schemas from highly unstructured medical documents.
What's next for Midnight Clinical Trial Matcher
Our immediate next steps involve:
- On-Device LLMs: Replacing the Groq API with an entirely local, WebGPU-based model so the medical PDF truly never leaves the user's browser environment, eliminating third-party API trust entirely.
- Tokenized Compensation: Wiring the smart contract to automatically disburse NIGHT tokens or stablecoins to patients as soon as their eligibility proof is verified on-chain.
- Mainnet Deployment: Transitioning our infrastructure from the local developer node environment to the live Midnight Mainnet upon release.
Built With
- compact
- express.js
- groq
- llama-3
- midnight-blockchain
- node.js
- react
- tailwind.css
- typescript
- vite

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