exo-federation
Federated cognitive mesh networking for EXO-AI 2025 distributed substrate.
Overview
This crate implements a distributed federation layer for cognitive substrates with:
- Post-quantum cryptography (CRYSTALS-Kyber key exchange)
- Privacy-preserving onion routing for query intent protection
- CRDT-based eventual consistency across federation nodes
- Byzantine fault-tolerant consensus (PBFT-style)
Architecture
┌─────────────────────────────────────────┐
│ FederatedMesh (Coordinator) │
├─────────────────────────────────────────┤
│ • Local substrate instance │
│ • Consensus coordination │
│ • Federation gateway │
│ • Cryptographic identity │
└─────────────────────────────────────────┘
│ │ │
┌─────┘ │ └─────┐
▼ ▼ ▼
Handshake Onion CRDT
Protocol Router Reconciliation
Modules
crypto.rs (232 lines)
Post-quantum cryptographic primitives:
PostQuantumKeypair- CRYSTALS-Kyber key pairs (placeholder implementation)EncryptedChannel- Secure communication channelsSharedSecret- Key derivation from PQ key exchange
Status: Placeholder implementation. Real implementation will use pqcrypto-kyber.
handshake.rs (280 lines)
Federation joining protocol:
join_federation()- Cryptographic handshake with peersFederationToken- Access token with negotiated capabilitiesCapability- Feature negotiation system
Protocol:
- Post-quantum key exchange
- Establish encrypted channel
- Exchange and negotiate capabilities
- Issue federation token
onion.rs (263 lines)
Privacy-preserving query routing:
onion_query()- Multi-hop encrypted routingOnionMessage- Layered encrypted messagespeel_layer()- Relay node layer decryption
Features:
- Query intent privacy (each relay only knows prev/next hop)
- Multiple encryption layers
- Response routing through same path
crdt.rs (329 lines)
Conflict-free replicated data types:
GSet<T>- Grow-only set (union merge)LWWRegister<T>- Last-writer-wins register (timestamp-based)LWWMap<K,V>- Map of LWW registersreconcile_crdt()- Merge federated query responses
Properties:
- Commutative, associative, idempotent merges
- Eventual consistency guarantees
- No coordination required for updates
consensus.rs (340 lines)
Byzantine fault-tolerant consensus:
byzantine_commit()- PBFT-style consensus protocolCommitProof- Cryptographic proof of consensus- Byzantine threshold calculation (n = 3f + 1)
Phases:
- Pre-prepare (leader proposes)
- Prepare (nodes acknowledge, 2f+1 required)
- Commit (nodes commit, 2f+1 required)
lib.rs (286 lines)
Main federation coordinator:
FederatedMesh- Main coordinator structFederationScope- Query scope control (Local/Direct/Global)FederatedResult- Query results from peers
Usage Example
use *;
async
Implementation Status
✅ Completed
- Core data structures and interfaces
- Module organization
- Async patterns with Tokio
- Comprehensive test coverage
- Documentation
🚧 Placeholder Implementations
-
Post-quantum crypto: Currently using simplified placeholders
- Real implementation needs
pqcrypto-kyberintegration - Proper key exchange protocol
- Real implementation needs
-
Network layer: Simulated message passing
- Real implementation needs TCP/UDP networking
- Message serialization/deserialization
-
Consensus coordination: Single-node simulation
- Real implementation needs distributed message collection
- Network timeout handling
🔜 Future Work
-
Real PQC Integration
- Integrate
pqcrypto-kybercrate - Implement actual key exchange
- Add digital signatures
- Integrate
-
Network Layer
- TCP/QUIC transport
- Message framing
- Connection pooling
-
Distributed Consensus
- Leader election
- View change protocol
- Checkpoint mechanisms
-
Performance Optimizations
- Batch message processing
- Parallel verification
- Cache optimizations
Security Considerations
Implemented
- Post-quantum key exchange (placeholder)
- Message authentication codes
- Onion routing for query privacy
TODO
- Certificate management
- Peer authentication
- Rate limiting
- DoS protection
- Audit logging
Dependencies
= { = "../exo-core" }
= { = "1.41", = ["full"] }
= { = "1.0", = ["derive"] }
= "6.1"
= "0.8"
= "0.10"
= "0.4"
Testing
# Run all tests
# Run specific module tests
References
- CRYSTALS-Kyber: pqcrypto.org
- PBFT: "Practical Byzantine Fault Tolerance" by Castro & Liskov
- CRDTs: "A comprehensive study of CRDTs" by Shapiro et al.
- Onion Routing: Tor protocol design
Integration with EXO-AI
This crate integrates with the broader EXO-AI cognitive substrate:
- exo-core: Core traits and types
- exo-temporal: Causal memory coordination
- exo-manifold: Distributed manifold queries
- exo-hypergraph: Federated topology queries
Links
License
MIT OR Apache-2.0