From 6a63be63e9949c8cbe94ba5df60cda88ee8a7592 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C4=99drzej=20Stuczy=C5=84ski?= Date: Thu, 4 May 2023 18:34:12 +0100 Subject: [PATCH] removing dead code + extra docs --- .../client-core/src/client/key_manager/mod.rs | 169 ++---------------- sdk/rust/nym-sdk/src/mixnet.rs | 6 +- sdk/rust/nym-sdk/src/mixnet/client.rs | 99 ++++------ sdk/rust/nym-sdk/src/mixnet/config.rs | 18 ++ sdk/rust/nym-sdk/src/mixnet/keys.rs | 68 ------- sdk/rust/nym-sdk/src/mixnet/paths.rs | 56 ++---- sdk/rust/nym-sdk/src/mixnet/socks5_client.rs | 2 +- 7 files changed, 79 insertions(+), 339 deletions(-) delete mode 100644 sdk/rust/nym-sdk/src/mixnet/keys.rs diff --git a/common/client-core/src/client/key_manager/mod.rs b/common/client-core/src/client/key_manager/mod.rs index 9009dc4164..ae30f53048 100644 --- a/common/client-core/src/client/key_manager/mod.rs +++ b/common/client-core/src/client/key_manager/mod.rs @@ -201,29 +201,7 @@ pub struct KeyManager { ack_key: Arc, } -// The expected flow of a KeyManager "lifetime" is as follows: -/* - 1. ::new() is called during client-init - 2. after gateway registration is completed [in init] ::insert_gateway_shared_key() is called - 3. ::store_keys() is called before init finishes execution. - 4. ::load_keys() is called at the beginning of each subsequent client-run - 5. [not implemented] ::rotate_keys() is called periodically during client-run I presume? -*/ - impl KeyManager { - // /// Creates new instance of a [`KeyManager`] - // pub fn new(rng: &mut R) -> Self - // where - // R: RngCore + CryptoRng, - // { - // KeyManager { - // identity_keypair: Arc::new(identity::KeyPair::new(rng)), - // encryption_keypair: Arc::new(encryption::KeyPair::new(rng)), - // gateway_shared_key: None, - // ack_key: Arc::new(AckKey::new(rng)), - // } - // } - pub fn from_keys( id_keypair: identity::KeyPair, enc_keypair: encryption::KeyPair, @@ -246,162 +224,35 @@ impl KeyManager { store.store_keys(self).await } - // - // /// Loads previously stored client keys from the disk. - // fn load_client_keys(client_pathfinder: &ClientKeyPathfinder) -> io::Result { - // let identity_keypair: identity::KeyPair = - // nym_pemstore::load_keypair(&nym_pemstore::KeyPairPath::new( - // client_pathfinder.private_identity_key().to_owned(), - // client_pathfinder.public_identity_key().to_owned(), - // ))?; - // let encryption_keypair: encryption::KeyPair = - // nym_pemstore::load_keypair(&nym_pemstore::KeyPairPath::new( - // client_pathfinder.private_encryption_key().to_owned(), - // client_pathfinder.public_encryption_key().to_owned(), - // ))?; - // - // let ack_key: AckKey = nym_pemstore::load_key(client_pathfinder.ack_key())?; - // - // Ok(KeyManager { - // identity_keypair: Arc::new(identity_keypair), - // encryption_keypair: Arc::new(encryption_keypair), - // gateway_shared_key: None, - // ack_key: Arc::new(ack_key), - // }) - // } - // - // /// Loads previously stored keys from the disk. Fails if not all, including the shared gateway - // /// key, is available. - // pub fn load_keys_from_disk(client_pathfinder: &ClientKeyPathfinder) -> io::Result { - // let mut key_manager = Self::load_client_keys(client_pathfinder)?; - // - // let gateway_shared_key: SharedKeys = - // nym_pemstore::load_key(client_pathfinder.gateway_shared_key())?; - // - // key_manager.gateway_shared_key = Some(Arc::new(gateway_shared_key)); - // - // Ok(key_manager) - // } - // - // /// Loads previously stored keys from the disk. Fails if client keys are not available, but the - // /// shared gateway key is optional. - // pub fn load_keys_from_disk_but_gateway_is_optional( - // client_pathfinder: &ClientKeyPathfinder, - // ) -> io::Result { - // let mut key_manager = Self::load_client_keys(client_pathfinder)?; - // - // let gateway_shared_key: Result = - // nym_pemstore::load_key(client_pathfinder.gateway_shared_key()); - // - // // It's ok if the gateway key was not found - // let gateway_shared_key = match gateway_shared_key { - // Err(err) if err.kind() == io::ErrorKind::NotFound => Ok(None), - // Err(err) => Err(err), - // Ok(key) => Ok(Some(key)), - // }?; - // - // key_manager.gateway_shared_key = gateway_shared_key.map(Arc::new); - // - // Ok(key_manager) - // } - // - // /// Stores all available keys on the disk. - // // While perhaps there is no much point in storing the `AckKey` on the disk, - // // it is done so for the consistency sake so that you wouldn't require an rng instance - // // during `load_keys` to generate the said key. - // pub fn store_keys_on_disk(&self, client_pathfinder: &ClientKeyPathfinder) -> io::Result<()> { - // nym_pemstore::store_keypair( - // self.identity_keypair.as_ref(), - // &nym_pemstore::KeyPairPath::new( - // client_pathfinder.private_identity_key().to_owned(), - // client_pathfinder.public_identity_key().to_owned(), - // ), - // )?; - // nym_pemstore::store_keypair( - // self.encryption_keypair.as_ref(), - // &nym_pemstore::KeyPairPath::new( - // client_pathfinder.private_encryption_key().to_owned(), - // client_pathfinder.public_encryption_key().to_owned(), - // ), - // )?; - // - // nym_pemstore::store_key(self.ack_key.as_ref(), client_pathfinder.ack_key())?; - // - // match self.gateway_shared_key.as_ref() { - // None => debug!("No gateway shared key available to store!"), - // Some(gate_key) => { - // nym_pemstore::store_key(gate_key.as_ref(), client_pathfinder.gateway_shared_key())? - // } - // } - // - // Ok(()) - // } - // - // pub fn store_gateway_key_on_disk( - // &self, - // client_pathfinder: &ClientKeyPathfinder, - // ) -> io::Result<()> { - // match self.gateway_shared_key.as_ref() { - // None => { - // return Err(io::Error::new( - // io::ErrorKind::Other, - // "trying to store a non-existing key", - // )) - // } - // Some(gate_key) => { - // nym_pemstore::store_key(gate_key.as_ref(), client_pathfinder.gateway_shared_key())? - // } - // } - // - // Ok(()) - // } - - /// Overwrite the existing identity keypair - #[deprecated] - pub fn set_identity_keypair(&mut self, id_keypair: identity::KeyPair) { - self.identity_keypair = Arc::new(id_keypair); - } - /// Gets an atomically reference counted pointer to [`identity::KeyPair`]. pub fn identity_keypair(&self) -> Arc { Arc::clone(&self.identity_keypair) } - /// Overwrite the existing encryption keypair - #[deprecated] - pub fn set_encryption_keypair(&mut self, enc_keypair: encryption::KeyPair) { - self.encryption_keypair = Arc::new(enc_keypair); - } - /// Gets an atomically reference counted pointer to [`encryption::KeyPair`]. pub fn encryption_keypair(&self) -> Arc { Arc::clone(&self.encryption_keypair) } - - /// Overwrite the existing ack key - #[deprecated] - pub fn set_ack_key(&mut self, ack_key: AckKey) { - self.ack_key = Arc::new(ack_key); - } - /// Gets an atomically reference counted pointer to [`AckKey`]. pub fn ack_key(&self) -> Arc { Arc::clone(&self.ack_key) } - // /// After shared key with the gateway is derived, puts its ownership to this instance of a [`KeyManager`]. - // pub fn insert_gateway_shared_key(&mut self, gateway_shared_key: Arc) { - // self.gateway_shared_key = Some(gateway_shared_key) - // } - /// Gets an atomically reference counted pointer to [`SharedKey`]. pub fn gateway_shared_key(&self) -> Arc { Arc::clone(&self.gateway_shared_key) } - // pub fn is_gateway_key_set(&self) -> bool { - // self.gateway_shared_key.is_some() - // } + pub fn remove_gateway_key(self) -> KeyManagerBuilder { + if Arc::strong_count(&self.gateway_shared_key) > 1 { + panic!("attempted to remove gateway key whilst still holding multiple references!") + } + KeyManagerBuilder { + identity_keypair: self.identity_keypair, + encryption_keypair: self.encryption_keypair, + ack_key: self.ack_key, + } + } } fn _assert_keys_zeroize_on_drop() { diff --git a/sdk/rust/nym-sdk/src/mixnet.rs b/sdk/rust/nym-sdk/src/mixnet.rs index f72bbc2324..ecaf9523a3 100644 --- a/sdk/rust/nym-sdk/src/mixnet.rs +++ b/sdk/rust/nym-sdk/src/mixnet.rs @@ -33,14 +33,12 @@ mod client; mod config; mod connection_state; -mod keys; mod native_client; mod paths; mod socks5_client; pub use client::{DisconnectedMixnetClient, IncludedSurbs, MixnetClientBuilder}; -pub use config::Config; -pub use keys::{Keys, KeysArc}; +pub use config::{Config, KeyMode}; pub use native_client::MixnetClient; pub use native_client::MixnetClientSender; pub use nym_client_core::{ @@ -69,5 +67,5 @@ pub use nym_sphinx::{ receiver::ReconstructedMessage, }; pub use nym_topology::{provider_trait::TopologyProvider, NymTopology}; -pub use paths::{GatewayKeyMode, KeyMode, StoragePaths}; +pub use paths::StoragePaths; pub use socks5_client::Socks5MixnetClient; diff --git a/sdk/rust/nym-sdk/src/mixnet/client.rs b/sdk/rust/nym-sdk/src/mixnet/client.rs index f3d150ee67..4be51a5406 100644 --- a/sdk/rust/nym-sdk/src/mixnet/client.rs +++ b/sdk/rust/nym-sdk/src/mixnet/client.rs @@ -42,18 +42,18 @@ const DEFAULT_NUMBER_OF_SURBS: u32 = 5; pub struct MixnetClientBuilder { config: Config, storage_paths: Option, - // keys: Option, gateway_config: Option, socks5_config: Option, custom_topology_provider: Option>, - // TODO: change that - gateway_endpoint_path: Option, + // TODO: incorporate it properly into `MixnetClientStorage` (I will need it in wasm anyway) + gateway_endpoint_config_path: Option, storage: S, } impl MixnetClientBuilder { + /// Creates a client builder with ephemeral storage. #[must_use] pub fn new_ephemeral() -> Self { MixnetClientBuilder { @@ -80,7 +80,7 @@ impl MixnetClientBuilder { storage: storage_paths .initialise_default_persistent_storage() .await?, - gateway_endpoint_path: Some(storage_paths.gateway_endpoint_config), + gateway_endpoint_config_path: None, }) } } @@ -93,7 +93,7 @@ where S::ReplyStore: Send + Sync, ::StorageError: Send + Sync, { - #[deprecated(note = "add docs")] + /// Creates a client builder with the provided client storage implementation. #[must_use] pub fn new_with_storage(storage: S) -> MixnetClientBuilder { MixnetClientBuilder { @@ -102,12 +102,12 @@ where gateway_config: None, socks5_config: None, custom_topology_provider: None, - gateway_endpoint_path: None, + gateway_endpoint_config_path: None, storage, } } - #[deprecated(note = "add docs")] + /// Change the underlying storage implementation. #[must_use] pub fn set_storage(self, storage: T) -> MixnetClientBuilder { MixnetClientBuilder { @@ -116,12 +116,12 @@ where gateway_config: self.gateway_config, socks5_config: self.socks5_config, custom_topology_provider: self.custom_topology_provider, - gateway_endpoint_path: self.gateway_endpoint_path, + gateway_endpoint_config_path: self.gateway_endpoint_config_path, storage, } } - #[deprecated(note = "add docs")] + /// Change the underlying storage of this builder to use default implementation of on-disk persistence. #[must_use] pub fn set_default_storage( self, @@ -182,6 +182,12 @@ where self } + /// Use specified file for storing gateway configuration. + pub fn gateway_endpoint_config_path>(mut self, path: P) -> Self { + self.gateway_endpoint_config_path = Some(path.as_ref().to_owned()); + self + } + /// Construct a [`DisconnectedMixnetClient`] from the setup specified. pub async fn build(self) -> Result> { let mut client = DisconnectedMixnetClient::new( @@ -189,14 +195,10 @@ where self.socks5_config, self.storage, self.custom_topology_provider, - self.gateway_endpoint_path, + self.gateway_endpoint_config_path, ) .await?; - // if let Some(keys) = self.keys { - // client.set_keys(keys); - // } - // If we have a gateway config, we can move the client into a registered state. This will // fail if no gateway key is set. if let Some(gateway_config) = self.gateway_config { @@ -222,29 +224,27 @@ where /// Socks5 configuration socks5_config: Option, - // /// Paths for client keys, including identity, encryption, ack and shared gateway keys. - // storage_paths: Option, /// The client can be in one of multiple states, depending on how it is created and if it's /// connected to the mixnet. state: BuilderState, - // TODO: refactor storages + // TODO: refactor storages and combine everything into a single struct /// Controller of bandwidth credentials that the mixnet client can use to connect bandwidth_controller: Option, S::CredentialStore>>, /// The storage backend for reply-SURBs reply_storage_backend: S::ReplyStore, + /// The storage backend for cryptographic keys key_store: S::KeyStore, /// Keys handled by the client managed_keys: ManagedKeys, - // TODO: change that - gateway_endpoint_path: Option, + // TODO: incorporate it properly into `MixnetClientStorage` (I will need it in wasm anyway) + /// Path to optionally persist gateway configuration. Note that it's required if one were to use persistent keys. + gateway_endpoint_config_path: Option, - // /// Underlying storage specification to be used by the client. - // storage: S, /// Alternative provider of network topology used for constructing sphinx packets. custom_topology_provider: Option>, } @@ -257,13 +257,6 @@ where S::ReplyStore: Send + Sync, ::StorageError: Send + Sync, { - // /// Attempts to load previously generated cryptographic keys from the underlying storage. - // /// In case of failure, new set of keys will be generated. - // async fn initial_key_setup(key_store: &S::KeyStore) -> ManagedKeys { - // let mut rng = thread_rng(); - // ManagedKeys::load_or_generate(&mut rng, &key_store).await - // } - /// Create a new mixnet client in a disconnected state. The default configuration, /// creates a new mainnet client with ephemeral keys stored in RAM, which will be discarded at /// application close. @@ -276,10 +269,7 @@ where socks5_config: Option, storage: S, custom_topology_provider: Option>, - - // TODO: change that - gateway_endpoint_path: Option, - // gateway_config: &Option, + gateway_endpoint_config_path: Option, ) -> Result> { let (key_store, reply_storage_backend, credential_store) = storage.into_split(); @@ -294,27 +284,19 @@ where None }; - // // The reply storage backend is generic, and can be set by the caller/instantiator - // let reply_storage_backend = B::new(&config.debug_config, reply_surb_database_path) - // .await - // .map_err(|err| Error::ReplyStorageError { - // source: Box::new(err), - // })?; - let mut rng = thread_rng(); let managed_keys = ManagedKeys::load_or_generate(&mut rng, &key_store).await; Ok(DisconnectedMixnetClient { config, socks5_config, - // storage_paths: None, state: BuilderState::New, reply_storage_backend, key_store, bandwidth_controller, custom_topology_provider, managed_keys, - gateway_endpoint_path, + gateway_endpoint_config_path, }) } @@ -335,22 +317,13 @@ where matches!(self.managed_keys, ManagedKeys::FullyDerived(..)) } - // /// Sets the keys of this [`MixnetClientBuilder`]. - // fn set_keys(&mut self, keys: Keys) { - // self.key_manager.set_identity_keypair(keys.identity_keypair); - // self.key_manager - // .set_encryption_keypair(keys.encryption_keypair); - // self.key_manager.set_ack_key(keys.ack_key); - // - // self.key_manager - // .insert_gateway_shared_key(Arc::new(keys.gateway_shared_key)); - // } - // - // /// Returns the keys of this [`DisconnectedMixnetClient`]. Client keys are always available - // /// since if none are specified at creation time, new random ones are generated. - // pub fn get_keys(&self) -> KeysArc { - // KeysArc::from(&self.key_manager) - // } + fn remove_gateway_key(&mut self) { + assert!(self.has_gateway_key()); + let ManagedKeys::FullyDerived(keys) = std::mem::replace(&mut self.managed_keys, ManagedKeys::Invalidated) else { + unreachable!() + }; + self.managed_keys = ManagedKeys::Initial(keys.remove_gateway_key()) + } /// Sets the gateway endpoint of this [`MixnetClientBuilder`]. /// @@ -474,13 +447,17 @@ where if matches!(self.state, BuilderState::New) { let already_registered = self.has_gateway_key(); if already_registered { - if let Some(gateway_endpoint_path) = self.gateway_endpoint_path.clone() { + if let Some(gateway_endpoint_path) = self.gateway_endpoint_config_path.clone() { self.read_gateway_endpoint_config(gateway_endpoint_path)?; + } else if !self.config.key_mode.is_keep() { + // if we don't have gateway configuration available and we're not keeping the keys, + // purge them + self.remove_gateway_key(); } } else { // TODO: that is redundant since the base client will perform gateway registration self.register_and_authenticate_gateway().await?; - if let Some(gateway_endpoint_path) = &self.gateway_endpoint_path { + if let Some(gateway_endpoint_path) = &self.gateway_endpoint_config_path { self.write_gateway_endpoint_config(gateway_endpoint_path)?; } } @@ -536,7 +513,7 @@ where /// async fn main() { /// let receiving_client = mixnet::MixnetClient::connect_new().await.unwrap(); /// let socks5_config = mixnet::Socks5::new(receiving_client.nym_address().to_string()); - /// let client = mixnet::MixnetClientBuilder::new() + /// let client = mixnet::MixnetClientBuilder::new_ephemeral() /// .socks5_config(socks5_config) /// .build() /// .await @@ -604,7 +581,7 @@ where /// /// #[tokio::main] /// async fn main() { - /// let client = mixnet::MixnetClientBuilder::new() + /// let client = mixnet::MixnetClientBuilder::new_ephemeral() /// .build() /// .await /// .unwrap(); diff --git a/sdk/rust/nym-sdk/src/mixnet/config.rs b/sdk/rust/nym-sdk/src/mixnet/config.rs index 5c2ff15914..3945b7b7f3 100644 --- a/sdk/rust/nym-sdk/src/mixnet/config.rs +++ b/sdk/rust/nym-sdk/src/mixnet/config.rs @@ -1,12 +1,30 @@ use nym_client_core::config::DebugConfig; use nym_network_defaults::NymNetworkDetails; +#[derive(Clone, Debug, Default)] +pub enum KeyMode { + /// Use existing key files if they exists, otherwise create new ones. + #[default] + Keep, + /// Create new keys, overwriting any potential previously existing keys. + Overwrite, +} + +impl KeyMode { + pub(crate) fn is_keep(&self) -> bool { + matches!(self, KeyMode::Keep) + } +} + /// Config struct for [`crate::mixnet::MixnetClient`] #[derive(Default)] pub struct Config { /// If the user has explicitly specified a gateway. pub user_chosen_gateway: Option, + /// Determines how to handle existing key files found. + pub key_mode: KeyMode, + /// The details of the network we're using. It defaults to the mainnet network. pub network_details: NymNetworkDetails, diff --git a/sdk/rust/nym-sdk/src/mixnet/keys.rs b/sdk/rust/nym-sdk/src/mixnet/keys.rs deleted file mode 100644 index 35933b70b5..0000000000 --- a/sdk/rust/nym-sdk/src/mixnet/keys.rs +++ /dev/null @@ -1,68 +0,0 @@ -use std::sync::Arc; - -use nym_client_core::client::key_manager::KeyManager; -use nym_crypto::asymmetric::{encryption, identity}; -use nym_gateway_requests::registration::handshake::SharedKeys; -use nym_sphinx::acknowledgements::AckKey; - -/// The set of keys used by the client. Identity, encryption and ack keys are generated at creating -/// unless specified to loaded from storage or somehow explictly specified. The gateway shared key -/// is generated when registering with a gateway. -pub struct Keys { - /// The identity key of the client. - pub identity_keypair: identity::KeyPair, - /// The encryption key of the client. - pub encryption_keypair: encryption::KeyPair, - /// The ack key used by the client. - pub ack_key: AckKey, - - /// The gateway shared key that is obtained after registering with a gateway. - pub gateway_shared_key: SharedKeys, -} - -/// The set of keys used by the client, but where each key is stored in an [`std::sync::Arc`] for -/// easy cloning. -pub struct KeysArc { - /// The identity key of the client. - pub identity_keypair: Arc, - /// The encryption key of the client. - pub encryption_keypair: Arc, - /// The ack key used by the client. - pub ack_key: Arc, - - /// The gateway shared key that is obtained after registering with a gateway. - pub gateway_shared_key: Arc, -} - -impl From for KeyManager { - fn from(keys: Keys) -> Self { - KeyManager::from_keys( - keys.identity_keypair, - keys.encryption_keypair, - keys.gateway_shared_key, - keys.ack_key, - ) - } -} - -impl From for KeysArc { - fn from(keys: Keys) -> Self { - KeysArc { - identity_keypair: keys.identity_keypair.into(), - encryption_keypair: keys.encryption_keypair.into(), - ack_key: keys.ack_key.into(), - gateway_shared_key: keys.gateway_shared_key.into(), - } - } -} - -impl From<&KeyManager> for KeysArc { - fn from(key_manager: &KeyManager) -> Self { - KeysArc { - identity_keypair: key_manager.identity_keypair(), - encryption_keypair: key_manager.encryption_keypair(), - ack_key: key_manager.ack_key(), - gateway_shared_key: key_manager.gateway_shared_key(), - } - } -} diff --git a/sdk/rust/nym-sdk/src/mixnet/paths.rs b/sdk/rust/nym-sdk/src/mixnet/paths.rs index 4e3994865d..55ca735c08 100644 --- a/sdk/rust/nym-sdk/src/mixnet/paths.rs +++ b/sdk/rust/nym-sdk/src/mixnet/paths.rs @@ -10,46 +10,19 @@ use nym_client_core::config::persistence::key_pathfinder::ClientKeyPathfinder; use nym_credential_storage::persistent_storage::PersistentStorage as PersistentCredentialStorage; use std::path::{Path, PathBuf}; -#[derive(Clone, Debug)] -pub enum KeyMode { - /// Use existing key files if they exists, otherwise create new ones. - Keep, - /// Create new keys, overwriting any potential previously existing keys. - Overwrite, -} - -impl KeyMode { - pub(crate) fn is_keep(&self) -> bool { - matches!(self, KeyMode::Keep) - } -} - -pub enum GatewayKeyMode { - /// Keep shared gateway key if found, otherwise create a new one. - Keep, - /// Create a new shared key and overwrite any potential existing one. - Overwrite, -} - -impl GatewayKeyMode { - pub(crate) fn is_keep(&self) -> bool { - matches!(self, GatewayKeyMode::Keep) - } -} - /// Set of storage paths that the client will use if it is setup to persist keys, credentials, and /// reply-SURBs. #[derive(Clone, Debug)] pub struct StoragePaths { - // /// Determines how to handle existing key files found. - // pub operating_mode: KeyMode, /// Client private identity key pub private_identity: PathBuf, + /// Client public identity key pub public_identity: PathBuf, /// Client private encryption key pub private_encryption: PathBuf, + /// Client public encryption key pub public_encryption: PathBuf, @@ -59,9 +32,6 @@ pub struct StoragePaths { /// Key setup after authenticating with a gateway pub gateway_shared_key: PathBuf, - /// The key isn't much use without knowing which entity it refers to. - pub gateway_endpoint_config: PathBuf, - /// The database containing credentials pub credential_database_path: PathBuf, @@ -76,28 +46,24 @@ impl StoragePaths { /// /// This function will return an error if it is passed a path to an existing file instead of a /// directory. - pub fn new_from_dir(operating_mode: KeyMode, dir: &Path) -> Result { + pub fn new_from_dir(dir: &Path) -> Result { if dir.is_file() { return Err(Error::ExpectedDirectory(dir.to_owned())); } Ok(Self { - // These filenames were chosen to match the ones we use in `nym-client`. Consider - // changing the defaults - // operating_mode, private_identity: dir.join("private_identity.pem"), public_identity: dir.join("public_identity.pem"), private_encryption: dir.join("private_encryption.pem"), public_encryption: dir.join("public_encryption.pem"), ack_key: dir.join("ack_key.pem"), gateway_shared_key: dir.join("gateway_shared.pem"), - gateway_endpoint_config: dir.join("gateway_endpoint_config.toml"), credential_database_path: dir.join("db.sqlite"), reply_surb_database_path: dir.join("persistent_reply_store.sqlite"), }) } - #[deprecated(note = "add docs")] + /// Instantiates default full client storage backend with default configuration. pub async fn initialise_default_persistent_storage( &self, ) -> Result { @@ -108,7 +74,7 @@ impl StoragePaths { )) } - #[deprecated(note = "add docs")] + /// Instantiates default full client storage backend with the provided configuration. pub async fn initialise_persistent_storage( &self, config: &config::DebugConfig, @@ -121,7 +87,7 @@ impl StoragePaths { )) } - #[deprecated(note = "add docs")] + /// Instantiates default coconut credential storage. pub async fn persistent_credential_storage( &self, ) -> Result { @@ -132,11 +98,12 @@ impl StoragePaths { }) } - #[deprecated(note = "add docs")] + /// Instantiates default reply surb storage backend with default configuration. pub async fn default_persistent_fs_reply_backend(&self) -> Result { self.persistent_fs_reply_backend(&Default::default()).await } + /// Instantiates default reply surb storage backend with the provided metadata config. pub async fn persistent_fs_reply_backend( &self, surb_config: &config::ReplySurbs, @@ -148,13 +115,12 @@ impl StoragePaths { .await?) } - #[deprecated(note = "add docs")] + /// Instantiates default persistent key storage. pub fn on_disk_key_storage_spec(&self) -> OnDiskKeys { OnDiskKeys::new(self.client_key_pathfinder()) } - #[deprecated(note = "add docs")] - pub fn client_key_pathfinder(&self) -> ClientKeyPathfinder { + fn client_key_pathfinder(&self) -> ClientKeyPathfinder { ClientKeyPathfinder { identity_private_key: self.private_identity.clone(), identity_public_key: self.public_identity.clone(), @@ -175,14 +141,12 @@ impl From for ClientKeyPathfinder { impl From<&nym_client_core::config::Config> for StoragePaths { fn from(value: &nym_client_core::config::Config) -> Self { Self { - // operating_mode: KeyMode::Keep, private_identity: value.get_private_identity_key_file(), public_identity: value.get_public_identity_key_file(), private_encryption: value.get_private_encryption_key_file(), public_encryption: value.get_public_encryption_key_file(), ack_key: value.get_ack_key_file(), gateway_shared_key: value.get_gateway_shared_key_file(), - gateway_endpoint_config: Default::default(), credential_database_path: value.get_database_path(), reply_surb_database_path: value.get_reply_surb_database_path(), } diff --git a/sdk/rust/nym-sdk/src/mixnet/socks5_client.rs b/sdk/rust/nym-sdk/src/mixnet/socks5_client.rs index 3999b5f7c1..7d1e277f12 100644 --- a/sdk/rust/nym-sdk/src/mixnet/socks5_client.rs +++ b/sdk/rust/nym-sdk/src/mixnet/socks5_client.rs @@ -41,7 +41,7 @@ impl Socks5MixnetClient { /// /// ``` pub async fn connect_new>(provider_mix_address: S) -> Result { - MixnetClientBuilder::new() + MixnetClientBuilder::new_ephemeral() .socks5_config(Socks5::new(provider_mix_address)) .build() .await?