Skip to content

Commit 7f53a3e

Browse files
committed
BOLT 8: make it clear that there are *two* chaining keys.
lnmessage got this wrong! It would pass our test vectors, but actually fail in real usage, since it used the same `ck`. Also, nonce rotation happens after 1000 encryptions, which is when the nonce reaches 1000 (since it's zero based!), not when it *exceeds* 1000. Signed-off-by: Rusty Russell <[email protected]>
1 parent e0995c9 commit 7f53a3e

File tree

1 file changed

+9
-4
lines changed

1 file changed

+9
-4
lines changed

08-transport.md

+9-4
Original file line numberDiff line numberDiff line change
@@ -369,7 +369,9 @@ construction, and 16 bytes for a final authenticating tag.
369369
receiving messages for the duration of the session, are generated.
370370
7. `rn = 0, sn = 0`
371371
* The sending and receiving nonces are initialized to 0.
372-
8. Send `m = 0 || c || t` over the network buffer.
372+
8. `rck = sck = ck`
373+
* The sending and receiving chaining keys are initialized the same.
374+
9. Send `m = 0 || c || t` over the network buffer.
373375

374376
**Receiver Actions:**
375377

@@ -401,6 +403,8 @@ construction, and 16 bytes for a final authenticating tag.
401403
receiving messages for the duration of the session, are generated.
402404
10. `rn = 0, sn = 0`
403405
* The sending and receiving nonces are initialized to 0.
406+
11. `rck = sck = ck`
407+
* The sending and receiving chaining keys are initialized the same.
404408

405409
## Lightning Message Specification
406410

@@ -488,14 +492,15 @@ Changing keys regularly and forgetting previous keys is useful to
488492
prevent the decryption of old messages, in the case of later key leakage (i.e.
489493
backwards secrecy).
490494

491-
Key rotation is performed for _each_ key (`sk` and `rk`) _individually_. A key
495+
Key rotation is performed for _each_ key (`sk` and `rk`) _individually_,
496+
using `sck` and `rck` respectively. A key
492497
is to be rotated after a party encrypts or decrypts 1000 times with it (i.e. every 500 messages).
493498
This can be properly accounted for by rotating the key once the nonce dedicated
494-
to it exceeds 1000.
499+
to it reaches 1000.
495500

496501
Key rotation for a key `k` is performed according to the following steps:
497502

498-
1. Let `ck` be the chaining key obtained at the end of Act Three.
503+
1. Let `ck` be the chaining key (i.e. `rck` for `rk` or `sck` for `sk`)
499504
2. `ck', k' = HKDF(ck, k)`
500505
3. Reset the nonce for the key to `n = 0`.
501506
4. `k = k'`

0 commit comments

Comments
 (0)