phantom-protocol
Post-quantum-secure L4/L6 universal transport framework in Rust.
phantom-protocol gives applications an authenticated, confidential,
post-quantum-secure byte pipe. It pairs a hybrid classical-plus-PQ handshake
(X25519 + ML-KEM-768 KEM, Ed25519 + ML-DSA-65 signatures — FIPS 203 / FIPS 204,
pure Rust) with a transport layer (TCP / WebSocket for sessions today; WASI and
embedded byte-stream framing; KCP / FakeTLS / multipath as experimental legs)
and adaptive fallback. Cross-language bindings via UniFFI (Python, Swift, Kotlin,
C); native wasm32 target; bare-metal EmbeddedLeg for no_std.
Pre-1.0 (
0.1.x). Wire format may break between minor versions; SemVer stabilizes at 1.0. The Rust crate isphantom-protocol; the import path isphantom_protocol.
Install
[]
= "0.1"
or cargo add phantom-protocol.
Highlights
- Hybrid post-quantum handshake — X25519 + ML-KEM-768 KEM, Ed25519 +
ML-DSA-65 signatures; both halves must verify. Pure-Rust RustCrypto
primitives (no C in the crypto path) — compiles on native, mobile, and
wasm32. - 0-RTT resumption — AEAD-sealed early-data (≤ 16 KiB) folded into the
single
ClientHello, one-shot anti-replay, best-effort 1-RTT fallback. - Mid-session rekey — HKDF ratchet with a per-stream sequence watermark that forces a rekey before any AEAD nonce can repeat.
- Per-stream replay protection — RFC 4303 §3.4.3 sliding-window bitmap, checked after AEAD verify.
- DoS-resistant handshake — stateless HMAC-SHA-256 cookie + adaptive blake3 proof-of-work.
- Observability — opt-in OpenTelemetry metrics + traces (
telemetry-otel), lock-free hot-path atomics. - FIPS posture — opt-in
fipsfeature swaps in an AWS-LC-FIPS substrate (ECDH-P-256, AES-256-GCM, HKDF-SHA256, CTR_DRBG) with power-on self-tests.
Minimal client / server
Server identity must be pinned — connect_with_transport requires a
HybridVerifyingKey; there is no skip path (a core security invariant).
use ;
use HybridVerifyingKey;
use TcpStream;
// (inside an async context — every call below is `.await?`)
// ── Server ──────────────────────────────────────────────────────────────
let listener = bind.await?;
let server_addr = listener.local_addr;
let pinned_key = listener.verifying_key_bytes; // share out-of-band
spawn;
// ── Client ──────────────────────────────────────────────────────────────
let stream = connect.await?;
let transport = new;
let key = from_bytes?;
let session = connect_with_transport;
session.send.await?;
let _reply = session.recv.await?;
Feature flags
| Feature | Default | Purpose |
|---|---|---|
std |
✅ | Standard "everything on" build (tokio, native transports). |
bindings |
✅ | UniFFI scaffolding (Python / Swift / Kotlin / C). |
compression-zstd |
✅ | zstd compression (lz4 is the always-on pure-Rust fallback). |
telemetry-otel |
— | OpenTelemetry metrics + traces pipeline. |
fips |
— | FIPS-140-3 substrate via AWS-LC-FIPS (native-only). |
embedded |
— | EmbeddedLeg over embedded-io-async (no_std + alloc). |
wasi-leg |
— | WasiLeg + WasiRuntime for wasm32-wasip2. |
no-std |
— | Bare-metal subset marker (pair with --no-default-features). |
Bare-metal: --no-default-features --features embedded,no-std.
WASI: --no-default-features --features std,wasi-leg.
Links
- Repository & full docs: https://github.com/snaart/phantom_protocol
- API docs: https://docs.rs/phantom-protocol
- Changelog: CHANGELOG.md
- Protocol spec:
docs/protocol/PROTOCOL.md
License
Licensed under the Apache License, Version 2.0.