https://github.com/furk4neg3/fedchain
A privacy-preserving federated learning framework integrated with blockchain to ensure decentralized training, secure model updates, and trustless collaboration.
https://github.com/furk4neg3/fedchain
Last synced: 3 months ago
JSON representation
A privacy-preserving federated learning framework integrated with blockchain to ensure decentralized training, secure model updates, and trustless collaboration.
- Host: GitHub
- URL: https://github.com/furk4neg3/fedchain
- Owner: furk4neg3
- License: mit
- Created: 2025-04-22T22:12:34.000Z (6 months ago)
- Default Branch: main
- Last Pushed: 2025-05-21T21:50:28.000Z (5 months ago)
- Last Synced: 2025-05-29T16:53:47.521Z (4 months ago)
- Language: Python
- Homepage:
- Size: 34.2 KB
- Stars: 1
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# FedChain π
A privacy-preserving federated-learning system secured by an Ethereum blockchain.
Clients train on disjoint MNIST shards, submit hashed model updates via Solidity smart contracts, and store both submissions and the aggregated global model on-chain.---
## π§ Prerequisites
- Git
- Docker & Docker Compose
- A local Ethereum network (we use Ganache CLI)---
## βοΈ Setup & Run
1. **Clone the repo**
```bash
git clone https://github.com/furk4neg3/FedChain.git
cd FedChain
```2. **Create your `.env`**
```env
SERVER_IP="XXX.XXX.XXX.XXX"
```
> Find your IP via:
> - **Windows:** `ipconfig`
> - **macOS/Linux:** `ifconfig` or `hostname -I`3. **Build & start everything**
```bash
docker-compose up --build
```
- π¨ **Heads-up:** The first build can take **over 1 hour**, as it builds images *and* runs 3 rounds of local training + global aggregation on MNIST.
---## π Whatβs Happening Under the Hood
1. **Local Training**
- 3 clients each train a small CNN on their shard (C1: digits 0β2; C2: 3β6; C3: 7β9).
- Local accuracies: ~30 %, ~40 %, ~30 %.
2. **Submission**
- Each client serializes its weights β computes a Keccak hash β calls `submitModel(hash, accuracy)` on the smart contract.
3. **On-Chain Logging**
- Solidity contract (on Ganache) logs `(round, client, hash, accuracy)` in a new block.
4. **Server Aggregation**
- Flask+Web3.py service listens for submission events β fetches off-chain weights β runs Federated Averaging β ~85 % global accuracy β calls `updateGlobalWeights(...)`.
5. **Dashboard Updates**
- Flask + Socket.IO pushes real-time charts (Chart.js) showing local vs. global accuracy and block/transaction metadata.---
## π View the HTML Report
After the containers are up & training finishes, open:
### macOS
```bash
open logs/report.html
```### Linux
```bash
xdg-open logs/report.html
```### Windows PowerShell
```powershell
start .\logs\report.html
```---
Happy federating! π€π