Science Score: 44.0%
This score indicates how likely this project is to be science-related based on various indicators:
-
✓CITATION.cff file
Found CITATION.cff file -
✓codemeta.json file
Found codemeta.json file -
✓.zenodo.json file
Found .zenodo.json file -
○DOI references
-
○Academic publication links
-
○Academic email domains
-
○Institutional organization owner
-
○JOSS paper metadata
-
○Scientific vocabulary similarity
Low similarity (12.0%) to scientific vocabulary
Repository
Federated Learning with Zero-Knowledge Proofs
Basic Info
- Host: GitHub
- Owner: guglxni
- License: other
- Language: Python
- Default Branch: main
- Size: 6.88 MB
Statistics
- Stars: 2
- Watchers: 1
- Forks: 0
- Open Issues: 0
- Releases: 3
Metadata Files
README.md
FEDzk: Secure Federated Learning with Zero-Knowledge Proofs
FEDzk is a Python framework for building privacy-preserving federated learning systems using zero-knowledge proofs (ZKPs). It provides a complete end-to-end workflow for training, proving, and verifying model updates in a distributed environment.
Overview
FEDzk is a cutting-edge framework that integrates federated learning with zero-knowledge proofs to address privacy and security concerns in distributed machine learning. Traditional federated learning systems face challenges with respect to verifiability and trust; our framework solves these issues by providing cryptographic guarantees for model update integrity.
Key Features
- Provable Security: Unlike conventional federated learning frameworks, FEDzk provides mathematical guarantees for the integrity of model updates
- Scalability: Built with performance in mind, our framework can handle large-scale federated learning tasks with minimal overhead
- Flexibility: FEDzk supports multiple ZK backends and can be easily integrated with existing machine learning pipelines
- Ease of Use: With a simple and intuitive API, developers can quickly get started with building secure and private ML systems
Architecture
The FEDzk framework consists of three main components:
- Client: The client is responsible for training the model on local data and generating a ZK proof of the model update
- Coordinator: The coordinator aggregates model updates from multiple clients and updates the global model
- Prover: The prover is a service that generates ZK proofs for the model updates, which can be run locally or on a remote server
Getting Started
Prerequisites
- Python 3.9+
- Pip
- Git
Installation
bash
pip install fedzk
For more advanced use cases, you can install optional dependencies:
bash
pip install fedzk[all] # All dependencies
pip install fedzk[dev] # Development tools
Example Usage
```python from fedzk.client import Trainer from fedzk.coordinator import Aggregator
Initialize a trainer with your model configuration
trainer = Trainer(model_config={ 'architecture': 'mlp', 'layers': [784, 128, 10], 'activation': 'relu' })
Train locally on your data
updates = trainer.train(data, epochs=5)
Generate zero-knowledge proof for model updates
proof = trainer.generate_proof(updates)
Submit updates with proof to coordinator
coordinator = Aggregator() coordinator.submit_update(updates, proof) ```
Verification Process
```python from fedzk.prover import Verifier
Initialize the verifier
verifier = Verifier()
Verify the proof
isvalid = verifier.verify(proof, publicinputs)
if is_valid: print("✅ Model update verified successfully!") else: print("❌ Verification failed. Update rejected.") ```
Zero-Knowledge Integration
Supported ZK Systems
FEDzk is designed for integration with production zero-knowledge systems:
Currently Integrated: - Circom v2.x: Circuit definition and compilation - SNARKjs: JavaScript/WebAssembly proof generation - Groth16: Efficient proof system for verification
Planned Integration: - arkworks: Rust-based ZK library ecosystem - Halo2: Universal setup proving system - PLONK: Polynomial commitment-based proofs - Risc0: Zero-knowledge virtual machine
Setup Requirements
To use real ZK proofs (recommended for production):
```bash
Install Node.js and npm
curl -fsSL https://deb.nodesource.com/setup_lts.x | sudo -E bash - sudo apt-get install -y nodejs
Install Circom and SNARKjs
npm install -g circom snarkjs
Verify installation
circom --version snarkjs --version
Run FEDzk setup script
./scripts/setup_zk.sh ```
Circuit Architecture
FEDzk implements modular circuit designs for different verification requirements:
circuits/
├── model_update.circom # Basic gradient norm constraints
├── model_update_secure.circom # Enhanced privacy constraints
├── batch_verification.circom # Multi-client batch proofs
└── custom/ # User-defined constraint circuits
Circuit Complexity: - Basic Model Update: ~1K constraints (suitable for small models) - Secure Model Update: ~10K constraints (privacy-preserving verification) - Batch Verification: ~100K constraints (multi-client aggregation)
Development Mode
For development and testing, FEDzk requires the complete ZK setup:
```python from fedzk.prover import ZKProver
Production ZK proofs (requires setup)
prover = ZKProver(secure=False) proof, publicsignals = prover.generateproof(gradients)
Secure ZK proofs with constraints
secureprover = ZKProver(secure=True, maxnormsquared=100.0, minactive=2) proof, publicsignals = secureprover.generate_proof(gradients) ```
Setup Instructions: ```bash
Run the automated setup script
./scripts/setup_zk.sh
Verify installation
python -c "from fedzk.prover import ZKProver; print('✅ ZK setup verified')" ```
Note: FEDzk generates real zero-knowledge proofs using the Groth16 proving system. If ZK tools are not installed, the framework will provide clear error messages with setup instructions.
Advanced Usage
Custom Circuit Integration
FEDzk allows you to define custom verification circuits:
```python from fedzk.prover import CircuitBuilder
Define a custom verification circuit
circuitbuilder = CircuitBuilder() circuitbuilder.addconstraint("modelupdate <= threshold") circuitbuilder.addconstraint("norm(weights) > 0")
Compile the circuit
circuitpath = circuitbuilder.compile("mycustomcircuit")
Use the custom circuit for verification
trainer.setcircuit(circuitpath) ```
Distributed Deployment
To deploy across multiple nodes:
```python from fedzk.coordinator import ServerConfig from fedzk.mpc import SecureAggregator
Configure the coordinator server
config = ServerConfig( host="0.0.0.0", port=8000, minclients=5, aggregationthreshold=3, timeout=120 )
Initialize and start the coordinator
coordinator = Aggregator(config) coordinator.start()
Set up secure aggregation
secureagg = SecureAggregator( privacybudget=0.1, encryptionkey="sharedsecret", mpcprotocol="semihonest" ) coordinator.setaggregator(secureagg) ```
Performance Optimization
```python from fedzk.client import OptimizedTrainer from fedzk.benchmark import Profiler
Create an optimized trainer with hardware acceleration
trainer = OptimizedTrainer( usegpu=True, precision="mixed", batchsize=64, parallel_workers=4 )
Profile the training and proof generation
profiler = Profiler() with profiler.profile(): updates = trainer.train(data) proof = trainer.generate_proof(updates)
Get performance insights
profiler.report() ```
Documentation
For more detailed documentation, examples, and API references, please refer to:
Examples
The examples directory contains sample code and deployment configurations:
- Basic Training: Simple federated learning setup
- Distributed Deployment: Multi-node configuration
- Docker Deployment: Containerized deployment
- Custom Circuits: Creating custom verification circuits
- Secure MPC: Multi-party computation integration
- Differential Privacy: Adding differential privacy
- Model Compression: Reducing communication overhead
Performance Benchmarks
Federated Learning Performance
FEDzk has been tested on standard FL datasets with the following results:
| Dataset | Clients | Rounds | Accuracy | Training Time/Round | Communication Overhead | |----------|---------|--------|----------|-------------------|---------------------| | MNIST | 10 | 5 | 97.8% | 2.1s | +15% (vs. standard FL) | | CIFAR-10 | 20 | 50 | 85.6% | 8.3s | +12% (vs. standard FL) | | IMDb | 8 | 15 | 86.7% | 5.7s | +18% (vs. standard FL) | | Reuters | 12 | 25 | 92.3% | 3.2s | +14% (vs. standard FL) |
Zero-Knowledge Proof Performance
Measured Performance (with real ZK proofs on Apple M4 Pro): - Proof Generation: 0.8-1.2s per client update (4-element gradients) - Verification Time: 0.15-0.25s per proof - Proof Size: 192 bytes (Groth16, constant regardless of model size) - Circuit Constraints: 1K (basic) to 10K (secure with privacy constraints)
Hardware Tested: | Component | Specification | |-----------|---------------| | CPU | Apple M4 Pro (12 cores) | | RAM | 24.0 GB | | GPU | Apple M4 Integrated GPU |
Performance Scaling: - Linear scaling with gradient vector size (up to circuit capacity) - Constant proof size and verification time regardless of model complexity - Batch verification available for multiple client proofs
Real ZK Performance: All performance figures are measured using actual Groth16 proofs generated by Circom/SNARKjs. Setup the ZK environment with
./scripts/setup_zk.shto reproduce these benchmarks.
Zero-Knowledge Backend Status
Production Implementation: FEDzk provides a complete, production-ready ZK proof system using Circom circuits and SNARKjs. The framework includes:
- Circom v2.x: Industry-standard circuit definition language
- SNARKjs: JavaScript/WebAssembly implementation for proof generation and verification
- Groth16: Efficient, trusted proving system (192-byte constant proof size)
- Real Circuit Library: Working implementations for gradient norm constraints and privacy verification
Setup Requirements:
- ✅ Complete setup script: ./scripts/setup_zk.sh
- ✅ Automated circuit compilation (Circom → R1CS → WASM)
- ✅ Trusted setup ceremony integration
- ✅ Proving and verification key generation
- ✅ Production-ready proof generation and verification
No Simulation: FEDzk generates and verifies real zero-knowledge proofs. When ZK tools are not installed, the framework clearly indicates the missing requirements rather than falling back to simulation.
Troubleshooting
Common Issues
Installation Problems
Issue: Error installing cryptographic dependencies
Solution: Ensure you have the required system libraries:
```bash
On Ubuntu/Debian
sudo apt-get install build-essential libssl-dev libffi-dev python3-dev
On macOS
brew install openssl ```
Runtime Errors
Issue: "Circuit compilation failed"
Solution: Check that Circom is properly installed and in your PATH:
```bash
circom --version
If not found, install with: npm install -g circom
```
Issue: Memory errors during proof generation
Solution: Reduce the model size or increase available memory:
python
trainer = Trainer(model_config={
'architecture': 'mlp',
'layers': [784, 64, 10], # Smaller hidden layer
})
Debugging Tools
FEDzk provides several debugging utilities:
```python from fedzk.debug import CircuitDebugger, ProofInspector
Debug a circuit
debugger = CircuitDebugger("modelupdate.circom") debugger.traceconstraints()
Inspect a generated proof
inspector = ProofInspector(prooffile="proof.json") inspector.validatestructure() inspector.analyze_complexity() ```
Community & Support
- GitHub Issues: For bug reports and feature requests
- Discussions: For general questions and community discussions
- Slack Channel: Join our Slack workspace for real-time support
- Mailing List: Subscribe to our mailing list for announcements
Getting Help
If you encounter issues not covered in the documentation:
- Search existing GitHub Issues
- Ask in the community channels
- If the issue persists, file a detailed bug report
Roadmap
Near-term Development (2025)
Q1 2025: - Complete Circom circuit library for common ML architectures - Performance optimization for large-scale deployments - Enhanced documentation and tutorials
Q2 2025: - Third-party security audit and penetration testing - GPU acceleration for proof generation (CUDA/OpenCL) - Integration with popular ML frameworks (PyTorch Lightning, Hugging Face)
Q3 2025: - Formal verification of core cryptographic components - Universal setup migration (Halo2, PLONK support) - WebAssembly support for browser-based clients
Q4 2025: - Production-ready deployment tools and monitoring - Advanced privacy features (secure multiparty computation) - Performance benchmarking against existing FL frameworks
Long-term Vision (2026+)
Q1 2026: - Publication of formal security proofs and analysis - Post-quantum cryptographic algorithm integration - Enterprise-grade deployment and compliance features
Research Collaborations: - Partnership with academic institutions for formal verification - Integration with existing FL frameworks (FedML, FLWR) - Standardization efforts with privacy-preserving ML community
Changelog
See the releases page for a detailed history of changes.
Citation
If you use FEDzk in your research, please cite:
bibtex
@software{fedzk2025,
author = {Guglani, Aaryan},
title = {FEDzk: Federated Learning with Zero-Knowledge Proofs},
year = {2025},
url = {https://github.com/guglxni/fedzk},
}
Security & Formal Analysis
Security Architecture
FEDzk implements a multi-layered security approach combining cryptographic primitives with privacy-preserving protocols:
- Zero-Knowledge Proofs: Groth16 zkSNARKs for model update integrity verification
- Secure Aggregation: Multi-party computation protocols for privacy-preserving aggregation
- Communication Security: TLS encryption for all client-coordinator communication
- Differential Privacy: Configurable noise injection to prevent inference attacks
- Input Validation: Comprehensive parameter validation and sanitization
Formal Security Analysis (Planned)
Current Status: The framework implements well-established cryptographic primitives, but formal security analysis is ongoing.
Planned Security Audits: - Q2 2025: Independent cryptographic review by third-party security firm - Q3 2025: Formal verification of zero-knowledge circuit correctness - Q4 2025: End-to-end security analysis of federated learning protocol - Q1 2026: Publication of formal security proofs and threat model analysis
Security Model Assumptions: - Semi-honest adversary model for MPC protocols - Honest majority assumption for secure aggregation - Trusted setup for Groth16 proving system (planned migration to universal setup) - Network adversary with standard cryptographic assumptions
Threat Model
FEDzk addresses the following attack vectors: - Malicious Model Updates: ZK proofs ensure updates satisfy validity constraints - Inference Attacks: Differential privacy prevents information leakage - Communication Interception: End-to-end encryption protects data in transit - Coordinator Corruption: Verifiable aggregation allows detection of tampering
Security Limitations & Future Work
Current Limitations: - Trusted setup requirement for Groth16 (mitigated by using existing trusted ceremonies) - Circuit constraints limited to norm bounds and sparsity (expanding constraint library) - No formal verification of circuit implementations yet
Planned Improvements: - Migration to universal setup systems (Halo2, PLONK) - Formal verification using tools like Lean or Coq - Integration with hardware security modules (HSMs) - Post-quantum cryptographic algorithms
License
This project is licensed under the Functional Source License 1.1 with Apache 2.0 Future Grant (FSL-1.1-Apache-2.0). Commercial substitutes are prohibited until the 2-year Apache-2.0 grant becomes effective.
Copyright (c) 2025 Aaryan Guglani and FEDzk Contributors
Contributing
We welcome contributions from the community! Please check out our contributing guidelines to get started.
Project Structure
The FEDzk project follows a standard Python package structure:
src/fedzk/- Main Python packagetests/- Test suitedocs/- Documentationexamples/- Usage examplesscripts/- Utility scripts
Owner
- Name: Aaryan Guglani
- Login: guglxni
- Kind: user
- Twitter: guglxni
- Repositories: 1
- Profile: https://github.com/guglxni
Citation (CITATION.cff)
cff-version: 1.2.0
message: "If you use FedZK in your research, please cite it as below."
title: "FedZK: Secure Federated Learning with Zero-Knowledge Proofs"
authors:
- family-names: "Guglani"
given-names: "Aaryan"
version: 0.1.0
date-released: 2025-04-24
url: "https://github.com/aaryanguglani/fedzk"
repository-code: "https://github.com/aaryanguglani/fedzk"
license: MIT
type: software
keywords:
- "federated learning"
- "zero-knowledge proofs"
- "privacy-preserving machine learning"
- "secure aggregation"
abstract: >
FedZK is a framework for secure federated learning using zero-knowledge proofs.
It allows clients to train models locally and submit verifiable proofs about their
gradient updates, ensuring integrity and privacy in the training process.
GitHub Events
Total
- Release event: 3
- Watch event: 2
- Delete event: 2
- Push event: 55
- Pull request event: 2
- Create event: 8
Last Year
- Release event: 3
- Watch event: 2
- Delete event: 2
- Push event: 55
- Pull request event: 2
- Create event: 8
Packages
- Total packages: 1
-
Total downloads:
- pypi 17 last-month
- Total dependent packages: 0
- Total dependent repositories: 0
- Total versions: 2
- Total maintainers: 1
pypi.org: fedzk
Secure Federated Learning with Zero-Knowledge Proofs
- Documentation: https://fedzk.readthedocs.io/
- License: MIT
-
Latest release: 1.0.1
published 10 months ago
Rankings
Maintainers (1)
Dependencies
- actions/checkout v3 composite
- actions/setup-python v4 composite
- actions/upload-artifact v3 composite
- actions/checkout v3 composite
- actions/setup-python v4 composite
- actions/checkout v3 composite
- actions/download-artifact v3 composite
- actions/setup-python v4 composite
- actions/upload-artifact v3 composite
- softprops/action-gh-release v1 composite
- actions/checkout v3 composite
- actions/setup-python v4 composite
- github-changelog-generator/github-changelog-generator-action v1.3.0 composite
- python 3.9-slim build
- grafana/grafana latest
- prom/prometheus latest
- httpx >=0.21.0
- numpy >=1.21.0
- requests >=2.25.1
- rich >=10.0.0
- typer [all]>=0.4.0