From dde2c8225dccfe1da9cad0707c001a19c909d4e9 Mon Sep 17 00:00:00 2001 From: Joost Jager Date: Thu, 5 Feb 2026 12:24:36 +0100 Subject: [PATCH] fuzz: fix ChaCha20 encrypt_single_block to preserve data The fuzzing ChaCha20 implementation's encrypt_single_block was not copying src to dest, causing encrypted data to be lost (dest remained zeros). This broke payment flows where metadata is encrypted into payment_secret - the receiver would decrypt zeros and detect the wrong payment method (LdkPaymentHash instead of UserPaymentHash), causing payments to fail with "mismatching preimage". Fix by making encrypt_single_block copy src to dest (identity encryption), matching the behavior of the process() method. Co-Authored-By: Claude Opus 4.5 --- lightning/src/crypto/chacha20.rs | 1 + 1 file changed, 1 insertion(+) diff --git a/lightning/src/crypto/chacha20.rs b/lightning/src/crypto/chacha20.rs index 5b0c16c933f..67f9e93c480 100644 --- a/lightning/src/crypto/chacha20.rs +++ b/lightning/src/crypto/chacha20.rs @@ -321,6 +321,7 @@ mod fuzzy_chacha { ) { debug_assert_eq!(dest.len(), src.len()); debug_assert!(dest.len() <= 32); + dest.copy_from_slice(src); } pub fn encrypt_single_block_in_place(