throughput: fast ring ChaCha20-Poly1305 data-plane AEAD (~3.3×) #52
No reviewers
Labels
No labels
bug
documentation
duplicate
enhancement
good first issue
help wanted
invalid
question
wontfix
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set
Reference
femboy/yip!52
Loading…
Reference in a new issue
No description provided.
Delete branch "feat/throughput-fast-aead"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
What
Replaces the data-plane AEAD implementation:
yip_crypto::Session::seal/opennow usering's ChaCha20-Poly1305 keyed by snow's secretSplit()transport keys, instead of snow's slower RustCrypto transport path. Same 256-bit ChaCha20-Poly1305 cipher (CLAUDE.md-conformant), byte-identical wire, ~3.3× faster. snow is now used for the handshake only. Lever 2 of 3 for single-core 10-Gbit (cheap FEC ✓ → fast AEAD ✓ → AF_XDP/batched I/O).Why
Post-P+Q, AEAD seal (~2.1 µs) was the dominant single-core per-packet cost. A probe on the target VPS (Ryzen 9 3900X, 1 core, AVX2+AES-NI) showed
openssldoes asm ChaCha20-Poly1305 at ~0.73 µs — a ~3× implementation gap within the same cipher. So this is purely a faster impl: no cipher change, no security-model change, handshake untouched. (Post-quantum is a separate handshake-layer milestone; symmetric ChaCha20 is already quantum-safe.)How (A2, chosen by a spike)
A spike (Task 1) proved that
ringChaCha20-Poly1305 — using snow's extracteddangerously_get_raw_split()keys + the Noise nonce ([0,0,0,0] ++ counter.to_le_bytes(), empty AAD) — is byte-for-byte identical to snow'swrite_message, and ~4× faster, so it's wire-compatible with existing nodes.crates/yip-crypto/src/lib.rs—Sessionholds two directionalring::aead::LessSafeKeys;into_sessionextracts the secret Split() keys and role-maps them (is_initiator: k0=initiator-send/responder-recv).seal/openuse ring. Added no-allocseal_into/open_into.crates/yip-crypto/Cargo.toml— addring; snow gainsrisky-raw-split.bin/yipd/src/dataplane.rs— tx hot loop usesseal_into+mem::takeinto the retx buffer (2→1 alloc/packet, removes a per-packet clone).Keys come from the secret
Split()output — never the channel binding (the handshake hash isn't secret). Nonce uniqueness is guaranteed by the monotonic per-direction counter; the Noise handshake, replay window, and counter semantics are untouched.Results
aead_seal_1300: ~2.1 µs → 0.63 µs (~3.3×).Session::sealoutput == snow'swrite_messagefor both directions across counters (teeth-verified: a wrong nonce endianness or swapped key mapping makes it fail).yip-crypto18/18, workspace 351/351, clippy clean,#![forbid(unsafe_code)]intact (ring's SIMD is internal).Final whole-branch review (opus): READY TO MERGE — traced no nonce-reuse path (ARQ regenerates FEC over stored ciphertext, never re-encrypts) and no send/recv key mismatch (guarded by the both-directions KAT).
Notes
seal_bufis moved into the retx buffer on most packets, so it isn't reused across packets — still a net 2→1 alloc.Design docs
docs/superpowers/specs/2026-07-11-throughput-fast-aead-design.mddocs/superpowers/plans/2026-07-11-throughput-fast-aead.md🤖 Generated with Claude Code
https://claude.ai/code/session_01RVP6NnbDMAg1iTsMMTfL86