Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add HKDF to bitcoin_hashes #2644

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open

Conversation

nyonson
Copy link

@nyonson nyonson commented Apr 1, 2024

rustaceanrob and I have been working on a Rust-based BIP324 implementation over at https://github.com/rustaceanrob/bip324. We have been attempting to keep the code pretty clean in hopes of a future "soft landing" in rust-bitcoin. I figured the HKDF implementation is a small, self-contained chunk that might allow us to learn the ropes here first.

There was a mention in the discussion thread on BIP324 that the hashes interface may be changing in the near future. I am not sure the effect that would have on this implementation, but happy to work through any issues.

Closes #2551

@github-actions github-actions bot added the C-hashes PRs modifying the hashes crate label Apr 1, 2024
@coveralls
Copy link

coveralls commented Apr 1, 2024

Pull Request Test Coverage Report for Build 8853654989

Details

  • 111 of 114 (97.37%) changed or added relevant lines in 1 file are covered.
  • No unchanged relevant lines lost coverage.
  • Overall coverage increased (+0.07%) to 83.205%

Changes Missing Coverage Covered Lines Changed/Added Lines %
hashes/src/hkdf.rs 111 114 97.37%
Totals Coverage Status
Change from base Build 8849264030: 0.07%
Covered Lines: 19307
Relevant Lines: 23204

💛 - Coveralls

Copy link
Member

@tcharding tcharding left a comment

Choose a reason for hiding this comment

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

Code review only, I know nothing about HKDF and am not a cryptographer.

Code looks nice and clean, just a couple questions about the mutable parameter and potential for panics.

hashes/src/hkdf.rs Show resolved Hide resolved
Copy link
Member

@tcharding tcharding left a comment

Choose a reason for hiding this comment

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

ACK with the feature gate fixes! Thanks.

hashes/src/hkdf.rs Show resolved Hide resolved
hashes/src/hkdf.rs Show resolved Hide resolved
@tcharding
Copy link
Member

@nyonson just FYI we are in a feature freeze at the moment. This only touches hashes and that has been released already so this could go in but it might be easier to just wait a week or so before we consider merging this - @apoelstra will likely work this out, but just wanted to mention it.

tcharding
tcharding previously approved these changes Apr 3, 2024
Copy link
Member

@tcharding tcharding left a comment

Choose a reason for hiding this comment

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

ACK 7d9b21c

@tcharding
Copy link
Member

Hey @apoelstra bump please.

@apoelstra
Copy link
Member

ACK 7d9b21c but could you squash all these commits (or most of them) since they are largely part of the same logical change? Also some of these commits don't compile by themselves.

@tcharding
Copy link
Member

Woops, I probably should have noticed that. My bad.

@nyonson
Copy link
Author

nyonson commented Apr 21, 2024

ACK 7d9b21c but could you squash all these commits (or most of them) since they are largely part of the same logical change? Also some of these commits don't compile by themselves.

My bad. I crunched down the test ones since they weren't all that interesting.

apoelstra
apoelstra previously approved these changes Apr 22, 2024
Copy link
Member

@apoelstra apoelstra left a comment

Choose a reason for hiding this comment

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

ACK 2a9215d

hashes/src/hkdf.rs Outdated Show resolved Hide resolved
BIP324's peer to peer encryption protocol requires an HMAC-based extract
and expand key derivation function (HKDF). HKDFs were not part of many
bitcoin protocols before BIP324, but the hope is that the encrypted
protocol becomes the dominant standard justifying this implementation.
Copy link
Member

@apoelstra apoelstra left a comment

Choose a reason for hiding this comment

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

ACK 67e67c9

Copy link
Contributor

@storopoli storopoli left a comment

Choose a reason for hiding this comment

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

ACK 67e67c9

Copy link
Member

@tcharding tcharding left a comment

Choose a reason for hiding this comment

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

ACK 67e67c9

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
C-hashes PRs modifying the hashes crate
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Add HKDF to bitcoin_hashes
5 participants