diff --git a/Cargo.lock b/Cargo.lock index 98a70afd7b..e0f32dda3d 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -4404,6 +4404,7 @@ dependencies = [ "nym-pemstore", "nym-sphinx-addressing", "nym-sphinx-params", + "nym-sphinx-routing", "nym-sphinx-types", "nym-topology", "rand 0.7.3", @@ -4431,6 +4432,7 @@ dependencies = [ "nym-crypto", "nym-sphinx-addressing", "nym-sphinx-params", + "nym-sphinx-routing", "nym-sphinx-types", "nym-topology", "rand 0.7.3", @@ -4462,6 +4464,7 @@ dependencies = [ "nym-sphinx-chunking", "nym-sphinx-forwarding", "nym-sphinx-params", + "nym-sphinx-routing", "nym-sphinx-types", "nym-topology", "rand 0.7.3", diff --git a/clients/webassembly/Cargo.lock b/clients/webassembly/Cargo.lock index c7792f6697..e87614acf9 100644 --- a/clients/webassembly/Cargo.lock +++ b/clients/webassembly/Cargo.lock @@ -2240,7 +2240,7 @@ dependencies = [ [[package]] name = "nym-bin-common" -version = "0.5.0" +version = "0.6.0" dependencies = [ "atty", "clap", @@ -2255,7 +2255,7 @@ dependencies = [ [[package]] name = "nym-client-core" -version = "1.1.14" +version = "1.1.15" dependencies = [ "async-trait", "base64 0.21.2", @@ -2300,7 +2300,7 @@ dependencies = [ [[package]] name = "nym-client-wasm" -version = "1.1.0" +version = "1.1.1" dependencies = [ "anyhow", "async-trait", @@ -2884,6 +2884,7 @@ dependencies = [ "nym-service-provider-directory-common", "nym-vesting-contract", "nym-vesting-contract-common", + "openssl", "prost", "reqwest", "serde", @@ -2974,6 +2975,15 @@ version = "0.1.5" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "ff011a302c396a5197692431fc1948019154afc178baf7d8e37367442a4601cf" +[[package]] +name = "openssl-src" +version = "111.26.0+1.1.1u" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "efc62c9f12b22b8f5208c23a7200a442b2e5999f8bdf80233852122b5a4f6f37" +dependencies = [ + "cc", +] + [[package]] name = "openssl-sys" version = "0.9.87" @@ -2982,6 +2992,7 @@ checksum = "8e17f59264b2809d77ae94f0e1ebabc434773f370d6ca667bd223ea10e06cc7e" dependencies = [ "cc", "libc", + "openssl-src", "pkg-config", "vcpkg", ] diff --git a/common/nymsphinx/acknowledgements/Cargo.toml b/common/nymsphinx/acknowledgements/Cargo.toml index a54f3d6fd0..95b3d8b30c 100644 --- a/common/nymsphinx/acknowledgements/Cargo.toml +++ b/common/nymsphinx/acknowledgements/Cargo.toml @@ -15,11 +15,12 @@ thiserror = { workspace = true } zeroize = { workspace = true } nym-crypto = { path = "../../crypto", features = ["symmetric", "rand"] } +nym-pemstore = { path = "../../pemstore" } nym-sphinx-addressing = { path = "../addressing" } nym-sphinx-params = { path = "../params" } +nym-sphinx-routing = { path = "../routing" } nym-sphinx-types = { path = "../types" } -nym-pemstore = { path = "../../pemstore" } nym-topology = { path = "../../topology" } [features] -serde = ["serde_crate", "generic-array"] \ No newline at end of file +serde = ["serde_crate", "generic-array"] diff --git a/common/nymsphinx/acknowledgements/src/surb_ack.rs b/common/nymsphinx/acknowledgements/src/surb_ack.rs index 6fb5b26c18..e623d4e738 100644 --- a/common/nymsphinx/acknowledgements/src/surb_ack.rs +++ b/common/nymsphinx/acknowledgements/src/surb_ack.rs @@ -9,7 +9,7 @@ use nym_sphinx_addressing::nodes::{ }; use nym_sphinx_params::packet_sizes::PacketSize; use nym_sphinx_params::{PacketType, DEFAULT_NUM_MIX_HOPS}; -use nym_sphinx_types::delays::{self, Delay}; +use nym_sphinx_types::delays::Delay; use nym_sphinx_types::{NymPacket, NymPacketError, MIN_PACKET_SIZE}; use nym_topology::{NymTopology, NymTopologyError}; use rand::{CryptoRng, RngCore}; @@ -51,7 +51,7 @@ impl SurbAck { { let route = topology.random_route_to_gateway(rng, DEFAULT_NUM_MIX_HOPS, recipient.gateway())?; - let delays = delays::generate_from_average_duration(route.len(), average_delay); + let delays = nym_sphinx_routing::generate_hop_delays(average_delay, route.len()); let destination = recipient.as_sphinx_destination(); let surb_ack_payload = prepare_identifier(rng, ack_key, marshaled_fragment_id); diff --git a/common/nymsphinx/anonymous-replies/Cargo.toml b/common/nymsphinx/anonymous-replies/Cargo.toml index 39d16f0b50..49367da152 100644 --- a/common/nymsphinx/anonymous-replies/Cargo.toml +++ b/common/nymsphinx/anonymous-replies/Cargo.toml @@ -16,6 +16,7 @@ thiserror = "1" nym-crypto = { path = "../../crypto", features = ["symmetric", "rand"] } nym-sphinx-addressing = { path = "../addressing" } nym-sphinx-params = { path = "../params" } +nym-sphinx-routing = { path = "../routing" } nym-sphinx-types = { path = "../types" } nym-topology = { path = "../../topology" } diff --git a/common/nymsphinx/anonymous-replies/src/reply_surb.rs b/common/nymsphinx/anonymous-replies/src/reply_surb.rs index 82fc8ea573..877e83023d 100644 --- a/common/nymsphinx/anonymous-replies/src/reply_surb.rs +++ b/common/nymsphinx/anonymous-replies/src/reply_surb.rs @@ -7,7 +7,7 @@ use nym_sphinx_addressing::clients::Recipient; use nym_sphinx_addressing::nodes::{NymNodeRoutingAddress, MAX_NODE_ADDRESS_UNPADDED_LEN}; use nym_sphinx_params::packet_sizes::PacketSize; use nym_sphinx_params::{PacketType, ReplySurbKeyDigestAlgorithm, DEFAULT_NUM_MIX_HOPS}; -use nym_sphinx_types::{delays, NymPacket, SURBMaterial, SphinxError, SURB}; +use nym_sphinx_types::{NymPacket, SURBMaterial, SphinxError, SURB}; use nym_topology::{NymTopology, NymTopologyError}; use rand::{CryptoRng, RngCore}; use serde::de::{Error as SerdeError, Visitor}; @@ -96,7 +96,7 @@ impl ReplySurb { { let route = topology.random_route_to_gateway(rng, DEFAULT_NUM_MIX_HOPS, recipient.gateway())?; - let delays = delays::generate_from_average_duration(route.len(), average_delay); + let delays = nym_sphinx_routing::generate_hop_delays(average_delay, route.len()); let destination = recipient.as_sphinx_destination(); let surb_material = SURBMaterial::new(route, delays, destination); diff --git a/common/nymsphinx/cover/Cargo.toml b/common/nymsphinx/cover/Cargo.toml index f1558d3676..e700327c93 100644 --- a/common/nymsphinx/cover/Cargo.toml +++ b/common/nymsphinx/cover/Cargo.toml @@ -15,7 +15,8 @@ nym-crypto = { path = "../../crypto" } nym-sphinx-acknowledgements = { path = "../acknowledgements" } nym-sphinx-addressing = { path = "../addressing" } nym-sphinx-chunking = { path = "../chunking" } -nym-sphinx-params = { path = "../params" } nym-sphinx-forwarding = { path = "../forwarding" } +nym-sphinx-params = { path = "../params" } +nym-sphinx-routing = { path = "../routing" } nym-sphinx-types = { path = "../types" } nym-topology = { path = "../../topology" } diff --git a/common/nymsphinx/cover/src/lib.rs b/common/nymsphinx/cover/src/lib.rs index bd2714c3ac..05f4cffe33 100644 --- a/common/nymsphinx/cover/src/lib.rs +++ b/common/nymsphinx/cover/src/lib.rs @@ -13,7 +13,7 @@ use nym_sphinx_params::packet_sizes::PacketSize; use nym_sphinx_params::{ PacketEncryptionAlgorithm, PacketHkdfAlgorithm, PacketType, DEFAULT_NUM_MIX_HOPS, }; -use nym_sphinx_types::{delays, NymPacket}; +use nym_sphinx_types::NymPacket; use nym_topology::{NymTopology, NymTopologyError}; use rand::{CryptoRng, RngCore}; use std::convert::TryFrom; @@ -120,7 +120,7 @@ where let route = topology.random_route_to_gateway(rng, DEFAULT_NUM_MIX_HOPS, full_address.gateway())?; - let delays = delays::generate_from_average_duration(route.len(), average_packet_delay); + let delays = nym_sphinx_routing::generate_hop_delays(average_packet_delay, route.len()); let destination = full_address.as_sphinx_destination(); let first_hop_address = diff --git a/common/nymsphinx/routing/src/lib.rs b/common/nymsphinx/routing/src/lib.rs index a7067f252c..e8881b409d 100644 --- a/common/nymsphinx/routing/src/lib.rs +++ b/common/nymsphinx/routing/src/lib.rs @@ -1,8 +1,10 @@ // Copyright 2023 - Nym Technologies SA // SPDX-License-Identifier: Apache-2.0 +use std::time::Duration; + use nym_sphinx_addressing::clients::Recipient; -use nym_sphinx_types::Node; +use nym_sphinx_types::{delays, Delay, Node}; use thiserror::Error; pub trait SphinxRouteMaker { @@ -41,3 +43,11 @@ impl SphinxRouteMaker for Vec { } } } + +pub fn generate_hop_delays(average_packet_delay: Duration, num_hops: usize) -> Vec { + if average_packet_delay.is_zero() { + vec![nym_sphinx_types::Delay::new_from_millis(0); num_hops] + } else { + delays::generate_from_average_duration(num_hops, average_packet_delay) + } +} diff --git a/common/nymsphinx/src/preparer/mod.rs b/common/nymsphinx/src/preparer/mod.rs index e97a9d011f..64b8de3ae4 100644 --- a/common/nymsphinx/src/preparer/mod.rs +++ b/common/nymsphinx/src/preparer/mod.rs @@ -14,7 +14,7 @@ use nym_sphinx_chunking::fragment::{Fragment, FragmentIdentifier}; use nym_sphinx_forwarding::packet::MixPacket; use nym_sphinx_params::packet_sizes::PacketSize; use nym_sphinx_params::{PacketType, ReplySurbKeyDigestAlgorithm, DEFAULT_NUM_MIX_HOPS}; -use nym_sphinx_types::{delays, Delay, NymPacket}; +use nym_sphinx_types::{Delay, NymPacket}; use nym_topology::{NymTopology, NymTopologyError}; use rand::{CryptoRng, Rng}; use std::convert::TryFrom; @@ -233,7 +233,7 @@ pub trait FragmentPreparer { // including set of delays let delays = - delays::generate_from_average_duration(route.len(), self.average_packet_delay()); + nym_sphinx_routing::generate_hop_delays(self.average_packet_delay(), route.len()); // create the actual sphinx packet here. With valid route and correct payload size, // there's absolutely no reason for this call to fail. diff --git a/nym-connect/desktop/Cargo.lock b/nym-connect/desktop/Cargo.lock index a3e407020a..e15065fe12 100644 --- a/nym-connect/desktop/Cargo.lock +++ b/nym-connect/desktop/Cargo.lock @@ -3220,7 +3220,7 @@ dependencies = [ [[package]] name = "nym-bin-common" -version = "0.5.0" +version = "0.6.0" dependencies = [ "atty", "clap", @@ -3235,7 +3235,7 @@ dependencies = [ [[package]] name = "nym-client-core" -version = "1.1.14" +version = "1.1.15" dependencies = [ "async-trait", "base64 0.21.2", @@ -3365,6 +3365,7 @@ dependencies = [ "nym-credential-storage", "nym-crypto", "nym-socks5-client-core", + "nym-sphinx", "nym-task", "pretty_env_logger", "rand 0.8.5", @@ -3906,6 +3907,7 @@ dependencies = [ "nym-service-provider-directory-common", "nym-vesting-contract", "nym-vesting-contract-common", + "openssl", "prost", "reqwest", "serde", @@ -4045,6 +4047,15 @@ version = "0.1.5" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "ff011a302c396a5197692431fc1948019154afc178baf7d8e37367442a4601cf" +[[package]] +name = "openssl-src" +version = "111.26.0+1.1.1u" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "efc62c9f12b22b8f5208c23a7200a442b2e5999f8bdf80233852122b5a4f6f37" +dependencies = [ + "cc", +] + [[package]] name = "openssl-sys" version = "0.9.82" @@ -4054,6 +4065,7 @@ dependencies = [ "autocfg", "cc", "libc", + "openssl-src", "pkg-config", "vcpkg", ] diff --git a/nym-connect/desktop/src-tauri/Cargo.toml b/nym-connect/desktop/src-tauri/Cargo.toml index a27c6ccc55..13324c003c 100644 --- a/nym-connect/desktop/src-tauri/Cargo.toml +++ b/nym-connect/desktop/src-tauri/Cargo.toml @@ -53,6 +53,7 @@ nym-crypto = { path = "../../../common/crypto" } nym-credential-storage = { path = "../../../common/credential-storage" } nym-bin-common = { path = "../../../common/bin-common"} nym-socks5-client-core = { path = "../../../common/socks5-client-core" } +nym-sphinx = { path = "../../../common/nymsphinx" } nym-task = { path = "../../../common/task" } [dev-dependencies] diff --git a/nym-connect/desktop/src-tauri/src/main.rs b/nym-connect/desktop/src-tauri/src/main.rs index aef1f08fae..3ea171f279 100644 --- a/nym-connect/desktop/src-tauri/src/main.rs +++ b/nym-connect/desktop/src-tauri/src/main.rs @@ -25,6 +25,11 @@ mod tasks; mod window; fn main() { + if std::env::var("NYM_CONNECT_ENABLE_MEDIUM").is_ok() { + std::env::set_var("NYM_CONNECT_DISABLE_COVER", "1"); + std::env::set_var("NYM_CONNECT_ENABLE_MIXED_SIZE_PACKETS", "1"); + std::env::set_var("NYM_CONNECT_DISABLE_PER_HOP_DELAYS", "1"); + } setup_env(None); println!("Starting up..."); diff --git a/nym-connect/desktop/src-tauri/src/tasks.rs b/nym-connect/desktop/src-tauri/src/tasks.rs index 9e70500dd0..1645bb5b60 100644 --- a/nym-connect/desktop/src-tauri/src/tasks.rs +++ b/nym-connect/desktop/src-tauri/src/tasks.rs @@ -4,8 +4,10 @@ use nym_client_core::client::base_client::storage::{MixnetClientStorage, OnDiskP use nym_client_core::{config::GatewayEndpointConfig, error::ClientCoreStatusMessage}; use nym_socks5_client_core::NymClient as Socks5NymClient; use nym_socks5_client_core::Socks5ControlMessageSender; +use nym_sphinx::params::PacketSize; use nym_task::manager::TaskStatus; use std::sync::Arc; +use std::time::Duration; use tap::TapFallible; use tokio::sync::RwLock; @@ -39,7 +41,7 @@ pub async fn start_nym_socks5_client( GatewayEndpointConfig, )> { log::info!("Loading config from file: {id}"); - let config = Config::read_from_default_path(id) + let mut config = Config::read_from_default_path(id) .tap_err(|_| log::warn!("Failed to load configuration file"))?; let storage = @@ -53,6 +55,21 @@ pub async fn start_nym_socks5_client( .expect("failed to load gateway details") .into(); + // Disable both the loop cover traffic that runs in the background as well as the Poisson + // process that injects cover traffic into the traffic stream. + if std::env::var("NYM_CONNECT_DISABLE_COVER").is_ok() { + config.core.base.set_no_cover_traffic(); + } + + if std::env::var("NYM_CONNECT_ENABLE_MIXED_SIZE_PACKETS").is_ok() { + config.core.base.debug.traffic.secondary_packet_size = Some(PacketSize::ExtendedPacket16); + } + + if std::env::var("NYM_CONNECT_DISABLE_PER_HOP_DELAY").is_ok() { + config.core.base.debug.traffic.average_packet_delay = Duration::ZERO; + config.core.base.debug.acknowledgements.average_ack_delay = Duration::ZERO; + } + log::info!("Starting socks5 client"); // Channel to send control messages to the socks5 client diff --git a/nym-wallet/Cargo.lock b/nym-wallet/Cargo.lock index 218ce62300..70502fc84a 100644 --- a/nym-wallet/Cargo.lock +++ b/nym-wallet/Cargo.lock @@ -2915,7 +2915,7 @@ dependencies = [ [[package]] name = "nym-bin-common" -version = "0.5.0" +version = "0.6.0" dependencies = [ "atty", "clap", @@ -3220,6 +3220,7 @@ dependencies = [ "nym-service-provider-directory-common", "nym-vesting-contract", "nym-vesting-contract-common", + "openssl", "prost", "reqwest", "serde", @@ -3297,7 +3298,7 @@ dependencies = [ [[package]] name = "nym_wallet" -version = "1.2.4" +version = "1.2.5" dependencies = [ "async-trait", "base64 0.13.1", @@ -3447,6 +3448,15 @@ version = "0.1.5" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "ff011a302c396a5197692431fc1948019154afc178baf7d8e37367442a4601cf" +[[package]] +name = "openssl-src" +version = "111.26.0+1.1.1u" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "efc62c9f12b22b8f5208c23a7200a442b2e5999f8bdf80233852122b5a4f6f37" +dependencies = [ + "cc", +] + [[package]] name = "openssl-sys" version = "0.9.80" @@ -3456,6 +3466,7 @@ dependencies = [ "autocfg", "cc", "libc", + "openssl-src", "pkg-config", "vcpkg", ]