Saorsa Core
Core P2P networking library for Saorsa platform with DHT, QUIC transport, four-word addresses, and MCP integration.
Features
- DHT (Distributed Hash Table): Advanced DHT implementation with RSPS (Root-Scoped Provider Summaries)
- Placement System: Intelligent shard placement with EigenTrust integration and Byzantine fault tolerance
- QUIC Transport: High-performance networking with ant-quic
- Four-Word Addresses: Human-readable network addresses
- MCP Integration: Model Context Protocol support
- Post-Quantum Cryptography: Future-ready cryptographic algorithms
- WebRTC Support: Voice and video calling capabilities
- Media Processing: Image and audio processing with blurhash and symphonia
- Geographic Routing: Location-aware networking
- Identity Management: Ed25519-based identity system
- Secure Storage: Database persistence with SQLx
- Monitoring: Prometheus metrics integration
Quick Start
Add this to your Cargo.toml:
[]
= "0.2.6"
Basic DHT Node
use ;
use tokio;
async
Four-Word Addresses
use NetworkAddress;
// Create from IP:port
let addr = from_ipv4;
// Get four-word representation
if let Some = addr.four_words
// Parse from four-word format
let addr = from_four_words?;
MCP Server
use ;
async
Architecture
Core Components
- Network Layer: QUIC-based P2P networking with NAT traversal
- DHT: Kademlia-based DHT with RSPS optimization
- Placement System: Intelligent shard placement with weighted selection algorithms
- Identity: Ed25519 cryptographic identities with four-word addresses
- Storage: Local and distributed content storage with audit and repair
- Geographic Routing: Location-aware message routing
- MCP Integration: Model Context Protocol for AI/LLM integration
Data Flow
Application
↓
Network API
↓
Placement Engine → DHT + Geographic Routing
↓ ↓
↓ Audit & Repair
↓ ↓
QUIC Transport (ant-quic)
↓
Internet
Placement System
Saorsa Core includes an advanced placement system for optimal distribution of erasure-coded shards across the network:
use ;
async
Key Features
- EigenTrust Integration: Uses reputation scores for node selection
- Weighted Selection: Balances trust, performance, capacity, and diversity
- Byzantine Fault Tolerance: Configurable f-out-of-3f+1 security model
- Geographic Diversity: Ensures shards are distributed across regions
- Continuous Monitoring: Audit system with automatic repair
- DHT Record Types: Efficient ≤512B records with proof-of-work
- Hysteresis Control: Prevents repair storms with smart cooldown
Configuration
use NetworkConfig;
let config = NetworkConfig ;
Feature Flags
default- DHT, MCP, ant-quic (four-word addresses always enabled)dht- DHT functionalitymcp- MCP server supportant-quic- QUIC transportquantum-resistant- Post-quantum cryptographythreshold- Threshold cryptographycli- CLI utilitiesmetrics- Prometheus metricscommercial- Commercial license features
Performance
Saorsa Core is designed for high performance:
- Concurrent Operations: Tokio-based async runtime
- Memory Efficiency: Zero-copy operations where possible
- Network Optimization: QUIC with congestion control
- Caching: Multi-level caching with Q-learning optimization
Benchmarks
Run benchmarks with:
Key benchmarks:
- DHT operations: ~10,000 ops/sec
- Storage throughput: ~100 MB/sec
- Geographic routing: <10ms latency
- Placement decisions: <1s for 8-node selection
- Shard repair: Automatic with <1h detection
- Cryptographic operations: Hardware-accelerated
Security
- Ed25519 Signatures: All operations cryptographically signed
- BLAKE3 Hashing: Fast and secure content addressing
- QUIC Encryption: Transport-level encryption
- Post-Quantum Ready: ML-KEM and ML-DSA support
- Secure Memory: Platform-specific memory protection
WebRTC Integration
Full WebRTC stack for real-time communication:
use ;
let webrtc = new.await?;
let call = webrtc.create_call.await?;
Media Processing
Built-in media processing capabilities:
- Images: JPEG, PNG, WebP, GIF support with blurhash
- Audio: Full codec support via symphonia
- Streaming: Real-time media streaming over WebRTC
Database Integration
SQLite-based persistence with migrations:
use Database;
let db = open.await?;
db.store_message.await?;
Geographic Features
Location-aware networking:
- Geographic distance calculations
- Location-based routing
- Regional content distribution
- Privacy-preserving location services
Development
Building
# Standard build
# With all features
# Feature-specific build
Testing
# Unit tests
# Integration tests
# Property-based tests
Linting
Contributing
- Fork the repository
- Create a feature branch
- Make your changes
- Add tests for new functionality
- Ensure all tests pass
- Submit a pull request
Code Style
- Follow Rust 2024 idioms
- Use
cargo fmtfor formatting - Ensure
cargo clippypasses - Add documentation for public APIs
- Include tests for all new features
License
This project is dual-licensed:
- AGPL-3.0: Open source license for open source projects
- Commercial: Commercial license for proprietary projects
For commercial licensing, contact: saorsalabs@gmail.com
Dependencies
Core Dependencies
tokio- Async runtimefutures- Future utilitiesserde- Serializationanyhow- Error handlingtracing- Logging
Networking
ant-quic- QUIC transportfour-word-networking- Human-readable addressesrustls- TLS support
Cryptography
ed25519-dalek- Digital signaturesblake3- Hashingrand- Random number generationx25519-dalek- Key exchangeaes-gcm- Symmetric encryption
Storage & Database
sqlx- Database operationslru- LRU cachingreed-solomon-erasure- Error correction
Media & WebRTC
webrtc- WebRTC implementationimage- Image processingsymphonia- Audio codecsrodio- Audio playback
See Cargo.toml for complete dependency list.
Changelog
See CHANGELOG.md for version history.
Support
- Issues: GitHub Issues
- Discussions: GitHub Discussions
- Email: saorsalabs@gmail.com
Saorsa Labs Limited - Building the decentralized future