Skip to content

Commit 19b7700

Browse files
committed
allocate act messages without vector prevarication
1 parent ffbf5ec commit 19b7700

File tree

1 file changed

+5
-8
lines changed
  • lightning/src/ln/peers/handshake

1 file changed

+5
-8
lines changed

lightning/src/ln/peers/handshake/mod.rs

Lines changed: 5 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -252,11 +252,9 @@ impl PeerHandshake {
252252
let authentication_tag = chacha::encrypt(&temporary_key, 0, &hash.value, &[0; 0]);
253253
let (sending_key, receiving_key) = hkdf::derive(&chaining_key, &[0; 0]);
254254

255-
let mut act_three_vec = [0u8].to_vec();
256-
act_three_vec.extend_from_slice(&tagged_encrypted_pubkey);
257-
act_three_vec.extend_from_slice(authentication_tag.as_slice());
258255
let mut act_three = [0u8; 66];
259-
act_three.copy_from_slice(act_three_vec.as_slice());
256+
act_three[1..50].copy_from_slice(&tagged_encrypted_pubkey);
257+
act_three[50..].copy_from_slice(authentication_tag.as_slice());
260258

261259
let connected_peer = Conduit {
262260
sending_key,
@@ -330,11 +328,10 @@ impl PeerHandshake {
330328

331329
hash.update(&tagged_ciphertext);
332330

333-
let mut act_vec = [0u8].to_vec();
334-
act_vec.extend_from_slice(&local_public_key.serialize());
335-
act_vec.extend_from_slice(tagged_ciphertext.as_slice());
336331
let mut act = [0u8; 50];
337-
act.copy_from_slice(act_vec.as_slice());
332+
act[1..34].copy_from_slice(&local_public_key.serialize());
333+
act[34..].copy_from_slice(tagged_ciphertext.as_slice());
334+
338335
(act, chaining_key, temporary_key)
339336
}
340337

0 commit comments

Comments
 (0)