Privacy Features¶
SolanaLM provides comprehensive privacy features for sensitive AI workloads.
Privacy Overview¶
SolanaLM implements multiple privacy layers:
| Layer | Feature | Protection |
|---|---|---|
| Network | Onion Routing | Hides request origin |
| Payment | Anonymous Payments | Breaks payment correlation |
| Training | Differential Privacy | Protects training data |
| Inference | End-to-End Encryption | Secures request content |
Onion Routing¶
Tor-like multi-hop encryption that hides request origin and destination.
How It Works¶
Client → Entry Node → Relay Node → Exit Node → Destination
(Layer 3) (Layer 2) (Layer 1)
Each hop only knows:
- Previous hop
- Next hop
- Nothing about origin or final destination
Using Private Inference¶
from client.python.solanalm_client import SolanaLMClient
async with SolanaLMClient("http://localhost:8001") as client:
response = await client.private_inference(
model="microsoft/DialoGPT-small",
prompt="Sensitive business query",
wallet_address="your-wallet",
privacy_level="standard" # or "high"
)
Privacy Levels¶
| Level | Circuit Length | Latency | Anonymity |
|---|---|---|---|
standard |
3 hops | ~500ms | Good |
high |
5 hops | ~1000ms | Excellent |
Circuit Configuration¶
# Custom circuit configuration
response = await client.private_inference(
model="microsoft/DialoGPT-small",
prompt="query",
wallet_address="wallet",
privacy_level="high",
circuit_config={
"min_hops": 5,
"max_hops": 7,
"prefer_diverse_regions": True,
"exclude_nodes": ["untrusted-node-1"]
}
)
Anonymous Payments¶
Break the correlation between requests and payments.
Payment Mixing¶
from core.privacy.anonymous_payments import AnonymousPaymentManager
payment_manager = AnonymousPaymentManager(
mixing_pool_size=100,
mixing_rounds=3,
delay_range=(10, 60) # Random delay in seconds
)
# Submit anonymous payment
tx_id = await payment_manager.pay_anonymously(
amount=0.01,
recipient="destination-wallet",
source_wallet="your-wallet"
)
Payment Privacy Modes¶
# Standard - fast but traceable
await client.inference(..., payment_mode="standard")
# Mixed - adds delay, breaks direct correlation
await client.inference(..., payment_mode="mixed")
# Anonymous - full mixing pool, maximum privacy
await client.inference(..., payment_mode="anonymous")
Differential Privacy in Training¶
Protect individual data points during federated learning.
Enabling DP¶
from core.nodes.training.node import TrainingNode
node = TrainingNode(
node_id="private-trainer",
wallet_address="wallet",
gateway_url="http://localhost:8001",
# Differential Privacy settings
enable_differential_privacy=True,
noise_multiplier=1.0,
max_grad_norm=1.0,
target_epsilon=8.0,
target_delta=1e-5
)
Privacy Budget¶
# Monitor privacy budget
status = await node.get_privacy_status()
print(f"Epsilon spent: {status['epsilon_spent']}")
print(f"Delta: {status['delta']}")
print(f"Remaining budget: {status['epsilon_remaining']}")
print(f"Rounds until budget exhausted: {status['rounds_remaining']}")
Noise Calibration¶
| Use Case | Epsilon | Noise Multiplier | Privacy |
|---|---|---|---|
| High privacy | ≤ 1.0 | 2.0+ | Maximum |
| Balanced | 2-8 | 1.0 | Good |
| Utility focus | > 8 | 0.5 | Moderate |
Secure Aggregation¶
Encrypt model updates during federated learning.
How It Works¶
┌─────────────────────────────────────────────────────┐
│ Nodes │
│ ┌───────┐ ┌───────┐ ┌───────┐ │
│ │Node A │ │Node B │ │Node C │ │
│ │Update │ │Update │ │Update │ │
│ │ + │ │ + │ │ + │ │
│ │Mask_A │ │Mask_B │ │Mask_C │ │
│ └───┬───┘ └───┬───┘ └───┬───┘ │
│ │ │ │ │
│ └────────────┼────────────┘ │
│ ▼ │
│ ┌─────────────────┐ │
│ │ Aggregator │ │
│ │ Sum of masked │ │
│ │ updates = Real │ Masks cancel out! │
│ │ aggregate │ │
│ └─────────────────┘ │
└─────────────────────────────────────────────────────┘
Enabling Secure Aggregation¶
from core.coordinator.training_coordinator import TrainingCoordinator
coordinator = TrainingCoordinator(
model_name="private-model",
secure_aggregation=True,
encryption_threshold=0.6, # 60% nodes needed
encryption_key_size=256
)
Privacy Metrics¶
Checking Network Privacy¶
async with SolanaLMClient(gateway_url) as client:
metrics = await client.get_privacy_metrics()
print(f"Anonymity set size: {metrics['anonymity_set_size']}")
print(f"Circuit diversity: {metrics['circuit_diversity_score']}")
print(f"Geographic coverage: {metrics['geographic_coverage']}")
Privacy Health¶
health = await client.get_privacy_network_health()
print(f"Privacy nodes online: {health['privacy_nodes']}")
print(f"Avg circuit length: {health['avg_circuit_length']}")
print(f"Success rate: {health['privacy_success_rate']}%")
Privacy Best Practices¶
For Users¶
-
Use private inference for sensitive queries
-
Rotate wallets for unlinkability
-
Verify circuit diversity
For Node Operators¶
-
Enable privacy features
-
Maintain uptime for circuit stability
-
Don't log sensitive request content
For Training Participants¶
-
Always enable differential privacy
-
Monitor privacy budget
-
Use secure aggregation when available
Privacy Trade-offs¶
Latency vs Privacy¶
Standard inference: ~100ms
Privacy level standard: ~500ms (5x slower)
Privacy level high: ~1000ms (10x slower)
Utility vs Privacy (Training)¶
Cost vs Privacy¶
Standard: 1x cost
Mixed payments: 1.05x cost (mixing fees)
Anonymous: 1.1x cost (full anonymization)
Compliance Considerations¶
SolanaLM privacy features help with:
- GDPR: Data minimization, right to be forgotten
- HIPAA: Protected health information handling
- CCPA: Consumer data privacy
- FERPA: Educational records privacy
Legal Disclaimer
Privacy features are tools to help protect data. Consult legal counsel for compliance requirements specific to your jurisdiction and use case.
Troubleshooting Privacy¶
Common Issues¶
Private inference times out
Circuit may have insufficient nodes. Check:
Differential privacy degrades model too much
Lower noise multiplier:
Secure aggregation fails
Not enough participants:
Next Steps¶
- Architecture Overview - System design
- Federated Learning - Training details
- API Reference - Full API documentation