@@ -90,10 +90,6 @@ impl Friend {
9090/// Friend connections module that handles friends and their connections.
9191#[ derive( Clone ) ]
9292pub struct FriendConnections {
93- /// Our long term `SecretKey`.
94- real_sk : SecretKey ,
95- /// Our long term `PublicKey`.
96- real_pk : PublicKey ,
9793 /// List of friends we want to be connected to.
9894 friends : Arc < RwLock < HashMap < PublicKey , Friend > > > ,
9995 /// Sink to send a connection status when it becomes connected or
@@ -112,16 +108,12 @@ pub struct FriendConnections {
112108impl FriendConnections {
113109 /// Create new `FriendConnections`.
114110 pub fn new (
115- real_sk : SecretKey ,
116- real_pk : PublicKey ,
117111 dht : DhtServer ,
118112 tcp_connections : TcpConnections ,
119113 onion_client : OnionClient ,
120114 net_crypto : NetCrypto ,
121115 ) -> Self {
122116 FriendConnections {
123- real_sk,
124- real_pk,
125117 friends : Arc :: new ( RwLock :: new ( HashMap :: new ( ) ) ) ,
126118 connection_status_tx : Arc :: new ( RwLock :: new ( None ) ) ,
127119 dht,
@@ -450,13 +442,11 @@ mod tests {
450442 lossy_tx,
451443 dht_pk,
452444 dht_sk,
453- real_pk : real_pk . clone ( ) ,
454- real_sk : real_sk . clone ( ) ,
445+ real_pk,
446+ real_sk,
455447 precomputed_keys,
456448 } ) ;
457449 let friend_connections = FriendConnections :: new (
458- real_sk,
459- real_pk,
460450 dht,
461451 tcp_connections,
462452 onion_client,
@@ -494,7 +484,7 @@ mod tests {
494484 let _ = friend_connections. tcp_connections . add_connection ( relay_pk, friend_dht_pk. clone ( ) ) ;
495485
496486 let session_precomputed_key = SalsaBox :: new ( & SecretKey :: generate ( & mut rng) . public_key ( ) , & SecretKey :: generate ( & mut rng) ) ;
497- let sent_nonce = crypto_box :: generate_nonce ( & mut rng) . into ( ) ;
487+ let sent_nonce = SalsaBox :: generate_nonce ( & mut rng) . into ( ) ;
498488 friend_connections. net_crypto . add_established_connection (
499489 SecretKey :: generate ( & mut rng) . public_key ( ) ,
500490 friend_pk. clone ( ) ,
@@ -547,7 +537,7 @@ mod tests {
547537 let _ = friend_connections. tcp_connections . add_connection ( relay_pk, friend_dht_pk. clone ( ) ) ;
548538
549539 let session_precomputed_key = SalsaBox :: new ( & SecretKey :: generate ( & mut rng) . public_key ( ) , & SecretKey :: generate ( & mut rng) ) ;
550- let sent_nonce = crypto_box :: generate_nonce ( & mut rng) . into ( ) ;
540+ let sent_nonce = SalsaBox :: generate_nonce ( & mut rng) . into ( ) ;
551541 friend_connections. net_crypto . add_established_connection (
552542 SecretKey :: generate ( & mut rng) . public_key ( ) ,
553543 friend_pk. clone ( ) ,
@@ -703,7 +693,7 @@ mod tests {
703693 friend_connections. friends . write ( ) . await . insert ( friend_pk. clone ( ) , friend) ;
704694
705695 let session_precomputed_key = SalsaBox :: new ( & SecretKey :: generate ( & mut rng) . public_key ( ) , & SecretKey :: generate ( & mut rng) ) ;
706- let sent_nonce = crypto_box :: generate_nonce ( & mut rng) . into ( ) ;
696+ let sent_nonce = SalsaBox :: generate_nonce ( & mut rng) . into ( ) ;
707697 friend_connections. net_crypto . add_established_connection (
708698 SecretKey :: generate ( & mut rng) . public_key ( ) ,
709699 friend_pk. clone ( ) ,
@@ -750,7 +740,7 @@ mod tests {
750740 friend_connections. friends . write ( ) . await . insert ( friend_pk. clone ( ) , friend) ;
751741
752742 let session_precomputed_key = SalsaBox :: new ( & SecretKey :: generate ( & mut rng) . public_key ( ) , & SecretKey :: generate ( & mut rng) ) ;
753- let sent_nonce = crypto_box :: generate_nonce ( & mut rng) . into ( ) ;
743+ let sent_nonce = SalsaBox :: generate_nonce ( & mut rng) . into ( ) ;
754744 friend_connections. net_crypto . add_established_connection (
755745 SecretKey :: generate ( & mut rng) . public_key ( ) ,
756746 friend_pk. clone ( ) ,
@@ -800,7 +790,7 @@ mod tests {
800790 friend_connections. friends . write ( ) . await . insert ( friend_pk. clone ( ) , friend) ;
801791
802792 let session_precomputed_key = SalsaBox :: new ( & SecretKey :: generate ( & mut rng) . public_key ( ) , & SecretKey :: generate ( & mut rng) ) ;
803- let sent_nonce = crypto_box :: generate_nonce ( & mut rng) . into ( ) ;
793+ let sent_nonce = SalsaBox :: generate_nonce ( & mut rng) . into ( ) ;
804794 friend_connections. net_crypto . add_established_connection (
805795 SecretKey :: generate ( & mut rng) . public_key ( ) ,
806796 friend_pk. clone ( ) ,
@@ -961,9 +951,9 @@ mod tests {
961951 let run_future = friend_connections. run ( )
962952 . map ( Result :: unwrap) ;
963953
964- let precomputed_key = SalsaBox :: new ( & friend_connections. real_pk , & friend_sk) ;
954+ let precomputed_key = SalsaBox :: new ( friend_connections. net_crypto . real_pk ( ) , & friend_sk) ;
965955 let cookie = friend_connections. net_crypto . get_cookie ( & mut rng, friend_pk. clone ( ) , friend_dht_pk) ;
966- let sent_nonce = crypto_box :: generate_nonce ( & mut rng) . into ( ) ;
956+ let sent_nonce = SalsaBox :: generate_nonce ( & mut rng) . into ( ) ;
967957 let friend_session_sk = SecretKey :: generate ( & mut rng) ;
968958 let friend_session_pk = friend_session_sk. public_key ( ) ;
969959 let our_cookie = EncryptedCookie {
0 commit comments