From aedacf6c6544c4c59d337ef1575dc08af3030ab8 Mon Sep 17 00:00:00 2001 From: pierre Date: Thu, 27 Jul 2023 11:08:24 +0200 Subject: [PATCH 01/21] ci: fix release strapi actions --- .github/workflows/nym-connect-publish-macos.yml | 4 ++-- .github/workflows/nym-connect-publish-ubuntu.yml | 5 +++-- .github/workflows/nym-connect-publish-windows10.yml | 4 ++-- .github/workflows/nym-wallet-publish-macos.yml | 4 ++-- .github/workflows/nym-wallet-publish-ubuntu.yml | 4 ++-- .github/workflows/nym-wallet-publish-windows10.yml | 4 ++-- 6 files changed, 13 insertions(+), 12 deletions(-) diff --git a/.github/workflows/nym-connect-publish-macos.yml b/.github/workflows/nym-connect-publish-macos.yml index 45dac7e87a..a4176eb285 100644 --- a/.github/workflows/nym-connect-publish-macos.yml +++ b/.github/workflows/nym-connect-publish-macos.yml @@ -19,7 +19,7 @@ jobs: outputs: release_id: ${{ steps.create-release.outputs.id }} - release_date: ${{ fromJSON(steps.create-release.outputs.assets)[0].created_at }} + release_date: ${{ fromJSON(steps.create-release.outputs.assets)[0].published_at }} version: ${{ steps.release-info.outputs.version }} filename: ${{ steps.release-info.outputs.filename }} file_hash: ${{ steps.release-info.outputs.file_hash }} @@ -118,7 +118,7 @@ jobs: ref=${{ github.ref_name }} semver="${ref##nym-connect-}" && semver="${semver##v}" echo "version=${semver}" >> "$GITHUB_OUTPUT" - echo "filename=nym-connect_${version}_x64_en-US.msi" >> "$GITHUB_OUTPUT" + echo "filename=nym-connect_${semver}_x64_en-US.msi" >> "$GITHUB_OUTPUT" echo "file_hash=${{ hashFiles('nym-connect/desktop/target/release/bundle/dmg/nym-connect_*_x64.dmg') }}" >> "$GITHUB_OUTPUT" push-release-data: diff --git a/.github/workflows/nym-connect-publish-ubuntu.yml b/.github/workflows/nym-connect-publish-ubuntu.yml index cc5e1f3f00..caec73b10a 100644 --- a/.github/workflows/nym-connect-publish-ubuntu.yml +++ b/.github/workflows/nym-connect-publish-ubuntu.yml @@ -19,7 +19,7 @@ jobs: outputs: release_id: ${{ steps.create-release.outputs.id }} - release_date: ${{ fromJSON(steps.create-release.outputs.assets)[0].created_at }} + release_date: ${{ fromJSON(steps.create-release.outputs.assets)[0].published_at }} version: ${{ steps.release-info.outputs.version }} filename: ${{ steps.release-info.outputs.filename }} file_hash: ${{ steps.release-info.outputs.file_hash }} @@ -85,8 +85,9 @@ jobs: ref=${{ github.ref_name }} semver="${ref##nym-connect-}" && semver="${semver##v}" echo "version=${semver}" >> "$GITHUB_OUTPUT" - echo "filename=nym-connect_${version}_amd64.AppImage" >> "$GITHUB_OUTPUT" + echo "filename=nym-connect_${semver}_amd64.AppImage" >> "$GITHUB_OUTPUT" echo "file_hash=${{ hashFiles('nym-connect/desktop/target/release/bundle/appimage/nym-connect_*_amd64.AppImage') }}" >> "$GITHUB_OUTPUT" + push-release-data: if: ${{ (startsWith(github.ref, 'refs/tags/nym-connect-') && github.event_name == 'release') || github.event_name == 'workflow_dispatch' }} uses: ./.github/workflows/push-release-data.yml diff --git a/.github/workflows/nym-connect-publish-windows10.yml b/.github/workflows/nym-connect-publish-windows10.yml index 1b4b1be2cc..aeb04dc872 100644 --- a/.github/workflows/nym-connect-publish-windows10.yml +++ b/.github/workflows/nym-connect-publish-windows10.yml @@ -19,7 +19,7 @@ jobs: outputs: release_id: ${{ steps.create-release.outputs.id }} - release_date: ${{ fromJSON(steps.create-release.outputs.assets)[0].created_at }} + release_date: ${{ fromJSON(steps.create-release.outputs.assets)[0].published_at }} version: ${{ steps.release-info.outputs.version }} filename: ${{ steps.release-info.outputs.filename }} file_hash: ${{ steps.release-info.outputs.file_hash }} @@ -104,7 +104,7 @@ jobs: ref=${{ github.ref_name }} semver="${ref##nym-connect-}" && semver="${semver##v}" echo "version=${semver}" >> "$GITHUB_OUTPUT" - echo "filename=nym-connect_${version}_x64_en-US.msi" >> "$GITHUB_OUTPUT" + echo "filename=nym-connect_${semver}_x64_en-US.msi" >> "$GITHUB_OUTPUT" echo "file_hash=${{ hashFiles('nym-connect/desktop/target/release/bundle/msi/nym-connect_*_x64_en-US.msi') }}" >> "$GITHUB_OUTPUT" push-release-data: diff --git a/.github/workflows/nym-wallet-publish-macos.yml b/.github/workflows/nym-wallet-publish-macos.yml index 408a3b7406..5db06a8f52 100644 --- a/.github/workflows/nym-wallet-publish-macos.yml +++ b/.github/workflows/nym-wallet-publish-macos.yml @@ -19,7 +19,7 @@ jobs: outputs: release_id: ${{ steps.create-release.outputs.id }} - release_date: ${{ fromJSON(steps.create-release.outputs.assets)[0].created_at }} + release_date: ${{ fromJSON(steps.create-release.outputs.assets)[0].published_at }} version: ${{ steps.release-info.outputs.version }} filename: ${{ steps.release-info.outputs.filename }} file_hash: ${{ steps.release-info.outputs.file_hash }} @@ -106,7 +106,7 @@ jobs: ref=${{ github.ref_name }} semver="${ref##nym-wallet-}" && semver="${semver##v}" echo "version=${semver}" >> "$GITHUB_OUTPUT" - echo "filename=nym-wallet_${version}_x64.dmg" >> "$GITHUB_OUTPUT" + echo "filename=nym-wallet_${semver}_x64.dmg" >> "$GITHUB_OUTPUT" echo "file_hash=${{ hashFiles('nym-wallet/target/release/bundle/dmg/nym-wallet_*_x64.dmg') }}" >> "$GITHUB_OUTPUT" push-release-data: diff --git a/.github/workflows/nym-wallet-publish-ubuntu.yml b/.github/workflows/nym-wallet-publish-ubuntu.yml index 9e9ee904cd..52887950fa 100644 --- a/.github/workflows/nym-wallet-publish-ubuntu.yml +++ b/.github/workflows/nym-wallet-publish-ubuntu.yml @@ -19,7 +19,7 @@ jobs: outputs: release_id: ${{ steps.create-release.outputs.id }} - release_date: ${{ fromJSON(steps.create-release.outputs.assets)[0].created_at }} + release_date: ${{ fromJSON(steps.create-release.outputs.assets)[0].published_at }} version: ${{ steps.release-info.outputs.version }} filename: ${{ steps.release-info.outputs.filename }} file_hash: ${{ steps.release-info.outputs.file_hash }} @@ -83,7 +83,7 @@ jobs: ref=${{ github.ref_name }} semver="${ref##nym-wallet-}" && semver="${semver##v}" echo "version=${semver}" >> "$GITHUB_OUTPUT" - echo "filename=nym-wallet_${version}_amd64.AppImage" >> "$GITHUB_OUTPUT" + echo "filename=nym-wallet_${semver}_amd64.AppImage" >> "$GITHUB_OUTPUT" echo "file_hash=${{ hashFiles('nym-wallet/target/release/bundle/appimage/nym-wallet_*_amd64.AppImage') }}" >> "$GITHUB_OUTPUT" push-release-data: diff --git a/.github/workflows/nym-wallet-publish-windows10.yml b/.github/workflows/nym-wallet-publish-windows10.yml index 56a332a75d..a7be3e4a37 100644 --- a/.github/workflows/nym-wallet-publish-windows10.yml +++ b/.github/workflows/nym-wallet-publish-windows10.yml @@ -19,7 +19,7 @@ jobs: outputs: release_id: ${{ steps.create-release.outputs.id }} - release_date: ${{ fromJSON(steps.create-release.outputs.assets)[0].created_at }} + release_date: ${{ fromJSON(steps.create-release.outputs.assets)[0].published_at }} version: ${{ steps.release-info.outputs.version }} filename: ${{ steps.release-info.outputs.filename }} file_hash: ${{ steps.release-info.outputs.file_hash }} @@ -103,7 +103,7 @@ jobs: ref=${{ github.ref_name }} semver="${ref##nym-wallet-}" && semver="${semver##v}" echo "version=${semver}" >> "$GITHUB_OUTPUT" - echo "filename=nym-wallet_${version}_x64_en-US.msi" >> "$GITHUB_OUTPUT" + echo "filename=nym-wallet_${semver}_x64_en-US.msi" >> "$GITHUB_OUTPUT" echo "file_hash=${{ hashFiles('nym-wallet/target/release/bundle/msi/nym-wallet_*_x64_en-US.msi') }}" >> "$GITHUB_OUTPUT" push-release-data: From 0bfc1be1d594ecfb7970e0ad54571e1b1111a6a3 Mon Sep 17 00:00:00 2001 From: pierre Date: Thu, 27 Jul 2023 11:42:02 +0200 Subject: [PATCH 02/21] ci: fix release strapi actions --- .github/workflows/nym-connect-publish-macos.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/nym-connect-publish-macos.yml b/.github/workflows/nym-connect-publish-macos.yml index a4176eb285..827676f4d3 100644 --- a/.github/workflows/nym-connect-publish-macos.yml +++ b/.github/workflows/nym-connect-publish-macos.yml @@ -118,7 +118,7 @@ jobs: ref=${{ github.ref_name }} semver="${ref##nym-connect-}" && semver="${semver##v}" echo "version=${semver}" >> "$GITHUB_OUTPUT" - echo "filename=nym-connect_${semver}_x64_en-US.msi" >> "$GITHUB_OUTPUT" + echo "filename=nym-connect_${semver}_x64.dmg " >> "$GITHUB_OUTPUT" echo "file_hash=${{ hashFiles('nym-connect/desktop/target/release/bundle/dmg/nym-connect_*_x64.dmg') }}" >> "$GITHUB_OUTPUT" push-release-data: From 5964f104c5ba699bda1a8e753741c01bbf7ea05c Mon Sep 17 00:00:00 2001 From: pierre Date: Thu, 27 Jul 2023 15:53:48 +0200 Subject: [PATCH 03/21] fix(nc-desktop): typo --- .../desktop/src/pages/menu/settings/PrivacyLevelSettings.tsx | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/nym-connect/desktop/src/pages/menu/settings/PrivacyLevelSettings.tsx b/nym-connect/desktop/src/pages/menu/settings/PrivacyLevelSettings.tsx index 5c2241b4d0..a97e7fdfdf 100644 --- a/nym-connect/desktop/src/pages/menu/settings/PrivacyLevelSettings.tsx +++ b/nym-connect/desktop/src/pages/menu/settings/PrivacyLevelSettings.tsx @@ -37,8 +37,8 @@ export const PrivacyLevelSettings = () => { label="Enable" /> - By activating this option, the connection speed will be relatively faster in exchange of relaxing some - protections + By activating this option, the connection speed will be relatively faster in exchange for relaxing some + privacy protections From 7b71775e08ad30fb13454493135026b3f70db629 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jon=20H=C3=A4ggblad?= Date: Fri, 28 Jul 2023 14:48:33 +0200 Subject: [PATCH 04/21] Add geo-aware mixnet topology provider (#3713) * WIP: initial work * wupwup * WIP: experiments * Move topology provider and requests to own crate * Make sure we use the new crate everywhere * Sort Cargo.toml * Extract out some functions in geo_aware_provider * rustfmt * Add CountryGroup type * Assign unknown as well * wipwip * Add command line flag to socks5-client * Use geo-aware mixnode selection in nym-connect when in medium mode * rustfmt * clippy * Fix nym-connect build * wasm fix * Spelling --- Cargo.lock | 20 ++ Cargo.toml | 13 +- clients/socks5/src/commands/init.rs | 1 + clients/socks5/src/commands/mod.rs | 15 +- clients/socks5/src/commands/run.rs | 13 + clients/webassembly/Cargo.lock | 13 + clients/webassembly/src/client/config.rs | 1 + common/client-core/Cargo.toml | 10 +- .../client-core/src/client/base_client/mod.rs | 15 +- .../topology_control/geo_aware_provider.rs | 319 ++++++++++++++++++ .../src/client/topology_control/mod.rs | 1 + common/client-core/src/config/mod.rs | 22 +- .../src/config/old_config_v1_1_20_2.rs | 1 + .../mixnet-contract/src/mixnode.rs | 4 + common/socks5-client-core/Cargo.toml | 13 +- common/socks5-client-core/src/lib.rs | 1 + explorer-api/Cargo.toml | 17 +- explorer-api/explorer-api-requests/Cargo.toml | 12 + explorer-api/explorer-api-requests/src/lib.rs | 44 +++ .../src/country_statistics/geolocate.rs | 4 +- explorer-api/src/geo_ip/location.rs | 12 + explorer-api/src/mix_node/http.rs | 3 +- explorer-api/src/mix_node/mod.rs | 2 +- explorer-api/src/mix_node/models.rs | 38 +-- explorer-api/src/mix_nodes/http.rs | 2 +- explorer-api/src/mix_nodes/location.rs | 23 +- explorer-api/src/mix_nodes/models.rs | 4 +- nym-connect/desktop/Cargo.lock | 39 ++- nym-connect/desktop/src-tauri/src/tasks.rs | 26 +- .../src/allowed_hosts/hosts.rs | 1 - 30 files changed, 574 insertions(+), 115 deletions(-) create mode 100644 common/client-core/src/client/topology_control/geo_aware_provider.rs create mode 100644 explorer-api/explorer-api-requests/Cargo.toml create mode 100644 explorer-api/explorer-api-requests/src/lib.rs diff --git a/Cargo.lock b/Cargo.lock index d576e05c0c..f7ba594a47 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -1907,6 +1907,7 @@ dependencies = [ "maxminddb", "nym-bin-common", "nym-contracts-common", + "nym-explorer-api-requests", "nym-mixnet-contract-common", "nym-network-defaults", "nym-task", @@ -3783,6 +3784,7 @@ dependencies = [ "nym-config", "nym-credential-storage", "nym-crypto", + "nym-explorer-api-requests", "nym-gateway-client", "nym-gateway-requests", "nym-network-defaults", @@ -3793,6 +3795,7 @@ dependencies = [ "nym-topology", "nym-validator-client", "rand 0.7.3", + "reqwest", "serde", "serde_json", "sha2 0.10.6", @@ -4005,6 +4008,18 @@ dependencies = [ "syn 1.0.109", ] +[[package]] +name = "nym-explorer-api-requests" +version = "0.1.0" +dependencies = [ + "nym-contracts-common", + "nym-mixnet-contract-common", + "nym-validator-client", + "schemars", + "serde", + "ts-rs", +] + [[package]] name = "nym-gateway" version = "1.1.23" @@ -4520,7 +4535,9 @@ dependencies = [ "nym-bandwidth-controller", "nym-client-core", "nym-config", + "nym-contracts-common", "nym-credential-storage", + "nym-mixnet-contract-common", "nym-network-defaults", "nym-service-providers-common", "nym-socks5-proxy-helpers", @@ -4530,10 +4547,13 @@ dependencies = [ "nym-validator-client", "pin-project", "rand 0.7.3", + "reqwest", + "schemars", "serde", "tap", "thiserror", "tokio", + "url", ] [[package]] diff --git a/Cargo.toml b/Cargo.toml index fd137c6bdf..2b2fad2698 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -74,6 +74,7 @@ members = [ "common/types", "common/wasm-utils", "explorer-api", + "explorer-api/explorer-api-requests", "gateway", "gateway/gateway-requests", "integrations/bity", @@ -117,31 +118,31 @@ anyhow = "1.0.71" async-trait = "0.1.64" bip39 = { version = "2.0.0", features = ["zeroize"] } cfg-if = "1.0.0" +cosmrs = "=0.14.0" cosmwasm-derive = "=1.2.5" cosmwasm-schema = "=1.2.5" cosmwasm-std = "=1.2.5" cosmwasm-storage = "=1.2.5" -cosmrs = "=0.14.0" -# same version as used by cosmrs -tendermint-rpc = "=0.32" -cw-utils = "=1.0.1" +cw-controllers = { version = "=1.0.1" } cw-storage-plus = "=1.0.1" +cw-utils = "=1.0.1" cw2 = { version = "=1.0.1" } cw3 = { version = "=1.0.1" } cw3-fixed-multisig = { version = "=1.0.1" } cw4 = { version = "=1.0.1" } -cw-controllers = { version = "=1.0.1" } dotenvy = "0.15.6" generic-array = "0.14.7" -k256 = "0.13" getrandom = "0.2.10" +k256 = "0.13" lazy_static = "1.4.0" log = "0.4" once_cell = "1.7.2" rand = "0.8.5" +reqwest = "0.11.18" serde = "1.0.152" serde_json = "1.0.91" tap = "1.0.1" +tendermint-rpc = "=0.32" # same version as used by cosmrs thiserror = "1.0.38" tokio = "1.24.1" url = "2.2" diff --git a/clients/socks5/src/commands/init.rs b/clients/socks5/src/commands/init.rs index 76337b84ac..ef370c54b8 100644 --- a/clients/socks5/src/commands/init.rs +++ b/clients/socks5/src/commands/init.rs @@ -94,6 +94,7 @@ impl From for OverrideConfig { use_anonymous_replies: init_config.use_reply_surbs, fastmode: init_config.fastmode, no_cover: init_config.no_cover, + geo_routing: None, medium_toggle: false, nyxd_urls: init_config.nyxd_urls, enabled_credentials_mode: init_config.enabled_credentials_mode, diff --git a/clients/socks5/src/commands/mod.rs b/clients/socks5/src/commands/mod.rs index 2b5fe425b6..12b4523330 100644 --- a/clients/socks5/src/commands/mod.rs +++ b/clients/socks5/src/commands/mod.rs @@ -16,7 +16,8 @@ use nym_client_core::client::base_client::storage::gateway_details::{ OnDiskGatewayDetails, PersistedGatewayDetails, }; use nym_client_core::client::key_manager::persistence::OnDiskKeys; -use nym_client_core::config::GatewayEndpointConfig; +use nym_client_core::client::topology_control::geo_aware_provider::CountryGroup; +use nym_client_core::config::{GatewayEndpointConfig, TopologyStructure}; use nym_client_core::error::ClientCoreError; use nym_config::OptionalSet; use nym_sphinx::params::{PacketSize, PacketType}; @@ -68,6 +69,7 @@ pub(crate) struct OverrideConfig { use_anonymous_replies: Option, fastmode: bool, no_cover: bool, + geo_routing: Option, medium_toggle: bool, nyxd_urls: Option>, enabled_credentials_mode: Option, @@ -91,6 +93,13 @@ pub(crate) fn override_config(config: Config, args: OverrideConfig) -> Config { let secondary_packet_size = args.medium_toggle.then_some(PacketSize::ExtendedPacket16); let no_per_hop_delays = args.medium_toggle; + let topology_structure = if args.medium_toggle || args.geo_routing.is_some() { + // TODO: rethink the default group. I just picked one for now. + TopologyStructure::GeoAware(args.geo_routing.unwrap_or(CountryGroup::Europe)) + } else { + TopologyStructure::default() + }; + let packet_type = if args.outfox { PacketType::Outfox } else { @@ -114,6 +123,10 @@ pub(crate) fn override_config(config: Config, args: OverrideConfig) -> Config { // NOTE: see comment above about the order of the other disble cover traffic config .with_base(BaseClientConfig::with_disabled_cover_traffic, args.no_cover) .with_base(BaseClientConfig::with_packet_type, packet_type) + .with_base( + BaseClientConfig::with_topology_structure, + topology_structure, + ) .with_optional(Config::with_anonymous_replies, args.use_anonymous_replies) .with_optional(Config::with_port, args.port) .with_optional_base_custom_env( diff --git a/clients/socks5/src/commands/run.rs b/clients/socks5/src/commands/run.rs index 5d54038c06..8dd289e2bf 100644 --- a/clients/socks5/src/commands/run.rs +++ b/clients/socks5/src/commands/run.rs @@ -11,6 +11,7 @@ use clap::Args; use log::*; use nym_bin_common::version_checker::is_minor_version_compatible; use nym_client_core::client::base_client::storage::OnDiskPersistent; +use nym_client_core::client::topology_control::geo_aware_provider::CountryGroup; use nym_crypto::asymmetric::identity; use nym_socks5_client_core::NymClient; use nym_sphinx::addressing::clients::Recipient; @@ -60,6 +61,10 @@ pub(crate) struct Run { #[clap(long, hide = true)] no_cover: bool, + /// Set geo-aware mixnode selection when sending mixnet traffic, for experiments only. + #[clap(long, hide = true, value_parser = validate_country_group)] + geo_routing: Option, + /// Enable medium mixnet traffic, for experiments only. /// This includes things like disabling cover traffic, no per hop delays, etc. #[clap(long, hide = true)] @@ -82,6 +87,7 @@ impl From for OverrideConfig { use_anonymous_replies: run_config.use_anonymous_replies, fastmode: run_config.fastmode, no_cover: run_config.no_cover, + geo_routing: run_config.geo_routing, medium_toggle: run_config.medium_toggle, nyxd_urls: run_config.nyxd_urls, enabled_credentials_mode: run_config.enabled_credentials_mode, @@ -90,6 +96,13 @@ impl From for OverrideConfig { } } +fn validate_country_group(s: &str) -> Result { + match s.parse() { + Ok(cg) => Ok(cg), + Err(_) => Err(format!("failed to parse country group: {}", s)), + } +} + // this only checks compatibility between config the binary. It does not take into consideration // network version. It might do so in the future. fn version_check(cfg: &Config) -> bool { diff --git a/clients/webassembly/Cargo.lock b/clients/webassembly/Cargo.lock index f0733eac1b..c6410d881c 100644 --- a/clients/webassembly/Cargo.lock +++ b/clients/webassembly/Cargo.lock @@ -2477,6 +2477,7 @@ dependencies = [ "nym-config", "nym-credential-storage", "nym-crypto", + "nym-explorer-api-requests", "nym-gateway-client", "nym-gateway-requests", "nym-network-defaults", @@ -2487,6 +2488,7 @@ dependencies = [ "nym-topology", "nym-validator-client", "rand 0.7.3", + "reqwest", "serde", "serde_json", "sha2 0.10.6", @@ -2692,6 +2694,17 @@ dependencies = [ "zeroize", ] +[[package]] +name = "nym-explorer-api-requests" +version = "0.1.0" +dependencies = [ + "nym-contracts-common", + "nym-mixnet-contract-common", + "nym-validator-client", + "schemars", + "serde", +] + [[package]] name = "nym-gateway-client" version = "0.1.0" diff --git a/clients/webassembly/src/client/config.rs b/clients/webassembly/src/client/config.rs index 07d9ab5f5f..f63d1456ac 100644 --- a/clients/webassembly/src/client/config.rs +++ b/clients/webassembly/src/client/config.rs @@ -246,6 +246,7 @@ impl From for ConfigTopology { topology.topology_resolution_timeout_ms, ), disable_refreshing: topology.disable_refreshing, + topology_structure: Default::default(), } } } diff --git a/common/client-core/Cargo.toml b/common/client-core/Cargo.toml index d5ae32dbd2..e63d6e0ff7 100644 --- a/common/client-core/Cargo.toml +++ b/common/client-core/Cargo.toml @@ -10,27 +10,29 @@ rust-version = "1.66" [dependencies] async-trait = { workspace = true } base64 = "0.21.2" -dirs = "4.0" dashmap = "5.4.0" +dirs = "4.0" futures = "0.3" humantime-serde = "1.0" log = { workspace = true } rand = { version = "0.7.3", features = ["wasm-bindgen"] } +reqwest = { workspace = true } serde = { workspace = true, features = ["derive"] } serde_json = { workspace = true } sha2 = "0.10.6" tap = "1.0.1" thiserror = "1.0.34" -url = { version ="2.2", features = ["serde"] } -tungstenite = { version = "0.13.0", default-features = false } -tokio = { version = "1.24.1", features = ["macros"]} time = "0.3.17" +tokio = { version = "1.24.1", features = ["macros"]} +tungstenite = { version = "0.13.0", default-features = false } +url = { version ="2.2", features = ["serde"] } zeroize = { workspace = true } # internal nym-bandwidth-controller = { path = "../bandwidth-controller" } nym-config = { path = "../config" } nym-crypto = { path = "../crypto" } +nym-explorer-api-requests = { path = "../../explorer-api/explorer-api-requests" } nym-gateway-client = { path = "../client-libs/gateway-client" } #gateway-client = { path = "../../common/client-libs/gateway-client", default-features = false, features = ["wasm", "coconut"] } nym-gateway-requests = { path = "../../gateway/gateway-requests" } diff --git a/common/client-core/src/client/base_client/mod.rs b/common/client-core/src/client/base_client/mod.rs index aecb7eb5c1..a934793953 100644 --- a/common/client-core/src/client/base_client/mod.rs +++ b/common/client-core/src/client/base_client/mod.rs @@ -2,6 +2,7 @@ // SPDX-License-Identifier: Apache-2.0 use super::received_buffer::ReceivedBufferMessage; +use super::topology_control::geo_aware_provider::GeoAwareTopologyProvider; use crate::client::base_client::storage::MixnetClientStorage; use crate::client::cover_traffic_stream::LoopCoverTrafficStream; use crate::client::inbound_messages::{InputMessage, InputMessageReceiver, InputMessageSender}; @@ -339,14 +340,20 @@ where fn setup_topology_provider( custom_provider: Option>, + provider_from_config: config::TopologyStructure, nym_api_urls: Vec, ) -> Box { // if no custom provider was ... provided ..., create one using nym-api - custom_provider.unwrap_or_else(|| { - Box::new(NymApiTopologyProvider::new( + custom_provider.unwrap_or_else(|| match provider_from_config { + config::TopologyStructure::NymApi => Box::new(NymApiTopologyProvider::new( nym_api_urls, env!("CARGO_PKG_VERSION").to_string(), - )) + )), + config::TopologyStructure::GeoAware(group) => Box::new(GeoAwareTopologyProvider::new( + nym_api_urls, + env!("CARGO_PKG_VERSION").to_string(), + group, + )), }) } @@ -521,8 +528,10 @@ where let topology_provider = Self::setup_topology_provider( self.custom_topology_provider.take(), + self.config.debug.topology.topology_structure, self.config.get_nym_api_endpoints(), ); + Self::start_topology_refresher( topology_provider, self.config.debug.topology, diff --git a/common/client-core/src/client/topology_control/geo_aware_provider.rs b/common/client-core/src/client/topology_control/geo_aware_provider.rs new file mode 100644 index 0000000000..268f6612e0 --- /dev/null +++ b/common/client-core/src/client/topology_control/geo_aware_provider.rs @@ -0,0 +1,319 @@ +use std::{collections::HashMap, fmt}; + +use log::{debug, error, info}; +use nym_explorer_api_requests::PrettyDetailedMixNodeBond; +use nym_topology::{ + nym_topology_from_detailed, + provider_trait::{async_trait, TopologyProvider}, + NymTopology, +}; +use nym_validator_client::client::MixId; +use rand::{prelude::SliceRandom, thread_rng}; +use serde::{Deserialize, Serialize}; +use url::Url; + +const MIN_NODES_PER_LAYER: usize = 1; +const EXPLORER_API_MIXNODES_URL: &str = "https://explorer.nymtech.net/api/v1/mix-nodes"; + +// TODO: create a explorer-api-client +async fn fetch_mixnodes_from_explorer_api() -> Option> { + reqwest::get(EXPLORER_API_MIXNODES_URL) + .await + .ok()? + .json::>() + .await + .ok() +} + +#[derive(Copy, Clone, Hash, PartialEq, Eq, Serialize, Deserialize, Debug)] +pub enum CountryGroup { + Europe, + NorthAmerica, + SouthAmerica, + Oceania, + Asia, + Africa, + Unknown, +} + +impl CountryGroup { + // We map contry codes into group, which initially are continent codes to a first approximation, + // but we do it manually to reserve the right to tweak this distribution for our purposes. + fn new(country_code: &str) -> Self { + let country_code = country_code.to_uppercase(); + use CountryGroup::*; + match country_code.as_ref() { + // Europe + "AT" => Europe, + "BG" => Europe, + "CH" => Europe, + "CY" => Europe, + "CZ" => Europe, + "DE" => Europe, + "DK" => Europe, + "ES" => Europe, + "FI" => Europe, + "FR" => Europe, + "GB" => Europe, + "GR" => Europe, + "IE" => Europe, + "IT" => Europe, + "LT" => Europe, + "LU" => Europe, + "LV" => Europe, + "MD" => Europe, + "MT" => Europe, + "NL" => Europe, + "NO" => Europe, + "PL" => Europe, + "RO" => Europe, + "SE" => Europe, + "SK" => Europe, + "TR" => Europe, + "UA" => Europe, + + // North America + "CA" => NorthAmerica, + "MX" => NorthAmerica, + "US" => NorthAmerica, + + // South America + "AR" => SouthAmerica, + "BR" => SouthAmerica, + "CL" => SouthAmerica, + "CO" => SouthAmerica, + "CR" => SouthAmerica, + "GT" => SouthAmerica, + + // Oceania + "AU" => Oceania, + + // Asia + "AM" => Asia, + "BH" => Asia, + "CN" => Asia, + "GE" => Asia, + "HK" => Asia, + "ID" => Asia, + "IL" => Asia, + "IN" => Asia, + "JP" => Asia, + "KH" => Asia, + "KR" => Asia, + "KZ" => Asia, + "MY" => Asia, + "RU" => Asia, + "SG" => Asia, + "TH" => Asia, + "VN" => Asia, + + // Africa + "SC" => Africa, + "UG" => Africa, + "ZA" => Africa, + + // And group level codes work too + "EU" => Europe, + "NA" => NorthAmerica, + "SA" => SouthAmerica, + "OC" => Oceania, + "AS" => Asia, + "AF" => Africa, + + // And some aliases + "EUROPE" => Europe, + "NORTHAMERICA" => NorthAmerica, + "SOUTHAMERICA" => SouthAmerica, + "OCEANIA" => Oceania, + "ASIA" => Asia, + "AFRICA" => Africa, + + _ => { + info!("Unknown country code: {}", country_code); + Unknown + } + } + } +} + +impl fmt::Display for CountryGroup { + fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { + use CountryGroup::*; + match self { + Europe => write!(f, "EU"), + NorthAmerica => write!(f, "NA"), + SouthAmerica => write!(f, "SA"), + Oceania => write!(f, "OC"), + Asia => write!(f, "AS"), + Africa => write!(f, "AF"), + Unknown => write!(f, "Unknown"), + } + } +} + +impl std::str::FromStr for CountryGroup { + type Err = (); + + fn from_str(s: &str) -> Result { + let group = CountryGroup::new(s); + if group == CountryGroup::Unknown { + Err(()) + } else { + Ok(group) + } + } +} + +impl CountryGroup { + #[allow(unused)] + fn known(self) -> Option { + use CountryGroup::*; + match self { + Europe | NorthAmerica | SouthAmerica | Oceania | Asia | Africa => Some(self), + Unknown => None, + } + } +} + +fn group_mixnodes_by_country_code( + mixnodes: Vec, +) -> HashMap> { + mixnodes + .into_iter() + .fold(HashMap::>::new(), |mut acc, m| { + if let Some(ref location) = m.location { + let country_code = location.two_letter_iso_country_code.clone(); + let group_code = CountryGroup::new(country_code.as_str()); + let mixnodes = acc.entry(group_code).or_insert_with(Vec::new); + mixnodes.push(m.mix_id); + } + acc + }) +} + +fn log_mixnode_distribution(mixnodes: &HashMap>) { + let mixnode_distribution = mixnodes + .iter() + .map(|(k, v)| format!("{}: {}", k, v.len())) + .collect::>() + .join(", "); + debug!("Mixnode distribution - {}", mixnode_distribution); +} + +fn check_layer_integrity(topology: NymTopology) -> Result<(), ()> { + let mixes = topology.mixes(); + if mixes.keys().len() < 3 { + error!("Layer is missing in topology!"); + return Err(()); + } + for (layer, mixnodes) in mixes { + debug!("Layer {:?} has {} mixnodes", layer, mixnodes.len()); + if mixnodes.len() < MIN_NODES_PER_LAYER { + error!( + "There are only {} mixnodes in layer {:?}", + mixnodes.len(), + layer + ); + return Err(()); + } + } + Ok(()) +} + +pub struct GeoAwareTopologyProvider { + validator_client: nym_validator_client::client::NymApiClient, + filter_on: CountryGroup, + client_version: String, +} + +impl GeoAwareTopologyProvider { + pub fn new( + mut nym_api_urls: Vec, + client_version: String, + filter_on: CountryGroup, + ) -> GeoAwareTopologyProvider { + log::info!( + "Creating geo-aware topology provider with filter on {:?}", + filter_on + ); + nym_api_urls.shuffle(&mut thread_rng()); + + GeoAwareTopologyProvider { + validator_client: nym_validator_client::client::NymApiClient::new( + nym_api_urls[0].clone(), + ), + filter_on, + client_version, + } + } + + async fn get_topology(&self) -> Option { + let mixnodes = match self.validator_client.get_cached_active_mixnodes().await { + Err(err) => { + error!("failed to get network mixnodes - {err}"); + return None; + } + Ok(mixes) => mixes, + }; + + let gateways = match self.validator_client.get_cached_gateways().await { + Err(err) => { + error!("failed to get network gateways - {err}"); + return None; + } + Ok(gateways) => gateways, + }; + + // Also fetch mixnodes cached by explorer-api, with the purpose of getting their + // geolocation. + debug!("Fetching mixnodes from explorer-api..."); + let Some(mixnodes_from_explorer_api) = fetch_mixnodes_from_explorer_api().await else { + error!("failed to get mixnodes from explorer-api"); + return None; + }; + + // Partition mixnodes_from_explorer_api according to the value of + // two_letter_iso_country_code. + // NOTE: we construct the full distribution here, but only use the one we're interested in. + // The reason we this instead of a straight filter is that this opens up the possibility to + // complement a small grouping with mixnodes from adjecent countries. + let mixnode_distribution = group_mixnodes_by_country_code(mixnodes_from_explorer_api); + log_mixnode_distribution(&mixnode_distribution); + + let Some(filtered_mixnode_ids) = mixnode_distribution.get(&self.filter_on) else { + error!("no mixnodes found for: {}", self.filter_on); + return None; + }; + + let mixnodes = mixnodes + .into_iter() + .filter(|m| filtered_mixnode_ids.contains(&m.mix_id())) + .collect::>(); + + let topology = nym_topology_from_detailed(mixnodes, gateways) + .filter_system_version(&self.client_version); + + // TODO: return real error type + check_layer_integrity(topology.clone()).ok()?; + + Some(topology) + } +} + +#[cfg(not(target_arch = "wasm32"))] +#[async_trait] +impl TopologyProvider for GeoAwareTopologyProvider { + // this will be manually refreshed on a timer specified inside mixnet client config + async fn get_new_topology(&mut self) -> Option { + self.get_topology().await + } +} + +#[cfg(target_arch = "wasm32")] +#[async_trait(?Send)] +impl TopologyProvider for GeoAwareTopologyProvider { + // this will be manually refreshed on a timer specified inside mixnet client config + async fn get_new_topology(&mut self) -> Option { + self.get_topology().await + } +} diff --git a/common/client-core/src/client/topology_control/mod.rs b/common/client-core/src/client/topology_control/mod.rs index 0fef523b1e..ed426dde50 100644 --- a/common/client-core/src/client/topology_control/mod.rs +++ b/common/client-core/src/client/topology_control/mod.rs @@ -10,6 +10,7 @@ use nym_topology::NymTopologyError; use std::time::Duration; mod accessor; +pub mod geo_aware_provider; pub(crate) mod nym_api_provider; // TODO: move it to config later diff --git a/common/client-core/src/config/mod.rs b/common/client-core/src/config/mod.rs index e8f08adfaa..465c227e19 100644 --- a/common/client-core/src/config/mod.rs +++ b/common/client-core/src/config/mod.rs @@ -8,7 +8,7 @@ use serde::{Deserialize, Serialize}; use std::time::Duration; use url::Url; -use crate::error::ClientCoreError; +use crate::{client::topology_control::geo_aware_provider::CountryGroup, error::ClientCoreError}; #[cfg(target_arch = "wasm32")] use wasm_bindgen::prelude::*; @@ -158,6 +158,15 @@ impl Config { self } + pub fn with_topology_structure(mut self, topology_structure: TopologyStructure) -> Self { + self.set_topology_structure(topology_structure); + self + } + + pub fn set_topology_structure(&mut self, topology_structure: TopologyStructure) { + self.debug.topology.topology_structure = topology_structure; + } + pub fn with_no_per_hop_delays(mut self, no_per_hop_delays: bool) -> Self { if no_per_hop_delays { self.set_no_per_hop_delays() @@ -466,6 +475,16 @@ pub struct Topology { /// the first valid instance. /// Supersedes `topology_refresh_rate_ms`. pub disable_refreshing: bool, + + /// Specifies the mixnode topology to be used for sending packets. + pub topology_structure: TopologyStructure, +} + +#[derive(Default, Copy, Clone, Debug, PartialEq, Serialize, Deserialize)] +pub enum TopologyStructure { + #[default] + NymApi, + GeoAware(CountryGroup), } impl Default for Topology { @@ -474,6 +493,7 @@ impl Default for Topology { topology_refresh_rate: DEFAULT_TOPOLOGY_REFRESH_RATE, topology_resolution_timeout: DEFAULT_TOPOLOGY_RESOLUTION_TIMEOUT, disable_refreshing: false, + topology_structure: TopologyStructure::default(), } } } diff --git a/common/client-core/src/config/old_config_v1_1_20_2.rs b/common/client-core/src/config/old_config_v1_1_20_2.rs index ed0cd0356a..a097b55f2a 100644 --- a/common/client-core/src/config/old_config_v1_1_20_2.rs +++ b/common/client-core/src/config/old_config_v1_1_20_2.rs @@ -267,6 +267,7 @@ impl From for Topology { topology_refresh_rate: value.topology_refresh_rate, topology_resolution_timeout: value.topology_resolution_timeout, disable_refreshing: value.disable_refreshing, + topology_structure: Default::default(), } } } diff --git a/common/cosmwasm-smart-contracts/mixnet-contract/src/mixnode.rs b/common/cosmwasm-smart-contracts/mixnet-contract/src/mixnode.rs index 69f1a89209..c29077c3b6 100644 --- a/common/cosmwasm-smart-contracts/mixnet-contract/src/mixnode.rs +++ b/common/cosmwasm-smart-contracts/mixnet-contract/src/mixnode.rs @@ -58,6 +58,10 @@ impl MixNodeDetails { self.bond_information.mix_id } + pub fn layer(&self) -> Layer { + self.bond_information.layer + } + pub fn is_unbonding(&self) -> bool { self.bond_information.is_unbonding } diff --git a/common/socks5-client-core/Cargo.toml b/common/socks5-client-core/Cargo.toml index 9ca792f8b1..2e1aa52b32 100644 --- a/common/socks5-client-core/Cargo.toml +++ b/common/socks5-client-core/Cargo.toml @@ -7,22 +7,27 @@ edition = "2021" [dependencies] dirs = "4.0" +futures = "0.3" log = { workspace = true } pin-project = "1.0" rand = { version = "0.7.3", features = ["wasm-bindgen"] } +reqwest = "0.11.4" +schemars = { version = "0.8", features = ["preserve_order"] } serde = { workspace = true, features = ["derive"] } # for config serialization/deserialization -thiserror = "1.0.34" tap = "1.0.1" +thiserror = "1.0.34" tokio = { version = "1.24.1", features = ["rt-multi-thread", "net", "signal"] } -futures = "0.3" +url = "2.2" -nym-client-core = { path = "../client-core", features = ["fs-surb-storage"] } nym-bandwidth-controller = { path = "../../common/bandwidth-controller" } +nym-client-core = { path = "../client-core", features = ["fs-surb-storage"] } nym-config = { path = "../config" } +nym-contracts-common = { path = "../cosmwasm-smart-contracts/contracts-common" } nym-credential-storage = { path = "../credential-storage" } +nym-mixnet-contract-common = { path = "../cosmwasm-smart-contracts/mixnet-contract" } nym-network-defaults = { path = "../network-defaults" } -nym-socks5-proxy-helpers = { path = "../socks5/proxy-helpers" } nym-service-providers-common = { path = "../../service-providers/common" } +nym-socks5-proxy-helpers = { path = "../socks5/proxy-helpers" } nym-socks5-requests = { path = "../socks5/requests" } nym-sphinx = { path = "../nymsphinx" } nym-task = { path = "../task" } diff --git a/common/socks5-client-core/src/lib.rs b/common/socks5-client-core/src/lib.rs index 2070eeaf71..74d27b69ed 100644 --- a/common/socks5-client-core/src/lib.rs +++ b/common/socks5-client-core/src/lib.rs @@ -24,6 +24,7 @@ use nym_credential_storage::storage::Storage as CredentialStorage; use nym_sphinx::addressing::clients::Recipient; use nym_sphinx::params::PacketType; use nym_task::{TaskClient, TaskManager}; + use std::error::Error; pub mod config; diff --git a/explorer-api/Cargo.toml b/explorer-api/Cargo.toml index 5e1dec9f48..c4c7b345bc 100644 --- a/explorer-api/Cargo.toml +++ b/explorer-api/Cargo.toml @@ -8,12 +8,17 @@ edition = "2021" [dependencies] chrono = { version = "0.4.19", features = ["serde"] } clap = { version = "4.0", features = ["cargo", "derive"] } +dotenvy = "0.15.6" humantime-serde = "1.0" isocountry = "0.3.2" itertools = "0.10.3" log = { workspace = true } +maxminddb = "0.23.0" okapi = { version = "0.7.0-rc.1", features = ["impl_json_schema"] } pretty_env_logger = "0.4.0" +rand = "0.8.5" +rand_pcg = "0.3.1" +rand_seeder = "0.2.3" reqwest = "0.11.4" rocket = { version = "0.5.0-rc.2", features = ["json"] } rocket_cors = { git="https://github.com/lawliet89/rocket_cors", rev="dfd3662c49e2f6fc37df35091cb94d82f7fb5915" } @@ -23,15 +28,11 @@ serde = "1.0.126" serde_json = "1.0.66" thiserror = "1.0.29" tokio = {version = "1.21.2", features = ["full"] } -maxminddb = "0.23.0" -dotenvy = "0.15.6" -rand = "0.8.5" -rand_seeder = "0.2.3" -rand_pcg = "0.3.1" -nym-mixnet-contract-common = { path = "../common/cosmwasm-smart-contracts/mixnet-contract" } -nym-contracts-common = { path = "../common/cosmwasm-smart-contracts/contracts-common" } -nym-network-defaults = { path = "../common/network-defaults" } nym-bin-common = { path = "../common/bin-common"} +nym-contracts-common = { path = "../common/cosmwasm-smart-contracts/contracts-common" } +nym-explorer-api-requests = { path = "explorer-api-requests" } +nym-mixnet-contract-common = { path = "../common/cosmwasm-smart-contracts/mixnet-contract" } +nym-network-defaults = { path = "../common/network-defaults" } nym-task = { path = "../common/task" } nym-validator-client = { path = "../common/client-libs/validator-client", features=["http-client"] } diff --git a/explorer-api/explorer-api-requests/Cargo.toml b/explorer-api/explorer-api-requests/Cargo.toml new file mode 100644 index 0000000000..93c8faaada --- /dev/null +++ b/explorer-api/explorer-api-requests/Cargo.toml @@ -0,0 +1,12 @@ +[package] +name = "nym-explorer-api-requests" +version = "0.1.0" +edition = "2021" + +[dependencies] +nym-contracts-common = { path = "../../common/cosmwasm-smart-contracts/contracts-common" } +nym-mixnet-contract-common = { path = "../../common/cosmwasm-smart-contracts/mixnet-contract" } +nym-validator-client = { path = "../../common/client-libs/validator-client" } +schemars = { version = "0.8", features = ["preserve_order"] } +serde = { version = "1.0", features = ["derive"] } +ts-rs = { version = "6.1.2", optional = true } diff --git a/explorer-api/explorer-api-requests/src/lib.rs b/explorer-api/explorer-api-requests/src/lib.rs new file mode 100644 index 0000000000..bfcafa2860 --- /dev/null +++ b/explorer-api/explorer-api-requests/src/lib.rs @@ -0,0 +1,44 @@ +use nym_contracts_common::Percent; +use nym_mixnet_contract_common::{Addr, Coin, Layer, MixId, MixNode}; +use nym_validator_client::models::NodePerformance; +use schemars::JsonSchema; +use serde::{Deserialize, Serialize}; + +#[derive(Clone, Debug, Serialize, Deserialize, JsonSchema, PartialEq)] +#[serde(rename_all = "snake_case")] +pub enum MixnodeStatus { + Active, // in both the active set and the rewarded set + Standby, // only in the rewarded set + Inactive, // in neither the rewarded set nor the active set +} + +#[derive(Clone, Debug, Serialize, Deserialize, JsonSchema)] +pub struct PrettyDetailedMixNodeBond { + pub mix_id: MixId, + pub location: Option, + pub status: MixnodeStatus, + pub pledge_amount: Coin, + pub total_delegation: Coin, + pub owner: Addr, + pub layer: Layer, + pub mix_node: MixNode, + pub stake_saturation: f32, + pub uncapped_saturation: f32, + pub avg_uptime: u8, + pub node_performance: NodePerformance, + pub estimated_operator_apy: f64, + pub estimated_delegators_apy: f64, + pub operating_cost: Coin, + pub profit_margin_percent: Percent, + pub family_id: Option, + pub blacklisted: bool, +} + +#[derive(Clone, Debug, JsonSchema, Serialize, Deserialize)] +pub struct Location { + pub two_letter_iso_country_code: String, + pub three_letter_iso_country_code: String, + pub country_name: String, + pub latitude: Option, + pub longitude: Option, +} diff --git a/explorer-api/src/country_statistics/geolocate.rs b/explorer-api/src/country_statistics/geolocate.rs index 8158c6e65e..a80ebc28e4 100644 --- a/explorer-api/src/country_statistics/geolocate.rs +++ b/explorer-api/src/country_statistics/geolocate.rs @@ -1,9 +1,9 @@ // Copyright 2022 - Nym Technologies SA // SPDX-License-Identifier: Apache-2.0 -use crate::mix_nodes::location::Location; use crate::state::ExplorerApiStateContext; use log::{info, warn}; +use nym_explorer_api_requests::Location; use nym_task::TaskClient; pub(crate) struct GeoLocateTask { @@ -64,7 +64,7 @@ impl GeoLocateTask { ) { Ok(opt) => match opt { Some(location) => { - let location = Location::new(location); + let location: Location = location.into(); trace!( "{} mix nodes already located. Ip {} is located in {:#?}", diff --git a/explorer-api/src/geo_ip/location.rs b/explorer-api/src/geo_ip/location.rs index adbdb6cef3..fdb8584938 100644 --- a/explorer-api/src/geo_ip/location.rs +++ b/explorer-api/src/geo_ip/location.rs @@ -42,6 +42,18 @@ pub(crate) struct Location { pub(crate) longitude: Option, } +impl From for nym_explorer_api_requests::Location { + fn from(location: Location) -> Self { + nym_explorer_api_requests::Location { + country_name: location.name, + two_letter_iso_country_code: location.iso_alpha2, + three_letter_iso_country_code: location.iso_alpha3, + latitude: location.latitude, + longitude: location.longitude, + } + } +} + impl GeoIp { pub fn new() -> Self { let db_path = std::env::var("GEOIP_DB_PATH").unwrap_or_else(|e| { diff --git a/explorer-api/src/mix_node/http.rs b/explorer-api/src/mix_node/http.rs index 137c6250ed..e00ed8ff82 100644 --- a/explorer-api/src/mix_node/http.rs +++ b/explorer-api/src/mix_node/http.rs @@ -6,9 +6,10 @@ use crate::mix_node::delegations::{ }; use crate::mix_node::econ_stats::retrieve_mixnode_econ_stats; use crate::mix_node::models::{ - EconomicDynamicsStats, NodeDescription, NodeStats, PrettyDetailedMixNodeBond, SummedDelegations, + EconomicDynamicsStats, NodeDescription, NodeStats, SummedDelegations, }; use crate::state::ExplorerApiStateContext; +use nym_explorer_api_requests::PrettyDetailedMixNodeBond; use nym_mixnet_contract_common::{Delegation, MixId}; use reqwest::Error as ReqwestError; use rocket::response::status::NotFound; diff --git a/explorer-api/src/mix_node/mod.rs b/explorer-api/src/mix_node/mod.rs index 88c3b1cd71..dac365c71d 100644 --- a/explorer-api/src/mix_node/mod.rs +++ b/explorer-api/src/mix_node/mod.rs @@ -1,4 +1,4 @@ pub(crate) mod delegations; pub(crate) mod econ_stats; pub(crate) mod http; -pub(crate) mod models; +pub mod models; diff --git a/explorer-api/src/mix_node/models.rs b/explorer-api/src/mix_node/models.rs index 94ae6558d0..4adfa6dd86 100644 --- a/explorer-api/src/mix_node/models.rs +++ b/explorer-api/src/mix_node/models.rs @@ -2,49 +2,15 @@ // SPDX-License-Identifier: Apache-2.0 use crate::cache::Cache; -use crate::mix_nodes::location::Location; -use nym_contracts_common::Percent; use nym_mixnet_contract_common::Delegation; -use nym_mixnet_contract_common::{Addr, Coin, Layer, MixId, MixNode}; -use nym_validator_client::models::{NodePerformance, SelectionChance}; +use nym_mixnet_contract_common::{Addr, Coin, MixId}; +use nym_validator_client::models::SelectionChance; use serde::Deserialize; use serde::Serialize; use std::sync::Arc; use std::time::SystemTime; use tokio::sync::RwLock; -#[derive(Clone, Debug, Serialize, JsonSchema, PartialEq)] -#[serde(rename_all = "snake_case")] -pub(crate) enum MixnodeStatus { - Active, // in both the active set and the rewarded set - Standby, // only in the rewarded set - Inactive, // in neither the rewarded set nor the active set -} - -#[derive(Clone, Debug, Serialize, JsonSchema)] -pub(crate) struct PrettyDetailedMixNodeBond { - // I leave this to @MS to refactor this type as a lot of things here are redundant thanks to - // the existence of `MixNodeDetails` - pub mix_id: MixId, - pub location: Option, - pub status: MixnodeStatus, - pub pledge_amount: Coin, - pub total_delegation: Coin, - pub owner: Addr, - pub layer: Layer, - pub mix_node: MixNode, - pub stake_saturation: f32, - pub uncapped_saturation: f32, - pub avg_uptime: u8, - pub node_performance: NodePerformance, - pub estimated_operator_apy: f64, - pub estimated_delegators_apy: f64, - pub operating_cost: Coin, - pub profit_margin_percent: Percent, - pub family_id: Option, - pub blacklisted: bool, -} - #[derive(Clone, Debug, Deserialize, Serialize, PartialEq, Eq, JsonSchema)] pub struct SummedDelegations { pub owner: Addr, diff --git a/explorer-api/src/mix_nodes/http.rs b/explorer-api/src/mix_nodes/http.rs index ef5570e455..a36843b66f 100644 --- a/explorer-api/src/mix_nodes/http.rs +++ b/explorer-api/src/mix_nodes/http.rs @@ -1,6 +1,6 @@ -use crate::mix_node::models::{MixnodeStatus, PrettyDetailedMixNodeBond}; use crate::mix_nodes::models::{MixNodeActiveSetSummary, MixNodeSummary}; use crate::state::ExplorerApiStateContext; +use nym_explorer_api_requests::{MixnodeStatus, PrettyDetailedMixNodeBond}; use rocket::serde::json::Json; use rocket::{Route, State}; use rocket_okapi::okapi::openapi3::OpenApi; diff --git a/explorer-api/src/mix_nodes/location.rs b/explorer-api/src/mix_nodes/location.rs index b876cdc792..4908564697 100644 --- a/explorer-api/src/mix_nodes/location.rs +++ b/explorer-api/src/mix_nodes/location.rs @@ -1,7 +1,7 @@ // Copyright 2021 - Nym Technologies SA // SPDX-License-Identifier: Apache-2.0 -use crate::geo_ip::location; +use nym_explorer_api_requests::Location; use nym_mixnet_contract_common::MixId; use serde::{Deserialize, Serialize}; use std::collections::HashMap; @@ -31,27 +31,6 @@ pub(crate) struct LocationCacheItem { pub(crate) valid_until: SystemTime, } -#[derive(Clone, Debug, JsonSchema, Serialize, Deserialize)] -pub(crate) struct Location { - pub(crate) two_letter_iso_country_code: String, - pub(crate) three_letter_iso_country_code: String, - pub(crate) country_name: String, - pub(crate) latitude: Option, - pub(crate) longitude: Option, -} - -impl Location { - pub(crate) fn new(location: location::Location) -> Self { - Location { - country_name: location.name, - two_letter_iso_country_code: location.iso_alpha2, - three_letter_iso_country_code: location.iso_alpha3, - latitude: location.latitude, - longitude: location.longitude, - } - } -} - impl LocationCacheItem { pub(crate) fn new_from_location(location: Option) -> Self { LocationCacheItem { diff --git a/explorer-api/src/mix_nodes/models.rs b/explorer-api/src/mix_nodes/models.rs index bfead42c8c..b107bb2168 100644 --- a/explorer-api/src/mix_nodes/models.rs +++ b/explorer-api/src/mix_nodes/models.rs @@ -5,6 +5,7 @@ use std::collections::{HashMap, HashSet}; use std::sync::Arc; use std::time::{Duration, SystemTime}; +use nym_explorer_api_requests::{Location, MixnodeStatus, PrettyDetailedMixNodeBond}; use nym_mixnet_contract_common::rewarding::helpers::truncate_reward; use nym_mixnet_contract_common::MixId; use serde::Serialize; @@ -14,8 +15,7 @@ use crate::helpers::best_effort_small_dec_to_f64; use nym_validator_client::models::MixNodeBondAnnotated; use super::utils::family_numerical_id; -use crate::mix_node::models::{MixnodeStatus, PrettyDetailedMixNodeBond}; -use crate::mix_nodes::location::{Location, LocationCache, LocationCacheItem}; +use crate::mix_nodes::location::{LocationCache, LocationCacheItem}; use crate::mix_nodes::CACHE_ENTRY_TTL; #[derive(Clone, Debug, Serialize, JsonSchema)] diff --git a/nym-connect/desktop/Cargo.lock b/nym-connect/desktop/Cargo.lock index 6287fadf38..3f657d5852 100644 --- a/nym-connect/desktop/Cargo.lock +++ b/nym-connect/desktop/Cargo.lock @@ -284,8 +284,8 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "93f2635620bf0b9d4576eb7bb9a38a55df78bd1205d26fa994b25911a69f212f" dependencies = [ "bitcoin_hashes", - "rand 0.7.3", - "rand_core 0.5.1", + "rand 0.8.5", + "rand_core 0.6.4", "serde", "unicode-normalization", "zeroize", @@ -2596,17 +2596,6 @@ dependencies = [ "winapi", ] -[[package]] -name = "hostname" -version = "0.3.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3c731c3e10504cc8ed35cfe2f1db4c9274c3d35fa486e3b31df46f068ef3e867" -dependencies = [ - "libc", - "match_cfg", - "winapi", -] - [[package]] name = "html5ever" version = "0.25.2" @@ -3572,6 +3561,7 @@ dependencies = [ "nym-config", "nym-credential-storage", "nym-crypto", + "nym-explorer-api-requests", "nym-gateway-client", "nym-gateway-requests", "nym-network-defaults", @@ -3582,6 +3572,7 @@ dependencies = [ "nym-topology", "nym-validator-client", "rand 0.7.3", + "reqwest", "serde", "serde_json", "sha2 0.10.6", @@ -3669,7 +3660,7 @@ dependencies = [ [[package]] name = "nym-connect" -version = "1.1.13" +version = "1.1.15" dependencies = [ "anyhow", "bip39", @@ -3794,6 +3785,17 @@ dependencies = [ "zeroize", ] +[[package]] +name = "nym-explorer-api-requests" +version = "0.1.0" +dependencies = [ + "nym-contracts-common", + "nym-mixnet-contract-common", + "nym-validator-client", + "schemars", + "serde", +] + [[package]] name = "nym-gateway-client" version = "0.1.0" @@ -3995,7 +3997,9 @@ dependencies = [ "nym-bandwidth-controller", "nym-client-core", "nym-config", + "nym-contracts-common", "nym-credential-storage", + "nym-mixnet-contract-common", "nym-network-defaults", "nym-service-providers-common", "nym-socks5-proxy-helpers", @@ -4005,10 +4009,13 @@ dependencies = [ "nym-validator-client", "pin-project", "rand 0.7.3", + "reqwest", + "schemars", "serde", "tap", "thiserror", "tokio", + "url", ] [[package]] @@ -5155,9 +5162,9 @@ checksum = "f162c6dd7b008981e4d40210aca20b4bd0f9b60ca9271061b07f78537722f2e1" [[package]] name = "reqwest" -version = "0.11.15" +version = "0.11.18" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0ba30cc2c0cd02af1222ed216ba659cdb2f879dfe3181852fe7c50b1d0005949" +checksum = "cde824a14b7c14f85caff81225f411faacc04a2013f41670f41443742b1c1c55" dependencies = [ "base64 0.21.2", "bytes", diff --git a/nym-connect/desktop/src-tauri/src/tasks.rs b/nym-connect/desktop/src-tauri/src/tasks.rs index 8c69b1be7e..06b0809c2f 100644 --- a/nym-connect/desktop/src-tauri/src/tasks.rs +++ b/nym-connect/desktop/src-tauri/src/tasks.rs @@ -1,17 +1,23 @@ use futures::{channel::mpsc, StreamExt}; -use nym_client_core::client::base_client::storage::gateway_details::GatewayDetailsStore; -use nym_client_core::client::base_client::storage::{MixnetClientStorage, OnDiskPersistent}; -use nym_client_core::{config::GatewayEndpointConfig, error::ClientCoreStatusMessage}; -use nym_socks5_client_core::NymClient as Socks5NymClient; -use nym_socks5_client_core::Socks5ControlMessageSender; +use nym_client_core::{ + client::{ + base_client::storage::{ + gateway_details::GatewayDetailsStore, MixnetClientStorage, OnDiskPersistent, + }, + topology_control::geo_aware_provider::CountryGroup, + }, + config::{GatewayEndpointConfig, TopologyStructure}, + error::ClientCoreStatusMessage, +}; +use nym_socks5_client_core::{NymClient as Socks5NymClient, Socks5ControlMessageSender}; use nym_sphinx::params::PacketSize; use nym_task::manager::TaskStatus; use std::sync::Arc; use tap::TapFallible; use tokio::sync::RwLock; -use crate::config::{Config, PrivacyLevel}; use crate::{ + config::{Config, PrivacyLevel}, error::Result, events::{self, emit_event, emit_status_event}, models::{ConnectionStatusKind, ConnectivityTestResult}, @@ -46,6 +52,14 @@ fn override_config_from_env(config: &mut Config, privacy_level: &PrivacyLevel) { log::warn!("Disabling per-hop delay"); config.core.base.set_no_per_hop_delays(); + + // TODO: selectable in the UI + let default_country_group = CountryGroup::Europe; + log::warn!("Using geo-aware mixnode selection: {default_country_group}"); + config + .core + .base + .set_topology_structure(TopologyStructure::GeoAware(default_country_group)); } } diff --git a/service-providers/network-requester/src/allowed_hosts/hosts.rs b/service-providers/network-requester/src/allowed_hosts/hosts.rs index 5c48369d0d..11aa3dd276 100644 --- a/service-providers/network-requester/src/allowed_hosts/hosts.rs +++ b/service-providers/network-requester/src/allowed_hosts/hosts.rs @@ -136,7 +136,6 @@ impl HostsStore { }) .map(Host::from) .collect(); - dbg!(&hosts); Ok(hosts) } } From a344cda9160b24ef8ce767725604fdbcd2b47bd0 Mon Sep 17 00:00:00 2001 From: mfahampshire Date: Tue, 1 Aug 2023 10:33:34 +0200 Subject: [PATCH 05/21] removed old wallet address flag again --- documentation/docs/src/nodes/mix-node-setup.md | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/documentation/docs/src/nodes/mix-node-setup.md b/documentation/docs/src/nodes/mix-node-setup.md index 2f93797e1e..4635aa56ac 100644 --- a/documentation/docs/src/nodes/mix-node-setup.md +++ b/documentation/docs/src/nodes/mix-node-setup.md @@ -84,15 +84,15 @@ To check available configuration options for initializing your node use: ``` ~~~ -Initalise your mixnode with the following command, replacing the value of `--id` with the moniker you wish to give your mixnode, and the `--wallet-address` with the Nym address you created earlier. Your `--host` must be publicly routable on the internet in order to mix packets, and can be either an Ipv4 or IPv6 address. The `$(curl ifconfig.me)` command returns your IP automatically using an external service. If you enter your IP address manually, enter it **without** any port information. +Initalise your mixnode with the following command, replacing the value of `--id` with the moniker you wish to give your mixnode. Your `--host` must be publicly routable on the internet in order to mix packets, and can be either an Ipv4 or IPv6 address. The `$(curl ifconfig.me)` command returns your IP automatically using an external service. If you enter your IP address manually, enter it **without** any port information. ``` -./nym-mixnode init --id winston-smithnode --host $(curl ifconfig.me) --wallet-address n1eufxdlgt0puwrwptgjfqne8pj4nhy2u5ft62uq +./nym-mixnode init --id winston-smithnode --host $(curl ifconfig.me) ``` ~~~admonish example collapsible=true title="Console output" ``` - + ``` ~~~ From c7147ebfb25228fcdfd32ddfccddbba4ba476dfd Mon Sep 17 00:00:00 2001 From: Lorexia Date: Tue, 25 Jul 2023 12:54:38 +0200 Subject: [PATCH 06/21] Add updates to community list projects --- .../community-applications-and-guides.md | 8 ++++++++ .../src/images/profile_picture/nymgraph_pp.png | Bin 0 -> 8489 bytes 2 files changed, 8 insertions(+) create mode 100644 documentation/dev-portal/src/images/profile_picture/nymgraph_pp.png diff --git a/documentation/dev-portal/src/community-resources/community-applications-and-guides.md b/documentation/dev-portal/src/community-resources/community-applications-and-guides.md index ba00922658..90e0801e80 100644 --- a/documentation/dev-portal/src/community-resources/community-applications-and-guides.md +++ b/documentation/dev-portal/src/community-resources/community-applications-and-guides.md @@ -93,6 +93,14 @@ We love seeing our developer community create applications using Nym. If you wou +## NymGraph + +> NymGraph is a graphical chat client for Nym running on Ubuntu and Debian. Test it to chat over the Nym network! +* [Github](https://github.com/Tyz3/nymgraph) + + + +

# Community Guides diff --git a/documentation/dev-portal/src/images/profile_picture/nymgraph_pp.png b/documentation/dev-portal/src/images/profile_picture/nymgraph_pp.png new file mode 100644 index 0000000000000000000000000000000000000000..411dbec6e01e27f9f960c521d4cdc453f874326b GIT binary patch literal 8489 zcmYLvdpr}~|Nj|d=xvG68!JjAp^`9ROSh#+7s@SBxle3!zbuq)=*`?pU>})J+^bs>-9RX*You{=e*AA?Di>(qmmK|5&!^6!m&fA z0T3b!K4PMtU zblcD5B$$_Zcz~( zp@sgH@4kx@@evXGGeW<+3&qSt(S-dsdi-(~qSw}M^1SnPhf6SQ5d_VF%!L6nMZs4y>nHq*Xy6MdafU@n<;`vmFV_qyNq}0tzRT1 zsLw#DvTy7P4so^)p6Cl~a}ckxx?NSY9f3zFX%8e1(X)m#&Rvp>zx&dB@63VCVpu0r zMETG6gfsqMo+A5>4P2)Q?_dA2?{t;JIs^2kz^r5;A1?xwsdKb3~!SZ zlC;l1%=~rPQx1tKQ5jTnqw(cXnr|SJl&|t6z@xUJ1r6Gv-a)5&$^jV^XZrkL+jR*k za^a_2{3NR4o3XR(oEX*mml7gKjMtuFxecS42JG7Q2bL3F&5^XIq-~6p;V01#M+XO{ zGxuiogzYYc(-++6g(8zaQyZBrp&t4r8mbF;`x=@Pqoub33gK7`T~Hv2^dnxF%_T@viNGL?C_w}{thsJqIb z#om7F>f2H1x~0s7(6^yRoz3Tw7%@W}8{)5m5;Kw_iy4ATF|;VPhF)c~5s3LZjf_M` zD=B}&u|Cl6^IdBid@t!yZw4Rp8+tDzhW+XJ)*<=+>{S#^E@1n&NiC7cI7W=U&Mf`h zl&y%z+@4uFyC?^;mfk1%$-2p?J8vM9wMRsK2M})RD0L}viOKL1gh3ru!gUa@{6|2V zeBY=!RP!~-57!mix-t;$ecpfkt#si~Y9(Q>90_-{+H$XUgidtEo@^Hzm9F^ZVUS!= zi^d<-Q*jNE9k^0+i)=9rf;yU)42eGsP^`& zXJDTKshlv`pj2neNa#(eO?lmOf_GkjSX(#io#78qh*|%@l3%5mob-TIWYNl1TP#l% zW9$sm-c(&2bM3{HXT2~3-oN|Hl9U0T|B`*e_I?=aO2@qrMgQGI=}Cf z!8+cl;H17oD5be$3if6XRov${RQrLG!+qGyD+im(_vqgW`3llJe0{i3)z;{^!*4S# znvU?|XwML2jhGWT9ZctTOCuv=2T>d?$WAQGb$U%^pbJ?`hF2W&?TnrppY z`NwN@O-4V|vZfM?L^vvt=~hL{OFJ~pQ!b#>!Bzr)^cPg}%yZySY9L}%xN+iYOKG)A zK*F$D!h*FhRdq{ZFFR6}+#y4%Zp})mEK~ryg5IuFFpF~B>1)r+|=HJC`^kl9y`Pq$0|tqsS}PAHAvJ2 z_u6y`mD%&-D$Mtw>TWU;?)BQ(=*uvJT^L!51Zx44q~!z4@gvEPOw`DfMi{xKpwIzr zE{2`oMB0+DLfj76|Ma)CE9`V`DP^Q8HWIACe7*R2d{eSn8~ly_qC)5wXO9$r-8ljV zLbUgqB0`)skQjbb?-c=d19evV{`A{4mtU!h4FdWpgUM$yJqf_=#YNXo&8)rqV#G62g{kL$5l^f00!>DU4N4&CFqeMCP1KI@{#L~$`%Qo0 zGVF1^K#lB-2K&F)tn4ylL6oE@V%R+>@W_ItG6HZN;@CGzumQgXooKxJ|2l7B@iD2w zz)GD5DQ;nra5_Qbyzbgu2NWs#$(NSHe=g1CpJPM3*Kio949_^JZq`z0yf*9n#KMfO z%paNmu>H8!t#BLNZdj%OrmtEOmf$ATciO8l+M*Rvm#w7!cT!f4S6wu*IMqn77D3@Z zxvJIOZmv8y{#1k4|7l-vplp-(R zsaXGAP7JV<7QVV_X0U+^Oq+5QeAx^4GQ&Fb<-`5B!8il+4swl zQV1p&!~r|saxzbb%(+vM2zTX7B$%HtXl7B=B8i%-WGQu9#K0+g*R8z$XW}d_LUIGI zj*7NJEV?2oNB3-qCx>#*(b5x9KHOc2w;yMpP12H3}E7Cup~9vrPP1iXJOxRzZxT3wfV^-;j#J7eXW zJlWf-Z*IPLYCj;qYj+6h_vB|~Lp7$L@n`6Ob@-3*FW*P}XkZE&B zzcFyS`@4MKO&UiA&O>d?)8kpRxA_dV83HGL?c<(eOiW`hVP{{zD0p_wj)S<}qeey_ z1fbIY;kz=&d~qyF1yGHHFMdMYPE#Y7*VqB-eBM4@)dnG8K=tTT{_vAVl7hc!JJH8F zc4t=-X4)2DTv7va4kNitI8}(=uC0LOp`SxQa?^-IY0_YzP+>K*t5K9Y*1dSe{)`aV zSHJubM)={rE(ze4XdA__A0CBtGy)?nxck}}b@CGupdNXu$9pFdE?=VqaKaAzzQ6dQ zX2Bzd*#N4jr+xmuoxJ1UnTIyPEh^w-`bRxAUe(|_kaz5{qj=~4iD%e^B0#BIhvqAV z4dk3_)qU0laH8fiT8h5@A8zRa4R6HA= zpqZr$Sk5*%K|Ozy38E%0fF?ZOb0B1$VAL^T!Q>+B=u4S*w_!CDlK`$E1Zn*8-f zsc@DiV5vlX#7&4XRlB~Y=>VEtoVjqR8bs>}z@a8`uKRB$YfFm)>^H6nV|O>)-v)}2 z0P8gxv&~+W$*uvB>>~_)q-smU~omg~bbB7RLMg>R$k$-11_h+VX1v=qyXJ zx$f<9&=qQTtu9#_-l81PSPmTkMNS}x@=06}Ep;PE44~5Nq9&{XmEP^fp(Ot4pI1`l zEp=jmlV>L}zch04$G4Te%|?7QDAb!e?lPgyOZe-#A*k!5e?HF_b?6Tk23}m-*it`M zMrOtWJYRgExXK;$QV#9zCpcwgiJvE3h8)KK3l!>VmUm+D3&j+820ci!^UR@fel!#T z;8j~;oxz&Z+5_s^=pFWg_|(LYGNl2v`oh>!!Z|f^nCCip@c0mQ@F>8_rjcID0;h<+ zUPm7ZL0q+{Hg&=dpE&ag#ZVa^Q6Zuy}tEepNMQ$Sgkrje~31$U2tej*%<-q)xf9k9n)CdL=oT?XAX5$<^hnW#nXPS2yia;&o`3M zhXB~uzMwD>@<;T0k_IHfZX_G?MF7j7`dnn2;#L6CM#oPI)*2DoLd(wdEFD!N8=FIl z^VQ|Z3~>y=k*eJfszcVD>zSDpA>j7B&n~h}vlg=Q2OHJ^qAk{Vm-(neJ|tiTR;NU^ zMMGd0PY9U0WMEKepMSNV7YFkaY8Y>{Egm7XzG zB-tV}7G4U0j?v485JN~n(N2y+1L|=M3^oo#Ij;k5#?4j<=H>`+if%42Cuz+zF=pl! z2)(r>41kg~FQn3hfg7Gx5d$Z4oXi#mc@IONB_0A0;Zgul32JO)n+DvOgEN%2R}`Y5 z9?Zh865y2Ke>^D#trde7!X~_suLYMt^nbYj+x=gv|8xsNP(Z~#$1;Y=7uCa9Y5Srx zobcIPL$W5oeO+6Jf20*!vAA{u8m^IGUj1Bq#2*E1rN}NV0Ge3z#|mie9;gK?l15q& zgQ0pd{_3aO0&{lirCaoxLEls!hSNy^>iB_Os0?pt)KcgLw7@&1V$6SXAT({zZSbpO zE3YwG2+*)D0(p<1c-m>x&|gb>1ixVa-=F=a6S_@TT{eLEZ$F^xg!)&z4`i&|S2eYj znAW#n1p~{2%R&^pKELW>C5YF{5N&}_mLIeO;_1WVk>XqqY+~qt$Ms7QxDE-`}$U8LJ_qYt?a9w?CxF3=v?GL`y%ZzD=+^clCRg zJeL2hQ~;oUaZ_d8=6F{QT%d-NB7(gXLidbD+6}=pbo3~GZ1daR=NYLYF3Q<4gSiy)=oYIVBZRSO$R6!gSBFU6%y&ocRVoE&b0vY>wAY zw-CU^E;^UacZ*$(ZBPCiIJsIA>6A#~X}U8Ij&-tI318b6CPrPr<1YpHnn1LvDD>geS@S9`8~D z%Mg04(Acy5a}VBzxI6sCJUqEVdWK`|k1GC-PydJjUc|>w{(G#!C9lYFtE3FkI7h66 z0J*nOYdee==H@lzI?KNM^Q|L^c2~p!3vcJX1A0`M_nYlMM}&x!hx9i3dnT;B{Q7$3 zVwU86)!f>Z%Nu~BPcGe{XK?jtcDo30TAe5<{R8>t(ER`u1n-#WcuwQ^y9@dZNT>{K@qmKfhI$JL_ zC&FczZv?chM&6GcP#N_bpaY4IGDI`BRTxcZ5z8!&HzA@=X^2Ul@G zX1Ta$Gou(U=YoU)rX)qQ$A%SD3sWyW%be>y8zAAZx&0-GV@u(_Q$~@DYX(Aqmrz~W z-WSPG>iWei76I6SAx6PY!(%L2vn(CJLWFo{R*O0qmW7P!iUQkj#4R>SO1pRx?a)!) zWec6%A*}aL5-oi{>;^20_#8?PhTK4JR|Ia^QTy8Pk;MHOf4Lk-fsz&%_lHCzS7n_X zpm}?f3Tc`me2NpmDIUOhU;|h*&4+;^pl5(~@>4WTHwWgp^BrR}O`Yd@YrnJioz#ya z7K!bFt#R`7nEkfMwtvwekNql_6f4GTaDF3bnQwbSiWSG6!2;UB*wi+dZ_C}4_KAlF z+H|U@jN2Gl&0 z#1=sbaxuwyd=m7?HVotb;=Go^D(cHb<#(cDXm zYD0(vCscU;nDU`HeEC@x`WOHl*3X5~vc0@_^>@k~5mfJ&PbZWQX+|;*ad-DA!=?Eo zP5)rYUfvzNSG5q}2kq3dDjko4PQI5IIvs`tozvMR(KJt72e*++26Y~rkDHyH$~(N} zUEP8-;5i$WsQuX+B7PEufX{UNM|33Px>bOpT>+?Tu`T}G^Nyw|T9XTKDYn@ZyenT8 z1mg3{Y~=+-6;Dl5I?OhfRpo2S0q*9)R;EGZ$0#C#ct9T~_fv-bggw-Nw zGK`k?aD3P6JW`T4D7lzlup`LAH8b08WTy;pqjz4kntAv*E}Y%vD;R!%2D=n^PCcq^ zmJC?OGlGeXS-j07;>Pw*2%O!@;}x%||FbYLD{qCvr>ZSX^vl1!4N&g#HN}9A@jaU# zOOrEmg{jXd^A(2pg|56x%bENnKz+8-Q@T8YVcnQ~m`?E_v0>sY#JM0I&r`3>kf>&czql_j1oUX%ND7iCFu|Y)~ zxTRgJ3=Jxz+3Aem^gSj7(q60Fk`KH&DGM+D3k2=wNT76Lv>*9hL5A5iH#DpXl-`*g z;Ar#qpCe{%z8wAxUIwyqRfT;brC|Mt8L|qKtdM|-lTwjHj+OqM!~#&LV^Jc(%s9;5 z-Rxs61pLSK)opEt{^cvcYkCZ!&kmNKn6N^5+39as;(F9ZQG=Dn^>82ixc7NmGJk2w zH$xnFX^p&Vx9)U0SbiNwNTTYHYLm4v=$!xe|3-ro<{q%TX`$bje2-#)mozDCk2(*H zp)5RtCBQp|0q@0`jfc3g5W%G0TZZ_ql03!6hI%keVBN+7DUuj7;|RAOT6%!* z<4jz(w|lXzPYnSgzGz7qIUg+F_I2Gd1e}^GLxwWnC`DRyAOwwD0$$jFGXC2M%Z+QD zXe$(OhULa_fpn~(0n3cz0M{yxEyGY&3#Gx?5g%v9-+yX}ZnvOO_=J8s63G6fzztQ) zOgELKcWm*-cj$Rss|v4Y1H}^7g>ME)lipu$Db0q^=_KAuP_mN*3b3-*P4@GF1=DCo z_B)-_@DppZGRGgoSCm&C;F|J!LNHXO=t4(WbLeTPhQXoMxt8{=3az?iSwmx^EownN zu%0U{FKY89nz8k(d?)l16|;P@^>afsdpR?Sd}5 ztTFD=QhNHUyuB&f928bGd_nE8(U4)jgZX{dWs|3sFBHJ@FWR%s4-=n9#)(FAcU#m6 z6)LD-uzQ{CY5woU`?a>>ppR#>r)#qsS!<{e2@06maSK{Fr0+5w+R9Q$w3 zT#^baV+Ax{281KyN*_<|optBl_zVng#kA)7WhR-iihSAJ#uBts|B0_sWH00K6MR@< zKa0jUwbf7Ve?kG3&O2jhEO4Hz<&-GH$WA_C7o34NMQN{B~I?~-7- zeQ;6>1*rpi9a0J_<3=Z(WMQ94_i0Evh&}`b;d-y%g0HGoT9ZrPTQS_})XS=a@O9K~ zi0Dguv?ce7drFM7FM21!<2iBn?(QLB;t?;QI zyZGlH9;ueU2C3>%rDx)3@DBp*g8u?ILNVHj_7`L`eaml^t1gtCg3{l|R~_!v3Ma81 z*=;^v#Z3uRydW(_#w~9xkWZ{CgKyw+K2Xr)k-n{y$!6{Q3Lb1uuGea2lYF4AeG0+V zIS~`l6GUSzXK#(ZXhld$Z*nwkCWu!xOv%{2^r6^`Ol#sS!=ziBp7>QvuPTOTp!hZ(b{aG10V#z(cQM-x#V%g{S&n?%> kelEbb4*4v#YdcoAP*-IP4!+)L22BHm!xo1a2c07SA6;5Yn*aa+ literal 0 HcmV?d00001 From 4696470b19a711abc0a1e5a116067a357d549edf Mon Sep 17 00:00:00 2001 From: mfahampshire Date: Wed, 2 Aug 2023 16:26:41 +0200 Subject: [PATCH 07/21] rephrased intro --- documentation/dev-portal/src/SUMMARY.md | 2 ++ documentation/dev-portal/src/introduction.md | 4 ++-- documentation/dev-portal/src/quickstart/chat-demo.md | 5 +++++ .../dev-portal/src/quickstart/cred-playground.md | 5 +++++ documentation/dev-portal/src/quickstart/overview.md | 12 +++--------- 5 files changed, 17 insertions(+), 11 deletions(-) create mode 100644 documentation/dev-portal/src/quickstart/chat-demo.md create mode 100644 documentation/dev-portal/src/quickstart/cred-playground.md diff --git a/documentation/dev-portal/src/SUMMARY.md b/documentation/dev-portal/src/SUMMARY.md index aeae804662..0e0c02bc58 100644 --- a/documentation/dev-portal/src/SUMMARY.md +++ b/documentation/dev-portal/src/SUMMARY.md @@ -11,6 +11,8 @@ # Quickstart - [Overview](quickstart/overview.md) +- [Chat demo (webapp)](quickstart/chat-demo.md) +- [Coconut Credential Playground (webapp)](quickstart/cred-playground.md) - [SOCKS Proxy (CLI)](quickstart/socks-proxy.md) - [NymConnect Beta (GUI)](quickstart/nymconnect-gui.md) diff --git a/documentation/dev-portal/src/introduction.md b/documentation/dev-portal/src/introduction.md index d679a77c53..7335fab32b 100644 --- a/documentation/dev-portal/src/introduction.md +++ b/documentation/dev-portal/src/introduction.md @@ -1,5 +1,5 @@ # Introduction -Welcome to the Nym Developer Portal, containing the resources and tools needed to build privacy enhanced apps (PEApps) with Nym's technology. Whether you're a seasoned developer or just getting started, our portal is designed to help you create decentralized applications and services utilising the Nym mixnet. +Welcome to the Nym Developer Portal, containing quickstart resources, user manuals, integration information, and tutorials outlining to start building privacy enhanced apps. -Join our community of developers and start building the decentralized future today! +For more in-depth information about nodes, network traffic flows, etc check out the [docs](https://nymtech.net/docs). diff --git a/documentation/dev-portal/src/quickstart/chat-demo.md b/documentation/dev-portal/src/quickstart/chat-demo.md new file mode 100644 index 0000000000..6e2f5c244a --- /dev/null +++ b/documentation/dev-portal/src/quickstart/chat-demo.md @@ -0,0 +1,5 @@ +# Chat demo (webapp) + +You can find a browser-based 'hello world' chat app [here](https://chat-demo.nymtech.net). + +Either open in two browser windows and send messages to yourself, or share with a friend and send messages to each other through the mixnet. diff --git a/documentation/dev-portal/src/quickstart/cred-playground.md b/documentation/dev-portal/src/quickstart/cred-playground.md new file mode 100644 index 0000000000..aa2220940c --- /dev/null +++ b/documentation/dev-portal/src/quickstart/cred-playground.md @@ -0,0 +1,5 @@ +# Coconut Credential Playground (webapp) + +There is a coconut-scheme based Credential Library playground [here](https://coco-demo.nymtech.net/). This is a WASM implementation of our Coconut libraries which generate raw Coconut credentials. Test it to create and re-randomize your own credentials. + +For more information on what is happening here check out the [Coconut docs](https://nymtech.net/docs/coconut.html). diff --git a/documentation/dev-portal/src/quickstart/overview.md b/documentation/dev-portal/src/quickstart/overview.md index b2ac4199c9..534ed60fe5 100644 --- a/documentation/dev-portal/src/quickstart/overview.md +++ b/documentation/dev-portal/src/quickstart/overview.md @@ -1,13 +1,7 @@ # Overview -There are multiple options to quickly connect to Nym and see the network in action without the need for any code changes to your application. At most, these involve running Nym as a second process alongside an existing application in order to send traffic through the mixnet. +There are multiple options to quickly connect to Nym and play with both the mixnet and credentials on the Sandbox testnet. -Demo applications: -* a browser-based 'hello world' [chat application](https://chat-demo.nymtech.net). Either open in two browser windows and send messages to yourself, or share with a friend and send messages to each other through the mixnet! -* a Coconut-scheme based [Credential Library](https://coco-demo.nymtech.net/). This is a WASM implementation of our Coconut libraries which generate raw Coconut credentials. Test it to create and re-randomize your own credentials! -
-Proxy traffic with the Nym Socks5 client: -* set up a plug-and-play connection with the [NymConnect](./nymconnect-gui.md) GUI for proxying Telegram, Electrum, Keybase or Blockstream Green traffic through the mixnet (~2 minutes). -* [Download and run](./socks-proxy.md) the Nym Socks5 client via the CLI, for other desktop applications with SOCKS5 connection options (~30 minutes). +At most, these involve running Nym as a second process alongside an existing application in order to send traffic through the mixnet, most are either interact webpages or a standalone app. -If you've already covered the information in this section, or want to jump straight into integrating/ a Nym connection into an existing application, head to the [Integrations](../integrations/integration-options.md) section. +If you've already covered the information in this section, or want to jump straight into integrating/ a Nym connection into an existing application, head to the [Integrations](../integrations/integration-options.md) section. From 49440bf60e752a1b30219103474055f2ff6f13cc Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bogdan-=C8=98tefan=20Neac=C5=9Fu?= Date: Mon, 7 Aug 2023 12:27:31 +0300 Subject: [PATCH 08/21] Apply fix from feature/ephemera to develop too (#3698) (#3742) --- common/crypto/Cargo.toml | 4 +- .../crypto/src/asymmetric/encryption/mod.rs | 6 + common/crypto/src/asymmetric/identity/mod.rs | 2 + common/nymsphinx/acknowledgements/Cargo.toml | 2 +- common/nymsphinx/addressing/Cargo.toml | 2 +- common/nymsphinx/forwarding/Cargo.toml | 2 +- common/nymsphinx/params/Cargo.toml | 4 + common/nymsphinx/params/src/packet_sizes.rs | 43 +- common/nymsphinx/routing/Cargo.toml | 4 +- common/nymsphinx/types/Cargo.toml | 8 +- common/nymsphinx/types/src/lib.rs | 28 ++ common/topology/Cargo.toml | 4 +- common/topology/src/error.rs | 1 + contracts/Cargo.lock | 448 +----------------- nym-connect/desktop/Cargo.lock | 2 - nym-wallet/Cargo.lock | 137 +----- 16 files changed, 112 insertions(+), 585 deletions(-) diff --git a/common/crypto/Cargo.toml b/common/crypto/Cargo.toml index c6521d9056..27702da016 100644 --- a/common/crypto/Cargo.toml +++ b/common/crypto/Cargo.toml @@ -27,7 +27,7 @@ thiserror = "1.0.37" zeroize = { workspace = true, optional = true, features = ["zeroize_derive"] } # internal -nym-sphinx-types = { path = "../nymsphinx/types", version = "0.2.0" } +nym-sphinx-types = { path = "../nymsphinx/types", version = "0.2.0", default-features = false } nym-pemstore = { path = "../../common/pemstore", version = "0.3.0" } [dev-dependencies] @@ -38,3 +38,5 @@ serde = ["serde_crate", "serde_bytes", "ed25519-dalek/serde", "x25519-dalek/serd asymmetric = ["x25519-dalek", "ed25519-dalek", "zeroize"] hashing = ["blake3", "digest", "hkdf", "hmac", "generic-array"] symmetric = ["aes", "ctr", "cipher", "generic-array"] +sphinx = ["nym-sphinx-types/sphinx"] +outfox = ["nym-sphinx-types/outfox"] diff --git a/common/crypto/src/asymmetric/encryption/mod.rs b/common/crypto/src/asymmetric/encryption/mod.rs index 5052e785a0..6c45d41d60 100644 --- a/common/crypto/src/asymmetric/encryption/mod.rs +++ b/common/crypto/src/asymmetric/encryption/mod.rs @@ -273,36 +273,42 @@ impl PemStorableKey for PrivateKey { } // compatibility with sphinx keys: +#[cfg(feature = "sphinx")] impl From for nym_sphinx_types::PublicKey { fn from(key: PublicKey) -> Self { nym_sphinx_types::PublicKey::from(key.to_bytes()) } } +#[cfg(feature = "sphinx")] impl<'a> From<&'a PublicKey> for nym_sphinx_types::PublicKey { fn from(key: &'a PublicKey) -> Self { nym_sphinx_types::PublicKey::from((*key).to_bytes()) } } +#[cfg(feature = "sphinx")] impl From for PublicKey { fn from(pub_key: nym_sphinx_types::PublicKey) -> Self { Self(x25519_dalek::PublicKey::from(*pub_key.as_bytes())) } } +#[cfg(feature = "sphinx")] impl From for nym_sphinx_types::PrivateKey { fn from(key: PrivateKey) -> Self { nym_sphinx_types::PrivateKey::from(key.to_bytes()) } } +#[cfg(feature = "sphinx")] impl<'a> From<&'a PrivateKey> for nym_sphinx_types::PrivateKey { fn from(key: &'a PrivateKey) -> Self { nym_sphinx_types::PrivateKey::from(key.to_bytes()) } } +#[cfg(feature = "sphinx")] impl From for PrivateKey { fn from(private_key: nym_sphinx_types::PrivateKey) -> Self { let private_key_bytes = private_key.to_bytes(); diff --git a/common/crypto/src/asymmetric/identity/mod.rs b/common/crypto/src/asymmetric/identity/mod.rs index c552206da3..efe11acf4f 100644 --- a/common/crypto/src/asymmetric/identity/mod.rs +++ b/common/crypto/src/asymmetric/identity/mod.rs @@ -5,6 +5,7 @@ pub use ed25519_dalek::ed25519::signature::Signature as SignatureTrait; pub use ed25519_dalek::SignatureError; pub use ed25519_dalek::{Verifier, PUBLIC_KEY_LENGTH, SECRET_KEY_LENGTH, SIGNATURE_LENGTH}; use nym_pemstore::traits::{PemStorableKey, PemStorableKeyPair}; +#[cfg(feature = "sphinx")] use nym_sphinx_types::{DestinationAddressBytes, DESTINATION_ADDRESS_LENGTH}; use std::fmt::{self, Display, Formatter}; use std::str::FromStr; @@ -113,6 +114,7 @@ impl Display for PublicKey { } impl PublicKey { + #[cfg(feature = "sphinx")] pub fn derive_destination_address(&self) -> DestinationAddressBytes { let mut temporary_address = [0u8; DESTINATION_ADDRESS_LENGTH]; let public_key_bytes = self.to_bytes(); diff --git a/common/nymsphinx/acknowledgements/Cargo.toml b/common/nymsphinx/acknowledgements/Cargo.toml index 95b3d8b30c..da9977d1f3 100644 --- a/common/nymsphinx/acknowledgements/Cargo.toml +++ b/common/nymsphinx/acknowledgements/Cargo.toml @@ -19,7 +19,7 @@ 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-sphinx-types = { path = "../types", features = ["sphinx"] } nym-topology = { path = "../../topology" } [features] diff --git a/common/nymsphinx/addressing/Cargo.toml b/common/nymsphinx/addressing/Cargo.toml index f9c646e04b..c6bc2856e3 100644 --- a/common/nymsphinx/addressing/Cargo.toml +++ b/common/nymsphinx/addressing/Cargo.toml @@ -9,7 +9,7 @@ repository = { workspace = true } [dependencies] nym-crypto = { path = "../../crypto", features = ["asymmetric"] } # all addresses are expressed in terms on their crypto keys -nym-sphinx-types = { path = "../types" } # we need to be able to refer to some types defined inside sphinx crate +nym-sphinx-types = { path = "../types", features = ["sphinx"] } # we need to be able to refer to some types defined inside sphinx crate serde = "1.0" # implementing serialization/deserialization for some types, like `Recipient` thiserror = "1.0.37" diff --git a/common/nymsphinx/forwarding/Cargo.toml b/common/nymsphinx/forwarding/Cargo.toml index 6509098398..4060cbf076 100644 --- a/common/nymsphinx/forwarding/Cargo.toml +++ b/common/nymsphinx/forwarding/Cargo.toml @@ -10,6 +10,6 @@ repository = { workspace = true } [dependencies] nym-sphinx-addressing = { path = "../addressing" } nym-sphinx-params = { path = "../params" } -nym-sphinx-types = { path = "../types" } +nym-sphinx-types = { path = "../types", features = ["sphinx", "outfox"] } nym-outfox = { path = "../../../nym-outfox" } thiserror = "1" diff --git a/common/nymsphinx/params/Cargo.toml b/common/nymsphinx/params/Cargo.toml index bc9b40b9a8..57872bb0ca 100644 --- a/common/nymsphinx/params/Cargo.toml +++ b/common/nymsphinx/params/Cargo.toml @@ -13,3 +13,7 @@ serde = { workspace = true, features = ["derive"] } nym-crypto = { path = "../../crypto", features = ["hashing", "symmetric"] } nym-sphinx-types = { path = "../types" } + +[features] +sphinx = ["nym-crypto/sphinx", "nym-sphinx-types/outfox"] +outfox = ["nym-crypto/outfox", "nym-sphinx-types/outfox"] diff --git a/common/nymsphinx/params/src/packet_sizes.rs b/common/nymsphinx/params/src/packet_sizes.rs index a6613f3024..58d9681efc 100644 --- a/common/nymsphinx/params/src/packet_sizes.rs +++ b/common/nymsphinx/params/src/packet_sizes.rs @@ -1,11 +1,11 @@ // Copyright 2021-2023 - Nym Technologies SA // SPDX-License-Identifier: Apache-2.0 -use crate::{PacketType, FRAG_ID_LEN}; -use nym_sphinx_types::header::HEADER_SIZE; -use nym_sphinx_types::{ - MIN_PACKET_SIZE, MIX_PARAMS_LEN, OUTFOX_PACKET_OVERHEAD, PAYLOAD_OVERHEAD_SIZE, -}; +use crate::PacketType; +#[cfg(feature = "sphinx")] +use nym_sphinx_types::{header::HEADER_SIZE, PAYLOAD_OVERHEAD_SIZE}; +#[cfg(feature = "outfox")] +use nym_sphinx_types::{MIN_PACKET_SIZE, MIX_PARAMS_LEN, OUTFOX_PACKET_OVERHEAD}; use serde::{Deserialize, Serialize}; use std::cmp::Ordering; use std::convert::TryFrom; @@ -14,6 +14,7 @@ use std::str::FromStr; use thiserror::Error; // each sphinx packet contains mandatory header and payload padding + markers +#[cfg(feature = "sphinx")] const SPHINX_PACKET_OVERHEAD: usize = HEADER_SIZE + PAYLOAD_OVERHEAD_SIZE; // it's up to the smart people to figure those values out : ) @@ -22,15 +23,23 @@ const SPHINX_PACKET_OVERHEAD: usize = HEADER_SIZE + PAYLOAD_OVERHEAD_SIZE; // TODO: I'm not entirely sure if we can easily extract `::NonceSize` // into a const usize before relevant stuff is stabilised in rust... +#[cfg(feature = "sphinx")] const ACK_IV_SIZE: usize = 16; -const ACK_PACKET_SIZE: usize = ACK_IV_SIZE + FRAG_ID_LEN + SPHINX_PACKET_OVERHEAD; +#[cfg(feature = "sphinx")] +const ACK_PACKET_SIZE: usize = ACK_IV_SIZE + crate::FRAG_ID_LEN + SPHINX_PACKET_OVERHEAD; +#[cfg(feature = "sphinx")] const REGULAR_PACKET_SIZE: usize = 2 * 1024 + SPHINX_PACKET_OVERHEAD; +#[cfg(feature = "sphinx")] const EXTENDED_PACKET_SIZE_8: usize = 8 * 1024 + SPHINX_PACKET_OVERHEAD; +#[cfg(feature = "sphinx")] const EXTENDED_PACKET_SIZE_16: usize = 16 * 1024 + SPHINX_PACKET_OVERHEAD; +#[cfg(feature = "sphinx")] const EXTENDED_PACKET_SIZE_32: usize = 32 * 1024 + SPHINX_PACKET_OVERHEAD; +#[cfg(feature = "outfox")] const OUTFOX_ACK_PACKET_SIZE: usize = MIN_PACKET_SIZE + OUTFOX_PACKET_OVERHEAD; +#[cfg(feature = "outfox")] const OUTFOX_REGULAR_PACKET_SIZE: usize = 2 * 1024 + OUTFOX_PACKET_OVERHEAD; #[derive(Debug, Error)] @@ -153,38 +162,55 @@ impl TryFrom for PacketSize { impl PacketSize { pub const fn size(self) -> usize { + #[allow(unreachable_patterns)] match self { + #[cfg(feature = "sphinx")] PacketSize::RegularPacket => REGULAR_PACKET_SIZE, + #[cfg(feature = "sphinx")] PacketSize::AckPacket => ACK_PACKET_SIZE, + #[cfg(feature = "sphinx")] PacketSize::ExtendedPacket8 => EXTENDED_PACKET_SIZE_8, + #[cfg(feature = "sphinx")] PacketSize::ExtendedPacket16 => EXTENDED_PACKET_SIZE_16, + #[cfg(feature = "sphinx")] PacketSize::ExtendedPacket32 => EXTENDED_PACKET_SIZE_32, + #[cfg(feature = "outfox")] PacketSize::OutfoxRegularPacket => OUTFOX_REGULAR_PACKET_SIZE, + #[cfg(feature = "outfox")] PacketSize::OutfoxAckPacket => OUTFOX_ACK_PACKET_SIZE, + _ => 0, } } pub const fn header_size(&self) -> usize { + #[allow(unreachable_patterns)] match self { + #[cfg(feature = "sphinx")] PacketSize::RegularPacket | PacketSize::AckPacket | PacketSize::ExtendedPacket8 | PacketSize::ExtendedPacket16 | PacketSize::ExtendedPacket32 => HEADER_SIZE, + #[cfg(feature = "outfox")] PacketSize::OutfoxRegularPacket | PacketSize::OutfoxAckPacket => MIX_PARAMS_LEN, + _ => 0, } } pub const fn payload_overhead(&self) -> usize { + #[allow(unreachable_patterns)] match self { + #[cfg(feature = "sphinx")] PacketSize::RegularPacket | PacketSize::AckPacket | PacketSize::ExtendedPacket8 | PacketSize::ExtendedPacket16 | PacketSize::ExtendedPacket32 => PAYLOAD_OVERHEAD_SIZE, + #[cfg(feature = "outfox")] PacketSize::OutfoxRegularPacket | PacketSize::OutfoxAckPacket => { OUTFOX_PACKET_OVERHEAD - MIX_PARAMS_LEN // Mix params are calculated into the total overhead so we take them out here } + _ => 0, } } @@ -242,11 +268,16 @@ impl PacketSize { plaintext_size: usize, packet_type: PacketType, ) -> Result { + #[allow(unreachable_patterns)] let overhead = match packet_type { + #[cfg(feature = "sphinx")] PacketType::Mix => SPHINX_PACKET_OVERHEAD, #[allow(deprecated)] + #[cfg(feature = "sphinx")] PacketType::Vpn => SPHINX_PACKET_OVERHEAD, + #[cfg(feature = "outfox")] PacketType::Outfox => OUTFOX_PACKET_OVERHEAD, + _ => 0, }; let packet_size = plaintext_size + overhead; Self::get_type(packet_size) diff --git a/common/nymsphinx/routing/Cargo.toml b/common/nymsphinx/routing/Cargo.toml index c0f7cf7628..37b8d5a4dc 100644 --- a/common/nymsphinx/routing/Cargo.toml +++ b/common/nymsphinx/routing/Cargo.toml @@ -11,4 +11,6 @@ repository = { workspace = true } thiserror = { workspace = true } nym-sphinx-addressing = { path = "../addressing" } -nym-sphinx-types = { path = "../types" } \ No newline at end of file +nym-sphinx-types = { path = "../types", features = ["sphinx"] } + +[features] \ No newline at end of file diff --git a/common/nymsphinx/types/Cargo.toml b/common/nymsphinx/types/Cargo.toml index 2c52ef03d9..0569ef1406 100644 --- a/common/nymsphinx/types/Cargo.toml +++ b/common/nymsphinx/types/Cargo.toml @@ -8,6 +8,10 @@ license = { workspace = true } repository = { workspace = true } [dependencies] -sphinx-packet = { version = "0.1.0" } -nym-outfox = { path = "../../../nym-outfox" } +sphinx-packet = { version = "0.1.0", optional = true } +nym-outfox = { path = "../../../nym-outfox", optional = true } thiserror = "1" + +[features] +sphinx = ["sphinx-packet"] +outfox = ["nym-outfox"] diff --git a/common/nymsphinx/types/src/lib.rs b/common/nymsphinx/types/src/lib.rs index bd3063f939..d75060e9b0 100644 --- a/common/nymsphinx/types/src/lib.rs +++ b/common/nymsphinx/types/src/lib.rs @@ -1,12 +1,15 @@ // Copyright 2021 - Nym Technologies SA // SPDX-License-Identifier: Apache-2.0 +#[cfg(feature = "outfox")] pub use nym_outfox::{ constants::MIN_PACKET_SIZE, constants::MIX_PARAMS_LEN, constants::OUTFOX_PACKET_OVERHEAD, error::OutfoxError, }; // re-exporting types and constants available in sphinx +#[cfg(feature = "outfox")] use nym_outfox::packet::{OutfoxPacket, OutfoxProcessedPacket}; +#[cfg(feature = "sphinx")] pub use sphinx_packet::{ constants::{ self, DESTINATION_ADDRESS_LENGTH, IDENTIFIER_LENGTH, MAX_PATH_LENGTH, NODE_ADDRESS_LENGTH, @@ -20,6 +23,7 @@ pub use sphinx_packet::{ surb::{SURBMaterial, SURB}, Error as SphinxError, ProcessedPacket, }; +#[cfg(feature = "sphinx")] use sphinx_packet::{SphinxPacket, SphinxPacketBuilder}; use std::{array::TryFromSliceError, fmt}; use thiserror::Error; @@ -27,9 +31,11 @@ use thiserror::Error; #[derive(Error, Debug)] pub enum NymPacketError { #[error("Sphinx error: {0}")] + #[cfg(feature = "sphinx")] Sphinx(#[from] sphinx_packet::Error), #[error("Outfox error: {0}")] + #[cfg(feature = "outfox")] Outfox(#[from] nym_outfox::error::OutfoxError), #[error("{0}")] @@ -38,31 +44,40 @@ pub enum NymPacketError { #[allow(clippy::large_enum_variant)] pub enum NymPacket { + #[cfg(feature = "sphinx")] Sphinx(SphinxPacket), + #[cfg(feature = "outfox")] Outfox(OutfoxPacket), } pub enum NymProcessedPacket { + #[cfg(feature = "sphinx")] Sphinx(ProcessedPacket), + #[cfg(feature = "outfox")] Outfox(OutfoxProcessedPacket), } impl fmt::Debug for NymPacket { fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { + #[allow(unreachable_patterns)] match &self { + #[cfg(feature = "sphinx")] NymPacket::Sphinx(packet) => f .debug_struct("NymPacket::Sphinx") .field("len", &packet.len()) .finish(), + #[cfg(feature = "outfox")] NymPacket::Outfox(packet) => f .debug_struct("NymPacket::Outfox") .field("len", &packet.len()) .finish(), + _ => write!(f, ""), } } } impl NymPacket { + #[cfg(feature = "sphinx")] pub fn sphinx_build>( size: usize, message: M, @@ -76,10 +91,12 @@ impl NymPacket { .build_packet(message, route, destination, delays)?, )) } + #[cfg(feature = "sphinx")] pub fn sphinx_from_bytes(bytes: &[u8]) -> Result { Ok(NymPacket::Sphinx(SphinxPacket::from_bytes(bytes)?)) } + #[cfg(feature = "outfox")] pub fn outfox_build>( payload: M, route: &[Node], @@ -94,14 +111,19 @@ impl NymPacket { )?)) } + #[cfg(feature = "outfox")] pub fn outfox_from_bytes(bytes: &[u8]) -> Result { Ok(NymPacket::Outfox(OutfoxPacket::try_from(bytes)?)) } pub fn len(&self) -> usize { + #[allow(unreachable_patterns)] match self { + #[cfg(feature = "sphinx")] NymPacket::Sphinx(packet) => packet.len(), + #[cfg(feature = "outfox")] NymPacket::Outfox(packet) => packet.len(), + _ => 0, } } @@ -110,12 +132,17 @@ impl NymPacket { } pub fn to_bytes(&self) -> Result, NymPacketError> { + #[allow(unreachable_patterns)] match self { + #[cfg(feature = "sphinx")] NymPacket::Sphinx(packet) => Ok(packet.to_bytes()), + #[cfg(feature = "outfox")] NymPacket::Outfox(packet) => Ok(packet.to_bytes()?), + _ => Ok(vec![]), } } + #[cfg(feature = "sphinx")] pub fn process( self, node_secret_key: &PrivateKey, @@ -124,6 +151,7 @@ impl NymPacket { NymPacket::Sphinx(packet) => { Ok(NymProcessedPacket::Sphinx(packet.process(node_secret_key)?)) } + #[cfg(feature = "outfox")] NymPacket::Outfox(mut packet) => { let next_address = packet.decode_next_layer(node_secret_key)?; Ok(NymProcessedPacket::Outfox(OutfoxProcessedPacket::new( diff --git a/common/topology/Cargo.toml b/common/topology/Cargo.toml index 1d41a93ee4..bfe2c98573 100644 --- a/common/topology/Cargo.toml +++ b/common/topology/Cargo.toml @@ -19,10 +19,10 @@ thiserror = "1.0.37" async-trait = { workspace = true, optional = true } ## internal -nym-crypto = { path = "../crypto" } +nym-crypto = { path = "../crypto", features = ["sphinx", "outfox"] } nym-mixnet-contract-common = { path = "../cosmwasm-smart-contracts/mixnet-contract" } nym-sphinx-addressing = { path = "../nymsphinx/addressing" } -nym-sphinx-types = { path = "../nymsphinx/types" } +nym-sphinx-types = { path = "../nymsphinx/types", features = ["sphinx", "outfox"] } nym-sphinx-routing = { path = "../nymsphinx/routing" } nym-bin-common = { path = "../bin-common" } diff --git a/common/topology/src/error.rs b/common/topology/src/error.rs index bb36b42886..3f2523576f 100644 --- a/common/topology/src/error.rs +++ b/common/topology/src/error.rs @@ -41,6 +41,7 @@ pub enum NymTopologyError { PayloadBuilder, #[error("Outfox: {0}")] + #[cfg(feature = "outfox")] Outfox(#[from] nym_sphinx_types::OutfoxError), #[error("{0}")] diff --git a/contracts/Cargo.lock b/contracts/Cargo.lock index 0c3efd0a24..3d719dd6dc 100644 --- a/contracts/Cargo.lock +++ b/contracts/Cargo.lock @@ -2,29 +2,6 @@ # It is not intended for manual editing. version = 3 -[[package]] -name = "aead" -version = "0.5.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d122413f284cf2d62fb1b7db97e02edb8cda96d769b16e443a4f6195e35662b0" -dependencies = [ - "crypto-common", - "generic-array 0.14.6", -] - -[[package]] -name = "aes" -version = "0.7.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9e8b47f52ea9bae42228d07ec09eb676433d7c4ed1ebdf0f1d1c29ed446f1ab8" -dependencies = [ - "cfg-if", - "cipher 0.3.0", - "cpufeatures", - "ctr", - "opaque-debug 0.3.0", -] - [[package]] name = "ahash" version = "0.7.6" @@ -42,18 +19,6 @@ version = "1.0.70" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "7de8ce5e0f9f8d88245311066a578d72b7af3e7088f32783804676302df237e4" -[[package]] -name = "arrayref" -version = "0.3.7" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6b4930d2cb77ce62f89ee5d5289b4ac049559b1c45539271f5ed4fdc7db34545" - -[[package]] -name = "arrayvec" -version = "0.7.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "96d30a06541fbafbc7f82ed10c06164cfbd2c401138f6addd8404629c4b16711" - [[package]] name = "autocfg" version = "1.1.0" @@ -90,39 +55,13 @@ version = "1.3.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "bef38d45163c2f1dde094a7dfd33ccf595c92905c8f8f4fdc18d06fb1037718a" -[[package]] -name = "blake2" -version = "0.8.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "94cb07b0da6a73955f8fb85d24c466778e70cda767a568229b104f0264089330" -dependencies = [ - "byte-tools", - "crypto-mac 0.7.0", - "digest 0.8.1", - "opaque-debug 0.2.3", -] - -[[package]] -name = "blake3" -version = "1.4.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "199c42ab6972d92c9f8995f086273d25c42fc0f7b2a1fcefba465c1352d25ba5" -dependencies = [ - "arrayref", - "arrayvec", - "cc", - "cfg-if", - "constant_time_eq", - "digest 0.10.7", -] - [[package]] name = "block-buffer" version = "0.9.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "4152116fd6e9dadb291ae18fc1ec3575ed6d84c29642d97890f4b4a3417297e4" dependencies = [ - "generic-array 0.14.6", + "generic-array", ] [[package]] @@ -131,7 +70,7 @@ version = "0.10.4" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "3078c7629b62d3f0439517fa394996acacc5cbc91c5a20d8c658e77abd503a71" dependencies = [ - "generic-array 0.14.6", + "generic-array", ] [[package]] @@ -146,12 +85,6 @@ version = "3.12.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "9b1ce199063694f33ffb7dd4e0ee620741495c32833cde5aa08f02a0bf96f0c8" -[[package]] -name = "byte-tools" -version = "0.3.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e3b5ca7a04898ad4bcd41c90c5285445ff5b791899bb1b0abdd2a2aa791211d7" - [[package]] name = "byteorder" version = "1.4.3" @@ -179,60 +112,6 @@ version = "1.0.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "baf1de4339761588bc0619e3cbc0120ee582ebb74b53b4efbf79117bd2da40fd" -[[package]] -name = "chacha" -version = "0.3.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ddf3c081b5fba1e5615640aae998e0fbd10c24cbd897ee39ed754a77601a4862" -dependencies = [ - "byteorder", - "keystream", -] - -[[package]] -name = "chacha20" -version = "0.9.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c3613f74bd2eac03dad61bd53dbe620703d4371614fe0bc3b9f04dd36fe4e818" -dependencies = [ - "cfg-if", - "cipher 0.4.4", - "cpufeatures", -] - -[[package]] -name = "chacha20poly1305" -version = "0.10.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "10cd79432192d1c0f4e1a0fef9527696cc039165d729fb41b3f4f4f354c2dc35" -dependencies = [ - "aead", - "chacha20", - "cipher 0.4.4", - "poly1305", - "zeroize", -] - -[[package]] -name = "cipher" -version = "0.3.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7ee52072ec15386f770805afd189a01c8841be8696bed250fa2f13c4c0d6dfb7" -dependencies = [ - "generic-array 0.14.6", -] - -[[package]] -name = "cipher" -version = "0.4.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "773f3b9af64447d2ce9850330c473515014aa235e6a783b02db81ff39e4a3dad" -dependencies = [ - "crypto-common", - "inout", - "zeroize", -] - [[package]] name = "coconut-test" version = "0.1.0" @@ -264,12 +143,6 @@ version = "0.9.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "520fbf3c07483f94e3e3ca9d0cfd913d7718ef2483d2cfd91c0d9e91474ab913" -[[package]] -name = "constant_time_eq" -version = "0.3.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f7144d30dcf0fafbce74250a3963025d8d52177934239851c917d29f1df280c2" - [[package]] name = "cosmwasm-crypto" version = "1.2.5" @@ -355,49 +228,6 @@ dependencies = [ "libc", ] -[[package]] -name = "crossbeam-channel" -version = "0.5.8" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a33c2bf77f2df06183c3aa30d1e96c0695a313d4f9c453cc3762a6db39f99200" -dependencies = [ - "cfg-if", - "crossbeam-utils", -] - -[[package]] -name = "crossbeam-deque" -version = "0.8.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ce6fd6f855243022dcecf8702fef0c297d4338e226845fe067f6341ad9fa0cef" -dependencies = [ - "cfg-if", - "crossbeam-epoch", - "crossbeam-utils", -] - -[[package]] -name = "crossbeam-epoch" -version = "0.9.15" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ae211234986c545741a7dc064309f67ee1e5ad243d0e48335adc0484d960bcc7" -dependencies = [ - "autocfg", - "cfg-if", - "crossbeam-utils", - "memoffset", - "scopeguard", -] - -[[package]] -name = "crossbeam-utils" -version = "0.8.16" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5a22b2d63d4d1dc0b7f1b6b2747dd0088008a9be28b6ddf0b1e7d335e3037294" -dependencies = [ - "cfg-if", -] - [[package]] name = "crunchy" version = "0.2.2" @@ -410,9 +240,9 @@ version = "0.4.9" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "ef2b4b23cddf68b89b8f8069890e8c270d54e2d5fe1b143820234805e4cb17ef" dependencies = [ - "generic-array 0.14.6", + "generic-array", "rand_core 0.6.4", - "subtle 2.4.1", + "subtle", "zeroize", ] @@ -422,40 +252,10 @@ version = "0.1.6" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "1bfb12502f3fc46cca1bb51ac28df9d618d813cdc3d2f25b9fe775a34af26bb3" dependencies = [ - "generic-array 0.14.6", - "rand_core 0.6.4", + "generic-array", "typenum", ] -[[package]] -name = "crypto-mac" -version = "0.7.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4434400df11d95d556bac068ddfedd482915eb18fe8bea89bc80b6e4b1c179e5" -dependencies = [ - "generic-array 0.12.4", - "subtle 1.0.0", -] - -[[package]] -name = "crypto-mac" -version = "0.11.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b1d1a86f49236c215f271d40892d5fc950490551400b02ef360692c29815c714" -dependencies = [ - "generic-array 0.14.6", - "subtle 2.4.1", -] - -[[package]] -name = "ctr" -version = "0.8.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "049bb91fb4aaf0e3c7efa6cd5ef877dbbbd15b39dad06d9948de4ec8a75761ea" -dependencies = [ - "cipher 0.3.0", -] - [[package]] name = "curve25519-dalek" version = "3.2.0" @@ -465,7 +265,7 @@ dependencies = [ "byteorder", "digest 0.9.0", "rand_core 0.5.1", - "subtle 2.4.1", + "subtle", "zeroize", ] @@ -676,22 +476,13 @@ dependencies = [ "syn 1.0.109", ] -[[package]] -name = "digest" -version = "0.8.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f3d0c8c8752312f9713efd397ff63acb9f85585afbf179282e720e7704954dd5" -dependencies = [ - "generic-array 0.12.4", -] - [[package]] name = "digest" version = "0.9.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "d3dd60d1080a57a05ab032377049e0591415d2b31afd7028356dbf3cc6dcb066" dependencies = [ - "generic-array 0.14.6", + "generic-array", ] [[package]] @@ -702,7 +493,7 @@ checksum = "9ed9a281f7bc9b7576e61468ba615a66a5c8cfdff42420a70aa82701a3b1e292" dependencies = [ "block-buffer 0.10.4", "crypto-common", - "subtle 2.4.1", + "subtle", ] [[package]] @@ -778,12 +569,12 @@ dependencies = [ "der", "digest 0.10.7", "ff", - "generic-array 0.14.6", + "generic-array", "group", "pkcs8", "rand_core 0.6.4", "sec1", - "subtle 2.4.1", + "subtle", "zeroize", ] @@ -844,7 +635,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "d013fc25338cc558c5c2cfbad646908fb23591e2404481826742b651c9af7160" dependencies = [ "rand_core 0.6.4", - "subtle 2.4.1", + "subtle", ] [[package]] @@ -963,15 +754,6 @@ dependencies = [ "slab", ] -[[package]] -name = "generic-array" -version = "0.12.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ffdf9f34f1447443d37393cc6c2b8313aebddcd96906caf34e54c68d8e57d7bd" -dependencies = [ - "typenum", -] - [[package]] name = "generic-array" version = "0.14.6" @@ -1002,10 +784,8 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "be4136b2a15dd319360be1c07d9933517ccf0be8f16bf62a3bee4f0d618df427" dependencies = [ "cfg-if", - "js-sys", "libc", "wasi 0.11.0+wasi-snapshot-preview1", - "wasm-bindgen", ] [[package]] @@ -1041,7 +821,7 @@ checksum = "5dfbfb3a6cfbd390d5c9564ab283a0349b9b9fcd46a706c1eb10e0db70bfbac7" dependencies = [ "ff", "rand_core 0.6.4", - "subtle 2.4.1", + "subtle", ] [[package]] @@ -1065,26 +845,6 @@ version = "0.4.3" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "7f24254aa9a54b5c858eaee2f5bccdb46aaf0e486a595ed5fd8f86ba55232a70" -[[package]] -name = "hkdf" -version = "0.11.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "01706d578d5c281058480e673ae4086a9f4710d8df1ad80a5b03e39ece5f886b" -dependencies = [ - "digest 0.9.0", - "hmac 0.11.0", -] - -[[package]] -name = "hmac" -version = "0.11.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2a2a2320eb7ec0ebe8da8f744d7812d9fc4cb4d09344ac01898dbcb6a20ae69b" -dependencies = [ - "crypto-mac 0.11.1", - "digest 0.9.0", -] - [[package]] name = "hmac" version = "0.12.1" @@ -1120,15 +880,6 @@ dependencies = [ "unicode-normalization", ] -[[package]] -name = "inout" -version = "0.1.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a0c10553d664a4d0bcff9f4215d0aac67a639cc68ef660840afe309b807bc9f5" -dependencies = [ - "generic-array 0.14.6", -] - [[package]] name = "instant" version = "0.1.12" @@ -1194,12 +945,6 @@ dependencies = [ "sha2 0.10.6", ] -[[package]] -name = "keystream" -version = "1.0.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c33070833c9ee02266356de0c43f723152bd38bd96ddf52c82b3af10c9138b28" - [[package]] name = "lazy_static" version = "1.4.0" @@ -1224,12 +969,6 @@ dependencies = [ "pkg-config", ] -[[package]] -name = "libm" -version = "0.2.6" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "348108ab3fba42ec82ff6e9564fc4ca0247bdccdc68dd8af9764bbc79c3c8ffb" - [[package]] name = "libz-sys" version = "1.1.8" @@ -1248,18 +987,6 @@ version = "0.3.7" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "ece97ea872ece730aed82664c424eb4c8291e1ff2480247ccf7409044bc6479f" -[[package]] -name = "lioness" -version = "0.1.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4ae926706ba42c425c9457121178330d75e273df2e82e28b758faf3de3a9acb9" -dependencies = [ - "arrayref", - "blake2", - "chacha", - "keystream", -] - [[package]] name = "log" version = "0.4.17" @@ -1275,15 +1002,6 @@ version = "2.5.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "2dffe52ecf27772e601905b7522cb4ef790d2cc203488bbd0e2fe85fcb74566d" -[[package]] -name = "memoffset" -version = "0.9.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5a634b1c61a95585bd15607c6ab0c4e5b226e695ff2800ba0cdccddf208c406c" -dependencies = [ - "autocfg", -] - [[package]] name = "mixnet-vesting-integration-tests" version = "0.1.0" @@ -1300,26 +1018,6 @@ dependencies = [ "rand_chacha 0.2.2", ] -[[package]] -name = "num-traits" -version = "0.2.15" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "578ede34cf02f8924ab9447f50c28075b4d3e5b269972345e7e0372b38c6cdcd" -dependencies = [ - "autocfg", - "libm", -] - -[[package]] -name = "num_cpus" -version = "1.16.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4161fcb6d602d4d2081af7c3a45852d875a03dd337a6bfdd6e06407b61342a43" -dependencies = [ - "hermit-abi", - "libc", -] - [[package]] name = "nym-coconut-bandwidth" version = "0.1.0" @@ -1507,23 +1205,6 @@ dependencies = [ "thiserror", ] -[[package]] -name = "nym-outfox" -version = "0.1.0" -dependencies = [ - "blake3", - "chacha20", - "chacha20poly1305", - "curve25519-dalek", - "getrandom 0.2.10", - "log", - "rand 0.7.3", - "rayon", - "sphinx-packet", - "thiserror", - "zeroize", -] - [[package]] name = "nym-pemstore" version = "0.3.0" @@ -1571,8 +1252,6 @@ dependencies = [ name = "nym-sphinx-types" version = "0.2.0" dependencies = [ - "nym-outfox", - "sphinx-packet", "thiserror", ] @@ -1616,12 +1295,6 @@ version = "1.17.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "b7e5500299e16ebb147ae15a00a942af264cf3688f47923b8fc2cd5858f23ad3" -[[package]] -name = "opaque-debug" -version = "0.2.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2839e79665f131bdb5782e51f2c6c9599c133c6098982a54c794358bf432529c" - [[package]] name = "opaque-debug" version = "0.3.0" @@ -1673,17 +1346,6 @@ version = "0.3.26" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "6ac9a59f73473f1b8d852421e59e64809f025994837ef743615c6d0c5b305160" -[[package]] -name = "poly1305" -version = "0.8.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8159bd90725d2df49889a078b54f4f79e87f1f8a8444194cdca81d38f5393abf" -dependencies = [ - "cpufeatures", - "opaque-debug 0.3.0", - "universal-hash", -] - [[package]] name = "ppv-lite86" version = "0.2.17" @@ -1823,16 +1485,6 @@ dependencies = [ "getrandom 0.2.10", ] -[[package]] -name = "rand_distr" -version = "0.3.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c9e9532ada3929fb8b2e9dbe28d1e06c9b2cc65813f074fcb6bd5fbefeff9d56" -dependencies = [ - "num-traits", - "rand 0.7.3", -] - [[package]] name = "rand_hc" version = "0.2.0" @@ -1842,28 +1494,6 @@ dependencies = [ "rand_core 0.5.1", ] -[[package]] -name = "rayon" -version = "1.7.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1d2df5196e37bcc87abebc0053e20787d73847bb33134a69841207dd0a47f03b" -dependencies = [ - "either", - "rayon-core", -] - -[[package]] -name = "rayon-core" -version = "1.11.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4b8f95bd6966f5c87776639160a66bd8ab9895d9d4ab01ddba9fc60661aebe8d" -dependencies = [ - "crossbeam-channel", - "crossbeam-deque", - "crossbeam-utils", - "num_cpus", -] - [[package]] name = "redox_syscall" version = "0.3.5" @@ -1895,7 +1525,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "7743f17af12fa0b03b803ba12cd6a8d9483a587e89c69445e3909655c0b9fabb" dependencies = [ "crypto-bigint", - "hmac 0.12.1", + "hmac", "zeroize", ] @@ -1996,12 +1626,6 @@ dependencies = [ "syn 1.0.109", ] -[[package]] -name = "scopeguard" -version = "1.1.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d29ab0c6d3fc0ee92fe66e2d99f700eab17a8d57d1c1d3b748380fb20baa78cd" - [[package]] name = "sec1" version = "0.3.0" @@ -2010,9 +1634,9 @@ checksum = "3be24c1842290c45df0a7bf069e0c268a747ad05a192f2fd7dcfdbc1cba40928" dependencies = [ "base16ct", "der", - "generic-array 0.14.6", + "generic-array", "pkcs8", - "subtle 2.4.1", + "subtle", "zeroize", ] @@ -2103,7 +1727,7 @@ dependencies = [ "cfg-if", "cpufeatures", "digest 0.9.0", - "opaque-debug 0.3.0", + "opaque-debug", ] [[package]] @@ -2136,30 +1760,6 @@ dependencies = [ "autocfg", ] -[[package]] -name = "sphinx-packet" -version = "0.1.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "cc43eda802856ee82a7555c7b75ceb9e07451741c7a2f5f23d036020e01189d4" -dependencies = [ - "aes", - "arrayref", - "blake2", - "bs58", - "byteorder", - "chacha", - "curve25519-dalek", - "digest 0.9.0", - "hkdf", - "hmac 0.11.0", - "lioness", - "log", - "rand 0.7.3", - "rand_distr", - "sha2 0.9.9", - "subtle 2.4.1", -] - [[package]] name = "spki" version = "0.6.0" @@ -2176,12 +1776,6 @@ version = "1.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "a2eb9349b6444b326872e140eb1cf5e7c522154d69e7a0ffb0fb81c06b37543f" -[[package]] -name = "subtle" -version = "1.0.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2d67a5a62ba6e01cb2192ff309324cb4875d0c451d55fe2319433abe7a05a8ee" - [[package]] name = "subtle" version = "2.4.1" @@ -2333,16 +1927,6 @@ dependencies = [ "tinyvec", ] -[[package]] -name = "universal-hash" -version = "0.5.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "fc1de2c688dc15305988b563c3854064043356019f97a4b46276fe734c4f07ea" -dependencies = [ - "crypto-common", - "subtle 2.4.1", -] - [[package]] name = "url" version = "2.3.1" diff --git a/nym-connect/desktop/Cargo.lock b/nym-connect/desktop/Cargo.lock index 3f657d5852..fc3dba557f 100644 --- a/nym-connect/desktop/Cargo.lock +++ b/nym-connect/desktop/Cargo.lock @@ -4186,8 +4186,6 @@ dependencies = [ name = "nym-sphinx-types" version = "0.2.0" dependencies = [ - "nym-outfox", - "sphinx-packet", "thiserror", ] diff --git a/nym-wallet/Cargo.lock b/nym-wallet/Cargo.lock index 2da872c4fc..5768438108 100644 --- a/nym-wallet/Cargo.lock +++ b/nym-wallet/Cargo.lock @@ -120,12 +120,6 @@ version = "0.3.6" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "a4c527152e37cf757a3f78aae5a06fbeefdb07ccc535c980a3208ee3060dd544" -[[package]] -name = "arrayvec" -version = "0.7.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "96d30a06541fbafbc7f82ed10c06164cfbd2c401138f6addd8404629c4b16711" - [[package]] name = "async-trait" version = "0.1.64" @@ -301,20 +295,6 @@ dependencies = [ "digest 0.10.7", ] -[[package]] -name = "blake3" -version = "1.4.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "199c42ab6972d92c9f8995f086273d25c42fc0f7b2a1fcefba465c1352d25ba5" -dependencies = [ - "arrayref", - "arrayvec", - "cc", - "cfg-if", - "constant_time_eq", - "digest 0.10.7", -] - [[package]] name = "block" version = "0.1.6" @@ -525,30 +505,6 @@ dependencies = [ "keystream", ] -[[package]] -name = "chacha20" -version = "0.9.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c3613f74bd2eac03dad61bd53dbe620703d4371614fe0bc3b9f04dd36fe4e818" -dependencies = [ - "cfg-if", - "cipher 0.4.4", - "cpufeatures", -] - -[[package]] -name = "chacha20poly1305" -version = "0.10.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "10cd79432192d1c0f4e1a0fef9527696cc039165d729fb41b3f4f4f354c2dc35" -dependencies = [ - "aead", - "chacha20", - "cipher 0.4.4", - "poly1305", - "zeroize", -] - [[package]] name = "cipher" version = "0.3.0" @@ -566,7 +522,6 @@ checksum = "773f3b9af64447d2ce9850330c473515014aa235e6a783b02db81ff39e4a3dad" dependencies = [ "crypto-common", "inout", - "zeroize", ] [[package]] @@ -700,12 +655,6 @@ version = "0.9.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "520fbf3c07483f94e3e3ca9d0cfd913d7718ef2483d2cfd91c0d9e91474ab913" -[[package]] -name = "constant_time_eq" -version = "0.3.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f7144d30dcf0fafbce74250a3963025d8d52177934239851c917d29f1df280c2" - [[package]] name = "convert_case" version = "0.4.0" @@ -879,30 +828,6 @@ dependencies = [ "crossbeam-utils", ] -[[package]] -name = "crossbeam-deque" -version = "0.8.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ce6fd6f855243022dcecf8702fef0c297d4338e226845fe067f6341ad9fa0cef" -dependencies = [ - "cfg-if", - "crossbeam-epoch", - "crossbeam-utils", -] - -[[package]] -name = "crossbeam-epoch" -version = "0.9.15" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ae211234986c545741a7dc064309f67ee1e5ad243d0e48335adc0484d960bcc7" -dependencies = [ - "autocfg", - "cfg-if", - "crossbeam-utils", - "memoffset 0.9.0", - "scopeguard", -] - [[package]] name = "crossbeam-utils" version = "0.8.14" @@ -1640,7 +1565,7 @@ version = "0.3.4" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "1e1c54951450cbd39f3dbcf1005ac413b49487dabf18a720ad2383eccfeffb92" dependencies = [ - "memoffset 0.6.5", + "memoffset", "rustc_version 0.3.3", ] @@ -2915,15 +2840,6 @@ dependencies = [ "autocfg", ] -[[package]] -name = "memoffset" -version = "0.9.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5a634b1c61a95585bd15607c6ab0c4e5b226e695ff2800ba0cdccddf208c406c" -dependencies = [ - "autocfg", -] - [[package]] name = "mime" version = "0.3.16" @@ -3328,23 +3244,6 @@ dependencies = [ "url", ] -[[package]] -name = "nym-outfox" -version = "0.1.0" -dependencies = [ - "blake3", - "chacha20", - "chacha20poly1305", - "curve25519-dalek", - "getrandom 0.2.10", - "log", - "rand 0.7.3", - "rayon", - "sphinx-packet", - "thiserror", - "zeroize", -] - [[package]] name = "nym-pemstore" version = "0.3.0" @@ -3369,7 +3268,6 @@ dependencies = [ name = "nym-sphinx-types" version = "0.2.0" dependencies = [ - "nym-outfox", "sphinx-packet", "thiserror", ] @@ -4074,17 +3972,6 @@ dependencies = [ "miniz_oxide", ] -[[package]] -name = "poly1305" -version = "0.8.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8159bd90725d2df49889a078b54f4f79e87f1f8a8444194cdca81d38f5393abf" -dependencies = [ - "cpufeatures", - "opaque-debug 0.3.0", - "universal-hash", -] - [[package]] name = "polyval" version = "0.6.0" @@ -4336,28 +4223,6 @@ dependencies = [ "cty", ] -[[package]] -name = "rayon" -version = "1.7.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1d2df5196e37bcc87abebc0053e20787d73847bb33134a69841207dd0a47f03b" -dependencies = [ - "either", - "rayon-core", -] - -[[package]] -name = "rayon-core" -version = "1.11.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4b8f95bd6966f5c87776639160a66bd8ab9895d9d4ab01ddba9fc60661aebe8d" -dependencies = [ - "crossbeam-channel", - "crossbeam-deque", - "crossbeam-utils", - "num_cpus", -] - [[package]] name = "redox_syscall" version = "0.2.16" From 314d7a7526da84b14db9c6cf024e43c2a5ab4d22 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bogdan-=C8=98tefan=20Neac=C8=99u?= Date: Mon, 7 Aug 2023 15:52:03 +0300 Subject: [PATCH 09/21] Set sphinx as default packet type --- common/crypto/Cargo.toml | 1 + common/nymsphinx/Cargo.toml | 5 + common/nymsphinx/framing/Cargo.toml | 5 +- common/nymsphinx/params/Cargo.toml | 1 + common/nymsphinx/types/Cargo.toml | 1 + contracts/Cargo.lock | 236 ++++++++++++++++++++++++++-- nym-connect/desktop/Cargo.lock | 2 + 7 files changed, 233 insertions(+), 18 deletions(-) diff --git a/common/crypto/Cargo.toml b/common/crypto/Cargo.toml index 27702da016..992005f2d4 100644 --- a/common/crypto/Cargo.toml +++ b/common/crypto/Cargo.toml @@ -34,6 +34,7 @@ nym-pemstore = { path = "../../common/pemstore", version = "0.3.0" } rand_chacha = "0.2" [features] +default = ["sphinx"] serde = ["serde_crate", "serde_bytes", "ed25519-dalek/serde", "x25519-dalek/serde"] asymmetric = ["x25519-dalek", "ed25519-dalek", "zeroize"] hashing = ["blake3", "digest", "hkdf", "hmac", "generic-array"] diff --git a/common/nymsphinx/Cargo.toml b/common/nymsphinx/Cargo.toml index df93301876..955051b267 100644 --- a/common/nymsphinx/Cargo.toml +++ b/common/nymsphinx/Cargo.toml @@ -40,3 +40,8 @@ path = "framing" [target."cfg(not(target_arch = \"wasm32\"))".dependencies.tokio] version = "1.24.1" features = ["sync"] + +[features] +default = ["sphinx"] +sphinx = ["nym-crypto/sphinx", "nym-sphinx-params/sphinx", "nym-sphinx-types/sphinx"] +outfox = ["nym-crypto/outfox", "nym-sphinx-params/outfox", "nym-sphinx-types/outfox"] diff --git a/common/nymsphinx/framing/Cargo.toml b/common/nymsphinx/framing/Cargo.toml index b510926555..3915f204a2 100644 --- a/common/nymsphinx/framing/Cargo.toml +++ b/common/nymsphinx/framing/Cargo.toml @@ -12,5 +12,6 @@ bytes = "1.0" tokio-util = { version = "0.7.4", features = ["codec"] } thiserror = "1.0.37" -nym-sphinx-types = { path = "../types" } -nym-sphinx-params = { path = "../params" } +nym-sphinx-types = { path = "../types", features = ["sphinx", "outfox"] } +nym-sphinx-params = { path = "../params", features = ["sphinx", "outfox"] } + diff --git a/common/nymsphinx/params/Cargo.toml b/common/nymsphinx/params/Cargo.toml index 57872bb0ca..9d9a5a24e2 100644 --- a/common/nymsphinx/params/Cargo.toml +++ b/common/nymsphinx/params/Cargo.toml @@ -15,5 +15,6 @@ nym-crypto = { path = "../../crypto", features = ["hashing", "symmetric"] } nym-sphinx-types = { path = "../types" } [features] +default = ["sphinx"] sphinx = ["nym-crypto/sphinx", "nym-sphinx-types/outfox"] outfox = ["nym-crypto/outfox", "nym-sphinx-types/outfox"] diff --git a/common/nymsphinx/types/Cargo.toml b/common/nymsphinx/types/Cargo.toml index 0569ef1406..ae348113a0 100644 --- a/common/nymsphinx/types/Cargo.toml +++ b/common/nymsphinx/types/Cargo.toml @@ -13,5 +13,6 @@ nym-outfox = { path = "../../../nym-outfox", optional = true } thiserror = "1" [features] +default = ["sphinx"] sphinx = ["sphinx-packet"] outfox = ["nym-outfox"] diff --git a/contracts/Cargo.lock b/contracts/Cargo.lock index 3d719dd6dc..c30bb959e8 100644 --- a/contracts/Cargo.lock +++ b/contracts/Cargo.lock @@ -2,6 +2,19 @@ # It is not intended for manual editing. version = 3 +[[package]] +name = "aes" +version = "0.7.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9e8b47f52ea9bae42228d07ec09eb676433d7c4ed1ebdf0f1d1c29ed446f1ab8" +dependencies = [ + "cfg-if", + "cipher", + "cpufeatures", + "ctr", + "opaque-debug 0.3.0", +] + [[package]] name = "ahash" version = "0.7.6" @@ -19,6 +32,12 @@ version = "1.0.70" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "7de8ce5e0f9f8d88245311066a578d72b7af3e7088f32783804676302df237e4" +[[package]] +name = "arrayref" +version = "0.3.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6b4930d2cb77ce62f89ee5d5289b4ac049559b1c45539271f5ed4fdc7db34545" + [[package]] name = "autocfg" version = "1.1.0" @@ -55,13 +74,25 @@ version = "1.3.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "bef38d45163c2f1dde094a7dfd33ccf595c92905c8f8f4fdc18d06fb1037718a" +[[package]] +name = "blake2" +version = "0.8.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "94cb07b0da6a73955f8fb85d24c466778e70cda767a568229b104f0264089330" +dependencies = [ + "byte-tools", + "crypto-mac 0.7.0", + "digest 0.8.1", + "opaque-debug 0.2.3", +] + [[package]] name = "block-buffer" version = "0.9.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "4152116fd6e9dadb291ae18fc1ec3575ed6d84c29642d97890f4b4a3417297e4" dependencies = [ - "generic-array", + "generic-array 0.14.6", ] [[package]] @@ -70,7 +101,7 @@ version = "0.10.4" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "3078c7629b62d3f0439517fa394996acacc5cbc91c5a20d8c658e77abd503a71" dependencies = [ - "generic-array", + "generic-array 0.14.6", ] [[package]] @@ -85,6 +116,12 @@ version = "3.12.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "9b1ce199063694f33ffb7dd4e0ee620741495c32833cde5aa08f02a0bf96f0c8" +[[package]] +name = "byte-tools" +version = "0.3.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e3b5ca7a04898ad4bcd41c90c5285445ff5b791899bb1b0abdd2a2aa791211d7" + [[package]] name = "byteorder" version = "1.4.3" @@ -112,6 +149,25 @@ version = "1.0.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "baf1de4339761588bc0619e3cbc0120ee582ebb74b53b4efbf79117bd2da40fd" +[[package]] +name = "chacha" +version = "0.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ddf3c081b5fba1e5615640aae998e0fbd10c24cbd897ee39ed754a77601a4862" +dependencies = [ + "byteorder", + "keystream", +] + +[[package]] +name = "cipher" +version = "0.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7ee52072ec15386f770805afd189a01c8841be8696bed250fa2f13c4c0d6dfb7" +dependencies = [ + "generic-array 0.14.6", +] + [[package]] name = "coconut-test" version = "0.1.0" @@ -240,9 +296,9 @@ version = "0.4.9" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "ef2b4b23cddf68b89b8f8069890e8c270d54e2d5fe1b143820234805e4cb17ef" dependencies = [ - "generic-array", + "generic-array 0.14.6", "rand_core 0.6.4", - "subtle", + "subtle 2.4.1", "zeroize", ] @@ -252,10 +308,39 @@ version = "0.1.6" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "1bfb12502f3fc46cca1bb51ac28df9d618d813cdc3d2f25b9fe775a34af26bb3" dependencies = [ - "generic-array", + "generic-array 0.14.6", "typenum", ] +[[package]] +name = "crypto-mac" +version = "0.7.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4434400df11d95d556bac068ddfedd482915eb18fe8bea89bc80b6e4b1c179e5" +dependencies = [ + "generic-array 0.12.4", + "subtle 1.0.0", +] + +[[package]] +name = "crypto-mac" +version = "0.11.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b1d1a86f49236c215f271d40892d5fc950490551400b02ef360692c29815c714" +dependencies = [ + "generic-array 0.14.6", + "subtle 2.4.1", +] + +[[package]] +name = "ctr" +version = "0.8.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "049bb91fb4aaf0e3c7efa6cd5ef877dbbbd15b39dad06d9948de4ec8a75761ea" +dependencies = [ + "cipher", +] + [[package]] name = "curve25519-dalek" version = "3.2.0" @@ -265,7 +350,7 @@ dependencies = [ "byteorder", "digest 0.9.0", "rand_core 0.5.1", - "subtle", + "subtle 2.4.1", "zeroize", ] @@ -476,13 +561,22 @@ dependencies = [ "syn 1.0.109", ] +[[package]] +name = "digest" +version = "0.8.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f3d0c8c8752312f9713efd397ff63acb9f85585afbf179282e720e7704954dd5" +dependencies = [ + "generic-array 0.12.4", +] + [[package]] name = "digest" version = "0.9.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "d3dd60d1080a57a05ab032377049e0591415d2b31afd7028356dbf3cc6dcb066" dependencies = [ - "generic-array", + "generic-array 0.14.6", ] [[package]] @@ -493,7 +587,7 @@ checksum = "9ed9a281f7bc9b7576e61468ba615a66a5c8cfdff42420a70aa82701a3b1e292" dependencies = [ "block-buffer 0.10.4", "crypto-common", - "subtle", + "subtle 2.4.1", ] [[package]] @@ -569,12 +663,12 @@ dependencies = [ "der", "digest 0.10.7", "ff", - "generic-array", + "generic-array 0.14.6", "group", "pkcs8", "rand_core 0.6.4", "sec1", - "subtle", + "subtle 2.4.1", "zeroize", ] @@ -635,7 +729,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "d013fc25338cc558c5c2cfbad646908fb23591e2404481826742b651c9af7160" dependencies = [ "rand_core 0.6.4", - "subtle", + "subtle 2.4.1", ] [[package]] @@ -754,6 +848,15 @@ dependencies = [ "slab", ] +[[package]] +name = "generic-array" +version = "0.12.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ffdf9f34f1447443d37393cc6c2b8313aebddcd96906caf34e54c68d8e57d7bd" +dependencies = [ + "typenum", +] + [[package]] name = "generic-array" version = "0.14.6" @@ -821,7 +924,7 @@ checksum = "5dfbfb3a6cfbd390d5c9564ab283a0349b9b9fcd46a706c1eb10e0db70bfbac7" dependencies = [ "ff", "rand_core 0.6.4", - "subtle", + "subtle 2.4.1", ] [[package]] @@ -845,6 +948,26 @@ version = "0.4.3" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "7f24254aa9a54b5c858eaee2f5bccdb46aaf0e486a595ed5fd8f86ba55232a70" +[[package]] +name = "hkdf" +version = "0.11.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "01706d578d5c281058480e673ae4086a9f4710d8df1ad80a5b03e39ece5f886b" +dependencies = [ + "digest 0.9.0", + "hmac 0.11.0", +] + +[[package]] +name = "hmac" +version = "0.11.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2a2a2320eb7ec0ebe8da8f744d7812d9fc4cb4d09344ac01898dbcb6a20ae69b" +dependencies = [ + "crypto-mac 0.11.1", + "digest 0.9.0", +] + [[package]] name = "hmac" version = "0.12.1" @@ -945,6 +1068,12 @@ dependencies = [ "sha2 0.10.6", ] +[[package]] +name = "keystream" +version = "1.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c33070833c9ee02266356de0c43f723152bd38bd96ddf52c82b3af10c9138b28" + [[package]] name = "lazy_static" version = "1.4.0" @@ -969,6 +1098,12 @@ dependencies = [ "pkg-config", ] +[[package]] +name = "libm" +version = "0.2.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f7012b1bbb0719e1097c47611d3898568c546d597c2e74d66f6087edd5233ff4" + [[package]] name = "libz-sys" version = "1.1.8" @@ -987,6 +1122,18 @@ version = "0.3.7" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "ece97ea872ece730aed82664c424eb4c8291e1ff2480247ccf7409044bc6479f" +[[package]] +name = "lioness" +version = "0.1.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4ae926706ba42c425c9457121178330d75e273df2e82e28b758faf3de3a9acb9" +dependencies = [ + "arrayref", + "blake2", + "chacha", + "keystream", +] + [[package]] name = "log" version = "0.4.17" @@ -1018,6 +1165,16 @@ dependencies = [ "rand_chacha 0.2.2", ] +[[package]] +name = "num-traits" +version = "0.2.16" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f30b0abd723be7e2ffca1272140fac1a2f084c77ec3e123c192b66af1ee9e6c2" +dependencies = [ + "autocfg", + "libm", +] + [[package]] name = "nym-coconut-bandwidth" version = "0.1.0" @@ -1252,6 +1409,7 @@ dependencies = [ name = "nym-sphinx-types" version = "0.2.0" dependencies = [ + "sphinx-packet", "thiserror", ] @@ -1295,6 +1453,12 @@ version = "1.17.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "b7e5500299e16ebb147ae15a00a942af264cf3688f47923b8fc2cd5858f23ad3" +[[package]] +name = "opaque-debug" +version = "0.2.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2839e79665f131bdb5782e51f2c6c9599c133c6098982a54c794358bf432529c" + [[package]] name = "opaque-debug" version = "0.3.0" @@ -1485,6 +1649,16 @@ dependencies = [ "getrandom 0.2.10", ] +[[package]] +name = "rand_distr" +version = "0.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c9e9532ada3929fb8b2e9dbe28d1e06c9b2cc65813f074fcb6bd5fbefeff9d56" +dependencies = [ + "num-traits", + "rand 0.7.3", +] + [[package]] name = "rand_hc" version = "0.2.0" @@ -1525,7 +1699,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "7743f17af12fa0b03b803ba12cd6a8d9483a587e89c69445e3909655c0b9fabb" dependencies = [ "crypto-bigint", - "hmac", + "hmac 0.12.1", "zeroize", ] @@ -1634,9 +1808,9 @@ checksum = "3be24c1842290c45df0a7bf069e0c268a747ad05a192f2fd7dcfdbc1cba40928" dependencies = [ "base16ct", "der", - "generic-array", + "generic-array 0.14.6", "pkcs8", - "subtle", + "subtle 2.4.1", "zeroize", ] @@ -1727,7 +1901,7 @@ dependencies = [ "cfg-if", "cpufeatures", "digest 0.9.0", - "opaque-debug", + "opaque-debug 0.3.0", ] [[package]] @@ -1760,6 +1934,30 @@ dependencies = [ "autocfg", ] +[[package]] +name = "sphinx-packet" +version = "0.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "cc43eda802856ee82a7555c7b75ceb9e07451741c7a2f5f23d036020e01189d4" +dependencies = [ + "aes", + "arrayref", + "blake2", + "bs58", + "byteorder", + "chacha", + "curve25519-dalek", + "digest 0.9.0", + "hkdf", + "hmac 0.11.0", + "lioness", + "log", + "rand 0.7.3", + "rand_distr", + "sha2 0.9.9", + "subtle 2.4.1", +] + [[package]] name = "spki" version = "0.6.0" @@ -1776,6 +1974,12 @@ version = "1.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "a2eb9349b6444b326872e140eb1cf5e7c522154d69e7a0ffb0fb81c06b37543f" +[[package]] +name = "subtle" +version = "1.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2d67a5a62ba6e01cb2192ff309324cb4875d0c451d55fe2319433abe7a05a8ee" + [[package]] name = "subtle" version = "2.4.1" diff --git a/nym-connect/desktop/Cargo.lock b/nym-connect/desktop/Cargo.lock index fc3dba557f..3f657d5852 100644 --- a/nym-connect/desktop/Cargo.lock +++ b/nym-connect/desktop/Cargo.lock @@ -4186,6 +4186,8 @@ dependencies = [ name = "nym-sphinx-types" version = "0.2.0" dependencies = [ + "nym-outfox", + "sphinx-packet", "thiserror", ] From 795efb9f0b68d194cdb9bfd7e07c8d9bc373eb46 Mon Sep 17 00:00:00 2001 From: benedettadavico Date: Tue, 8 Aug 2023 11:15:30 +0200 Subject: [PATCH 10/21] Update changelog and versions for release v1.1.26 --- CHANGELOG.md | 22 +++++++++++++++++++ Cargo.lock | 18 +++++++-------- clients/native/Cargo.toml | 2 +- clients/socks5/Cargo.toml | 2 +- explorer-api/Cargo.toml | 2 +- gateway/Cargo.toml | 2 +- mixnode/Cargo.toml | 2 +- nym-api/Cargo.toml | 2 +- nym-connect/desktop/CHANGELOG.md | 6 +++++ nym-connect/desktop/package.json | 2 +- nym-connect/desktop/src-tauri/Cargo.toml | 2 +- nym-connect/desktop/src-tauri/tauri.conf.json | 2 +- .../network-requester/Cargo.toml | 2 +- .../network-statistics/Cargo.toml | 2 +- tools/nym-cli/Cargo.toml | 2 +- 15 files changed, 49 insertions(+), 21 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index f938c81fe3..1ec4a60145 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -4,6 +4,28 @@ Post 1.0.0 release, the changelog format is based on [Keep a Changelog](https:// ## [Unreleased] +## [v1.1.24] (2023-08-08) + +- Latency based gateway selection is serial and slow ([#3710]) +- Network-requester: strip comments from allow lists ([#3625]) +- Remove (or start maintaining) `upgrade` commands from all binaries ([#3600]) +- Set sphinx as default packet type ([#3748]) +- Apply fix from feature/ephemera to develop too (#3698) ([#3742]) +- Feature/coco demos ([#3732]) +- Add updates to community list projects ([#3722]) +- Add geo-aware mixnet topology provider ([#3713]) +- Add updates to community list projects ([#3711]) + +[#3710]: https://github.com/nymtech/nym/issues/3710 +[#3625]: https://github.com/nymtech/nym/issues/3625 +[#3600]: https://github.com/nymtech/nym/issues/3600 +[#3748]: https://github.com/nymtech/nym/pull/3748 +[#3742]: https://github.com/nymtech/nym/pull/3742 +[#3732]: https://github.com/nymtech/nym/pull/3732 +[#3722]: https://github.com/nymtech/nym/pull/3722 +[#3713]: https://github.com/nymtech/nym/pull/3713 +[#3711]: https://github.com/nymtech/nym/pull/3711 + ## [v1.1.23] (2023-07-04) - nym-cli: add client identity key signing support ([#3576]) diff --git a/Cargo.lock b/Cargo.lock index f7ba594a47..dc276f492c 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -1895,7 +1895,7 @@ checksum = "0206175f82b8d6bf6652ff7d71a1e27fd2e4efde587fd368662814d6ec1d9ce0" [[package]] name = "explorer-api" -version = "1.1.23" +version = "1.1.24" dependencies = [ "chrono", "clap 4.2.7", @@ -3531,7 +3531,7 @@ dependencies = [ [[package]] name = "nym-api" -version = "1.1.24" +version = "1.1.25" dependencies = [ "anyhow", "async-trait", @@ -3668,7 +3668,7 @@ dependencies = [ [[package]] name = "nym-cli" -version = "1.1.23" +version = "1.1.24" dependencies = [ "anyhow", "base64 0.13.1", @@ -3734,7 +3734,7 @@ dependencies = [ [[package]] name = "nym-client" -version = "1.1.23" +version = "1.1.24" dependencies = [ "clap 4.2.7", "dirs 4.0.0", @@ -4022,7 +4022,7 @@ dependencies = [ [[package]] name = "nym-gateway" -version = "1.1.23" +version = "1.1.24" dependencies = [ "anyhow", "async-trait", @@ -4175,7 +4175,7 @@ dependencies = [ [[package]] name = "nym-mixnode" -version = "1.1.24" +version = "1.1.25" dependencies = [ "anyhow", "bs58 0.4.0", @@ -4291,7 +4291,7 @@ dependencies = [ [[package]] name = "nym-network-requester" -version = "1.1.23" +version = "1.1.24" dependencies = [ "anyhow", "async-file-watcher", @@ -4338,7 +4338,7 @@ dependencies = [ [[package]] name = "nym-network-statistics" -version = "1.1.23" +version = "1.1.24" dependencies = [ "dirs 4.0.0", "log", @@ -4497,7 +4497,7 @@ dependencies = [ [[package]] name = "nym-socks5-client" -version = "1.1.23" +version = "1.1.24" dependencies = [ "clap 4.2.7", "lazy_static", diff --git a/clients/native/Cargo.toml b/clients/native/Cargo.toml index 6064304a90..2135883752 100644 --- a/clients/native/Cargo.toml +++ b/clients/native/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "nym-client" -version = "1.1.23" +version = "1.1.24" authors = ["Dave Hrycyszyn ", "Jędrzej Stuczyński "] description = "Implementation of the Nym Client" edition = "2021" diff --git a/clients/socks5/Cargo.toml b/clients/socks5/Cargo.toml index 658d52a047..afbf36178f 100644 --- a/clients/socks5/Cargo.toml +++ b/clients/socks5/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "nym-socks5-client" -version = "1.1.23" +version = "1.1.24" authors = ["Dave Hrycyszyn "] description = "A SOCKS5 localhost proxy that converts incoming messages to Sphinx and sends them to a Nym address" edition = "2021" diff --git a/explorer-api/Cargo.toml b/explorer-api/Cargo.toml index c4c7b345bc..6dfd65903f 100644 --- a/explorer-api/Cargo.toml +++ b/explorer-api/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "explorer-api" -version = "1.1.23" +version = "1.1.24" edition = "2021" # See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html diff --git a/gateway/Cargo.toml b/gateway/Cargo.toml index 763b3ab676..007fcca40d 100644 --- a/gateway/Cargo.toml +++ b/gateway/Cargo.toml @@ -3,7 +3,7 @@ [package] name = "nym-gateway" -version = "1.1.23" +version = "1.1.24" authors = [ "Dave Hrycyszyn ", "Jędrzej Stuczyński ", diff --git a/mixnode/Cargo.toml b/mixnode/Cargo.toml index 9f512f0d85..8421bebb3a 100644 --- a/mixnode/Cargo.toml +++ b/mixnode/Cargo.toml @@ -3,7 +3,7 @@ [package] name = "nym-mixnode" -version = "1.1.24" +version = "1.1.25" authors = [ "Dave Hrycyszyn ", "Jędrzej Stuczyński ", diff --git a/nym-api/Cargo.toml b/nym-api/Cargo.toml index f9b378f59d..50568b440a 100644 --- a/nym-api/Cargo.toml +++ b/nym-api/Cargo.toml @@ -3,7 +3,7 @@ [package] name = "nym-api" -version = "1.1.24" +version = "1.1.25" authors = [ "Dave Hrycyszyn ", "Jędrzej Stuczyński ", diff --git a/nym-connect/desktop/CHANGELOG.md b/nym-connect/desktop/CHANGELOG.md index 1149c3b227..8a0b86151a 100644 --- a/nym-connect/desktop/CHANGELOG.md +++ b/nym-connect/desktop/CHANGELOG.md @@ -2,6 +2,12 @@ ## [Unreleased] +## [v1.1.16] (2023-08-08) + +- Uncouple network-requester <-> gateway in nym-connect and harbourmaster ([#3472]) + +[#3472]: https://github.com/nymtech/nym/issues/3472 + ## [v1.1.15] (2023-07-25) - NC Desktop - remove sentry DSN from code ([#3694]) diff --git a/nym-connect/desktop/package.json b/nym-connect/desktop/package.json index 626b415b8f..96d9e83438 100644 --- a/nym-connect/desktop/package.json +++ b/nym-connect/desktop/package.json @@ -1,6 +1,6 @@ { "name": "@nym/nym-connect", - "version": "1.1.15", + "version": "1.1.16", "main": "index.js", "license": "MIT", "scripts": { diff --git a/nym-connect/desktop/src-tauri/Cargo.toml b/nym-connect/desktop/src-tauri/Cargo.toml index e3bd49cb41..0d1089132d 100644 --- a/nym-connect/desktop/src-tauri/Cargo.toml +++ b/nym-connect/desktop/src-tauri/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "nym-connect" -version = "1.1.15" +version = "1.1.16" description = "nym-connect" authors = ["Nym Technologies SA"] license = "" diff --git a/nym-connect/desktop/src-tauri/tauri.conf.json b/nym-connect/desktop/src-tauri/tauri.conf.json index b95859ca53..5f5e86bec0 100644 --- a/nym-connect/desktop/src-tauri/tauri.conf.json +++ b/nym-connect/desktop/src-tauri/tauri.conf.json @@ -1,7 +1,7 @@ { "package": { "productName": "nym-connect", - "version": "1.1.15" + "version": "1.1.16" }, "build": { "distDir": "../dist", diff --git a/service-providers/network-requester/Cargo.toml b/service-providers/network-requester/Cargo.toml index 5b80088b30..d1d7367d85 100644 --- a/service-providers/network-requester/Cargo.toml +++ b/service-providers/network-requester/Cargo.toml @@ -3,7 +3,7 @@ [package] name = "nym-network-requester" -version = "1.1.23" +version = "1.1.24" authors.workspace = true edition.workspace = true rust-version = "1.65" diff --git a/service-providers/network-statistics/Cargo.toml b/service-providers/network-statistics/Cargo.toml index cc7024c545..7c0138ca8f 100644 --- a/service-providers/network-statistics/Cargo.toml +++ b/service-providers/network-statistics/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "nym-network-statistics" -version = "1.1.23" +version = "1.1.24" edition = "2021" # See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html diff --git a/tools/nym-cli/Cargo.toml b/tools/nym-cli/Cargo.toml index ea5cad9e65..9f3c0d6a2a 100644 --- a/tools/nym-cli/Cargo.toml +++ b/tools/nym-cli/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "nym-cli" -version = "1.1.23" +version = "1.1.24" authors.workspace = true edition = "2021" From 2d60a9da3f9ae671e0fcc8192bfe4ddca5cc2c30 Mon Sep 17 00:00:00 2001 From: benedettadavico Date: Tue, 8 Aug 2023 11:24:08 +0200 Subject: [PATCH 11/21] Temporary update to fix windows build --- package.json | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/package.json b/package.json index 523db5363f..cad6eaf88d 100644 --- a/package.json +++ b/package.json @@ -8,7 +8,6 @@ "ts-packages/*", "nym-wallet", "nym-connect/**", - "nym-browser-extension", "explorer", "types", "clients/validator" @@ -29,9 +28,8 @@ "tsc": "lerna run tsc --stream", "types:lint:fix": "lerna run lint:fix --scope @nymproject/types --scope @nymproject/nym-wallet-app", "audit:fix": "npm_config_yes=true npx yarn-audit-fix -- --dry-run", - "preinstall": "yarn install:copy-placeholders && yarn install:copy-storage-placeholders", - "install:copy-placeholders": "cp scripts/build/yarn/wasm-placeholder/package.json sdk/typescript/packages/nym-client-wasm", - "install:copy-storage-placeholders": "mkdir -p nym-browser-extension/storage/pkg && cp scripts/build/yarn/storage-placeholder/package.json nym-browser-extension/storage/pkg" + "preinstall": "yarn install:copy-placeholders", + "install:copy-placeholders": "cp scripts/build/yarn/wasm-placeholder/package.json sdk/typescript/packages/nym-client-wasm" }, "devDependencies": { "lerna": "^6.6.2", From 0af9b3c6c87cb92cd789c65238ac4752c320ec39 Mon Sep 17 00:00:00 2001 From: benedettadavico Date: Tue, 8 Aug 2023 14:17:55 +0200 Subject: [PATCH 12/21] Revert package.json changes needed temporary build --- package.json | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/package.json b/package.json index cad6eaf88d..523db5363f 100644 --- a/package.json +++ b/package.json @@ -8,6 +8,7 @@ "ts-packages/*", "nym-wallet", "nym-connect/**", + "nym-browser-extension", "explorer", "types", "clients/validator" @@ -28,8 +29,9 @@ "tsc": "lerna run tsc --stream", "types:lint:fix": "lerna run lint:fix --scope @nymproject/types --scope @nymproject/nym-wallet-app", "audit:fix": "npm_config_yes=true npx yarn-audit-fix -- --dry-run", - "preinstall": "yarn install:copy-placeholders", - "install:copy-placeholders": "cp scripts/build/yarn/wasm-placeholder/package.json sdk/typescript/packages/nym-client-wasm" + "preinstall": "yarn install:copy-placeholders && yarn install:copy-storage-placeholders", + "install:copy-placeholders": "cp scripts/build/yarn/wasm-placeholder/package.json sdk/typescript/packages/nym-client-wasm", + "install:copy-storage-placeholders": "mkdir -p nym-browser-extension/storage/pkg && cp scripts/build/yarn/storage-placeholder/package.json nym-browser-extension/storage/pkg" }, "devDependencies": { "lerna": "^6.6.2", From e00910bcb8088e694586c24b964fb244ecee2d97 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jon=20H=C3=A4ggblad?= Date: Fri, 28 Jul 2023 14:48:33 +0200 Subject: [PATCH 13/21] Add geo-aware mixnet topology provider (#3713) * WIP: initial work * wupwup * WIP: experiments * Move topology provider and requests to own crate * Make sure we use the new crate everywhere * Sort Cargo.toml * Extract out some functions in geo_aware_provider * rustfmt * Add CountryGroup type * Assign unknown as well * wipwip * Add command line flag to socks5-client * Use geo-aware mixnode selection in nym-connect when in medium mode * rustfmt * clippy * Fix nym-connect build * wasm fix * Spelling --- Cargo.lock | 20 ++ Cargo.toml | 5 +- clients/socks5/src/commands/init.rs | 1 + clients/socks5/src/commands/mod.rs | 15 +- clients/socks5/src/commands/run.rs | 13 + clients/webassembly/Cargo.lock | 13 + clients/webassembly/src/client/config.rs | 1 + common/client-core/Cargo.toml | 10 +- .../client-core/src/client/base_client/mod.rs | 15 +- .../topology_control/geo_aware_provider.rs | 319 ++++++++++++++++++ .../src/client/topology_control/mod.rs | 1 + common/client-core/src/config/mod.rs | 22 +- .../src/config/old_config_v1_1_20_2.rs | 1 + .../mixnet-contract/src/mixnode.rs | 4 + common/socks5-client-core/Cargo.toml | 13 +- common/socks5-client-core/src/lib.rs | 1 + explorer-api/Cargo.toml | 17 +- explorer-api/explorer-api-requests/Cargo.toml | 12 + explorer-api/explorer-api-requests/src/lib.rs | 44 +++ .../src/country_statistics/geolocate.rs | 4 +- explorer-api/src/geo_ip/location.rs | 12 + explorer-api/src/mix_node/http.rs | 3 +- explorer-api/src/mix_node/mod.rs | 2 +- explorer-api/src/mix_node/models.rs | 38 +-- explorer-api/src/mix_nodes/http.rs | 2 +- explorer-api/src/mix_nodes/location.rs | 23 +- explorer-api/src/mix_nodes/models.rs | 4 +- nym-connect/desktop/Cargo.lock | 22 +- nym-connect/desktop/src-tauri/src/tasks.rs | 26 +- .../src/allowed_hosts/hosts.rs | 1 - 30 files changed, 568 insertions(+), 96 deletions(-) create mode 100644 common/client-core/src/client/topology_control/geo_aware_provider.rs create mode 100644 explorer-api/explorer-api-requests/Cargo.toml create mode 100644 explorer-api/explorer-api-requests/src/lib.rs diff --git a/Cargo.lock b/Cargo.lock index c2eadc94b5..1dcf4528bf 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -1909,6 +1909,7 @@ dependencies = [ "maxminddb", "nym-bin-common", "nym-contracts-common", + "nym-explorer-api-requests", "nym-mixnet-contract-common", "nym-network-defaults", "nym-task", @@ -3782,6 +3783,7 @@ dependencies = [ "nym-config", "nym-credential-storage", "nym-crypto", + "nym-explorer-api-requests", "nym-gateway-client", "nym-gateway-requests", "nym-network-defaults", @@ -3792,6 +3794,7 @@ dependencies = [ "nym-topology", "nym-validator-client", "rand 0.7.3", + "reqwest", "serde", "serde_json", "sha2 0.10.6", @@ -4004,6 +4007,18 @@ dependencies = [ "syn 1.0.109", ] +[[package]] +name = "nym-explorer-api-requests" +version = "0.1.0" +dependencies = [ + "nym-contracts-common", + "nym-mixnet-contract-common", + "nym-validator-client", + "schemars", + "serde", + "ts-rs", +] + [[package]] name = "nym-gateway" version = "1.1.23" @@ -4520,7 +4535,9 @@ dependencies = [ "nym-bandwidth-controller", "nym-client-core", "nym-config", + "nym-contracts-common", "nym-credential-storage", + "nym-mixnet-contract-common", "nym-network-defaults", "nym-service-providers-common", "nym-socks5-proxy-helpers", @@ -4530,10 +4547,13 @@ dependencies = [ "nym-validator-client", "pin-project", "rand 0.7.3", + "reqwest", + "schemars", "serde", "tap", "thiserror", "tokio", + "url", ] [[package]] diff --git a/Cargo.toml b/Cargo.toml index 666d1f76fc..198f37890e 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -74,6 +74,7 @@ members = [ "common/types", "common/wasm-utils", "explorer-api", + "explorer-api/explorer-api-requests", "gateway", "gateway/gateway-requests", "integrations/bity", @@ -135,15 +136,17 @@ cw4 = { version = "=1.1.0" } cw-controllers = { version = "=1.1.0" } dotenvy = "0.15.6" generic-array = "0.14.7" -k256 = "0.13" getrandom = "0.2.10" +k256 = "0.13" lazy_static = "1.4.0" log = "0.4" once_cell = "1.7.2" rand = "0.8.5" +reqwest = "0.11.18" serde = "1.0.152" serde_json = "1.0.91" tap = "1.0.1" +tendermint-rpc = "=0.32" # same version as used by cosmrs thiserror = "1.0.38" tokio = "1.24.1" url = "2.2" diff --git a/clients/socks5/src/commands/init.rs b/clients/socks5/src/commands/init.rs index 76337b84ac..ef370c54b8 100644 --- a/clients/socks5/src/commands/init.rs +++ b/clients/socks5/src/commands/init.rs @@ -94,6 +94,7 @@ impl From for OverrideConfig { use_anonymous_replies: init_config.use_reply_surbs, fastmode: init_config.fastmode, no_cover: init_config.no_cover, + geo_routing: None, medium_toggle: false, nyxd_urls: init_config.nyxd_urls, enabled_credentials_mode: init_config.enabled_credentials_mode, diff --git a/clients/socks5/src/commands/mod.rs b/clients/socks5/src/commands/mod.rs index 5ef887a3a2..393429246d 100644 --- a/clients/socks5/src/commands/mod.rs +++ b/clients/socks5/src/commands/mod.rs @@ -16,7 +16,8 @@ use nym_client_core::client::base_client::storage::gateway_details::{ OnDiskGatewayDetails, PersistedGatewayDetails, }; use nym_client_core::client::key_manager::persistence::OnDiskKeys; -use nym_client_core::config::GatewayEndpointConfig; +use nym_client_core::client::topology_control::geo_aware_provider::CountryGroup; +use nym_client_core::config::{GatewayEndpointConfig, TopologyStructure}; use nym_client_core::error::ClientCoreError; use nym_config::OptionalSet; use nym_sphinx::params::{PacketSize, PacketType}; @@ -75,6 +76,7 @@ pub(crate) struct OverrideConfig { use_anonymous_replies: Option, fastmode: bool, no_cover: bool, + geo_routing: Option, medium_toggle: bool, nyxd_urls: Option>, enabled_credentials_mode: Option, @@ -99,6 +101,13 @@ pub(crate) fn override_config(config: Config, args: OverrideConfig) -> Config { let secondary_packet_size = args.medium_toggle.then_some(PacketSize::ExtendedPacket16); let no_per_hop_delays = args.medium_toggle; + let topology_structure = if args.medium_toggle || args.geo_routing.is_some() { + // TODO: rethink the default group. I just picked one for now. + TopologyStructure::GeoAware(args.geo_routing.unwrap_or(CountryGroup::Europe)) + } else { + TopologyStructure::default() + }; + let packet_type = if args.outfox { PacketType::Outfox } else { @@ -122,6 +131,10 @@ pub(crate) fn override_config(config: Config, args: OverrideConfig) -> Config { // NOTE: see comment above about the order of the other disble cover traffic config .with_base(BaseClientConfig::with_disabled_cover_traffic, args.no_cover) .with_base(BaseClientConfig::with_packet_type, packet_type) + .with_base( + BaseClientConfig::with_topology_structure, + topology_structure, + ) .with_optional(Config::with_anonymous_replies, args.use_anonymous_replies) .with_optional(Config::with_port, args.port) .with_optional_base_custom_env( diff --git a/clients/socks5/src/commands/run.rs b/clients/socks5/src/commands/run.rs index 5d54038c06..8dd289e2bf 100644 --- a/clients/socks5/src/commands/run.rs +++ b/clients/socks5/src/commands/run.rs @@ -11,6 +11,7 @@ use clap::Args; use log::*; use nym_bin_common::version_checker::is_minor_version_compatible; use nym_client_core::client::base_client::storage::OnDiskPersistent; +use nym_client_core::client::topology_control::geo_aware_provider::CountryGroup; use nym_crypto::asymmetric::identity; use nym_socks5_client_core::NymClient; use nym_sphinx::addressing::clients::Recipient; @@ -60,6 +61,10 @@ pub(crate) struct Run { #[clap(long, hide = true)] no_cover: bool, + /// Set geo-aware mixnode selection when sending mixnet traffic, for experiments only. + #[clap(long, hide = true, value_parser = validate_country_group)] + geo_routing: Option, + /// Enable medium mixnet traffic, for experiments only. /// This includes things like disabling cover traffic, no per hop delays, etc. #[clap(long, hide = true)] @@ -82,6 +87,7 @@ impl From for OverrideConfig { use_anonymous_replies: run_config.use_anonymous_replies, fastmode: run_config.fastmode, no_cover: run_config.no_cover, + geo_routing: run_config.geo_routing, medium_toggle: run_config.medium_toggle, nyxd_urls: run_config.nyxd_urls, enabled_credentials_mode: run_config.enabled_credentials_mode, @@ -90,6 +96,13 @@ impl From for OverrideConfig { } } +fn validate_country_group(s: &str) -> Result { + match s.parse() { + Ok(cg) => Ok(cg), + Err(_) => Err(format!("failed to parse country group: {}", s)), + } +} + // this only checks compatibility between config the binary. It does not take into consideration // network version. It might do so in the future. fn version_check(cfg: &Config) -> bool { diff --git a/clients/webassembly/Cargo.lock b/clients/webassembly/Cargo.lock index 793f321a97..0ea047444e 100644 --- a/clients/webassembly/Cargo.lock +++ b/clients/webassembly/Cargo.lock @@ -2475,6 +2475,7 @@ dependencies = [ "nym-config", "nym-credential-storage", "nym-crypto", + "nym-explorer-api-requests", "nym-gateway-client", "nym-gateway-requests", "nym-network-defaults", @@ -2485,6 +2486,7 @@ dependencies = [ "nym-topology", "nym-validator-client", "rand 0.7.3", + "reqwest", "serde", "serde_json", "sha2 0.10.6", @@ -2689,6 +2691,17 @@ dependencies = [ "zeroize", ] +[[package]] +name = "nym-explorer-api-requests" +version = "0.1.0" +dependencies = [ + "nym-contracts-common", + "nym-mixnet-contract-common", + "nym-validator-client", + "schemars", + "serde", +] + [[package]] name = "nym-gateway-client" version = "0.1.0" diff --git a/clients/webassembly/src/client/config.rs b/clients/webassembly/src/client/config.rs index 07d9ab5f5f..f63d1456ac 100644 --- a/clients/webassembly/src/client/config.rs +++ b/clients/webassembly/src/client/config.rs @@ -246,6 +246,7 @@ impl From for ConfigTopology { topology.topology_resolution_timeout_ms, ), disable_refreshing: topology.disable_refreshing, + topology_structure: Default::default(), } } } diff --git a/common/client-core/Cargo.toml b/common/client-core/Cargo.toml index ab1c9b8c04..0811b08add 100644 --- a/common/client-core/Cargo.toml +++ b/common/client-core/Cargo.toml @@ -10,27 +10,29 @@ rust-version = "1.66" [dependencies] async-trait = { workspace = true } base64 = "0.21.2" -dirs = "4.0" dashmap = "5.4.0" +dirs = "4.0" futures = "0.3" humantime-serde = "1.0" log = { workspace = true } rand = { version = "0.7.3", features = ["wasm-bindgen"] } +reqwest = { workspace = true } serde = { workspace = true, features = ["derive"] } serde_json = { workspace = true } sha2 = "0.10.6" tap = "1.0.1" thiserror = "1.0.34" -url = { version ="2.2", features = ["serde"] } -tungstenite = { version = "0.13.0", default-features = false } -tokio = { version = "1.24.1", features = ["macros"]} time = "0.3.17" +tokio = { version = "1.24.1", features = ["macros"]} +tungstenite = { version = "0.13.0", default-features = false } +url = { version ="2.2", features = ["serde"] } zeroize = { workspace = true } # internal nym-bandwidth-controller = { path = "../bandwidth-controller" } nym-config = { path = "../config" } nym-crypto = { path = "../crypto" } +nym-explorer-api-requests = { path = "../../explorer-api/explorer-api-requests" } nym-gateway-client = { path = "../client-libs/gateway-client" } #gateway-client = { path = "../../common/client-libs/gateway-client", default-features = false, features = ["wasm", "coconut"] } nym-gateway-requests = { path = "../../gateway/gateway-requests" } diff --git a/common/client-core/src/client/base_client/mod.rs b/common/client-core/src/client/base_client/mod.rs index aecb7eb5c1..a934793953 100644 --- a/common/client-core/src/client/base_client/mod.rs +++ b/common/client-core/src/client/base_client/mod.rs @@ -2,6 +2,7 @@ // SPDX-License-Identifier: Apache-2.0 use super::received_buffer::ReceivedBufferMessage; +use super::topology_control::geo_aware_provider::GeoAwareTopologyProvider; use crate::client::base_client::storage::MixnetClientStorage; use crate::client::cover_traffic_stream::LoopCoverTrafficStream; use crate::client::inbound_messages::{InputMessage, InputMessageReceiver, InputMessageSender}; @@ -339,14 +340,20 @@ where fn setup_topology_provider( custom_provider: Option>, + provider_from_config: config::TopologyStructure, nym_api_urls: Vec, ) -> Box { // if no custom provider was ... provided ..., create one using nym-api - custom_provider.unwrap_or_else(|| { - Box::new(NymApiTopologyProvider::new( + custom_provider.unwrap_or_else(|| match provider_from_config { + config::TopologyStructure::NymApi => Box::new(NymApiTopologyProvider::new( nym_api_urls, env!("CARGO_PKG_VERSION").to_string(), - )) + )), + config::TopologyStructure::GeoAware(group) => Box::new(GeoAwareTopologyProvider::new( + nym_api_urls, + env!("CARGO_PKG_VERSION").to_string(), + group, + )), }) } @@ -521,8 +528,10 @@ where let topology_provider = Self::setup_topology_provider( self.custom_topology_provider.take(), + self.config.debug.topology.topology_structure, self.config.get_nym_api_endpoints(), ); + Self::start_topology_refresher( topology_provider, self.config.debug.topology, diff --git a/common/client-core/src/client/topology_control/geo_aware_provider.rs b/common/client-core/src/client/topology_control/geo_aware_provider.rs new file mode 100644 index 0000000000..268f6612e0 --- /dev/null +++ b/common/client-core/src/client/topology_control/geo_aware_provider.rs @@ -0,0 +1,319 @@ +use std::{collections::HashMap, fmt}; + +use log::{debug, error, info}; +use nym_explorer_api_requests::PrettyDetailedMixNodeBond; +use nym_topology::{ + nym_topology_from_detailed, + provider_trait::{async_trait, TopologyProvider}, + NymTopology, +}; +use nym_validator_client::client::MixId; +use rand::{prelude::SliceRandom, thread_rng}; +use serde::{Deserialize, Serialize}; +use url::Url; + +const MIN_NODES_PER_LAYER: usize = 1; +const EXPLORER_API_MIXNODES_URL: &str = "https://explorer.nymtech.net/api/v1/mix-nodes"; + +// TODO: create a explorer-api-client +async fn fetch_mixnodes_from_explorer_api() -> Option> { + reqwest::get(EXPLORER_API_MIXNODES_URL) + .await + .ok()? + .json::>() + .await + .ok() +} + +#[derive(Copy, Clone, Hash, PartialEq, Eq, Serialize, Deserialize, Debug)] +pub enum CountryGroup { + Europe, + NorthAmerica, + SouthAmerica, + Oceania, + Asia, + Africa, + Unknown, +} + +impl CountryGroup { + // We map contry codes into group, which initially are continent codes to a first approximation, + // but we do it manually to reserve the right to tweak this distribution for our purposes. + fn new(country_code: &str) -> Self { + let country_code = country_code.to_uppercase(); + use CountryGroup::*; + match country_code.as_ref() { + // Europe + "AT" => Europe, + "BG" => Europe, + "CH" => Europe, + "CY" => Europe, + "CZ" => Europe, + "DE" => Europe, + "DK" => Europe, + "ES" => Europe, + "FI" => Europe, + "FR" => Europe, + "GB" => Europe, + "GR" => Europe, + "IE" => Europe, + "IT" => Europe, + "LT" => Europe, + "LU" => Europe, + "LV" => Europe, + "MD" => Europe, + "MT" => Europe, + "NL" => Europe, + "NO" => Europe, + "PL" => Europe, + "RO" => Europe, + "SE" => Europe, + "SK" => Europe, + "TR" => Europe, + "UA" => Europe, + + // North America + "CA" => NorthAmerica, + "MX" => NorthAmerica, + "US" => NorthAmerica, + + // South America + "AR" => SouthAmerica, + "BR" => SouthAmerica, + "CL" => SouthAmerica, + "CO" => SouthAmerica, + "CR" => SouthAmerica, + "GT" => SouthAmerica, + + // Oceania + "AU" => Oceania, + + // Asia + "AM" => Asia, + "BH" => Asia, + "CN" => Asia, + "GE" => Asia, + "HK" => Asia, + "ID" => Asia, + "IL" => Asia, + "IN" => Asia, + "JP" => Asia, + "KH" => Asia, + "KR" => Asia, + "KZ" => Asia, + "MY" => Asia, + "RU" => Asia, + "SG" => Asia, + "TH" => Asia, + "VN" => Asia, + + // Africa + "SC" => Africa, + "UG" => Africa, + "ZA" => Africa, + + // And group level codes work too + "EU" => Europe, + "NA" => NorthAmerica, + "SA" => SouthAmerica, + "OC" => Oceania, + "AS" => Asia, + "AF" => Africa, + + // And some aliases + "EUROPE" => Europe, + "NORTHAMERICA" => NorthAmerica, + "SOUTHAMERICA" => SouthAmerica, + "OCEANIA" => Oceania, + "ASIA" => Asia, + "AFRICA" => Africa, + + _ => { + info!("Unknown country code: {}", country_code); + Unknown + } + } + } +} + +impl fmt::Display for CountryGroup { + fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { + use CountryGroup::*; + match self { + Europe => write!(f, "EU"), + NorthAmerica => write!(f, "NA"), + SouthAmerica => write!(f, "SA"), + Oceania => write!(f, "OC"), + Asia => write!(f, "AS"), + Africa => write!(f, "AF"), + Unknown => write!(f, "Unknown"), + } + } +} + +impl std::str::FromStr for CountryGroup { + type Err = (); + + fn from_str(s: &str) -> Result { + let group = CountryGroup::new(s); + if group == CountryGroup::Unknown { + Err(()) + } else { + Ok(group) + } + } +} + +impl CountryGroup { + #[allow(unused)] + fn known(self) -> Option { + use CountryGroup::*; + match self { + Europe | NorthAmerica | SouthAmerica | Oceania | Asia | Africa => Some(self), + Unknown => None, + } + } +} + +fn group_mixnodes_by_country_code( + mixnodes: Vec, +) -> HashMap> { + mixnodes + .into_iter() + .fold(HashMap::>::new(), |mut acc, m| { + if let Some(ref location) = m.location { + let country_code = location.two_letter_iso_country_code.clone(); + let group_code = CountryGroup::new(country_code.as_str()); + let mixnodes = acc.entry(group_code).or_insert_with(Vec::new); + mixnodes.push(m.mix_id); + } + acc + }) +} + +fn log_mixnode_distribution(mixnodes: &HashMap>) { + let mixnode_distribution = mixnodes + .iter() + .map(|(k, v)| format!("{}: {}", k, v.len())) + .collect::>() + .join(", "); + debug!("Mixnode distribution - {}", mixnode_distribution); +} + +fn check_layer_integrity(topology: NymTopology) -> Result<(), ()> { + let mixes = topology.mixes(); + if mixes.keys().len() < 3 { + error!("Layer is missing in topology!"); + return Err(()); + } + for (layer, mixnodes) in mixes { + debug!("Layer {:?} has {} mixnodes", layer, mixnodes.len()); + if mixnodes.len() < MIN_NODES_PER_LAYER { + error!( + "There are only {} mixnodes in layer {:?}", + mixnodes.len(), + layer + ); + return Err(()); + } + } + Ok(()) +} + +pub struct GeoAwareTopologyProvider { + validator_client: nym_validator_client::client::NymApiClient, + filter_on: CountryGroup, + client_version: String, +} + +impl GeoAwareTopologyProvider { + pub fn new( + mut nym_api_urls: Vec, + client_version: String, + filter_on: CountryGroup, + ) -> GeoAwareTopologyProvider { + log::info!( + "Creating geo-aware topology provider with filter on {:?}", + filter_on + ); + nym_api_urls.shuffle(&mut thread_rng()); + + GeoAwareTopologyProvider { + validator_client: nym_validator_client::client::NymApiClient::new( + nym_api_urls[0].clone(), + ), + filter_on, + client_version, + } + } + + async fn get_topology(&self) -> Option { + let mixnodes = match self.validator_client.get_cached_active_mixnodes().await { + Err(err) => { + error!("failed to get network mixnodes - {err}"); + return None; + } + Ok(mixes) => mixes, + }; + + let gateways = match self.validator_client.get_cached_gateways().await { + Err(err) => { + error!("failed to get network gateways - {err}"); + return None; + } + Ok(gateways) => gateways, + }; + + // Also fetch mixnodes cached by explorer-api, with the purpose of getting their + // geolocation. + debug!("Fetching mixnodes from explorer-api..."); + let Some(mixnodes_from_explorer_api) = fetch_mixnodes_from_explorer_api().await else { + error!("failed to get mixnodes from explorer-api"); + return None; + }; + + // Partition mixnodes_from_explorer_api according to the value of + // two_letter_iso_country_code. + // NOTE: we construct the full distribution here, but only use the one we're interested in. + // The reason we this instead of a straight filter is that this opens up the possibility to + // complement a small grouping with mixnodes from adjecent countries. + let mixnode_distribution = group_mixnodes_by_country_code(mixnodes_from_explorer_api); + log_mixnode_distribution(&mixnode_distribution); + + let Some(filtered_mixnode_ids) = mixnode_distribution.get(&self.filter_on) else { + error!("no mixnodes found for: {}", self.filter_on); + return None; + }; + + let mixnodes = mixnodes + .into_iter() + .filter(|m| filtered_mixnode_ids.contains(&m.mix_id())) + .collect::>(); + + let topology = nym_topology_from_detailed(mixnodes, gateways) + .filter_system_version(&self.client_version); + + // TODO: return real error type + check_layer_integrity(topology.clone()).ok()?; + + Some(topology) + } +} + +#[cfg(not(target_arch = "wasm32"))] +#[async_trait] +impl TopologyProvider for GeoAwareTopologyProvider { + // this will be manually refreshed on a timer specified inside mixnet client config + async fn get_new_topology(&mut self) -> Option { + self.get_topology().await + } +} + +#[cfg(target_arch = "wasm32")] +#[async_trait(?Send)] +impl TopologyProvider for GeoAwareTopologyProvider { + // this will be manually refreshed on a timer specified inside mixnet client config + async fn get_new_topology(&mut self) -> Option { + self.get_topology().await + } +} diff --git a/common/client-core/src/client/topology_control/mod.rs b/common/client-core/src/client/topology_control/mod.rs index 0fef523b1e..ed426dde50 100644 --- a/common/client-core/src/client/topology_control/mod.rs +++ b/common/client-core/src/client/topology_control/mod.rs @@ -10,6 +10,7 @@ use nym_topology::NymTopologyError; use std::time::Duration; mod accessor; +pub mod geo_aware_provider; pub(crate) mod nym_api_provider; // TODO: move it to config later diff --git a/common/client-core/src/config/mod.rs b/common/client-core/src/config/mod.rs index e8f08adfaa..465c227e19 100644 --- a/common/client-core/src/config/mod.rs +++ b/common/client-core/src/config/mod.rs @@ -8,7 +8,7 @@ use serde::{Deserialize, Serialize}; use std::time::Duration; use url::Url; -use crate::error::ClientCoreError; +use crate::{client::topology_control::geo_aware_provider::CountryGroup, error::ClientCoreError}; #[cfg(target_arch = "wasm32")] use wasm_bindgen::prelude::*; @@ -158,6 +158,15 @@ impl Config { self } + pub fn with_topology_structure(mut self, topology_structure: TopologyStructure) -> Self { + self.set_topology_structure(topology_structure); + self + } + + pub fn set_topology_structure(&mut self, topology_structure: TopologyStructure) { + self.debug.topology.topology_structure = topology_structure; + } + pub fn with_no_per_hop_delays(mut self, no_per_hop_delays: bool) -> Self { if no_per_hop_delays { self.set_no_per_hop_delays() @@ -466,6 +475,16 @@ pub struct Topology { /// the first valid instance. /// Supersedes `topology_refresh_rate_ms`. pub disable_refreshing: bool, + + /// Specifies the mixnode topology to be used for sending packets. + pub topology_structure: TopologyStructure, +} + +#[derive(Default, Copy, Clone, Debug, PartialEq, Serialize, Deserialize)] +pub enum TopologyStructure { + #[default] + NymApi, + GeoAware(CountryGroup), } impl Default for Topology { @@ -474,6 +493,7 @@ impl Default for Topology { topology_refresh_rate: DEFAULT_TOPOLOGY_REFRESH_RATE, topology_resolution_timeout: DEFAULT_TOPOLOGY_RESOLUTION_TIMEOUT, disable_refreshing: false, + topology_structure: TopologyStructure::default(), } } } diff --git a/common/client-core/src/config/old_config_v1_1_20_2.rs b/common/client-core/src/config/old_config_v1_1_20_2.rs index ed0cd0356a..a097b55f2a 100644 --- a/common/client-core/src/config/old_config_v1_1_20_2.rs +++ b/common/client-core/src/config/old_config_v1_1_20_2.rs @@ -267,6 +267,7 @@ impl From for Topology { topology_refresh_rate: value.topology_refresh_rate, topology_resolution_timeout: value.topology_resolution_timeout, disable_refreshing: value.disable_refreshing, + topology_structure: Default::default(), } } } diff --git a/common/cosmwasm-smart-contracts/mixnet-contract/src/mixnode.rs b/common/cosmwasm-smart-contracts/mixnet-contract/src/mixnode.rs index 248bc7e143..676098fce6 100644 --- a/common/cosmwasm-smart-contracts/mixnet-contract/src/mixnode.rs +++ b/common/cosmwasm-smart-contracts/mixnet-contract/src/mixnode.rs @@ -69,6 +69,10 @@ impl MixNodeDetails { self.bond_information.mix_id } + pub fn layer(&self) -> Layer { + self.bond_information.layer + } + pub fn is_unbonding(&self) -> bool { self.bond_information.is_unbonding } diff --git a/common/socks5-client-core/Cargo.toml b/common/socks5-client-core/Cargo.toml index 9ca792f8b1..2e1aa52b32 100644 --- a/common/socks5-client-core/Cargo.toml +++ b/common/socks5-client-core/Cargo.toml @@ -7,22 +7,27 @@ edition = "2021" [dependencies] dirs = "4.0" +futures = "0.3" log = { workspace = true } pin-project = "1.0" rand = { version = "0.7.3", features = ["wasm-bindgen"] } +reqwest = "0.11.4" +schemars = { version = "0.8", features = ["preserve_order"] } serde = { workspace = true, features = ["derive"] } # for config serialization/deserialization -thiserror = "1.0.34" tap = "1.0.1" +thiserror = "1.0.34" tokio = { version = "1.24.1", features = ["rt-multi-thread", "net", "signal"] } -futures = "0.3" +url = "2.2" -nym-client-core = { path = "../client-core", features = ["fs-surb-storage"] } nym-bandwidth-controller = { path = "../../common/bandwidth-controller" } +nym-client-core = { path = "../client-core", features = ["fs-surb-storage"] } nym-config = { path = "../config" } +nym-contracts-common = { path = "../cosmwasm-smart-contracts/contracts-common" } nym-credential-storage = { path = "../credential-storage" } +nym-mixnet-contract-common = { path = "../cosmwasm-smart-contracts/mixnet-contract" } nym-network-defaults = { path = "../network-defaults" } -nym-socks5-proxy-helpers = { path = "../socks5/proxy-helpers" } nym-service-providers-common = { path = "../../service-providers/common" } +nym-socks5-proxy-helpers = { path = "../socks5/proxy-helpers" } nym-socks5-requests = { path = "../socks5/requests" } nym-sphinx = { path = "../nymsphinx" } nym-task = { path = "../task" } diff --git a/common/socks5-client-core/src/lib.rs b/common/socks5-client-core/src/lib.rs index 2070eeaf71..74d27b69ed 100644 --- a/common/socks5-client-core/src/lib.rs +++ b/common/socks5-client-core/src/lib.rs @@ -24,6 +24,7 @@ use nym_credential_storage::storage::Storage as CredentialStorage; use nym_sphinx::addressing::clients::Recipient; use nym_sphinx::params::PacketType; use nym_task::{TaskClient, TaskManager}; + use std::error::Error; pub mod config; diff --git a/explorer-api/Cargo.toml b/explorer-api/Cargo.toml index ab0a56612b..d6941a19e1 100644 --- a/explorer-api/Cargo.toml +++ b/explorer-api/Cargo.toml @@ -8,13 +8,18 @@ edition = "2021" [dependencies] chrono = { version = "0.4.19", features = ["serde"] } clap = { version = "4.0", features = ["cargo", "derive"] } +dotenvy = "0.15.6" humantime-serde = "1.0" isocountry = "0.3.2" itertools = "0.10.3" lazy_static = "1.4.0" log = { workspace = true } +maxminddb = "0.23.0" okapi = { version = "0.7.0-rc.1", features = ["impl_json_schema"] } pretty_env_logger = "0.4.0" +rand = "0.8.5" +rand_pcg = "0.3.1" +rand_seeder = "0.2.3" reqwest = "0.11.4" rocket = { version = "0.5.0-rc.2", features = ["json"] } rocket_cors = { git="https://github.com/lawliet89/rocket_cors", rev="dfd3662c49e2f6fc37df35091cb94d82f7fb5915" } @@ -24,15 +29,11 @@ serde = "1.0.126" serde_json = "1.0.66" thiserror = "1.0.29" tokio = {version = "1.21.2", features = ["full"] } -maxminddb = "0.23.0" -dotenvy = "0.15.6" -rand = "0.8.5" -rand_seeder = "0.2.3" -rand_pcg = "0.3.1" -nym-mixnet-contract-common = { path = "../common/cosmwasm-smart-contracts/mixnet-contract" } -nym-contracts-common = { path = "../common/cosmwasm-smart-contracts/contracts-common" } -nym-network-defaults = { path = "../common/network-defaults" } nym-bin-common = { path = "../common/bin-common"} +nym-contracts-common = { path = "../common/cosmwasm-smart-contracts/contracts-common" } +nym-explorer-api-requests = { path = "explorer-api-requests" } +nym-mixnet-contract-common = { path = "../common/cosmwasm-smart-contracts/mixnet-contract" } +nym-network-defaults = { path = "../common/network-defaults" } nym-task = { path = "../common/task" } nym-validator-client = { path = "../common/client-libs/validator-client", features=["http-client"] } diff --git a/explorer-api/explorer-api-requests/Cargo.toml b/explorer-api/explorer-api-requests/Cargo.toml new file mode 100644 index 0000000000..93c8faaada --- /dev/null +++ b/explorer-api/explorer-api-requests/Cargo.toml @@ -0,0 +1,12 @@ +[package] +name = "nym-explorer-api-requests" +version = "0.1.0" +edition = "2021" + +[dependencies] +nym-contracts-common = { path = "../../common/cosmwasm-smart-contracts/contracts-common" } +nym-mixnet-contract-common = { path = "../../common/cosmwasm-smart-contracts/mixnet-contract" } +nym-validator-client = { path = "../../common/client-libs/validator-client" } +schemars = { version = "0.8", features = ["preserve_order"] } +serde = { version = "1.0", features = ["derive"] } +ts-rs = { version = "6.1.2", optional = true } diff --git a/explorer-api/explorer-api-requests/src/lib.rs b/explorer-api/explorer-api-requests/src/lib.rs new file mode 100644 index 0000000000..bfcafa2860 --- /dev/null +++ b/explorer-api/explorer-api-requests/src/lib.rs @@ -0,0 +1,44 @@ +use nym_contracts_common::Percent; +use nym_mixnet_contract_common::{Addr, Coin, Layer, MixId, MixNode}; +use nym_validator_client::models::NodePerformance; +use schemars::JsonSchema; +use serde::{Deserialize, Serialize}; + +#[derive(Clone, Debug, Serialize, Deserialize, JsonSchema, PartialEq)] +#[serde(rename_all = "snake_case")] +pub enum MixnodeStatus { + Active, // in both the active set and the rewarded set + Standby, // only in the rewarded set + Inactive, // in neither the rewarded set nor the active set +} + +#[derive(Clone, Debug, Serialize, Deserialize, JsonSchema)] +pub struct PrettyDetailedMixNodeBond { + pub mix_id: MixId, + pub location: Option, + pub status: MixnodeStatus, + pub pledge_amount: Coin, + pub total_delegation: Coin, + pub owner: Addr, + pub layer: Layer, + pub mix_node: MixNode, + pub stake_saturation: f32, + pub uncapped_saturation: f32, + pub avg_uptime: u8, + pub node_performance: NodePerformance, + pub estimated_operator_apy: f64, + pub estimated_delegators_apy: f64, + pub operating_cost: Coin, + pub profit_margin_percent: Percent, + pub family_id: Option, + pub blacklisted: bool, +} + +#[derive(Clone, Debug, JsonSchema, Serialize, Deserialize)] +pub struct Location { + pub two_letter_iso_country_code: String, + pub three_letter_iso_country_code: String, + pub country_name: String, + pub latitude: Option, + pub longitude: Option, +} diff --git a/explorer-api/src/country_statistics/geolocate.rs b/explorer-api/src/country_statistics/geolocate.rs index 8158c6e65e..a80ebc28e4 100644 --- a/explorer-api/src/country_statistics/geolocate.rs +++ b/explorer-api/src/country_statistics/geolocate.rs @@ -1,9 +1,9 @@ // Copyright 2022 - Nym Technologies SA // SPDX-License-Identifier: Apache-2.0 -use crate::mix_nodes::location::Location; use crate::state::ExplorerApiStateContext; use log::{info, warn}; +use nym_explorer_api_requests::Location; use nym_task::TaskClient; pub(crate) struct GeoLocateTask { @@ -64,7 +64,7 @@ impl GeoLocateTask { ) { Ok(opt) => match opt { Some(location) => { - let location = Location::new(location); + let location: Location = location.into(); trace!( "{} mix nodes already located. Ip {} is located in {:#?}", diff --git a/explorer-api/src/geo_ip/location.rs b/explorer-api/src/geo_ip/location.rs index adbdb6cef3..fdb8584938 100644 --- a/explorer-api/src/geo_ip/location.rs +++ b/explorer-api/src/geo_ip/location.rs @@ -42,6 +42,18 @@ pub(crate) struct Location { pub(crate) longitude: Option, } +impl From for nym_explorer_api_requests::Location { + fn from(location: Location) -> Self { + nym_explorer_api_requests::Location { + country_name: location.name, + two_letter_iso_country_code: location.iso_alpha2, + three_letter_iso_country_code: location.iso_alpha3, + latitude: location.latitude, + longitude: location.longitude, + } + } +} + impl GeoIp { pub fn new() -> Self { let db_path = std::env::var("GEOIP_DB_PATH").unwrap_or_else(|e| { diff --git a/explorer-api/src/mix_node/http.rs b/explorer-api/src/mix_node/http.rs index 137c6250ed..e00ed8ff82 100644 --- a/explorer-api/src/mix_node/http.rs +++ b/explorer-api/src/mix_node/http.rs @@ -6,9 +6,10 @@ use crate::mix_node::delegations::{ }; use crate::mix_node::econ_stats::retrieve_mixnode_econ_stats; use crate::mix_node::models::{ - EconomicDynamicsStats, NodeDescription, NodeStats, PrettyDetailedMixNodeBond, SummedDelegations, + EconomicDynamicsStats, NodeDescription, NodeStats, SummedDelegations, }; use crate::state::ExplorerApiStateContext; +use nym_explorer_api_requests::PrettyDetailedMixNodeBond; use nym_mixnet_contract_common::{Delegation, MixId}; use reqwest::Error as ReqwestError; use rocket::response::status::NotFound; diff --git a/explorer-api/src/mix_node/mod.rs b/explorer-api/src/mix_node/mod.rs index 88c3b1cd71..dac365c71d 100644 --- a/explorer-api/src/mix_node/mod.rs +++ b/explorer-api/src/mix_node/mod.rs @@ -1,4 +1,4 @@ pub(crate) mod delegations; pub(crate) mod econ_stats; pub(crate) mod http; -pub(crate) mod models; +pub mod models; diff --git a/explorer-api/src/mix_node/models.rs b/explorer-api/src/mix_node/models.rs index 94ae6558d0..4adfa6dd86 100644 --- a/explorer-api/src/mix_node/models.rs +++ b/explorer-api/src/mix_node/models.rs @@ -2,49 +2,15 @@ // SPDX-License-Identifier: Apache-2.0 use crate::cache::Cache; -use crate::mix_nodes::location::Location; -use nym_contracts_common::Percent; use nym_mixnet_contract_common::Delegation; -use nym_mixnet_contract_common::{Addr, Coin, Layer, MixId, MixNode}; -use nym_validator_client::models::{NodePerformance, SelectionChance}; +use nym_mixnet_contract_common::{Addr, Coin, MixId}; +use nym_validator_client::models::SelectionChance; use serde::Deserialize; use serde::Serialize; use std::sync::Arc; use std::time::SystemTime; use tokio::sync::RwLock; -#[derive(Clone, Debug, Serialize, JsonSchema, PartialEq)] -#[serde(rename_all = "snake_case")] -pub(crate) enum MixnodeStatus { - Active, // in both the active set and the rewarded set - Standby, // only in the rewarded set - Inactive, // in neither the rewarded set nor the active set -} - -#[derive(Clone, Debug, Serialize, JsonSchema)] -pub(crate) struct PrettyDetailedMixNodeBond { - // I leave this to @MS to refactor this type as a lot of things here are redundant thanks to - // the existence of `MixNodeDetails` - pub mix_id: MixId, - pub location: Option, - pub status: MixnodeStatus, - pub pledge_amount: Coin, - pub total_delegation: Coin, - pub owner: Addr, - pub layer: Layer, - pub mix_node: MixNode, - pub stake_saturation: f32, - pub uncapped_saturation: f32, - pub avg_uptime: u8, - pub node_performance: NodePerformance, - pub estimated_operator_apy: f64, - pub estimated_delegators_apy: f64, - pub operating_cost: Coin, - pub profit_margin_percent: Percent, - pub family_id: Option, - pub blacklisted: bool, -} - #[derive(Clone, Debug, Deserialize, Serialize, PartialEq, Eq, JsonSchema)] pub struct SummedDelegations { pub owner: Addr, diff --git a/explorer-api/src/mix_nodes/http.rs b/explorer-api/src/mix_nodes/http.rs index ef5570e455..a36843b66f 100644 --- a/explorer-api/src/mix_nodes/http.rs +++ b/explorer-api/src/mix_nodes/http.rs @@ -1,6 +1,6 @@ -use crate::mix_node::models::{MixnodeStatus, PrettyDetailedMixNodeBond}; use crate::mix_nodes::models::{MixNodeActiveSetSummary, MixNodeSummary}; use crate::state::ExplorerApiStateContext; +use nym_explorer_api_requests::{MixnodeStatus, PrettyDetailedMixNodeBond}; use rocket::serde::json::Json; use rocket::{Route, State}; use rocket_okapi::okapi::openapi3::OpenApi; diff --git a/explorer-api/src/mix_nodes/location.rs b/explorer-api/src/mix_nodes/location.rs index b876cdc792..4908564697 100644 --- a/explorer-api/src/mix_nodes/location.rs +++ b/explorer-api/src/mix_nodes/location.rs @@ -1,7 +1,7 @@ // Copyright 2021 - Nym Technologies SA // SPDX-License-Identifier: Apache-2.0 -use crate::geo_ip::location; +use nym_explorer_api_requests::Location; use nym_mixnet_contract_common::MixId; use serde::{Deserialize, Serialize}; use std::collections::HashMap; @@ -31,27 +31,6 @@ pub(crate) struct LocationCacheItem { pub(crate) valid_until: SystemTime, } -#[derive(Clone, Debug, JsonSchema, Serialize, Deserialize)] -pub(crate) struct Location { - pub(crate) two_letter_iso_country_code: String, - pub(crate) three_letter_iso_country_code: String, - pub(crate) country_name: String, - pub(crate) latitude: Option, - pub(crate) longitude: Option, -} - -impl Location { - pub(crate) fn new(location: location::Location) -> Self { - Location { - country_name: location.name, - two_letter_iso_country_code: location.iso_alpha2, - three_letter_iso_country_code: location.iso_alpha3, - latitude: location.latitude, - longitude: location.longitude, - } - } -} - impl LocationCacheItem { pub(crate) fn new_from_location(location: Option) -> Self { LocationCacheItem { diff --git a/explorer-api/src/mix_nodes/models.rs b/explorer-api/src/mix_nodes/models.rs index bfead42c8c..b107bb2168 100644 --- a/explorer-api/src/mix_nodes/models.rs +++ b/explorer-api/src/mix_nodes/models.rs @@ -5,6 +5,7 @@ use std::collections::{HashMap, HashSet}; use std::sync::Arc; use std::time::{Duration, SystemTime}; +use nym_explorer_api_requests::{Location, MixnodeStatus, PrettyDetailedMixNodeBond}; use nym_mixnet_contract_common::rewarding::helpers::truncate_reward; use nym_mixnet_contract_common::MixId; use serde::Serialize; @@ -14,8 +15,7 @@ use crate::helpers::best_effort_small_dec_to_f64; use nym_validator_client::models::MixNodeBondAnnotated; use super::utils::family_numerical_id; -use crate::mix_node::models::{MixnodeStatus, PrettyDetailedMixNodeBond}; -use crate::mix_nodes::location::{Location, LocationCache, LocationCacheItem}; +use crate::mix_nodes::location::{LocationCache, LocationCacheItem}; use crate::mix_nodes::CACHE_ENTRY_TTL; #[derive(Clone, Debug, Serialize, JsonSchema)] diff --git a/nym-connect/desktop/Cargo.lock b/nym-connect/desktop/Cargo.lock index 5897f51672..c522d297d1 100644 --- a/nym-connect/desktop/Cargo.lock +++ b/nym-connect/desktop/Cargo.lock @@ -3559,6 +3559,7 @@ dependencies = [ "nym-config", "nym-credential-storage", "nym-crypto", + "nym-explorer-api-requests", "nym-gateway-client", "nym-gateway-requests", "nym-network-defaults", @@ -3569,6 +3570,7 @@ dependencies = [ "nym-topology", "nym-validator-client", "rand 0.7.3", + "reqwest", "serde", "serde_json", "sha2 0.10.6", @@ -3780,6 +3782,17 @@ dependencies = [ "zeroize", ] +[[package]] +name = "nym-explorer-api-requests" +version = "0.1.0" +dependencies = [ + "nym-contracts-common", + "nym-mixnet-contract-common", + "nym-validator-client", + "schemars", + "serde", +] + [[package]] name = "nym-gateway-client" version = "0.1.0" @@ -3979,7 +3992,9 @@ dependencies = [ "nym-bandwidth-controller", "nym-client-core", "nym-config", + "nym-contracts-common", "nym-credential-storage", + "nym-mixnet-contract-common", "nym-network-defaults", "nym-service-providers-common", "nym-socks5-proxy-helpers", @@ -3989,10 +4004,13 @@ dependencies = [ "nym-validator-client", "pin-project", "rand 0.7.3", + "reqwest", + "schemars", "serde", "tap", "thiserror", "tokio", + "url", ] [[package]] @@ -5121,9 +5139,9 @@ checksum = "f162c6dd7b008981e4d40210aca20b4bd0f9b60ca9271061b07f78537722f2e1" [[package]] name = "reqwest" -version = "0.11.15" +version = "0.11.18" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0ba30cc2c0cd02af1222ed216ba659cdb2f879dfe3181852fe7c50b1d0005949" +checksum = "cde824a14b7c14f85caff81225f411faacc04a2013f41670f41443742b1c1c55" dependencies = [ "base64 0.21.2", "bytes", diff --git a/nym-connect/desktop/src-tauri/src/tasks.rs b/nym-connect/desktop/src-tauri/src/tasks.rs index 8c69b1be7e..06b0809c2f 100644 --- a/nym-connect/desktop/src-tauri/src/tasks.rs +++ b/nym-connect/desktop/src-tauri/src/tasks.rs @@ -1,17 +1,23 @@ use futures::{channel::mpsc, StreamExt}; -use nym_client_core::client::base_client::storage::gateway_details::GatewayDetailsStore; -use nym_client_core::client::base_client::storage::{MixnetClientStorage, OnDiskPersistent}; -use nym_client_core::{config::GatewayEndpointConfig, error::ClientCoreStatusMessage}; -use nym_socks5_client_core::NymClient as Socks5NymClient; -use nym_socks5_client_core::Socks5ControlMessageSender; +use nym_client_core::{ + client::{ + base_client::storage::{ + gateway_details::GatewayDetailsStore, MixnetClientStorage, OnDiskPersistent, + }, + topology_control::geo_aware_provider::CountryGroup, + }, + config::{GatewayEndpointConfig, TopologyStructure}, + error::ClientCoreStatusMessage, +}; +use nym_socks5_client_core::{NymClient as Socks5NymClient, Socks5ControlMessageSender}; use nym_sphinx::params::PacketSize; use nym_task::manager::TaskStatus; use std::sync::Arc; use tap::TapFallible; use tokio::sync::RwLock; -use crate::config::{Config, PrivacyLevel}; use crate::{ + config::{Config, PrivacyLevel}, error::Result, events::{self, emit_event, emit_status_event}, models::{ConnectionStatusKind, ConnectivityTestResult}, @@ -46,6 +52,14 @@ fn override_config_from_env(config: &mut Config, privacy_level: &PrivacyLevel) { log::warn!("Disabling per-hop delay"); config.core.base.set_no_per_hop_delays(); + + // TODO: selectable in the UI + let default_country_group = CountryGroup::Europe; + log::warn!("Using geo-aware mixnode selection: {default_country_group}"); + config + .core + .base + .set_topology_structure(TopologyStructure::GeoAware(default_country_group)); } } diff --git a/service-providers/network-requester/src/allowed_hosts/hosts.rs b/service-providers/network-requester/src/allowed_hosts/hosts.rs index 5c48369d0d..11aa3dd276 100644 --- a/service-providers/network-requester/src/allowed_hosts/hosts.rs +++ b/service-providers/network-requester/src/allowed_hosts/hosts.rs @@ -136,7 +136,6 @@ impl HostsStore { }) .map(Host::from) .collect(); - dbg!(&hosts); Ok(hosts) } } From 53db18df2c4e29359daef186f9cdb51c6e02f2ca Mon Sep 17 00:00:00 2001 From: mfahampshire Date: Wed, 2 Aug 2023 16:26:41 +0200 Subject: [PATCH 14/21] rephrased intro --- documentation/dev-portal/src/SUMMARY.md | 2 ++ documentation/dev-portal/src/introduction.md | 4 ++-- documentation/dev-portal/src/quickstart/chat-demo.md | 5 +++++ .../dev-portal/src/quickstart/cred-playground.md | 5 +++++ documentation/dev-portal/src/quickstart/overview.md | 12 +++--------- 5 files changed, 17 insertions(+), 11 deletions(-) create mode 100644 documentation/dev-portal/src/quickstart/chat-demo.md create mode 100644 documentation/dev-portal/src/quickstart/cred-playground.md diff --git a/documentation/dev-portal/src/SUMMARY.md b/documentation/dev-portal/src/SUMMARY.md index aeae804662..0e0c02bc58 100644 --- a/documentation/dev-portal/src/SUMMARY.md +++ b/documentation/dev-portal/src/SUMMARY.md @@ -11,6 +11,8 @@ # Quickstart - [Overview](quickstart/overview.md) +- [Chat demo (webapp)](quickstart/chat-demo.md) +- [Coconut Credential Playground (webapp)](quickstart/cred-playground.md) - [SOCKS Proxy (CLI)](quickstart/socks-proxy.md) - [NymConnect Beta (GUI)](quickstart/nymconnect-gui.md) diff --git a/documentation/dev-portal/src/introduction.md b/documentation/dev-portal/src/introduction.md index d679a77c53..7335fab32b 100644 --- a/documentation/dev-portal/src/introduction.md +++ b/documentation/dev-portal/src/introduction.md @@ -1,5 +1,5 @@ # Introduction -Welcome to the Nym Developer Portal, containing the resources and tools needed to build privacy enhanced apps (PEApps) with Nym's technology. Whether you're a seasoned developer or just getting started, our portal is designed to help you create decentralized applications and services utilising the Nym mixnet. +Welcome to the Nym Developer Portal, containing quickstart resources, user manuals, integration information, and tutorials outlining to start building privacy enhanced apps. -Join our community of developers and start building the decentralized future today! +For more in-depth information about nodes, network traffic flows, etc check out the [docs](https://nymtech.net/docs). diff --git a/documentation/dev-portal/src/quickstart/chat-demo.md b/documentation/dev-portal/src/quickstart/chat-demo.md new file mode 100644 index 0000000000..6e2f5c244a --- /dev/null +++ b/documentation/dev-portal/src/quickstart/chat-demo.md @@ -0,0 +1,5 @@ +# Chat demo (webapp) + +You can find a browser-based 'hello world' chat app [here](https://chat-demo.nymtech.net). + +Either open in two browser windows and send messages to yourself, or share with a friend and send messages to each other through the mixnet. diff --git a/documentation/dev-portal/src/quickstart/cred-playground.md b/documentation/dev-portal/src/quickstart/cred-playground.md new file mode 100644 index 0000000000..aa2220940c --- /dev/null +++ b/documentation/dev-portal/src/quickstart/cred-playground.md @@ -0,0 +1,5 @@ +# Coconut Credential Playground (webapp) + +There is a coconut-scheme based Credential Library playground [here](https://coco-demo.nymtech.net/). This is a WASM implementation of our Coconut libraries which generate raw Coconut credentials. Test it to create and re-randomize your own credentials. + +For more information on what is happening here check out the [Coconut docs](https://nymtech.net/docs/coconut.html). diff --git a/documentation/dev-portal/src/quickstart/overview.md b/documentation/dev-portal/src/quickstart/overview.md index b2ac4199c9..534ed60fe5 100644 --- a/documentation/dev-portal/src/quickstart/overview.md +++ b/documentation/dev-portal/src/quickstart/overview.md @@ -1,13 +1,7 @@ # Overview -There are multiple options to quickly connect to Nym and see the network in action without the need for any code changes to your application. At most, these involve running Nym as a second process alongside an existing application in order to send traffic through the mixnet. +There are multiple options to quickly connect to Nym and play with both the mixnet and credentials on the Sandbox testnet. -Demo applications: -* a browser-based 'hello world' [chat application](https://chat-demo.nymtech.net). Either open in two browser windows and send messages to yourself, or share with a friend and send messages to each other through the mixnet! -* a Coconut-scheme based [Credential Library](https://coco-demo.nymtech.net/). This is a WASM implementation of our Coconut libraries which generate raw Coconut credentials. Test it to create and re-randomize your own credentials! -
-Proxy traffic with the Nym Socks5 client: -* set up a plug-and-play connection with the [NymConnect](./nymconnect-gui.md) GUI for proxying Telegram, Electrum, Keybase or Blockstream Green traffic through the mixnet (~2 minutes). -* [Download and run](./socks-proxy.md) the Nym Socks5 client via the CLI, for other desktop applications with SOCKS5 connection options (~30 minutes). +At most, these involve running Nym as a second process alongside an existing application in order to send traffic through the mixnet, most are either interact webpages or a standalone app. -If you've already covered the information in this section, or want to jump straight into integrating/ a Nym connection into an existing application, head to the [Integrations](../integrations/integration-options.md) section. +If you've already covered the information in this section, or want to jump straight into integrating/ a Nym connection into an existing application, head to the [Integrations](../integrations/integration-options.md) section. From 122612fa03441c5758c154a94b4d3b0656189580 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bogdan-=C8=98tefan=20Neac=C5=9Fu?= Date: Mon, 7 Aug 2023 12:27:31 +0300 Subject: [PATCH 15/21] Apply fix from feature/ephemera to develop too (#3698) (#3742) --- common/nymsphinx/params/src/packet_sizes.rs | 39 ++++++++++++++++++--- contracts/Cargo.lock | 6 ++++ nym-connect/desktop/Cargo.lock | 2 -- nym-wallet/Cargo.lock | 17 +++++++++ 4 files changed, 57 insertions(+), 7 deletions(-) diff --git a/common/nymsphinx/params/src/packet_sizes.rs b/common/nymsphinx/params/src/packet_sizes.rs index ecae71993d..58d9681efc 100644 --- a/common/nymsphinx/params/src/packet_sizes.rs +++ b/common/nymsphinx/params/src/packet_sizes.rs @@ -2,10 +2,10 @@ // SPDX-License-Identifier: Apache-2.0 use crate::PacketType; -use nym_sphinx_types::{ - header::HEADER_SIZE, MIN_PACKET_SIZE, MIX_PARAMS_LEN, OUTFOX_PACKET_OVERHEAD, - PAYLOAD_OVERHEAD_SIZE, -}; +#[cfg(feature = "sphinx")] +use nym_sphinx_types::{header::HEADER_SIZE, PAYLOAD_OVERHEAD_SIZE}; +#[cfg(feature = "outfox")] +use nym_sphinx_types::{MIN_PACKET_SIZE, MIX_PARAMS_LEN, OUTFOX_PACKET_OVERHEAD}; use serde::{Deserialize, Serialize}; use std::cmp::Ordering; use std::convert::TryFrom; @@ -14,6 +14,7 @@ use std::str::FromStr; use thiserror::Error; // each sphinx packet contains mandatory header and payload padding + markers +#[cfg(feature = "sphinx")] const SPHINX_PACKET_OVERHEAD: usize = HEADER_SIZE + PAYLOAD_OVERHEAD_SIZE; // it's up to the smart people to figure those values out : ) @@ -22,16 +23,23 @@ const SPHINX_PACKET_OVERHEAD: usize = HEADER_SIZE + PAYLOAD_OVERHEAD_SIZE; // TODO: I'm not entirely sure if we can easily extract `::NonceSize` // into a const usize before relevant stuff is stabilised in rust... - +#[cfg(feature = "sphinx")] const ACK_IV_SIZE: usize = 16; +#[cfg(feature = "sphinx")] const ACK_PACKET_SIZE: usize = ACK_IV_SIZE + crate::FRAG_ID_LEN + SPHINX_PACKET_OVERHEAD; +#[cfg(feature = "sphinx")] const REGULAR_PACKET_SIZE: usize = 2 * 1024 + SPHINX_PACKET_OVERHEAD; +#[cfg(feature = "sphinx")] const EXTENDED_PACKET_SIZE_8: usize = 8 * 1024 + SPHINX_PACKET_OVERHEAD; +#[cfg(feature = "sphinx")] const EXTENDED_PACKET_SIZE_16: usize = 16 * 1024 + SPHINX_PACKET_OVERHEAD; +#[cfg(feature = "sphinx")] const EXTENDED_PACKET_SIZE_32: usize = 32 * 1024 + SPHINX_PACKET_OVERHEAD; +#[cfg(feature = "outfox")] const OUTFOX_ACK_PACKET_SIZE: usize = MIN_PACKET_SIZE + OUTFOX_PACKET_OVERHEAD; +#[cfg(feature = "outfox")] const OUTFOX_REGULAR_PACKET_SIZE: usize = 2 * 1024 + OUTFOX_PACKET_OVERHEAD; #[derive(Debug, Error)] @@ -154,39 +162,55 @@ impl TryFrom for PacketSize { impl PacketSize { pub const fn size(self) -> usize { + #[allow(unreachable_patterns)] match self { + #[cfg(feature = "sphinx")] PacketSize::RegularPacket => REGULAR_PACKET_SIZE, + #[cfg(feature = "sphinx")] PacketSize::AckPacket => ACK_PACKET_SIZE, + #[cfg(feature = "sphinx")] PacketSize::ExtendedPacket8 => EXTENDED_PACKET_SIZE_8, + #[cfg(feature = "sphinx")] PacketSize::ExtendedPacket16 => EXTENDED_PACKET_SIZE_16, + #[cfg(feature = "sphinx")] PacketSize::ExtendedPacket32 => EXTENDED_PACKET_SIZE_32, + #[cfg(feature = "outfox")] PacketSize::OutfoxRegularPacket => OUTFOX_REGULAR_PACKET_SIZE, + #[cfg(feature = "outfox")] PacketSize::OutfoxAckPacket => OUTFOX_ACK_PACKET_SIZE, + _ => 0, } } pub const fn header_size(&self) -> usize { + #[allow(unreachable_patterns)] match self { + #[cfg(feature = "sphinx")] PacketSize::RegularPacket | PacketSize::AckPacket | PacketSize::ExtendedPacket8 | PacketSize::ExtendedPacket16 | PacketSize::ExtendedPacket32 => HEADER_SIZE, + #[cfg(feature = "outfox")] PacketSize::OutfoxRegularPacket | PacketSize::OutfoxAckPacket => MIX_PARAMS_LEN, + _ => 0, } } pub const fn payload_overhead(&self) -> usize { #[allow(unreachable_patterns)] match self { + #[cfg(feature = "sphinx")] PacketSize::RegularPacket | PacketSize::AckPacket | PacketSize::ExtendedPacket8 | PacketSize::ExtendedPacket16 | PacketSize::ExtendedPacket32 => PAYLOAD_OVERHEAD_SIZE, + #[cfg(feature = "outfox")] PacketSize::OutfoxRegularPacket | PacketSize::OutfoxAckPacket => { OUTFOX_PACKET_OVERHEAD - MIX_PARAMS_LEN // Mix params are calculated into the total overhead so we take them out here } + _ => 0, } } @@ -244,11 +268,16 @@ impl PacketSize { plaintext_size: usize, packet_type: PacketType, ) -> Result { + #[allow(unreachable_patterns)] let overhead = match packet_type { + #[cfg(feature = "sphinx")] PacketType::Mix => SPHINX_PACKET_OVERHEAD, #[allow(deprecated)] + #[cfg(feature = "sphinx")] PacketType::Vpn => SPHINX_PACKET_OVERHEAD, + #[cfg(feature = "outfox")] PacketType::Outfox => OUTFOX_PACKET_OVERHEAD, + _ => 0, }; let packet_size = plaintext_size + overhead; Self::get_type(packet_size) diff --git a/contracts/Cargo.lock b/contracts/Cargo.lock index 1a87652242..ebeae6d7ea 100644 --- a/contracts/Cargo.lock +++ b/contracts/Cargo.lock @@ -234,6 +234,12 @@ dependencies = [ "libc", ] +[[package]] +name = "crunchy" +version = "0.2.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7a81dae078cea95a014a339291cec439d2f232ebe854a9d672b796c6afafa9b7" + [[package]] name = "crypto-bigint" version = "0.4.9" diff --git a/nym-connect/desktop/Cargo.lock b/nym-connect/desktop/Cargo.lock index c522d297d1..947ecbf73c 100644 --- a/nym-connect/desktop/Cargo.lock +++ b/nym-connect/desktop/Cargo.lock @@ -4181,8 +4181,6 @@ dependencies = [ name = "nym-sphinx-types" version = "0.2.0" dependencies = [ - "nym-outfox", - "sphinx-packet", "thiserror", ] diff --git a/nym-wallet/Cargo.lock b/nym-wallet/Cargo.lock index 2e7df7a43e..b9d551fd84 100644 --- a/nym-wallet/Cargo.lock +++ b/nym-wallet/Cargo.lock @@ -101,6 +101,12 @@ dependencies = [ "password-hash", ] +[[package]] +name = "arrayref" +version = "0.3.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a4c527152e37cf757a3f78aae5a06fbeefdb07ccc535c980a3208ee3060dd544" + [[package]] name = "async-trait" version = "0.1.64" @@ -464,6 +470,16 @@ version = "1.0.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "baf1de4339761588bc0619e3cbc0120ee582ebb74b53b4efbf79117bd2da40fd" +[[package]] +name = "chacha" +version = "0.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ddf3c081b5fba1e5615640aae998e0fbd10c24cbd897ee39ed754a77601a4862" +dependencies = [ + "byteorder", + "keystream", +] + [[package]] name = "cipher" version = "0.4.4" @@ -3120,6 +3136,7 @@ dependencies = [ name = "nym-sphinx-types" version = "0.2.0" dependencies = [ + "sphinx-packet", "thiserror", ] From 5620fd7009e8b4dd54c25ca6fac59ee53c4021da Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bogdan-=C8=98tefan=20Neac=C8=99u?= Date: Mon, 7 Aug 2023 15:52:03 +0300 Subject: [PATCH 16/21] Set sphinx as default packet type --- common/crypto/Cargo.toml | 1 + common/nymsphinx/Cargo.toml | 5 + common/nymsphinx/framing/Cargo.toml | 5 +- common/nymsphinx/params/Cargo.toml | 1 + common/nymsphinx/types/Cargo.toml | 1 + contracts/Cargo.lock | 236 ++++++++++++++++++++++++++-- nym-connect/desktop/Cargo.lock | 2 + 7 files changed, 233 insertions(+), 18 deletions(-) diff --git a/common/crypto/Cargo.toml b/common/crypto/Cargo.toml index 27702da016..992005f2d4 100644 --- a/common/crypto/Cargo.toml +++ b/common/crypto/Cargo.toml @@ -34,6 +34,7 @@ nym-pemstore = { path = "../../common/pemstore", version = "0.3.0" } rand_chacha = "0.2" [features] +default = ["sphinx"] serde = ["serde_crate", "serde_bytes", "ed25519-dalek/serde", "x25519-dalek/serde"] asymmetric = ["x25519-dalek", "ed25519-dalek", "zeroize"] hashing = ["blake3", "digest", "hkdf", "hmac", "generic-array"] diff --git a/common/nymsphinx/Cargo.toml b/common/nymsphinx/Cargo.toml index df93301876..955051b267 100644 --- a/common/nymsphinx/Cargo.toml +++ b/common/nymsphinx/Cargo.toml @@ -40,3 +40,8 @@ path = "framing" [target."cfg(not(target_arch = \"wasm32\"))".dependencies.tokio] version = "1.24.1" features = ["sync"] + +[features] +default = ["sphinx"] +sphinx = ["nym-crypto/sphinx", "nym-sphinx-params/sphinx", "nym-sphinx-types/sphinx"] +outfox = ["nym-crypto/outfox", "nym-sphinx-params/outfox", "nym-sphinx-types/outfox"] diff --git a/common/nymsphinx/framing/Cargo.toml b/common/nymsphinx/framing/Cargo.toml index b510926555..3915f204a2 100644 --- a/common/nymsphinx/framing/Cargo.toml +++ b/common/nymsphinx/framing/Cargo.toml @@ -12,5 +12,6 @@ bytes = "1.0" tokio-util = { version = "0.7.4", features = ["codec"] } thiserror = "1.0.37" -nym-sphinx-types = { path = "../types" } -nym-sphinx-params = { path = "../params" } +nym-sphinx-types = { path = "../types", features = ["sphinx", "outfox"] } +nym-sphinx-params = { path = "../params", features = ["sphinx", "outfox"] } + diff --git a/common/nymsphinx/params/Cargo.toml b/common/nymsphinx/params/Cargo.toml index 57872bb0ca..9d9a5a24e2 100644 --- a/common/nymsphinx/params/Cargo.toml +++ b/common/nymsphinx/params/Cargo.toml @@ -15,5 +15,6 @@ nym-crypto = { path = "../../crypto", features = ["hashing", "symmetric"] } nym-sphinx-types = { path = "../types" } [features] +default = ["sphinx"] sphinx = ["nym-crypto/sphinx", "nym-sphinx-types/outfox"] outfox = ["nym-crypto/outfox", "nym-sphinx-types/outfox"] diff --git a/common/nymsphinx/types/Cargo.toml b/common/nymsphinx/types/Cargo.toml index 0569ef1406..ae348113a0 100644 --- a/common/nymsphinx/types/Cargo.toml +++ b/common/nymsphinx/types/Cargo.toml @@ -13,5 +13,6 @@ nym-outfox = { path = "../../../nym-outfox", optional = true } thiserror = "1" [features] +default = ["sphinx"] sphinx = ["sphinx-packet"] outfox = ["nym-outfox"] diff --git a/contracts/Cargo.lock b/contracts/Cargo.lock index ebeae6d7ea..0f56b6f7a9 100644 --- a/contracts/Cargo.lock +++ b/contracts/Cargo.lock @@ -2,6 +2,19 @@ # It is not intended for manual editing. version = 3 +[[package]] +name = "aes" +version = "0.7.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9e8b47f52ea9bae42228d07ec09eb676433d7c4ed1ebdf0f1d1c29ed446f1ab8" +dependencies = [ + "cfg-if", + "cipher", + "cpufeatures", + "ctr", + "opaque-debug 0.3.0", +] + [[package]] name = "ahash" version = "0.7.6" @@ -19,6 +32,12 @@ version = "1.0.70" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "7de8ce5e0f9f8d88245311066a578d72b7af3e7088f32783804676302df237e4" +[[package]] +name = "arrayref" +version = "0.3.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6b4930d2cb77ce62f89ee5d5289b4ac049559b1c45539271f5ed4fdc7db34545" + [[package]] name = "autocfg" version = "1.1.0" @@ -55,13 +74,25 @@ version = "1.3.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "bef38d45163c2f1dde094a7dfd33ccf595c92905c8f8f4fdc18d06fb1037718a" +[[package]] +name = "blake2" +version = "0.8.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "94cb07b0da6a73955f8fb85d24c466778e70cda767a568229b104f0264089330" +dependencies = [ + "byte-tools", + "crypto-mac 0.7.0", + "digest 0.8.1", + "opaque-debug 0.2.3", +] + [[package]] name = "block-buffer" version = "0.9.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "4152116fd6e9dadb291ae18fc1ec3575ed6d84c29642d97890f4b4a3417297e4" dependencies = [ - "generic-array", + "generic-array 0.14.6", ] [[package]] @@ -70,7 +101,7 @@ version = "0.10.4" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "3078c7629b62d3f0439517fa394996acacc5cbc91c5a20d8c658e77abd503a71" dependencies = [ - "generic-array", + "generic-array 0.14.6", ] [[package]] @@ -91,6 +122,12 @@ version = "3.12.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "9b1ce199063694f33ffb7dd4e0ee620741495c32833cde5aa08f02a0bf96f0c8" +[[package]] +name = "byte-tools" +version = "0.3.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e3b5ca7a04898ad4bcd41c90c5285445ff5b791899bb1b0abdd2a2aa791211d7" + [[package]] name = "byteorder" version = "1.4.3" @@ -118,6 +155,25 @@ version = "1.0.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "baf1de4339761588bc0619e3cbc0120ee582ebb74b53b4efbf79117bd2da40fd" +[[package]] +name = "chacha" +version = "0.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ddf3c081b5fba1e5615640aae998e0fbd10c24cbd897ee39ed754a77601a4862" +dependencies = [ + "byteorder", + "keystream", +] + +[[package]] +name = "cipher" +version = "0.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7ee52072ec15386f770805afd189a01c8841be8696bed250fa2f13c4c0d6dfb7" +dependencies = [ + "generic-array 0.14.6", +] + [[package]] name = "coconut-test" version = "0.1.0" @@ -246,9 +302,9 @@ version = "0.4.9" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "ef2b4b23cddf68b89b8f8069890e8c270d54e2d5fe1b143820234805e4cb17ef" dependencies = [ - "generic-array", + "generic-array 0.14.6", "rand_core 0.6.4", - "subtle", + "subtle 2.4.1", "zeroize", ] @@ -258,10 +314,39 @@ version = "0.1.6" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "1bfb12502f3fc46cca1bb51ac28df9d618d813cdc3d2f25b9fe775a34af26bb3" dependencies = [ - "generic-array", + "generic-array 0.14.6", "typenum", ] +[[package]] +name = "crypto-mac" +version = "0.7.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4434400df11d95d556bac068ddfedd482915eb18fe8bea89bc80b6e4b1c179e5" +dependencies = [ + "generic-array 0.12.4", + "subtle 1.0.0", +] + +[[package]] +name = "crypto-mac" +version = "0.11.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b1d1a86f49236c215f271d40892d5fc950490551400b02ef360692c29815c714" +dependencies = [ + "generic-array 0.14.6", + "subtle 2.4.1", +] + +[[package]] +name = "ctr" +version = "0.8.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "049bb91fb4aaf0e3c7efa6cd5ef877dbbbd15b39dad06d9948de4ec8a75761ea" +dependencies = [ + "cipher", +] + [[package]] name = "curve25519-dalek" version = "3.2.0" @@ -271,7 +356,7 @@ dependencies = [ "byteorder", "digest 0.9.0", "rand_core 0.5.1", - "subtle", + "subtle 2.4.1", "zeroize", ] @@ -483,13 +568,22 @@ dependencies = [ "syn 1.0.109", ] +[[package]] +name = "digest" +version = "0.8.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f3d0c8c8752312f9713efd397ff63acb9f85585afbf179282e720e7704954dd5" +dependencies = [ + "generic-array 0.12.4", +] + [[package]] name = "digest" version = "0.9.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "d3dd60d1080a57a05ab032377049e0591415d2b31afd7028356dbf3cc6dcb066" dependencies = [ - "generic-array", + "generic-array 0.14.6", ] [[package]] @@ -500,7 +594,7 @@ checksum = "9ed9a281f7bc9b7576e61468ba615a66a5c8cfdff42420a70aa82701a3b1e292" dependencies = [ "block-buffer 0.10.4", "crypto-common", - "subtle", + "subtle 2.4.1", ] [[package]] @@ -576,12 +670,12 @@ dependencies = [ "der", "digest 0.10.7", "ff", - "generic-array", + "generic-array 0.14.6", "group", "pkcs8", "rand_core 0.6.4", "sec1", - "subtle", + "subtle 2.4.1", "zeroize", ] @@ -642,7 +736,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "d013fc25338cc558c5c2cfbad646908fb23591e2404481826742b651c9af7160" dependencies = [ "rand_core 0.6.4", - "subtle", + "subtle 2.4.1", ] [[package]] @@ -761,6 +855,15 @@ dependencies = [ "slab", ] +[[package]] +name = "generic-array" +version = "0.12.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ffdf9f34f1447443d37393cc6c2b8313aebddcd96906caf34e54c68d8e57d7bd" +dependencies = [ + "typenum", +] + [[package]] name = "generic-array" version = "0.14.6" @@ -828,7 +931,7 @@ checksum = "5dfbfb3a6cfbd390d5c9564ab283a0349b9b9fcd46a706c1eb10e0db70bfbac7" dependencies = [ "ff", "rand_core 0.6.4", - "subtle", + "subtle 2.4.1", ] [[package]] @@ -852,6 +955,26 @@ version = "0.4.3" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "7f24254aa9a54b5c858eaee2f5bccdb46aaf0e486a595ed5fd8f86ba55232a70" +[[package]] +name = "hkdf" +version = "0.11.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "01706d578d5c281058480e673ae4086a9f4710d8df1ad80a5b03e39ece5f886b" +dependencies = [ + "digest 0.9.0", + "hmac 0.11.0", +] + +[[package]] +name = "hmac" +version = "0.11.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2a2a2320eb7ec0ebe8da8f744d7812d9fc4cb4d09344ac01898dbcb6a20ae69b" +dependencies = [ + "crypto-mac 0.11.1", + "digest 0.9.0", +] + [[package]] name = "hmac" version = "0.12.1" @@ -952,6 +1075,12 @@ dependencies = [ "sha2 0.10.6", ] +[[package]] +name = "keystream" +version = "1.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c33070833c9ee02266356de0c43f723152bd38bd96ddf52c82b3af10c9138b28" + [[package]] name = "lazy_static" version = "1.4.0" @@ -976,6 +1105,12 @@ dependencies = [ "pkg-config", ] +[[package]] +name = "libm" +version = "0.2.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f7012b1bbb0719e1097c47611d3898568c546d597c2e74d66f6087edd5233ff4" + [[package]] name = "libz-sys" version = "1.1.8" @@ -994,6 +1129,18 @@ version = "0.3.7" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "ece97ea872ece730aed82664c424eb4c8291e1ff2480247ccf7409044bc6479f" +[[package]] +name = "lioness" +version = "0.1.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4ae926706ba42c425c9457121178330d75e273df2e82e28b758faf3de3a9acb9" +dependencies = [ + "arrayref", + "blake2", + "chacha", + "keystream", +] + [[package]] name = "log" version = "0.4.17" @@ -1025,6 +1172,16 @@ dependencies = [ "rand_chacha 0.2.2", ] +[[package]] +name = "num-traits" +version = "0.2.16" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f30b0abd723be7e2ffca1272140fac1a2f084c77ec3e123c192b66af1ee9e6c2" +dependencies = [ + "autocfg", + "libm", +] + [[package]] name = "nym-coconut-bandwidth" version = "0.1.0" @@ -1263,6 +1420,7 @@ dependencies = [ name = "nym-sphinx-types" version = "0.2.0" dependencies = [ + "sphinx-packet", "thiserror", ] @@ -1308,6 +1466,12 @@ version = "1.17.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "b7e5500299e16ebb147ae15a00a942af264cf3688f47923b8fc2cd5858f23ad3" +[[package]] +name = "opaque-debug" +version = "0.2.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2839e79665f131bdb5782e51f2c6c9599c133c6098982a54c794358bf432529c" + [[package]] name = "opaque-debug" version = "0.3.0" @@ -1498,6 +1662,16 @@ dependencies = [ "getrandom 0.2.10", ] +[[package]] +name = "rand_distr" +version = "0.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c9e9532ada3929fb8b2e9dbe28d1e06c9b2cc65813f074fcb6bd5fbefeff9d56" +dependencies = [ + "num-traits", + "rand 0.7.3", +] + [[package]] name = "rand_hc" version = "0.2.0" @@ -1538,7 +1712,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "7743f17af12fa0b03b803ba12cd6a8d9483a587e89c69445e3909655c0b9fabb" dependencies = [ "crypto-bigint", - "hmac", + "hmac 0.12.1", "zeroize", ] @@ -1647,9 +1821,9 @@ checksum = "3be24c1842290c45df0a7bf069e0c268a747ad05a192f2fd7dcfdbc1cba40928" dependencies = [ "base16ct", "der", - "generic-array", + "generic-array 0.14.6", "pkcs8", - "subtle", + "subtle 2.4.1", "zeroize", ] @@ -1731,7 +1905,7 @@ dependencies = [ "cfg-if", "cpufeatures", "digest 0.9.0", - "opaque-debug", + "opaque-debug 0.3.0", ] [[package]] @@ -1764,6 +1938,30 @@ dependencies = [ "autocfg", ] +[[package]] +name = "sphinx-packet" +version = "0.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "cc43eda802856ee82a7555c7b75ceb9e07451741c7a2f5f23d036020e01189d4" +dependencies = [ + "aes", + "arrayref", + "blake2", + "bs58", + "byteorder", + "chacha", + "curve25519-dalek", + "digest 0.9.0", + "hkdf", + "hmac 0.11.0", + "lioness", + "log", + "rand 0.7.3", + "rand_distr", + "sha2 0.9.9", + "subtle 2.4.1", +] + [[package]] name = "spki" version = "0.6.0" @@ -1774,6 +1972,12 @@ dependencies = [ "der", ] +[[package]] +name = "subtle" +version = "1.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2d67a5a62ba6e01cb2192ff309324cb4875d0c451d55fe2319433abe7a05a8ee" + [[package]] name = "subtle" version = "2.4.1" diff --git a/nym-connect/desktop/Cargo.lock b/nym-connect/desktop/Cargo.lock index 947ecbf73c..c522d297d1 100644 --- a/nym-connect/desktop/Cargo.lock +++ b/nym-connect/desktop/Cargo.lock @@ -4181,6 +4181,8 @@ dependencies = [ name = "nym-sphinx-types" version = "0.2.0" dependencies = [ + "nym-outfox", + "sphinx-packet", "thiserror", ] From 8fda246a3c94aecc46aeb51ff32c0a06f06b2143 Mon Sep 17 00:00:00 2001 From: benedettadavico Date: Tue, 8 Aug 2023 11:15:30 +0200 Subject: [PATCH 17/21] Update changelog and versions for release v1.1.26 --- CHANGELOG.md | 22 +++++++++++++++++++ Cargo.lock | 18 +++++++-------- clients/native/Cargo.toml | 2 +- clients/socks5/Cargo.toml | 2 +- explorer-api/Cargo.toml | 2 +- gateway/Cargo.toml | 2 +- mixnode/Cargo.toml | 2 +- nym-api/Cargo.toml | 2 +- nym-connect/desktop/CHANGELOG.md | 6 +++++ nym-connect/desktop/package.json | 2 +- nym-connect/desktop/src-tauri/Cargo.toml | 2 +- nym-connect/desktop/src-tauri/tauri.conf.json | 2 +- .../network-requester/Cargo.toml | 2 +- .../network-statistics/Cargo.toml | 2 +- tools/nym-cli/Cargo.toml | 2 +- 15 files changed, 49 insertions(+), 21 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index f938c81fe3..1ec4a60145 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -4,6 +4,28 @@ Post 1.0.0 release, the changelog format is based on [Keep a Changelog](https:// ## [Unreleased] +## [v1.1.24] (2023-08-08) + +- Latency based gateway selection is serial and slow ([#3710]) +- Network-requester: strip comments from allow lists ([#3625]) +- Remove (or start maintaining) `upgrade` commands from all binaries ([#3600]) +- Set sphinx as default packet type ([#3748]) +- Apply fix from feature/ephemera to develop too (#3698) ([#3742]) +- Feature/coco demos ([#3732]) +- Add updates to community list projects ([#3722]) +- Add geo-aware mixnet topology provider ([#3713]) +- Add updates to community list projects ([#3711]) + +[#3710]: https://github.com/nymtech/nym/issues/3710 +[#3625]: https://github.com/nymtech/nym/issues/3625 +[#3600]: https://github.com/nymtech/nym/issues/3600 +[#3748]: https://github.com/nymtech/nym/pull/3748 +[#3742]: https://github.com/nymtech/nym/pull/3742 +[#3732]: https://github.com/nymtech/nym/pull/3732 +[#3722]: https://github.com/nymtech/nym/pull/3722 +[#3713]: https://github.com/nymtech/nym/pull/3713 +[#3711]: https://github.com/nymtech/nym/pull/3711 + ## [v1.1.23] (2023-07-04) - nym-cli: add client identity key signing support ([#3576]) diff --git a/Cargo.lock b/Cargo.lock index 1dcf4528bf..85ff104b27 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -1896,7 +1896,7 @@ checksum = "0206175f82b8d6bf6652ff7d71a1e27fd2e4efde587fd368662814d6ec1d9ce0" [[package]] name = "explorer-api" -version = "1.1.23" +version = "1.1.24" dependencies = [ "chrono", "clap 4.2.7", @@ -3530,7 +3530,7 @@ dependencies = [ [[package]] name = "nym-api" -version = "1.1.24" +version = "1.1.25" dependencies = [ "anyhow", "async-trait", @@ -3667,7 +3667,7 @@ dependencies = [ [[package]] name = "nym-cli" -version = "1.1.23" +version = "1.1.24" dependencies = [ "anyhow", "base64 0.13.1", @@ -3733,7 +3733,7 @@ dependencies = [ [[package]] name = "nym-client" -version = "1.1.23" +version = "1.1.24" dependencies = [ "clap 4.2.7", "dirs 4.0.0", @@ -4021,7 +4021,7 @@ dependencies = [ [[package]] name = "nym-gateway" -version = "1.1.23" +version = "1.1.24" dependencies = [ "anyhow", "async-trait", @@ -4176,7 +4176,7 @@ dependencies = [ [[package]] name = "nym-mixnode" -version = "1.1.24" +version = "1.1.25" dependencies = [ "anyhow", "bs58 0.4.0", @@ -4293,7 +4293,7 @@ dependencies = [ [[package]] name = "nym-network-requester" -version = "1.1.23" +version = "1.1.24" dependencies = [ "anyhow", "async-file-watcher", @@ -4340,7 +4340,7 @@ dependencies = [ [[package]] name = "nym-network-statistics" -version = "1.1.23" +version = "1.1.24" dependencies = [ "dirs 4.0.0", "log", @@ -4497,7 +4497,7 @@ dependencies = [ [[package]] name = "nym-socks5-client" -version = "1.1.23" +version = "1.1.24" dependencies = [ "clap 4.2.7", "lazy_static", diff --git a/clients/native/Cargo.toml b/clients/native/Cargo.toml index 6064304a90..2135883752 100644 --- a/clients/native/Cargo.toml +++ b/clients/native/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "nym-client" -version = "1.1.23" +version = "1.1.24" authors = ["Dave Hrycyszyn ", "Jędrzej Stuczyński "] description = "Implementation of the Nym Client" edition = "2021" diff --git a/clients/socks5/Cargo.toml b/clients/socks5/Cargo.toml index 658d52a047..afbf36178f 100644 --- a/clients/socks5/Cargo.toml +++ b/clients/socks5/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "nym-socks5-client" -version = "1.1.23" +version = "1.1.24" authors = ["Dave Hrycyszyn "] description = "A SOCKS5 localhost proxy that converts incoming messages to Sphinx and sends them to a Nym address" edition = "2021" diff --git a/explorer-api/Cargo.toml b/explorer-api/Cargo.toml index d6941a19e1..04e7255d01 100644 --- a/explorer-api/Cargo.toml +++ b/explorer-api/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "explorer-api" -version = "1.1.23" +version = "1.1.24" edition = "2021" # See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html diff --git a/gateway/Cargo.toml b/gateway/Cargo.toml index 763b3ab676..007fcca40d 100644 --- a/gateway/Cargo.toml +++ b/gateway/Cargo.toml @@ -3,7 +3,7 @@ [package] name = "nym-gateway" -version = "1.1.23" +version = "1.1.24" authors = [ "Dave Hrycyszyn ", "Jędrzej Stuczyński ", diff --git a/mixnode/Cargo.toml b/mixnode/Cargo.toml index 9f512f0d85..8421bebb3a 100644 --- a/mixnode/Cargo.toml +++ b/mixnode/Cargo.toml @@ -3,7 +3,7 @@ [package] name = "nym-mixnode" -version = "1.1.24" +version = "1.1.25" authors = [ "Dave Hrycyszyn ", "Jędrzej Stuczyński ", diff --git a/nym-api/Cargo.toml b/nym-api/Cargo.toml index f9b378f59d..50568b440a 100644 --- a/nym-api/Cargo.toml +++ b/nym-api/Cargo.toml @@ -3,7 +3,7 @@ [package] name = "nym-api" -version = "1.1.24" +version = "1.1.25" authors = [ "Dave Hrycyszyn ", "Jędrzej Stuczyński ", diff --git a/nym-connect/desktop/CHANGELOG.md b/nym-connect/desktop/CHANGELOG.md index 1149c3b227..8a0b86151a 100644 --- a/nym-connect/desktop/CHANGELOG.md +++ b/nym-connect/desktop/CHANGELOG.md @@ -2,6 +2,12 @@ ## [Unreleased] +## [v1.1.16] (2023-08-08) + +- Uncouple network-requester <-> gateway in nym-connect and harbourmaster ([#3472]) + +[#3472]: https://github.com/nymtech/nym/issues/3472 + ## [v1.1.15] (2023-07-25) - NC Desktop - remove sentry DSN from code ([#3694]) diff --git a/nym-connect/desktop/package.json b/nym-connect/desktop/package.json index 626b415b8f..96d9e83438 100644 --- a/nym-connect/desktop/package.json +++ b/nym-connect/desktop/package.json @@ -1,6 +1,6 @@ { "name": "@nym/nym-connect", - "version": "1.1.15", + "version": "1.1.16", "main": "index.js", "license": "MIT", "scripts": { diff --git a/nym-connect/desktop/src-tauri/Cargo.toml b/nym-connect/desktop/src-tauri/Cargo.toml index e3bd49cb41..0d1089132d 100644 --- a/nym-connect/desktop/src-tauri/Cargo.toml +++ b/nym-connect/desktop/src-tauri/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "nym-connect" -version = "1.1.15" +version = "1.1.16" description = "nym-connect" authors = ["Nym Technologies SA"] license = "" diff --git a/nym-connect/desktop/src-tauri/tauri.conf.json b/nym-connect/desktop/src-tauri/tauri.conf.json index b95859ca53..5f5e86bec0 100644 --- a/nym-connect/desktop/src-tauri/tauri.conf.json +++ b/nym-connect/desktop/src-tauri/tauri.conf.json @@ -1,7 +1,7 @@ { "package": { "productName": "nym-connect", - "version": "1.1.15" + "version": "1.1.16" }, "build": { "distDir": "../dist", diff --git a/service-providers/network-requester/Cargo.toml b/service-providers/network-requester/Cargo.toml index 5b80088b30..d1d7367d85 100644 --- a/service-providers/network-requester/Cargo.toml +++ b/service-providers/network-requester/Cargo.toml @@ -3,7 +3,7 @@ [package] name = "nym-network-requester" -version = "1.1.23" +version = "1.1.24" authors.workspace = true edition.workspace = true rust-version = "1.65" diff --git a/service-providers/network-statistics/Cargo.toml b/service-providers/network-statistics/Cargo.toml index cc7024c545..7c0138ca8f 100644 --- a/service-providers/network-statistics/Cargo.toml +++ b/service-providers/network-statistics/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "nym-network-statistics" -version = "1.1.23" +version = "1.1.24" edition = "2021" # See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html diff --git a/tools/nym-cli/Cargo.toml b/tools/nym-cli/Cargo.toml index ea5cad9e65..9f3c0d6a2a 100644 --- a/tools/nym-cli/Cargo.toml +++ b/tools/nym-cli/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "nym-cli" -version = "1.1.23" +version = "1.1.24" authors.workspace = true edition = "2021" From a26c6d7a29c6f6935fac0dc4e894358ed6253726 Mon Sep 17 00:00:00 2001 From: benedettadavico Date: Tue, 8 Aug 2023 11:24:08 +0200 Subject: [PATCH 18/21] Temporary update to fix windows build --- package.json | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/package.json b/package.json index 523db5363f..cad6eaf88d 100644 --- a/package.json +++ b/package.json @@ -8,7 +8,6 @@ "ts-packages/*", "nym-wallet", "nym-connect/**", - "nym-browser-extension", "explorer", "types", "clients/validator" @@ -29,9 +28,8 @@ "tsc": "lerna run tsc --stream", "types:lint:fix": "lerna run lint:fix --scope @nymproject/types --scope @nymproject/nym-wallet-app", "audit:fix": "npm_config_yes=true npx yarn-audit-fix -- --dry-run", - "preinstall": "yarn install:copy-placeholders && yarn install:copy-storage-placeholders", - "install:copy-placeholders": "cp scripts/build/yarn/wasm-placeholder/package.json sdk/typescript/packages/nym-client-wasm", - "install:copy-storage-placeholders": "mkdir -p nym-browser-extension/storage/pkg && cp scripts/build/yarn/storage-placeholder/package.json nym-browser-extension/storage/pkg" + "preinstall": "yarn install:copy-placeholders", + "install:copy-placeholders": "cp scripts/build/yarn/wasm-placeholder/package.json sdk/typescript/packages/nym-client-wasm" }, "devDependencies": { "lerna": "^6.6.2", From 62316244d9222ea695387426bf5ed926c0b7dc5f Mon Sep 17 00:00:00 2001 From: benedettadavico Date: Tue, 8 Aug 2023 14:17:55 +0200 Subject: [PATCH 19/21] Revert package.json changes needed temporary build --- package.json | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/package.json b/package.json index cad6eaf88d..523db5363f 100644 --- a/package.json +++ b/package.json @@ -8,6 +8,7 @@ "ts-packages/*", "nym-wallet", "nym-connect/**", + "nym-browser-extension", "explorer", "types", "clients/validator" @@ -28,8 +29,9 @@ "tsc": "lerna run tsc --stream", "types:lint:fix": "lerna run lint:fix --scope @nymproject/types --scope @nymproject/nym-wallet-app", "audit:fix": "npm_config_yes=true npx yarn-audit-fix -- --dry-run", - "preinstall": "yarn install:copy-placeholders", - "install:copy-placeholders": "cp scripts/build/yarn/wasm-placeholder/package.json sdk/typescript/packages/nym-client-wasm" + "preinstall": "yarn install:copy-placeholders && yarn install:copy-storage-placeholders", + "install:copy-placeholders": "cp scripts/build/yarn/wasm-placeholder/package.json sdk/typescript/packages/nym-client-wasm", + "install:copy-storage-placeholders": "mkdir -p nym-browser-extension/storage/pkg && cp scripts/build/yarn/storage-placeholder/package.json nym-browser-extension/storage/pkg" }, "devDependencies": { "lerna": "^6.6.2", From 191aa149df2c698427a3bbdcf1d4387f9bc74731 Mon Sep 17 00:00:00 2001 From: benedetta davico <46782255+benedettadavico@users.noreply.github.com> Date: Tue, 8 Aug 2023 15:37:16 +0200 Subject: [PATCH 20/21] Update Cargo.toml --- Cargo.toml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Cargo.toml b/Cargo.toml index 198f37890e..2e9a393993 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -146,11 +146,11 @@ reqwest = "0.11.18" serde = "1.0.152" serde_json = "1.0.91" tap = "1.0.1" -tendermint-rpc = "=0.32" # same version as used by cosmrs +tendermint-rpc = "0.32" # same version as used by cosmrs thiserror = "1.0.38" tokio = "1.24.1" url = "2.2" zeroize = "1.6.0" # wasm-related dependencies -wasmtimer = "0.2.0" \ No newline at end of file +wasmtimer = "0.2.0" From d8a95d3810ddea730ad5b3e1e1ffe6fb9e80ee3d Mon Sep 17 00:00:00 2001 From: benedetta davico <46782255+benedettadavico@users.noreply.github.com> Date: Tue, 8 Aug 2023 15:42:05 +0200 Subject: [PATCH 21/21] Update Cargo.toml --- Cargo.toml | 1 - 1 file changed, 1 deletion(-) diff --git a/Cargo.toml b/Cargo.toml index 2e9a393993..9d609443f0 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -127,7 +127,6 @@ serde-json-wasm = "=0.5.0" cosmwasm-storage = "=1.3.0" cosmrs = "=0.14.0" # same version as used by cosmrs -tendermint-rpc = "=0.32" cw-utils = "=1.0.1" cw-storage-plus = "=1.1.0" cw2 = { version = "=1.1.0" }