Dependencies for Iroh Development: Complete Cargo.toml Guide
The iroh crate depends on 35+ direct dependencies including tokio for async runtime, noq for QUIC transport, ed25519-dalek for cryptography, and several internal workspace crates like iroh-base and iroh-relay, all declared in iroh/Cargo.toml.
The n0-computer/iroh repository provides a Rust implementation of a distributed networking stack for building peer-to-peer applications. Understanding the dependencies for iroh development is essential for contributors and downstream users who need to audit the supply chain or troubleshoot build issues. All direct dependencies are precisely declared in the main manifest at iroh/Cargo.toml, which serves as the canonical source for the core library.
Core Async Runtime and Utilities
The foundation of iroh's asynchronous architecture relies on the tokio ecosystem. According to iroh/Cargo.toml lines 54-59, the crate pins tokio to version 1.44.1 with features including io-util, macros, sync, and rt. Complementing this are tokio-stream at line 60 and tokio-util at line 61, which provide stream processing and additional I/O utilities.
For structured logging across async contexts, iroh uses tracing at line 62. The project also pulls in n0-future (L37) and n0-error (L38) from the n0 suite, which provide helper traits and error handling wrappers built on anyhow. Buffer management relies on bytes 1.11 (L26), while pin-project (L42) handles pinning utilities for complex futures.
Cryptographic and Security Dependencies
Security-critical functionality depends on several specialized crates with careful feature management. blake3 version 1.8.3 (L25) provides fast cryptographic hashing for content-addressed identifiers, configured with no default features to minimize compilation overhead. ed25519-dalek at line 31 (pinned to =3.0.0-rc.0) handles public-key cryptography with features for serde, rand_core, zeroize, and pkcs8.
For TLS operations, iroh integrates rustls 0.23.33 (L50) with default features disabled, alongside webpki-types (aliased as rustls-pki-types) at line 64 for X.509 type definitions. The ctutils crate (L27) provides constant-time operations to mitigate timing attacks, and data-encoding (L28) handles base-64 and base-32 encoding for keys and identifiers.
Networking and Transport Layer
The QUIC transport implementation depends on the noq ecosystem. Line 44 declares noq version 1.0.0 with rustls features, while lines 45-46 pull in noq-proto and noq-udp for protocol definitions and UDP socket abstractions respectively. rand 0.10 (L47) provides entropy for cryptographic keys and nonces.
Network monitoring capabilities come from netwatch (L40) for interface state detection, while ipnet (L33) handles IPv4/IPv6 subnet calculations. For unreliable network operations, backon (L24) provides retry utilities, and portable-atomic (L43) ensures atomic operations work on all targets including wasm. The optional portmapper dependency at line 78 enables UPnP/NAT-PMP for automatic port mapping.
Data Serialization and Collection Types
Serialization across the network relies on serde 1.0.219 (L51) with derive and rc features enabled. The derive_more crate at line 30 provides boilerplate-free trait implementations, while strum (L53) with the derive feature adds enum utilities like Display and FromStr.
Collection optimization comes from smallvec 1.11.1 (L52) for small-vector optimization and rustc-hash (L49) for fast hash maps used in internal caches. papaya 0.2.3 (L41) provides deterministic hashing utilities, and url 2.5 (L63) with serde features handles relay URL parsing.
Internal Workspace Dependencies
The iroh crate heavily relies on sibling crates within the same repository. Line 34 declares iroh-base 1.0.0 (path ../iroh-base) with features key and relay, providing core data structures for peer identity. iroh-dns at line 35 handles DNS resolution for peer discovery, while iroh-relay (L36) implements the relay server/client for NAT traversal with default features disabled.
Additional internal utilities include n0-watcher (L39) for filesystem watching during configuration hot-reloading. reqwest 0.13 (L48) with rustls-no-provider and stream features provides HTTP client capabilities for fetching discovery documents.
Platform-Specific and Optional Dependencies
For non-wasm targets, hickory-resolver 0.26.0 (L77) provides DNS resolution with default features disabled. The portmapper dependency at line 78 is optional and enhances peer-to-peer connectivity on native platforms.
WebAssembly support requires specific adaptations. Line 92 includes wasm-bindgen-futures 0.4 for bridging Rust futures to JavaScript promises. Time handling in browsers uses time 0.3 with the wasm-bindgen feature (L94-95), while getrandom 0.4 (L95-96) with feature wasm_js provides secure random number generation for wasm targets.
How to Use Iroh in Your Project
To use these dependencies in your own application, add iroh to your Cargo.toml:
[dependencies]
iroh = { git = "https://github.com/n0-computer/iroh", rev = "main" }
Then create an endpoint and connect to peers:
use iroh::endpoint::Endpoint;
use iroh::iroh_base::key::PublicKey;
use std::net::SocketAddr;
#[tokio::main]
async fn main() -> anyhow::Result<()> {
// Initialize endpoint with automatic key generation
let ep = Endpoint::default().await?;
// Connect using peer's public key
let remote_key = PublicKey::from_hex("ab...")?;
let remote_addr: SocketAddr = "127.0.0.1:4000".parse()?;
let conn = ep.connect(remote_key, remote_addr).await?;
println!("Connected to {}", conn.remote_id());
Ok(())
}
The Endpoint struct defined in iroh/src/endpoint.rs serves as the high-level entry point for all networking operations, utilizing the underlying tokio runtime and noq transport layers.
Summary
- The iroh core crate declares 35+ direct dependencies in
iroh/Cargo.toml, ranging from the tokio async runtime to specialized QUIC libraries like noq. - Cryptographic security relies on blake3, ed25519-dalek, and rustls, with careful feature flag management to minimize attack surface and compilation time.
- Internal workspace crates (iroh-base, iroh-dns, iroh-relay) provide domain-specific functionality for peer identity, discovery, and NAT traversal.
- Platform-specific dependencies enable WebAssembly support via wasm-bindgen-futures and getrandom, while optional crates like portmapper enhance connectivity on native platforms.
- All dependency versions are precisely pinned in the manifest, with specific features enabled only when necessary to control binary size and build duration.
Frequently Asked Questions
What is the minimum Rust version required to compile iroh?
The source code does not specify a minimum Rust version (MSRV) in the provided analysis, but dependencies like tokio 1.44 and rustls 0.23 typically require Rust 1.70 or later. Check the latest Cargo.toml in the n0-computer/iroh repository for the current MSRV declaration in the rust-version field.
Does iroh require OpenSSL for TLS connections?
No. According to iroh/Cargo.toml line 50, iroh uses rustls 0.23.33 with default features disabled, which provides a pure-Rust TLS implementation. The crate explicitly avoids OpenSSL dependencies, making builds more portable and easier to cross-compile to targets like WebAssembly.
Can I use iroh in a WebAssembly environment?
Yes. The crate includes specific dependencies for wasm targets: wasm-bindgen-futures (L92), time with wasm-bindgen features (L94-95), and getrandom with wasm_js feature (L95-96). However, some networking features like hickory-resolver and portmapper are only available on native targets, as indicated by their conditional compilation flags in the manifest.
Why does iroh use both blake3 and ed25519-dalek?
blake3 (L25) provides fast cryptographic hashing for content-addressed identifiers and data integrity checks, configured for high-performance hashing of large data streams. ed25519-dalek (L31) handles public-key cryptography for peer identity and connection authentication. This separation allows optimized performance for different cryptographic operations—cryptographic hashing versus digital signatures—while maintaining clear security boundaries in the codebase.
Have a question about this repo?
These articles cover the highlights, but your codebase questions are specific. Give your agent direct access to the source. Share this with your agent to get started:
curl -s "https://instagit.com/install.md" Maintain an open-source project? Get it listed too →