Crate saorsa_core

Source
Expand description

§Saorsa Core

A next-generation peer-to-peer networking foundation built in Rust.

§Features

  • QUIC-based transport with NAT traversal
  • IPv4-first with simple addressing
  • Kademlia DHT for distributed routing
  • Built-in MCP server for AI capabilities
  • Four-word human-readable addresses

§Example

use saorsa_core::{P2PNode, NodeConfig, NetworkAddress};
use std::str::FromStr;

#[tokio::main]
async fn main() -> anyhow::Result<()> {
    let addr = "127.0.0.1:9000".parse::<NetworkAddress>()?;
    let node = P2PNode::builder()
        .listen_on(addr)
        .with_mcp_server()
        .build()
        .await?;
     
    node.run().await?;
    Ok(())
}

Re-exports§

pub use address::AddressBook;
pub use address::NetworkAddress;
pub use bootstrap::BootstrapCache;
pub use bootstrap::BootstrapManager;
pub use bootstrap::CacheConfig;
pub use bootstrap::ContactEntry;
pub use crypto_verify::BatchVerificationRequest;
pub use crypto_verify::BatchVerificationResult;
pub use crypto_verify::EnhancedSignatureVerification;
pub use crypto_verify::EnhancedSignatureVerifier;
pub use crypto_verify::VerificationStats;
pub use dht::Key;
pub use dht::Record;
pub use dht_network_manager::BootstrapNode;
pub use dht_network_manager::DhtNetworkConfig;
pub use dht_network_manager::DhtNetworkEvent;
pub use dht_network_manager::DhtNetworkManager;
pub use dht_network_manager::DhtNetworkOperation;
pub use dht_network_manager::DhtNetworkResult;
pub use dht_network_manager::DhtPeerInfo;
pub use encrypted_key_storage::Argon2Config;
pub use encrypted_key_storage::DerivationPriority as KeyDerivationPriority;
pub use encrypted_key_storage::EncryptedKeyStorageManager;
pub use encrypted_key_storage::KeyMetadata;
pub use encrypted_key_storage::PasswordValidation;
pub use encrypted_key_storage::SecurityLevel;
pub use encrypted_key_storage::StorageStats;
pub use error::P2PError;
pub use error::P2pResult as Result;
pub use health::ComponentChecker;
pub use health::ComponentHealth;
pub use health::HealthEndpoints;
pub use health::HealthManager;
pub use health::HealthResponse;
pub use health::HealthServer;
pub use health::HealthStatus;
pub use health::PrometheusExporter;
pub use identity_manager::Identity;
pub use identity_manager::IdentityCreationParams;
pub use identity_manager::IdentityKeyPair;
pub use identity_manager::IdentityManager;
pub use identity_manager::IdentityState;
pub use identity_manager::IdentityStats;
pub use identity_manager::IdentitySyncPackage;
pub use identity_manager::IdentityUpdate;
pub use identity_manager::IdentityVerification;
pub use identity_manager::RevocationCertificate;
pub use identity_manager::RevocationReason;
pub use key_derivation::BatchDerivationRequest;
pub use key_derivation::BatchDerivationResult;
pub use key_derivation::DerivationPath;
pub use key_derivation::DerivationPriority;
pub use key_derivation::DerivationStats;
pub use key_derivation::DerivedKey;
pub use key_derivation::HierarchicalKeyDerivation;
pub use key_derivation::MasterSeed;
pub use mcp::MCPServer;
pub use mcp::MCPService;
pub use mcp::Tool;
pub use monotonic_counter::BatchUpdateRequest;
pub use monotonic_counter::BatchUpdateResult;
pub use monotonic_counter::CounterStats;
pub use monotonic_counter::MonotonicCounterSystem;
pub use monotonic_counter::PeerCounter;
pub use monotonic_counter::SequenceValidationResult;
pub use network::NodeBuilder;
pub use network::NodeConfig;
pub use network::P2PEvent;
pub use network::P2PNode;
pub use peer_record::EndpointId;
pub use peer_record::NatType;
pub use peer_record::PeerDHTRecord;
pub use peer_record::PeerEndpoint;
pub use peer_record::SignatureCache;
pub use peer_record::UserId;
pub use persistent_state::FlushStrategy;
pub use persistent_state::IntegrityReport;
pub use persistent_state::PersistentStateManager;
pub use persistent_state::RecoveryMode;
pub use persistent_state::RecoveryStats;
pub use persistent_state::StateChangeEvent;
pub use persistent_state::StateConfig;
pub use persistent_state::TransactionType;
pub use persistent_state::WalEntry;
pub use production::ProductionConfig;
pub use production::ResourceManager;
pub use production::ResourceMetrics;
pub use secure_memory::PoolStats;
pub use secure_memory::SecureMemory;
pub use secure_memory::SecureMemoryPool;
pub use secure_memory::SecureString;
pub use secure_memory::SecureVec;
pub use secure_memory::allocate_secure;
pub use secure_memory::secure_string_with_capacity;
pub use secure_memory::secure_vec_with_capacity;
pub use validation::RateLimitConfig;
pub use validation::RateLimiter;
pub use validation::Sanitize;
pub use validation::Validate;
pub use validation::ValidationContext;
pub use validation::ValidationError;
pub use validation::sanitize_string;
pub use validation::validate_dht_key;
pub use validation::validate_dht_value;
pub use validation::validate_file_path;
pub use validation::validate_message_size;
pub use validation::validate_network_address;
pub use validation::validate_peer_id;
pub use identity::enhanced::Department;
pub use identity::enhanced::EnhancedIdentity;
pub use identity::enhanced::EnhancedIdentityManager;
pub use identity::enhanced::Organization;
pub use identity::enhanced::Permission;
pub use identity::enhanced::Team;
pub use storage::FileChunker;
pub use storage::StorageManager;
pub use chat::Call;
pub use chat::Channel;
pub use chat::ChannelId;
pub use chat::ChannelType;
pub use chat::ChatManager;
pub use chat::Message;
pub use chat::MessageId;
pub use chat::Thread;
pub use discuss::Badge;
pub use discuss::Category;
pub use discuss::CategoryId;
pub use discuss::DiscussManager;
pub use discuss::Poll;
pub use discuss::Reply;
pub use discuss::ReplyId;
pub use discuss::Topic;
pub use discuss::TopicId;
pub use discuss::UserStats;
pub use projects::Document;
pub use projects::DocumentId;
pub use projects::Folder;
pub use projects::Project;
pub use projects::ProjectAnalytics;
pub use projects::ProjectId;
pub use projects::ProjectsManager;
pub use projects::WorkflowState;
pub use threshold::GroupMetadata;
pub use threshold::ParticipantInfo;
pub use threshold::ThresholdGroup;
pub use threshold::ThresholdGroupManager;
pub use threshold::ThresholdSignature;
pub use quantum_crypto::QuantumCryptoError;
pub use quantum_crypto::CryptoCapabilities;
pub use quantum_crypto::ProtocolVersion;
pub use quantum_crypto::KemAlgorithm;
pub use quantum_crypto::SignatureAlgorithm;
pub use quantum_crypto::NegotiatedAlgorithms;
pub use quantum_crypto::negotiate_algorithms;
pub use quantum_crypto::ant_quic_integration::create_default_pqc_config;
pub use quantum_crypto::ant_quic_integration::create_pqc_only_config;
pub use quantum_crypto::ant_quic_integration::generate_ml_dsa_keypair;
pub use quantum_crypto::ant_quic_integration::ml_dsa_sign;
pub use quantum_crypto::ant_quic_integration::ml_dsa_verify;
pub use quantum_crypto::ant_quic_integration::generate_ml_kem_keypair;
pub use quantum_crypto::ant_quic_integration::ml_kem_encapsulate;
pub use quantum_crypto::ant_quic_integration::ml_kem_decapsulate;
pub use quantum_crypto::types::GroupId;
pub use quantum_crypto::types::ParticipantId;
pub use quantum_crypto::types::PeerId as QuantumPeerId;
pub use quantum_crypto::types::SessionId;
pub use quantum_crypto::types::QuantumPeerIdentity;
pub use quantum_crypto::types::SecureSession;
pub use quantum_crypto::types::SessionState;
pub use quantum_crypto::types::HandshakeParameters;
pub use quantum_crypto::types::Ed25519PublicKey;
pub use quantum_crypto::types::Ed25519PrivateKey;
pub use quantum_crypto::types::Ed25519Signature;
pub use quantum_crypto::types::FrostPublicKey;
pub use quantum_crypto::types::FrostGroupPublicKey;
pub use quantum_crypto::types::FrostKeyShare;
pub use quantum_crypto::types::FrostCommitment;
pub use quantum_crypto::types::FrostSignature;
pub use placement::AuditSystem;
pub use placement::DataPointer;
pub use placement::DhtRecord;
pub use placement::DiversityEnforcer;
pub use placement::GeographicLocation;
pub use placement::GroupBeacon;
pub use placement::NetworkRegion;
pub use placement::NodeAd;
pub use placement::PlacementConfig;
pub use placement::PlacementDecision;
pub use placement::PlacementEngine;
pub use placement::PlacementMetrics;
pub use placement::PlacementOrchestrator;
pub use placement::RegisterPointer;
pub use placement::RepairSystem;
pub use placement::StorageOrchestrator;
pub use placement::WeightedPlacementStrategy;

Modules§

adaptive
Adaptive P2P network implementation Adaptive P2P Network Implementation
address
Network address types
bootstrap
Bootstrap cache for decentralized peer discovery Bootstrap Cache System
chat
Chat system (Slack-like) Chat system (Slack-like) with channels, threads, and real-time messaging
config
Configuration management system
crypto_verify
Enhanced cryptographic signature verification system
dht
Distributed Hash Table implementation Distributed Hash Table (DHT) Implementation
dht_network_manager
DHT Network Integration Manager DHT Network Manager
discuss
Discuss system (Discourse-like) Discuss system (Discourse-like) for long-form discussions and knowledge sharing
encrypted_key_storage
Encrypted key storage with Argon2id and AES-256-GCM
error
Error types Comprehensive error handling framework for P2P Foundation
geographic_enhanced_network
Geographic-aware networking enhancements for P2P routing optimization Geographic Enhanced Network Module
health
Health check system for monitoring and metrics Health check system for P2P Foundation
identity
User identity and privacy system Identity management module
identity_manager
Identity management system with Ed25519/X25519 key pairs
key_derivation
Hierarchical key derivation system
mcp
Model Context Protocol server Model Context Protocol (MCP) Server Implementation
messaging
Rich messaging system (WhatsApp/Slack-style)
monotonic_counter
Monotonic counter system for replay attack prevention
network
Network core functionality Network module
peer_record
Peer record system for DHT-based peer discovery
persistent_state
Persistent state management with crash recovery
placement
Placement Loop & Storage Orchestration System Placement Loop & Storage Orchestration System
production
Production hardening features Production hardening features for the P2P Foundation
projects
Projects system with hierarchical organization Projects system with hierarchical organization structure
quantum_crypto
Quantum-resistant cryptography Quantum-resistant cryptography module
secure_memory
Secure memory management for cryptographic operations
security
Security and cryptography Security module
storage
DHT-based storage for multi-device sync DHT-based storage module for multi-device synchronization
threshold
Threshold cryptography for group operations Threshold cryptography module
transport
Transport layer (QUIC, TCP) Transport Layer
utils
Utility functions and types Utilities module placeholder
validation
Validation framework for input sanitization and rate limiting Comprehensive input validation framework for P2P Foundation

Structs§

MlDsa65
ML-DSA-65 implementation
MlDsaPublicKey
ML-DSA-65 public key
MlDsaSecretKey
ML-DSA-65 secret key
MlDsaSignature
ML-DSA-65 signature
MlKem768
ML-KEM-768 implementation
MlKemCiphertext
ML-KEM-768 ciphertext
MlKemPublicKey
ML-KEM-768 public key
MlKemSecretKey
ML-KEM-768 secret key
PqcConfig
Configuration for Post-Quantum Cryptography behavior
PqcConfigBuilder
Builder for PqcConfig
SharedSecret
Shared secret from key encapsulation

Enums§

HybridPreference
Preference for algorithm selection in hybrid mode
PqcMode
Operation mode for Post-Quantum Cryptography

Constants§

VERSION
Saorsa Core version

Type Aliases§

Multiaddr
Network address used for peer-to-peer communication
PeerId
Peer identifier used throughout Saorsa