Skip to content

Commit 2c8e38d

Browse files
committed
constantify key rotation index for conduit
1 parent cc27a51 commit 2c8e38d

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

lightning/src/ln/peers/conduit.rs

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,12 @@ use ln::peers::{chacha, hkdf};
44
use util::byte_utils;
55

66
pub(super) type SymmetricKey = [u8; 32];
7+
78
const MESSAGE_LENGTH_HEADER_SIZE: usize = 2;
89
const TAGGED_MESSAGE_LENGTH_HEADER_SIZE: usize = MESSAGE_LENGTH_HEADER_SIZE + chacha::TAG_SIZE;
910

11+
const KEY_ROTATION_INDEX: u32 = 1000;
12+
1013
/// Returned after a successful handshake to encrypt and decrypt communication with peer nodes.
1114
/// It should not normally be manually instantiated.
1215
/// Automatically handles key rotation.
@@ -109,7 +112,7 @@ impl Conduit {
109112

110113
fn increment_nonce(nonce: &mut u32, chaining_key: &mut SymmetricKey, key: &mut SymmetricKey) {
111114
*nonce += 1;
112-
if *nonce == 1000 {
115+
if *nonce == KEY_ROTATION_INDEX {
113116
Self::rotate_key(chaining_key, key);
114117
*nonce = 0;
115118
}

0 commit comments

Comments
 (0)