Skip to content

Commit 9049c78

Browse files
f remove offer_id from held htlc avail message context
1 parent 4c03b58 commit 9049c78

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
@@ -21,8 +21,6 @@ use crate::ln::channelmanager::PaymentId;
2121
use crate::ln::inbound_payment::{ExpandedKey, IV_LEN};
2222
use crate::offers::merkle::TlvRecord;
2323
use crate::offers::nonce::Nonce;
24-
#[cfg(async_payments)]
25-
use crate::offers::offer::OfferId;
2624
use crate::util::ser::Writeable;
2725

2826
use crate::prelude::*;
@@ -52,9 +50,10 @@ const PAYMENT_HASH_HMAC_INPUT: &[u8; 16] = &[7; 16];
5250
// HMAC input for `ReceiveTlvs`. The HMAC is used in `blinded_path::payment::PaymentContext`.
5351
const PAYMENT_TLVS_HMAC_INPUT: &[u8; 16] = &[8; 16];
5452

55-
// HMAC input for an `OfferId`. The HMAC is used in `AsyncPaymentsContext::InboundPayment`.
53+
// HMAC input used in `AsyncPaymentsContext::InboundPayment` to authenticate inbound
54+
// held_htlc_available onion messages.
5655
#[cfg(async_payments)]
57-
const ASYNC_PAYMENT_OFFER_ID_HMAC_INPUT: &[u8; 16] = &[9; 16];
56+
const ASYNC_PAYMENTS_HELD_HTLC_HMAC_INPUT: &[u8; 16] = &[9; 16];
5857

5958
/// Message metadata which possibly is derived from [`MetadataMaterial`] such that it can be
6059
/// verified.
@@ -491,15 +490,14 @@ pub(crate) fn verify_payment_tlvs(
491490
}
492491

493492
#[cfg(async_payments)]
494-
pub(crate) fn hmac_for_static_invoice_offer_id(
495-
offer_id: OfferId, nonce: Nonce, expanded_key: &ExpandedKey,
493+
pub(crate) fn hmac_for_held_htlc_available_context(
494+
nonce: Nonce, expanded_key: &ExpandedKey,
496495
) -> Hmac<Sha256> {
497-
const IV_BYTES: &[u8; IV_LEN] = b"LDK Offer ID ~~~";
496+
const IV_BYTES: &[u8; IV_LEN] = b"LDK Held HTLC OM";
498497
let mut hmac = expanded_key.hmac_for_offer();
499498
hmac.input(IV_BYTES);
500499
hmac.input(&nonce.0);
501-
hmac.input(ASYNC_PAYMENT_OFFER_ID_HMAC_INPUT);
502-
hmac.input(&offer_id.0);
500+
hmac.input(ASYNC_PAYMENTS_HELD_HTLC_HMAC_INPUT);
503501

504502
Hmac::from_engine(hmac)
505503
}

0 commit comments

Comments
 (0)