尚未偵測到更新。GitHub 發布版本後會顯示在這裡。
個人 GitHub 帳號下公開儲存庫的擁有者可以登入並驗證所有權,自行管理介紹,無需管理員核准。
登入並產生驗證檔案,在 30 分鐘內將其提交至此儲存庫的預設分支。其他分支或分叉儲存庫中的檔案無效。然後在下方檢查檔案,即可無需管理員核准直接管理專案。請保留檔案以維持管理權限。
如需登入,將前往登入頁面。登入後請回到此處,再次點擊所選的驗證按鈕。
在專案資料夾中執行 /nomorevibe verify,即可驗證所有權並自行管理介紹。
一分鐘完成驗證Fall semester project: Cardano blockchain-powered encrypted medical records backend
翻譯準備中
取自儲存庫 README
正在載入完整 README。
檢視完整 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")
POST /api/access/request
Content-Type: application/json
{
"recordId": "uuid",
"actorId": "02",
"actorAddr": "addr_test1...",
"actorSignature": "signature"
}
POST /api/encrypt/revoke
Content-Type: application/json
{
"recordId": "uuid",
"actorId": "03",
"ownerAddr": "addr_test1...",
"ownerSignature": "signature"
}
POST /api/encrypt/propose-share
Content-Type: application/json
{
"headId": "head-...",
"payload": { "operation": "share", "recordId": "uuid", "actors": ["doctor"], "timestamp": 1730000000000 },
"signature": { "key": "...", "signature": "..." }
}
The payload must be signed by the record owner. Each actor gets the file key wrapped under their own X25519 public key, so the Hydra snapshot never holds the plain key.
POST /api/encrypt/confirm-anchor
Content-Type: application/json
{ "recordId": "uuid", "onchainTxHash": "..." }
With a Blockfrost key set, the transaction must exist and its metadata must
contain the record's cidHash. After a revoke rotates the key of an anchored
record, the record goes back to pending_anchor until the owner anchors the
new CID the same way.
GET /api/hydra/health
GET /api/hydra/status # mode, parties, epoch, recent snapshots, signature check
POST /api/hydra/benchmark # times real lookups against the L2 snapshot
GET /api/records/:recordId/metadata
/ — landing page (public/index.html + landing.css + landing.js)/portal/<role> — the four actor portals (public/dashboard.html + dashboard.css + dashboard.js, locked to one actor)/portal/patient → Hydra L2 Network — live head view: snapshot feed, party signatures, L2 vs L1 timing/present — the guided demo (public/present.html + present.css + present.js)/login — sign-in for each portal/api/logs — audit log viewerOlder pages are still reachable for reference: /app (earlier wallet-connect
UI), /demo (older encryption-only demo), and public/api-demo.html.
backend/
├── src/
│ ├── controllers/ # API request handlers
│ ├── services/ # Business logic
│ │ ├── cryptoService.js
│ │ ├── ipfsService.js
│ │ ├── hydraClient.js
│ │ ├── aikenService.js
│ │ ├── midnightService.js
│ │ ├── permissionService.js
│ │ └── auditLogger.js
│ ├── models/ # MongoDB schemas
│ ├── routes/ # Express routes
│ └── utils/ # Helper functions
├── public/ # Frontend — index.html (landing) + dashboard.html (main demo)
├── api/ # Vercel serverless entry point
├── tests/ # Jest tests
├── contracts/ # Aiken smart contracts
├── mock-hydra/ # Hydra Layer-2 mock server
├── scripts/ # Utility scripts
└── package.json
# Run all tests (crypto, CIP-8 signature checks, anchor checks, API smoke tests)
npm test
# Run demo flow
npm run demo
MIT