Curve and HPKE source research and implementation

This record distinguishes source reuse, implemented candidates and measured qualification. The implementation was authored on 2026-10-25. Root-owned workspace compilation and measurement receipts determine its actual validation status.

Selected code

Building block Selected source Concrete change
X25519 x25519-dalek 2.0.1 over curve25519-dalek 4.1.3 Caller-owned secret, checked zero-DH output; original encodings retained
Ed25519 signing prepared ed25519-dalek 2.2.0 fork Seed expansion/public derivation reused explicitly; native prepared secret retained
Ed25519 verification prepared curve25519-dalek 4.1.3 fork Native negative-A table reused; canonical decoded R compared projectively
Aggregate Ed25519 upstream Dalek batch implementation Explicit prime-subgroup construction policy, distinct from strict singles
DHKEM/HPKE Base HPKE 0.13.0 plus Showtime cached-recipient design Fixed suite, cached recipient PK, prepared public info, in-place AEAD
Labeled HKDF shared local hash crate Multipart extraction/expansion and reusable prepared HMAC states
Batched X25519 affine output narrow curve fork extension Caller scratch and shared final inversion; existing ladders unchanged

Published Dalek sources retain BSD-3-Clause licenses. The HPKE reference retains MIT/Apache-2.0 notices. Each vendor directory preserves published archive hashes, original patches, copied-file inventory and additional local patches. HPKE's provenance directory records the exact reference files. Importing these prior sources does not transfer their old benchmark qualification to this artifact.

The selected packages are historical pins. Current primary documentation on the research date listed curve25519-dalek5.0.0, x25519-dalek3.0.0, ed25519-dalek3.0.0 and hpke0.14.1. Moving the prepared forks to those majors is further work with fresh differential and target measurements, not a reason to relabel these pins as current upstream.

Preserved mathematical contracts

RFC 7748 defines the clamped scalar and masked/reduced Montgomery coordinate interpretation. The primitive accepts noncanonical representatives; checked agreement rejects zero shared output. DHKEM's context retains the original enc/recipient bytes, so equivalent coordinates do not imply identical derived KEM secrets.

The selected RFC 9180 suite uses the KEM and complete HPKE suite IDs independently. Labels separate DeriveKeyPair, DHKEM extraction, Base scheduling, encryption key, nonce and exporter. Base nonce mixing is big-endian and successful opens alone advance the receiver. Context types prevent implicit sender-state cloning. Exported independent AEAD has its own framed domain and caller-owned nonce contract.

Pure Ed25519 signs exact message bytes using SHA-512. Preparation binds the expanded scalar, nonce prefix and public key. Restoring an already reduced scalar must not clamp it again. Strict single verification accepts canonical, on-curve, non-small-order A/R and S<L, preserving the full uncofactored equation for mixed-order points. The cached table is for -A with positive k; substituting (-k mod L)A changes that policy.

Generic upstream batch verification reduces aggregate coefficients modulo L. PrimeOrderBatch therefore explicitly admits prime-subgroup A/R only. It is not an optimization silently substituted beneath strict singles. Batch transcript and multiscalar allocation are included in measured batch calls. Sequential prepared verification retains the exact single-item policy and every result.

Backend and page hypotheses

Compare serial32, serial64, fiat32 and fiat64 on wasm32 and wasm64 independently. The upstream backend documentation supports each serial/Fiat word-size choice. Intel SIMD is not a Wasm backend. The selected 32-bit field implementation accumulates widening products in u64; the 64-bit implementation uses u128. Target address width alone does not rank them. Preserve effective dependency cfg output with each installed artifact.

Prepared native public tables avoid repeated portable table decoding but retain more bytes than a compressed key. Existing fixed-base tables add read-only footprint. The inversion candidate stores three field elements per item and can use bounded tiles; it may trade inversion instructions for extra touched regions. Measure whole messages, actual accessed/dirty regions, stack, statics, allocator metadata and prepared-state placement. A smaller allocation count does not prove a lower charged-region count.

The optional shared-inversion implementation postpones only existing affine conversion. It masks zero denominators, preserves independent outputs, rejects all-zero DH per item and clears caller scratch. It requires fresh verification across all four field backends and negative/mixed batches. It has no current performance qualification.

Benchmarks and evidence boundaries

The curve registry covers key generation, direct/cached/prepared signing, preparation, validation, strict singles, sequential strict cohorts, prime-order aggregate batches and optional shared-inversion DH. distinct=false shares prepared signing/verifying state across the records where that API permits it. Optional Ed25519 contexts are separately owned Boxes: ordinary key/sign/verify fixtures reserve pointer-sized absent contexts rather than an unused native public table in every key row. Preparation cases allocate their result Box in setup and overwrite it during timing, preserving the allocation-free factory operation. Present prepared contexts retain their full actual table payloads. Batch cases report the cohort through operations_per_run, preventing an N² driver loop. Aggregate Ed25519 includes the temporary message-view array and upstream dynamic scratch.

The curve adapters distinguish ed25519.verify.batch-prime-order, which reuses the exact checked key/signature batch constructed in setup, from ed25519.verify.batch-prime-order.fresh. The fresh case collects raw keys/signatures/message views, constructs PrimeOrderBatch and verifies it inside each timed grouped call, including all canonical A/R/S, non-small-order and prime-subgroup checks and all collection, checked-state and upstream scratch allocation. A construction error remains an error in the retained result; it cannot masquerade as an expensive aggregate rejection. Invalid/mixed fixtures use well-formed wrong-key signatures so that construction passes and the aggregate equation executes. Fresh one-key cohorts vary messages by row index at the requested length; 100 normal-size records have distinct signatures. Empty/very-short message domains can necessarily repeat. Both cases report group length N; their costs are not interchangeable. Native parity tests cover 1/8/32/100/128/500 records, both key populations and all patterns; their execution and any installed-Wasm cost claim require the root owner's new test/artifact receipts.

The ordinary x25519.dh case retains a separate local secret for each record. The shared-inversion experiment instead has a matched x25519.dh.one-local-key.scalar-cohort control. Both use the same single local secret, exact peer bytes, output/validity buffers, reserved scratch allocation and checksum/check logic, and both report the full cohort as their group size. The scalar path performs an independent ordinary agreement per peer; it does not artificially access scratch that only the shared-inversion algorithm needs. Distinct inputs change peer keys in these matched cases, never the local key.

HPKE cases separate recipient construction, DHKEM encap/decap, sender/receiver setup, cached-key/prepared-info controls, complete one-shot messages, established contexts, export and exported independent AEAD. In-place cases include input buffer restoration. Session-open fixtures advance their matching sender in the untimed check after authenticated output validation. Invalid session inputs stay on the original unresolved sequence. Every record uses an independent ephemeral fixture IKM, including repeated-recipient-key cohorts.

Separate single-context cases sequence a whole cohort through one established sender or receiver and report one grouped invocation. Distinct inputs vary the messages within that one session. Ordered single-context opens explicitly admit valid fixtures only: a rejected packet does not advance the receiver, so later unrelated packets cannot retain the independent-record pattern semantics. The independent-context cases retain valid/invalid/mixed coverage. Cohort checks validate every scalar record and every grouped output, including repeated rounds.

Previously measured Showtime cached-PK query opens fell from 1,131,729,312 to 598,721,412 complete instructions for 100 independent 256-byte records. Its later serial32 change reduced 598,721,812 to 227,649,542, with unchanged reported page charges. Previously measured Motoko prepared 32-byte Ed25519 signing fell from 1,803,963 to 907,801 instructions and verification from 2,308,542 to 2,071,444, excluding preparation. These are exact historical artifacts, not measurements of this workspace or guarantees about the newly composed HKDF implementation.

The tests import 41 frozen signing answers and 72 mixed-order/mode verification answers with hashes, including all five pure RFC 8032 cases, independent OpenSSL answers and affine-oracle adversarial cases. RFC 7748 agreement/iteration values, RFC 9180 Base values and a separate upstream HPKE receiver/exporter differential test cover the protocol composition. The root owner's test and artifact receipts must state which native and installed target configurations were actually run.