adding proper noise key announcing on nodes

This commit is contained in:
Simon Wicky
2025-05-20 16:03:47 +02:00
parent d21eff3b7f
commit 6cf8d79988
6 changed files with 26 additions and 14 deletions
+2
View File
@@ -55,6 +55,8 @@ nym-config = { path = "../common/config" }
nym-crypto = { path = "../common/crypto", features = ["asymmetric", "rand"] }
nym-nonexhaustive-delayqueue = { path = "../common/nonexhaustive-delayqueue" }
nym-mixnet-client = { path = "../common/client-libs/mixnet-client" }
nym-noise = { path = "../common/nymnoise" }
nym-noise-keys = { path = "../common/nymnoise/keys" }
nym-pemstore = { path = "../common/pemstore" }
nym-sphinx-acknowledgements = { path = "../common/nymsphinx/acknowledgements" }
nym-sphinx-addressing = { path = "../common/nymsphinx/addressing" }
+1
View File
@@ -26,6 +26,7 @@ nym-crypto = { path = "../../common/crypto", features = [
"serde",
] }
nym-exit-policy = { path = "../../common/exit-policy" }
nym-noise-keys = { path = "../../common/nymnoise/keys" }
nym-wireguard-types = { path = "../../common/wireguard-types", default-features = false }
# feature-specific dependencies:
+11 -3
View File
@@ -105,8 +105,10 @@ impl Display for ErrorResponse {
#[cfg(test)]
mod tests {
use super::*;
use nym_crypto::asymmetric::{ed25519, x25519};
use nym_noise_keys::{NoiseVersion, VersionedNoiseKey};
use rand_chacha::rand_core::SeedableRng;
#[test]
@@ -114,7 +116,10 @@ mod tests {
let mut rng = rand_chacha::ChaCha20Rng::from_seed([0u8; 32]);
let ed22519 = ed25519::KeyPair::new(&mut rng);
let x25519_sphinx = x25519::KeyPair::new(&mut rng);
let x25519_noise = x25519::KeyPair::new(&mut rng);
let x25519_noise = VersionedNoiseKey {
version: NoiseVersion::V1,
x25519_pubkey: *x25519::KeyPair::new(&mut rng).public_key(),
};
let host_info = crate::api::v1::node::models::HostInformation {
ip_address: vec!["1.1.1.1".parse().unwrap()],
@@ -136,7 +141,7 @@ mod tests {
keys: crate::api::v1::node::models::HostKeys {
ed25519_identity: *ed22519.public_key(),
x25519_sphinx: *x25519_sphinx.public_key(),
x25519_noise: Some(*x25519_noise.public_key()),
x25519_noise: Some(x25519_noise),
},
};
@@ -189,7 +194,10 @@ mod tests {
keys: crate::api::v1::node::models::HostKeys {
ed25519_identity: legacy_info_noise.keys.ed25519_identity.parse().unwrap(),
x25519_sphinx: legacy_info_noise.keys.x25519_sphinx.parse().unwrap(),
x25519_noise: Some(legacy_info_noise.keys.x25519_noise.parse().unwrap()),
x25519_noise: Some(VersionedNoiseKey {
version: NoiseVersion::V1,
x25519_pubkey: legacy_info_noise.keys.x25519_noise.parse().unwrap(),
}),
},
};
@@ -3,10 +3,8 @@
use celes::Country;
use nym_crypto::asymmetric::ed25519::{self, serde_helpers::bs58_ed25519_pubkey};
use nym_crypto::asymmetric::x25519::{
self,
serde_helpers::{bs58_x25519_pubkey, option_bs58_x25519_pubkey},
};
use nym_crypto::asymmetric::x25519::{self, serde_helpers::bs58_x25519_pubkey};
use nym_noise_keys::VersionedNoiseKey;
use schemars::JsonSchema;
use serde::{Deserialize, Serialize};
use std::net::IpAddr;
@@ -124,10 +122,7 @@ pub struct HostKeys {
/// Base58-encoded x25519 public key of this node used for the noise protocol.
#[serde(default)]
#[serde(with = "option_bs58_x25519_pubkey")]
#[schemars(with = "Option<String>")]
#[cfg_attr(feature = "openapi", schema(value_type = Option<String>))]
pub x25519_noise: Option<x25519::PublicKey>,
pub x25519_noise: Option<VersionedNoiseKey>,
}
#[derive(Serialize)]
@@ -150,7 +145,7 @@ impl From<HostKeys> for LegacyHostKeysV2 {
x25519_sphinx: value.x25519_sphinx.to_base58_string(),
x25519_noise: value
.x25519_noise
.map(|k| k.to_base58_string())
.map(|k| k.x25519_pubkey.to_base58_string())
.unwrap_or_default(),
}
}
+2 -1
View File
@@ -7,13 +7,14 @@ use crate::node::http::api::api_requests;
use crate::node::http::error::NymNodeHttpError;
use nym_crypto::asymmetric::{ed25519, x25519};
use nym_node_requests::api::SignedHostInformation;
use nym_noise_keys::VersionedNoiseKey;
pub mod system_info;
pub(crate) fn sign_host_details(
config: &Config,
x22519_sphinx: &x25519::PublicKey,
x25519_noise: &x25519::PublicKey,
x25519_noise: &VersionedNoiseKey,
ed22519_identity: &ed25519::KeyPair,
) -> Result<SignedHostInformation, NymNodeError> {
let x25519_noise = if config.mixnet.debug.unsafe_disable_noise {
+6 -1
View File
@@ -44,6 +44,8 @@ use nym_network_requester::{
use nym_node_metrics::events::MetricEventsSender;
use nym_node_metrics::NymNodeMetrics;
use nym_node_requests::api::v1::node::models::{AnnouncePorts, NodeDescription};
use nym_noise::config::{NoiseConfig, NoiseNetworkView};
use nym_noise_keys::VersionedNoiseKey;
use nym_sphinx_acknowledgements::AckKey;
use nym_sphinx_addressing::Recipient;
use nym_task::{ShutdownManager, ShutdownToken, TaskClient};
@@ -700,7 +702,10 @@ impl NymNode {
let host_details = sign_host_details(
&self.config,
self.x25519_sphinx_keys.public_key(),
self.x25519_noise_keys.public_key(),
&VersionedNoiseKey {
version: nym_noise::NOISE_VERSION,
x25519_pubkey: *self.x25519_noise_keys.public_key(),
},
&self.ed25519_identity_keys,
)?;