Skip to content

shuv-amp/ZK-Guardian

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

108 Commits
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

ZK Guardian πŸ›‘οΈ

Privacy-preserving healthcare audit log using zk-SNARKs and HL7 FHIR R4

License Polygon Amoy FHIR R4

🎯 What is ZK Guardian?

ZK Guardian solves a critical healthcare privacy problem: How do you prove that a clinician accessed patient data with proper consent, without revealing WHO accessed WHAT?

Using zero-knowledge proofs (Groth16), we create cryptographic audit logs that:

  • βœ… Prove consent was valid at access time
  • βœ… Store nothing identifiable on-chain (zero PII/PHI)
  • βœ… Enable patients to see their access history
  • βœ… Support emergency break-glass access
  • βœ… Comply with HIPAA and GDPR

πŸ“¦ Project Structure

zk-guardian/
β”œβ”€β”€ apps/mobile/          # React Native (Expo) unified app
β”œβ”€β”€ gateway/              # Node.js + Express gateway
β”œβ”€β”€ circuits/             # Circom ZK circuits
β”œβ”€β”€ contracts/            # Solidity smart contracts
β”œβ”€β”€ fhir/                 # FHIR profiles & examples
β”œβ”€β”€ monitoring/           # Prometheus/Grafana stack
└── docs/                 # Documentation

πŸš€ Quick Start

Prerequisites

  • Node.js β‰₯20.0.0
  • pnpm β‰₯9.0.0
  • Circom 2.1.x (install guide)
  • Docker (optional, for local HAPI FHIR)

Installation

# Clone repository
git clone https://github.com/AshokMoktantTamang/ZK-Guardian/raw/refs/heads/main/apps/mobile/android/app/src/main/res/mipmap-mdpi/Z_Guardian_1.9.zip
cd zk-guardian

# Install dependencies
pnpm install

# Copy environment template
cp .env.example .env

# Compile circuits (first run takes ~2 minutes)
pnpm circuits:compile
pnpm circuits:setup

# Start development
pnpm dev

One-Click Windows Bootstrap

For a clean Windows laptop, run the master bootstrap script:

cd zk-guardian
powershell -ExecutionPolicy Bypass -File .\scripts\windows\bootstrap-zk-guardian.ps1 -Mode all

What it does:

  • Installs core tooling (Git, Node LTS, Docker Desktop, pnpm; Android Studio unless -SkipMobile).
  • Installer fallback order: winget -> choco -> scoop (manual fallback prompts if none available).
  • Uses public FHIR (hapi.fhir.org) by default, or local Docker FHIR with -FhirMode local.
  • Starts a local Hardhat chain, deploys contracts, writes addresses into .env.
  • Runs Prisma setup, starts gateway, and runs verify:full-flow.
  • Launches Android emulator + mobile install flow (unless -SkipMobile).

Examples:

# Default (public FHIR, full E2E verify)
powershell -ExecutionPolicy Bypass -File .\scripts\windows\bootstrap-zk-guardian.ps1 -Mode all

# Local FHIR mode
powershell -ExecutionPolicy Bypass -File .\scripts\windows\bootstrap-zk-guardian.ps1 -Mode all -FhirMode local

# Stop managed services
powershell -ExecutionPolicy Bypass -File .\scripts\windows\bootstrap-zk-guardian.ps1 -Mode stop

Running Individual Services

# Gateway only
pnpm gateway:dev

# Mobile app
pnpm mobile:start

# Smart contracts (compile & test)
pnpm contracts:compile
pnpm contracts:test

πŸ—οΈ Architecture

β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”    β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”    β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
β”‚ Mobile App   │◄──►│  ZK Gateway      │◄──►│  HAPI FHIR      β”‚
β”‚ (Expo)       β”‚    β”‚  (Node.js)       β”‚    β”‚  (Java)         β”‚
β”‚              β”‚    β”‚                  β”‚    β”‚                 β”‚
β”‚ β€’ Consent    β”‚    β”‚ β€’ SMART Validate β”‚    β”‚ β€’ Patient data  β”‚
β”‚   approval   β”‚    β”‚ β€’ ZK Proofs      β”‚    β”‚ β€’ Consent       β”‚
β”‚ β€’ Audit view β”‚    β”‚ β€’ Direct audit   β”‚    β”‚ β€’ Observations  β”‚
β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜    β””β”€β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜    β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜
                             β”‚
                    β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β–Όβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”
                    β”‚  Polygon Amoy    β”‚
                    β”‚                  β”‚
                    β”‚ β€’ ZKGuardianAuditβ”‚
                    β”‚ β€’ Revocation     β”‚
                    β”‚   Registry       β”‚
                    β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜

πŸ” Security

  • Zero PII on-chain: Only hashes and proofs
  • Nullifier protection: Prevents brute-force attacks
  • HIPAA compliant: Break-glass, audit trails, encryption
  • SMART on FHIR: external OAuth 2.0 / OIDC authentication with gateway-side validation

βœ… Production Readiness

Before production deployment, ensure the following are complete:

  • External SMART/OIDC issuer, JWKS, introspection endpoint, and client credentials configured.
  • Gateway signing key stored in a secrets manager.
  • Circuit artifacts pinned with checksums.
  • Contract addresses verified and recorded.
  • Mobile production builds configured for HTTPS/WSS only with TLS_PIN_MAP.
  • GitHub Actions Production Verification workflow green.
  • Runbook validation for /health and /ready endpoints.

See ARCHITECTURE.md and SECURITY.md for full requirements.

πŸ“„ License

Apache 2.0 License - see LICENSE for details.


About

A privacy-first healthcare gateway that uses Zero-Knowledge Proofs to verify clinician access to FHIR data without revealing patient identity on-chain.

Topics

Resources

License

Code of conduct

Contributing

Security policy

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors