Skip to main content

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

Aspectv1 Detail
Connection modelFriend-based: both parties must explicitly add each other before communication is possible.
DHTTox-specific DHT with its own routing and lookup semantics.
NAT traversalICE/STUN/TURN via PJSIP/PJNATH libraries.
CryptoCurve25519 key exchange via libsodium.
Session extensionPseudoTCP over UDP for reliable data channels, with a separate file transfer API.
LanguageC (with wrappers for other languages).

Limitations That Drove the Rewrite

  1. 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.
  2. Tox DHT constraints: The inherited DHT was designed for human social graphs, not for general-purpose service discovery or value storage.
  3. No service discovery: There was no built-in mechanism for a node to announce capabilities and for others to discover them programmatically.
  4. Maintenance burden: Tracking upstream c-toxcore changes while maintaining Elastos-specific extensions became increasingly difficult.

v2: Current Architecture

Repositories:

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

Aspectv1 (Classic)v2 (Current)
Connection modelFriend-based (mutual add required)Service-oriented (any node can discover and connect)
DHTTox-specificCustom Kademlia (160-bit key space, k=8, α=3)
NAT traversalICE/STUN/TURN (external libraries)Active Proxy (built-in TCP relay with CryptoBox encryption)
Anti-spamNoneSHA-256 token-based system with difficulty mining
Service discoveryNot supportedANNOUNCE_PEER / FIND_PEER DHT operations
Value storageNot supportedSTORE_VALUE / FIND_VALUE for small records (≤ 2 KB)
ExtensibilityMonolithicAddon architecture (Active Proxy, DHT Proxy, custom addons)
IdentityCurve25519Ed25519 (signatures + identity) / X25519 (encryption)
LanguagesCC++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

v1 is deprecated

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 Patternv2 Equivalent
elastos_carrier_new()Node(Configuration) constructor
Friend add/accept flowDirect service discovery via DHT
ElaCarrier handleNode object
Session with ICEActive Proxy relay (automatic)
No service discoveryannounceService() / findService()

Repository Status

RepositoryStatus
Elastos.CarrierClassic.NativeDeprecated: v1 codebase, no active development.
Elastos.Carrier.NativeActive: Primary C++ implementation of v2.
Elastos.Carrier.JavaActive: Server-oriented Java implementation of v2.