Skip to content

Expand standalone bench suite to mirror comparative.rs and add rust-hpke memory footprint to README - #10

Merged
nadimkobeissi merged 2 commits into
symbolicsoft:mainfrom
danieldia-dev:main
Jun 1, 2026
Merged

Expand standalone bench suite to mirror comparative.rs and add rust-hpke memory footprint to README#10
nadimkobeissi merged 2 commits into
symbolicsoft:mainfrom
danieldia-dev:main

Conversation

@danieldia-dev

Copy link
Copy Markdown
Contributor

This PR makes two improvements to the benchmark infrastructure:

  1. benches/bench.rs is rewritten to functionally serve as a standalone mirror of the hpke_ng members in comparative.rs. Group names and benchmark IDs now match exactly (e.g. kem/x25519/hpke_ng/generate, x25519_chacha20_seal_sweep/hpke_ng/64). The previous bench.rs used a flat monolithic structure (bench_kem, bench_setup, bench_seal_open, bench_export) with ad-hoc group names that did not align with comparative.rs. The rewrite switches OsRng to a seeded ChaCha20Rng (matching the entropy source in comparative.rs), splits into per-KEM and per-ciphersuite functions, and fills the following coverage gaps: p256 derive_key_pair and decap (previously missing); k256 all four ops (previously absent entirely); PQ KEM groups (kem/xwing, kem/mlkem768, kem/mlkem1024) and their setup counterparts under #[cfg(feature = "pq")]; AES-128 seal and open sweeps; context_open (seal + open), matching the lockstep design in comparative.rs; export lengths expanded from [32, 64, 128] to EXPORT_LENGTHS = [16, 32, 64, 128, 256]; and a roundtrip_1k end-to-end benchmark. bench.rs also adds hpke_ng/auth_encap and hpke_ng/auth_decap inside kem/x25519, which are not present in comparative.rs. criterion_group! / criterion_main! are split into classical_benches and pq_benches with cfg gates so --features pq controls which targets compile. The new suite compiles and runs under:
RUSTFLAGS="-C target-cpu=native" cargo bench --bench bench
RUSTFLAGS="-C target-cpu=native" cargo bench --bench bench --features pq
  1. The README performance section is updated to reflect the rust-hpke memory footprint data collected in the prior session. The memory table gains a rust-hpke column covering Context<_, _, ChaCha20Poly1305> (96 bytes), ExportOnly (184 bytes), Aes128Gcm (912 bytes), Aes256Gcm (1,168 bytes), and minimal release binary (430 KB), with a note explaining the AeadCtxS / AeadCtxR type equivalents, the KDF-dependent size growth, and why the ExportOnly row is larger in rust-hpke than in hpke-ng. Table column separators are also aligned throughout for readability.

@nadimkobeissi
nadimkobeissi merged commit a9cf1ee into symbolicsoft:main Jun 1, 2026
5 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.

2 participants