Skip to content

rainbowpuffpuff/ez_think2earn

Repository files navigation

ez_think2earn

Open In Colab License: MIT ZKML Prize

End-to-end ZKML over a brain–computer interface model: train / load an fNIRS classifier, prove inference with EZKL, without revealing the model weights as a black box you can’t verify.

Built for ZuThailand (EZKL Prize · Honorable Mention) as part of the think2earn open-neurotech stack.
Author: Carol Calin · @rainbowpuffpuff


Why this matters

Biometric models only become markets if third parties can trust results without taking the raw neural data. ZKML lets a contributor (or device) prove:

“This public sample, run through this committed model, produced class C.”

That is the cryptographic half of think2earn’s later pay-for-data-that-improves-models loop: verify inference, then verify improvement (separate systems / EigenLayer / NEAR work).


Architecture

flowchart TB
  subgraph Data
    NIRS[fNIRS NIRS_01-29 · TU Berlin hBCI]
  end
  subgraph Train
    NET[fNIRSNet-style classifier]
    ONNX[model.onnx]
    NET --> ONNX
  end
  subgraph Prove
    EZ[EZKL circuit + proof]
    ONNX --> EZ
    NIRS --> EZ
    EZ --> P[zk proof + public outputs]
  end
  subgraph Optional UI
    FE[React frontend]
    BE[Flask backend]
    FE --> BE
    BE --> EZ
  end
Loading
Class Meaning (demo)
Mental arithmetic Active cognitive task
Baseline Rest / observation

Demo subset: first 9 participants from TU Berlin NIRS for buildathon speed.


5-minute path (Colab)

  1. Open the notebook:
    ZuThailand_EZKL_demo.ipynb
  2. Runtime → Run all (~1 minute after setup).
  3. Read the verified EZKL proof output for mental-arithmetic vs baseline.

No local GPU required for the Colab path.


Local full stack (optional)

git clone https://github.com/rainbowpuffpuff/ez_think2earn.git
cd ez_think2earn

# 1) Train (writes under fNIRSNET/save/)
cd fNIRSNET && python KFold_train.py && cd ..

# 2) Backend
cd flask-backend && python app.py
# 3) Frontend (second terminal)
cd frontend && npm install && npm start

Upload model.onnx from e.g.
fNIRSNET/save/MA/KFold/1/1/ and generate proofs via the UI.

Training curves / confusion matrices from the Mental Arithmetic run are linked in repo history / assets (≈68–71% class-wise accuracy on the demo setup — moderate; the prize was for the verifiable pipeline, not SOTA accuracy).


Data

  • Source: TU Berlin hBCI / NIRS
  • Model lineage: fNIRSNet-style architecture
  • Demo files in-repo: model.onnx, model.pt, train_data.npz, test_data.npz

Repo layout

Path Role
ZuThailand_EZKL_demo.ipynb Start here — Colab-ready proof demo
fNIRSNET/ Training
flask-backend/ · frontend/ Local proof upload UI
model.onnx / model.pt Example artifacts

License

MIT (see LICENSE). Respect TU Berlin data access terms for redistributed NIRS usage.

Related think2earn public work

Repo Role
algo_t2e Data capture → ownership ASA mint flow (Algorand PoC)
agentic_health Agents × health / financial data
AVSAthon---PySyft-TenSEAL HE / federated biometric ML
think2earn Product overview: chat → paid data

About

ZKML (EZKL) proofs over fNIRS BCI models — mental arithmetic vs baseline (ZuThailand EZKL Prize). Colab in ~5 min.

Topics

Resources

Stars

Watchers

Forks

Releases

Packages

Used by

Contributors

Languages