Carrier v1 to v2 Evolution
Carrier has gone through two major architectural generations. Understanding the differences is important for anyone maintaining legacy integrations or evaluating the current stack.
v1: Classic (Deprecated)
Repository: Elastos.CarrierClassic.Native (C)
Carrier v1 was built on a fork of c-toxcore, the open-source library behind the Tox encrypted messenger. It inherited Tox's design philosophy and protocol stack.
Architecture
┌─────────────────────────────────────────┐
│ Application Layer │
│ (Elastos apps, dApps, Essentials) │
└──────────────────┬──────────────────────┘
│
┌──────────────────▼──────────────────────┐
│ Session Extension Layer │
│ ICE / PseudoTCP / File Transfer │
└──────────────────┬──────────────────────┘
│
┌──────────────────▼──────────────────────┐
│ c-toxcore (forked) │
│ Tox DHT │ Friend Graph │ Messaging │
└──────────────────┬──────────────────────┘
│
┌──────────────────▼──────────────────────┐
│ Crypto / Transport │
│ Curve25519 (libsodium) │ UDP │
│ ICE / STUN / TURN (PJSIP/PJNATH) │
└─────────────────────────────────────────┘
Key Characteristics
| Aspect | v1 Detail |
|---|---|
| Connection model | Friend-based: both parties must explicitly add each other before communication is possible. |
| DHT | Tox-specific DHT with its own routing and lookup semantics. |
| NAT traversal | ICE/STUN/TURN via PJSIP/PJNATH libraries. |
| Crypto | Curve25519 key exchange via libsodium. |
| Session extension | PseudoTCP over UDP for reliable data channels, with a separate file transfer API. |
| Language | C (with wrappers for other languages). |
Limitations That Drove the Rewrite
- Mutual friend-add requirement: Both nodes had to complete a friend-request handshake before any data exchange. This made machine-to-machine and service-oriented use cases awkward.
- Tox DHT constraints: The inherited DHT was designed for human social graphs, not for general-purpose service discovery or value storage.
- No service discovery: There was no built-in mechanism for a node to announce capabilities and for others to discover them programmatically.
- Maintenance burden: Tracking upstream c-toxcore changes while maintaining Elastos-specific extensions became increasingly difficult.
v2: Current Architecture
Repositories:
Elastos.Carrier.Native(C++17)Elastos.Carrier.Java(Java)
Carrier v2 is a ground-up rebuild that replaces every layer of the v1 stack with purpose-built components.
Architecture
┌─────────────────────────────────────────┐
│ Application Layer │
└──────────────────┬──────────────────────┘
│
┌──────────────────▼──────────────────────┐
│ Addons / Services │
│ Active Proxy │ DHT Proxy │ Extensible │
└──────────────────┬──────────────────────┘
│
┌──────────────────▼──────────────────────┐
│ Core DHT Layer (Custom Kademlia) │
│ Routing Table │ Value/Peer Storage │
│ Token Manager │ RPC │ Task Manager │
└──────────────────┬──────────────────────┘
│
┌──────────────────▼──────────────────────┐
│ Crypto / Transport │
│ Ed25519 │ X25519 │ CryptoBox (NaCl) │
│ SHA-256 │ UDP (DHT) │ TCP (Proxy) │
└─────────────────────────────────────────┘
Key Improvements Over v1
| Aspect | v1 (Classic) | v2 (Current) |
|---|---|---|
| Connection model | Friend-based (mutual add required) | Service-oriented (any node can discover and connect) |
| DHT | Tox-specific | Custom Kademlia (160-bit key space, k=8, α=3) |
| NAT traversal | ICE/STUN/TURN (external libraries) | Active Proxy (built-in TCP relay with CryptoBox encryption) |
| Anti-spam | None | SHA-256 token-based system with difficulty mining |
| Service discovery | Not supported | ANNOUNCE_PEER / FIND_PEER DHT operations |
| Value storage | Not supported | STORE_VALUE / FIND_VALUE for small records (≤ 2 KB) |
| Extensibility | Monolithic | Addon architecture (Active Proxy, DHT Proxy, custom addons) |
| Identity | Curve25519 | Ed25519 (signatures + identity) / X25519 (encryption) |
| Languages | C | C++17 (native), Java (server) |
Design Decisions
Service-oriented, not friend-based: v2 treats the network as a fabric of services. Any node can announce capabilities (ANNOUNCE_PEER) and any node can discover them (FIND_PEER). There is no social-graph prerequisite for communication.
Built-in relay instead of external ICE: Rather than depending on third-party STUN/TURN infrastructure, v2 includes Active Proxy as a first-class addon. Relays authenticate via Carrier IDs and forward only ciphertext.
Token-based abuse resistance: The SHA-256 token system with difficulty-based mining makes DHT pollution expensive without requiring a central authority or reputation service.
Dual-implementation strategy: The C++ native implementation targets performance-sensitive environments (mobile, desktop, embedded). The Java implementation targets server workloads and uses CBOR encoding (vs. JSON in C++) and Jetty for HTTP where applicable.
Migration
Carrier v1 (Classic) is deprecated and should not be used for new development. All new projects should build against the v2 APIs.
What Changes for Developers
| v1 Pattern | v2 Equivalent |
|---|---|
elastos_carrier_new() | Node(Configuration) constructor |
| Friend add/accept flow | Direct service discovery via DHT |
ElaCarrier handle | Node object |
| Session with ICE | Active Proxy relay (automatic) |
| No service discovery | announceService() / findService() |
Repository Status
| Repository | Status |
|---|---|
Elastos.CarrierClassic.Native | Deprecated: v1 codebase, no active development. |
Elastos.Carrier.Native | Active: Primary C++ implementation of v2. |
Elastos.Carrier.Java | Active: Server-oriented Java implementation of v2. |