Skip to content

Commit de630bd

Browse files
f remove offer_id from held htlc avail message context
1 parent f6dcfd5 commit de630bd

File tree

3 files changed

+9
-35
lines changed

3 files changed

+9
-35
lines changed

lightning/src/blinded_path/message.rs

Lines changed: 2 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,6 @@ use crate::ln::msgs::DecodeError;
2525
use crate::ln::onion_utils;
2626
use crate::types::payment::PaymentHash;
2727
use crate::offers::nonce::Nonce;
28-
use crate::offers::offer::OfferId;
2928
use crate::onion_message::packet::ControlTlvs;
3029
use crate::routing::gossip::{NodeId, ReadOnlyNetworkGraph};
3130
use crate::sign::{EntropySource, NodeSigner, Recipient};
@@ -408,12 +407,6 @@ pub enum AsyncPaymentsContext {
408407
///
409408
/// [`HeldHtlcAvailable`]: crate::onion_message::async_payments::HeldHtlcAvailable
410409
InboundPayment {
411-
/// The ID of the [`Offer`] that this [`BlindedMessagePath`]'s static invoice corresponds to.
412-
/// Useful to authenticate that this blinded path was created by us for asynchronously paying
413-
/// one of our offers.
414-
///
415-
/// [`Offer`]: crate::offers::offer::Offer
416-
offer_id: OfferId,
417410
/// A nonce used for authenticating that a [`HeldHtlcAvailable`] message is valid for a
418411
/// preceding static invoice.
419412
///
@@ -457,9 +450,8 @@ impl_writeable_tlv_based_enum!(AsyncPaymentsContext,
457450
(4, hmac, required),
458451
},
459452
(1, InboundPayment) => {
460-
(0, offer_id, required),
461-
(2, nonce, required),
462-
(4, hmac, required),
453+
(0, nonce, required),
454+
(2, hmac, required),
463455
},
464456
);
465457

lightning/src/offers/offer.rs

Lines changed: 0 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -98,13 +98,6 @@ use crate::offers::signer::{Metadata, MetadataMaterial, self};
9898
use crate::util::ser::{CursorReadable, HighZeroBytesDroppedBigSize, Readable, WithoutLength, Writeable, Writer};
9999
use crate::util::string::PrintableString;
100100

101-
#[cfg(async_payments)]
102-
use {
103-
bitcoin::hashes::hmac::Hmac,
104-
bitcoin::hashes::sha256::Hash as Sha256,
105-
crate::ln::inbound_payment,
106-
};
107-
108101
#[cfg(not(c_bindings))]
109102
use {
110103
crate::offers::invoice_request::InvoiceRequestBuilder,
@@ -141,15 +134,6 @@ impl OfferId {
141134
let tagged_hash = TaggedHash::from_tlv_stream(Self::ID_TAG, tlv_stream);
142135
Self(tagged_hash.to_bytes())
143136
}
144-
145-
/// Constructs an HMAC to include in [`AsyncPaymentsContext::InboundPayment`] for the offer id
146-
/// along with the given [`Nonce`].
147-
#[cfg(async_payments)]
148-
pub fn hmac_for_static_invoice(
149-
&self, nonce: Nonce, expanded_key: &inbound_payment::ExpandedKey,
150-
) -> Hmac<Sha256> {
151-
signer::hmac_for_static_invoice_offer_id(*self, nonce, expanded_key)
152-
}
153137
}
154138

155139
impl Borrow<[u8]> for OfferId {

lightning/src/offers/signer.rs

Lines changed: 7 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -20,8 +20,6 @@ use crate::ln::channelmanager::PaymentId;
2020
use crate::ln::inbound_payment::{ExpandedKey, IV_LEN};
2121
use crate::offers::merkle::TlvRecord;
2222
use crate::offers::nonce::Nonce;
23-
#[cfg(async_payments)]
24-
use crate::offers::offer::OfferId;
2523
use crate::util::ser::Writeable;
2624

2725
use crate::prelude::*;
@@ -48,9 +46,10 @@ const ASYNC_PAYMENT_ID_HMAC_INPUT: &[u8; 16] = &[6; 16];
4846
// HMAC input for a `PaymentHash`. The HMAC is used in `OffersContext::InboundPayment`.
4947
const PAYMENT_HASH_HMAC_INPUT: &[u8; 16] = &[7; 16];
5048

51-
// HMAC input for an `OfferId`. The HMAC is used in `AsyncPaymentsContext::InboundPayment`.
49+
// HMAC input used in `AsyncPaymentsContext::InboundPayment` to authenticate inbound
50+
// held_htlc_available onion messages.
5251
#[cfg(async_payments)]
53-
const ASYNC_PAYMENT_OFFER_ID_HMAC_INPUT: &[u8; 16] = &[8; 16];
52+
const ASYNC_PAYMENTS_HELD_HTLC_HMAC_INPUT: &[u8; 16] = &[8; 16];
5453

5554
/// Message metadata which possibly is derived from [`MetadataMaterial`] such that it can be
5655
/// verified.
@@ -467,15 +466,14 @@ fn hmac_for_payment_id(
467466
}
468467

469468
#[cfg(async_payments)]
470-
pub(crate) fn hmac_for_static_invoice_offer_id(
471-
offer_id: OfferId, nonce: Nonce, expanded_key: &ExpandedKey,
469+
pub(crate) fn hmac_for_held_htlc_available_context(
470+
nonce: Nonce, expanded_key: &ExpandedKey,
472471
) -> Hmac<Sha256> {
473-
const IV_BYTES: &[u8; IV_LEN] = b"LDK Offer ID ~~~";
472+
const IV_BYTES: &[u8; IV_LEN] = b"LDK Held HTLC OM";
474473
let mut hmac = expanded_key.hmac_for_offer();
475474
hmac.input(IV_BYTES);
476475
hmac.input(&nonce.0);
477-
hmac.input(ASYNC_PAYMENT_OFFER_ID_HMAC_INPUT);
478-
hmac.input(&offer_id.0);
476+
hmac.input(ASYNC_PAYMENTS_HELD_HTLC_HMAC_INPUT);
479477

480478
Hmac::from_engine(hmac)
481479
}

0 commit comments

Comments
 (0)