Skip to content

Commit d7e4a44

Browse files
committed
Use [u8; 32] rather than Hmac<Sha256> for simplicity
Mapping an `Hmac<Sha256>` would require somewhat custom logic as we'd have to behave differently based on generic parameters, so its simplest to just swap it to a `[u8; 32]` instead.
1 parent b600c62 commit d7e4a44

File tree

2 files changed

+7
-6
lines changed

2 files changed

+7
-6
lines changed

lightning/src/blinded_path/payment.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -332,7 +332,7 @@ pub struct ReceiveTlvs {
332332
/// The TLVs for which the HMAC in `authentication` is derived.
333333
pub(crate) tlvs: UnauthenticatedReceiveTlvs,
334334
/// An HMAC of `tlvs` along with a nonce used to construct it.
335-
pub(crate) authentication: (Hmac<Sha256>, Nonce),
335+
pub(crate) authentication: ([u8; 32], Nonce),
336336
}
337337

338338
impl ReceiveTlvs {

lightning/src/ln/channelmanager.rs

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -570,24 +570,25 @@ pub trait Verification {
570570
/// [`Nonce`].
571571
fn hmac_for_offer_payment(
572572
&self, nonce: Nonce, expanded_key: &inbound_payment::ExpandedKey,
573-
) -> Hmac<Sha256>;
573+
) -> [u8; 32];
574574

575575
/// Authenticates the data using an HMAC and a [`Nonce`] taken from an [`OffersContext`].
576576
fn verify_for_offer_payment(
577-
&self, hmac: Hmac<Sha256>, nonce: Nonce, expanded_key: &inbound_payment::ExpandedKey,
577+
&self, hmac: [u8; 32], nonce: Nonce, expanded_key: &inbound_payment::ExpandedKey,
578578
) -> Result<(), ()>;
579579
}
580580

581581
impl Verification for UnauthenticatedReceiveTlvs {
582582
fn hmac_for_offer_payment(
583583
&self, nonce: Nonce, expanded_key: &inbound_payment::ExpandedKey,
584-
) -> Hmac<Sha256> {
585-
signer::hmac_for_payment_tlvs(self, nonce, expanded_key)
584+
) -> [u8; 32] {
585+
signer::hmac_for_payment_tlvs(self, nonce, expanded_key).to_byte_array()
586586
}
587587

588588
fn verify_for_offer_payment(
589-
&self, hmac: Hmac<Sha256>, nonce: Nonce, expanded_key: &inbound_payment::ExpandedKey,
589+
&self, hmac: [u8; 32], nonce: Nonce, expanded_key: &inbound_payment::ExpandedKey,
590590
) -> Result<(), ()> {
591+
let hmac = bitcoin::hashes::hmac::Hmac::from_byte_array(hmac);
591592
signer::verify_payment_tlvs(self, hmac, nonce, expanded_key)
592593
}
593594
}

0 commit comments

Comments
 (0)