diff --git a/common/authenticator-requests/src/v1/registration.rs b/common/authenticator-requests/src/v1/registration.rs index 6aef222026..da44cf97bf 100644 --- a/common/authenticator-requests/src/v1/registration.rs +++ b/common/authenticator-requests/src/v1/registration.rs @@ -13,7 +13,7 @@ use std::{fmt, ops::Deref, str::FromStr}; #[cfg(feature = "verify")] use hmac::{Hmac, Mac}; #[cfg(feature = "verify")] -use nym_crypto::asymmetric::encryption::{PrivateKey, PublicKey}; +use nym_crypto::asymmetric::x25519::{PrivateKey, PublicKey}; #[cfg(feature = "verify")] use sha2::Sha256; @@ -190,15 +190,15 @@ impl<'de> Deserialize<'de> for ClientMac { #[cfg(test)] mod tests { use super::*; - use nym_crypto::asymmetric::encryption; + use nym_crypto::asymmetric::x25519; #[test] #[cfg(feature = "verify")] fn client_request_roundtrip() { let mut rng = rand::thread_rng(); - let gateway_key_pair = encryption::KeyPair::new(&mut rng); - let client_key_pair = encryption::KeyPair::new(&mut rng); + let gateway_key_pair = x25519::KeyPair::new(&mut rng); + let client_key_pair = x25519::KeyPair::new(&mut rng); let nonce = 1234567890; diff --git a/common/authenticator-requests/src/v2/registration.rs b/common/authenticator-requests/src/v2/registration.rs index 4d387e8b5c..cdc9d2180c 100644 --- a/common/authenticator-requests/src/v2/registration.rs +++ b/common/authenticator-requests/src/v2/registration.rs @@ -14,7 +14,7 @@ use std::{fmt, ops::Deref, str::FromStr}; #[cfg(feature = "verify")] use hmac::{Hmac, Mac}; #[cfg(feature = "verify")] -use nym_crypto::asymmetric::encryption::{PrivateKey, PublicKey}; +use nym_crypto::asymmetric::x25519::{PrivateKey, PublicKey}; #[cfg(feature = "verify")] use sha2::Sha256; @@ -199,15 +199,15 @@ impl<'de> Deserialize<'de> for ClientMac { #[cfg(test)] mod tests { use super::*; - use nym_crypto::asymmetric::encryption; + use nym_crypto::asymmetric::x25519; #[test] #[cfg(feature = "verify")] fn client_request_roundtrip() { let mut rng = rand::thread_rng(); - let gateway_key_pair = encryption::KeyPair::new(&mut rng); - let client_key_pair = encryption::KeyPair::new(&mut rng); + let gateway_key_pair = x25519::KeyPair::new(&mut rng); + let client_key_pair = x25519::KeyPair::new(&mut rng); let nonce = 1234567890; diff --git a/common/authenticator-requests/src/v3/conversion.rs b/common/authenticator-requests/src/v3/conversion.rs index 1a55576a0d..5a49c771cd 100644 --- a/common/authenticator-requests/src/v3/conversion.rs +++ b/common/authenticator-requests/src/v3/conversion.rs @@ -340,7 +340,7 @@ mod tests { use std::{net::IpAddr, str::FromStr}; use nym_credentials_interface::CredentialSpendingData; - use nym_crypto::asymmetric::encryption::PrivateKey; + use nym_crypto::asymmetric::x25519::PrivateKey; use nym_sphinx::addressing::Recipient; use nym_wireguard_types::PeerPublicKey; use x25519_dalek::PublicKey; diff --git a/common/authenticator-requests/src/v3/registration.rs b/common/authenticator-requests/src/v3/registration.rs index dd6467e7c3..8d51a970f1 100644 --- a/common/authenticator-requests/src/v3/registration.rs +++ b/common/authenticator-requests/src/v3/registration.rs @@ -14,7 +14,7 @@ use std::{fmt, ops::Deref, str::FromStr}; #[cfg(feature = "verify")] use hmac::{Hmac, Mac}; #[cfg(feature = "verify")] -use nym_crypto::asymmetric::encryption::{PrivateKey, PublicKey}; +use nym_crypto::asymmetric::x25519::{PrivateKey, PublicKey}; #[cfg(feature = "verify")] use sha2::Sha256; @@ -199,15 +199,15 @@ impl<'de> Deserialize<'de> for ClientMac { #[cfg(test)] mod tests { use super::*; - use nym_crypto::asymmetric::encryption; + use nym_crypto::asymmetric::x25519; #[test] #[cfg(feature = "verify")] fn client_request_roundtrip() { let mut rng = rand::thread_rng(); - let gateway_key_pair = encryption::KeyPair::new(&mut rng); - let client_key_pair = encryption::KeyPair::new(&mut rng); + let gateway_key_pair = x25519::KeyPair::new(&mut rng); + let client_key_pair = x25519::KeyPair::new(&mut rng); let nonce = 1234567890; diff --git a/common/authenticator-requests/src/v4/conversion.rs b/common/authenticator-requests/src/v4/conversion.rs index 86a1c8791b..8731222446 100644 --- a/common/authenticator-requests/src/v4/conversion.rs +++ b/common/authenticator-requests/src/v4/conversion.rs @@ -306,7 +306,7 @@ mod tests { }; use nym_credentials_interface::CredentialSpendingData; - use nym_crypto::asymmetric::encryption::PrivateKey; + use nym_crypto::asymmetric::x25519::PrivateKey; use nym_sphinx::addressing::Recipient; use nym_wireguard_types::PeerPublicKey; use x25519_dalek::PublicKey; diff --git a/common/authenticator-requests/src/v4/registration.rs b/common/authenticator-requests/src/v4/registration.rs index e370565a55..09359a1a68 100644 --- a/common/authenticator-requests/src/v4/registration.rs +++ b/common/authenticator-requests/src/v4/registration.rs @@ -15,7 +15,7 @@ use std::{fmt, ops::Deref, str::FromStr}; #[cfg(feature = "verify")] use hmac::{Hmac, Mac}; #[cfg(feature = "verify")] -use nym_crypto::asymmetric::encryption::{PrivateKey, PublicKey}; +use nym_crypto::asymmetric::x25519::{PrivateKey, PublicKey}; #[cfg(feature = "verify")] use sha2::Sha256; @@ -251,7 +251,7 @@ impl<'de> Deserialize<'de> for ClientMac { #[cfg(test)] mod tests { use super::*; - use nym_crypto::asymmetric::encryption; + use nym_crypto::asymmetric::x25519; #[test] fn create_ip_pair() { @@ -266,8 +266,8 @@ mod tests { fn client_request_roundtrip() { let mut rng = rand::thread_rng(); - let gateway_key_pair = encryption::KeyPair::new(&mut rng); - let client_key_pair = encryption::KeyPair::new(&mut rng); + let gateway_key_pair = x25519::KeyPair::new(&mut rng); + let client_key_pair = x25519::KeyPair::new(&mut rng); let nonce = 1234567890; diff --git a/common/authenticator-requests/src/v5/conversion.rs b/common/authenticator-requests/src/v5/conversion.rs index e3f7da0830..77ed294323 100644 --- a/common/authenticator-requests/src/v5/conversion.rs +++ b/common/authenticator-requests/src/v5/conversion.rs @@ -230,7 +230,7 @@ mod tests { }; use nym_credentials_interface::CredentialSpendingData; - use nym_crypto::asymmetric::encryption::PrivateKey; + use nym_crypto::asymmetric::x25519::PrivateKey; use nym_sphinx::addressing::Recipient; use nym_wireguard_types::PeerPublicKey; use x25519_dalek::PublicKey; diff --git a/common/authenticator-requests/src/v5/registration.rs b/common/authenticator-requests/src/v5/registration.rs index e370565a55..09359a1a68 100644 --- a/common/authenticator-requests/src/v5/registration.rs +++ b/common/authenticator-requests/src/v5/registration.rs @@ -15,7 +15,7 @@ use std::{fmt, ops::Deref, str::FromStr}; #[cfg(feature = "verify")] use hmac::{Hmac, Mac}; #[cfg(feature = "verify")] -use nym_crypto::asymmetric::encryption::{PrivateKey, PublicKey}; +use nym_crypto::asymmetric::x25519::{PrivateKey, PublicKey}; #[cfg(feature = "verify")] use sha2::Sha256; @@ -251,7 +251,7 @@ impl<'de> Deserialize<'de> for ClientMac { #[cfg(test)] mod tests { use super::*; - use nym_crypto::asymmetric::encryption; + use nym_crypto::asymmetric::x25519; #[test] fn create_ip_pair() { @@ -266,8 +266,8 @@ mod tests { fn client_request_roundtrip() { let mut rng = rand::thread_rng(); - let gateway_key_pair = encryption::KeyPair::new(&mut rng); - let client_key_pair = encryption::KeyPair::new(&mut rng); + let gateway_key_pair = x25519::KeyPair::new(&mut rng); + let client_key_pair = x25519::KeyPair::new(&mut rng); let nonce = 1234567890; diff --git a/common/bandwidth-controller/src/acquire/mod.rs b/common/bandwidth-controller/src/acquire/mod.rs index 450c9e338e..b6c3aae8cb 100644 --- a/common/bandwidth-controller/src/acquire/mod.rs +++ b/common/bandwidth-controller/src/acquire/mod.rs @@ -11,7 +11,7 @@ use nym_credentials::ecash::bandwidth::IssuanceTicketBook; use nym_credentials::ecash::utils::obtain_aggregate_wallet; use nym_credentials::IssuedTicketBook; use nym_credentials_interface::TicketType; -use nym_crypto::asymmetric::identity; +use nym_crypto::asymmetric::ed25519; use nym_ecash_time::{ecash_default_expiration_date, Date}; use nym_validator_client::coconut::all_ecash_api_clients; use nym_validator_client::nym_api::EpochId; @@ -31,7 +31,7 @@ where C: EcashSigningClient + EcashQueryClient + Sync, { let mut rng = OsRng; - let signing_key = identity::PrivateKey::new(&mut rng); + let signing_key = ed25519::PrivateKey::new(&mut rng); let expiration = expiration.unwrap_or_else(ecash_default_expiration_date); let deposit_amount = client.get_required_deposit_amount().await?; diff --git a/common/bandwidth-controller/src/error.rs b/common/bandwidth-controller/src/error.rs index 01619b53ed..4fcff3731a 100644 --- a/common/bandwidth-controller/src/error.rs +++ b/common/bandwidth-controller/src/error.rs @@ -4,8 +4,8 @@ use nym_credential_storage::error::StorageError; use nym_credentials::error::Error as CredentialsError; use nym_credentials_interface::CompactEcashError; -use nym_crypto::asymmetric::encryption::KeyRecoveryError; -use nym_crypto::asymmetric::identity::Ed25519RecoveryError; +use nym_crypto::asymmetric::ed25519::Ed25519RecoveryError; +use nym_crypto::asymmetric::x25519::KeyRecoveryError; use nym_validator_client::coconut::EcashApiError; use nym_validator_client::error::ValidatorClientError; use thiserror::Error; diff --git a/common/client-core/gateways-storage/src/error.rs b/common/client-core/gateways-storage/src/error.rs index 82afc5334b..2c251f513d 100644 --- a/common/client-core/gateways-storage/src/error.rs +++ b/common/client-core/gateways-storage/src/error.rs @@ -1,7 +1,7 @@ // Copyright 2024 - Nym Technologies SA // SPDX-License-Identifier: Apache-2.0 -use nym_crypto::asymmetric::identity::Ed25519RecoveryError; +use nym_crypto::asymmetric::ed25519::Ed25519RecoveryError; use nym_gateway_requests::shared_key::SharedKeyConversionError; use thiserror::Error; diff --git a/common/client-core/gateways-storage/src/lib.rs b/common/client-core/gateways-storage/src/lib.rs index 1351059afd..fd3f1af1e3 100644 --- a/common/client-core/gateways-storage/src/lib.rs +++ b/common/client-core/gateways-storage/src/lib.rs @@ -5,7 +5,7 @@ #![warn(clippy::unwrap_used)] use async_trait::async_trait; -use nym_crypto::asymmetric::identity; +use nym_crypto::asymmetric::ed25519; use nym_gateway_requests::SharedSymmetricKey; use std::error::Error; @@ -36,9 +36,7 @@ pub trait GatewaysDetailsStore { async fn all_gateways(&self) -> Result, Self::StorageError>; /// Return identity keys of all registered gateways. - async fn all_gateways_identities( - &self, - ) -> Result, Self::StorageError> { + async fn all_gateways_identities(&self) -> Result, Self::StorageError> { Ok(self .all_gateways() .await? @@ -64,7 +62,7 @@ pub trait GatewaysDetailsStore { async fn upgrade_stored_remote_gateway_key( &self, - gateway_id: identity::PublicKey, + gateway_id: ed25519::PublicKey, updated_key: &SharedSymmetricKey, ) -> Result<(), Self::StorageError>; diff --git a/common/client-core/gateways-storage/src/types.rs b/common/client-core/gateways-storage/src/types.rs index 4f5f17843d..477e9df99f 100644 --- a/common/client-core/gateways-storage/src/types.rs +++ b/common/client-core/gateways-storage/src/types.rs @@ -3,7 +3,7 @@ use crate::BadGateway; use cosmrs::AccountId; -use nym_crypto::asymmetric::identity; +use nym_crypto::asymmetric::ed25519; use nym_gateway_requests::shared_key::{LegacySharedKeys, SharedGatewayKey, SharedSymmetricKey}; use serde::{Deserialize, Serialize}; use std::fmt::{Display, Formatter}; @@ -29,7 +29,7 @@ pub struct GatewayRegistration { } impl GatewayRegistration { - pub fn gateway_id(&self) -> identity::PublicKey { + pub fn gateway_id(&self) -> ed25519::PublicKey { self.details.gateway_id() } } @@ -64,7 +64,7 @@ impl From for GatewayRegistration { impl GatewayDetails { pub fn new_remote( - gateway_id: identity::PublicKey, + gateway_id: ed25519::PublicKey, shared_key: Arc, gateway_owner_address: Option, gateway_listener: Url, @@ -77,11 +77,11 @@ impl GatewayDetails { }) } - pub fn new_custom(gateway_id: identity::PublicKey, data: Option>) -> Self { + pub fn new_custom(gateway_id: ed25519::PublicKey, data: Option>) -> Self { GatewayDetails::Custom(CustomGatewayDetails { gateway_id, data }) } - pub fn gateway_id(&self) -> identity::PublicKey { + pub fn gateway_id(&self) -> ed25519::PublicKey { match self { GatewayDetails::Remote(details) => details.gateway_id, GatewayDetails::Custom(details) => details.gateway_id, @@ -157,7 +157,7 @@ pub struct RawRegisteredGateway { #[derive(Debug, Clone, Copy)] pub struct RegisteredGateway { - pub gateway_id: identity::PublicKey, + pub gateway_id: ed25519::PublicKey, pub registration_timestamp: OffsetDateTime, @@ -179,7 +179,7 @@ impl TryFrom for RemoteGatewayDetails { fn try_from(value: RawRemoteGatewayDetails) -> Result { let gateway_id = - identity::PublicKey::from_base58_string(&value.gateway_id_bs58).map_err(|source| { + ed25519::PublicKey::from_base58_string(&value.gateway_id_bs58).map_err(|source| { BadGateway::MalformedGatewayIdentity { gateway_id: value.gateway_id_bs58.clone(), source, @@ -267,7 +267,7 @@ impl<'a> From<&'a RemoteGatewayDetails> for RawRemoteGatewayDetails { #[derive(Debug, Clone)] pub struct RemoteGatewayDetails { - pub gateway_id: identity::PublicKey, + pub gateway_id: ed25519::PublicKey, pub shared_key: Arc, @@ -288,7 +288,7 @@ impl TryFrom for CustomGatewayDetails { fn try_from(value: RawCustomGatewayDetails) -> Result { let gateway_id = - identity::PublicKey::from_base58_string(&value.gateway_id_bs58).map_err(|source| { + ed25519::PublicKey::from_base58_string(&value.gateway_id_bs58).map_err(|source| { BadGateway::MalformedGatewayIdentity { gateway_id: value.gateway_id_bs58.clone(), source, @@ -314,12 +314,12 @@ impl<'a> From<&'a CustomGatewayDetails> for RawCustomGatewayDetails { #[derive(Debug, Clone)] pub struct CustomGatewayDetails { - pub gateway_id: identity::PublicKey, + pub gateway_id: ed25519::PublicKey, pub data: Option>, } impl CustomGatewayDetails { - pub fn new(gateway_id: identity::PublicKey) -> CustomGatewayDetails { + pub fn new(gateway_id: ed25519::PublicKey) -> CustomGatewayDetails { Self { gateway_id, data: None, diff --git a/common/client-core/src/cli_helpers/client_add_gateway.rs b/common/client-core/src/cli_helpers/client_add_gateway.rs index e87f73ff0f..8811aff1d3 100644 --- a/common/client-core/src/cli_helpers/client_add_gateway.rs +++ b/common/client-core/src/cli_helpers/client_add_gateway.rs @@ -14,7 +14,7 @@ use crate::{ }; use log::info; use nym_client_core_gateways_storage::GatewayDetails; -use nym_crypto::asymmetric::identity; +use nym_crypto::asymmetric::ed25519; use nym_topology::NymTopology; use nym_validator_client::UserAgent; use std::path::PathBuf; @@ -29,7 +29,7 @@ pub struct CommonClientAddGatewayArgs { /// Explicitly specify id of the gateway to register with. /// If unspecified, a random gateway will be chosen instead. #[cfg_attr(feature = "cli", clap(long, alias = "gateway"))] - pub gateway_id: Option, + pub gateway_id: Option, /// Specifies whether the client will attempt to enforce tls connection to the desired gateway. #[cfg_attr(feature = "cli", clap(long))] diff --git a/common/client-core/src/cli_helpers/client_init.rs b/common/client-core/src/cli_helpers/client_init.rs index 40ad1caa28..03f41ed077 100644 --- a/common/client-core/src/cli_helpers/client_init.rs +++ b/common/client-core/src/cli_helpers/client_init.rs @@ -14,7 +14,7 @@ use crate::{ }; use log::info; use nym_client_core_gateways_storage::GatewayDetails; -use nym_crypto::asymmetric::identity; +use nym_crypto::asymmetric::ed25519; use nym_sphinx::addressing::Recipient; use nym_topology::NymTopology; use nym_validator_client::UserAgent; @@ -42,7 +42,7 @@ pub struct CommonClientInitArgs { /// Id of the gateway we are going to connect to. #[cfg_attr(feature = "cli", clap(long))] - pub gateway: Option, + pub gateway: Option, /// Specifies whether the client will attempt to enforce tls connection to the desired gateway. #[cfg_attr(feature = "cli", clap(long))] diff --git a/common/client-core/src/cli_helpers/client_run.rs b/common/client-core/src/cli_helpers/client_run.rs index 327d38e501..147aec2013 100644 --- a/common/client-core/src/cli_helpers/client_run.rs +++ b/common/client-core/src/cli_helpers/client_run.rs @@ -1,7 +1,7 @@ // Copyright 2023 - Nym Technologies SA // SPDX-License-Identifier: Apache-2.0 -use nym_crypto::asymmetric::identity; +use nym_crypto::asymmetric::ed25519; use nym_sphinx::addressing::Recipient; use std::path::PathBuf; @@ -15,7 +15,7 @@ pub struct CommonClientRunArgs { /// Id of the gateway we want to connect to. If overridden, it is user's responsibility to /// ensure prior registration happened #[cfg_attr(feature = "cli", clap(long))] - pub gateway: Option, + pub gateway: Option, /// Comma separated list of rest endpoints of the nyxd validators #[cfg_attr( diff --git a/common/client-core/src/cli_helpers/client_switch_gateway.rs b/common/client-core/src/cli_helpers/client_switch_gateway.rs index 0468575e63..1363234fae 100644 --- a/common/client-core/src/cli_helpers/client_switch_gateway.rs +++ b/common/client-core/src/cli_helpers/client_switch_gateway.rs @@ -4,7 +4,7 @@ use crate::cli_helpers::{CliClient, CliClientConfig}; use crate::client::base_client::non_wasm_helpers::setup_fs_gateways_storage; use crate::client::base_client::storage::helpers::set_active_gateway; -use nym_crypto::asymmetric::identity; +use nym_crypto::asymmetric::ed25519; #[cfg_attr(feature = "cli", derive(clap::Args))] #[derive(Debug, Clone)] @@ -15,7 +15,7 @@ pub struct CommonClientSwitchGatewaysArgs { /// Id of the gateway we want to switch to. #[cfg_attr(feature = "cli", clap(long))] - pub gateway_id: identity::PublicKey, + pub gateway_id: ed25519::PublicKey, } pub async fn switch_gateway(args: A) -> Result<(), C::Error> diff --git a/common/client-core/src/cli_helpers/types.rs b/common/client-core/src/cli_helpers/types.rs index 5cf2ebb012..1cdc731637 100644 --- a/common/client-core/src/cli_helpers/types.rs +++ b/common/client-core/src/cli_helpers/types.rs @@ -1,7 +1,7 @@ // Copyright 2024 - Nym Technologies SA // SPDX-License-Identifier: Apache-2.0 -use nym_crypto::asymmetric::identity; +use nym_crypto::asymmetric::ed25519; use serde::{Deserialize, Serialize}; use std::fmt::{Display, Formatter}; use time::OffsetDateTime; @@ -10,7 +10,7 @@ use url::Url; #[derive(Serialize, Deserialize)] pub struct GatewayInfo { pub registration: OffsetDateTime, - pub identity: identity::PublicKey, + pub identity: ed25519::PublicKey, pub active: bool, pub typ: String, diff --git a/common/client-core/src/client/base_client/mod.rs b/common/client-core/src/client/base_client/mod.rs index ee56744e50..90031fd0fe 100644 --- a/common/client-core/src/client/base_client/mod.rs +++ b/common/client-core/src/client/base_client/mod.rs @@ -39,7 +39,7 @@ use nym_bandwidth_controller::BandwidthController; use nym_client_core_config_types::ForgetMe; use nym_client_core_gateways_storage::{GatewayDetails, GatewaysDetailsStore}; use nym_credential_storage::storage::Storage as CredentialStorage; -use nym_crypto::asymmetric::{encryption, identity}; +use nym_crypto::asymmetric::{ed25519, x25519}; use nym_crypto::hkdf::DerivationMaterial; use nym_gateway_client::client::config::GatewayClientConfig; use nym_gateway_client::{ @@ -367,7 +367,7 @@ where // buffer controlling all messages fetched from provider // required so that other components would be able to use them (say the websocket) fn start_received_messages_buffer_controller( - local_encryption_keypair: Arc, + local_encryption_keypair: Arc, query_receiver: ReceivedBufferRequestReceiver, mixnet_receiver: MixnetMessageReceiver, reply_key_storage: SentReplyKeys, @@ -936,7 +936,7 @@ where pub struct BaseClient { pub address: Recipient, - pub identity_keys: Arc, + pub identity_keys: Arc, pub client_input: ClientInputStatus, pub client_output: ClientOutputStatus, pub client_state: ClientState, diff --git a/common/client-core/src/client/base_client/storage/helpers.rs b/common/client-core/src/client/base_client/storage/helpers.rs index b2a200579d..ba4cb4b20a 100644 --- a/common/client-core/src/client/base_client/storage/helpers.rs +++ b/common/client-core/src/client/base_client/storage/helpers.rs @@ -5,7 +5,7 @@ use crate::client::key_manager::persistence::KeyStore; use crate::client::key_manager::ClientKeys; use crate::error::ClientCoreError; use nym_client_core_gateways_storage::{ActiveGateway, GatewayRegistration, GatewaysDetailsStore}; -use nym_crypto::asymmetric::identity; +use nym_crypto::asymmetric::ed25519; // helpers for error wrapping pub async fn set_active_gateway( @@ -26,7 +26,7 @@ where pub async fn get_active_gateway_identity( details_store: &D, -) -> Result, ClientCoreError> +) -> Result, ClientCoreError> where D: GatewaysDetailsStore, D::StorageError: Send + Sync + 'static, @@ -42,7 +42,7 @@ where pub async fn get_all_registered_identities( details_store: &D, -) -> Result, ClientCoreError> +) -> Result, ClientCoreError> where D: GatewaysDetailsStore + Sync, D::StorageError: Send + Sync + 'static, diff --git a/common/client-core/src/client/key_manager/mod.rs b/common/client-core/src/client/key_manager/mod.rs index d67ff80a3e..24d5943203 100644 --- a/common/client-core/src/client/key_manager/mod.rs +++ b/common/client-core/src/client/key_manager/mod.rs @@ -3,7 +3,7 @@ use crate::client::key_manager::persistence::KeyStore; use nym_crypto::{ - asymmetric::{encryption, identity}, + asymmetric::{ed25519, x25519}, hkdf::{DerivationMaterial, InvalidLength}, }; use nym_gateway_requests::shared_key::{LegacySharedKeys, SharedGatewayKey, SharedSymmetricKey}; @@ -25,10 +25,10 @@ mod test; #[derive(Clone)] pub struct ClientKeys { /// identity key associated with the client instance. - identity_keypair: Arc, + identity_keypair: Arc, /// encryption key associated with the client instance. - encryption_keypair: Arc, + encryption_keypair: Arc, /// key used for producing and processing acknowledgement packets. ack_key: Arc, @@ -41,8 +41,8 @@ impl ClientKeys { R: RngCore + CryptoRng, { ClientKeys { - identity_keypair: Arc::new(identity::KeyPair::new(rng)), - encryption_keypair: Arc::new(encryption::KeyPair::new(rng)), + identity_keypair: Arc::new(ed25519::KeyPair::new(rng)), + encryption_keypair: Arc::new(x25519::KeyPair::new(rng)), ack_key: Arc::new(AckKey::new(rng)), } } @@ -56,18 +56,18 @@ impl ClientKeys { { let secret = derivation_material.derive_secret()?; Ok(ClientKeys { - identity_keypair: Arc::new(identity::KeyPair::from_secret( + identity_keypair: Arc::new(ed25519::KeyPair::from_secret( secret, derivation_material.index(), )), - encryption_keypair: Arc::new(encryption::KeyPair::new(rng)), + encryption_keypair: Arc::new(x25519::KeyPair::new(rng)), ack_key: Arc::new(AckKey::new(rng)), }) } pub fn from_keys( - id_keypair: identity::KeyPair, - enc_keypair: encryption::KeyPair, + id_keypair: ed25519::KeyPair, + enc_keypair: x25519::KeyPair, ack_key: AckKey, ) -> Self { Self { @@ -85,13 +85,13 @@ impl ClientKeys { store.store_keys(self).await } - /// Gets an atomically reference counted pointer to [`identity::KeyPair`]. - pub fn identity_keypair(&self) -> Arc { + /// Gets an atomically reference counted pointer to [`ed25519::KeyPair`]. + pub fn identity_keypair(&self) -> Arc { Arc::clone(&self.identity_keypair) } - /// Gets an atomically reference counted pointer to [`encryption::KeyPair`]. - pub fn encryption_keypair(&self) -> Arc { + /// Gets an atomically reference counted pointer to [`x25519::KeyPair`]. + pub fn encryption_keypair(&self) -> Arc { Arc::clone(&self.encryption_keypair) } /// Gets an atomically reference counted pointer to [`AckKey`]. @@ -103,8 +103,8 @@ impl ClientKeys { fn _assert_keys_zeroize_on_drop() { fn _assert_zeroize_on_drop() {} - _assert_zeroize_on_drop::(); - _assert_zeroize_on_drop::(); + _assert_zeroize_on_drop::(); + _assert_zeroize_on_drop::(); _assert_zeroize_on_drop::(); _assert_zeroize_on_drop::(); _assert_zeroize_on_drop::(); diff --git a/common/client-core/src/client/key_manager/persistence.rs b/common/client-core/src/client/key_manager/persistence.rs index 42a0b6a19a..6395e07da6 100644 --- a/common/client-core/src/client/key_manager/persistence.rs +++ b/common/client-core/src/client/key_manager/persistence.rs @@ -11,7 +11,7 @@ use tokio::sync::Mutex; #[cfg(not(target_arch = "wasm32"))] use crate::config::disk_persistence::ClientKeysPaths; #[cfg(not(target_arch = "wasm32"))] -use nym_crypto::asymmetric::{encryption, identity}; +use nym_crypto::asymmetric::{ed25519, x25519}; #[cfg(not(target_arch = "wasm32"))] use nym_pemstore::traits::{PemStorableKey, PemStorableKeyPair}; #[cfg(not(target_arch = "wasm32"))] @@ -86,13 +86,13 @@ impl OnDiskKeys { } #[doc(hidden)] - pub fn load_encryption_keypair(&self) -> Result { + pub fn load_encryption_keypair(&self) -> Result { let encryption_paths = self.paths.encryption_key_pair_path(); self.load_keypair(encryption_paths, "encryption") } #[doc(hidden)] - pub fn load_identity_keypair(&self) -> Result { + pub fn load_identity_keypair(&self) -> Result { let identity_paths = self.paths.identity_key_pair_path(); self.load_keypair(identity_paths, "identity") } diff --git a/common/client-core/src/client/mix_traffic/transceiver.rs b/common/client-core/src/client/mix_traffic/transceiver.rs index 56c0a195d9..6ec0e68ae6 100644 --- a/common/client-core/src/client/mix_traffic/transceiver.rs +++ b/common/client-core/src/client/mix_traffic/transceiver.rs @@ -4,7 +4,7 @@ use async_trait::async_trait; use log::{debug, error}; use nym_credential_storage::storage::Storage as CredentialStorage; -use nym_crypto::asymmetric::identity; +use nym_crypto::asymmetric::ed25519; use nym_gateway_client::error::GatewayClientError; use nym_gateway_client::GatewayClient; pub use nym_gateway_client::{GatewayPacketRouter, PacketRouter}; @@ -30,7 +30,7 @@ fn erase_err(err: E) -> ErasedGate /// This combines combines the functionalities of being able to send and receive mix packets. #[async_trait] pub trait GatewayTransceiver: GatewaySender + GatewayReceiver { - fn gateway_identity(&self) -> identity::PublicKey; + fn gateway_identity(&self) -> ed25519::PublicKey; fn ws_fd(&self) -> Option; async fn send_client_request( &mut self, @@ -75,7 +75,7 @@ pub trait GatewayReceiver { #[async_trait] impl GatewayTransceiver for Box { #[inline] - fn gateway_identity(&self) -> identity::PublicKey { + fn gateway_identity(&self) -> ed25519::PublicKey { (**self).gateway_identity() } fn ws_fd(&self) -> Option { @@ -134,7 +134,7 @@ where St: CredentialStorage, ::StorageError: Send + Sync + 'static, { - fn gateway_identity(&self) -> identity::PublicKey { + fn gateway_identity(&self) -> ed25519::PublicKey { self.gateway_client.gateway_identity() } fn ws_fd(&self) -> Option { @@ -190,7 +190,7 @@ pub enum LocalGatewayError { #[cfg(not(target_arch = "wasm32"))] pub struct LocalGateway { /// Identity of the locally managed gateway - local_identity: identity::PublicKey, + local_identity: ed25519::PublicKey, // 'sender' part /// Channel responsible for taking mix packets and forwarding them further into the further mixnet layers. @@ -203,7 +203,7 @@ pub struct LocalGateway { #[cfg(not(target_arch = "wasm32"))] impl LocalGateway { pub fn new( - local_identity: identity::PublicKey, + local_identity: ed25519::PublicKey, packet_forwarder: nym_mixnet_client::forwarder::MixForwardingSender, packet_router_tx: oneshot::Sender, ) -> Self { @@ -221,7 +221,7 @@ mod nonwasm_sealed { #[async_trait] impl GatewayTransceiver for LocalGateway { - fn gateway_identity(&self) -> identity::PublicKey { + fn gateway_identity(&self) -> ed25519::PublicKey { self.local_identity } fn ws_fd(&self) -> Option { @@ -263,7 +263,7 @@ mod nonwasm_sealed { // if we ever decided to start writing unit tests... : ) pub struct MockGateway { - dummy_identity: identity::PublicKey, + dummy_identity: ed25519::PublicKey, packet_router: Option, sent: Vec, } @@ -303,7 +303,7 @@ impl GatewaySender for MockGateway { #[async_trait] impl GatewayTransceiver for MockGateway { - fn gateway_identity(&self) -> identity::PublicKey { + fn gateway_identity(&self) -> ed25519::PublicKey { self.dummy_identity } fn ws_fd(&self) -> Option { diff --git a/common/client-core/src/client/received_buffer.rs b/common/client-core/src/client/received_buffer.rs index 468ded249c..380e519460 100644 --- a/common/client-core/src/client/received_buffer.rs +++ b/common/client-core/src/client/received_buffer.rs @@ -9,7 +9,7 @@ use futures::channel::mpsc; use futures::lock::Mutex; use futures::StreamExt; use log::*; -use nym_crypto::asymmetric::encryption; +use nym_crypto::asymmetric::x25519; use nym_crypto::Digest; use nym_gateway_client::MixnetMessageReceiver; use nym_sphinx::anonymous_replies::requests::{ @@ -39,7 +39,7 @@ pub type ReconstructedMessagesReceiver = mpsc::UnboundedReceiver { messages: Vec, - local_encryption_keypair: Arc, + local_encryption_keypair: Arc, // TODO: looking how it 'looks' here, perhaps `MessageReceiver` should be renamed to something // else instead. @@ -176,7 +176,7 @@ struct ReceivedMessagesBuffer { impl ReceivedMessagesBuffer { fn new( - local_encryption_keypair: Arc, + local_encryption_keypair: Arc, reply_key_storage: SentReplyKeys, reply_controller_sender: ReplyControllerSender, stats_tx: ClientStatsSender, @@ -566,7 +566,7 @@ pub(crate) struct ReceivedMessagesBufferController { impl ReceivedMessagesBufferController { pub(crate) fn new( - local_encryption_keypair: Arc, + local_encryption_keypair: Arc, query_receiver: ReceivedBufferRequestReceiver, mixnet_packet_receiver: MixnetMessageReceiver, reply_key_storage: SentReplyKeys, diff --git a/common/client-core/src/error.rs b/common/client-core/src/error.rs index 76add9d71d..0cf2a88b6b 100644 --- a/common/client-core/src/error.rs +++ b/common/client-core/src/error.rs @@ -2,7 +2,7 @@ // SPDX-License-Identifier: Apache-2.0 use crate::client::mix_traffic::transceiver::ErasedGatewayError; -use nym_crypto::asymmetric::identity::Ed25519RecoveryError; +use nym_crypto::asymmetric::ed25519::Ed25519RecoveryError; use nym_gateway_client::error::GatewayClientError; use nym_topology::node::RoutingNodeError; use nym_topology::{NodeId, NymTopologyError}; diff --git a/common/client-core/src/init/helpers.rs b/common/client-core/src/init/helpers.rs index 9d8d669bc1..b007243ce6 100644 --- a/common/client-core/src/init/helpers.rs +++ b/common/client-core/src/init/helpers.rs @@ -5,7 +5,7 @@ use crate::error::ClientCoreError; use crate::init::types::RegistrationResult; use futures::{SinkExt, StreamExt}; use log::{debug, info, trace, warn}; -use nym_crypto::asymmetric::identity; +use nym_crypto::asymmetric::ed25519; use nym_gateway_client::GatewayClient; use nym_topology::node::RoutingNode; use nym_validator_client::client::IdentityKeyRef; @@ -52,7 +52,7 @@ const PING_TIMEOUT: Duration = Duration::from_millis(1000); // The abstraction that some of these helpers use pub trait ConnectableGateway { fn node_id(&self) -> NodeId; - fn identity(&self) -> identity::PublicKey; + fn identity(&self) -> ed25519::PublicKey; fn clients_address(&self, prefer_ipv6: bool) -> Option; fn is_wss(&self) -> bool; } @@ -62,7 +62,7 @@ impl ConnectableGateway for RoutingNode { self.node_id } - fn identity(&self) -> identity::PublicKey { + fn identity(&self) -> ed25519::PublicKey { self.identity_key } @@ -287,7 +287,7 @@ pub(super) fn get_specified_gateway( must_use_tls: bool, ) -> Result { log::debug!("Requesting specified gateway: {}", gateway_identity); - let user_gateway = identity::PublicKey::from_base58_string(gateway_identity) + let user_gateway = ed25519::PublicKey::from_base58_string(gateway_identity) .map_err(ClientCoreError::UnableToCreatePublicKeyFromGatewayId)?; let gateway = gateways @@ -312,9 +312,9 @@ pub(super) fn get_specified_gateway( } pub(super) async fn register_with_gateway( - gateway_id: identity::PublicKey, + gateway_id: ed25519::PublicKey, gateway_listener: Url, - our_identity: Arc, + our_identity: Arc, #[cfg(unix)] connection_fd_callback: Option>, ) -> Result { let mut gateway_client = GatewayClient::new_init( diff --git a/common/client-core/src/init/types.rs b/common/client-core/src/init/types.rs index 7b163f5478..d9a17206c3 100644 --- a/common/client-core/src/init/types.rs +++ b/common/client-core/src/init/types.rs @@ -9,7 +9,7 @@ use crate::init::{setup_gateway, use_loaded_gateway_details}; use nym_client_core_gateways_storage::{ GatewayRegistration, GatewaysDetailsStore, RemoteGatewayDetails, }; -use nym_crypto::asymmetric::identity; +use nym_crypto::asymmetric::ed25519; use nym_gateway_client::client::InitGatewayClient; use nym_gateway_requests::shared_key::SharedGatewayKey; use nym_sphinx::addressing::clients::Recipient; @@ -26,14 +26,14 @@ use url::Url; pub enum SelectedGateway { Remote { - gateway_id: identity::PublicKey, + gateway_id: ed25519::PublicKey, gateway_owner_address: Option, gateway_listener: Url, }, Custom { - gateway_id: identity::PublicKey, + gateway_id: ed25519::PublicKey, additional_data: Option>, }, } @@ -77,7 +77,7 @@ impl SelectedGateway { gateway_id: String, additional_data: Option>, ) -> Result { - let gateway_id = identity::PublicKey::from_base58_string(&gateway_id) + let gateway_id = ed25519::PublicKey::from_base58_string(&gateway_id) .map_err(|source| ClientCoreError::MalformedGatewayIdentity { gateway_id, source })?; Ok(SelectedGateway::Custom { @@ -86,7 +86,7 @@ impl SelectedGateway { }) } - pub fn gateway_id(&self) -> &identity::PublicKey { + pub fn gateway_id(&self) -> &ed25519::PublicKey { match self { SelectedGateway::Remote { gateway_id, .. } => gateway_id, SelectedGateway::Custom { gateway_id, .. } => gateway_id, @@ -142,7 +142,7 @@ impl InitialisationResult { ) } - pub fn gateway_id(&self) -> identity::PublicKey { + pub fn gateway_id(&self) -> ed25519::PublicKey { self.gateway_registration.details.gateway_id() } } @@ -271,7 +271,7 @@ impl GatewaySetup { } /// new gateway setup performed by each client that's inbuilt in a gateway (like NR or IPR) - pub fn new_inbuilt(identity: identity::PublicKey) -> Self { + pub fn new_inbuilt(identity: ed25519::PublicKey) -> Self { GatewaySetup::New { specification: GatewaySelectionSpecification::Custom { gateway_identity: identity.to_base58_string(), diff --git a/common/client-libs/gateway-client/src/client/mod.rs b/common/client-libs/gateway-client/src/client/mod.rs index 59473142fd..fc1676ab67 100644 --- a/common/client-libs/gateway-client/src/client/mod.rs +++ b/common/client-libs/gateway-client/src/client/mod.rs @@ -17,7 +17,7 @@ use nym_credential_storage::ephemeral_storage::EphemeralStorage as EphemeralCred use nym_credential_storage::storage::Storage as CredentialStorage; use nym_credentials::CredentialSpendingData; use nym_credentials_interface::TicketType; -use nym_crypto::asymmetric::identity; +use nym_crypto::asymmetric::ed25519; use nym_gateway_requests::registration::handshake::client_handshake; use nym_gateway_requests::{ BinaryRequest, ClientControlRequest, ClientRequest, GatewayProtocolVersionExt, @@ -57,7 +57,7 @@ pub(crate) mod websockets; use websockets::connect_async; pub struct GatewayConfig { - pub gateway_identity: identity::PublicKey, + pub gateway_identity: ed25519::PublicKey, // currently a dead field pub gateway_owner: Option, @@ -67,7 +67,7 @@ pub struct GatewayConfig { impl GatewayConfig { pub fn new( - gateway_identity: identity::PublicKey, + gateway_identity: ed25519::PublicKey, gateway_owner: Option, gateway_listener: String, ) -> Self { @@ -93,8 +93,8 @@ pub struct GatewayClient { authenticated: bool, bandwidth: ClientBandwidth, gateway_address: String, - gateway_identity: identity::PublicKey, - local_identity: Arc, + gateway_identity: ed25519::PublicKey, + local_identity: Arc, shared_key: Option>, connection: SocketState, packet_router: PacketRouter, @@ -117,7 +117,7 @@ impl GatewayClient { pub fn new( cfg: GatewayClientConfig, gateway_config: GatewayConfig, - local_identity: Arc, + local_identity: Arc, // TODO: make it mandatory. if you don't want to pass it, use `new_init` shared_key: Option>, packet_router: PacketRouter, @@ -145,7 +145,7 @@ impl GatewayClient { } } - pub fn gateway_identity(&self) -> identity::PublicKey { + pub fn gateway_identity(&self) -> ed25519::PublicKey { self.gateway_identity } @@ -1063,8 +1063,8 @@ impl GatewayClient { // for initialisation we do not need credential storage. Though it's still a bit weird we have to set the generic... pub fn new_init( gateway_listener: Url, - gateway_identity: identity::PublicKey, - local_identity: Arc, + gateway_identity: ed25519::PublicKey, + local_identity: Arc, #[cfg(unix)] connection_fd_callback: Option>, ) -> Self { log::trace!("Initialising gateway client"); diff --git a/common/commands/src/ecash/issue_ticket_book.rs b/common/commands/src/ecash/issue_ticket_book.rs index 71c1d87982..e57cb579dc 100644 --- a/common/commands/src/ecash/issue_ticket_book.rs +++ b/common/commands/src/ecash/issue_ticket_book.rs @@ -15,7 +15,7 @@ use nym_credentials::{ AggregatedCoinIndicesSignatures, AggregatedExpirationDateSignatures, EpochVerificationKey, }; use nym_credentials_interface::TicketType; -use nym_crypto::asymmetric::identity; +use nym_crypto::asymmetric::ed25519; use std::fs; use std::path::PathBuf; use tempfile::NamedTempFile; @@ -83,7 +83,7 @@ async fn issue_client_ticketbook( ); let persistent_storage = initialise_persistent_storage(credentials_store).await; - let private_id_key: identity::PrivateKey = nym_pemstore::load_key(private_id_key)?; + let private_id_key: ed25519::PrivateKey = nym_pemstore::load_key(private_id_key)?; utils::issue_credential( &client, &persistent_storage, diff --git a/common/commands/src/validator/mixnet/operators/identity_key/mod.rs b/common/commands/src/validator/mixnet/operators/identity_key/mod.rs index 793259270e..9805b0ee3e 100644 --- a/common/commands/src/validator/mixnet/operators/identity_key/mod.rs +++ b/common/commands/src/validator/mixnet/operators/identity_key/mod.rs @@ -1,6 +1,6 @@ use clap::{Args, Parser, Subcommand}; use nym_bin_common::output_format::OutputFormat; -use nym_crypto::asymmetric::identity; +use nym_crypto::asymmetric::ed25519; use nym_types::helpers::ConsoleSigningOutput; use nym_validator_client::nyxd::error::NyxdError; use std::path::PathBuf; @@ -34,14 +34,14 @@ pub struct SignArgs { pub async fn sign(args: SignArgs) -> Result<(), NyxdError> { eprintln!(">>> loading: {}", args.private_key.display()); - let private_identity_key: identity::PrivateKey = + let private_identity_key: ed25519::PrivateKey = nym_pemstore::load_key(args.private_key).expect("failed to load key"); print_signed_msg(&private_identity_key, &args.base58_msg, args.output); Ok(()) } -fn print_signed_msg(private_key: &identity::PrivateKey, raw_msg: &str, output: OutputFormat) { +fn print_signed_msg(private_key: &ed25519::PrivateKey, raw_msg: &str, output: OutputFormat) { let trimmed = raw_msg.trim(); eprintln!(">>> attempting to sign: {trimmed}"); diff --git a/common/credentials/src/ecash/bandwidth/issuance.rs b/common/credentials/src/ecash/bandwidth/issuance.rs index 6e9e217f90..3d1cacc72d 100644 --- a/common/credentials/src/ecash/bandwidth/issuance.rs +++ b/common/credentials/src/ecash/bandwidth/issuance.rs @@ -12,7 +12,7 @@ use nym_credentials_interface::{ BlindedSignature, KeyPairUser, PartialWallet, TicketType, VerificationKeyAuth, WalletSignatures, WithdrawalRequest, }; -use nym_crypto::asymmetric::identity; +use nym_crypto::asymmetric::ed25519; use nym_ecash_contract_common::deposit::DepositId; use nym_ecash_time::{ecash_default_expiration_date, ecash_today, EcashTime}; use nym_validator_client::nym_api::EpochId; @@ -27,7 +27,7 @@ pub struct IssuanceTicketBook { deposit_id: DepositId, /// base58 encoded private key ensuring the depositer requested these attributes - signing_key: identity::PrivateKey, + signing_key: ed25519::PrivateKey, /// ecash keypair related to the credential ecash_keypair: KeyPairUser, @@ -43,7 +43,7 @@ impl IssuanceTicketBook { pub fn new>( deposit_id: DepositId, identifier: M, - signing_key: identity::PrivateKey, + signing_key: ed25519::PrivateKey, ticketbook_type: TicketType, ) -> Self { //this expiration date will get fed to the ecash library, force midnight to be set @@ -59,7 +59,7 @@ impl IssuanceTicketBook { pub fn new_with_expiration>( deposit_id: DepositId, identifier: M, - signing_key: identity::PrivateKey, + signing_key: ed25519::PrivateKey, ticketbook_type: TicketType, expiration_date: Date, ) -> Self { @@ -93,7 +93,7 @@ impl IssuanceTicketBook { message } - fn request_signature(&self, signing_request: &CredentialSigningData) -> identity::Signature { + fn request_signature(&self, signing_request: &CredentialSigningData) -> ed25519::Signature { let message = Self::request_plaintext(&signing_request.withdrawal_request, self.deposit_id); self.signing_key.sign(message) } @@ -127,7 +127,7 @@ impl IssuanceTicketBook { self.deposit_id } - pub fn identity_key(&self) -> &identity::PrivateKey { + pub fn identity_key(&self) -> &ed25519::PrivateKey { &self.signing_key } diff --git a/common/credentials/src/error.rs b/common/credentials/src/error.rs index 8f69056de5..fa751451dc 100644 --- a/common/credentials/src/error.rs +++ b/common/credentials/src/error.rs @@ -3,7 +3,7 @@ use crate::ecash::bandwidth::issued::CURRENT_SERIALIZATION_REVISION; use nym_credentials_interface::CompactEcashError; -use nym_crypto::asymmetric::encryption::KeyRecoveryError; +use nym_crypto::asymmetric::x25519::KeyRecoveryError; use nym_validator_client::ValidatorClientError; use thiserror::Error; diff --git a/common/crypto/src/asymmetric/identity/mod.rs b/common/crypto/src/asymmetric/ed25519/mod.rs similarity index 100% rename from common/crypto/src/asymmetric/identity/mod.rs rename to common/crypto/src/asymmetric/ed25519/mod.rs diff --git a/common/crypto/src/asymmetric/identity/serde_helpers.rs b/common/crypto/src/asymmetric/ed25519/serde_helpers.rs similarity index 95% rename from common/crypto/src/asymmetric/identity/serde_helpers.rs rename to common/crypto/src/asymmetric/ed25519/serde_helpers.rs index 6496291aa3..51a0ac2dfe 100644 --- a/common/crypto/src/asymmetric/identity/serde_helpers.rs +++ b/common/crypto/src/asymmetric/ed25519/serde_helpers.rs @@ -18,7 +18,7 @@ pub mod bs58_ed25519_pubkey { } pub mod bs58_ed25519_signature { - use crate::asymmetric::identity::Signature; + use crate::asymmetric::ed25519::Signature; use serde::{Deserialize, Deserializer, Serializer}; pub fn serialize( diff --git a/common/crypto/src/asymmetric/mod.rs b/common/crypto/src/asymmetric/mod.rs index 4f6b8eb4bf..ab7cc2b534 100644 --- a/common/crypto/src/asymmetric/mod.rs +++ b/common/crypto/src/asymmetric/mod.rs @@ -1,8 +1,13 @@ // Copyright 2021 - Nym Technologies SA // SPDX-License-Identifier: Apache-2.0 -pub mod encryption; -pub mod identity; +pub mod ed25519; +pub mod x25519; -pub use encryption as x25519; -pub use identity as ed25519; +// don't break existing imports +// but deprecate them +#[deprecated(note = "use ed25519 instead")] +pub use ed25519 as identity; + +#[deprecated(note = "use x25519 instead")] +pub use x25519 as encryption; diff --git a/common/crypto/src/asymmetric/encryption/mod.rs b/common/crypto/src/asymmetric/x25519/mod.rs similarity index 100% rename from common/crypto/src/asymmetric/encryption/mod.rs rename to common/crypto/src/asymmetric/x25519/mod.rs diff --git a/common/crypto/src/asymmetric/encryption/serde_helpers.rs b/common/crypto/src/asymmetric/x25519/serde_helpers.rs similarity index 100% rename from common/crypto/src/asymmetric/encryption/serde_helpers.rs rename to common/crypto/src/asymmetric/x25519/serde_helpers.rs diff --git a/common/crypto/src/shared_key.rs b/common/crypto/src/shared_key.rs index def5709339..19f6442545 100644 --- a/common/crypto/src/shared_key.rs +++ b/common/crypto/src/shared_key.rs @@ -1,7 +1,7 @@ // Copyright 2021 - Nym Technologies SA // SPDX-License-Identifier: Apache-2.0 -use crate::asymmetric::encryption; +use crate::asymmetric::x25519; use crate::hkdf; use cipher::{Key, KeyIvInit, StreamCipher}; use digest::crypto_common::BlockSizeUser; @@ -15,14 +15,14 @@ use rand::{CryptoRng, RngCore}; #[cfg(feature = "rand")] pub fn new_ephemeral_shared_key( rng: &mut R, - remote_key: &encryption::PublicKey, -) -> (encryption::KeyPair, Key) + remote_key: &x25519::PublicKey, +) -> (x25519::KeyPair, Key) where C: StreamCipher + KeyIvInit, D: Digest + BlockSizeUser + Clone, R: RngCore + CryptoRng, { - let ephemeral_keypair = encryption::KeyPair::new(rng); + let ephemeral_keypair = x25519::KeyPair::new(rng); // after performing diffie-hellman we don't care about the private component anymore let dh_result = ephemeral_keypair.private_key().diffie_hellman(remote_key); @@ -43,8 +43,8 @@ where /// Recompute shared key using remote public key and local private key. pub fn recompute_shared_key( - remote_key: &encryption::PublicKey, - local_key: &encryption::PrivateKey, + remote_key: &x25519::PublicKey, + local_key: &x25519::PrivateKey, ) -> Key where C: StreamCipher + KeyIvInit, diff --git a/common/gateway-requests/src/registration/handshake/mod.rs b/common/gateway-requests/src/registration/handshake/mod.rs index 4a6f44b7d7..53373f5c30 100644 --- a/common/gateway-requests/src/registration/handshake/mod.rs +++ b/common/gateway-requests/src/registration/handshake/mod.rs @@ -6,7 +6,7 @@ use crate::registration::handshake::state::State; use crate::SharedGatewayKey; use futures::future::BoxFuture; use futures::{Sink, Stream}; -use nym_crypto::asymmetric::identity; +use nym_crypto::asymmetric::ed25519; use rand::{CryptoRng, RngCore}; use std::future::Future; use std::pin::Pin; @@ -48,8 +48,8 @@ impl Future for GatewayHandshake<'_> { pub fn client_handshake<'a, S, R>( rng: &'a mut R, ws_stream: &'a mut S, - identity: &'a identity::KeyPair, - gateway_pubkey: identity::PublicKey, + identity: &'a ed25519::KeyPair, + gateway_pubkey: ed25519::PublicKey, expects_credential_usage: bool, derive_aes256_gcm_siv_key: bool, #[cfg(not(target_arch = "wasm32"))] shutdown: TaskClient, @@ -78,7 +78,7 @@ where pub fn gateway_handshake<'a, S, R>( rng: &'a mut R, ws_stream: &'a mut S, - identity: &'a identity::KeyPair, + identity: &'a ed25519::KeyPair, received_init_payload: Vec, shutdown: TaskClient, ) -> GatewayHandshake<'a> diff --git a/common/gateway-requests/src/registration/handshake/state.rs b/common/gateway-requests/src/registration/handshake/state.rs index ab7ae4d97f..62e9eba9e8 100644 --- a/common/gateway-requests/src/registration/handshake/state.rs +++ b/common/gateway-requests/src/registration/handshake/state.rs @@ -14,11 +14,7 @@ use crate::{ use futures::{Sink, SinkExt, Stream, StreamExt}; use nym_crypto::asymmetric::{ed25519, x25519}; use nym_crypto::symmetric::aead::random_nonce; -use nym_crypto::{ - asymmetric::{encryption, identity}, - generic_array::typenum::Unsigned, - hkdf, -}; +use nym_crypto::{generic_array::typenum::Unsigned, hkdf}; use nym_sphinx::params::{GatewayEncryptionAlgorithm, GatewaySharedKeyHkdfAlgorithm}; use rand::{thread_rng, CryptoRng, RngCore}; use std::any::{type_name, Any}; @@ -74,14 +70,14 @@ impl<'a, S, R> State<'a, S, R> { pub(crate) fn new( rng: &'a mut R, ws_stream: &'a mut S, - identity: &'a identity::KeyPair, - remote_pubkey: Option, + identity: &'a ed25519::KeyPair, + remote_pubkey: Option, #[cfg(not(target_arch = "wasm32"))] shutdown: TaskClient, ) -> Self where R: CryptoRng + RngCore, { - let ephemeral_keypair = encryption::KeyPair::new(rng); + let ephemeral_keypair = x25519::KeyPair::new(rng); State { ws_stream, rng, @@ -113,7 +109,7 @@ impl<'a, S, R> State<'a, S, R> { } #[cfg(not(target_arch = "wasm32"))] - pub(crate) fn local_ephemeral_key(&self) -> &encryption::PublicKey { + pub(crate) fn local_ephemeral_key(&self) -> &x25519::PublicKey { self.ephemeral_keypair.public_key() } @@ -150,7 +146,7 @@ impl<'a, S, R> State<'a, S, R> { pub(crate) fn derive_shared_key( &mut self, - remote_ephemeral_key: &encryption::PublicKey, + remote_ephemeral_key: &x25519::PublicKey, initiator_salt: Option<&[u8]>, ) { let dh_result = self @@ -189,7 +185,7 @@ impl<'a, S, R> State<'a, S, R> { // assuming x is local and y is remote pub(crate) fn prepare_key_material_sig( &self, - remote_ephemeral_key: &encryption::PublicKey, + remote_ephemeral_key: &x25519::PublicKey, ) -> Result { let plaintext: Vec<_> = self .ephemeral_keypair @@ -243,7 +239,7 @@ impl<'a, S, R> State<'a, S, R> { )?; // now verify signature itself - let signature = identity::Signature::from_bytes(&decrypted_signature) + let signature = ed25519::Signature::from_bytes(&decrypted_signature) .map_err(|_| HandshakeError::InvalidSignature)?; // g^y || g^x, if y is remote and x is local @@ -261,7 +257,7 @@ impl<'a, S, R> State<'a, S, R> { } #[cfg(not(target_arch = "wasm32"))] - pub(crate) fn update_remote_identity(&mut self, remote_pubkey: identity::PublicKey) { + pub(crate) fn update_remote_identity(&mut self, remote_pubkey: ed25519::PublicKey) { self.remote_pubkey = Some(remote_pubkey) } diff --git a/common/ip-packet-requests/src/v7/request.rs b/common/ip-packet-requests/src/v7/request.rs index 2313c16942..e82a85ae53 100644 --- a/common/ip-packet-requests/src/v7/request.rs +++ b/common/ip-packet-requests/src/v7/request.rs @@ -1,6 +1,6 @@ use std::fmt; -use nym_crypto::asymmetric::identity; +use nym_crypto::asymmetric::ed25519; use nym_sphinx::addressing::clients::Recipient; use serde::{Deserialize, Serialize}; use time::OffsetDateTime; @@ -200,7 +200,7 @@ impl fmt::Display for IpPacketRequestData { } impl IpPacketRequestData { - pub fn add_signature(&mut self, signature: identity::Signature) -> Option { + pub fn add_signature(&mut self, signature: ed25519::Signature) -> Option { match self { IpPacketRequestData::StaticConnect(request) => { request.signature = Some(signature); @@ -269,11 +269,11 @@ impl StaticConnectRequest { #[derive(Clone, Debug, Serialize, Deserialize, PartialEq)] pub struct SignedStaticConnectRequest { pub request: StaticConnectRequest, - pub signature: Option, + pub signature: Option, } impl SignedRequest for SignedStaticConnectRequest { - fn identity(&self) -> Option<&identity::PublicKey> { + fn identity(&self) -> Option<&ed25519::PublicKey> { Some(self.request.reply_to.identity()) } @@ -286,7 +286,7 @@ impl SignedRequest for SignedStaticConnectRequest { }) } - fn signature(&self) -> Option<&identity::Signature> { + fn signature(&self) -> Option<&ed25519::Signature> { self.signature.as_ref() } @@ -333,11 +333,11 @@ impl DynamicConnectRequest { #[derive(Clone, Debug, Serialize, Deserialize, PartialEq)] pub struct SignedDynamicConnectRequest { pub request: DynamicConnectRequest, - pub signature: Option, + pub signature: Option, } impl SignedRequest for SignedDynamicConnectRequest { - fn identity(&self) -> Option<&identity::PublicKey> { + fn identity(&self) -> Option<&ed25519::PublicKey> { Some(self.request.reply_to.identity()) } @@ -350,7 +350,7 @@ impl SignedRequest for SignedDynamicConnectRequest { }) } - fn signature(&self) -> Option<&identity::Signature> { + fn signature(&self) -> Option<&ed25519::Signature> { self.signature.as_ref() } @@ -382,11 +382,11 @@ impl DisconnectRequest { #[derive(Clone, Debug, Serialize, Deserialize, PartialEq)] pub struct SignedDisconnectRequest { pub request: DisconnectRequest, - pub signature: Option, + pub signature: Option, } impl SignedRequest for SignedDisconnectRequest { - fn identity(&self) -> Option<&identity::PublicKey> { + fn identity(&self) -> Option<&ed25519::PublicKey> { Some(self.request.reply_to.identity()) } @@ -399,7 +399,7 @@ impl SignedRequest for SignedDisconnectRequest { }) } - fn signature(&self) -> Option<&identity::Signature> { + fn signature(&self) -> Option<&ed25519::Signature> { self.signature.as_ref() } diff --git a/common/node-tester-utils/src/processor.rs b/common/node-tester-utils/src/processor.rs index 0146c25258..0db125732e 100644 --- a/common/node-tester-utils/src/processor.rs +++ b/common/node-tester-utils/src/processor.rs @@ -3,7 +3,7 @@ use crate::error::NetworkTestingError; use crate::TestMessage; -use nym_crypto::asymmetric::encryption; +use nym_crypto::asymmetric::x25519; use nym_sphinx::acknowledgements::identifier::recover_identifier; use nym_sphinx::acknowledgements::AckKey; use nym_sphinx::chunking::fragment::FragmentIdentifier; @@ -31,7 +31,7 @@ impl From for Received { } pub struct TestPacketProcessor { - local_encryption_keypair: Arc, + local_encryption_keypair: Arc, ack_key: Arc, /// Structure responsible for decrypting and recovering plaintext message from received ciphertexts. @@ -42,7 +42,7 @@ pub struct TestPacketProcessor { impl TestPacketProcessor { pub fn new_sphinx_processor( - local_encryption_keypair: Arc, + local_encryption_keypair: Arc, ack_key: Arc, ) -> Self { Self::new(local_encryption_keypair, ack_key) @@ -53,7 +53,7 @@ impl TestPacketProcessor where R: MessageReceiver, { - pub fn new(local_encryption_keypair: Arc, ack_key: Arc) -> Self { + pub fn new(local_encryption_keypair: Arc, ack_key: Arc) -> Self { TestPacketProcessor { local_encryption_keypair, ack_key, diff --git a/common/node-tester-utils/src/receiver.rs b/common/node-tester-utils/src/receiver.rs index bf659bf0a5..fd764d56dc 100644 --- a/common/node-tester-utils/src/receiver.rs +++ b/common/node-tester-utils/src/receiver.rs @@ -6,7 +6,7 @@ use crate::processor::{Received, TestPacketProcessor}; use crate::{log_err, log_info, log_warn}; use futures::channel::mpsc; use futures::StreamExt; -use nym_crypto::asymmetric::encryption; +use nym_crypto::asymmetric::x25519; use nym_sphinx::acknowledgements::AckKey; use nym_sphinx::receiver::{MessageReceiver, SphinxMessageReceiver}; use nym_task::TaskClient; @@ -29,7 +29,7 @@ pub struct SimpleMessageReceiver impl SimpleMessageReceiver { pub fn new_sphinx_receiver( - local_encryption_keypair: Arc, + local_encryption_keypair: Arc, ack_key: Arc, mixnet_message_receiver: mpsc::UnboundedReceiver>>, acks_receiver: mpsc::UnboundedReceiver>>, @@ -49,7 +49,7 @@ impl SimpleMessageReceiver { impl SimpleMessageReceiver { pub fn new( - local_encryption_keypair: Arc, + local_encryption_keypair: Arc, ack_key: Arc, mixnet_message_receiver: mpsc::UnboundedReceiver>>, acks_receiver: mpsc::UnboundedReceiver>>, diff --git a/common/nymsphinx/addressing/src/clients.rs b/common/nymsphinx/addressing/src/clients.rs index d60581bf21..0b1bcf7623 100644 --- a/common/nymsphinx/addressing/src/clients.rs +++ b/common/nymsphinx/addressing/src/clients.rs @@ -5,7 +5,7 @@ // it's already destructed). use crate::nodes::{NodeIdentity, NODE_IDENTITY_SIZE}; -use nym_crypto::asymmetric::{encryption, identity}; +use nym_crypto::asymmetric::{ed25519, x25519}; use nym_sphinx_types::Destination; use serde::de::{Error as SerdeError, Unexpected, Visitor}; use serde::{Deserialize, Deserializer, Serialize, Serializer}; @@ -15,11 +15,11 @@ use thiserror::Error; // Not entirely sure whether this is the correct place for those, but let's see how it's going // to work out -pub type ClientEncryptionKey = encryption::PublicKey; -const CLIENT_ENCRYPTION_KEY_SIZE: usize = encryption::PUBLIC_KEY_SIZE; +pub type ClientEncryptionKey = x25519::PublicKey; +const CLIENT_ENCRYPTION_KEY_SIZE: usize = x25519::PUBLIC_KEY_SIZE; -pub type ClientIdentity = identity::PublicKey; -const CLIENT_IDENTITY_SIZE: usize = identity::PUBLIC_KEY_LENGTH; +pub type ClientIdentity = ed25519::PublicKey; +const CLIENT_IDENTITY_SIZE: usize = ed25519::PUBLIC_KEY_LENGTH; pub type RecipientBytes = [u8; Recipient::LEN]; @@ -29,13 +29,13 @@ pub enum RecipientFormattingError { MalformedRecipientError { reason: String }, #[error("recipient's identity key is malformed: {0}")] - MalformedIdentityError(identity::Ed25519RecoveryError), + MalformedIdentityError(ed25519::Ed25519RecoveryError), #[error("recipient's encryption key is malformed: {0}")] - MalformedEncryptionKeyError(#[from] encryption::KeyRecoveryError), + MalformedEncryptionKeyError(#[from] x25519::KeyRecoveryError), #[error("recipient gateway's identity key is malformed: {0}")] - MalformedGatewayError(identity::Ed25519RecoveryError), + MalformedGatewayError(ed25519::Ed25519RecoveryError), } // TODO: this should a different home... somewhere, but where? @@ -249,9 +249,9 @@ mod tests { fn string_conversion_works() { let mut rng = rand::thread_rng(); - let client_id_pair = identity::KeyPair::new(&mut rng); - let client_enc_pair = encryption::KeyPair::new(&mut rng); - let gateway_id_pair = identity::KeyPair::new(&mut rng); + let client_id_pair = ed25519::KeyPair::new(&mut rng); + let client_enc_pair = x25519::KeyPair::new(&mut rng); + let gateway_id_pair = ed25519::KeyPair::new(&mut rng); let recipient = Recipient::new( *client_id_pair.public_key(), @@ -281,9 +281,9 @@ mod tests { fn bytes_conversion_works() { let mut rng = rand::thread_rng(); - let client_id_pair = identity::KeyPair::new(&mut rng); - let client_enc_pair = encryption::KeyPair::new(&mut rng); - let gateway_id_pair = identity::KeyPair::new(&mut rng); + let client_id_pair = ed25519::KeyPair::new(&mut rng); + let client_enc_pair = x25519::KeyPair::new(&mut rng); + let gateway_id_pair = ed25519::KeyPair::new(&mut rng); let recipient = Recipient::new( *client_id_pair.public_key(), diff --git a/common/nymsphinx/addressing/src/nodes.rs b/common/nymsphinx/addressing/src/nodes.rs index cbf05e7b41..264eaa5ed9 100644 --- a/common/nymsphinx/addressing/src/nodes.rs +++ b/common/nymsphinx/addressing/src/nodes.rs @@ -8,7 +8,7 @@ //! Currently, that routing information is an IP address, but in principle it can be anything //! for as long as it's going to fit in the field. -use nym_crypto::asymmetric::identity; +use nym_crypto::asymmetric::ed25519; use nym_sphinx_types::{NodeAddressBytes, NODE_ADDRESS_LENGTH}; use std::net::{IpAddr, Ipv4Addr, Ipv6Addr, SocketAddr}; @@ -16,8 +16,8 @@ use thiserror::Error; // Not entirely sure whether this is the correct place for those, but let's see how it's going // to work out -pub type NodeIdentity = identity::PublicKey; -pub const NODE_IDENTITY_SIZE: usize = identity::PUBLIC_KEY_LENGTH; +pub type NodeIdentity = ed25519::PublicKey; +pub const NODE_IDENTITY_SIZE: usize = ed25519::PUBLIC_KEY_LENGTH; /// MAX_UNPADDED_LEN represents maximum length an unpadded address could have. /// In this case it's an ipv6 socket address (with version prefix) diff --git a/common/nymsphinx/anonymous-replies/src/requests/mod.rs b/common/nymsphinx/anonymous-replies/src/requests/mod.rs index 6bb382579c..2a95236386 100644 --- a/common/nymsphinx/anonymous-replies/src/requests/mod.rs +++ b/common/nymsphinx/anonymous-replies/src/requests/mod.rs @@ -485,7 +485,7 @@ mod tests { use crate::requests::v2::{AdditionalSurbsV2, DataV2, HeartbeatV2}; use crate::requests::{AnonymousSenderTag, RepliableMessageContent, ReplyMessageContent}; use crate::{ReplySurb, SurbEncryptionKey}; - use nym_crypto::asymmetric::{encryption, identity}; + use nym_crypto::asymmetric::{ed25519, x25519}; use nym_sphinx_addressing::clients::Recipient; use nym_sphinx_types::{ Delay, Destination, DestinationAddressBytes, Node, NodeAddressBytes, PrivateKey, @@ -515,9 +515,9 @@ mod tests { } pub(super) fn recipient(rng: &mut ChaCha20Rng) -> Recipient { - let client_id = identity::KeyPair::new(rng); - let client_enc = encryption::KeyPair::new(rng); - let gateway_id = identity::KeyPair::new(rng); + let client_id = ed25519::KeyPair::new(rng); + let client_enc = x25519::KeyPair::new(rng); + let gateway_id = ed25519::KeyPair::new(rng); Recipient::new( *client_id.public_key(), diff --git a/common/nymsphinx/src/message.rs b/common/nymsphinx/src/message.rs index c87bd05b51..666b2f9336 100644 --- a/common/nymsphinx/src/message.rs +++ b/common/nymsphinx/src/message.rs @@ -2,7 +2,7 @@ // SPDX-License-Identifier: Apache-2.0 use crate::chunking; -use nym_crypto::asymmetric::encryption; +use nym_crypto::asymmetric::x25519; use nym_crypto::Digest; use nym_sphinx_addressing::clients::Recipient; use nym_sphinx_addressing::nodes::MAX_NODE_ADDRESS_UNPADDED_LEN; @@ -184,7 +184,7 @@ impl NymMessage { // each plain or repliable packet attaches an ephemeral public key so that the recipient // could perform diffie-hellman with its own keys followed by a kdf to re-derive // the packet encryption key - NymMessage::Plain(_) | NymMessage::Repliable(_) => encryption::PUBLIC_KEY_SIZE, + NymMessage::Plain(_) | NymMessage::Repliable(_) => x25519::PUBLIC_KEY_SIZE, // each reply attaches the digest of the encryption key so that the recipient could // lookup correct key for decryption, NymMessage::Reply(_) => ReplySurbKeyDigestAlgorithm::output_size(), diff --git a/common/nymsphinx/src/preparer/mod.rs b/common/nymsphinx/src/preparer/mod.rs index 0d4c75c2ca..0d7915ea14 100644 --- a/common/nymsphinx/src/preparer/mod.rs +++ b/common/nymsphinx/src/preparer/mod.rs @@ -4,7 +4,7 @@ use crate::message::{NymMessage, ACK_OVERHEAD, OUTFOX_ACK_OVERHEAD}; use crate::NymPayloadBuilder; use log::debug; -use nym_crypto::asymmetric::encryption; +use nym_crypto::asymmetric::x25519; use nym_crypto::Digest; use nym_sphinx_acknowledgements::surb_ack::SurbAck; use nym_sphinx_acknowledgements::AckKey; @@ -190,7 +190,7 @@ pub trait FragmentPreparer { let destination = packet_recipient.gateway(); monitoring::fragment_sent(&fragment, self.nonce(), destination); - let non_reply_overhead = encryption::PUBLIC_KEY_SIZE; + let non_reply_overhead = x25519::PUBLIC_KEY_SIZE; let expected_plaintext = match packet_type { PacketType::Outfox => { fragment.serialized_size() + OUTFOX_ACK_OVERHEAD + non_reply_overhead diff --git a/common/nymsphinx/src/preparer/payload.rs b/common/nymsphinx/src/preparer/payload.rs index bfd1715d57..0ea0a069c5 100644 --- a/common/nymsphinx/src/preparer/payload.rs +++ b/common/nymsphinx/src/preparer/payload.rs @@ -2,7 +2,7 @@ // SPDX-License-Identifier: Apache-2.0 use nym_crypto::aes::cipher::{KeyIvInit, StreamCipher}; -use nym_crypto::asymmetric::encryption; +use nym_crypto::asymmetric::x25519; use nym_crypto::shared_key::new_ephemeral_shared_key; use nym_crypto::symmetric::stream_cipher; use nym_crypto::symmetric::stream_cipher::CipherKey; @@ -67,7 +67,7 @@ impl NymPayloadBuilder { pub fn build_regular( self, rng: &mut R, - recipient_encryption_key: &encryption::PublicKey, + recipient_encryption_key: &x25519::PublicKey, ) -> Result where R: RngCore + CryptoRng, diff --git a/common/nymsphinx/src/receiver.rs b/common/nymsphinx/src/receiver.rs index f2f3feadd9..d99637c88b 100644 --- a/common/nymsphinx/src/receiver.rs +++ b/common/nymsphinx/src/receiver.rs @@ -3,7 +3,7 @@ use crate::message::{NymMessage, NymMessageError, PaddedMessage, PlainMessage}; use nym_crypto::aes::cipher::{KeyIvInit, StreamCipher}; -use nym_crypto::asymmetric::encryption; +use nym_crypto::asymmetric::x25519; use nym_crypto::shared_key::recompute_shared_key; use nym_crypto::symmetric::stream_cipher; use nym_crypto::symmetric::stream_cipher::CipherKey; @@ -62,7 +62,7 @@ pub enum MessageRecoveryError { NotEnoughBytesForEphemeralKey { provided: usize, required: usize }, #[error("Recovered remote x25519 public key is invalid - {0}")] - InvalidRemoteEphemeralKey(#[from] encryption::KeyRecoveryError), + InvalidRemoteEphemeralKey(#[from] x25519::KeyRecoveryError), #[error("The reconstructed message was malformed - {source}")] MalformedReconstructedMessage { @@ -100,19 +100,19 @@ pub trait MessageReceiver { fn recover_plaintext_from_regular_packet<'a>( &self, - local_key: &encryption::PrivateKey, + local_key: &x25519::PrivateKey, raw_enc_frag: &'a mut [u8], ) -> Result<&'a mut [u8], MessageRecoveryError> { - if raw_enc_frag.len() < encryption::PUBLIC_KEY_SIZE { + if raw_enc_frag.len() < x25519::PUBLIC_KEY_SIZE { return Err(MessageRecoveryError::NotEnoughBytesForEphemeralKey { provided: raw_enc_frag.len(), - required: encryption::PUBLIC_KEY_SIZE, + required: x25519::PUBLIC_KEY_SIZE, }); } // 1. recover remote encryption key - let remote_key_bytes = &raw_enc_frag[..encryption::PUBLIC_KEY_SIZE]; - let remote_ephemeral_key = encryption::PublicKey::from_bytes(remote_key_bytes)?; + let remote_key_bytes = &raw_enc_frag[..x25519::PUBLIC_KEY_SIZE]; + let remote_ephemeral_key = x25519::PublicKey::from_bytes(remote_key_bytes)?; // 2. recompute shared encryption key let encryption_key = recompute_shared_key::( @@ -121,7 +121,7 @@ pub trait MessageReceiver { ); // 3. decrypt fragment data - let fragment_ciphertext = &mut raw_enc_frag[encryption::PUBLIC_KEY_SIZE..]; + let fragment_ciphertext = &mut raw_enc_frag[x25519::PUBLIC_KEY_SIZE..]; self.decrypt_raw_message::( fragment_ciphertext, diff --git a/common/types/src/monitoring.rs b/common/types/src/monitoring.rs index 09024caaa8..11d7a3f937 100644 --- a/common/types/src/monitoring.rs +++ b/common/types/src/monitoring.rs @@ -1,4 +1,4 @@ -use nym_crypto::asymmetric::identity::{PrivateKey, PublicKey, Signature}; +use nym_crypto::asymmetric::ed25519::{PrivateKey, PublicKey, Signature}; use nym_mixnet_contract_common::NodeId; use schemars::JsonSchema; use serde::{Deserialize, Serialize}; diff --git a/common/verloc/src/measurements/listener.rs b/common/verloc/src/measurements/listener.rs index 09cf483179..cc74cf8984 100644 --- a/common/verloc/src/measurements/listener.rs +++ b/common/verloc/src/measurements/listener.rs @@ -5,7 +5,7 @@ use crate::error::VerlocError; use crate::measurements::packet::{EchoPacket, ReplyPacket}; use bytes::{BufMut, BytesMut}; use futures::StreamExt; -use nym_crypto::asymmetric::identity; +use nym_crypto::asymmetric::ed25519; use nym_task::ShutdownToken; use std::net::SocketAddr; use std::sync::Arc; @@ -25,7 +25,7 @@ pub struct PacketListener { impl PacketListener { pub fn new( address: SocketAddr, - identity: Arc, + identity: Arc, shutdown_token: ShutdownToken, ) -> Self { PacketListener { @@ -75,7 +75,7 @@ impl PacketListener { } struct ConnectionHandler { - identity: Arc, + identity: Arc, } impl ConnectionHandler { diff --git a/common/verloc/src/measurements/measurer.rs b/common/verloc/src/measurements/measurer.rs index 573a2f0258..5831551363 100644 --- a/common/verloc/src/measurements/measurer.rs +++ b/common/verloc/src/measurements/measurer.rs @@ -7,7 +7,7 @@ use crate::measurements::{Config, PacketListener, PacketSender}; use crate::models::VerlocNodeResult; use futures::stream::FuturesUnordered; use futures::StreamExt; -use nym_crypto::asymmetric::identity; +use nym_crypto::asymmetric::ed25519; use nym_task::ShutdownToken; use nym_validator_client::models::NymNodeDescription; use nym_validator_client::NymApiClient; @@ -30,7 +30,7 @@ pub struct VerlocMeasurer { impl VerlocMeasurer { pub fn new( config: Config, - identity: Arc, + identity: Arc, shutdown_token: ShutdownToken, ) -> Self { VerlocMeasurer { diff --git a/common/wasm/client-core/src/error.rs b/common/wasm/client-core/src/error.rs index 55f5d3979d..8066a9f2bb 100644 --- a/common/wasm/client-core/src/error.rs +++ b/common/wasm/client-core/src/error.rs @@ -5,7 +5,7 @@ use crate::storage::wasm_client_traits::WasmClientStorageError; use crate::topology::WasmTopologyError; use nym_client_core::client::base_client::storage::gateways_storage::BadGateway; use nym_client_core::error::ClientCoreError; -use nym_crypto::asymmetric::identity::Ed25519RecoveryError; +use nym_crypto::asymmetric::ed25519::Ed25519RecoveryError; use nym_gateway_client::error::GatewayClientError; use nym_sphinx::addressing::clients::RecipientFormattingError; use nym_sphinx::anonymous_replies::requests::InvalidAnonymousSenderTagRepresentation; diff --git a/common/wasm/client-core/src/storage/wasm_client_traits.rs b/common/wasm/client-core/src/storage/wasm_client_traits.rs index 1353112885..8cc7edc87a 100644 --- a/common/wasm/client-core/src/storage/wasm_client_traits.rs +++ b/common/wasm/client-core/src/storage/wasm_client_traits.rs @@ -4,7 +4,7 @@ use crate::storage::types::WasmRawRegisteredGateway; use async_trait::async_trait; use nym_client_core::client::base_client::storage::gateways_storage::RawActiveGateway; -use nym_crypto::asymmetric::{encryption, identity}; +use nym_crypto::asymmetric::{ed25519, x25519}; use nym_sphinx_acknowledgements::AckKey; use std::error::Error; use thiserror::Error; @@ -60,7 +60,7 @@ pub trait WasmClientStorage: BaseWasmStorage { async fn may_read_identity_keypair( &self, - ) -> Result, ::StorageError> { + ) -> Result, ::StorageError> { self.read_value( v1::KEYS_STORE, JsValue::from_str(v1::ED25519_IDENTITY_KEYPAIR), @@ -71,7 +71,7 @@ pub trait WasmClientStorage: BaseWasmStorage { async fn may_read_encryption_keypair( &self, - ) -> Result, ::StorageError> { + ) -> Result, ::StorageError> { self.read_value( v1::KEYS_STORE, JsValue::from_str(v1::X25519_ENCRYPTION_KEYPAIR), @@ -90,7 +90,7 @@ pub trait WasmClientStorage: BaseWasmStorage { async fn must_read_identity_keypair( &self, - ) -> Result::StorageError> { + ) -> Result::StorageError> { self.may_read_identity_keypair() .await? .ok_or(WasmClientStorageError::CryptoKeyNotInStorage { @@ -101,7 +101,7 @@ pub trait WasmClientStorage: BaseWasmStorage { async fn must_read_encryption_keypair( &self, - ) -> Result::StorageError> { + ) -> Result::StorageError> { self.may_read_encryption_keypair() .await? .ok_or(WasmClientStorageError::CryptoKeyNotInStorage { @@ -130,7 +130,7 @@ pub trait WasmClientStorage: BaseWasmStorage { async fn store_identity_keypair( &self, - keypair: &identity::KeyPair, + keypair: &ed25519::KeyPair, ) -> Result<(), ::StorageError> { self.store_value( v1::KEYS_STORE, @@ -143,7 +143,7 @@ pub trait WasmClientStorage: BaseWasmStorage { async fn store_encryption_keypair( &self, - keypair: &encryption::KeyPair, + keypair: &x25519::KeyPair, ) -> Result<(), ::StorageError> { self.store_value( v1::KEYS_STORE, diff --git a/common/wireguard/src/lib.rs b/common/wireguard/src/lib.rs index f397a3bbea..3858d476bc 100644 --- a/common/wireguard/src/lib.rs +++ b/common/wireguard/src/lib.rs @@ -7,7 +7,7 @@ // #![warn(clippy::unwrap_used)] use defguard_wireguard_rs::WGApi; -use nym_crypto::asymmetric::encryption::KeyPair; +use nym_crypto::asymmetric::x25519::KeyPair; use nym_wireguard_types::Config; use peer_controller::PeerControlRequest; use std::sync::Arc; diff --git a/contracts/mixnet-vesting-integration-tests/src/support/setup.rs b/contracts/mixnet-vesting-integration-tests/src/support/setup.rs index f1d0328f69..90aa13526f 100644 --- a/contracts/mixnet-vesting-integration-tests/src/support/setup.rs +++ b/contracts/mixnet-vesting-integration-tests/src/support/setup.rs @@ -8,7 +8,7 @@ use crate::support::helpers::{ use cosmwasm_std::{coins, Addr, Coin, Decimal, Timestamp}; use cw_multi_test::{App, AppBuilder, Executor}; use nym_contracts_common::signing::{ContractMessageContent, MessageSignature, Nonce}; -use nym_crypto::asymmetric::identity; +use nym_crypto::asymmetric::ed25519; use nym_mixnet_contract_common::nym_node::{EpochAssignmentResponse, Role, RolesMetadataResponse}; use nym_mixnet_contract_common::reward_params::{NodeRewardingParameters, Performance}; use nym_mixnet_contract_common::{ @@ -376,9 +376,9 @@ impl TestSetup { ) .unwrap(); - let keypair = identity::KeyPair::new(&mut self.rng); + let keypair = ed25519::KeyPair::new(&mut self.rng); let identity_key = keypair.public_key().to_base58_string(); - let legit_sphinx_keys = nym_crypto::asymmetric::encryption::KeyPair::new(&mut self.rng); + let legit_sphinx_keys = nym_crypto::asymmetric::x25519::KeyPair::new(&mut self.rng); let mixnode = MixNode { identity_key, diff --git a/contracts/mixnet/src/mixnodes/transactions.rs b/contracts/mixnet/src/mixnodes/transactions.rs index 3daffbfb15..be1d0c6236 100644 --- a/contracts/mixnet/src/mixnodes/transactions.rs +++ b/contracts/mixnet/src/mixnodes/transactions.rs @@ -724,8 +724,8 @@ pub mod tests { let mut test = TestSetup::new(); let env = test.env(); - let keypair1 = nym_crypto::asymmetric::identity::KeyPair::new(&mut test.rng); - let keypair2 = nym_crypto::asymmetric::identity::KeyPair::new(&mut test.rng); + let keypair1 = nym_crypto::asymmetric::ed25519::KeyPair::new(&mut test.rng); + let keypair2 = nym_crypto::asymmetric::ed25519::KeyPair::new(&mut test.rng); let cost_params = fixtures::node_cost_params_fixture(); let mixnode1 = MixNode { @@ -733,7 +733,7 @@ pub mod tests { mix_port: 1234, verloc_port: 1234, http_api_port: 1234, - sphinx_key: nym_crypto::asymmetric::encryption::KeyPair::new(&mut test.rng) + sphinx_key: nym_crypto::asymmetric::x25519::KeyPair::new(&mut test.rng) .public_key() .to_base58_string(), identity_key: keypair1.public_key().to_base58_string(), @@ -742,7 +742,7 @@ pub mod tests { // change identity but reuse sphinx key let mut mixnode2 = mixnode1.clone(); - mixnode2.sphinx_key = nym_crypto::asymmetric::encryption::KeyPair::new(&mut test.rng) + mixnode2.sphinx_key = nym_crypto::asymmetric::x25519::KeyPair::new(&mut test.rng) .public_key() .to_base58_string(); diff --git a/contracts/mixnet/src/support/tests/mod.rs b/contracts/mixnet/src/support/tests/mod.rs index d19c800dd6..61974e0da3 100644 --- a/contracts/mixnet/src/support/tests/mod.rs +++ b/contracts/mixnet/src/support/tests/mod.rs @@ -85,8 +85,8 @@ pub mod test_helpers { use nym_contracts_common::signing::{ ContractMessageContent, MessageSignature, SignableMessage, SigningAlgorithm, SigningPurpose, }; - use nym_crypto::asymmetric::identity; - use nym_crypto::asymmetric::identity::KeyPair; + use nym_crypto::asymmetric::ed25519; + use nym_crypto::asymmetric::ed25519::KeyPair; use rand::distributions::WeightedIndex; use rand::prelude::*; use rand_chacha::rand_core::{CryptoRng, RngCore, SeedableRng}; @@ -701,7 +701,7 @@ pub mod test_helpers { &mut self, owner: &Addr, stake: Option, - ) -> (NodeId, identity::KeyPair) { + ) -> (NodeId, ed25519::KeyPair) { let (bond, _, keypair) = self.add_nymnode(owner, stake); (bond.node_id, keypair) } @@ -764,14 +764,14 @@ pub mod test_helpers { &mut self, owner: &Addr, stake: Option, - ) -> (NodeId, identity::KeyPair) { + ) -> (NodeId, ed25519::KeyPair) { let pledge = self.make_mix_pledge(stake).pop().unwrap(); let proxy = self.vesting_contract(); - let keypair = identity::KeyPair::new(&mut self.rng); + let keypair = ed25519::KeyPair::new(&mut self.rng); let identity_key = keypair.public_key().to_base58_string(); - let legit_sphinx_keys = nym_crypto::asymmetric::encryption::KeyPair::new(&mut self.rng); + let legit_sphinx_keys = nym_crypto::asymmetric::x25519::KeyPair::new(&mut self.rng); let mixnode = MixNode { identity_key, @@ -910,7 +910,7 @@ pub mod test_helpers { pub fn mixnode_bonding_signature( &mut self, - key: &identity::PrivateKey, + key: &ed25519::PrivateKey, owner: &Addr, mixnode: MixNode, stake: Option, @@ -924,7 +924,7 @@ pub mod test_helpers { &mut self, owner: &Addr, stake: Option, - ) -> (NodeId, identity::KeyPair) { + ) -> (NodeId, ed25519::KeyPair) { let stake = self.make_mix_pledge(stake); let (mixnode, _, keypair) = self.mixnode_with_signature(owner, Some(stake.clone())); @@ -954,7 +954,7 @@ pub mod test_helpers { ) -> (NymNode, MessageSignature, KeyPair) { let stake = stake.unwrap_or(good_node_plegge()); - let keypair = identity::KeyPair::new(&mut self.rng); + let keypair = ed25519::KeyPair::new(&mut self.rng); let identity_key = keypair.public_key().to_base58_string(); let node = NymNode { @@ -975,9 +975,9 @@ pub mod test_helpers { ) -> (MixNode, MessageSignature, KeyPair) { let stake = stake.unwrap_or(good_mixnode_pledge()); - let keypair = identity::KeyPair::new(&mut self.rng); + let keypair = ed25519::KeyPair::new(&mut self.rng); let identity_key = keypair.public_key().to_base58_string(); - let legit_sphinx_keys = nym_crypto::asymmetric::encryption::KeyPair::new(&mut self.rng); + let legit_sphinx_keys = nym_crypto::asymmetric::x25519::KeyPair::new(&mut self.rng); let mixnode = MixNode { identity_key, @@ -997,9 +997,9 @@ pub mod test_helpers { ) -> (Gateway, MessageSignature) { let stake = stake.unwrap_or(good_gateway_pledge()); - let keypair = identity::KeyPair::new(&mut self.rng); + let keypair = ed25519::KeyPair::new(&mut self.rng); let identity_key = keypair.public_key().to_base58_string(); - let legit_sphinx_keys = nym_crypto::asymmetric::encryption::KeyPair::new(&mut self.rng); + let legit_sphinx_keys = nym_crypto::asymmetric::x25519::KeyPair::new(&mut self.rng); let gateway = Gateway { identity_key, @@ -1530,7 +1530,7 @@ pub mod test_helpers { pub fn ed25519_sign_message( message: SignableMessage, - private_key: &identity::PrivateKey, + private_key: &ed25519::PrivateKey, ) -> MessageSignature { match message.algorithm { SigningAlgorithm::Ed25519 => { diff --git a/gateway/src/node/client_handling/websocket/common_state.rs b/gateway/src/node/client_handling/websocket/common_state.rs index fc66e855be..7f4d66c828 100644 --- a/gateway/src/node/client_handling/websocket/common_state.rs +++ b/gateway/src/node/client_handling/websocket/common_state.rs @@ -3,7 +3,7 @@ use crate::node::ActiveClientsStore; use nym_credential_verification::{ecash::EcashManager, BandwidthFlushingBehaviourConfig}; -use nym_crypto::asymmetric::identity; +use nym_crypto::asymmetric::ed25519; use nym_gateway_storage::GatewayStorage; use nym_mixnet_client::forwarder::MixForwardingSender; use nym_node_metrics::events::MetricEventsSender; @@ -24,7 +24,7 @@ pub(crate) struct CommonHandlerState { pub(crate) cfg: Config, pub(crate) ecash_verifier: Arc, pub(crate) storage: GatewayStorage, - pub(crate) local_identity: Arc, + pub(crate) local_identity: Arc, pub(crate) metrics: NymNodeMetrics, pub(crate) metrics_sender: MetricEventsSender, pub(crate) outbound_mix_sender: MixForwardingSender, diff --git a/nym-api/src/ecash/deposit.rs b/nym-api/src/ecash/deposit.rs index 9118e9d3af..0d40445474 100644 --- a/nym-api/src/ecash/deposit.rs +++ b/nym-api/src/ecash/deposit.rs @@ -49,7 +49,7 @@ mod test { assert!(matches!( err, EcashError::Ed25519ParseError( - nym_crypto::asymmetric::identity::Ed25519RecoveryError::MalformedPublicKeyString { .. } + nym_crypto::asymmetric::ed25519::Ed25519RecoveryError::MalformedPublicKeyString { .. } ) )); diff --git a/nym-api/src/ecash/dkg/controller/mod.rs b/nym-api/src/ecash/dkg/controller/mod.rs index 56d380bb1d..51e0df1586 100644 --- a/nym-api/src/ecash/dkg/controller/mod.rs +++ b/nym-api/src/ecash/dkg/controller/mod.rs @@ -9,7 +9,7 @@ use crate::nyxd; use crate::support::config; use anyhow::{bail, Result}; use nym_coconut_dkg_common::types::{Epoch, EpochId, EpochState}; -use nym_crypto::asymmetric::identity; +use nym_crypto::asymmetric::ed25519; use nym_dkg::bte::keys::KeyPair as DkgKeyPair; use nym_task::{TaskClient, TaskManager}; use rand::rngs::OsRng; @@ -37,7 +37,7 @@ impl DkgController { nyxd_client: nyxd::Client, coconut_keypair: CoconutKeyPair, dkg_keypair: DkgKeyPair, - identity_key: identity::PublicKey, + identity_key: ed25519::PublicKey, rng: R, ) -> Result { let Some(announce_address) = &config.announce_address else { @@ -312,7 +312,7 @@ impl DkgController { nyxd_client: nyxd::Client, coconut_keypair: CoconutKeyPair, dkg_bte_keypair: DkgKeyPair, - identity_key: identity::PublicKey, + identity_key: ed25519::PublicKey, rng: R, shutdown: &TaskManager, ) -> Result<()> diff --git a/nym-api/src/ecash/dkg/state/mod.rs b/nym-api/src/ecash/dkg/state/mod.rs index 065cdb3f24..e329513bd4 100644 --- a/nym-api/src/ecash/dkg/state/mod.rs +++ b/nym-api/src/ecash/dkg/state/mod.rs @@ -12,7 +12,7 @@ use crate::ecash::keys::{KeyPair as CoconutKeyPair, KeyPairWithEpoch}; use cosmwasm_std::Addr; use nym_coconut_dkg_common::dealer::DealerDetails; use nym_coconut_dkg_common::types::EpochId; -use nym_crypto::asymmetric::identity; +use nym_crypto::asymmetric::ed25519; use nym_dkg::bte::keys::KeyPair as DkgKeyPair; use nym_dkg::{bte, NodeIndex, Threshold}; use serde::{Deserialize, Serialize}; @@ -108,7 +108,7 @@ pub(crate) struct State { announce_address: Url, - identity_key: identity::PublicKey, + identity_key: ed25519::PublicKey, dkg_keypair: DkgKeyPair, @@ -121,7 +121,7 @@ impl State { persistent_state: PersistentState, announce_address: Url, dkg_keypair: DkgKeyPair, - identity_key: identity::PublicKey, + identity_key: ed25519::PublicKey, coconut_keypair: CoconutKeyPair, ) -> Self { State { @@ -339,7 +339,7 @@ impl State { &self.announce_address } - pub fn identity_key(&self) -> identity::PublicKey { + pub fn identity_key(&self) -> ed25519::PublicKey { self.identity_key } diff --git a/nym-api/src/ecash/error.rs b/nym-api/src/ecash/error.rs index a201db3a96..5e4c0e6e89 100644 --- a/nym-api/src/ecash/error.rs +++ b/nym-api/src/ecash/error.rs @@ -5,8 +5,8 @@ use crate::node_status_api::models::NymApiStorageError; use nym_coconut_dkg_common::types::{ChunkIndex, DealingIndex, EpochId}; use nym_credentials_interface::UnknownTicketType; use nym_crypto::asymmetric::{ - encryption::KeyRecoveryError, - identity::{Ed25519RecoveryError, SignatureError}, + ed25519::{Ed25519RecoveryError, SignatureError}, + x25519::KeyRecoveryError, }; use nym_dkg::error::DkgError; use nym_dkg::Threshold; diff --git a/nym-api/src/ecash/state/local.rs b/nym-api/src/ecash/state/local.rs index 93cc576a85..b9e54ec711 100644 --- a/nym-api/src/ecash/state/local.rs +++ b/nym-api/src/ecash/state/local.rs @@ -9,7 +9,7 @@ use crate::ecash::helpers::{ use crate::ecash::keys::KeyPair; use crate::ecash::storage::models::IssuedHash; use nym_api_requests::ecash::models::{CommitedDeposit, DepositId}; -use nym_crypto::asymmetric::identity; +use nym_crypto::asymmetric::ed25519; use nym_ticketbooks_merkle::{ IssuedTicketbook, IssuedTicketbooksFullMerkleProof, IssuedTicketbooksMerkleTree, MerkleLeaf, }; @@ -134,7 +134,7 @@ impl DailyMerkleTree { pub(crate) struct LocalEcashState { pub(crate) ecash_keypair: KeyPair, - pub(crate) identity_keypair: identity::KeyPair, + pub(crate) identity_keypair: ed25519::KeyPair, pub(crate) explicitly_disabled: bool, @@ -152,7 +152,7 @@ pub(crate) struct LocalEcashState { impl LocalEcashState { pub(crate) fn new( ecash_keypair: KeyPair, - identity_keypair: identity::KeyPair, + identity_keypair: ed25519::KeyPair, explicitly_disabled: bool, ) -> Self { LocalEcashState { diff --git a/nym-api/src/ecash/state/mod.rs b/nym-api/src/ecash/state/mod.rs index 375b89ebc0..d9ac0e5dce 100644 --- a/nym-api/src/ecash/state/mod.rs +++ b/nym-api/src/ecash/state/mod.rs @@ -39,7 +39,7 @@ use nym_compact_ecash::{ }; use nym_credentials::ecash::utils::EcashTime; use nym_credentials::{aggregate_verification_keys, CredentialSpendingData}; -use nym_crypto::asymmetric::identity; +use nym_crypto::asymmetric::ed25519; use nym_ecash_contract_common::deposit::{Deposit, DepositId}; use nym_ecash_contract_common::msg::ExecuteMsg; use nym_ecash_contract_common::redeem_credential::BATCH_REDEMPTION_PROPOSAL_TITLE; @@ -123,7 +123,7 @@ impl EcashState { global_config: &Config, contract_address: AccountId, client: C, - identity_keypair: identity::KeyPair, + identity_keypair: ed25519::KeyPair, key_pair: KeyPair, comm_channel: D, storage: NymApiStorage, diff --git a/nym-api/src/ecash/tests/fixtures.rs b/nym-api/src/ecash/tests/fixtures.rs index b49b9fc17e..a23cf4ea9e 100644 --- a/nym-api/src/ecash/tests/fixtures.rs +++ b/nym-api/src/ecash/tests/fixtures.rs @@ -12,7 +12,7 @@ use cosmwasm_std::Addr; use nym_coconut_dkg_common::dealer::DealerRegistrationDetails; use nym_coconut_dkg_common::types::{DealerDetails, EpochId}; use nym_compact_ecash::VerificationKeyAuth; -use nym_crypto::asymmetric::identity; +use nym_crypto::asymmetric::ed25519; use nym_dkg::bte::keys::KeyPair as DkgKeyPair; use nym_dkg::{NodeIndex, Threshold}; use nym_validator_client::nyxd::AccountId; @@ -38,7 +38,7 @@ pub fn dealer_fixture(rng: &mut ChaCha20Rng, id: NodeIndex) -> DealerDetails { let keypair = DkgKeyPair::new(dkg::params(), rng.clone()); let addr = pseudorandom_account(rng); - let identity_keypair = identity::KeyPair::new(rng); + let identity_keypair = ed25519::KeyPair::new(rng); let bte_public_key_with_proof = bs58::encode(&keypair.public_key().to_bytes()).into_string(); let port = 8080 + id; @@ -146,7 +146,7 @@ impl TestingDkgControllerBuilder { let mut secondary_seed = [0u8; 32]; rng.fill_bytes(&mut secondary_seed); - let identity_keypair = identity::KeyPair::new(&mut test_rng(secondary_seed)); + let identity_keypair = ed25519::KeyPair::new(&mut test_rng(secondary_seed)); DealerDetails { address: Addr::unchecked(address.as_ref()), diff --git a/nym-api/src/ecash/tests/mod.rs b/nym-api/src/ecash/tests/mod.rs index d5f43bbbe4..443e68c7e0 100644 --- a/nym-api/src/ecash/tests/mod.rs +++ b/nym-api/src/ecash/tests/mod.rs @@ -51,7 +51,7 @@ use nym_config::defaults::{NymNetworkDetails, ValidatorDetails}; use nym_contracts_common::IdentityKey; use nym_credentials::IssuanceTicketBook; use nym_credentials_interface::TicketType; -use nym_crypto::asymmetric::{ed25519, identity}; +use nym_crypto::asymmetric::ed25519; use nym_dkg::{NodeIndex, Threshold}; use nym_ecash_contract_common::blacklist::{BlacklistedAccountResponse, Blacklisting}; use nym_ecash_contract_common::deposit::{Deposit, DepositId, DepositResponse}; @@ -1191,7 +1191,7 @@ impl super::comm::APICommunicationChannel for DummyCommunicationChannel { #[allow(dead_code)] pub fn deposit_fixture() -> Deposit { let mut rng = OsRng; - let identity_keypair = identity::KeyPair::new(&mut rng); + let identity_keypair = ed25519::KeyPair::new(&mut rng); Deposit { bs58_encoded_ed25519_pubkey: identity_keypair.public_key().to_base58_string(), @@ -1239,17 +1239,17 @@ pub fn voucher_fixture(deposit_id: Option) -> IssuanceTicketBook { let mut rng = OsRng; let deposit_id = deposit_id.unwrap_or(69); - let identity_keypair = identity::KeyPair::new(&mut rng); + let identity_keypair = ed25519::KeyPair::new(&mut rng); let id_priv = - identity::PrivateKey::from_bytes(&identity_keypair.private_key().to_bytes()).unwrap(); + ed25519::PrivateKey::from_bytes(&identity_keypair.private_key().to_bytes()).unwrap(); let identifier = [44u8; 32]; // (voucher, request) IssuanceTicketBook::new(deposit_id, identifier, id_priv, TicketType::V1MixnetEntry) } #[allow(unused)] -fn dummy_signature() -> identity::Signature { +fn dummy_signature() -> ed25519::Signature { "3vUCc6MCN5AC2LNgDYjRB1QeErZSN1S8f6K14JHjpUcKWXbjGYFExA8DbwQQBki9gyUqrpBF94Drttb4eMcGQXkp" .parse() .unwrap() @@ -1293,7 +1293,7 @@ impl TestFixture { async fn new() -> Self { let mut rng = crate::ecash::tests::fixtures::test_rng([69u8; 32]); let coconut_keypair = ttp_keygen(1, 1).unwrap().remove(0); - let identity = identity::KeyPair::new(&mut rng); + let identity = ed25519::KeyPair::new(&mut rng); let epoch = Arc::new(AtomicU64::new(1)); let address = AccountId::from_str(TEST_REWARDING_VALIDATOR_ADDRESS).unwrap(); let comm_channel = DummyCommunicationChannel::new_single_dummy( @@ -1534,7 +1534,7 @@ mod credential_tests { #[tokio::test] async fn state_functions() { let mut rng = OsRng; - let identity = identity::KeyPair::new(&mut rng); + let identity = ed25519::KeyPair::new(&mut rng); let address = AccountId::from_str(TEST_REWARDING_VALIDATOR_ADDRESS).unwrap(); let nyxd_client = DummyClient::new(address.clone(), Default::default()); @@ -1672,12 +1672,12 @@ mod credential_tests { let deposit_id = 42; let mut rng = OsRng; - let identity_keypair = identity::KeyPair::new(&mut rng); + let identity_keypair = ed25519::KeyPair::new(&mut rng); let identifier = [42u8; 32]; let voucher = IssuanceTicketBook::new( deposit_id, identifier, - identity::PrivateKey::from_base58_string( + ed25519::PrivateKey::from_base58_string( identity_keypair.private_key().to_base58_string(), ) .unwrap(), diff --git a/nym-api/src/network_monitor/gateways_reader.rs b/nym-api/src/network_monitor/gateways_reader.rs index bc3eeaa44c..50e5f7ff5f 100644 --- a/nym-api/src/network_monitor/gateways_reader.rs +++ b/nym-api/src/network_monitor/gateways_reader.rs @@ -2,7 +2,7 @@ // SPDX-License-Identifier: GPL-3.0-only use futures::Stream; -use nym_crypto::asymmetric::{ed25519, identity}; +use nym_crypto::asymmetric::ed25519; use nym_gateway_client::{AcknowledgementReceiver, MixnetMessageReceiver}; use std::pin::Pin; use std::task::{Context, Poll}; @@ -28,7 +28,7 @@ impl GatewaysReader { pub fn add_receivers( &mut self, - id: identity::PublicKey, + id: ed25519::PublicKey, message_receiver: MixnetMessageReceiver, ack_receiver: AcknowledgementReceiver, ) { diff --git a/nym-api/src/network_monitor/mod.rs b/nym-api/src/network_monitor/mod.rs index a7f9391fe2..32028b263a 100644 --- a/nym-api/src/network_monitor/mod.rs +++ b/nym-api/src/network_monitor/mod.rs @@ -21,7 +21,7 @@ use crate::support::nyxd; use futures::channel::mpsc; use nym_bandwidth_controller::BandwidthController; use nym_credential_storage::persistent_storage::PersistentStorage; -use nym_crypto::asymmetric::{encryption, identity}; +use nym_crypto::asymmetric::{ed25519, x25519}; use nym_sphinx::acknowledgements::AckKey; use nym_sphinx::params::PacketType; use nym_sphinx::receiver::MessageReceiver; @@ -90,8 +90,8 @@ impl<'a> NetworkMonitorBuilder<'a> { // in the future let mut rng = rand::rngs::OsRng; - let identity_keypair = Arc::new(identity::KeyPair::new(&mut rng)); - let encryption_keypair = Arc::new(encryption::KeyPair::new(&mut rng)); + let identity_keypair = Arc::new(ed25519::KeyPair::new(&mut rng)); + let encryption_keypair = Arc::new(x25519::KeyPair::new(&mut rng)); let ack_key = Arc::new(AckKey::new(&mut rng)); let (gateway_status_update_sender, gateway_status_update_receiver) = mpsc::unbounded(); @@ -183,8 +183,8 @@ fn new_packet_preparer( node_status_cache: NodeStatusCache, per_node_test_packets: usize, ack_key: Arc, - self_public_identity: identity::PublicKey, - self_public_encryption: encryption::PublicKey, + self_public_identity: ed25519::PublicKey, + self_public_encryption: x25519::PublicKey, ) -> PacketPreparer { PacketPreparer::new( contract_cache, @@ -200,7 +200,7 @@ fn new_packet_preparer( fn new_packet_sender( config: &Config, gateways_status_updater: GatewayClientUpdateSender, - local_identity: Arc, + local_identity: Arc, bandwidth_controller: BandwidthController, ) -> PacketSender { PacketSender::new( @@ -213,7 +213,7 @@ fn new_packet_sender( fn new_received_processor( packets_receiver: ReceivedProcessorReceiver, - client_encryption_keypair: Arc, + client_encryption_keypair: Arc, ack_key: Arc, ) -> ReceivedProcessor { ReceivedProcessor::new(packets_receiver, client_encryption_keypair, ack_key) diff --git a/nym-api/src/network_monitor/monitor/preparer.rs b/nym-api/src/network_monitor/monitor/preparer.rs index 433288c4a2..69c509b8c7 100644 --- a/nym-api/src/network_monitor/monitor/preparer.rs +++ b/nym-api/src/network_monitor/monitor/preparer.rs @@ -11,7 +11,7 @@ use crate::support::legacy_helpers::legacy_host_to_ips_and_hostname; use nym_api_requests::legacy::{LegacyGatewayBondWithId, LegacyMixNodeBondWithLayer}; use nym_api_requests::models::{NodeAnnotation, NymNodeDescription}; use nym_contracts_common::NaiveFloat; -use nym_crypto::asymmetric::{encryption, identity}; +use nym_crypto::asymmetric::{ed25519, x25519}; use nym_mixnet_contract_common::{LegacyMixLayer, NodeId}; use nym_node_tester_utils::node::{NodeType, TestableNode}; use nym_node_tester_utils::NodeTester; @@ -89,8 +89,8 @@ pub(crate) struct PacketPreparer { // in the future we should really create unique set of keys every time otherwise // gateways might recognise our "test" keys and take special care to always forward those packets // even if otherwise they are malicious. - self_public_identity: identity::PublicKey, - self_public_encryption: encryption::PublicKey, + self_public_identity: ed25519::PublicKey, + self_public_encryption: x25519::PublicKey, } impl PacketPreparer { @@ -100,8 +100,8 @@ impl PacketPreparer { node_status_cache: NodeStatusCache, per_node_test_packets: usize, ack_key: Arc, - self_public_identity: identity::PublicKey, - self_public_encryption: encryption::PublicKey, + self_public_identity: ed25519::PublicKey, + self_public_encryption: x25519::PublicKey, ) -> Self { PacketPreparer { contract_cache, @@ -223,9 +223,9 @@ impl PacketPreparer { node_id: bond.mix_id, mix_host: SocketAddr::new(*ips.first()?, bond.mix_node.mix_port), entry: None, - identity_key: identity::PublicKey::from_base58_string(&bond.mix_node.identity_key) + identity_key: ed25519::PublicKey::from_base58_string(&bond.mix_node.identity_key) .ok()?, - sphinx_key: encryption::PublicKey::from_base58_string(&bond.mix_node.sphinx_key) + sphinx_key: x25519::PublicKey::from_base58_string(&bond.mix_node.sphinx_key) .ok()?, supported_roles: SupportedRoles { mixnode: true, @@ -255,10 +255,9 @@ impl PacketPreparer { hostname, clients_wss_port: None, }), - identity_key: identity::PublicKey::from_base58_string(&bond.gateway.identity_key) - .ok()?, - sphinx_key: encryption::PublicKey::from_base58_string(&bond.gateway.sphinx_key) + identity_key: ed25519::PublicKey::from_base58_string(&bond.gateway.identity_key) .ok()?, + sphinx_key: x25519::PublicKey::from_base58_string(&bond.gateway.sphinx_key).ok()?, supported_roles: SupportedRoles { mixnode: false, mixnet_entry: true, diff --git a/nym-api/src/network_monitor/monitor/processor.rs b/nym-api/src/network_monitor/monitor/processor.rs index b69f919f74..5eb6f25a8a 100644 --- a/nym-api/src/network_monitor/monitor/processor.rs +++ b/nym-api/src/network_monitor/monitor/processor.rs @@ -7,7 +7,7 @@ use crate::network_monitor::ROUTE_TESTING_TEST_NONCE; use futures::channel::mpsc; use futures::lock::Mutex; use futures::StreamExt; -use nym_crypto::asymmetric::encryption; +use nym_crypto::asymmetric::x25519; use nym_node_tester_utils::error::NetworkTestingError; use nym_node_tester_utils::processor::TestPacketProcessor; use nym_sphinx::acknowledgements::AckKey; @@ -145,7 +145,7 @@ where { pub(crate) fn new( packets_receiver: ReceivedProcessorReceiver, - client_encryption_keypair: Arc, + client_encryption_keypair: Arc, ack_key: Arc, ) -> Self { let shared_data = SharedProcessorData { diff --git a/nym-api/src/network_monitor/monitor/receiver.rs b/nym-api/src/network_monitor/monitor/receiver.rs index a317b9985b..e84398b9b4 100644 --- a/nym-api/src/network_monitor/monitor/receiver.rs +++ b/nym-api/src/network_monitor/monitor/receiver.rs @@ -5,7 +5,7 @@ use crate::network_monitor::gateways_reader::{GatewayMessages, GatewaysReader}; use crate::network_monitor::monitor::processor::ReceivedProcessorSender; use futures::channel::mpsc; use futures::StreamExt; -use nym_crypto::asymmetric::identity; +use nym_crypto::asymmetric::ed25519; use nym_gateway_client::{AcknowledgementReceiver, MixnetMessageReceiver}; use nym_task::TaskClient; use tracing::{error, trace}; @@ -14,9 +14,9 @@ pub(crate) type GatewayClientUpdateSender = mpsc::UnboundedSender; pub(crate) enum GatewayClientUpdate { - Disconnect(identity::PublicKey), + Disconnect(ed25519::PublicKey), New( - identity::PublicKey, + ed25519::PublicKey, (MixnetMessageReceiver, AcknowledgementReceiver), ), } diff --git a/nym-api/src/network_monitor/test_route/mod.rs b/nym-api/src/network_monitor/test_route/mod.rs index d1384e851b..fd59a6419b 100644 --- a/nym-api/src/network_monitor/test_route/mod.rs +++ b/nym-api/src/network_monitor/test_route/mod.rs @@ -3,7 +3,7 @@ use crate::network_monitor::test_packet::NymApiTestMessageExt; use crate::network_monitor::ROUTE_TESTING_TEST_NONCE; -use nym_crypto::asymmetric::identity; +use nym_crypto::asymmetric::ed25519; use nym_mixnet_contract_common::nym_node::Role; use nym_mixnet_contract_common::{EpochId, EpochRewardedSet, RewardedSet}; use nym_topology::node::RoutingNode; @@ -80,7 +80,7 @@ impl TestRoute { self.gateway().ws_entry_address(false) } - pub(crate) fn gateway_identity(&self) -> identity::PublicKey { + pub(crate) fn gateway_identity(&self) -> ed25519::PublicKey { self.gateway().identity_key } diff --git a/nym-api/src/support/config/helpers.rs b/nym-api/src/support/config/helpers.rs index 8a6652e4f8..e1b1c53484 100644 --- a/nym-api/src/support/config/helpers.rs +++ b/nym-api/src/support/config/helpers.rs @@ -7,7 +7,7 @@ use crate::support::config::{ default_config_directory, default_data_directory, upgrade_helpers, Config, }; use anyhow::{Context, Result}; -use nym_crypto::asymmetric::identity; +use nym_crypto::asymmetric::ed25519; use rand::rngs::OsRng; use std::{fs, io}; @@ -20,7 +20,7 @@ fn init_identity_keys(config: &config::NymApiPaths) -> Result<()> { ); let mut rng = OsRng; - let keypair = identity::KeyPair::new(&mut rng); + let keypair = ed25519::KeyPair::new(&mut rng); nym_pemstore::store_keypair(&keypair, &keypaths) .context("failed to store identity keys of the nym api")?; Ok(()) diff --git a/nym-api/src/support/config/persistence.rs b/nym-api/src/support/config/persistence.rs index f2c98c038f..8e401457a5 100644 --- a/nym-api/src/support/config/persistence.rs +++ b/nym-api/src/support/config/persistence.rs @@ -3,7 +3,7 @@ use crate::support::config::default_data_directory; use anyhow::Context; -use nym_crypto::asymmetric::identity; +use nym_crypto::asymmetric::ed25519; use serde::{Deserialize, Serialize}; use std::path::{Path, PathBuf}; @@ -123,7 +123,7 @@ impl NymApiPaths { } } - pub fn load_identity(&self) -> anyhow::Result { + pub fn load_identity(&self) -> anyhow::Result { let keypaths = nym_pemstore::KeyPairPath::new( &self.private_identity_key_file, &self.public_identity_key_file, diff --git a/nym-network-monitor/src/main.rs b/nym-network-monitor/src/main.rs index e38fcefe8f..f285446a30 100644 --- a/nym-network-monitor/src/main.rs +++ b/nym-network-monitor/src/main.rs @@ -143,7 +143,7 @@ struct Args { fn generate_key_pair() -> Result<()> { let mut rng = rand::thread_rng(); - let keypair = nym_crypto::asymmetric::identity::KeyPair::new(&mut rng); + let keypair = nym_crypto::asymmetric::ed25519::KeyPair::new(&mut rng); let mut public_key_file = File::create("network-monitor-public")?; public_key_file.write_all(keypair.public_key().to_base58_string().as_bytes())?; diff --git a/nym-node-status-api/nym-node-status-agent/src/cli/generate_keypair.rs b/nym-node-status-api/nym-node-status-agent/src/cli/generate_keypair.rs index f769d3acb0..f3134685b8 100644 --- a/nym-node-status-api/nym-node-status-agent/src/cli/generate_keypair.rs +++ b/nym-node-status-api/nym-node-status-agent/src/cli/generate_keypair.rs @@ -4,7 +4,7 @@ use tracing::info; pub(crate) fn generate_key_pair(path: impl AsRef) -> anyhow::Result<()> { let priv_key_path = path.as_ref(); let mut rng = rand::thread_rng(); - let keypair = nym_crypto::asymmetric::identity::KeyPair::new(&mut rng); + let keypair = nym_crypto::asymmetric::ed25519::KeyPair::new(&mut rng); info!("Generated keypair as Base58-encoded string"); let mut private_key_file = File::create(priv_key_path)?; diff --git a/nym-node/nym-node-requests/src/api/mod.rs b/nym-node/nym-node-requests/src/api/mod.rs index 5e09d150b7..c2ae5badb4 100644 --- a/nym-node/nym-node-requests/src/api/mod.rs +++ b/nym-node/nym-node-requests/src/api/mod.rs @@ -3,7 +3,7 @@ use crate::api::v1::node::models::{LegacyHostInformation, LegacyHostInformationV2}; use crate::error::Error; -use nym_crypto::asymmetric::identity; +use nym_crypto::asymmetric::ed25519; use schemars::JsonSchema; use serde::{Deserialize, Serialize}; use std::fmt::{Display, Formatter}; @@ -35,7 +35,7 @@ pub struct SignedData { } impl SignedData { - pub fn new(data: T, key: &identity::PrivateKey) -> Result + pub fn new(data: T, key: &ed25519::PrivateKey) -> Result where T: Serialize, { @@ -44,7 +44,7 @@ impl SignedData { Ok(SignedData { data, signature }) } - pub fn verify(&self, key: &identity::PublicKey) -> bool + pub fn verify(&self, key: &ed25519::PublicKey) -> bool where T: Serialize, { @@ -52,7 +52,7 @@ impl SignedData { return false; }; - let Ok(signature) = identity::Signature::from_base58_string(&self.signature) else { + let Ok(signature) = ed25519::Signature::from_base58_string(&self.signature) else { return false; }; diff --git a/nym-node/src/cli/commands/sign.rs b/nym-node/src/cli/commands/sign.rs index a9326df24f..22ad977756 100644 --- a/nym-node/src/cli/commands/sign.rs +++ b/nym-node/src/cli/commands/sign.rs @@ -5,7 +5,7 @@ use crate::cli::helpers::ConfigArgs; use crate::config::upgrade_helpers::try_load_current_config; use crate::node::helpers::load_ed25519_identity_keypair; use nym_bin_common::output_format::OutputFormat; -use nym_crypto::asymmetric::identity; +use nym_crypto::asymmetric::ed25519; use nym_types::helpers::ConsoleSigningOutput; // I don't think it makes sense to expose 'text' and 'contract-msg' as env variables @@ -27,7 +27,7 @@ pub struct Args { output: OutputFormat, } -fn print_signed_text(private_key: &identity::PrivateKey, text: &str, output: OutputFormat) { +fn print_signed_text(private_key: &ed25519::PrivateKey, text: &str, output: OutputFormat) { eprintln!("Signing the text {text:?} using your node's Ed25519 identity key...",); let signature = private_key.sign_text(text); @@ -36,7 +36,7 @@ fn print_signed_text(private_key: &identity::PrivateKey, text: &str, output: Out } fn print_signed_contract_msg( - private_key: &identity::PrivateKey, + private_key: &ed25519::PrivateKey, raw_msg: &str, output: OutputFormat, ) { diff --git a/nym-node/src/config/old_configs/old_config_v1.rs b/nym-node/src/config/old_configs/old_config_v1.rs index b268ea86ab..ae8caf03db 100644 --- a/nym-node/src/config/old_configs/old_config_v1.rs +++ b/nym-node/src/config/old_configs/old_config_v1.rs @@ -6,7 +6,7 @@ use crate::config::*; use crate::error::KeyIOFailure; use nym_client_core_config_types::DebugConfig as ClientDebugConfig; use nym_config::serde_helpers::de_maybe_port; -use nym_crypto::asymmetric::encryption::KeyPair; +use nym_crypto::asymmetric::x25519::KeyPair; use nym_pemstore::store_keypair; use old_configs::old_config_v2::*; use rand::rngs::OsRng; diff --git a/nym-node/src/config/old_configs/old_config_v2.rs b/nym-node/src/config/old_configs/old_config_v2.rs index 712555b3b5..d1b1003caf 100644 --- a/nym-node/src/config/old_configs/old_config_v2.rs +++ b/nym-node/src/config/old_configs/old_config_v2.rs @@ -714,7 +714,7 @@ impl ConfigV2 { pub async fn initialise( paths: &AuthenticatorPathsV3, - public_key: nym_crypto::asymmetric::identity::PublicKey, + public_key: nym_crypto::asymmetric::ed25519::PublicKey, ) -> Result<(), NymNodeError> { let mut rng = OsRng; let ed25519_keys = ed25519::KeyPair::new(&mut rng); diff --git a/nym-node/src/error.rs b/nym-node/src/error.rs index cc5ef5444d..519f927e69 100644 --- a/nym-node/src/error.rs +++ b/nym-node/src/error.rs @@ -131,7 +131,7 @@ pub enum NymNodeError { #[error(transparent)] KeyRecoveryError { #[from] - source: nym_crypto::asymmetric::encryption::KeyRecoveryError, + source: nym_crypto::asymmetric::x25519::KeyRecoveryError, }, #[error(transparent)] diff --git a/nym-node/src/node/http/error.rs b/nym-node/src/node/http/error.rs index f63ed26f49..178e26fdcd 100644 --- a/nym-node/src/node/http/error.rs +++ b/nym-node/src/node/http/error.rs @@ -23,7 +23,7 @@ pub enum NymNodeHttpError { #[error(transparent)] KeyRecoveryError { #[from] - source: nym_crypto::asymmetric::encryption::KeyRecoveryError, + source: nym_crypto::asymmetric::x25519::KeyRecoveryError, }, #[error("error building or using HTTP client: {source}")] diff --git a/nym-wallet/src-tauri/src/error.rs b/nym-wallet/src-tauri/src/error.rs index 855f137d1a..e90d362ca6 100644 --- a/nym-wallet/src-tauri/src/error.rs +++ b/nym-wallet/src-tauri/src/error.rs @@ -1,5 +1,5 @@ use nym_contracts_common::signing::SigningAlgorithm; -use nym_crypto::asymmetric::identity::Ed25519RecoveryError; +use nym_crypto::asymmetric::ed25519::Ed25519RecoveryError; use nym_node_requests::api::client::NymNodeApiClientError; use nym_types::error::TypesError; use nym_validator_client::nym_api::error::NymAPIError; diff --git a/nym-wallet/src-tauri/src/operations/helpers.rs b/nym-wallet/src-tauri/src/operations/helpers.rs index c2267ccb20..fca8ce07c1 100644 --- a/nym-wallet/src-tauri/src/operations/helpers.rs +++ b/nym-wallet/src-tauri/src/operations/helpers.rs @@ -7,7 +7,7 @@ use cosmwasm_std::Addr; use nym_contracts_common::signing::{ ContractMessageContent, MessageSignature, Nonce, SignableMessage, SigningAlgorithm, }; -use nym_crypto::asymmetric::identity; +use nym_crypto::asymmetric::ed25519; use nym_mixnet_contract_common::{ construct_legacy_mixnode_bonding_sign_payload, Gateway, GatewayBondingPayload, MixNode, NodeCostParams, NymNode, NymNodeBondingPayload, SignableGatewayBondingMsg, @@ -70,8 +70,8 @@ pub(crate) async fn verify_mixnode_bonding_sign_payload Result<(), BackendError> { - let identity_key = identity::PublicKey::from_base58_string(&nym_node.identity_key)?; - let signature = identity::Signature::from_bytes(msg_signature.as_ref())?; + let identity_key = ed25519::PublicKey::from_base58_string(&nym_node.identity_key)?; + let signature = ed25519::Signature::from_bytes(msg_signature.as_ref())?; // recreate the plaintext let msg = create_nym_node_bonding_sign_payload( @@ -224,7 +224,7 @@ mod tests { #[tokio::test] async fn dummy_mix_bonding_signature_verification() { let mut rng = test_rng(); - let identity_keypair = identity::KeyPair::new(&mut rng); + let identity_keypair = ed25519::KeyPair::new(&mut rng); let dummy_mixnode = MixNode { host: "1.2.3.4".to_string(), mix_port: 1234, @@ -300,7 +300,7 @@ mod tests { #[tokio::test] async fn dummy_gateway_bonding_signature_verification() { let mut rng = test_rng(); - let identity_keypair = identity::KeyPair::new(&mut rng); + let identity_keypair = ed25519::KeyPair::new(&mut rng); let dummy_gateway = Gateway { host: "1.2.3.4".to_string(), mix_port: 1234, diff --git a/sdk/rust/nym-sdk/src/error.rs b/sdk/rust/nym-sdk/src/error.rs index f4656e572f..c44e40d88d 100644 --- a/sdk/rust/nym-sdk/src/error.rs +++ b/sdk/rust/nym-sdk/src/error.rs @@ -14,7 +14,7 @@ pub enum Error { TomlDeserializationError(#[from] toml::de::Error), #[error("Ed25519 error: {0}")] - Ed25519RecoveryError(#[from] nym_crypto::asymmetric::identity::Ed25519RecoveryError), + Ed25519RecoveryError(#[from] nym_crypto::asymmetric::ed25519::Ed25519RecoveryError), #[error(transparent)] ClientCoreError(#[from] nym_client_core::error::ClientCoreError), diff --git a/service-providers/authenticator/src/cli/sign.rs b/service-providers/authenticator/src/cli/sign.rs index 9e1de18bf0..30bd8ed1d1 100644 --- a/service-providers/authenticator/src/cli/sign.rs +++ b/service-providers/authenticator/src/cli/sign.rs @@ -7,7 +7,7 @@ use nym_authenticator::error::AuthenticatorError; use nym_bin_common::output_format::OutputFormat; use nym_client_core::client::key_manager::persistence::OnDiskKeys; use nym_client_core::error::ClientCoreError; -use nym_crypto::asymmetric::identity; +use nym_crypto::asymmetric::ed25519; use nym_types::helpers::ConsoleSigningOutput; #[derive(Args, Clone)] @@ -25,7 +25,7 @@ pub(crate) struct Sign { } fn print_signed_contract_msg( - private_key: &identity::PrivateKey, + private_key: &ed25519::PrivateKey, raw_msg: &str, output: OutputFormat, ) { diff --git a/service-providers/ip-packet-router/src/cli/sign.rs b/service-providers/ip-packet-router/src/cli/sign.rs index cb4aea63bd..bfb9074035 100644 --- a/service-providers/ip-packet-router/src/cli/sign.rs +++ b/service-providers/ip-packet-router/src/cli/sign.rs @@ -3,7 +3,7 @@ use clap::Args; use nym_bin_common::output_format::OutputFormat; use nym_client_core::client::key_manager::persistence::OnDiskKeys; use nym_client_core::error::ClientCoreError; -use nym_crypto::asymmetric::identity; +use nym_crypto::asymmetric::ed25519; use nym_ip_packet_router::error::IpPacketRouterError; use nym_types::helpers::ConsoleSigningOutput; @@ -22,7 +22,7 @@ pub(crate) struct Sign { } fn print_signed_contract_msg( - private_key: &identity::PrivateKey, + private_key: &ed25519::PrivateKey, raw_msg: &str, output: OutputFormat, ) { diff --git a/service-providers/network-requester/src/cli/sign.rs b/service-providers/network-requester/src/cli/sign.rs index 769c5c5b13..d74ac44af2 100644 --- a/service-providers/network-requester/src/cli/sign.rs +++ b/service-providers/network-requester/src/cli/sign.rs @@ -7,7 +7,7 @@ use clap::Args; use nym_bin_common::output_format::OutputFormat; use nym_client_core::client::key_manager::persistence::OnDiskKeys; use nym_client_core::error::ClientCoreError; -use nym_crypto::asymmetric::identity; +use nym_crypto::asymmetric::ed25519; use nym_types::helpers::ConsoleSigningOutput; #[derive(Args, Clone)] @@ -25,7 +25,7 @@ pub(crate) struct Sign { } fn print_signed_contract_msg( - private_key: &identity::PrivateKey, + private_key: &ed25519::PrivateKey, raw_msg: &str, output: OutputFormat, ) {