From 91b64329ee110bca09740e3a55ec8627468338ed Mon Sep 17 00:00:00 2001 From: "pingcheng.ruan" Date: Fri, 18 Oct 2024 17:34:06 +0800 Subject: [PATCH] edit verification msg --- crates/zk-por-cli/src/main.rs | 41 ++++++++++++++++++----------------- 1 file changed, 21 insertions(+), 20 deletions(-) diff --git a/crates/zk-por-cli/src/main.rs b/crates/zk-por-cli/src/main.rs index 74414f5..d6dc499 100644 --- a/crates/zk-por-cli/src/main.rs +++ b/crates/zk-por-cli/src/main.rs @@ -9,7 +9,7 @@ use zk_por_cli::{ checker::check_non_neg_user, constant::{DEFAULT_USER_PROOF_FILE_PATTERN, GLOBAL_PROOF_FILENAME}, prover::prove, - verifier::{print_circuit_verifier_hex, verify_global, verify_user}, + verifier::{verify_global, verify_user}, }; use zk_por_core::error::PoRError; @@ -36,10 +36,6 @@ pub enum ZkPorCommands { #[arg(short, long)] cfg_path: String, // path to config file }, - PrintRootCircuitVerifier { - #[arg(short, long)] - proof_path: String, - }, VerifyGlobal { #[arg(short, long)] @@ -74,11 +70,6 @@ impl Execute for Option { check_non_neg_user(prover_cfg) } - Some(ZkPorCommands::PrintRootCircuitVerifier { proof_path }) => { - let global_proof_path = PathBuf::from_str(&proof_path).unwrap(); - print_circuit_verifier_hex(global_proof_path) - } - Some(ZkPorCommands::VerifyGlobal { proof_path: global_proof_path }) => { let global_proof_path = PathBuf::from_str(&global_proof_path).unwrap(); verify_global(global_proof_path, true, true) @@ -112,22 +103,30 @@ impl Execute for Option { .to_str() .unwrap() .to_string(); - let mut result = Ok(()); - if verify_global(global_proof_path.clone(), false, false).is_ok() { + + let global_result = verify_global(global_proof_path.clone(), false, false); + let user_result = verify_user(global_proof_path, &user_proof_path_pattern, false); + + if global_result.is_ok() { println!("Total sum and non-negative constraint validation passed"); } else { println!("Total sum and non-negative constraint validation failed"); - result = Err(PoRError::InvalidProof); } - if verify_user(global_proof_path, &user_proof_path_pattern, false).is_ok() { + if user_result.is_ok() { println!("Inclusion constraint validation passed"); } else { println!("Inclusion constraint validation failed"); - result = Err(PoRError::InvalidProof); } println!("============Validation finished============"); - result + + if global_result.is_err() { + global_result + } else if user_result.is_err() { + user_result + } else { + Ok(()) + } } } } @@ -135,13 +134,15 @@ impl Execute for Option { fn main() { let cli = Cli::parse(); + let start = std::time::Instant::now(); let r = cli.command.execute(); + let duration = start.elapsed(); + println!("Execution result: {:?}, duration: {:?}", r, duration); + let is_prove_command = matches!(cli.command, Some(ZkPorCommands::Prove { cfg_path: _, output_path: _ })); - if is_prove_command { - println!("Execution result: {:?}", r); - } else { - println!("Execution result: {:?}. Press Enter to quit...", r); + if !is_prove_command { + println!("Press Enter to quit..."); stdin().read_exact(&mut [0]).unwrap(); } }