ant-quic
QUIC transport with NAT traversal for P2P networks. Every node is symmetric - can connect AND accept connections.
Key Features
- 100% Post-Quantum Cryptography - ML-KEM-768 + ML-DSA-65 on every connection
- Symmetric P2P Nodes - Every node is identical: connect, accept, coordinate
- Automatic NAT Traversal - Per draft-seemann-quic-nat-traversal-02
- External Address Discovery - Per draft-ietf-quic-address-discovery-00
- Raw Public Key Identity - Ed25519 identity per RFC 7250
- Zero Configuration Required - Sensible defaults, just create and connect
Quick Start
use ;
async
Architecture
ant-quic uses a symmetric P2P model where every node has identical capabilities:
┌─────────────┐ ┌─────────────┐
│ Node A │◄───────►│ Node B │
│ (peer) │ QUIC │ (peer) │
│ │ PQC │ │
└─────────────┘ └─────────────┘
│ │
│ OBSERVED_ADDRESS │
│◄──────────────────────┤
│ │
├──────────────────────►│
│ ADD_ADDRESS │
└───────────────────────┘
No Roles - All Nodes Are Equal
In v0.13.0, we removed all role distinctions:
- No
EndpointRole::Client/Server/Bootstrap - No
NatTraversalRoleenum - Any peer can coordinate NAT traversal for other peers
- Any peer can report your external address via OBSERVED_ADDRESS frames
The term "known_peers" replaces "bootstrap_nodes" - they're just addresses to connect to first. Any connected peer can help with address discovery.
Three-Layer Design
- Protocol Layer: QUIC + NAT traversal extension frames
- Integration APIs:
P2pEndpoint,P2pConfig - Applications: Binary, examples
Post-Quantum Cryptography (Always On)
Every connection uses post-quantum cryptography - there is no classical-only mode.
Algorithms
| Algorithm | Standard | Purpose | Security Level |
|---|---|---|---|
| ML-KEM-768 | FIPS 203 | Key Exchange | NIST Level 3 (192-bit) |
| ML-DSA-65 | FIPS 204 | Digital Signatures | NIST Level 3 (192-bit) |
Configuration
PQC is always enabled. The PqcConfig only tunes performance parameters:
use PqcConfig;
let pqc = builder
.ml_kem // Key exchange (required)
.ml_dsa // Signatures (optional, default: true)
.memory_pool_size // Memory pool for crypto ops
.handshake_timeout_multiplier // PQC handshakes are larger
.build?;
Why 100% PQC?
- Harvest Now, Decrypt Later - Protect against future quantum computers
- NIST Standardized - ML-KEM and ML-DSA are FIPS 203/204 standards
- No Configuration Errors - Can't accidentally use weak crypto
- Future-Proof - All historical connections are quantum-resistant
See docs/guides/pqc-security.md for security analysis.
NAT Traversal
NAT traversal is built into the QUIC protocol via extension frames, not STUN/TURN.
How It Works
- Connect to any known peer
- Peer observes your external address from incoming packets
- Peer sends OBSERVED_ADDRESS frame back to you
- You learn your public address and can coordinate hole punching
- Direct P2P connection established through NAT
Extension Frames
| Frame | Type ID | Purpose |
|---|---|---|
ADD_ADDRESS |
0x3d7e90 (IPv4), 0x3d7e91 (IPv6) | Advertise candidate addresses |
PUNCH_ME_NOW |
0x3d7e92 (IPv4), 0x3d7e93 (IPv6) | Coordinate hole punching timing |
REMOVE_ADDRESS |
0x3d7e94 | Remove stale address |
OBSERVED_ADDRESS |
0x9f81a6 (IPv4), 0x9f81a7 (IPv6) | Report external address to peer |
Transport Parameters
| Parameter | ID | Purpose |
|---|---|---|
| NAT Traversal Capability | 0x3d7e9f0bca12fea6 | Negotiates NAT traversal support |
| RFC-Compliant Frames | 0x3d7e9f0bca12fea8 | Enables RFC frame format |
| Address Discovery | 0x9f81a176 | Configures address observation |
NAT Type Support
| NAT Type | Success Rate | Notes |
|---|---|---|
| Full Cone | >95% | Direct connection |
| Restricted Cone | 80-90% | Coordinated punch |
| Port Restricted | 70-85% | Port-specific coordination |
| Symmetric | 60-80% | Prediction algorithms |
| CGNAT | 50-70% | Relay fallback may be needed |
See docs/NAT_TRAVERSAL_GUIDE.md for detailed information.
Raw Public Key Identity
Each node has an Ed25519 identity key. The PeerId is derived from the public key:
// PeerId = SHA-256(SubjectPublicKeyInfo)
let = generate_ed25519_keypair;
let peer_id = derive_peer_id_from_public_key;
This follows RFC 7250 for raw public keys in TLS/QUIC.
Trust Model
- TOFU (Trust On First Use): First contact stores SPKI fingerprint
- Rotation: New keys must be signed by old key (continuity)
- Channel Binding: TLS exporter signed with ML-DSA/Ed25519
- NAT/Path Changes: Token binding uses (PeerId || CID || nonce)
Installation
From Crates.io
Pre-built Binaries
Download from GitHub Releases:
- Linux:
ant-quic-linux-x86_64,ant-quic-linux-aarch64 - Windows:
ant-quic-windows-x86_64.exe - macOS:
ant-quic-macos-x86_64,ant-quic-macos-aarch64
From Source
Binary Usage
# Run as P2P node (connects and accepts)
# Connect to known peers for discovery
# Show your external address (discovered via peers)
# Output: External address: YOUR.PUBLIC.IP:PORT
# Run with monitoring dashboard
# Interactive commands while running:
# /status - Show connections and discovered addresses
# /peers - List connected peers
# /help - Show all commands
API Reference
Primary Types
| Type | Purpose |
|---|---|
P2pEndpoint |
Main entry point for P2P networking |
P2pConfig |
Configuration builder |
P2pEvent |
Events from the endpoint |
PeerId |
32-byte peer identifier |
PqcConfig |
Post-quantum crypto tuning |
NatConfig |
NAT traversal tuning |
P2pEndpoint Methods
P2pConfig Builder
let config = builder
.bind_addr // Local address
.known_peer // Add known peer
.known_peers // Add multiple
.max_connections // Connection limit
.pqc // PQC tuning
.nat // NAT tuning
.mtu // MTU for PQC
.build?;
See docs/API_GUIDE.md for the complete API reference.
RFC Compliance
ant-quic implements these specifications:
| Specification | Status | Notes |
|---|---|---|
| RFC 9000 | Full | QUIC Transport Protocol |
| RFC 9001 | Full | QUIC TLS |
| RFC 7250 | Full | Raw Public Keys |
| draft-seemann-quic-nat-traversal-02 | Full | NAT Traversal |
| draft-ietf-quic-address-discovery-00 | Full | Address Discovery |
| FIPS 203 | Full | ML-KEM |
| FIPS 204 | Full | ML-DSA |
See docs/review.md for detailed RFC compliance analysis.
Performance
Connection Establishment
| Metric | Value |
|---|---|
| Handshake (PQC) | ~50ms typical |
| Address Discovery | <100ms |
| NAT Traversal | 200-500ms |
| PQC Overhead | ~8.7% |
Data Transfer (localhost)
| Metric | Value |
|---|---|
| Send Throughput | 267 Mbps |
| Protocol Efficiency | 96.5% |
| Protocol Overhead | 3.5% |
Scalability
| Connections | Memory | CPU |
|---|---|---|
| 100 | 56 KB | Minimal |
| 1,000 | 547 KB | Minimal |
| 5,000 | 2.7 MB | Linear |
System Requirements
- Rust: 1.85.0+ (Edition 2024)
- OS: Linux 3.10+, Windows 10+, macOS 10.15+
- Memory: 64MB minimum, 256MB recommended
- Network: UDP traffic on chosen port
Documentation
- API Guide - Complete API reference
- Symmetric P2P - Architecture explanation
- NAT Traversal Guide - NAT traversal details
- PQC Configuration - PQC tuning
- Architecture - System design
- Troubleshooting - Common issues
Examples
# Simple chat application
# Chat with peer discovery
# Statistics dashboard
Testing
# Run all tests
# Run with verbose output
# Specific test categories
# Run benchmarks
Contributing
Contributions welcome! Please see CONTRIBUTING.md.
# Development setup
License
Licensed under either of:
- Apache License, Version 2.0 (LICENSE-APACHE)
- MIT license (LICENSE-MIT)
at your option.
Acknowledgments
- Built on Quinn QUIC implementation
- NAT traversal per draft-seemann-quic-nat-traversal-02
- Developed for the Autonomi decentralized network
Security
For security vulnerabilities, please email security@autonomi.com rather than filing a public issue.