Skip to content

feat(proto)!: Don't require a HKDF construction in HandshakeTokenKey#480

Merged
matheus23 merged 4 commits intomainfrom
matheus23/change-handshake-token-key
Mar 6, 2026
Merged

feat(proto)!: Don't require a HKDF construction in HandshakeTokenKey#480
matheus23 merged 4 commits intomainfrom
matheus23/change-handshake-token-key

Conversation

@matheus23
Copy link
Copy Markdown
Member

Description

This is a pure refactor of the HandshakeTokenKey trait, this PR doesn't change any behavior.

This essentially merges trait AeadKey (with adjustments) into HandshakeTokenKey.

The aead_from_hkdf construction can be computed inside AeadKey::open and AeadKey::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 HandshakeTokenKey trait reduces the amount of traits and makes it possible to implement HandshakeTokenKey without an HKDF construction, e.g. by using random nonces with XChaCha (which is completely safe and doesn't require weird nonce tricks).

Breaking Changes

  • Removed the noq_proto::crypto::AeadKey trait. It essentially was moved into noq_proto::crypto::HandshakeTokenKey.
  • Adjusted the signatures of seal and open. They no longer require you to process additional_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.

@matheus23 matheus23 self-assigned this Mar 6, 2026
@github-actions
Copy link
Copy Markdown

github-actions bot commented Mar 6, 2026

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

@n0bot n0bot bot added this to iroh Mar 6, 2026
@github-project-automation github-project-automation bot moved this to 🚑 Needs Triage in iroh Mar 6, 2026
@github-actions
Copy link
Copy Markdown

github-actions bot commented Mar 6, 2026

Performance Comparison Report

c05364bf18a6ee09df317b3c6b25fb3343dba5e7 - artifacts

Raw Benchmarks (localhost)

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

@matheus23 matheus23 enabled auto-merge March 6, 2026 11:51
@matheus23 matheus23 added this pull request to the merge queue Mar 6, 2026
Merged via the queue into main with commit bb46490 Mar 6, 2026
35 checks passed
@matheus23 matheus23 deleted the matheus23/change-handshake-token-key branch March 6, 2026 12:41
@github-project-automation github-project-automation bot moved this from 🚑 Needs Triage to ✅ Done in iroh Mar 6, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: ✅ Done

Development

Successfully merging this pull request may close these issues.

2 participants