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!("写入私钥文件失败: {e}")))?;
println!(
"[OK] 私钥种子已写入: {} (公钥: {})",
path.display(),
pk_hex
);
println!("[WARN] 本文件包含私钥种子,请以安全方式保管(建议 chmod 600 或同理权限)");
} else {
println!("=== G-A1 审计锚点签名密钥对 ===");
println!("[SECRET] 私钥种子 (sk_seed_hex): {}", sk_seed_hex);
println!("[PUBLIC] 公钥 (pk_hex): {}", pk_hex);
println!("[WARN] 私钥种子请绝对不要泄露/提交到版本库;公钥可分发给验证方");
}
Ok(())
}