adds --skip-key-check option to setup, run and prove commands

This commit is contained in:
Damir Shamanaev 2021-01-29 23:01:52 +03:00
parent 9aa0fb6069
commit ea742a5a4e
4 changed files with 25 additions and 19 deletions

View File

@ -42,6 +42,9 @@ jobs:
cd .. && leo new my-app && cd my-app
leo login -u "$USER" -p "$PASS"
leo add argus4130/xnor
leo setup
leo setup
leo setup --skip-key-check
leo remove xnor
leo clean

View File

@ -29,24 +29,24 @@ use std::{convert::TryFrom, env::current_dir, time::Instant};
pub struct ProveCommand;
impl CLI for ProveCommand {
type Options = ();
type Options = bool;
type Output = (Proof<Bls12_377>, PreparedVerifyingKey<Bls12_377>);
const ABOUT: AboutType = "Run the program and produce a proof";
const ARGUMENTS: &'static [ArgumentType] = &[];
const FLAGS: &'static [FlagType] = &[];
const FLAGS: &'static [FlagType] = &[("--skip-key-check")];
const NAME: NameType = "prove";
const OPTIONS: &'static [OptionType] = &[];
const SUBCOMMANDS: &'static [SubCommandType] = &[];
#[cfg_attr(tarpaulin, skip)]
fn parse(_arguments: &ArgMatches) -> Result<Self::Options, CLIError> {
Ok(())
fn parse(arguments: &ArgMatches) -> Result<Self::Options, CLIError> {
Ok(!arguments.is_present("skip-key-check"))
}
#[cfg_attr(tarpaulin, skip)]
fn output(options: Self::Options) -> Result<Self::Output, CLIError> {
let (program, parameters, prepared_verifying_key) = SetupCommand::output(options)?;
fn output(do_setup_check: Self::Options) -> Result<Self::Output, CLIError> {
let (program, parameters, prepared_verifying_key) = SetupCommand::output(do_setup_check)?;
// Begin "Proving" context for console logging
let span = tracing::span!(tracing::Level::INFO, "Proving");

View File

@ -28,24 +28,24 @@ use std::time::Instant;
pub struct RunCommand;
impl CLI for RunCommand {
type Options = ();
type Options = bool;
type Output = ();
const ABOUT: AboutType = "Run a program with input variables";
const ARGUMENTS: &'static [ArgumentType] = &[];
const FLAGS: &'static [FlagType] = &[];
const FLAGS: &'static [FlagType] = &[("--skip-key-check")];
const NAME: NameType = "run";
const OPTIONS: &'static [OptionType] = &[];
const SUBCOMMANDS: &'static [SubCommandType] = &[];
#[cfg_attr(tarpaulin, skip)]
fn parse(_arguments: &ArgMatches) -> Result<Self::Options, CLIError> {
Ok(())
fn parse(arguments: &ArgMatches) -> Result<Self::Options, CLIError> {
Ok(!arguments.is_present("skip-key-check"))
}
#[cfg_attr(tarpaulin, skip)]
fn output(options: Self::Options) -> Result<(), CLIError> {
let (proof, prepared_verifying_key) = ProveCommand::output(options)?;
fn output(do_setup_check: Self::Options) -> Result<(), CLIError> {
let (proof, prepared_verifying_key) = ProveCommand::output(do_setup_check)?;
// Begin "Verifying" context for console logging
let span = tracing::span!(tracing::Level::INFO, "Verifying");

View File

@ -39,7 +39,7 @@ use std::{convert::TryFrom, env::current_dir, time::Instant};
pub struct SetupCommand;
impl CLI for SetupCommand {
type Options = ();
type Options = bool;
type Output = (
Compiler<Fr, EdwardsGroupType>,
Parameters<Bls12_377>,
@ -48,23 +48,23 @@ impl CLI for SetupCommand {
const ABOUT: AboutType = "Run a program setup";
const ARGUMENTS: &'static [ArgumentType] = &[];
const FLAGS: &'static [FlagType] = &[];
const FLAGS: &'static [FlagType] = &[("--skip-key-check")];
const NAME: NameType = "setup";
const OPTIONS: &'static [OptionType] = &[];
const SUBCOMMANDS: &'static [SubCommandType] = &[];
#[cfg_attr(tarpaulin, skip)]
fn parse(_arguments: &ArgMatches) -> Result<Self::Options, CLIError> {
Ok(())
fn parse(arguments: &ArgMatches) -> Result<Self::Options, CLIError> {
Ok(!arguments.is_present("skip-key-check"))
}
#[cfg_attr(tarpaulin, skip)]
fn output(options: Self::Options) -> Result<Self::Output, CLIError> {
fn output(do_check: Self::Options) -> Result<Self::Output, CLIError> {
// Get the package name
let path = current_dir()?;
let package_name = Manifest::try_from(path.as_path())?.get_package_name();
match BuildCommand::output(options)? {
match BuildCommand::output(())? {
Some((program, checksum_differs)) => {
// Begin "Setup" context for console logging
let span = tracing::span!(tracing::Level::INFO, "Setup");
@ -116,8 +116,11 @@ impl CLI for SetupCommand {
// Read the proving key file from the output directory
tracing::info!("Loading proving key...");
if !do_check {
tracing::info!("Skipping curve check");
}
let proving_key_bytes = ProvingKeyFile::new(&package_name).read_from(&path)?;
let proving_key = Parameters::<Bls12_377>::read(proving_key_bytes.as_slice(), true)?;
let proving_key = Parameters::<Bls12_377>::read(proving_key_bytes.as_slice(), do_check)?;
tracing::info!("Complete");
// Read the verification key file from the output directory