Feature/mix ed25519 identity (#388)
* Introduced identity keypair to mixnode * Updated upgrade 0.9.0 mix upgrade instructions * Printing failed upgrade notice when it failed * Moved printing upgrade start notice to beginning of function
This commit is contained in:
committed by
GitHub
parent
c8bf454ccc
commit
2f7b3eec08
@@ -86,8 +86,8 @@ impl NymConfig for Config {
|
||||
}
|
||||
}
|
||||
|
||||
pub fn missing_string_value() -> String {
|
||||
MISSING_VALUE.to_string()
|
||||
pub fn missing_string_value<T: From<String>>() -> T {
|
||||
MISSING_VALUE.to_string().into()
|
||||
}
|
||||
|
||||
impl Config {
|
||||
@@ -98,6 +98,20 @@ impl Config {
|
||||
// builder methods
|
||||
pub fn with_id<S: Into<String>>(mut self, id: S) -> Self {
|
||||
let id = id.into();
|
||||
if self
|
||||
.mixnode
|
||||
.private_identity_key_file
|
||||
.as_os_str()
|
||||
.is_empty()
|
||||
{
|
||||
self.mixnode.private_identity_key_file =
|
||||
self::MixNode::default_private_identity_key_file(&id);
|
||||
}
|
||||
if self.mixnode.public_identity_key_file.as_os_str().is_empty() {
|
||||
self.mixnode.public_identity_key_file =
|
||||
self::MixNode::default_public_identity_key_file(&id);
|
||||
}
|
||||
|
||||
if self.mixnode.private_sphinx_key_file.as_os_str().is_empty() {
|
||||
self.mixnode.private_sphinx_key_file =
|
||||
self::MixNode::default_private_sphinx_key_file(&id);
|
||||
@@ -106,6 +120,7 @@ impl Config {
|
||||
self.mixnode.public_sphinx_key_file =
|
||||
self::MixNode::default_public_sphinx_key_file(&id);
|
||||
}
|
||||
|
||||
self.mixnode.id = id;
|
||||
self
|
||||
}
|
||||
@@ -218,6 +233,14 @@ impl Config {
|
||||
self.mixnode.location.clone()
|
||||
}
|
||||
|
||||
pub fn get_private_identity_key_file(&self) -> PathBuf {
|
||||
self.mixnode.private_identity_key_file.clone()
|
||||
}
|
||||
|
||||
pub fn get_public_identity_key_file(&self) -> PathBuf {
|
||||
self.mixnode.public_identity_key_file.clone()
|
||||
}
|
||||
|
||||
pub fn get_private_sphinx_key_file(&self) -> PathBuf {
|
||||
self.mixnode.private_sphinx_key_file.clone()
|
||||
}
|
||||
@@ -277,6 +300,14 @@ impl Config {
|
||||
pub fn get_version(&self) -> &str {
|
||||
&self.mixnode.version
|
||||
}
|
||||
|
||||
// upgrade-specific
|
||||
pub(crate) fn set_default_identity_keypair_paths(&mut self) {
|
||||
self.mixnode.private_identity_key_file =
|
||||
self::MixNode::default_private_identity_key_file(&self.mixnode.id);
|
||||
self.mixnode.public_identity_key_file =
|
||||
self::MixNode::default_public_identity_key_file(&self.mixnode.id);
|
||||
}
|
||||
}
|
||||
|
||||
#[derive(Debug, Deserialize, PartialEq, Serialize)]
|
||||
@@ -309,6 +340,14 @@ pub struct MixNode {
|
||||
/// `listening_address`.
|
||||
announce_address: String,
|
||||
|
||||
/// Path to file containing private identity key.
|
||||
#[serde(default = "missing_string_value")]
|
||||
private_identity_key_file: PathBuf,
|
||||
|
||||
/// Path to file containing public identity key.
|
||||
#[serde(default = "missing_string_value")]
|
||||
public_identity_key_file: PathBuf,
|
||||
|
||||
/// Path to file containing private sphinx key.
|
||||
private_sphinx_key_file: PathBuf,
|
||||
|
||||
@@ -329,6 +368,14 @@ pub struct MixNode {
|
||||
}
|
||||
|
||||
impl MixNode {
|
||||
fn default_private_identity_key_file(id: &str) -> PathBuf {
|
||||
Config::default_data_directory(Some(id)).join("private_identity.pem")
|
||||
}
|
||||
|
||||
fn default_public_identity_key_file(id: &str) -> PathBuf {
|
||||
Config::default_data_directory(Some(id)).join("public_identity.pem")
|
||||
}
|
||||
|
||||
fn default_private_sphinx_key_file(id: &str) -> PathBuf {
|
||||
Config::default_data_directory(Some(id)).join("private_sphinx.pem")
|
||||
}
|
||||
@@ -353,6 +400,8 @@ impl Default for MixNode {
|
||||
.parse()
|
||||
.unwrap(),
|
||||
announce_address: format!("127.0.0.1:{}", DEFAULT_LISTENING_PORT),
|
||||
private_identity_key_file: Default::default(),
|
||||
public_identity_key_file: Default::default(),
|
||||
private_sphinx_key_file: Default::default(),
|
||||
public_sphinx_key_file: Default::default(),
|
||||
presence_directory_server: DEFAULT_DIRECTORY_SERVER.to_string(),
|
||||
|
||||
@@ -17,7 +17,8 @@ use std::path::{Path, PathBuf};
|
||||
|
||||
#[derive(Debug)]
|
||||
pub struct MixNodePathfinder {
|
||||
config_dir: PathBuf,
|
||||
identity_private_key: PathBuf,
|
||||
identity_public_key: PathBuf,
|
||||
private_sphinx_key: PathBuf,
|
||||
public_sphinx_key: PathBuf,
|
||||
}
|
||||
@@ -25,12 +26,21 @@ pub struct MixNodePathfinder {
|
||||
impl MixNodePathfinder {
|
||||
pub fn new_from_config(config: &Config) -> Self {
|
||||
MixNodePathfinder {
|
||||
config_dir: config.get_config_file_save_location(),
|
||||
identity_private_key: config.get_private_identity_key_file(),
|
||||
identity_public_key: config.get_public_identity_key_file(),
|
||||
private_sphinx_key: config.get_private_sphinx_key_file(),
|
||||
public_sphinx_key: config.get_public_sphinx_key_file(),
|
||||
}
|
||||
}
|
||||
|
||||
pub fn private_identity_key(&self) -> &Path {
|
||||
&self.identity_private_key
|
||||
}
|
||||
|
||||
pub fn public_identity_key(&self) -> &Path {
|
||||
&self.identity_public_key
|
||||
}
|
||||
|
||||
pub fn private_encryption_key(&self) -> &Path {
|
||||
&self.private_sphinx_key
|
||||
}
|
||||
|
||||
@@ -42,6 +42,12 @@ layer = {{ mixnode.layer }}
|
||||
# Socket address to which this mixnode will bind to and will be listening for packets.
|
||||
listening_address = '{{ mixnode.listening_address }}'
|
||||
|
||||
# Path to file containing private identity key.
|
||||
private_identity_key_file = '{{ mixnode.private_identity_key_file }}'
|
||||
|
||||
# Path to file containing public identity key.
|
||||
public_identity_key_file = '{{ mixnode.public_identity_key_file }}'
|
||||
|
||||
# Path to file containing private identity key.
|
||||
private_sphinx_key_file = '{{ mixnode.private_sphinx_key_file }}'
|
||||
|
||||
|
||||
Reference in New Issue
Block a user