Skip to content

smite: add node_announcement codec#78

Merged
morehouse merged 2 commits into
masterfrom
node_announcement
May 20, 2026
Merged

smite: add node_announcement codec#78
morehouse merged 2 commits into
masterfrom
node_announcement

Conversation

@morehouse
Copy link
Copy Markdown
Owner

@morehouse morehouse commented May 15, 2026

The first commit implements the standard codec, and the second commit adds the sign and verify methods we'll want for fuzzing.

Ref: #71

Comment thread smite/src/bolt/node_announcement.rs Outdated
Comment on lines +137 to +138
assert_eq!(original, decoded);
}
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

nit: just for the e2e test of the actual usage of the message

Suggested change
assert_eq!(original, decoded);
}
assert_eq!(original, decoded);
assert!(decoded.verify());
}

Copy link
Copy Markdown
Owner Author

Choose a reason for hiding this comment

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

Currently roundtrip tests that original == decoded. The verify_succeeds_after_sign test below ensures that original.verify() is true. So if both pass, we already know decoded.verify() is true.

I mildly prefer to have the tests separated like they currently are.

@morehouse
Copy link
Copy Markdown
Owner Author

Added another commit 25acf4e that includes trailing message bytes in the signature, as required by the spec:

https://github.com/lightning/bolts/blob/aff897f8f6ac0a7ba071b3b61fede7dc813be0b5/07-routing-gossip.md?plain=1#L362-L364

This is important in case an implementation eventually adds an extension to the node_announcement message.

Copy link
Copy Markdown
Contributor

@ekzyis ekzyis left a comment

Choose a reason for hiding this comment

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

LGTM, just one question: What about requirements for addresses like:

[The origin node] MUST place address descriptors in ascending order.

[The receiving node] SHOULD ignore the first address descriptor that does NOT match the types defined above.

Are they not relevant for fuzzing (yet)?

@morehouse
Copy link
Copy Markdown
Owner Author

LGTM, just one question: What about requirements for addresses like:

[The origin node] MUST place address descriptors in ascending order.

[The receiving node] SHOULD ignore the first address descriptor that does NOT match the types defined above.

Are they not relevant for fuzzing (yet)?

On the receiving side, we currently do not parse the address descriptors at all, we just save the bytes. For the forseeable future, I don't think we can gain much from extracting those addresses anyway.

On the sending side, we currently just let the fuzzer pick arbitrary bytes. In the future we could add a new IR type if the fuzzer needs some help to exercise the address parsing logic, or if our announcements are all getting rejected due to invalid descriptors.

Copy link
Copy Markdown
Contributor

@NishantBansal2003 NishantBansal2003 left a comment

Choose a reason for hiding this comment

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

LGTM 👍

Added another commit 25acf4e that includes trailing message bytes in the signature, as required by the spec:

https://github.com/lightning/bolts/blob/aff897f8f6ac0a7ba071b3b61fede7dc813be0b5/07-routing-gossip.md?plain=1#L362-L364

This is important in case an implementation eventually adds an extension to the node_announcement message.

In the future, any added fields will likely be optional for forward compatibility, so outbound signature verification should still pass, though inbound messages could cause issues. I was thinking of adding an assert that this extra field is empty, so future additions are caught explicitly, but I don’t think it adds much value. The current approach achieves the desired behavior well enough for now

morehouse added 2 commits May 20, 2026 18:06
These methods will be needed to correctly sign node_announcement
messages we create and to verify signatures provided by a target.
@morehouse morehouse force-pushed the node_announcement branch from 25acf4e to a0bd0d6 Compare May 20, 2026 23:07
@morehouse morehouse merged commit 099c6cb into master May 20, 2026
5 checks passed
@morehouse morehouse deleted the node_announcement branch May 20, 2026 23:11
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.

3 participants