mirror of
https://github.com/AleoHQ/leo.git
synced 2024-12-26 11:06:00 +03:00
adds --skip-key-check option to setup, run and prove commands
This commit is contained in:
parent
9aa0fb6069
commit
ea742a5a4e
3
.github/workflows/leo-add-remove.yml
vendored
3
.github/workflows/leo-add-remove.yml
vendored
@ -42,6 +42,9 @@ jobs:
|
|||||||
cd .. && leo new my-app && cd my-app
|
cd .. && leo new my-app && cd my-app
|
||||||
leo login -u "$USER" -p "$PASS"
|
leo login -u "$USER" -p "$PASS"
|
||||||
leo add argus4130/xnor
|
leo add argus4130/xnor
|
||||||
|
leo setup
|
||||||
|
leo setup
|
||||||
|
leo setup --skip-key-check
|
||||||
leo remove xnor
|
leo remove xnor
|
||||||
leo clean
|
leo clean
|
||||||
|
|
||||||
|
@ -29,24 +29,24 @@ use std::{convert::TryFrom, env::current_dir, time::Instant};
|
|||||||
pub struct ProveCommand;
|
pub struct ProveCommand;
|
||||||
|
|
||||||
impl CLI for ProveCommand {
|
impl CLI for ProveCommand {
|
||||||
type Options = ();
|
type Options = bool;
|
||||||
type Output = (Proof<Bls12_377>, PreparedVerifyingKey<Bls12_377>);
|
type Output = (Proof<Bls12_377>, PreparedVerifyingKey<Bls12_377>);
|
||||||
|
|
||||||
const ABOUT: AboutType = "Run the program and produce a proof";
|
const ABOUT: AboutType = "Run the program and produce a proof";
|
||||||
const ARGUMENTS: &'static [ArgumentType] = &[];
|
const ARGUMENTS: &'static [ArgumentType] = &[];
|
||||||
const FLAGS: &'static [FlagType] = &[];
|
const FLAGS: &'static [FlagType] = &[("--skip-key-check")];
|
||||||
const NAME: NameType = "prove";
|
const NAME: NameType = "prove";
|
||||||
const OPTIONS: &'static [OptionType] = &[];
|
const OPTIONS: &'static [OptionType] = &[];
|
||||||
const SUBCOMMANDS: &'static [SubCommandType] = &[];
|
const SUBCOMMANDS: &'static [SubCommandType] = &[];
|
||||||
|
|
||||||
#[cfg_attr(tarpaulin, skip)]
|
#[cfg_attr(tarpaulin, skip)]
|
||||||
fn parse(_arguments: &ArgMatches) -> Result<Self::Options, CLIError> {
|
fn parse(arguments: &ArgMatches) -> Result<Self::Options, CLIError> {
|
||||||
Ok(())
|
Ok(!arguments.is_present("skip-key-check"))
|
||||||
}
|
}
|
||||||
|
|
||||||
#[cfg_attr(tarpaulin, skip)]
|
#[cfg_attr(tarpaulin, skip)]
|
||||||
fn output(options: Self::Options) -> Result<Self::Output, CLIError> {
|
fn output(do_setup_check: Self::Options) -> Result<Self::Output, CLIError> {
|
||||||
let (program, parameters, prepared_verifying_key) = SetupCommand::output(options)?;
|
let (program, parameters, prepared_verifying_key) = SetupCommand::output(do_setup_check)?;
|
||||||
|
|
||||||
// Begin "Proving" context for console logging
|
// Begin "Proving" context for console logging
|
||||||
let span = tracing::span!(tracing::Level::INFO, "Proving");
|
let span = tracing::span!(tracing::Level::INFO, "Proving");
|
||||||
|
@ -28,24 +28,24 @@ use std::time::Instant;
|
|||||||
pub struct RunCommand;
|
pub struct RunCommand;
|
||||||
|
|
||||||
impl CLI for RunCommand {
|
impl CLI for RunCommand {
|
||||||
type Options = ();
|
type Options = bool;
|
||||||
type Output = ();
|
type Output = ();
|
||||||
|
|
||||||
const ABOUT: AboutType = "Run a program with input variables";
|
const ABOUT: AboutType = "Run a program with input variables";
|
||||||
const ARGUMENTS: &'static [ArgumentType] = &[];
|
const ARGUMENTS: &'static [ArgumentType] = &[];
|
||||||
const FLAGS: &'static [FlagType] = &[];
|
const FLAGS: &'static [FlagType] = &[("--skip-key-check")];
|
||||||
const NAME: NameType = "run";
|
const NAME: NameType = "run";
|
||||||
const OPTIONS: &'static [OptionType] = &[];
|
const OPTIONS: &'static [OptionType] = &[];
|
||||||
const SUBCOMMANDS: &'static [SubCommandType] = &[];
|
const SUBCOMMANDS: &'static [SubCommandType] = &[];
|
||||||
|
|
||||||
#[cfg_attr(tarpaulin, skip)]
|
#[cfg_attr(tarpaulin, skip)]
|
||||||
fn parse(_arguments: &ArgMatches) -> Result<Self::Options, CLIError> {
|
fn parse(arguments: &ArgMatches) -> Result<Self::Options, CLIError> {
|
||||||
Ok(())
|
Ok(!arguments.is_present("skip-key-check"))
|
||||||
}
|
}
|
||||||
|
|
||||||
#[cfg_attr(tarpaulin, skip)]
|
#[cfg_attr(tarpaulin, skip)]
|
||||||
fn output(options: Self::Options) -> Result<(), CLIError> {
|
fn output(do_setup_check: Self::Options) -> Result<(), CLIError> {
|
||||||
let (proof, prepared_verifying_key) = ProveCommand::output(options)?;
|
let (proof, prepared_verifying_key) = ProveCommand::output(do_setup_check)?;
|
||||||
|
|
||||||
// Begin "Verifying" context for console logging
|
// Begin "Verifying" context for console logging
|
||||||
let span = tracing::span!(tracing::Level::INFO, "Verifying");
|
let span = tracing::span!(tracing::Level::INFO, "Verifying");
|
||||||
|
@ -39,7 +39,7 @@ use std::{convert::TryFrom, env::current_dir, time::Instant};
|
|||||||
pub struct SetupCommand;
|
pub struct SetupCommand;
|
||||||
|
|
||||||
impl CLI for SetupCommand {
|
impl CLI for SetupCommand {
|
||||||
type Options = ();
|
type Options = bool;
|
||||||
type Output = (
|
type Output = (
|
||||||
Compiler<Fr, EdwardsGroupType>,
|
Compiler<Fr, EdwardsGroupType>,
|
||||||
Parameters<Bls12_377>,
|
Parameters<Bls12_377>,
|
||||||
@ -48,23 +48,23 @@ impl CLI for SetupCommand {
|
|||||||
|
|
||||||
const ABOUT: AboutType = "Run a program setup";
|
const ABOUT: AboutType = "Run a program setup";
|
||||||
const ARGUMENTS: &'static [ArgumentType] = &[];
|
const ARGUMENTS: &'static [ArgumentType] = &[];
|
||||||
const FLAGS: &'static [FlagType] = &[];
|
const FLAGS: &'static [FlagType] = &[("--skip-key-check")];
|
||||||
const NAME: NameType = "setup";
|
const NAME: NameType = "setup";
|
||||||
const OPTIONS: &'static [OptionType] = &[];
|
const OPTIONS: &'static [OptionType] = &[];
|
||||||
const SUBCOMMANDS: &'static [SubCommandType] = &[];
|
const SUBCOMMANDS: &'static [SubCommandType] = &[];
|
||||||
|
|
||||||
#[cfg_attr(tarpaulin, skip)]
|
#[cfg_attr(tarpaulin, skip)]
|
||||||
fn parse(_arguments: &ArgMatches) -> Result<Self::Options, CLIError> {
|
fn parse(arguments: &ArgMatches) -> Result<Self::Options, CLIError> {
|
||||||
Ok(())
|
Ok(!arguments.is_present("skip-key-check"))
|
||||||
}
|
}
|
||||||
|
|
||||||
#[cfg_attr(tarpaulin, skip)]
|
#[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
|
// Get the package name
|
||||||
let path = current_dir()?;
|
let path = current_dir()?;
|
||||||
let package_name = Manifest::try_from(path.as_path())?.get_package_name();
|
let package_name = Manifest::try_from(path.as_path())?.get_package_name();
|
||||||
|
|
||||||
match BuildCommand::output(options)? {
|
match BuildCommand::output(())? {
|
||||||
Some((program, checksum_differs)) => {
|
Some((program, checksum_differs)) => {
|
||||||
// Begin "Setup" context for console logging
|
// Begin "Setup" context for console logging
|
||||||
let span = tracing::span!(tracing::Level::INFO, "Setup");
|
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
|
// Read the proving key file from the output directory
|
||||||
tracing::info!("Loading proving key...");
|
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_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");
|
tracing::info!("Complete");
|
||||||
|
|
||||||
// Read the verification key file from the output directory
|
// Read the verification key file from the output directory
|
||||||
|
Loading…
Reference in New Issue
Block a user