chore: rename 'identity' module to 'ed25519' and 'encryption' to 'x25519' (#5707)

This commit is contained in:
Jędrzej Stuczyński
2025-04-13 11:58:25 +01:00
committed by GitHub
parent 660463908d
commit 84db9f6bcd
90 changed files with 330 additions and 332 deletions
@@ -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;
@@ -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;
@@ -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;
@@ -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;
@@ -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;
@@ -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;
@@ -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;
@@ -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;
@@ -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?;
+2 -2
View File
@@ -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;
@@ -1,7 +1,7 @@
// Copyright 2024 - Nym Technologies SA <contact@nymtech.net>
// 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;
@@ -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<Vec<GatewayRegistration>, Self::StorageError>;
/// Return identity keys of all registered gateways.
async fn all_gateways_identities(
&self,
) -> Result<Vec<identity::PublicKey>, Self::StorageError> {
async fn all_gateways_identities(&self) -> Result<Vec<ed25519::PublicKey>, 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>;
@@ -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<GatewayDetails> for GatewayRegistration {
impl GatewayDetails {
pub fn new_remote(
gateway_id: identity::PublicKey,
gateway_id: ed25519::PublicKey,
shared_key: Arc<SharedGatewayKey>,
gateway_owner_address: Option<AccountId>,
gateway_listener: Url,
@@ -77,11 +77,11 @@ impl GatewayDetails {
})
}
pub fn new_custom(gateway_id: identity::PublicKey, data: Option<Vec<u8>>) -> Self {
pub fn new_custom(gateway_id: ed25519::PublicKey, data: Option<Vec<u8>>) -> 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<RawRemoteGatewayDetails> for RemoteGatewayDetails {
fn try_from(value: RawRemoteGatewayDetails) -> Result<Self, Self::Error> {
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<SharedGatewayKey>,
@@ -288,7 +288,7 @@ impl TryFrom<RawCustomGatewayDetails> for CustomGatewayDetails {
fn try_from(value: RawCustomGatewayDetails) -> Result<Self, Self::Error> {
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<Vec<u8>>,
}
impl CustomGatewayDetails {
pub fn new(gateway_id: identity::PublicKey) -> CustomGatewayDetails {
pub fn new(gateway_id: ed25519::PublicKey) -> CustomGatewayDetails {
Self {
gateway_id,
data: None,
@@ -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<identity::PublicKey>,
pub gateway_id: Option<ed25519::PublicKey>,
/// Specifies whether the client will attempt to enforce tls connection to the desired gateway.
#[cfg_attr(feature = "cli", clap(long))]
@@ -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<identity::PublicKey>,
pub gateway: Option<ed25519::PublicKey>,
/// Specifies whether the client will attempt to enforce tls connection to the desired gateway.
#[cfg_attr(feature = "cli", clap(long))]
@@ -1,7 +1,7 @@
// Copyright 2023 - Nym Technologies SA <contact@nymtech.net>
// 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<identity::PublicKey>,
pub gateway: Option<ed25519::PublicKey>,
/// Comma separated list of rest endpoints of the nyxd validators
#[cfg_attr(
@@ -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<C, A>(args: A) -> Result<(), C::Error>
+2 -2
View File
@@ -1,7 +1,7 @@
// Copyright 2024 - Nym Technologies SA <contact@nymtech.net>
// 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,
@@ -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<encryption::KeyPair>,
local_encryption_keypair: Arc<x25519::KeyPair>,
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<identity::KeyPair>,
pub identity_keys: Arc<ed25519::KeyPair>,
pub client_input: ClientInputStatus,
pub client_output: ClientOutputStatus,
pub client_state: ClientState,
@@ -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<D>(
@@ -26,7 +26,7 @@ where
pub async fn get_active_gateway_identity<D>(
details_store: &D,
) -> Result<Option<identity::PublicKey>, ClientCoreError>
) -> Result<Option<ed25519::PublicKey>, ClientCoreError>
where
D: GatewaysDetailsStore,
D::StorageError: Send + Sync + 'static,
@@ -42,7 +42,7 @@ where
pub async fn get_all_registered_identities<D>(
details_store: &D,
) -> Result<Vec<identity::PublicKey>, ClientCoreError>
) -> Result<Vec<ed25519::PublicKey>, ClientCoreError>
where
D: GatewaysDetailsStore + Sync,
D::StorageError: Send + Sync + 'static,
@@ -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>,
identity_keypair: Arc<ed25519::KeyPair>,
/// encryption key associated with the client instance.
encryption_keypair: Arc<encryption::KeyPair>,
encryption_keypair: Arc<x25519::KeyPair>,
/// key used for producing and processing acknowledgement packets.
ack_key: Arc<AckKey>,
@@ -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<identity::KeyPair> {
/// Gets an atomically reference counted pointer to [`ed25519::KeyPair`].
pub fn identity_keypair(&self) -> Arc<ed25519::KeyPair> {
Arc::clone(&self.identity_keypair)
}
/// Gets an atomically reference counted pointer to [`encryption::KeyPair`].
pub fn encryption_keypair(&self) -> Arc<encryption::KeyPair> {
/// Gets an atomically reference counted pointer to [`x25519::KeyPair`].
pub fn encryption_keypair(&self) -> Arc<x25519::KeyPair> {
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<T: ZeroizeOnDrop>() {}
_assert_zeroize_on_drop::<identity::KeyPair>();
_assert_zeroize_on_drop::<encryption::KeyPair>();
_assert_zeroize_on_drop::<ed25519::KeyPair>();
_assert_zeroize_on_drop::<x25519::KeyPair>();
_assert_zeroize_on_drop::<AckKey>();
_assert_zeroize_on_drop::<LegacySharedKeys>();
_assert_zeroize_on_drop::<SharedSymmetricKey>();
@@ -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<encryption::KeyPair, OnDiskKeysError> {
pub fn load_encryption_keypair(&self) -> Result<x25519::KeyPair, OnDiskKeysError> {
let encryption_paths = self.paths.encryption_key_pair_path();
self.load_keypair(encryption_paths, "encryption")
}
#[doc(hidden)]
pub fn load_identity_keypair(&self) -> Result<identity::KeyPair, OnDiskKeysError> {
pub fn load_identity_keypair(&self) -> Result<ed25519::KeyPair, OnDiskKeysError> {
let identity_paths = self.paths.identity_key_pair_path();
self.load_keypair(identity_paths, "identity")
}
@@ -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<E: std::error::Error + Send + Sync + 'static>(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<RawFd>;
async fn send_client_request(
&mut self,
@@ -75,7 +75,7 @@ pub trait GatewayReceiver {
#[async_trait]
impl<G: GatewayTransceiver + ?Sized + Send> GatewayTransceiver for Box<G> {
#[inline]
fn gateway_identity(&self) -> identity::PublicKey {
fn gateway_identity(&self) -> ed25519::PublicKey {
(**self).gateway_identity()
}
fn ws_fd(&self) -> Option<RawFd> {
@@ -134,7 +134,7 @@ where
St: CredentialStorage,
<St as 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<RawFd> {
@@ -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<PacketRouter>,
) -> 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<RawFd> {
@@ -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<PacketRouter>,
sent: Vec<MixPacket>,
}
@@ -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<RawFd> {
@@ -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<Vec<Reconstruct
struct ReceivedMessagesBufferInner<R: MessageReceiver> {
messages: Vec<ReconstructedMessage>,
local_encryption_keypair: Arc<encryption::KeyPair>,
local_encryption_keypair: Arc<x25519::KeyPair>,
// TODO: looking how it 'looks' here, perhaps `MessageReceiver` should be renamed to something
// else instead.
@@ -176,7 +176,7 @@ struct ReceivedMessagesBuffer<R: MessageReceiver> {
impl<R: MessageReceiver> ReceivedMessagesBuffer<R> {
fn new(
local_encryption_keypair: Arc<encryption::KeyPair>,
local_encryption_keypair: Arc<x25519::KeyPair>,
reply_key_storage: SentReplyKeys,
reply_controller_sender: ReplyControllerSender,
stats_tx: ClientStatsSender,
@@ -566,7 +566,7 @@ pub(crate) struct ReceivedMessagesBufferController<R: MessageReceiver> {
impl<R: MessageReceiver + Clone + Send + 'static> ReceivedMessagesBufferController<R> {
pub(crate) fn new(
local_encryption_keypair: Arc<encryption::KeyPair>,
local_encryption_keypair: Arc<x25519::KeyPair>,
query_receiver: ReceivedBufferRequestReceiver,
mixnet_packet_receiver: MixnetMessageReceiver,
reply_key_storage: SentReplyKeys,
+1 -1
View File
@@ -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};
+6 -6
View File
@@ -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<String>;
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<RoutingNode, ClientCoreError> {
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<identity::KeyPair>,
our_identity: Arc<ed25519::KeyPair>,
#[cfg(unix)] connection_fd_callback: Option<Arc<dyn Fn(RawFd) + Send + Sync>>,
) -> Result<RegistrationResult, ClientCoreError> {
let mut gateway_client = GatewayClient::new_init(
+7 -7
View File
@@ -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<AccountId>,
gateway_listener: Url,
},
Custom {
gateway_id: identity::PublicKey,
gateway_id: ed25519::PublicKey,
additional_data: Option<Vec<u8>>,
},
}
@@ -77,7 +77,7 @@ impl SelectedGateway {
gateway_id: String,
additional_data: Option<Vec<u8>>,
) -> Result<Self, ClientCoreError> {
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(),
@@ -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<String>,
@@ -67,7 +67,7 @@ pub struct GatewayConfig {
impl GatewayConfig {
pub fn new(
gateway_identity: identity::PublicKey,
gateway_identity: ed25519::PublicKey,
gateway_owner: Option<String>,
gateway_listener: String,
) -> Self {
@@ -93,8 +93,8 @@ pub struct GatewayClient<C, St = EphemeralCredentialStorage> {
authenticated: bool,
bandwidth: ClientBandwidth,
gateway_address: String,
gateway_identity: identity::PublicKey,
local_identity: Arc<identity::KeyPair>,
gateway_identity: ed25519::PublicKey,
local_identity: Arc<ed25519::KeyPair>,
shared_key: Option<Arc<SharedGatewayKey>>,
connection: SocketState,
packet_router: PacketRouter,
@@ -117,7 +117,7 @@ impl<C, St> GatewayClient<C, St> {
pub fn new(
cfg: GatewayClientConfig,
gateway_config: GatewayConfig,
local_identity: Arc<identity::KeyPair>,
local_identity: Arc<ed25519::KeyPair>,
// TODO: make it mandatory. if you don't want to pass it, use `new_init`
shared_key: Option<Arc<SharedGatewayKey>>,
packet_router: PacketRouter,
@@ -145,7 +145,7 @@ impl<C, St> GatewayClient<C, St> {
}
}
pub fn gateway_identity(&self) -> identity::PublicKey {
pub fn gateway_identity(&self) -> ed25519::PublicKey {
self.gateway_identity
}
@@ -1063,8 +1063,8 @@ impl GatewayClient<InitOnly, EphemeralCredentialStorage> {
// 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<identity::KeyPair>,
gateway_identity: ed25519::PublicKey,
local_identity: Arc<ed25519::KeyPair>,
#[cfg(unix)] connection_fd_callback: Option<Arc<dyn Fn(RawFd) + Send + Sync>>,
) -> Self {
log::trace!("Initialising gateway client");
@@ -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,
@@ -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}");
@@ -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<M: AsRef<[u8]>>(
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<M: AsRef<[u8]>>(
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
}
+1 -1
View File
@@ -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;
@@ -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<S: Serializer>(
+9 -4
View File
@@ -1,8 +1,13 @@
// Copyright 2021 - Nym Technologies SA <contact@nymtech.net>
// 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;
+6 -6
View File
@@ -1,7 +1,7 @@
// Copyright 2021 - Nym Technologies SA <contact@nymtech.net>
// 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<C, D, R>(
rng: &mut R,
remote_key: &encryption::PublicKey,
) -> (encryption::KeyPair, Key<C>)
remote_key: &x25519::PublicKey,
) -> (x25519::KeyPair, Key<C>)
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<C, D>(
remote_key: &encryption::PublicKey,
local_key: &encryption::PrivateKey,
remote_key: &x25519::PublicKey,
local_key: &x25519::PrivateKey,
) -> Key<C>
where
C: StreamCipher + KeyIvInit,
@@ -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<u8>,
shutdown: TaskClient,
) -> GatewayHandshake<'a>
@@ -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::PublicKey>,
identity: &'a ed25519::KeyPair,
remote_pubkey: Option<ed25519::PublicKey>,
#[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<MaterialExchange, HandshakeError> {
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)
}
+11 -11
View File
@@ -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<identity::Signature> {
pub fn add_signature(&mut self, signature: ed25519::Signature) -> Option<ed25519::Signature> {
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<identity::Signature>,
pub signature: Option<ed25519::Signature>,
}
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<identity::Signature>,
pub signature: Option<ed25519::Signature>,
}
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<identity::Signature>,
pub signature: Option<ed25519::Signature>,
}
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()
}
+4 -4
View File
@@ -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<T> From<FragmentIdentifier> for Received<T> {
}
pub struct TestPacketProcessor<T, R: MessageReceiver = SphinxMessageReceiver> {
local_encryption_keypair: Arc<encryption::KeyPair>,
local_encryption_keypair: Arc<x25519::KeyPair>,
ack_key: Arc<AckKey>,
/// Structure responsible for decrypting and recovering plaintext message from received ciphertexts.
@@ -42,7 +42,7 @@ pub struct TestPacketProcessor<T, R: MessageReceiver = SphinxMessageReceiver> {
impl<T> TestPacketProcessor<T, SphinxMessageReceiver> {
pub fn new_sphinx_processor(
local_encryption_keypair: Arc<encryption::KeyPair>,
local_encryption_keypair: Arc<x25519::KeyPair>,
ack_key: Arc<AckKey>,
) -> Self {
Self::new(local_encryption_keypair, ack_key)
@@ -53,7 +53,7 @@ impl<T, R> TestPacketProcessor<T, R>
where
R: MessageReceiver,
{
pub fn new(local_encryption_keypair: Arc<encryption::KeyPair>, ack_key: Arc<AckKey>) -> Self {
pub fn new(local_encryption_keypair: Arc<x25519::KeyPair>, ack_key: Arc<AckKey>) -> Self {
TestPacketProcessor {
local_encryption_keypair,
ack_key,
+3 -3
View File
@@ -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<T, R: MessageReceiver = SphinxMessageReceiver>
impl<T> SimpleMessageReceiver<T, SphinxMessageReceiver> {
pub fn new_sphinx_receiver(
local_encryption_keypair: Arc<encryption::KeyPair>,
local_encryption_keypair: Arc<x25519::KeyPair>,
ack_key: Arc<AckKey>,
mixnet_message_receiver: mpsc::UnboundedReceiver<Vec<Vec<u8>>>,
acks_receiver: mpsc::UnboundedReceiver<Vec<Vec<u8>>>,
@@ -49,7 +49,7 @@ impl<T> SimpleMessageReceiver<T, SphinxMessageReceiver> {
impl<T, R: MessageReceiver> SimpleMessageReceiver<T, R> {
pub fn new(
local_encryption_keypair: Arc<encryption::KeyPair>,
local_encryption_keypair: Arc<x25519::KeyPair>,
ack_key: Arc<AckKey>,
mixnet_message_receiver: mpsc::UnboundedReceiver<Vec<Vec<u8>>>,
acks_receiver: mpsc::UnboundedReceiver<Vec<Vec<u8>>>,
+14 -14
View File
@@ -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(),
+3 -3
View File
@@ -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)
@@ -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(),
+2 -2
View File
@@ -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(),
+2 -2
View File
@@ -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
+2 -2
View File
@@ -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<R>(
self,
rng: &mut R,
recipient_encryption_key: &encryption::PublicKey,
recipient_encryption_key: &x25519::PublicKey,
) -> Result<NymPayload, SurbAckRecoveryError>
where
R: RngCore + CryptoRng,
+8 -8
View File
@@ -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::<PacketEncryptionAlgorithm, PacketHkdfAlgorithm>(
@@ -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::<PacketEncryptionAlgorithm>(
fragment_ciphertext,
+1 -1
View File
@@ -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};
+3 -3
View File
@@ -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::KeyPair>,
identity: Arc<ed25519::KeyPair>,
shutdown_token: ShutdownToken,
) -> Self {
PacketListener {
@@ -75,7 +75,7 @@ impl PacketListener {
}
struct ConnectionHandler {
identity: Arc<identity::KeyPair>,
identity: Arc<ed25519::KeyPair>,
}
impl ConnectionHandler {
+2 -2
View File
@@ -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::KeyPair>,
identity: Arc<ed25519::KeyPair>,
shutdown_token: ShutdownToken,
) -> Self {
VerlocMeasurer {
+1 -1
View File
@@ -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;
@@ -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<Option<identity::KeyPair>, <Self as WasmClientStorage>::StorageError> {
) -> Result<Option<ed25519::KeyPair>, <Self as WasmClientStorage>::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<Option<encryption::KeyPair>, <Self as WasmClientStorage>::StorageError> {
) -> Result<Option<x25519::KeyPair>, <Self as WasmClientStorage>::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<identity::KeyPair, <Self as WasmClientStorage>::StorageError> {
) -> Result<ed25519::KeyPair, <Self as WasmClientStorage>::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<encryption::KeyPair, <Self as WasmClientStorage>::StorageError> {
) -> Result<x25519::KeyPair, <Self as WasmClientStorage>::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<(), <Self as WasmClientStorage>::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<(), <Self as WasmClientStorage>::StorageError> {
self.store_value(
v1::KEYS_STORE,
+1 -1
View File
@@ -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;
@@ -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,
@@ -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();
+14 -14
View File
@@ -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<Uint128>,
) -> (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<Uint128>,
) -> (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<Uint128>,
@@ -924,7 +924,7 @@ pub mod test_helpers {
&mut self,
owner: &Addr,
stake: Option<Uint128>,
) -> (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<T: Serialize + SigningPurpose>(
message: SignableMessage<T>,
private_key: &identity::PrivateKey,
private_key: &ed25519::PrivateKey,
) -> MessageSignature {
match message.algorithm {
SigningAlgorithm::Ed25519 => {
@@ -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<EcashManager>,
pub(crate) storage: GatewayStorage,
pub(crate) local_identity: Arc<identity::KeyPair>,
pub(crate) local_identity: Arc<ed25519::KeyPair>,
pub(crate) metrics: NymNodeMetrics,
pub(crate) metrics_sender: MetricEventsSender,
pub(crate) outbound_mix_sender: MixForwardingSender,
+1 -1
View File
@@ -49,7 +49,7 @@ mod test {
assert!(matches!(
err,
EcashError::Ed25519ParseError(
nym_crypto::asymmetric::identity::Ed25519RecoveryError::MalformedPublicKeyString { .. }
nym_crypto::asymmetric::ed25519::Ed25519RecoveryError::MalformedPublicKeyString { .. }
)
));
+3 -3
View File
@@ -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<R: RngCore + CryptoRng + Clone> DkgController<R> {
nyxd_client: nyxd::Client,
coconut_keypair: CoconutKeyPair,
dkg_keypair: DkgKeyPair,
identity_key: identity::PublicKey,
identity_key: ed25519::PublicKey,
rng: R,
) -> Result<Self> {
let Some(announce_address) = &config.announce_address else {
@@ -312,7 +312,7 @@ impl<R: RngCore + CryptoRng + Clone> DkgController<R> {
nyxd_client: nyxd::Client,
coconut_keypair: CoconutKeyPair,
dkg_bte_keypair: DkgKeyPair,
identity_key: identity::PublicKey,
identity_key: ed25519::PublicKey,
rng: R,
shutdown: &TaskManager,
) -> Result<()>
+4 -4
View File
@@ -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
}
+2 -2
View File
@@ -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;
+3 -3
View File
@@ -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 {
+2 -2
View File
@@ -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,
+3 -3
View File
@@ -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()),
+9 -9
View File
@@ -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<DepositId>) -> 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(),
@@ -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,
) {
+7 -7
View File
@@ -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<AckKey>,
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<identity::KeyPair>,
local_identity: Arc<ed25519::KeyPair>,
bandwidth_controller: BandwidthController<nyxd::Client, PersistentStorage>,
) -> PacketSender {
PacketSender::new(
@@ -213,7 +213,7 @@ fn new_packet_sender(
fn new_received_processor<R: MessageReceiver + Send + 'static>(
packets_receiver: ReceivedProcessorReceiver,
client_encryption_keypair: Arc<encryption::KeyPair>,
client_encryption_keypair: Arc<x25519::KeyPair>,
ack_key: Arc<AckKey>,
) -> ReceivedProcessor<R> {
ReceivedProcessor::new(packets_receiver, client_encryption_keypair, ack_key)
@@ -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<AckKey>,
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,
@@ -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<encryption::KeyPair>,
client_encryption_keypair: Arc<x25519::KeyPair>,
ack_key: Arc<AckKey>,
) -> Self {
let shared_data = SharedProcessorData {
@@ -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<GatewayClientU
pub(crate) type GatewayClientUpdateReceiver = mpsc::UnboundedReceiver<GatewayClientUpdate>;
pub(crate) enum GatewayClientUpdate {
Disconnect(identity::PublicKey),
Disconnect(ed25519::PublicKey),
New(
identity::PublicKey,
ed25519::PublicKey,
(MixnetMessageReceiver, AcknowledgementReceiver),
),
}
@@ -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
}
+2 -2
View File
@@ -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(())
+2 -2
View File
@@ -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<identity::KeyPair> {
pub fn load_identity(&self) -> anyhow::Result<ed25519::KeyPair> {
let keypaths = nym_pemstore::KeyPairPath::new(
&self.private_identity_key_file,
&self.public_identity_key_file,
+1 -1
View File
@@ -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())?;
@@ -4,7 +4,7 @@ use tracing::info;
pub(crate) fn generate_key_pair(path: impl AsRef<Path>) -> 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)?;
+4 -4
View File
@@ -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<T> {
}
impl<T> SignedData<T> {
pub fn new(data: T, key: &identity::PrivateKey) -> Result<Self, Error>
pub fn new(data: T, key: &ed25519::PrivateKey) -> Result<Self, Error>
where
T: Serialize,
{
@@ -44,7 +44,7 @@ impl<T> SignedData<T> {
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<T> SignedData<T> {
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;
};
+3 -3
View File
@@ -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,
) {
@@ -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;
@@ -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);
+1 -1
View File
@@ -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)]
+1 -1
View File
@@ -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}")]
+1 -1
View File
@@ -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;
@@ -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<P: AddressAndNonceProvid
if vesting {
return Err(BackendError::UnsupportedVestingOperation);
}
let identity_key = identity::PublicKey::from_base58_string(&mix_node.identity_key)?;
let signature = identity::Signature::from_bytes(msg_signature.as_ref())?;
let identity_key = ed25519::PublicKey::from_base58_string(&mix_node.identity_key)?;
let signature = ed25519::Signature::from_bytes(msg_signature.as_ref())?;
// recreate the plaintext
let msg = create_mixnode_bonding_sign_payload(
@@ -124,8 +124,8 @@ pub(crate) async fn verify_gateway_bonding_sign_payload<P: AddressAndNonceProvid
if vesting {
return Err(BackendError::UnsupportedVestingOperation);
}
let identity_key = identity::PublicKey::from_base58_string(&gateway.identity_key)?;
let signature = identity::Signature::from_bytes(msg_signature.as_ref())?;
let identity_key = ed25519::PublicKey::from_base58_string(&gateway.identity_key)?;
let signature = ed25519::Signature::from_bytes(msg_signature.as_ref())?;
// recreate the plaintext
let msg = create_gateway_bonding_sign_payload(client, gateway.clone(), pledge.clone(), vesting)
@@ -165,8 +165,8 @@ pub(crate) async fn verify_nym_node_bonding_sign_payload<P: AddressAndNonceProvi
pledge: &Coin,
msg_signature: &MessageSignature,
) -> 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,
+1 -1
View File
@@ -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),
@@ -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,
) {
@@ -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,
) {
@@ -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,
) {