A lightweight, offline cryptographic integrity system for medical records using ECC signatures, SHA-256 hashing, version chaining, and tamper-evident audit logs — designed for low-resource hospitals.
# Lightweight Cryptographic Integrity System for Medical Records
## Quick Start (3 commands)
```bash
# 1. Install the only dependency
pip install cryptography
# 2. Run ALL tests at once
python run_all_tests.py
# 3. Or run the full hospital simulation only
python simulation.py
```
That's it. No database, no server, no config files needed.
---
## What You Can Run
### Option 1: Run Everything (Recommended)
```bash
python run_all_tests.py
```
Runs all 11 modules in sequence, shows PASS/FAIL for each, and prints a
summary report. This is the single command that verifies the entire system.
### Option 2: Run the Full Simulation
```bash
python simulation.py
```
Simulates a complete hospital workflow:
- Admin registers a doctor and nurse
- Doctor logs in via nonce challenge
- Doctor creates a patient record (chest pain → MI)
- Nurse adds vitals (version 2)
- Doctor adds ECG results (version 3)
- System verifies record integrity + full version chain
- System reviews the 10-entry audit log
- Attacker tampers with record → DETECTED
- Attacker forges hash too → STILL DETECTED (signature catches it)
- Attacker edits audit log → DETECTED
### Option 3: Run Individual Modules
Each module has a built-in self-test. Run any one directly:
```bash
# Crypto primitives
python hash_engine.py # SHA-256 hashing
python key_manager.py # Ed25519 key generation
python signer.py # Digital signing
python verifier.py # Signature verification
# System layers
python auth.py # Nonce challenge-response login
python record_manager.py # Record creation
python record_verifier.py # Record integrity checks
python version_manager.py # Hash-chained versioning
python audit_logger.py # Hash-chained audit logs
# Security testing
python tamper_detector.py # 5 different attack simulations
```
---
## Project Structure
```
crypto_integrity_system/
├── hash_engine.py # SHA-256 hashing
├── key_manager.py …