mirror of
https://github.com/ProvableHQ/leo.git
synced 2024-12-25 03:04:13 +03:00
Merge pull request #589 from AleoHQ/add-check-setup
[CLI] Adds --skip-key-check option to setup, run and prove commands
This commit is contained in:
commit
bdae2425a7
47
.github/workflows/leo-setup.yml
vendored
Normal file
47
.github/workflows/leo-setup.yml
vendored
Normal file
@ -0,0 +1,47 @@
|
||||
name: leo-setup
|
||||
on:
|
||||
pull_request:
|
||||
push:
|
||||
branches:
|
||||
- master
|
||||
paths-ignore:
|
||||
- 'docs/**'
|
||||
- 'documentation/**'
|
||||
env:
|
||||
RUST_BACKTRACE: 1
|
||||
|
||||
jobs:
|
||||
add:
|
||||
name: Add Package ('leo add')
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- name: Checkout
|
||||
uses: actions/checkout@v1
|
||||
|
||||
- name: Install Rust
|
||||
uses: actions-rs/toolchain@v1
|
||||
with:
|
||||
profile: minimal
|
||||
toolchain: nightly
|
||||
override: true
|
||||
components: rustfmt
|
||||
|
||||
- name: Install Leo
|
||||
uses: actions-rs/cargo@v1
|
||||
env:
|
||||
CARGO_NET_GIT_FETCH_WITH_CLI: true
|
||||
with:
|
||||
command: install
|
||||
args: --path .
|
||||
|
||||
- name: 'leo setup for examples'
|
||||
env:
|
||||
USER: ${{ secrets.ALEO_PM_USERNAME }}
|
||||
PASS: ${{ secrets.ALEO_PM_PASSWORD }}
|
||||
run: |
|
||||
cd examples/pedersen-hash
|
||||
leo setup
|
||||
leo setup
|
||||
leo setup --skip-key-check
|
||||
leo clean
|
||||
|
@ -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");
|
||||
|
@ -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");
|
||||
|
@ -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
|
||||
|
Loading…
Reference in New Issue
Block a user