Skip to content

Commit 6320463

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 16c6f67 commit 6320463

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
@@ -112,8 +112,8 @@ impl TestCtx {
112112
}
113113
}
114114

115-
// Common test function that sends encrypted messages between an encryptor/decryptor until the source
116-
// data runs out.
115+
// Common test function that sends encrypted messages between an encryptor/decryptor until the
116+
// source data runs out.
117117
#[inline]
118118
fn do_encrypted_communication_tests(generator: &mut FuzzGen,
119119
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
@@ -170,8 +170,8 @@ impl Decryptor {
170170
increment_nonce_helper(&mut self.receiving_nonce, &mut self.receiving_chaining_key, &mut self.receiving_key);
171171
}
172172

173-
// Used in tests to determine whether or not excess bytes entered the conduit without needing to bring up
174-
// infrastructure to properly encode it
173+
// Used in tests to determine whether or not excess bytes entered the Decryptor without needing
174+
// to bring up infrastructure to properly encode it
175175
#[cfg(test)]
176176
pub fn read_buffer_length(&self) -> usize {
177177
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
@@ -4,7 +4,7 @@
44
55
use bitcoin::secp256k1::{PublicKey, SecretKey};
66

7-
use ln::peers::conduit::{Decryptor, Encryptor};
7+
use ln::peers::encryption::{Decryptor, Encryptor};
88
use ln::peers::handshake::acts::Act;
99
use ln::peers::handshake::states::HandshakeState;
1010
use ln::peers::transport::IPeerHandshake;
@@ -52,8 +52,8 @@ impl IPeerHandshake for PeerHandshake {
5252
self.ready_to_process = true;
5353

5454
// This transition does not have a failure path
55-
let (response_vec_option, conduit_and_remote_static_public_key_option) = self.process_act(&[]).unwrap();
56-
assert!(conduit_and_remote_static_public_key_option.is_none());
55+
let (response_vec_option, completed_handshake_info) = self.process_act(&[]).unwrap();
56+
assert!(completed_handshake_info.is_none());
5757

5858
response_vec_option.unwrap()
5959
}

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

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

77
use ln::peers::{chacha, hkdf5869rfc};
8-
use ln::peers::conduit::{SymmetricKey, create_encryptor_decryptor};
8+
use ln::peers::encryption::{SymmetricKey, create_encryptor_decryptor};
99
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};
1010
use ln::peers::handshake::{CompletedHandshakeInfo, IHandshakeState};
1111

@@ -774,10 +774,10 @@ mod test {
774774
}
775775

776776
// Responder::AwaitingActThree -> None (with extra bytes)
777-
// Ensures that any remaining data in the read buffer is transferred to the conduit once
777+
// Ensures that any remaining data in the read buffer is transferred to the Decryptor once
778778
// the handshake is complete
779779
#[test]
780-
fn awaiting_act_three_excess_bytes_after_complete_are_in_conduit() {
780+
fn awaiting_act_three_excess_bytes_after_complete_are_in_decryptor() {
781781
let test_ctx = TestCtx::new();
782782
let (_act2, awaiting_act_three_state) = do_next_or_panic!(test_ctx.responder, &test_ctx.valid_act1);
783783
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
@@ -1,7 +1,8 @@
11
//! Everything that has to do with over-the-wire peer communication.
22
//! The handshake module exposes mechanisms to conduct inbound and outbound handshakes.
3-
//! When a handshake completes, it returns an instance of Conduit.
4-
//! Conduit enables message encryption and decryption, and automatically handles key rotation.
3+
//! When a handshake completes, it returns an instance of CompletedPeerHandshake containing an
4+
//! Encryptor/Decryptor used for encrypted communication and the remote static public key used for
5+
//! identification.
56
67
#[cfg(test)]
78
#[macro_use]
@@ -17,9 +18,9 @@ mod hkdf5869rfc;
1718
mod outbound_queue;
1819

1920
#[cfg(feature = "fuzztarget")]
20-
pub mod conduit;
21+
pub mod encryption;
2122
#[cfg(not(feature = "fuzztarget"))]
22-
mod conduit;
23+
mod encryption;
2324

2425
#[cfg(feature = "fuzztarget")]
2526
pub mod handshake;

lightning/src/ln/peers/test_util.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
use bitcoin::secp256k1;
44
use bitcoin::secp256k1::key::{PublicKey, SecretKey};
55

6-
use ln::peers::conduit;
6+
use ln::peers::encryption::{create_encryptor_decryptor};
77
use ln::peers::handler::{SocketDescriptor, ITransport, PeerHandleError, MessageQueuer};
88
use ln::peers::handshake::CompletedHandshakeInfo;
99
use ln::peers::transport::{IPeerHandshake, PayloadQueuer};
@@ -74,7 +74,7 @@ impl IPeerHandshake for PeerHandshakeTestStubBytes {
7474
}
7575
}
7676

77-
/// Stub implementation of IPeerhandshake that returns Some(Conduit, PublicKey)
77+
/// Stub implementation of IPeerhandshake that returns Some(CompletedHandshakeInfo)
7878
pub(super) struct PeerHandshakeTestStubComplete { }
7979

8080
impl IPeerHandshake for PeerHandshakeTestStubComplete {
@@ -94,7 +94,7 @@ impl IPeerHandshake for PeerHandshakeTestStubComplete {
9494
let curve = secp256k1::Secp256k1::new();
9595
let private_key = SecretKey::from_slice(&[0x_21_u8; 32]).unwrap();
9696
let public_key = PublicKey::from_secret_key(&curve, &private_key);
97-
let (encryptor, decryptor) = conduit::create_encryptor_decryptor([0;32], [0;32], [0;32]);
97+
let (encryptor, decryptor) = create_encryptor_decryptor([0;32], [0;32], [0;32]);
9898

9999
Ok((None, Some(
100100
CompletedHandshakeInfo {

0 commit comments

Comments
 (0)