safeeyes
Protect your eyes from eye strain using this simple and beautiful, yet extensible break reminder
翻訳待ち
No updates detected yet. GitHub releases will appear here.
Fall semester project: Cardano blockchain-powered encrypted medical records backend
翻訳待ち
Loading the full README.
Read the full README ↗Decentralized Electronic Health Record (EHR) system with encrypted medical file storage on IPFS, immutable verification on Cardano blockchain, and multi-layer permission control.
DB_URI to a remote instance)DISABLE_REDIS=true uses an in-memory CEK cache insteadnpm install
cd mock-hydra && npm install && cd ..
cp .env.example .env
The defaults in .env.example run the whole system in DEMO_MODE: encryption
and Hydra L2 are genuinely live, everything else (IPFS, Midnight, Blockfrost,
wallet signatures) runs against mocked/local scaffolding so the full pipeline
works without any real credentials. See the comments in .env.example for
where to plug in real Blockfrost/Pinata/Midnight keys later — flip
DEMO_MODE=false once you do.
node scripts/genActorKeys.js
This generates RSA key pairs for 4 actors:
# Optional: Terminal 1 — mock Hydra L2 node
cd mock-hydra && npm start
# Terminal 2 — main server
npm start # or: npm run dev (nodemon)
You can skip the mock Hydra node. If no Hydra node answers, the server runs a
simulated Hydra head in-process (this is what the hosted Vercel demo uses).
The simulated head fills itself with made-up patients (PT-xxxx, tagged
synthetic) so the L2 layer looks alive. Its timing is simulated too, but every
snapshot is still signed by all four parties with real Ed25519 keys, and the
signatures are checked again each time the head is read. Set
HYDRA_MODE=simulated to always use it, or HYDRA_MODE=remote to turn the
fallback off.
Each actor has its own portal and its own sign-in:
| Portal | URL | What it shows |
|---|---|---|
| Patient | /portal/patient | Upload & encrypt, my records (grant and revoke), access history, Hydra L2 network |
| Doctor | /portal/doctor | Records shared with me, request access, my activity |
| Hospital | /portal/hospital | Records shared with me, request access, my activity |
| Insurance | /portal/insurance | Records shared with me, request access, my activity |
A portal opens only for a browser signed in as that actor and is locked to
it: every API call carries an X-Acting-As header, and the server refuses a
call from a portal whose actor is not signed in, or that tries to act as
another actor. Requesting actors only ever see the records shared with them,
never who else has access (the same property the Midnight ZK layer protects),
and only their own audit entries. Signing out of one portal leaves the others
signed in, so several portals can be open side by side.
Run the guided demo on the landing page (or open /present) loads the
four portals side by side and runs every feature end to end, explaining the
idea behind each step and checking the result on the server:
The 24 checks are listed as the demo runs, so it doubles as an end-to-end
test. Space pauses, → skips the wait, Esc stops. /present?autostart=1
starts it straight away. It needs DEMO_MODE=true for one-click sign-in;
otherwise sign in to each portal at /login first.
Sign-in works on a fresh deploy without extra setup: the actors' password
hashes ship in config/actor-credentials.json, and on Vercel the session key
is derived from server-only settings. Setting ACTOR_CREDENTIALS and
SESSION_SECRET (from node scripts/setActorPasswords.js) overrides both.
Then open http://localhost:4000 for the landing page and http://localhost:4000/login to sign in to a portal.
Wallets: with an Eternl extension installed, "Connect
Wallet" uses it and signs every action with CIP-8. Without one, and only while
the server runs with DEMO_MODE=true, the portals fall back to a demo
wallet so the full pipeline can still be shown in any browser.
flowchart LR
P[Patient uploads file] --> E[Encrypt with AES-256-GCM]
E --> I[Store on IPFS]
E --> W[Wrap key for each chosen actor]
W --> H[Share via Hydra L2]
D[Doctor asks for access] --> C{Permission check<br/>Hydra, Aiken, Midnight, Blockfrost}
C -->|allowed| U[Doctor unwraps key and reads file]
C -->|denied| X[Access denied + audit log]
R[Patient revokes access] --> K[New key, file re-encrypted]
POST /api/encrypt/upload
Content-Type: multipart/form-data
Body:
- file: medical file
- ownerAddr: wallet address
- actorIds: comma-separated (e.g., "01,02,03")
This is the beginning of the README. Read the rest at the original. Read the full README ↗