From dc77e3f962b2f81526112438fcf66d97d79bae2c Mon Sep 17 00:00:00 2001 From: Simon Wicky Date: Mon, 24 Jul 2023 16:54:08 +0200 Subject: [PATCH] swap id key for sphinx key --- common/topology/src/lib.rs | 11 +++++++---- .../mixnet_handling/receiver/connection_handler.rs | 10 +++++----- gateway/src/node/mod.rs | 2 +- mixnode/src/node/listener/connection_handler/mod.rs | 10 +++++----- mixnode/src/node/mod.rs | 10 +--------- 5 files changed, 19 insertions(+), 24 deletions(-) diff --git a/common/topology/src/lib.rs b/common/topology/src/lib.rs index 0903df1603..376c3be501 100644 --- a/common/topology/src/lib.rs +++ b/common/topology/src/lib.rs @@ -3,7 +3,7 @@ use crate::filter::VersionFilterable; use log::warn; -use nym_crypto::asymmetric::identity; +use nym_crypto::asymmetric::encryption; use nym_mixnet_contract_common::mixnode::MixNodeDetails; use nym_mixnet_contract_common::{GatewayBond, IdentityKeyRef, MixId}; use nym_sphinx_addressing::nodes::NodeIdentity; @@ -108,16 +108,19 @@ impl NymTopology { None } - pub fn find_node_key_by_mix_host(&self, mix_host: SocketAddr) -> Option<&identity::PublicKey> { + pub fn find_node_key_by_mix_host( + &self, + mix_host: SocketAddr, + ) -> Option<&encryption::PublicKey> { for node in self.gateways.iter() { if node.mix_host.ip() == mix_host.ip() { - return Some(&node.identity_key); + return Some(&node.sphinx_key); } } for nodes in self.mixes.values() { for node in nodes { if node.mix_host.ip() == mix_host.ip() { - return Some(&node.identity_key); + return Some(&node.sphinx_key); } } } diff --git a/gateway/src/node/mixnet_handling/receiver/connection_handler.rs b/gateway/src/node/mixnet_handling/receiver/connection_handler.rs index d28bdac758..2d4e37c71f 100644 --- a/gateway/src/node/mixnet_handling/receiver/connection_handler.rs +++ b/gateway/src/node/mixnet_handling/receiver/connection_handler.rs @@ -3,14 +3,14 @@ use crate::node::client_handling::active_clients::ActiveClientsStore; use crate::node::client_handling::websocket::message_receiver::MixMessageSender; -use crate::node::identity::{PUBLIC_KEY_LENGTH, SECRET_KEY_LENGTH}; +use crate::node::encryption::{PRIVATE_KEY_SIZE, PUBLIC_KEY_SIZE}; use crate::node::mixnet_handling::receiver::packet_processing::PacketProcessor; use crate::node::storage::error::StorageError; use crate::node::storage::Storage; use futures::StreamExt; use log::*; use nym_client_core::client::topology_control::accessor::TopologyAccessor; -use nym_crypto::asymmetric::identity; +use nym_crypto::asymmetric::encryption; use nym_mixnet_client::forwarder::MixForwardingSender; use nym_mixnode_common::packet_processor::processor::ProcessedFinalHop; use nym_noise::upgrade_noise_responder; @@ -36,8 +36,8 @@ pub(crate) struct ConnectionHandler { storage: St, ack_sender: MixForwardingSender, topology_access: TopologyAccessor, - public_identity_key: [u8; PUBLIC_KEY_LENGTH], - private_identity_key: [u8; SECRET_KEY_LENGTH], + public_identity_key: [u8; PUBLIC_KEY_SIZE], + private_identity_key: [u8; PRIVATE_KEY_SIZE], } impl Clone for ConnectionHandler { @@ -70,7 +70,7 @@ impl ConnectionHandler { ack_sender: MixForwardingSender, active_clients_store: ActiveClientsStore, topology_access: TopologyAccessor, - identity_key: &identity::KeyPair, + identity_key: &encryption::KeyPair, ) -> Self { ConnectionHandler { packet_processor, diff --git a/gateway/src/node/mod.rs b/gateway/src/node/mod.rs index e517629f8e..24cb4ae3b5 100644 --- a/gateway/src/node/mod.rs +++ b/gateway/src/node/mod.rs @@ -146,7 +146,7 @@ impl Gateway { ack_sender, active_clients_store, topology_access, - &self.identity_keypair, + &self.sphinx_keypair, ); let listening_address = SocketAddr::new( diff --git a/mixnode/src/node/listener/connection_handler/mod.rs b/mixnode/src/node/listener/connection_handler/mod.rs index 59e8f86a9c..8e933d889d 100644 --- a/mixnode/src/node/listener/connection_handler/mod.rs +++ b/mixnode/src/node/listener/connection_handler/mod.rs @@ -1,7 +1,7 @@ // Copyright 2020 - Nym Technologies SA // SPDX-License-Identifier: Apache-2.0 -use crate::node::identity::{PUBLIC_KEY_LENGTH, SECRET_KEY_LENGTH}; +use crate::node::encryption::{PRIVATE_KEY_SIZE, PUBLIC_KEY_SIZE}; use crate::node::listener::connection_handler::packet_processing::{ MixProcessingResult, PacketProcessor, }; @@ -9,7 +9,7 @@ use crate::node::packet_delayforwarder::PacketDelayForwardSender; use crate::node::TaskClient; use futures::StreamExt; use nym_client_core::client::topology_control::accessor::TopologyAccessor; -use nym_crypto::asymmetric::identity; +use nym_crypto::asymmetric::encryption; use nym_mixnode_common::measure; use nym_noise::upgrade_noise_responder; use nym_sphinx::forwarding::packet::MixPacket; @@ -30,8 +30,8 @@ pub(crate) struct ConnectionHandler { packet_processor: PacketProcessor, delay_forwarding_channel: PacketDelayForwardSender, topology_access: TopologyAccessor, - private_identity_key: [u8; SECRET_KEY_LENGTH], - public_identity_key: [u8; PUBLIC_KEY_LENGTH], + private_identity_key: [u8; PRIVATE_KEY_SIZE], + public_identity_key: [u8; PUBLIC_KEY_SIZE], } impl ConnectionHandler { @@ -39,7 +39,7 @@ impl ConnectionHandler { packet_processor: PacketProcessor, delay_forwarding_channel: PacketDelayForwardSender, topology_access: TopologyAccessor, - identity_key: &identity::KeyPair, + identity_key: &encryption::KeyPair, ) -> Self { ConnectionHandler { packet_processor, diff --git a/mixnode/src/node/mod.rs b/mixnode/src/node/mod.rs index 09acb65565..051c5cadff 100644 --- a/mixnode/src/node/mod.rs +++ b/mixnode/src/node/mod.rs @@ -164,7 +164,7 @@ impl MixNode { packet_processor, delay_forwarding_channel, topology_access, - &self.identity_keypair, + &self.sphinx_keypair, ); let listening_address = SocketAddr::new( @@ -325,14 +325,6 @@ impl MixNode { if self.check_if_bonded().await { warn!("You seem to have bonded your mixnode before starting it - that's highly unrecommended as in the future it might result in slashing"); } - println!( - "Secret key start : {:?}", - self.identity_keypair.private_key().to_bytes() - ); - println!( - "Public key start : {:?}", - self.identity_keypair.public_key().to_bytes() - ); let shutdown = TaskManager::default();