Skip to content
/ zkMed Public

zkMed is an innovative healthcare platform that bridges traditional Web2 insurance processes with secure Web3 blockchain technology. The platform revolutionizes healthcare insurance management by providing transparent, automated, and cryptographically verified transactions between patients, hospitals, and insurance companies.

License

Notifications You must be signed in to change notification settings

ppezzull/zkMed

Repository files navigation

zkMed - Revolutionary Healthcare Insurance Platform

Privacy-preserving healthcare platform using vlayer MailProofs and automatic payments on Base

Base vlayer Chainlink Scaffold-ETH

First introduced at ETHGlobal Prague and developed at ETHGlobal Napuleth 2025 hackathon on Base

🎯 Project Vision

Overview

zkMed is the world's first privacy-preserving healthcare insurance payment platform that automates payments from insurers to hospitals and patients by leveraging cryptographically verifiable email proofs (vlayer MailProofs) and Chainlink Automation for recurring payments. Built on Base with a seamless Privy wallet integration.

Core Innovation

Web2/Web3 hybrid architecture that maintains regulatory compliance while delivering revolutionary blockchain benefits:

  • Web2 Layer: Traditional claim processing, medical review, regulatory compliance
  • Web3 Layer: MailProof verification, instant payments, automated processing
  • Bridge: DKIM-signed emails provide cryptographic proof without exposing medical data

πŸ—οΈ Technical Architecture

Blockchain Infrastructure

Privacy Layer

  • vlayer MailProof: DKIM verification for payment authorization
  • Domain Verification: Cryptographic proof of organizational email control
  • Zero-Knowledge Architecture: Complete medical privacy preservation
  • Audit Trails: Complete email verification history for compliance

Payment System

  • Chainlink Automation: Scheduled monthly payment execution via checkUpkeep and performUpkeep functions
  • zkMedLinkPay: Smart contract implementing AutomationCompatibleInterface for recurring payments and fees
  • Payment Plans: Verified by email proof between insurer and patient

Privy

  • Framework: Next.js with Server Components
  • Web3 Integration: Privy SDK for seamless authentication
  • Smart Accounts: Abstract account management with gas sponsorship
  • Responsive Design: Modern UI/UX with desktop-first approach

πŸ“‹ Smart Contract Architecture

Hybrid Insurance System Integration

graph TB
    subgraph "Web2: Traditional Insurance Systems"
        A[Insurer Claims Portal] --> B[Manual Claim Review]
        B --> C[DKIM-Signed Payment Plan Email]
    end
    
    subgraph "Web3: Blockchain Automation"
        D[vlayer MailProof Verification] --> E[zkMed Smart Contracts]
        E --> F[Chainlink Automation Trigger]
        F --> G[Automated Monthly Payments]
    end
    
    C --> D
Loading

Automated Premium Payments (Patient to Insurer)

This diagram shows how a patient uses a MailProof from their insurer to authorize and set up automated monthly premium payments via Chainlink Automation.

sequenceDiagram
    participant P as Patient
    participant I as Insurer (Web2)

    participant Privy as zkMed Platform (Privy)
    participant V as vlayer
    participant ZK as zkMed Contracts
    participant C as Chainlink Automation

    Note over I,P: 1. Insurer sends Premium Plan Email
    I->>P: DKIM-Signed email with premium details

    Note over P,Privy: 2. Patient Onboards & Sets Up Automation
    P->>Privy: Logs in, submits email proof
    Privy->>V: Verifies email proof with vlayer
    V-->>Privy: Returns verified premium data
    
    Note over Privy,C: 3. Patient with Privy Smart-Wallet Creates Chainlink Upkeep
    Privy->>ZK: Registers premium plan on-chain
    ZK-->>Privy: Confirms registration
    Privy->>C: Creates & funds a new Chainlink Upkeep for Patient

    Note over C,I: 4. Chainlink Executes Automated Premium Payments
    loop Monthly Premiums
        C->>ZK: checkUpkeep()
        ZK-->>C: upkeepNeeded = true
        C->>ZK: performUpkeep()
        ZK->>I: Transfers premium payment to Insurer
    end
Loading

Direct Payouts (Insurer to Patient/Hospital)

This diagram shows how an insurer can directly pay a user (a patient for reimbursement or a hospital for services) using their Privy smart account. This is a simple, direct transfer and does not involve MailProofs or automation.

sequenceDiagram
    participant I as Insurer
    participant U as User (Patient or Hospital)
    participant Privy as zkMed Platform (Privy)
    participant ZK as zkMed Contracts

    Note over I,U: 1. Off-Chain Agreement
    I-->>U: Insurer decides to pay user based on off-chain processes

    Note over I,Privy: 2. Insurer Executes On-Chain Payout
    I->>Privy: Logs in, initiates a direct USDC payment to User
    Privy->>ZK: Triggers a simple transfer function
    ZK->>U: Transfers USDC to the User's wallet
    ZK-->>I: Records transaction on-chain
Loading

πŸ₯ Multi-Role User Management Patterns

Identity Verification (For Hospitals & Insurers)

sequenceDiagram
    participant Org as Organization (Hospital/Insurer)
    participant V as vlayer
    participant Privy as zkMed Platform (Privy)
    participant ZK as zkMed Contracts

    Note over Org,Privy: 1. Onboarding
    Org->>Privy: Logs in and initiates domain verification
    Privy->>Org: Prompts to send a verification email

    Note over Org,V: 2. MailProof Verification
    Org->>V: Submits DKIM-signed email for verification
    V-->>Privy: Confirms domain ownership for the Org's wallet

    Note over Privy,ZK: 3. On-Chain Record
    Privy->>ZK: Associates the verified domain/email hash with the Org's address
Loading

Patient Experience Pattern

sequenceDiagram
    participant P as Patient
    participant I as Insurer
    participant Privy as zkMed Platform (Privy)
    participant C as Chainlink Automation

    Note over P,I: 1. Onboarding & Premiums
    I->>P: Sends premium plan details via email
    P->>Privy: Logs in, uses MailProof to set up automated premium payments TO Insurer
    Privy->>C: Creates and manages Chainlink Upkeep

    Note over I,P: 2. Receiving Payouts
    I->>Privy: Insurer logs in to send a direct payment (e.g., reimbursement)
    Privy->>P: Patient receives USDC directly to their wallet
Loading

Insurance Company Pattern

sequenceDiagram
    participant I as Insurer
    participant P as Patient
    participant H as Hospital
    participant C as Chainlink Automation
    participant Privy as zkMed Platform (Privy)

    Note over I,P: 1. Receiving Premiums
    I->>P: Sends premium plan email
    P->>C: Patient sets up automated premium payments TO Insurer

    Note over I,Privy: 2. Making Payouts
    I->>Privy: Logs in to make direct payments
    Privy->>P: Sends reimbursement to Patient
    Privy->>H: Sends payment for services to Hospital
Loading

πŸ”„ Hybrid Claim Processing Flow

Why Hybrid Architecture?

  • Regulatory Compliance: Medical data stays in traditional systems (GDPR/HIPAA)
  • Industry Integration: Seamless adoption without disrupting existing workflows
  • Privacy Protection: Medical information never exposed on-chain
  • Recurring Settlements: Blockchain automation for scheduled payment execution

πŸš€ Bounties Implementation

Scaffold++ (Scaffold-ETH with Privy)

  • Template Used: Scaffold-ETH 2 with Privy integration
  • Features Added:
    • Smart wallet creation and management
    • Social login options (email, phone, social)
    • Gasless transactions for improved UX
    • Automatic user role detection and routing

Chainlink Automation

  • Implementation: Full AutomationCompatibleInterface with:
    • checkUpkeep: Identifies payment plans due for processing
    • performUpkeep: Executes monthly payments to hospitals
    • Automated triggers based on email-verified payment plans
    • Platform fee distribution and payment statistics

πŸ§ͺ Email Formats

Registration Email

Organizations verify identity through domain ownership:

Payment Plan Email

Insurers authorize payment plans through verified emails:

Claim Email (Insurer β†’ Patient)


πŸš€ Getting Started

Prerequisites

  • Node.js: Version 18+
  • Yarn: For package management
  • Foundry: For smart contract development
  • Docker: To run vlayer containers for local development and testing
  • vlayer: Version 1.2.3 required to run MailProof contract tests

Quick Start

# Clone the repository
git clone https://github.com/ppezzull/zkMed.git

# Install submodules
git submodule update --init --recursive

cd zkMed

# Install dependencies
yarn install

# Run vlayer devnet
yarn devnet:up

# Deploy contract locally
yarn deploy

# Enjoy the frontend ;-)
yarn start

Registration Flow

  • Patient, Hospital, and Insurer registration now works end-to-end using vlayer proofs
  • Frontend hooks call zkMedCore.registerPatient|Hospital|Insurer(proof, data)

πŸ—ΊοΈ Development Roadmap

Current MVP

  • βœ… Privy Integration: Smart account integration with social logins
  • βœ… Smart Contract Deploy: Smart contracts deployed and accessible via /debug page
  • βœ… Role-Based Access: Dynamic routing based on user type
  • βœ… User Registration with MailProofs: Users register (Patient, Hospital, Insurer) via email-based proofs for identity verification

Next Steps

  • 🚧 Frontend: Connect role dashboards/pages to backend
  • 🚧 Backend: AAVE pool integrations triggered when Insurer registers (capital efficiency)
  • 🚧 Backend: Payment plan automation (Chainlink upkeeps) wired to on-chain plans
  • 🚧 Enhanced Payment Analytics and Mobile UX

Long-Term Vision

  • πŸ“‹ Regulatory Compliance Framework: Comprehensive GDPR/HIPAA compliance
  • πŸ“‹ Decentralized Health Records: Private, patient-controlled medical data
  • πŸ“‹ Global Healthcare Network: Cross-border insurance and care coordination
  • πŸ“‹ Universal Insurance Integration: Payment system compatible with every insurance provider

🎯 Economic Model

Stakeholder Benefits

Patients

  • Simplified Process: One-time setup for recurring payments
  • Enhanced Privacy: Medical data never exposed during processing
  • Trusted Verification: Cryptographic proof of payment authorization

Hospitals

  • Predictable Cash Flow: Guaranteed monthly payments from insurance
  • Reduced Admin Costs: Automated processing reduces overhead
  • Enhanced Security: MailProof validation prevents fraud

Insurers

  • Capital Efficiency: Clear payment schedules improve financial planning
  • Reduced Overhead: Automation eliminates manual payment processing
  • Enhanced Transparency: Complete audit trail of all transactions

Platform

  • Sustainable Revenue: Small fee from each processed payment
  • Scalable Model: Infrastructure supports unlimited users and transactions
  • Regulatory Compliance: Privacy-preserving architecture meets healthcare standards

πŸ‘¨β€πŸ’» Contributors

Built by students from 42 Roma Luiss:

  • ppezzull – Smart contract backend
  • rdolzi – Next.js frontend

zkMed represents the first practical implementation of privacy-preserving healthcare insurance through Web3 technology, delivering measurable benefits while maintaining regulatory compliance and user familiarity. πŸš€


Built with ❀️ for the future of healthcare finance

About

zkMed is an innovative healthcare platform that bridges traditional Web2 insurance processes with secure Web3 blockchain technology. The platform revolutionizes healthcare insurance management by providing transparent, automated, and cryptographically verified transactions between patients, hospitals, and insurance companies.

Topics

Resources

License

Contributing

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Contributors 2

  •  
  •