Skip to content

Use symmetric crypto from rust-bitcoin primitives to prep for 0.7 - #13

Merged
DanGould merged 2 commits into
payjoin:mainfrom
DanGould:crypto-0.7
Sep 23, 2026
Merged

DanGould merged 2 commits into
payjoin:mainfrom
DanGould:crypto-0.7

Conversation

@DanGould

Copy link
Copy Markdown
Member

No description provided.

Replace the `hkdf` and `sha2` dependencies with a direct RFC 5869
implementation over `bitcoin_hashes`' HMAC, keeping SHA-256/384/512 support
and the existing public interface. bitcoin_hashes ships HMAC but no HKDF, so
Extract/Expand are written out here; Expand rejects lengths needing more than
255 blocks, which the `hkdf` crate enforced.

The RFC 5869 test vectors already in this module (appendix A.1-A.3) pass
unchanged, so derived key material is byte-identical.
With AES-GCM no longer selectable, `rh/aead.rs` needs no dispatch enum, so it is
rewritten directly onto the rust-bitcoin `chacha20-poly1305` crate. That crate is
detached and in-place, so seal appends the tag and open splits it off; `Aead::new`
now rejects the GCM algorithm ids rather than constructing an engine for them.

This drops `aead`, `aes-gcm`, and `chacha20poly1305`, leaving `bitcoin_hashes` and
`chacha20-poly1305` as the only crypto dependencies. `Error::Aead` loses its
`aead::Error` source and becomes a unit variant.

Both crates implement RFC 8439, so ciphertexts are unchanged: the QUIC
ChaCha20-Poly1305 test vector still passes. The two QUIC AES-GCM vectors are
dropped with the engines they exercised, and a test is added asserting that the
GCM ids are rejected.
@DanGould
DanGould requested a review from benalleng September 23, 2026 15:22
@DanGould DanGould mentioned this pull request Sep 23, 2026

@benalleng benalleng left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

TACK 9bb794c

Ran a full suite on rust-payjoin with this branch and bitcoin-hpke-0.20.0

@DanGould
DanGould merged commit 2bb822f into payjoin:main Sep 23, 2026
2 checks passed
@DanGould
DanGould deleted the crypto-0.7 branch September 23, 2026 15:55
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