use std::path::Path;
use crate::error::CliError;
use crate::signing::AuditSigner;
pub fn run(output: Option<&Path>) -> Result<(), CliError> {
let (sk_seed_hex, pk_hex) =
AuditSigner::generate_keys().map_err(|e| CliError::other(e.to_string()))?;
if let Some(path) = output {
std::fs::write(path, format!("{}\n", sk_seed_hex))
.map_err(|e| CliError::other(format!("Write private key file failed: {e}")))?;
println!(
"[OK] Private seed written to: {} (public key: {})",
path.display(),
pk_hex
);
println!(
"[WARN] This file contains the private seed; keep it secure (chmod 600 or equivalent)"
);
} else {
println!("=== G-A1 Audit Anchor Signing Keypair ===");
println!("[SECRET] Private seed (sk_seed_hex): {}", sk_seed_hex);
println!("[PUBLIC] Public key (pk_hex): {}", pk_hex);
println!("[WARN] Never leak the private seed or commit it to version control; the public key may be distributed to verifiers");
}
Ok(())
}