A C++ implementation of HyperDHT -- wire-compatible with the JavaScript reference. Connect any device to the Hyperswarm P2P network without a Node.js runtime.
Two devices on different networks, behind NATs, find each other by public key and establish an encrypted channel. No servers, no port forwarding, no configuration.
- DHT peer discovery -- Kademlia routing table, iterative lookups, announcements
- NAT traversal -- UDP holepunching with 4 strategies (consistent, random, birthday paradox, blind relay)
- End-to-end encryption -- Noise IK handshake (Ed25519) + SecretStream (XChaCha20-Poly1305)
- Mutable/immutable storage -- signed key-value records on the DHT
- C FFI -- 90-function
extern "C"API for Python, Go, Rust, Swift, Kotlin - Wrappers included -- Python (
from hyperdht import HyperDHT, KeyPair), Rust (hyperdht+hyperdht-syscrates), Kotlin/JNI for Android
The JS HyperDHT requires Node.js (~30MB runtime). This implementation is a single shared library (~1-2MB stripped) that embeds anywhere: mobile apps, embedded devices, system daemons, game engines, or any language with C FFI.
Wire-compatible with JS hyperdht@6.29.1. Live-tested in both directions on the public network.
| Tests | 731 unit + 6 live, ASAN/UBSan clean |
| API parity | Wire-compatible with JS hyperdht@6.29.1; behavioural parity ~93% and tracked openly in docs/TODO.md (original audit) |
| Languages | C++ / C / Python / Rust / Kotlin (Swift, Go via the C API) |
| Platforms | Linux, macOS, Windows, Android, ESP32 |
nix develop && mkdir -p build && cd build && cmake .. -G Ninja && ninja && ctest -L unit
Without Nix: install cmake, ninja, libsodium, libuv, then the same cmake flow. Docker also works (docker build -t hyperdht .). On Windows, use vcpkg for the dependencies and MSVC — CI builds the static and shared variants on every push (.github/workflows/windows.yml). See BUILDING.md for full instructions (Linux, macOS, Windows, Docker, linking, troubleshooting).
⚠️ libuv 1.51.x required — do not build against libuv 1.52.0/1.52.1. libuv 1.52.0 has a UDPPOLLERRregression that silently wedges established connections on real NAT paths (via libudx's PMTU-probe socket). The flake pinsnixos-25.11(libuv 1.51) deliberately. Building onnixos-26.05/ libuv 1.52 requires the override innix/libuv-1.52-udp-pollerr.patch. Full write-up + upstream status + re-check checklist: docs/LIBUV-VERSION.md.
| Build instructions | Linux, macOS, Windows, Docker, Nix — deps, compile, link, troubleshoot |
| C API reference | 90 functions, opaque-pointer pattern, callback-based async |
| C++ API reference | RAII wrappers, error codes, single-threaded event loop |
| Rust wrapper | hyperdht-sys (bindgen) + safe hyperdht crate, async/await API |
| Python examples | Server, client, holesail tunnel, 22 wrapper tests |
| ESP32 guide | Build, flash, run HyperDHT on ESP32-S3 (echo server + client) |
| Android example | Kotlin/JNI wrapper with echo test app |
| Wire protocol spec | Reverse-engineered from JS, 12 sections |
| JS name mapping | Side-by-side: createServer -> create_server -> hyperdht_server_create |
| Worklist | Single source of truth: open parity findings, hardening, field diagnoses |
The public HyperDHT network (same nodes the JS ecosystem uses):
node1.hyperdht.org:49737
node2.hyperdht.org:49737
node3.hyperdht.org:49737
docs/TODO.md is the single source of truth for outstanding work — open JS-parity findings, hardening tasks and field diagnoses, each with the JS file:line it diverges from. Every network-behaviour change must be live-tested against a JS peer before landing.
LGPL-3.0 -- library changes must be shared; downstream apps can use any license.