| Crates.io | ant-core |
| lib.rs | ant-core |
| version | 0.1.8 |
| created_at | 2025-06-27 09:51:52.603948+00 |
| updated_at | 2025-06-27 09:51:52.603948+00 |
| description | Ant Network - Core P2P networking library with DHT, QUIC transport, three-word addresses, and MCP integration |
| homepage | https://github.com/dirvine/p2p |
| repository | https://github.com/dirvine/p2p |
| max_upload_size | |
| id | 1728399 |
| size | 965,999 |
Ant Network - Core P2P networking library with DHT, QUIC transport, three-word addresses, and MCP integration
Ant Core is a modern P2P networking library built in Rust that provides:
Add this to your Cargo.toml:
[dependencies]
ant-core = "0.1.8"
tokio = { version = "1", features = ["full"] }
use ant_core::{
network::{P2PNode, NodeConfig},
identity::manager::{IdentityManager, IdentityManagerConfig},
};
#[tokio::main]
async fn main() -> Result<(), Box<dyn std::error::Error>> {
// Create a P2P node
let config = NodeConfig::default();
let node = P2PNode::new(config).await?;
// Create identity manager
let identity_manager = IdentityManager::new(IdentityManagerConfig::default());
// Create a user identity
let identity = identity_manager.create_identity(
"My Display Name".to_string(),
"my.three.words".to_string(),
None,
None,
).await?;
println!("Created identity: {}", identity.user_id);
// Store data in DHT
let key = ant_core::dht::Key::new(b"my-key");
let value = b"my-value".to_vec();
node.dht_put(key.clone(), value).await?;
// Retrieve data from DHT
if let Some(retrieved) = node.dht_get(key).await? {
println!("Retrieved: {:?}", String::from_utf8_lossy(&retrieved));
}
Ok(())
}
use ant_core::identity::manager::{IdentityManager, IdentityManagerConfig};
let manager = IdentityManager::new(IdentityManagerConfig::default());
// Create encrypted identity
let identity = manager.create_identity(
"Alice".to_string(),
"alice.secure.network".to_string(),
None,
None,
).await?;
// Export for backup
let export_data = manager.export_identity().await?;
// Import on another device
let imported = manager.import_identity(&export_data).await?;
use ant_core::dht::Key;
// Store data
let key = Key::new(b"user:alice:profile");
let data = b"encrypted_profile_data".to_vec();
node.dht_put(key.clone(), data).await?;
// Retrieve data
if let Some(data) = node.dht_get(key).await? {
println!("Found profile data");
}
Ant Core is designed with a modular architecture:
┌─────────────────┐
│ Application │
├─────────────────┤
│ Identity Mgmt │
├─────────────────┤
│ MCP Server │
├─────────────────┤
│ DHT │
├─────────────────┤
│ Transport │
│ (QUIC/TCP) │
├─────────────────┤
│ Bootstrap │
└─────────────────┘
use ant_core::network::{NodeConfig, SecurityConfig, TrustLevel};
use std::time::Duration;
let config = NodeConfig {
listen_addr: "0.0.0.0:9000".parse()?,
enable_ipv6: true,
enable_mcp_server: true,
connection_timeout: Duration::from_secs(30),
max_connections: 100,
security_config: SecurityConfig {
enable_noise: true,
enable_tls: true,
trust_level: TrustLevel::Basic,
},
..Default::default()
};
Check out the examples directory for:
Ant Core powers:
We welcome contributions! Please see our contributing guidelines for details.
Licensed under either of
at your option.