Skip to content

Commit d3120ba

Browse files
Update onion message handler docs for new auth scheme
In the previous commit, we stopped authenticating incoming onion messages via an explicit nonce and hmac encoded in the message context, and entirely switched to authenticating via the new NodeSigner::get_receive_auth_key more or less included as AAD in the ChaCha20Poly1305 de/encoding for the messages. As such, the message handler docs need updating to describe the new authentication scheme.
1 parent e4b7bfe commit d3120ba

File tree

5 files changed

+22
-4
lines changed

5 files changed

+22
-4
lines changed

lightning/src/blinded_path/message.rs

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -608,10 +608,8 @@ impl_writeable_tlv_based_enum!(AsyncPaymentsContext,
608608
/// [`DNSSECProof`]: crate::onion_message::dns_resolution::DNSSECProof
609609
#[derive(Clone, Debug, Hash, PartialEq, Eq)]
610610
pub struct DNSResolverContext {
611-
/// A nonce which uniquely describes a DNS resolution.
612-
///
613-
/// When we receive a DNSSEC proof message, we should check that it was sent over the blinded
614-
/// path we included in the request by comparing a stored nonce with this one.
611+
/// A nonce which uniquely describes a DNS resolution, useful for looking up metadata about the
612+
/// request.
615613
pub nonce: [u8; 16],
616614
}
617615

lightning/src/onion_message/async_payments.rs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,11 @@ const RELEASE_HELD_HTLC_TLV_TYPE: u64 = 74;
2828

2929
/// A handler for an [`OnionMessage`] containing an async payments message as its payload.
3030
///
31+
/// The [`AsyncPaymentsContext`]s provided to each method was authenticated by the
32+
/// [`OnionMessenger`] as coming from a blinded path that we created.
33+
///
3134
/// [`OnionMessage`]: crate::ln::msgs::OnionMessage
35+
/// [`OnionMessenger`]: crate::onion_message::messenger::OnionMessenger
3236
pub trait AsyncPaymentsMessageHandler {
3337
/// Handle an [`OfferPathsRequest`] message. If we are a static invoice server and the message was
3438
/// sent over paths that we previously provided to an async recipient, an [`OfferPaths`] message

lightning/src/onion_message/dns_resolution.rs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,12 @@ pub trait DNSResolverMessageHandler {
6868

6969
/// Handle a [`DNSSECProof`] message (in response to a [`DNSSECQuery`] we presumably sent).
7070
///
71+
/// The provided [`DNSResolverContext`] was authenticated by the [`OnionMessenger`] as coming from
72+
/// a blinded path that we created.
73+
///
7174
/// With this, we should be able to validate the DNS record we requested.
75+
///
76+
/// [`OnionMessenger`]: crate::onion_message::messenger::OnionMessenger
7277
fn handle_dnssec_proof(&self, message: DNSSECProof, context: DNSResolverContext);
7378

7479
/// Gets the node feature flags which this handler itself supports. Useful for setting the

lightning/src/onion_message/messenger.rs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -906,6 +906,9 @@ pub trait CustomOnionMessageHandler {
906906

907907
/// Called with the custom message that was received, returning a response to send, if any.
908908
///
909+
/// If the provided `context` is `Some`, then the message was sent to a blinded path that we
910+
/// created and was authenticated as such by the [`OnionMessenger`].
911+
///
909912
/// The returned [`Self::CustomMessage`], if any, is enqueued to be sent by [`OnionMessenger`].
910913
fn handle_custom_message(
911914
&self, message: Self::CustomMessage, context: Option<Vec<u8>>, responder: Option<Responder>,

lightning/src/onion_message/offers.rs

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,14 @@ pub trait OffersMessageHandler {
4040
/// Handles the given message by either responding with an [`Bolt12Invoice`], sending a payment,
4141
/// or replying with an error.
4242
///
43+
/// If the provided [`OffersContext`] is `Some`, then the message was sent to a blinded path that we
44+
/// created and was authenticated as such by the [`OnionMessenger`]. There is one exception to
45+
/// this: [`OffersContext::InvoiceRequest`].
46+
///
47+
/// In order to support offers created prior to LDK 0.2, [`OffersContext::InvoiceRequest`]s are
48+
/// not authenticated by the [`OnionMessenger`]. It is the responsibility of message handling code
49+
/// to authenticate the provided [`OffersContext`] in this case.
50+
///
4351
/// The returned [`OffersMessage`], if any, is enqueued to be sent by [`OnionMessenger`].
4452
///
4553
/// [`OnionMessenger`]: crate::onion_message::messenger::OnionMessenger

0 commit comments

Comments
 (0)