feat(proto)!: Don't require a HKDF construction in HandshakeTokenKey#480
Merged
feat(proto)!: Don't require a HKDF construction in HandshakeTokenKey#480
HandshakeTokenKey#480Conversation
|
Documentation for this PR has been generated and is available at: https://n0-computer.github.io/noq/pr/480/docs/noq/ Last updated: 2026-03-06T12:21:47Z |
Performance Comparison Report
|
| Scenario | noq | upstream | Delta | CPU (avg/max) |
|---|---|---|---|---|
| large-single | 5750.3 Mbps | 7953.2 Mbps | -27.7% | 93.5% / 98.3% |
| medium-concurrent | 5956.3 Mbps | 7621.7 Mbps | -21.9% | 92.9% / 97.7% |
| medium-single | 4111.9 Mbps | 4469.5 Mbps | -8.0% | 95.5% / 109.0% |
| small-concurrent | 3764.1 Mbps | 5125.8 Mbps | -26.6% | 96.3% / 109.0% |
| small-single | 3539.5 Mbps | 4758.4 Mbps | -25.6% | 92.7% / 109.0% |
Netsim Benchmarks (network simulation)
| Condition | noq | upstream | Delta |
|---|---|---|---|
| ideal | 2933.0 Mbps | 3974.1 Mbps | -26.2% |
| lan | 776.3 Mbps | 808.2 Mbps | -3.9% |
| lossy | 69.8 Mbps | 55.9 Mbps | +25.0% |
| wan | 83.8 Mbps | 83.8 Mbps | ~0% |
Summary
noq is 22.6% slower on average
e86b3ea991dca4018e63db27f281e60a4e96d568 - artifacts
Raw Benchmarks (localhost)
| Scenario | noq | upstream | Delta | CPU (avg/max) |
|---|---|---|---|---|
| large-single | 5407.0 Mbps | 7993.9 Mbps | -32.4% | 94.4% / 99.8% |
| medium-concurrent | 5341.3 Mbps | 7905.3 Mbps | -32.4% | 91.7% / 96.8% |
| medium-single | 4214.9 Mbps | 4705.2 Mbps | -10.4% | 84.7% / 95.2% |
| small-concurrent | 3694.7 Mbps | 5238.9 Mbps | -29.5% | 93.1% / 100.0% |
| small-single | 3382.7 Mbps | 4719.1 Mbps | -28.3% | 97.2% / 134.0% |
Netsim Benchmarks (network simulation)
| Condition | noq | upstream | Delta |
|---|---|---|---|
| ideal | N/A | 3896.7 Mbps | N/A |
| lan | N/A | 810.3 Mbps | N/A |
| lossy | N/A | 69.8 Mbps | N/A |
| wan | N/A | 83.8 Mbps | N/A |
Summary
noq is 27.9% slower on average
flub
approved these changes
Mar 6, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
This is a pure refactor of the
HandshakeTokenKeytrait, this PR doesn't change any behavior.This essentially merges
trait AeadKey(with adjustments) intoHandshakeTokenKey.The
aead_from_hkdfconstruction can be computed insideAeadKey::openandAeadKey::seal, and this is always done together, so there's no need to do both things together.This is part of n0-computer/iroh#3978
Motivation
Merging these things in the
HandshakeTokenKeytrait reduces the amount of traits and makes it possible to implementHandshakeTokenKeywithout an HKDF construction, e.g. by using random nonces with XChaCha (which is completely safe and doesn't require weird nonce tricks).Breaking Changes
noq_proto::crypto::AeadKeytrait. It essentially was moved intonoq_proto::crypto::HandshakeTokenKey.sealandopen. They no longer require you to processadditional_data(AAD), because this is never used in Quinn.Notes & open questions
I intentionally kept this a pure refactor.
It's worth considering exchanging the cryptography used here with something that's not HKDF+AES-GCM with zero nonces, but that can be another PR.
My plan for now is to do the opinionated cryptography changes in iroh instead of in noq.