Skip to content

Commit 611b221

Browse files
committed
f - HMAC entire ReceiveTlvs
1 parent c93e81f commit 611b221

File tree

2 files changed

+14
-14
lines changed

2 files changed

+14
-14
lines changed

lightning/src/ln/channelmanager.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -477,17 +477,17 @@ impl Verification for PaymentHash {
477477
}
478478
}
479479

480-
impl Verification for PaymentContext {
480+
impl Verification for ReceiveTlvs {
481481
fn hmac_for_offer_payment(
482482
&self, nonce: Nonce, expanded_key: &inbound_payment::ExpandedKey,
483483
) -> Hmac<Sha256> {
484-
signer::hmac_for_payment_context(self, nonce, expanded_key)
484+
signer::hmac_for_payment_tlvs(self, nonce, expanded_key)
485485
}
486486

487487
fn verify_for_offer_payment(
488488
&self, hmac: Hmac<Sha256>, nonce: Nonce, expanded_key: &inbound_payment::ExpandedKey,
489489
) -> Result<(), ()> {
490-
signer::verify_payment_context(self, hmac, nonce, expanded_key)
490+
signer::verify_payment_tlvs(self, hmac, nonce, expanded_key)
491491
}
492492
}
493493

lightning/src/offers/signer.rs

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ use bitcoin::hashes::sha256::Hash as Sha256;
1616
use bitcoin::secp256k1::{Keypair, PublicKey, Secp256k1, SecretKey, self};
1717
use types::payment::PaymentHash;
1818
use core::fmt;
19-
use crate::blinded_path::payment::PaymentContext;
19+
use crate::blinded_path::payment::ReceiveTlvs;
2020
use crate::ln::channelmanager::PaymentId;
2121
use crate::ln::inbound_payment::{ExpandedKey, IV_LEN};
2222
use crate::offers::merkle::TlvRecord;
@@ -47,8 +47,8 @@ const ASYNC_PAYMENT_ID_HMAC_INPUT: &[u8; 16] = &[6; 16];
4747
// HMAC input for a `PaymentHash`. The HMAC is used in `OffersContext::InboundPayment`.
4848
const PAYMENT_HASH_HMAC_INPUT: &[u8; 16] = &[7; 16];
4949

50-
// HMAC input for a `PaymentContext`. The HMAC is used in `blinded_path::payment::ReceiveTlvs`.
51-
const PAYMENT_CONTEXT_HMAC_INPUT: &[u8; 16] = &[8; 16];
50+
// HMAC input for `ReceiveTlvs`. The HMAC is used in `blinded_path::payment::PaymentContext`.
51+
const PAYMENT_TLVS_HMAC_INPUT: &[u8; 16] = &[8; 16];
5252

5353
/// Message metadata which possibly is derived from [`MetadataMaterial`] such that it can be
5454
/// verified.
@@ -464,21 +464,21 @@ fn hmac_for_payment_id(
464464
Hmac::from_engine(hmac)
465465
}
466466

467-
pub(crate) fn hmac_for_payment_context(
468-
payment_context: &PaymentContext, nonce: Nonce, expanded_key: &ExpandedKey,
467+
pub(crate) fn hmac_for_payment_tlvs(
468+
receive_tlvs: &ReceiveTlvs, nonce: Nonce, expanded_key: &ExpandedKey,
469469
) -> Hmac<Sha256> {
470-
const IV_BYTES: &[u8; IV_LEN] = b"LDK Payment ~~~~";
470+
const IV_BYTES: &[u8; IV_LEN] = b"LDK Payment TLVs";
471471
let mut hmac = expanded_key.hmac_for_offer();
472472
hmac.input(IV_BYTES);
473473
hmac.input(&nonce.0);
474-
hmac.input(PAYMENT_CONTEXT_HMAC_INPUT);
475-
payment_context.write(&mut hmac).unwrap();
474+
hmac.input(PAYMENT_TLVS_HMAC_INPUT);
475+
receive_tlvs.write(&mut hmac).unwrap();
476476

477477
Hmac::from_engine(hmac)
478478
}
479479

480-
pub(crate) fn verify_payment_context(
481-
payment_context: &PaymentContext, hmac: Hmac<Sha256>, nonce: Nonce, expanded_key: &ExpandedKey,
480+
pub(crate) fn verify_payment_tlvs(
481+
receive_tlvs: &ReceiveTlvs, hmac: Hmac<Sha256>, nonce: Nonce, expanded_key: &ExpandedKey,
482482
) -> Result<(), ()> {
483-
if hmac_for_payment_context(payment_context, nonce, expanded_key) == hmac { Ok(()) } else { Err(()) }
483+
if hmac_for_payment_tlvs(receive_tlvs, nonce, expanded_key) == hmac { Ok(()) } else { Err(()) }
484484
}

0 commit comments

Comments
 (0)