Skip to content

Remove SHA384 and SHA512 - #7

Merged
DanGould merged 1 commit into
mainfrom
rm-sha-384-512
Sep 22, 2026
Merged

DanGould merged 1 commit into
mainfrom
rm-sha-384-512

Conversation

@DanGould

@DanGould DanGould commented Aug 14, 2024

Copy link
Copy Markdown
Member

Rebased onto main now that HKDF runs over bitcoin_hashes (#15).

Bitcoin HPKE apps don't use HKDF-SHA384 or HKDF-SHA512. DHKEM(secp256k1, HKDF-SHA256) is the only KEM here and rust-payjoin only instantiates HkdfSha256, so the two extra KDFs are maintenance surface with no users. bitcoin_hashes still ships both hashes, so adding them back is a Kdf impl each if anyone needs them.

What goes: the two Kdf impls and the Wycheproof HKDF-SHA384/512 vector files. The secp256k1 known-answer vectors only ever used kdf_id 1, so KAT coverage is unchanged. The changelog entry for the unreleased 0.20.0 is updated to match.

MAX_DIGEST_SIZE stays at the RFC 9180 bound of 64. Kdf is a public trait, and shrinking the constant would turn a downstream impl with a wider digest into a runtime panic in the key schedule. assert_output_size now checks the bound at monomorphization instead. A test-only HkdfSha512 keeps the generic Extract and Expand code exercised at a second block size, since every shipped KDF is now 32 bytes wide.

Disclosure: rebase and test cleanup done with Claude Code.

@DanGould
DanGould force-pushed the rm-sha-384-512 branch 2 times, most recently from b458e5f to 1fda5a5 Compare August 14, 2024 19:07
@DanGould
DanGould marked this pull request as ready for review September 22, 2026 16:06
@DanGould
DanGould requested a review from benalleng September 22, 2026 16:06
Bitcoin HPKE apps don't use them, although SHA512 is used in
BIP32 derivation. HKDF-SHA256 is the only KDF the crate exposes now,
and the Wycheproof HKDF-SHA384/512 vector files go with the impls.

MAX_DIGEST_SIZE stays at the RFC 9180 bound of 64: Kdf is a public
trait, and a downstream impl with a wider digest would otherwise
overflow the key-schedule buffers at runtime. assert_output_size now
checks that bound at monomorphization. A test-only HkdfSha512 keeps the
generic Extract and Expand code exercised at a second block size.

@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 f82bfc2

Ran a test suite in rust-payjoin utilizing this branch upstream

The expand_rejects_more_than_255_blocks test was a bit hard to follow when looking at it in the diff format but with no other context to confuse me I think it is fine.

Everything else is a pretty straightforward net delete, keeping hkdf-sha512 in tests seems logical enough testing against the different widths and covering MAX_DIGEST_SIZE better.

@DanGould
DanGould merged commit 6b55153 into main Sep 22, 2026
24 checks passed
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