Fix the build on modern Rust and stop advertising unimplementable AES-GCM suites - #8
Draft
DanGould wants to merge 3 commits into
Draft
Fix the build on modern Rust and stop advertising unimplementable AES-GCM suites#8DanGould wants to merge 3 commits into
DanGould wants to merge 3 commits into
Conversation
`PrivateKey`'s Debug impl still bound `b` from `key_data()` after the body was changed to print "[REDACTED]", leaving it unused. With `#![deny(warnings)]` that is a hard error on current rustc, so the crate does not build on the CI matrix's `stable` leg. `PublicKey`'s Debug still uses `b` and is unchanged.
The AES-GCM symmetric suites were advertised but could never be used. bitcoin-hpke removed its AES-GCM schemes in 0.13.0, and `dispatch_hpkes_new!` only ever mapped ChaCha20Poly1305, so a peer that honoured the advertisement and selected AES-GCM got `Err(InvalidKeyType)`. `Config::supported()` returned true for it anyway, and the test constants listed it first — which is why 11 of this crate's own tests failed. Correcting `supported()` is enough: `strip_unsupported` then prunes the advertised KeyConfig automatically. The `Aead` enum keeps its GCM variants so other peers' configs still parse. `decode` built its probe config with `Aes128Gcm` on the grounds that "the KDF and AEAD doesn't matter here"; it does now, since the probe is checked against `supported()`, so it uses ChaCha20Poly1305. Two tests were stale from before the secp256k1 port and never passed: `derive_key_pair`'s expected config encoded a 32-byte X25519 key under KEM 0x0020, regenerated here for KEM 0x0016 with a 65-byte key; and `truncate_kdf_aead_list` hard-coded an offset that assumed the X25519 key size, so it now derives the offset from the encoding. The suite is green: 22 passed. Also fixes two lints current clippy rejects under this crate's `deny(warnings, clippy::pedantic)`: a redundant `continue` and non-inlined format args.
DanGould
force-pushed
the
fix-build-and-aes-gcm-advertisement
branch
from
August 19, 2026 10:58
e02c1bb to
50d7ce2
Compare
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.
maindoes not build on current Rust, and once it does, 11 of the crate's 23 tests fail. Two independent causes, one commit each. Neither needs a newbitcoin-hpkerelease, so this can land now.Fix build on modern Rust after key-material redaction
PrivateKey'sDebugimpl still bindsbfromkey_data()after the body changed to print[REDACTED], leaving it unused. This crate sets#![deny(warnings, clippy::pedantic)], so that is a hard error on current rustc.PublicKey'sDebugstill usesband is untouched. Introduced in e275713.Stop advertising the unimplementable AES-GCM suites
The AES-GCM symmetric suites were advertised but could never be used.
bitcoin-hpkeremoved its AES-GCM schemes in 0.13.0 anddispatch_hpkes_new!only ever mapped ChaCha20Poly1305, so a peer that honoured the advertisement and selected AES-GCM gotErr(InvalidKeyType).Config::supported()returned true for it regardless, and the test constants listed it first, which is why 11 of this crate's own tests failed.Correcting
supported()is enough.strip_unsupportedthen prunes the advertisedKeyConfigautomatically. TheAeadenum keeps its GCM variants so other peers' configs still parse.decodebuilt its probe config withAes128Gcmon the grounds that the KDF and AEAD did not matter there. They do now, since the probe is checked againstsupported(), so it uses ChaCha20Poly1305.Two tests were stale from before the secp256k1 port and had never passed:
derive_key_pair's expected config encoded a 32-byte X25519 key under KEM 0x0020, regenerated here for KEM 0x0016 with a 65-byte key; andtruncate_kdf_aead_listhard-coded an offset assuming the X25519 key size, so it now derives the offset from the encoding.This commit also clears two lints current clippy rejects under this crate's
deny(warnings, clippy::pedantic): a redundantcontinueand non-inlined format args.Behaviour change worth reviewing
Removing AES-GCM from the advertised set is wire-visible. A client selecting one of those suites previously got a runtime error; now it never sees them offered. Anything relying on the advertisement was already broken at use time, so this turns a runtime failure into an absent option rather than removing working functionality.
payjoin negotiates one suite, DHKEM(secp256k1) / HKDF-SHA256 / ChaCha20-Poly1305, so nothing on that path changes.
Verification
Against the published
bitcoin-hpke0.13.0, on current stable:Scoped to
-p bitcoin-ohttpdeliberately: a workspace-wide run still fails in the siblingbhttpcrate, which is a separate pre-existing problem tracked in #7 and is not a dependency of this crate.What this does not fix
The
1.63.0matrix leg fails before any of this crate's code is reached:That cargo cannot parse a modern dependency manifest, which no change here can address. It needs the MSRV decision in #6, and it fails identically on
main.The
nsslegs are untested locally; they need an NSS build.Disclosure: co-authored by Claude Code.