Fixed-suite Base HPKE

This no_std crate implements RFC 9180 Base HPKE with DHKEM(X25519, HKDF-SHA256), HKDF-SHA256 and ChaCha20Poly1305. Suite identifiers are 0x0020/0x0001/0x0003. Keys, exact input bytes, randomness, nonces and buffers stay with the caller. Base mode does not authenticate a sender. Use the preferred paths and dated best-pick report for installed qualification and complete preparation/output boundaries.

PreparedRecipient constructs and privately binds its secret and matching public bytes once. Repeated independent decapsulation reuses those public bytes, retaining the original remote encapsulation bytes in the KEM transcript. Raw secret import, RFC DeriveKeyPair from IKM and CSPRNG generation are separate APIs. No query clock or deterministic ambient RNG is used.

PreparedBaseInfo caches the public 65-byte Base key-schedule context for one immutable info value. The shared hash crate streams multipart labeled values without concatenation and holds reusable PRK HMAC states, erased on drop. Ephemeral secrets, raw DH results, extracted PRKs and temporary keys use owned zeroization. ChaCha20Poly1305 clears its owned key on drop. This does not prove erasure of every compiler temporary or caller-owned import.

Sender and receiver setup return distinct, non-cloneable contexts. Their nonce is the base nonce XOR the zero-padded big-endian u64 sequence, starting at 0. After 2^64 successful messages the context rejects further operations; this is an explicit limit below the suite's 96-bit nonce space. Authentication failures do not advance the receiver. All seal/open errors wipe the supplied body. Failed export bounds checks leave its output untouched.

Detached body and AAD lengths are checked before cipher processing or sequence changes. The pinned ChaCha backend admits bodies through 274,877,906,816 bytes, 64 bytes below RFC 8439's 274,877,906,880-byte limit: its stream wrapper excludes the last counter block. This narrower bound prevents an upstream infallible stream panic on a partially used final block. AAD byte length must fit u64. validate_aead_lengths accepts integer lengths for pure admission and boundary tests without allocating huge buffers. Every error path owns exactly one body wipe, including failed complete-operation setup; sequence state never advances on a failed seal/open.

Exporter state is independent of the message sequence. export is the RFC interface and permits up to 8,160 bytes. exported_aead is an explicitly separate application contract: its exporter context is cdk-rsx.exported-aead.v1\0 || u16be(context.len) || context. The resulting independent ChaCha20Poly1305 object requires caller-owned unique 12-byte nonces; use distinct contexts for directions and purposes. It is not HPKE Seal and does not provide replay admission or transport ordering.

The optional experimental-batch-inversion feature exposes caller-scratch cohorts in experimental. Each sender still derives an independent ephemeral key from its own supplied IKM, forms its exact KEM transcript and constructs its own non-cloneable sequence-zero context. Batched public generation shares one final Edwards-to-Montgomery inversion; independent DH ladders share a second final inversion. import_recipients_batch constructs matched recipient keys from raw secrets, and setup_receivers_batch accepts those checked keys or an explicit common epoch key. Each all-zero DH rejects only its own record.

All slice lengths are checked before caller buffers change. Secret-derived curve scratch is cleared before return; sender secret slots are also cleared. Scratch remains private and synchronous. Outputs and buffers are caller-owned, and the primitives allocate no memory. The experimental API keeps contexts, ephemeral keys and ordered nonce state independent. Installed costs and qualification belong to the exact benchmark/artifact receipts.

The opt-in x25519-simd128 feature adds fresh raw-input cohorts in simd128. It retains the existing constant-time fixed-base public derivation and combines it with the selected four-ladder/global-inversion X25519 agreement kernel. Workspace borrows caller-owned public, DH, validity and both curve scratch arrays; no allocation or earlier-call key preparation is hidden. Sender calls also borrow erased ephemeral-scalar storage. encap_with_ikm_batch, decap_batch, setup_senders_with_ikm_batch and setup_receivers_batch retain independent RFC transcripts, rejection results and sequence-zero contexts. See SIMD APIs, buffers and RFC semantics. The dated report separates complete DHKEM/HPKE measurements from standalone DH and records the selected artifact's validation.

Provenance and controls

The fixed-suite port follows the HPKE 0.13.0 transcript and Showtime's prepared recipient change. provenance/source.json records exact reference file hashes; the MIT and Apache licenses are retained beside it. It composes the current local curves and hash APIs rather than copying a generic protocol framework. The prepared-key association, all-zero check, exact KEM transcript and standard labels remain part of the contract.

HPKE 0.13.0 is an explicit historical optimization reference. HPKE 0.14.1 was the latest stable release when checked on 2026-10-25. It still derives the recipient public key per ordinary decapsulation. The dev dependency on0.13.0 supplies an independent upstream receiver/exporter control for this port.

Tests cover RFC 9180 Appendix A.2 Base values, deterministic DeriveKeyPair, DHKEM shared secret, ciphertexts, exporter values, sequence boundaries, exact-byte encapsulation aliases, low-order rejection, authentication failures, recovery, last-sequence behavior, huge-length preflight without allocation and the separate exported-AEAD domain. Dated source reviews and native gates remain separate evidence from the installed qualification linked above.