Skip to content

Fix the build on modern Rust and stop advertising unimplementable AES-GCM suites - #8

Open
DanGould wants to merge 4 commits into
payjoin:mainfrom
DanGould:fix-build-and-aes-gcm-advertisement
Open

Fix the build on modern Rust and stop advertising unimplementable AES-GCM suites#8
DanGould wants to merge 4 commits into
payjoin:mainfrom
DanGould:fix-build-and-aes-gcm-advertisement

Conversation

@DanGould

@DanGould DanGould commented Aug 18, 2026

Copy link
Copy Markdown
Member

main does not build on current Rust, and once it does, 11 of the bitcoin-ohttp's 23 tests fail. CI had not run here which is how the fails survived. Three causes of failure get one commit each to fix + a CI change. Nothing here needs a new bitcoin-hpke release, so this can land now.

  • make ohttp compile`
  • AES-GCM was advertised but could not be used because bitcoin-hpke dropts its GCM schemes in 0.13.0 and the dispatch macro only ever pointed to ChaCha20Poly1305, so that'd always throw InvalidKeyType. Supported now wasys so which is enough for it to get pruned from the advertised config. decode now returns Unsupported for an unusable config instead of letting a ClientRequest::from_config get built and then throwing later.

CI

1.63 was red because it needed dep resolution #6, nss was referencing an already-removed Kem variant from bac8f2c and can't work without a secp256k1 DHKEM in NSS. nss should be removed in its own follow up imo.

Disclosure: co-authored by Claude Code.

@DanGould
DanGould force-pushed the fix-build-and-aes-gcm-advertisement branch from e02c1bb to 50d7ce2 Compare August 19, 2026 10:58
@DanGould
DanGould force-pushed the fix-build-and-aes-gcm-advertisement branch from 50d7ce2 to 99f24f5 Compare September 7, 2026 11:45
DanGould and others added 4 commits September 7, 2026 19:59
Run the rust-hpke backend on stable Rust and nothing else, so a red board
means a real regression.

The nss legs could never pass: NSS has no secp256k1 DHKEM, and the backend
has not compiled since the Kem enum was pruned to K256Sha256 in bac8f2c.
Whether to delete the backend is a separate decision; until then it stays out
of the matrix. The 1.63.0 legs die during dependency resolution, before any
code in this repository is compiled, because that cargo cannot parse modern
dependency manifests; the MSRV leg returns once martinthomson#6 settles what the MSRV is.

The NSS build prerequisites and clone steps go with the legs that used them,
as does the llvm-tools-preview component nothing here consumes.
`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()` makes
`strip_unsupported` prune 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.

`decode` also rejects a config whose suite list is empty after pruning, with
`Error::Unsupported`. Without that, a client handed a GCM-only config reached
`ClientRequest::from_config`, which selects `symmetric[0]`, and panicked on the
empty list where `main` returned `InvalidKeyType`. `decode_list` already skips
`Unsupported` entries, so a list containing such a config decodes to the usable
remainder. A test covers both paths. The example server no longer requests
AES-128-GCM, which it would only have had stripped.

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.

Also fixes two lints current clippy rejects under this crate's
`deny(warnings, clippy::pedantic)`: a redundant `continue` and non-inlined
format args.
@DanGould
DanGould force-pushed the fix-build-and-aes-gcm-advertisement branch from 99f24f5 to 57b6619 Compare September 7, 2026 12:03
@DanGould
DanGould marked this pull request as ready for review September 7, 2026 12:15
@DanGould
DanGould requested a review from spacebear21 September 8, 2026 09:47
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants