Skip to content

Conversation

@tnull
Copy link
Contributor

@tnull tnull commented Sep 19, 2025

Originally, we copied over our ChaCha20Poly1305 implementation from LDK. However, recently rust-bitcoin has published the chacha20_poly1305 crate, 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).

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).
@ldk-reviews-bot
Copy link

ldk-reviews-bot commented Sep 19, 2025

👋 Thanks for assigning @tankyleo as a reviewer!
I'll wait for their review and will help manage the review process.
Once they submit their review, I'll check if a second reviewer would be helpful.

Copy link

@TheBlueMatt TheBlueMatt left a 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?

@ldk-reviews-bot
Copy link

🔔 1st Reminder

Hey @tankyleo! This PR has been waiting for your review.
Please take a look when you have a chance. If you're unable to review, please let us know so we can find another reviewer.

Copy link
Contributor Author

@tnull tnull left a 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.

@ldk-reviews-bot
Copy link

🔔 2nd Reminder

Hey @tankyleo! This PR has been waiting for your review.
Please take a look when you have a chance. If you're unable to review, please let us know so we can find another reviewer.

Copy link
Contributor

@tankyleo tankyleo left a 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)

@tnull
Copy link
Contributor Author

tnull commented Sep 24, 2025

Addressed all pending comments, let me know if I can squash.

@tnull tnull requested a review from tankyleo September 24, 2025 13:43
Copy link
Contributor

@tankyleo tankyleo left a 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.
@tnull tnull force-pushed the 2025-09-switch-to-rust-bitcoin-chacha20poly1305 branch from cdd6577 to c1e572e Compare September 25, 2025 10:02
@tnull
Copy link
Contributor Author

tnull commented Sep 25, 2025

Took another pass good to squash thank you.

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]);
Copy link
Contributor

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

Copy link
Contributor Author

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

Yes, I'm aware, belt-and-suspenders it is!

@ldk-reviews-bot
Copy link

🔔 1st Reminder

Hey @TheBlueMatt! This PR has been waiting for your review.
Please take a look when you have a chance. If you're unable to review, please let us know so we can find another reviewer.

@tnull
Copy link
Contributor Author

tnull commented Sep 27, 2025

Going ahead landing this

@tnull tnull merged commit 5067abc into lightningdevkit:main Sep 27, 2025
3 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.

4 participants