Skip to content

Conversation

@Abeeujah
Copy link

closes #4316

This PR switches the ChaChaPoly encryption algorithm to the chacha20-poly1305 = "0.1.2" crate, the following impls have been modified

  • EncryptedOurPeerStorage
  • PeerChannelEncryptor

The chacha20-poly1305 dependency was only added because the issue description by @TheBlueMatt requested it be added, and also, thanks to @tnull for the reference implementation provided.

@ldk-reviews-bot
Copy link

ldk-reviews-bot commented Jan 29, 2026

👋 Thanks for assigning @TheBlueMatt 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
Collaborator

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

You should try to remove the existing chacha20poly1305rfc module entirely. Is there some limitations of the upstream implementation that prevented that?

@TheBlueMatt TheBlueMatt removed the request for review from valentinewallace January 29, 2026 18:15
@Abeeujah
Copy link
Author

@TheBlueMatt at the moment, streams.rs lightning/src/crypto/streams.rs still depends on it, I'm currently working on switching it to the chacha20-poly1305 crate as well.

Copy link
Collaborator

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

Looks like you still didn't manage to remove chacha20poly1305rfc.rs (and chacha20.rs and poly1305.rs)?

@ldk-reviews-bot
Copy link

👋 The first review has been submitted!

Do you think this PR is ready for a second reviewer? If so, click here to assign a second reviewer.

@Abeeujah Abeeujah requested a review from TheBlueMatt January 30, 2026 21:30
struct ChaChaDualPolyReader<'a, R: Read> {
chacha: &'a mut ChaCha20,
poly: &'a mut Poly1305,
poly_aad: &'a mut Poly1305,
Copy link
Collaborator

Choose a reason for hiding this comment

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

Nah, we definitely don't want to do the full poly1305 validation twice. We'll have to upstream a Clone for Poly1305, mind opening a PR upstream at https://github.com/rust-bitcoin/rust-bitcoin/?

Integrated the  crate across all modules (Router,
PeerStorage, Onion Utils, etc.) and removed the deprecated internal
implementation. Updated test vectors to align with the new 12-byte
nonce construction and ensured SCID encryption remains consistent.
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.

Switch to chacha20-poly1305 crate

3 participants