Skip to content

Commit d5570e5

Browse files
f remove to-be-deprecated auth from offer_paths_req reply path
1 parent 0d59fb8 commit d5570e5

File tree

4 files changed

+5
-45
lines changed

4 files changed

+5
-45
lines changed

lightning/src/blinded_path/message.rs

Lines changed: 1 addition & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -410,19 +410,6 @@ pub enum AsyncPaymentsContext {
410410
/// [`OfferPathsRequest`]: crate::onion_message::async_payments::OfferPathsRequest
411411
/// [`OfferPaths`]: crate::onion_message::async_payments::OfferPaths
412412
OfferPaths {
413-
/// A nonce used for authenticating that an [`OfferPaths`] message is valid for a preceding
414-
/// [`OfferPathsRequest`] that we sent as an async recipient.
415-
///
416-
/// [`OfferPathsRequest`]: crate::onion_message::async_payments::OfferPathsRequest
417-
/// [`OfferPaths`]: crate::onion_message::async_payments::OfferPaths
418-
nonce: Nonce,
419-
/// Authentication code for the [`OfferPaths`] message.
420-
///
421-
/// Prevents nodes from creating their own blinded path that terminates at our async recipient
422-
/// node and causing us to cache an unintended async receive offer.
423-
///
424-
/// [`OfferPaths`]: crate::onion_message::async_payments::OfferPaths
425-
hmac: Hmac<Sha256>,
426413
/// The time as duration since the Unix epoch at which this path expires and messages sent over
427414
/// it should be ignored.
428415
///
@@ -513,9 +500,7 @@ impl_writeable_tlv_based_enum!(AsyncPaymentsContext,
513500
(4, path_absolute_expiry, required),
514501
},
515502
(2, OfferPaths) => {
516-
(0, nonce, required),
517-
(2, hmac, required),
518-
(4, path_absolute_expiry, required),
503+
(0, path_absolute_expiry, required),
519504
},
520505
);
521506

lightning/src/ln/channelmanager.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5142,7 +5142,7 @@ where
51425142
#[cfg(async_payments)]
51435143
fn check_refresh_async_receive_offers(&self) {
51445144
let peers = self.get_peers_for_blinded_path();
5145-
match self.flow.check_refresh_async_receive_offers(peers, &*self.entropy_source) {
5145+
match self.flow.check_refresh_async_receive_offers(peers) {
51465146
Err(()) => {
51475147
log_error!(
51485148
self.logger,

lightning/src/offers/flow.rs

Lines changed: 3 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1132,18 +1132,14 @@ where
11321132
///
11331133
/// Errors if we failed to create blinded reply paths when sending an [`OfferPathsRequest`] message.
11341134
#[cfg(async_payments)]
1135-
pub(crate) fn check_refresh_async_receive_offers<ES: Deref>(
1136-
&self, peers: Vec<MessageForwardNode>, entropy: ES,
1137-
) -> Result<(), ()>
1138-
where
1139-
ES::Target: EntropySource,
1140-
{
1135+
pub(crate) fn check_refresh_async_receive_offers(
1136+
&self, peers: Vec<MessageForwardNode>,
1137+
) -> Result<(), ()> {
11411138
// Terminate early if this node does not intend to receive async payments.
11421139
if self.paths_to_static_invoice_server.is_empty() {
11431140
return Ok(());
11441141
}
11451142

1146-
let expanded_key = &self.inbound_payment_key;
11471143
let duration_since_epoch = self.duration_since_epoch();
11481144

11491145
// Update the cache to remove expired offers, and check to see whether we need new offers to be
@@ -1156,10 +1152,7 @@ where
11561152

11571153
// If we need new offers, send out offer paths request messages to the static invoice server.
11581154
if needs_new_offers {
1159-
let nonce = Nonce::from_entropy_source(&*entropy);
11601155
let context = MessageContext::AsyncPayments(AsyncPaymentsContext::OfferPaths {
1161-
nonce,
1162-
hmac: signer::hmac_for_offer_paths_context(nonce, expanded_key),
11631156
path_absolute_expiry: duration_since_epoch
11641157
.saturating_add(TEMP_REPLY_PATH_RELATIVE_EXPIRY),
11651158
});

lightning/src/offers/signer.rs

Lines changed: 0 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -55,11 +55,6 @@ const PAYMENT_TLVS_HMAC_INPUT: &[u8; 16] = &[8; 16];
5555
#[cfg(async_payments)]
5656
const ASYNC_PAYMENTS_HELD_HTLC_HMAC_INPUT: &[u8; 16] = &[9; 16];
5757

58-
// HMAC input used in `AsyncPaymentsContext::OfferPaths` to authenticate inbound offer_paths onion
59-
// messages.
60-
#[cfg(async_payments)]
61-
const ASYNC_PAYMENTS_OFFER_PATHS_INPUT: &[u8; 16] = &[10; 16];
62-
6358
/// Message metadata which possibly is derived from [`MetadataMaterial`] such that it can be
6459
/// verified.
6560
#[derive(Clone)]
@@ -575,16 +570,3 @@ pub(crate) fn verify_held_htlc_available_context(
575570
Err(())
576571
}
577572
}
578-
579-
#[cfg(async_payments)]
580-
pub(crate) fn hmac_for_offer_paths_context(
581-
nonce: Nonce, expanded_key: &ExpandedKey,
582-
) -> Hmac<Sha256> {
583-
const IV_BYTES: &[u8; IV_LEN] = b"LDK Offer Paths~";
584-
let mut hmac = expanded_key.hmac_for_offer();
585-
hmac.input(IV_BYTES);
586-
hmac.input(&nonce.0);
587-
hmac.input(ASYNC_PAYMENTS_OFFER_PATHS_INPUT);
588-
589-
Hmac::from_engine(hmac)
590-
}

0 commit comments

Comments
 (0)