commit 014780d0c6110e1517077ed29a85805da56b19a9
parent d5ff3c2ef45779560e66a0e00fbdc65d87c98f9f
Author: Jared Tobin <jared@jtobin.io>
Date: Sat, 10 Oct 2026 13:04:51 +0400
lib: rotate keys whenever the nonce reaches 1000 or more
step_nonce rotated only when the incremented nonce was exactly 1000,
so a session whose nonce was already past 1000 would never rotate and
its nonce would grow without bound. Rotate on >= 1000 instead.
Diffstat:
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/lib/Lightning/Protocol/BOLT8/Internal.hs b/lib/Lightning/Protocol/BOLT8/Internal.hs
@@ -827,7 +827,7 @@ step_nonce
-> BS.ByteString
-> (Word64, BS.ByteString, BS.ByteString)
step_nonce n ck k
- | n + 1 == 1000 =
+ | n + 1 >= 1000 =
let !(ck', k') = mix_key ck k
in (0, ck', k')
| otherwise = (n + 1, ck, k)