add ecash key to api
This commit is contained in:
@@ -15,6 +15,7 @@ use crate::network_monitor::monitor::Monitor;
|
||||
use crate::nym_contract_cache::cache::NymContractCache;
|
||||
use crate::storage::NymApiStorage;
|
||||
use crate::support::{config, nyxd};
|
||||
use anyhow::Result;
|
||||
use futures::channel::mpsc;
|
||||
use nym_bandwidth_controller::BandwidthController;
|
||||
use nym_compact_ecash::generate_keypair_user;
|
||||
@@ -34,6 +35,18 @@ pub(crate) mod test_route;
|
||||
|
||||
pub(crate) const ROUTE_TESTING_TEST_NONCE: u64 = 0;
|
||||
|
||||
pub(crate) fn init_ecash_keypair(config: &config::NetworkMonitor) -> Result<()> {
|
||||
let kp = generate_keypair_user(&GroupParameters::new().unwrap());
|
||||
nym_pemstore::store_keypair(
|
||||
&kp,
|
||||
&nym_pemstore::KeyPairPath::new(
|
||||
&config.storage_paths.ecash_private_key_path,
|
||||
&config.storage_paths.ecash_public_key_path,
|
||||
),
|
||||
)?;
|
||||
Ok(())
|
||||
}
|
||||
|
||||
pub(crate) fn setup<'a>(
|
||||
config: &'a config::NetworkMonitor,
|
||||
nym_contract_cache_state: &NymContractCache,
|
||||
@@ -81,6 +94,10 @@ impl<'a> NetworkMonitorBuilder<'a> {
|
||||
let identity_keypair = Arc::new(identity::KeyPair::new(&mut rng));
|
||||
let encryption_keypair = Arc::new(encryption::KeyPair::new(&mut rng));
|
||||
let ecash_keypair = generate_keypair_user(&GroupParameters::new().unwrap());
|
||||
// let ecash_keypair = nym_pemstore::load_keypair(&KeyPairPath::new(
|
||||
// self.config.storage_paths.ecash_private_key_path,
|
||||
// self.config.storage_paths.ecash_public_key_path,
|
||||
// )); //SW todo : load ecash key
|
||||
let ack_key = Arc::new(AckKey::new(&mut rng));
|
||||
|
||||
let ecash_parameters = EcashParameters::new().ecash_params().clone();
|
||||
@@ -106,7 +123,7 @@ impl<'a> NetworkMonitorBuilder<'a> {
|
||||
self.nyxd_client.clone(),
|
||||
ecash_keypair,
|
||||
ecash_parameters,
|
||||
) //SW fill in those todo
|
||||
)
|
||||
};
|
||||
|
||||
let packet_sender = new_packet_sender(
|
||||
|
||||
@@ -20,6 +20,7 @@ fn try_upgrade_v1_1_21_config(id: &str) -> Result<()> {
|
||||
info!("It is going to get updated to the current specification.");
|
||||
|
||||
let updated: Config = old_config.into();
|
||||
crate::network_monitor::init_ecash_keypair(&updated.network_monitor)?;
|
||||
Ok(updated.save_to_default_location()?)
|
||||
}
|
||||
|
||||
@@ -36,6 +37,7 @@ fn try_upgrade_v1_1_27_config(id: &str) -> Result<()> {
|
||||
info!("It is going to get updated to the current specification.");
|
||||
|
||||
let updated: Config = old_config.into();
|
||||
crate::network_monitor::init_ecash_keypair(&updated.network_monitor)?;
|
||||
Ok(updated.save_to_default_location()?)
|
||||
}
|
||||
|
||||
@@ -48,6 +50,7 @@ pub(crate) fn initialise_new(id: &str) -> Result<Config> {
|
||||
let config = Config::new(id);
|
||||
init_paths(id)?;
|
||||
crate::coconut::dkg::controller::init_keypair(&config.coconut_signer)?;
|
||||
crate::network_monitor::init_ecash_keypair(&config.network_monitor)?;
|
||||
Ok(config)
|
||||
}
|
||||
|
||||
|
||||
@@ -95,6 +95,8 @@ impl From<ConfigV1_1_21> for Config {
|
||||
enabled: value.network_monitor.enabled,
|
||||
storage_paths: NetworkMonitorPaths {
|
||||
credentials_database_path: value.network_monitor.credentials_database_path,
|
||||
ecash_public_key_path: Default::default(),
|
||||
ecash_private_key_path: Default::default(),
|
||||
},
|
||||
debug: NetworkMonitorDebug {
|
||||
min_mixnode_reliability: value.network_monitor.min_mixnode_reliability,
|
||||
|
||||
@@ -68,6 +68,8 @@ impl From<ConfigV1_1_27> for Config {
|
||||
.network_monitor
|
||||
.storage_paths
|
||||
.credentials_database_path,
|
||||
ecash_public_key_path: Default::default(),
|
||||
ecash_private_key_path: Default::default(),
|
||||
},
|
||||
debug: NetworkMonitorDebug {
|
||||
min_mixnode_reliability: value.network_monitor.debug.min_mixnode_reliability,
|
||||
@@ -204,6 +206,8 @@ impl Default for NetworkMonitorV1_1_27 {
|
||||
enabled: false,
|
||||
storage_paths: NetworkMonitorPaths {
|
||||
credentials_database_path: Default::default(),
|
||||
ecash_public_key_path: Default::default(),
|
||||
ecash_private_key_path: Default::default(),
|
||||
},
|
||||
debug: Default::default(),
|
||||
}
|
||||
|
||||
@@ -6,6 +6,8 @@ use serde::{Deserialize, Serialize};
|
||||
use std::path::{Path, PathBuf};
|
||||
|
||||
pub const DEFAULT_NETWORK_MONITOR_CREDENTIALS_DATABASE_FILENAME: &str = "credentials_database.db";
|
||||
pub const DEFAULT_NETWORK_MONITOR_ECASH_PRIVATE_KEY_FILENAME: &str = "private_ecash.pem";
|
||||
pub const DEFAULT_NETWORK_MONITOR_ECASH_PUBLIC_KEY_FILENAME: &str = "public_ecash.pem";
|
||||
|
||||
pub const DEFAULT_NODE_STATUS_API_DATABASE_FILENAME: &str = "db.sqlite";
|
||||
|
||||
@@ -39,6 +41,8 @@ pub struct NetworkMonitorPaths {
|
||||
// TODO: this should contain the path to the database holding the results, but changing it would break backwards compatibility
|
||||
/// Path to the database containing bandwidth credentials of this client.
|
||||
pub credentials_database_path: PathBuf,
|
||||
pub ecash_public_key_path: PathBuf,
|
||||
pub ecash_private_key_path: PathBuf,
|
||||
}
|
||||
|
||||
impl NetworkMonitorPaths {
|
||||
@@ -48,6 +52,9 @@ impl NetworkMonitorPaths {
|
||||
NetworkMonitorPaths {
|
||||
credentials_database_path: data_dir
|
||||
.join(DEFAULT_NETWORK_MONITOR_CREDENTIALS_DATABASE_FILENAME),
|
||||
ecash_public_key_path: data_dir.join(DEFAULT_NETWORK_MONITOR_ECASH_PUBLIC_KEY_FILENAME),
|
||||
ecash_private_key_path: data_dir
|
||||
.join(DEFAULT_NETWORK_MONITOR_ECASH_PRIVATE_KEY_FILENAME),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -36,6 +36,12 @@ enabled = {{ network_monitor.enabled }}
|
||||
# Path to the database containing bandwidth credentials of this client.
|
||||
credentials_database_path = '{{ network_monitor.storage_paths.credentials_database_path }}'
|
||||
|
||||
# Path to the ecash public key
|
||||
ecash_public_key_path = '{{ network_monitor.storage_paths.ecash_public_key_path }}'
|
||||
|
||||
# Path to the ecash private key
|
||||
ecash_private_key_path = '{{ network_monitor.storage_paths.ecash_private_key_path }}'
|
||||
|
||||
[network_monitor.debug]
|
||||
|
||||
# Indicates whether this validator api is running in a disabled credentials mode, thus attempting
|
||||
|
||||
Reference in New Issue
Block a user