Skip to content

Latest commit

Β 

History

52 Commits

Folders and files

NameName
Last commit message
Last commit date
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

VeriHealth Logo

πŸ›‘οΈ VeriHealth

Proving health facts with absolute cryptographic certainty. Sharing zero medical data.

Next.js TypeScript Tailwind CSS Prisma Midnight

Type Check Test Suite Production Build

⚠️ DISCLAIMER: This application is live and running entirely on the Midnight PREPROD Network.


πŸ”— Important Links


πŸ“š Detailed Documentation

For a deeper dive into the technical setup, usage, and original vision for VeriHealth, please refer to our detailed markdown guides:

  • SETUP.md β€” Comprehensive guide on configuring the WSL2 environment, installing the Compact compiler, and spinning up the Midnight network.
  • USAGE.md β€” Step-by-step walkthrough of the workflows for Admins, Issuers (Hospitals), and Patients.
  • PROPOSAL.md β€” The original hackathon proposal detailing the core problem, our privacy-first solution, and business model.

πŸ“– Table of Contents

  1. About the Product
  2. Public State vs Private Witness
  3. Project Screenshots
  4. Smart Contracts
  5. System Architecture
  6. User Workflow
  7. File Structure
  8. Testing
  9. Future Implementation

πŸ’‘ About the Product

The Problem

Healthcare data sharing today is all-or-nothing. Proving a single fact β€” vaccination status, procedure eligibility, allergy-free status β€” typically requires handing over an entire medical record or portal login. Every recipient of that data becomes a new breach target and a new compliance liability, even though regulations like HIPAA and GDPR explicitly call for data minimization. Current tooling forces a trade-off between usability and privacy that the law does not actually require.

The Solution

VeriHealth is a zero-knowledge health credential network built entirely on the Midnight Blockchain. Hospitals and labs issue medical facts as cryptographically signed credentials that never leave the patient's device. To prove something to an employer, insurer, or pharmacy, the patient's wallet generates a Zero-Knowledge proof β€” mathematical evidence the fact is true β€” without revealing why.

Verifiers check the proof on-chain in milliseconds and learn only the answer (e.g., VALID: YES), never the medical record.


πŸ” Public State vs Private Witness (Midnight ZK)

VeriHealth leverages Midnight's native Data Protection features to separate what is public from what is private:

  • Public State: The registry of authorized issuers (Hospitals/Labs) and the cryptographic commitments of the credentials. This ensures anyone can verify who issued a credential and that it hasn't been revoked, ensuring trust without central authorities.
  • Private Witness: The actual clinical data (blood pressure, specific test results, PII). This data stays purely on the Patient's device. During verification, the ZK Circuit acts as a private witness, asserting that the patient holds a valid credential matching the public commitment, without ever leaking the payload to the network.

πŸ“Έ Project Screenshots

Landing Page

Landing Page

Admin Panel (Registering Issuers)

Admin Panel

Issuer Portal (Form & Issuing)

Issuer Form Issue Credentials

Patient Dashboard

Patient Dashboard

Verifier Portal (Challenge & Results)

Verify Link & QR Verify Portal

πŸ“œ Smart Contracts

Our smart contracts are written in Compact and deployed on the Midnight PREPROD network. They handle institutional trust through authorized registries and credential revocation.

On-Chain Proof Links (PREPROD Network - 1 AM Explorer)

Action Txn ID / Contract Address Explorer Link
πŸš€ Contract Deployment 4779029ff10019881b4125128c60b5f7aecaa00820614dac825271d2d830f47a View on Explorer
πŸ₯ Register Issuer Tx 1579645f5e6c7ad2f33a009300870386636574ef9ea16e289a0687addd7afec5 View on Explorer
πŸ“„ Issue Credentials Tx 3030488a6b33e15b2fbc5ee1dd6b88ed3b65b6b2377a721ccab4de5c9d315fd2 View on Explorer

Contract Execution Screenshots

Contract Deployment Register Issuer Issue Credentials

πŸ—οΈ System Architecture

graph TD
    subgraph Frontend [Next.js App UI]
        AdminUI[Admin Dashboard]
        IssuerUI[Issuer Portal]
        PatientUI[Patient Portal]
        VerifierUI[Verifier Portal]
    end

    subgraph Backend [Next.js API & DB]
        API[API Routes]
        DB[(Prisma PostgreSQL)]
    end

    subgraph Midnight [Midnight PREPROD Network]
        Compact[verihealth.compact]
        ZK[Zero-Knowledge Proofs]
    end

    AdminUI -->|Authorize| API
    IssuerUI -->|Create Credential| API
    PatientUI -->|Query Facts| API
    VerifierUI -->|Verify ZK Challenge| API

    API <-->|State Cache| DB
    API -->|Submit ZK Proofs| ZK
    ZK <-->|Verify| Compact
Loading

πŸ”„ User Workflow

sequenceDiagram
    actor Admin
    actor Hospital as Issuer (Hospital)
    actor Patient
    actor Employer as Verifier (Employer)
    participant Midnight as Midnight Blockchain

    Admin->>Midnight: 1. Deploy Contract
    Admin->>Midnight: 2. Register Hospital Public Key
    Hospital->>Patient: 3. Verify real-world identity
    Hospital->>Midnight: 4. Issue Credential (ZK Commitment)
    Midnight-->>Patient: 5. Store Private Data Locally
    Employer->>Patient: 6. Request Work Clearance Proof
    Patient->>Midnight: 7. Generate ZK Proof via 1 AM Wallet
    Patient-->>Employer: 8. Provide Shareable Link / QR
    Employer->>Midnight: 9. Verify Proof mathematically
    Midnight-->>Employer: 10. Return "VALID" (No data leaked)
Loading

πŸ“ File Structure

VeriHealth/
β”œβ”€β”€ app/                  # Next.js App Router (Frontend + API)
β”‚   β”œβ”€β”€ (auth)/           # Dashboards (Admin, Issuer, Patient, Verifier)
β”‚   β”œβ”€β”€ api/              # Backend routes interfacing with Midnight SDK
β”‚   └── components/       # Reusable UI components
β”œβ”€β”€ contracts/            # Midnight Smart Contracts
β”‚   β”œβ”€β”€ src/
β”‚   β”‚   └── verihealth.compact  # Core ZK Circuit Logic
β”‚   └── artifacts/        # Compiled circuits and prover keys (.bzkir)
β”œβ”€β”€ prisma/               # Database schema and migrations
β”œβ”€β”€ __tests__/            # Jest UI test suite
β”œβ”€β”€ .github/workflows/    # CI/CD Pipelines
└── assets/               # Documentation images & screenshots

πŸ§ͺ Testing

We use Jest and React Testing Library to ensure UI reliability, combined with strict TypeScript checks via our GitHub Actions CI pipeline.

To run tests locally:

npm install
npm run test
Test Passed

πŸš€ Future Implementation & Real World Applications

VeriHealth’s architecture paves the way for a massive transformation in health data handling:

  1. IoT Medical Devices: Wearables (like glucose monitors or ECG patches) could act as direct issuers to a patient's Midnight wallet. A patient could prove to an insurance company that they maintained healthy thresholds all year without revealing their exact minute-by-minute biometric data.
  2. Pharmacy Prescriptions: A doctor issues a prescription credential. The patient proves to a pharmacy that they hold a valid script for a specific medication without the pharmacy system having access to their broader medical diagnosis or history.
  3. Automated Insurance Underwriting: Submitting ZK proofs of health factors to immediately fulfill smart-contract-based insurance policies, bypassing manual claims review and completely eliminating data leaks.

πŸŽ‰ Salutation

A massive Thank You to the Midnight Team for organizing this incredible hackathon, providing phenomenal documentation, and building a blockchain that genuinely prioritizes data protection and privacy! πŸŒ‘βœ¨

About

Proving health facts with absolute cryptographic certainty. Sharing zero medical data.

Topics

Resources

Stars

0 stars

Watchers

0 watching

Forks

Contributors

Languages