diff --git a/crates/nargo_cli/src/cli/execute_cmd.rs b/crates/nargo_cli/src/cli/execute_cmd.rs index 61e709ce500..c175c0336f1 100644 --- a/crates/nargo_cli/src/cli/execute_cmd.rs +++ b/crates/nargo_cli/src/cli/execute_cmd.rs @@ -21,6 +21,10 @@ pub(crate) struct ExecuteCommand { /// Write the execution witness to named file witness_name: Option, + /// The name of the toml file which contains the inputs for the prover + #[clap(long, short, default_value = PROVER_INPUT_FILE)] + prover_name: String, + #[clap(flatten)] compile_options: CompileOptions, } @@ -31,7 +35,7 @@ pub(crate) fn run( config: NargoConfig, ) -> Result<(), CliError> { let (return_value, solved_witness) = - execute_with_path(backend, &config.program_dir, &args.compile_options)?; + execute_with_path(backend, &config.program_dir, args.prover_name, &args.compile_options)?; println!("Circuit witness successfully solved"); if let Some(return_value) = return_value { @@ -50,13 +54,14 @@ pub(crate) fn run( fn execute_with_path( backend: &B, program_dir: &Path, + prover_name: String, compile_options: &CompileOptions, ) -> Result<(Option, WitnessMap), CliError> { let CompiledProgram { abi, circuit } = compile_circuit(backend, program_dir, compile_options)?; // Parse the initial witness values from Prover.toml let (inputs_map, _) = - read_inputs_from_file(program_dir, PROVER_INPUT_FILE, Format::Toml, &abi)?; + read_inputs_from_file(program_dir, prover_name.as_str(), Format::Toml, &abi)?; let solved_witness = execute_program(backend, circuit, &abi, &inputs_map)?; diff --git a/crates/nargo_cli/src/cli/prove_cmd.rs b/crates/nargo_cli/src/cli/prove_cmd.rs index 1238dbd9f8e..601bacd278b 100644 --- a/crates/nargo_cli/src/cli/prove_cmd.rs +++ b/crates/nargo_cli/src/cli/prove_cmd.rs @@ -35,6 +35,14 @@ pub(crate) struct ProveCommand { /// The name of the circuit build files (ACIR, proving and verification keys) circuit_name: Option, + /// The name of the toml file which contains the inputs for the prover + #[clap(long, short, default_value = PROVER_INPUT_FILE)] + prover_name: String, + + /// The name of the toml file which contains the inputs for the verifier + #[clap(long, short, default_value = VERIFIER_INPUT_FILE)] + verifier_name: String, + /// Verify proof after proving #[arg(short, long)] verify: bool, @@ -57,6 +65,8 @@ pub(crate) fn run( prove_with_path( backend, args.proof_name, + args.prover_name, + args.verifier_name, config.program_dir, proof_dir, circuit_build_path, @@ -67,9 +77,12 @@ pub(crate) fn run( Ok(()) } +#[allow(clippy::too_many_arguments)] pub(crate) fn prove_with_path>( backend: &B, proof_name: Option, + prover_name: String, + verifier_name: String, program_dir: P, proof_dir: P, circuit_build_path: Option, @@ -107,7 +120,7 @@ pub(crate) fn prove_with_path>( // Parse the initial witness values from Prover.toml let (inputs_map, _) = - read_inputs_from_file(&program_dir, PROVER_INPUT_FILE, Format::Toml, &abi)?; + read_inputs_from_file(&program_dir, prover_name.as_str(), Format::Toml, &abi)?; let solved_witness = execute_program(backend, bytecode.clone(), &abi, &inputs_map)?; @@ -119,7 +132,7 @@ pub(crate) fn prove_with_path>( &public_inputs, &return_value, &program_dir, - VERIFIER_INPUT_FILE, + verifier_name.as_str(), Format::Toml, )?; diff --git a/crates/nargo_cli/src/cli/verify_cmd.rs b/crates/nargo_cli/src/cli/verify_cmd.rs index 26eb39f3f81..e326aafbc52 100644 --- a/crates/nargo_cli/src/cli/verify_cmd.rs +++ b/crates/nargo_cli/src/cli/verify_cmd.rs @@ -31,6 +31,10 @@ pub(crate) struct VerifyCommand { /// The name of the circuit build files (ACIR, proving and verification keys) circuit_name: Option, + /// The name of the toml file which contains the inputs for the verifier + #[clap(long, short, default_value = VERIFIER_INPUT_FILE)] + verifier_name: String, + #[clap(flatten)] compile_options: CompileOptions, } @@ -52,6 +56,7 @@ pub(crate) fn run( &config.program_dir, proof_path, circuit_build_path.as_ref(), + args.verifier_name, &args.compile_options, ) } @@ -61,6 +66,7 @@ fn verify_with_path>( program_dir: P, proof_path: PathBuf, circuit_build_path: Option

, + verifier_name: String, compile_options: &CompileOptions, ) -> Result<(), CliError> { let common_reference_string = read_cached_common_reference_string(); @@ -91,10 +97,10 @@ fn verify_with_path>( let PreprocessedProgram { abi, bytecode, verification_key, .. } = preprocessed_program; - // Load public inputs (if any) from `VERIFIER_INPUT_FILE`. + // Load public inputs (if any) from `verifier_name`. let public_abi = abi.public_abi(); let (public_inputs_map, return_value) = - read_inputs_from_file(program_dir, VERIFIER_INPUT_FILE, Format::Toml, &public_abi)?; + read_inputs_from_file(program_dir, verifier_name.as_str(), Format::Toml, &public_abi)?; let public_inputs = public_abi.encode(&public_inputs_map, return_value)?; let proof = load_hex_data(&proof_path)?;