Skip to content

Commit 56f1e72

Browse files
committed
f - comments explaining HMAC input constants
1 parent 5996518 commit 56f1e72

File tree

1 file changed

+8
-0
lines changed

1 file changed

+8
-0
lines changed

lightning/src/offers/signer.rs

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,8 +23,16 @@ use crate::util::ser::Writeable;
2323

2424
use crate::prelude::*;
2525

26+
// Use a different HMAC input for each derivation. Otherwise, an attacker could:
27+
// - take an Offer that has metadata consisting of a nonce and HMAC
28+
// - strip off the HMAC and replace the signing_pubkey where the privkey is the HMAC,
29+
// - generate and sign an invoice using the new signing_pubkey, and
30+
// - claim they paid it since they would know the preimage of the invoice's payment_hash
2631
const DERIVED_METADATA_HMAC_INPUT: &[u8; 16] = &[1; 16];
2732
const DERIVED_METADATA_AND_KEYS_HMAC_INPUT: &[u8; 16] = &[2; 16];
33+
34+
// Additional HMAC inputs to distinguish use cases, either Offer or Refund/InvoiceRequest, where
35+
// metadata for the latter contain an encrypted PaymentId.
2836
const WITHOUT_ENCRYPTED_PAYMENT_ID_HMAC_INPUT: &[u8; 16] = &[3; 16];
2937
const WITH_ENCRYPTED_PAYMENT_ID_HMAC_INPUT: &[u8; 16] = &[4; 16];
3038

0 commit comments

Comments
 (0)