X-Git-Url: http://git.bitcoin.ninja/index.cgi?a=blobdiff_plain;f=lightning%2Fsrc%2Fln%2Finbound_payment.rs;h=f9e10880afbe5f5eae122d48220f5b8e5dcd9757;hb=d0f0d9c19f86e5056bbb768e06c6d5f2fb6b925d;hp=25e79e3bc15db59fab2d05b7edd33bd8a6b9a7d9;hpb=4732484520838081703fe61ef4bd8c4531637b85;p=rust-lightning diff --git a/lightning/src/ln/inbound_payment.rs b/lightning/src/ln/inbound_payment.rs index 25e79e3b..f9e10880 100644 --- a/lightning/src/ln/inbound_payment.rs +++ b/lightning/src/ln/inbound_payment.rs @@ -86,6 +86,13 @@ impl ExpandedKey { hmac.input(&nonce.0); hmac } + + /// Encrypts or decrypts the given `bytes`. Used for data included in an offer message's + /// metadata (e.g., payment id). + pub(crate) fn crypt_for_offer(&self, mut bytes: [u8; 32], nonce: Nonce) -> [u8; 32] { + ChaCha20::encrypt_single_block_in_place(&self.offers_encryption_key, &nonce.0, &mut bytes); + bytes + } } /// A 128-bit number used only once.