Skip to content

Commit daf7964

Browse files
committed
refactor: Rename conduit.rs and clean up remaining references
Clean up the loose comments, test names, and variables names that still referred to conduit now that it has been destructured.
1 parent 037212d commit daf7964

File tree

6 files changed

+18
-17
lines changed

6 files changed

+18
-17
lines changed

fuzz/src/peer_crypt.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -121,8 +121,8 @@ impl TestCtx {
121121
}
122122
}
123123

124-
// Common test function that sends encrypted messages between an encryptor/decryptor until the source
125-
// data runs out.
124+
// Common test function that sends encrypted messages between an encryptor/decryptor until the
125+
// source data runs out.
126126
#[inline]
127127
fn do_encrypted_communication_tests(generator: &mut FuzzGen,
128128
initiator_completed_handshake_info: &mut CompletedHandshakeInfo,

lightning/src/ln/peers/conduit.rs renamed to lightning/src/ln/peers/encryption.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -192,8 +192,8 @@ impl Decryptor {
192192
increment_nonce_helper(&mut self.receiving_nonce, &mut self.receiving_chaining_key, &mut self.receiving_key);
193193
}
194194

195-
// Used in tests to determine whether or not excess bytes entered the conduit without needing to bring up
196-
// infrastructure to properly encode it
195+
// Used in tests to determine whether or not excess bytes entered the Decryptor without needing
196+
// to bring up infrastructure to properly encode it
197197
#[cfg(test)]
198198
pub fn read_buffer_length(&self) -> usize {
199199
match &self.read_buffer {

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

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
1414
use bitcoin::secp256k1::{PublicKey, SecretKey};
1515

16-
use ln::peers::conduit::{Decryptor, Encryptor};
16+
use ln::peers::encryption::{Decryptor, Encryptor};
1717
use ln::peers::handshake::acts::Act;
1818
use ln::peers::handshake::states::HandshakeState;
1919
use ln::peers::transport::IPeerHandshake;
@@ -61,8 +61,8 @@ impl IPeerHandshake for PeerHandshake {
6161
self.ready_to_process = true;
6262

6363
// This transition does not have a failure path
64-
let (response_vec_option, conduit_and_remote_static_public_key_option) = self.process_act(&[]).unwrap();
65-
assert!(conduit_and_remote_static_public_key_option.is_none());
64+
let (response_vec_option, completed_handshake_info) = self.process_act(&[]).unwrap();
65+
assert!(completed_handshake_info.is_none());
6666

6767
response_vec_option.unwrap()
6868
}

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

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ use bitcoin::hashes::sha256::Hash as Sha256;
1414
use bitcoin::secp256k1::{SecretKey, PublicKey};
1515

1616
use ln::peers::{chacha, hkdf5869rfc};
17-
use ln::peers::conduit::{SymmetricKey, create_encryptor_decryptor};
17+
use ln::peers::encryption::{SymmetricKey, create_encryptor_decryptor};
1818
use ln::peers::handshake::acts::{Act, ActBuilder, ACT_ONE_LENGTH, ACT_TWO_LENGTH, ACT_THREE_LENGTH, EMPTY_ACT_ONE, EMPTY_ACT_TWO, EMPTY_ACT_THREE};
1919
use ln::peers::handshake::{CompletedHandshakeInfo, IHandshakeState};
2020

@@ -783,10 +783,10 @@ mod test {
783783
}
784784

785785
// Responder::AwaitingActThree -> None (with extra bytes)
786-
// Ensures that any remaining data in the read buffer is transferred to the conduit once
786+
// Ensures that any remaining data in the read buffer is transferred to the Decryptor once
787787
// the handshake is complete
788788
#[test]
789-
fn awaiting_act_three_excess_bytes_after_complete_are_in_conduit() {
789+
fn awaiting_act_three_excess_bytes_after_complete_are_in_decryptor() {
790790
let test_ctx = TestCtx::new();
791791
let (_act2, awaiting_act_three_state) = do_next_or_panic!(test_ctx.responder, &test_ctx.valid_act1);
792792
let mut act3 = test_ctx.valid_act3;

lightning/src/ln/peers/mod.rs

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,9 @@
99

1010
//! Everything that has to do with over-the-wire peer communication.
1111
//! The handshake module exposes mechanisms to conduct inbound and outbound handshakes.
12-
//! When a handshake completes, it returns an instance of Conduit.
13-
//! Conduit enables message encryption and decryption, and automatically handles key rotation.
12+
//! When a handshake completes, it returns an instance of CompletedPeerHandshake containing an
13+
//! Encryptor/Decryptor used for encrypted communication and the remote static public key used for
14+
//! identification.
1415
1516
#[cfg(test)]
1617
#[macro_use]
@@ -26,9 +27,9 @@ mod hkdf5869rfc;
2627
mod outbound_queue;
2728

2829
#[cfg(feature = "fuzztarget")]
29-
pub mod conduit;
30+
pub mod encryption;
3031
#[cfg(not(feature = "fuzztarget"))]
31-
mod conduit;
32+
mod encryption;
3233

3334
#[cfg(feature = "fuzztarget")]
3435
pub mod handshake;

lightning/src/ln/peers/test_util.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
use bitcoin::secp256k1;
1313
use bitcoin::secp256k1::key::{PublicKey, SecretKey};
1414

15-
use ln::peers::conduit;
15+
use ln::peers::encryption::{create_encryptor_decryptor};
1616
use ln::peers::handler::{SocketDescriptor, ITransport, PeerHandleError, MessageQueuer};
1717
use ln::peers::handshake::CompletedHandshakeInfo;
1818
use ln::peers::transport::{IPeerHandshake, PayloadQueuer};
@@ -83,7 +83,7 @@ impl IPeerHandshake for PeerHandshakeTestStubBytes {
8383
}
8484
}
8585

86-
/// Stub implementation of IPeerhandshake that returns Some(Conduit, PublicKey)
86+
/// Stub implementation of IPeerhandshake that returns Some(CompletedHandshakeInfo)
8787
pub(super) struct PeerHandshakeTestStubComplete { }
8888

8989
impl IPeerHandshake for PeerHandshakeTestStubComplete {
@@ -103,7 +103,7 @@ impl IPeerHandshake for PeerHandshakeTestStubComplete {
103103
let curve = secp256k1::Secp256k1::new();
104104
let private_key = SecretKey::from_slice(&[0x_21_u8; 32]).unwrap();
105105
let public_key = PublicKey::from_secret_key(&curve, &private_key);
106-
let (encryptor, decryptor) = conduit::create_encryptor_decryptor([0;32], [0;32], [0;32]);
106+
let (encryptor, decryptor) = create_encryptor_decryptor([0;32], [0;32], [0;32]);
107107

108108
Ok((None, Some(
109109
CompletedHandshakeInfo {

0 commit comments

Comments
 (0)