File tree Expand file tree Collapse file tree 1 file changed +8
-0
lines changed Expand file tree Collapse file tree 1 file changed +8
-0
lines changed Original file line number Diff line number Diff line change @@ -23,8 +23,16 @@ use crate::util::ser::Writeable;
2323
2424use 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
2631const DERIVED_METADATA_HMAC_INPUT : & [ u8 ; 16 ] = & [ 1 ; 16 ] ;
2732const 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.
2836const WITHOUT_ENCRYPTED_PAYMENT_ID_HMAC_INPUT : & [ u8 ; 16 ] = & [ 3 ; 16 ] ;
2937const WITH_ENCRYPTED_PAYMENT_ID_HMAC_INPUT : & [ u8 ; 16 ] = & [ 4 ; 16 ] ;
3038
You can’t perform that action at this time.
0 commit comments