From 587161f6588d8ee4e2e4dda02382cb974145678a Mon Sep 17 00:00:00 2001 From: Simon Wicky Date: Tue, 7 May 2024 13:21:52 +0200 Subject: [PATCH] allow offline verification flag --- gateway/src/commands/helpers.rs | 5 +++++ gateway/src/commands/run.rs | 5 +++++ gateway/src/config/mod.rs | 13 +++++++++++++ gateway/src/config/old_config_v1_1_31.rs | 3 +++ gateway/src/config/template.rs | 3 +++ nym-node/src/cli/commands/migrate.rs | 1 + nym-node/src/config/entry_gateway.rs | 4 ++++ nym-node/src/config/helpers.rs | 1 + 8 files changed, 35 insertions(+) diff --git a/gateway/src/commands/helpers.rs b/gateway/src/commands/helpers.rs index ff487dc7c2..8cd8e760b6 100644 --- a/gateway/src/commands/helpers.rs +++ b/gateway/src/commands/helpers.rs @@ -45,6 +45,7 @@ pub(crate) struct OverrideConfig { pub(crate) mnemonic: Option, pub(crate) nyxd_urls: Option>, pub(crate) only_coconut_credentials: Option, + pub(crate) offline_credential_verification: Option, pub(crate) with_network_requester: Option, pub(crate) with_ip_packet_router: Option, } @@ -81,6 +82,10 @@ impl OverrideConfig { Config::with_only_coconut_credentials, self.only_coconut_credentials, ) + .with_optional( + Config::with_offline_credential_verification, + self.offline_credential_verification, + ) .with_optional( Config::with_enabled_network_requester, self.with_network_requester, diff --git a/gateway/src/commands/run.rs b/gateway/src/commands/run.rs index 547045ebb7..596b8fd3ae 100644 --- a/gateway/src/commands/run.rs +++ b/gateway/src/commands/run.rs @@ -73,6 +73,10 @@ pub struct Run { #[arg(long, hide = true)] only_coconut_credentials: Option, + /// Set this gateway to use offline credentials verification + #[clap(long, hide = true)] + offline_credential_verification: Option, + /// Enable/disable gateway anonymized statistics that get sent to a statistics aggregator server #[arg(long)] enabled_statistics: Option, @@ -151,6 +155,7 @@ impl From for OverrideConfig { statistics_service_url: run_config.statistics_service_url, nyxd_urls: run_config.nyxd_urls, only_coconut_credentials: run_config.only_coconut_credentials, + offline_credential_verification: run_config.offline_credential_verification, with_network_requester: run_config.with_network_requester, with_ip_packet_router: run_config.with_ip_packet_router, } diff --git a/gateway/src/config/mod.rs b/gateway/src/config/mod.rs index 7932d2456f..b539ceebaa 100644 --- a/gateway/src/config/mod.rs +++ b/gateway/src/config/mod.rs @@ -232,6 +232,14 @@ impl Config { self } + pub fn with_offline_credential_verification( + mut self, + offline_credential_verification: bool, + ) -> Self { + self.gateway.offline_credential_verification = offline_credential_verification; + self + } + pub fn with_enabled_statistics(mut self, enabled_statistics: bool) -> Self { self.gateway.enabled_statistics = enabled_statistics; self @@ -395,6 +403,10 @@ pub struct Gateway { #[serde(default)] pub only_coconut_credentials: bool, + /// Indicates whether this gateway is using offline mode for credential verification + #[serde(default)] + pub offline_credential_verification: bool, + /// Address to which this mixnode will bind to and will be listening for packets. #[zeroize(skip)] pub listening_address: IpAddr, @@ -443,6 +455,7 @@ impl Gateway { version: env!("CARGO_PKG_VERSION").to_string(), id: id.into(), only_coconut_credentials: false, + offline_credential_verification: false, listening_address: inaddr_any(), mix_port: DEFAULT_MIX_LISTENING_PORT, clients_port: DEFAULT_CLIENT_LISTENING_PORT, diff --git a/gateway/src/config/old_config_v1_1_31.rs b/gateway/src/config/old_config_v1_1_31.rs index 0d57cfe777..aa6ec22aa0 100644 --- a/gateway/src/config/old_config_v1_1_31.rs +++ b/gateway/src/config/old_config_v1_1_31.rs @@ -115,6 +115,9 @@ impl From for Config { version: value.gateway.version, id: value.gateway.id, only_coconut_credentials: value.gateway.only_coconut_credentials, + // \/ ADDED + offline_credential_verification: false, + // /\ ADDED listening_address: value.gateway.listening_address, mix_port: value.gateway.mix_port, clients_port: value.gateway.clients_port, diff --git a/gateway/src/config/template.rs b/gateway/src/config/template.rs index 1b6ac71262..d396986fd5 100644 --- a/gateway/src/config/template.rs +++ b/gateway/src/config/template.rs @@ -33,6 +33,9 @@ id = '{{ gateway.id }}' # the mixnet, or if it also accepts non-paying clients only_coconut_credentials = {{ gateway.only_coconut_credentials }} +# Indicates whether this gateway is using offline mode for credential verification +offline_credential_verification = {{ gateway.offline_credential_verification }} + # Socket address to which this gateway will bind to and will be listening for packets. listening_address = '{{ gateway.listening_address }}' diff --git a/nym-node/src/cli/commands/migrate.rs b/nym-node/src/cli/commands/migrate.rs index b4ca40e429..4cad2f689c 100644 --- a/nym-node/src/cli/commands/migrate.rs +++ b/nym-node/src/cli/commands/migrate.rs @@ -413,6 +413,7 @@ async fn migrate_gateway(mut args: Args) -> Result<(), NymNodeError> { config::EntryGatewayConfig { storage_paths: config::persistence::EntryGatewayPaths::new(&data_dir), enforce_zk_nyms: cfg.gateway.only_coconut_credentials, + offline_zk_nyms: cfg.gateway.offline_credential_verification, bind_address: SocketAddr::new(ip, cfg.gateway.clients_port), announce_ws_port: None, announce_wss_port: cfg.gateway.clients_wss_port, diff --git a/nym-node/src/config/entry_gateway.rs b/nym-node/src/config/entry_gateway.rs index e0db9aca64..be44919e0f 100644 --- a/nym-node/src/config/entry_gateway.rs +++ b/nym-node/src/config/entry_gateway.rs @@ -23,6 +23,9 @@ pub struct EntryGatewayConfig { /// or if it also accepts non-paying clients pub enforce_zk_nyms: bool, + /// Indicates whether this gateway uses offline zk-nyms verification + pub offline_zk_nyms: bool, + /// Socket address this node will use for binding its client websocket API. /// default: `0.0.0.0:9000` pub bind_address: SocketAddr, @@ -66,6 +69,7 @@ impl EntryGatewayConfig { EntryGatewayConfig { storage_paths: EntryGatewayPaths::new(data_dir), enforce_zk_nyms: false, + offline_zk_nyms: false, bind_address: SocketAddr::new(inaddr_any(), DEFAULT_WS_PORT), announce_ws_port: None, announce_wss_port: None, diff --git a/nym-node/src/config/helpers.rs b/nym-node/src/config/helpers.rs index 7ca4dcac97..df8dede393 100644 --- a/nym-node/src/config/helpers.rs +++ b/nym-node/src/config/helpers.rs @@ -44,6 +44,7 @@ pub fn ephemeral_gateway_config( version: format!("{}-nym-node", crate_version!()), id: config.id, only_coconut_credentials: config.entry_gateway.enforce_zk_nyms, + offline_credential_verification: config.entry_gateway.offline_zk_nyms, listening_address: clients_bind_ip, mix_port: config.mixnet.bind_address.port(), clients_port: config.entry_gateway.bind_address.port(),