Skip to content

Conversation

erickcestari
Copy link
Contributor

After running differential fuzzing on the parsing of init Lightning messages between c-lightning and rust-lightning, I found that rust-lightning parses and displays OnionV3 addresses incorrectly.

Tor v3 addresses are base32 of 35 bytes laid out as:
[32-byte ed25519 pubkey][2-byte checksum big-endian][1-byte version]

see: https://spec.torproject.org/rend-spec/encoding-onion-addresses.html

  • Parsing now slices 0..32 = pubkey, 32..34 = checksum (BE), 34 = version.
  • Display now appends pubkey + checksum + version and lowercases base32.
  • Adds/updates test vector accordingly.

@ldk-reviews-bot
Copy link

ldk-reviews-bot commented Sep 18, 2025

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

codecov bot commented Sep 18, 2025

Codecov Report

❌ Patch coverage is 90.90909% with 3 lines in your changes missing coverage. Please review.
✅ Project coverage is 88.61%. Comparing base (cd85a80) to head (f9fc879).
⚠️ Report is 30 commits behind head on main.

Files with missing lines Patch % Lines
lightning/src/ln/msgs.rs 90.90% 2 Missing and 1 partial ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main    #4090      +/-   ##
==========================================
+ Coverage   88.60%   88.61%   +0.01%     
==========================================
  Files         176      176              
  Lines      132070   132130      +60     
  Branches   132070   132130      +60     
==========================================
+ Hits       117015   117082      +67     
+ Misses      12386    12378       -8     
- Partials     2669     2670       +1     
Flag Coverage Δ
fuzzing 21.92% <0.00%> (-0.02%) ⬇️
tests 88.44% <90.90%> (+0.01%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

Copy link
Contributor

@wpaulino wpaulino left a comment

Choose a reason for hiding this comment

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

Thanks! LGTM.

Could be worth extending the test to do a round-trip on the string to parsed address back to string -- this would've caught the uppercase issue. Could also add an assert on the version to be the default (3).

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

Tor v3 addresses are base32 of 35 bytes laid out as:
  [32-byte ed25519 pubkey][2-byte checksum big-endian][1-byte version]

see: https://spec.torproject.org/rend-spec/encoding-onion-addresses.html

* Parsing now slices 0..32 = pubkey, 32..34 = checksum (BE), 34 = version.
* Display now appends pubkey + checksum + version and lowercases base32.
* Adds/updates test vector accordingly.
@erickcestari
Copy link
Contributor Author

Thanks! LGTM.

Could be worth extending the test to do a round-trip on the string to parsed address back to string -- this would've caught the uppercase issue. Could also add an assert on the version to be the default (3).

Updated!

@ldk-reviews-bot
Copy link

🔔 1st Reminder

Hey @wpaulino! 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 tnull self-requested a review September 22, 2025 10:28
Copy link
Contributor

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

LGTM

@wpaulino wpaulino merged commit e82ef2c into lightningdevkit:main Sep 22, 2025
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.

4 participants