-
Notifications
You must be signed in to change notification settings - Fork 233
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
chore: silence `nargo compile` output fix: display `nargo prove` doc comment in help
- Loading branch information
1 parent
2c30f64
commit cfb30c5
Showing
5 changed files
with
83 additions
and
47 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
use acvm::acir::circuit::Circuit; | ||
use acvm::ProofSystemCompiler; | ||
use std::path::{Path, PathBuf}; | ||
|
||
use clap::Args; | ||
|
||
use crate::{constants::TARGET_DIR, errors::CliError}; | ||
|
||
use super::fs::{ | ||
acir::{read_acir_from_file, save_acir_hash_to_dir}, | ||
keys::save_key_to_dir, | ||
}; | ||
use super::NargoConfig; | ||
|
||
/// Generate proving and verification keys for a circuit. | ||
#[derive(Debug, Clone, Args)] | ||
pub(crate) struct PreprocessCommand { | ||
/// The name of the circuit ACIR build file. | ||
circuit_name: String, | ||
} | ||
|
||
pub(crate) fn run(args: PreprocessCommand, config: NargoConfig) -> Result<(), CliError> { | ||
let circuit_dir = config.program_dir.join(TARGET_DIR); | ||
|
||
let circuit = read_acir_from_file(circuit_dir.join(&args.circuit_name))?; | ||
|
||
preprocess_with_path(&args.circuit_name, circuit_dir, &circuit)?; | ||
|
||
Ok(()) | ||
} | ||
|
||
pub(crate) fn preprocess_with_path<P: AsRef<Path>>( | ||
key_name: &str, | ||
preprocess_dir: P, | ||
circuit: &Circuit, | ||
) -> Result<(PathBuf, PathBuf), CliError> { | ||
let backend = crate::backends::ConcreteBackend; | ||
let (proving_key, verification_key) = backend.preprocess(circuit); | ||
|
||
// Save a checksum of the circuit to compare against during proving and verification. | ||
// If hash doesn't match then the circuit has been updated and keys are stale. | ||
save_acir_hash_to_dir(circuit, key_name, &preprocess_dir); | ||
|
||
let pk_path = save_key_to_dir(proving_key, key_name, &preprocess_dir, true)?; | ||
let vk_path = save_key_to_dir(verification_key, key_name, preprocess_dir, false)?; | ||
|
||
Ok((pk_path, vk_path)) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters