Skip to content

Commit edb7533

Browse files
committed
f - pass Nonce instead of IV
1 parent 4d20a96 commit edb7533

File tree

2 files changed

+4
-4
lines changed

2 files changed

+4
-4
lines changed

lightning/src/ln/inbound_payment.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -89,8 +89,8 @@ impl ExpandedKey {
8989

9090
/// Encrypts or decrypts the given `bytes`. Used for data included in an offer message's
9191
/// metadata (e.g., payment id).
92-
pub(crate) fn crypt_for_offer(&self, mut bytes: [u8; 32], iv_bytes: &[u8; IV_LEN]) -> [u8; 32] {
93-
let chacha_block = ChaCha20::get_single_block(&self.offers_encryption_key, iv_bytes);
92+
pub(crate) fn crypt_for_offer(&self, mut bytes: [u8; 32], nonce: Nonce) -> [u8; 32] {
93+
let chacha_block = ChaCha20::get_single_block(&self.offers_encryption_key, &nonce.0);
9494
for i in 0..bytes.len() {
9595
bytes[i] = chacha_block[i] ^ bytes[i];
9696
}

lightning/src/offers/signer.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -167,7 +167,7 @@ impl MetadataMaterial {
167167
) -> Self {
168168
// Encrypt payment_id
169169
let encrypted_payment_id = payment_id.map(|payment_id| {
170-
expanded_key.crypt_for_offer(payment_id.0, &nonce.0)
170+
expanded_key.crypt_for_offer(payment_id.0, nonce)
171171
});
172172

173173
Self {
@@ -254,7 +254,7 @@ pub(super) fn verify_payer_metadata<'a, T: secp256k1::Signing>(
254254
)?;
255255

256256
let nonce = Nonce::try_from(&metadata[PaymentId::LENGTH..][..Nonce::LENGTH]).unwrap();
257-
let payment_id = expanded_key.crypt_for_offer(encrypted_payment_id, &nonce.0);
257+
let payment_id = expanded_key.crypt_for_offer(encrypted_payment_id, nonce);
258258

259259
Ok(PaymentId(payment_id))
260260
}

0 commit comments

Comments
 (0)