-
Notifications
You must be signed in to change notification settings - Fork 7
Switch to use rust-bitcoin's ChaCha20Poly1305
#42
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
Switch to use rust-bitcoin's ChaCha20Poly1305
#42
Conversation
We take a dependency on `rust-bitcoin`'s new-ish `chacha20poly1305` crate and check compatibility with our previous hand-rolled implementation (might be redundant, but better safe than sorry).
|
👋 Thanks for assigning @tankyleo as a reviewer! |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Basically LGTM, do we have fuzzers for these things?
|
🔔 1st Reminder Hey @tankyleo! This PR has been waiting for your review. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Addressed pending comments.
do we have fuzzers for these things?
Not yet, might be worth to add eventually.
|
🔔 2nd Reminder Hey @tankyleo! This PR has been waiting for your review. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Compat tests passed on my machine (cargo test check_chacha)
|
Addressed all pending comments, let me know if I can squash. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Took another pass good to squash thank you.
We delete our homebrewn implementation and switch to use the recently-published `chacha20_poly1305` crate.
cdd6577 to
c1e572e
Compare
Thanks! Squashed without further changes! |
| let (wrapped_nonce_bytes, wrapped_nonce_tag_bytes) = remaining.split_at(NONCE_LENGTH); | ||
|
|
||
| let mut wrapped_nonce_tag = [0u8; TAG_LENGTH]; | ||
| wrapped_nonce_tag.copy_from_slice(&wrapped_nonce_tag_bytes[..TAG_LENGTH]); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
a nit for the future: wrapped_nonce_tag_bytes is guaranteed to be of length TAG_LENGTH here
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
a nit for the future:
wrapped_nonce_tag_bytesis guaranteed to be of lengthTAG_LENGTHhere
Yes, I'm aware, belt-and-suspenders it is!
|
🔔 1st Reminder Hey @TheBlueMatt! This PR has been waiting for your review. |
|
Going ahead landing this |
Originally, we copied over our
ChaCha20Poly1305implementation from LDK. However, recentlyrust-bitcoinhas published thechacha20_poly1305crate, also including some performance improvements.Here, we switch over to use that new crate and drop our howmbrewn implementation (after adding a - probably unnecessary - testing step asserting that the two implementations are actually compatible).