Key Regeneration

This commit is contained in:
Alex Emmet 2026-05-23 02:43:40 +02:00
commit 2193583f00
3 changed files with 29 additions and 24 deletions

View file

@ -417,10 +417,12 @@ pub async fn run_command(command: &str) {
log!("User command usage: user add <username> | user remove <username> | user list");
}
["help", "reconnect"] => {
log!("Reconnect command usage: reconnect — retry connecting to the Omikron server");
log!("Reconnect command usage: reconnect. Retry connecting to the Omikron server");
}
["help", "regenerate"] => {
log!("Regenerate command usage: regenerate private-key — generate a new Iota key pair and reconnect");
log!(
"Regenerate command usage: regenerate keys. Generate a new Iota key pair and reconnect"
);
}
["ping"] => {
@ -472,15 +474,13 @@ pub async fn run_command(command: &str) {
OMIKRON_CONNECTION.reconnect().await;
log!("Reconnected to Omikron server");
}
["regenerate", "private-key"] => {
["regenerate", "keys"] => {
log!("Regenerating Iota key pair...");
let key_pair = crypto_helper::generate_keypair();
let public_key_base64 = crypto_helper::public_key_to_base64(&key_pair.public);
let private_key_base64 = crypto_helper::secret_key_to_base64(&key_pair.secret);
{
let mut conf = CONFIG.write().await;
conf.change("public_key", json::JsonValue::from(public_key_base64));
conf.change("private_key", json::JsonValue::from(private_key_base64));
conf.remove("public_key");
conf.remove("private_key");
conf.remove("iota_id");
conf.update();
}
log!("Key pair regenerated. Reconnecting to Omikron server...");