Repository navigation
Conversation
The array parameter decays to a pointer, so callers can supply fewer than 32 writable bytes without a compiler diagnostic. Take a fixed-size byte span and pass output containers directly so their sizes are checked at compile time.
Extract key setup into PrepareHMAC before reusing prepared HMAC state. Pass input key material as a byte span so callers can use their existing byte containers directly.
Check fixed outputs for all six BIP324 labels and interleaved reuse of the existing HKDF test vectors. Measure HKDF context creation, the six BIP324 expansions, and clearing together before reusing prepared HMAC states.
Each HKDF expansion hashes the same two HMAC key pads, costing two SHA256 compressions before hashing the label. Prepare those states once per HKDF context and replace the repeated hashing with a copy of the prepared HMAC state. Across BIP324's six expansions this saves ten SHA256 compressions, with identical derived bytes. Cleanse the temporary extracted secret after constructing the prepared state.
|
The following sections might be updated with supplementary metadata relevant to reviewers and maintainers. External sites
ReviewsSee the guideline and AI policy for information on the review process.
If your review is incorrectly listed, please copy-paste ConflictsNo conflicts as of last run. |
|
Concept ACK |
|
Concept ACK |
|
Code review ACK (read the diff, didn't build). The optimization is standard and correct: HKDF-Expand here uses the same PRK for all six expansions, so pre-absorbing the key pads once ( Two things I checked while reviewing:
The ~20% on connection setup is a nice win for a hot path. LGTM modulo a Tested ACK from someone who can run |

Problem: Setting up an encrypted connection derives six values with the same secret. Each HKDF expansion repeats two SHA256 compressions to hash the same HMAC key pads.
Fix: Hash the key pads once per HKDF context, then copy the prepared HMAC state for each expansion. The copy replaces two setup compressions, saving ten SHA256 compressions across the six outputs - the derived bytes stay identical. RFC 2104 section 4 describes this optimization:
Measurements: