Some checks failed
Blockchain Synchronization Verification / sync-verification (push) Failing after 3s
CLI Tests / test-cli (push) Failing after 3s
Cross-Chain Functionality Tests / test-cross-chain-sync (push) Successful in 2s
Cross-Chain Functionality Tests / test-cross-chain-transactions (push) Successful in 3s
Cross-Chain Functionality Tests / test-cross-chain-bridge (push) Has been skipped
Cross-Chain Functionality Tests / test-multi-chain-consensus (push) Successful in 2s
Cross-Chain Functionality Tests / aggregate-results (push) Has been skipped
Deploy to Testnet / deploy-testnet (push) Successful in 1m12s
Documentation Validation / validate-docs (push) Failing after 8s
Documentation Validation / validate-policies-strict (push) Successful in 3s
Integration Tests / test-service-integration (push) Successful in 2m6s
Multi-Chain Island Architecture Tests / test-multi-chain-island (push) Successful in 2s
Multi-Node Blockchain Health Monitoring / health-check (push) Failing after 4s
P2P Network Verification / p2p-verification (push) Successful in 4s
Package Tests / Python package - aitbc-agent-sdk (push) Successful in 32s
Package Tests / Python package - aitbc-core (push) Successful in 14s
Package Tests / Python package - aitbc-crypto (push) Successful in 12s
Package Tests / Python package - aitbc-sdk (push) Successful in 9s
Package Tests / JavaScript package - aitbc-sdk-js (push) Successful in 8s
Package Tests / JavaScript package - aitbc-token (push) Successful in 17s
Python Tests / test-python (push) Successful in 15s
Security Scanning / security-scan (push) Successful in 27s
Node Failover Simulation / failover-test (push) Successful in 7s
Multi-Node Stress Testing / stress-test (push) Successful in 6s
Cross-Node Transaction Testing / transaction-test (push) Successful in 4s
- Add SQLCipher encryption for ait-mainnet database with configurable flag - Add db_encryption_enabled and db_encryption_key_path config settings - Implement encryption key loading and PRAGMA key setup via connection events - Add shutdown_db function for proper database cleanup - Export middleware classes in aitbc/__init__.py - Fix import path in sync.py for settings - Remove duplicate agent documentation from docs
142 lines
3.9 KiB
Markdown
142 lines
3.9 KiB
Markdown
# ZK Circuits Engine
|
|
|
|
## Overview
|
|
|
|
The ZK Circuits Engine provides zero-knowledge proof capabilities for privacy-preserving machine learning operations on the AITBC platform. It enables cryptographic verification of ML computations without revealing the underlying data or model parameters.
|
|
|
|
## Architecture
|
|
|
|
### Circuit Library
|
|
- **ml_inference_verification.circom**: Verifies neural network inference correctness
|
|
- **ml_training_verification.circom**: Verifies gradient descent training without revealing data
|
|
- **receipt_simple.circom**: Basic receipt verification (existing)
|
|
|
|
### Proof System
|
|
- **Groth16**: Primary proving system for efficiency
|
|
- **Trusted Setup**: Powers-of-tau ceremony for circuit-specific keys
|
|
- **Verification Keys**: Pre-computed for each circuit
|
|
|
|
## Circuit Details
|
|
|
|
### ML Inference Verification
|
|
|
|
```circom
|
|
pragma circom 2.0.0;
|
|
|
|
template MLInferenceVerification(INPUT_SIZE, HIDDEN_SIZE, OUTPUT_SIZE) {
|
|
signal public input model_id;
|
|
signal public input inference_id;
|
|
signal public input expected_output[OUTPUT_SIZE];
|
|
signal public input output_hash;
|
|
|
|
signal private input inputs[INPUT_SIZE];
|
|
signal private input weights1[HIDDEN_SIZE][INPUT_SIZE];
|
|
signal private input biases1[HIDDEN_SIZE];
|
|
signal private input weights2[OUTPUT_SIZE][HIDDEN_SIZE];
|
|
signal private input biases2[OUTPUT_SIZE];
|
|
|
|
signal private input inputs_hash;
|
|
signal private input weights1_hash;
|
|
signal private input biases1_hash;
|
|
signal private input weights2_hash;
|
|
signal private input biases2_hash;
|
|
|
|
signal output verification_result;
|
|
// ... neural network computation and verification
|
|
}
|
|
```
|
|
|
|
**Features:**
|
|
- Matrix multiplication verification
|
|
- ReLU activation function verification
|
|
- Hash-based privacy preservation
|
|
- Output correctness verification
|
|
|
|
### ML Training Verification
|
|
|
|
```circom
|
|
template GradientDescentStep(PARAM_COUNT) {
|
|
signal input parameters[PARAM_COUNT];
|
|
signal input gradients[PARAM_COUNT];
|
|
signal input learning_rate;
|
|
signal input parameters_hash;
|
|
signal input gradients_hash;
|
|
|
|
signal output new_parameters[PARAM_COUNT];
|
|
signal output new_parameters_hash;
|
|
// ... gradient descent computation
|
|
}
|
|
```
|
|
|
|
**Features:**
|
|
- Gradient descent verification
|
|
- Parameter update correctness
|
|
- Training data privacy preservation
|
|
- Convergence verification
|
|
|
|
## API Integration
|
|
|
|
### Proof Generation
|
|
```bash
|
|
POST /v1/ml-zk/prove/inference
|
|
{
|
|
"inputs": {
|
|
"model_id": "model_123",
|
|
"inference_id": "inference_456",
|
|
"expected_output": [2.5]
|
|
},
|
|
"private_inputs": {
|
|
"inputs": [1, 2, 3, 4],
|
|
"weights1": [0.1, 0.2, 0.3, 0.4],
|
|
"biases1": [0.1, 0.2]
|
|
}
|
|
}
|
|
```
|
|
|
|
### Proof Verification
|
|
```bash
|
|
POST /v1/ml-zk/verify/inference
|
|
{
|
|
"proof": "...",
|
|
"public_signals": [...],
|
|
"verification_key": "..."
|
|
}
|
|
```
|
|
|
|
## Development Workflow
|
|
|
|
### Circuit Development
|
|
1. Write Circom circuit with templates
|
|
2. Compile with `circom circuit.circom --r1cs --wasm --sym --c -o build/`
|
|
3. Generate trusted setup with `snarkjs`
|
|
4. Export verification key
|
|
5. Integrate with ZKProofService
|
|
|
|
### Testing
|
|
- Unit tests for circuit compilation
|
|
- Integration tests for proof generation/verification
|
|
- Performance benchmarks for proof time
|
|
- Memory usage analysis
|
|
|
|
## Performance Characteristics
|
|
|
|
- **Circuit Compilation**: ~30-60 seconds
|
|
- **Proof Generation**: <2 seconds
|
|
- **Proof Verification**: <100ms
|
|
- **Circuit Size**: ~10-50KB compiled
|
|
- **Security Level**: 128-bit equivalent
|
|
|
|
## Security Considerations
|
|
|
|
- **Trusted Setup**: Powers-of-tau ceremony properly executed
|
|
- **Circuit Correctness**: Thorough mathematical verification
|
|
- **Input Validation**: Proper bounds checking on all signals
|
|
- **Side Channel Protection**: Constant-time operations where possible
|
|
|
|
## Future Enhancements
|
|
|
|
- **PLONK/STARK Integration**: Alternative proving systems
|
|
- **Recursive Proofs**: Proof composition for complex workflows
|
|
- **Hardware Acceleration**: GPU-accelerated proof generation
|
|
- **Multi-party Computation**: Distributed proof generation
|