add core and cli changes
This commit is contained in:
parent
27b65f11f6
commit
0589f7e0a6
5 changed files with 176 additions and 7 deletions
158
Cargo.lock
generated
158
Cargo.lock
generated
|
@ -401,7 +401,7 @@ version = "0.5.0"
|
|||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "7862e21c893d65a1650125d157eaeec691439379a1cee17ee49031b79236ada4"
|
||||
dependencies = [
|
||||
"proc-macro-error",
|
||||
"proc-macro-error 1.0.4",
|
||||
"proc-macro2 1.0.37",
|
||||
"quote 1.0.17",
|
||||
"syn 1.0.91",
|
||||
|
@ -679,12 +679,43 @@ dependencies = [
|
|||
"ansi_term 0.12.1",
|
||||
"atty",
|
||||
"bitflags",
|
||||
"strsim",
|
||||
"strsim 0.8.0",
|
||||
"textwrap",
|
||||
"unicode-width",
|
||||
"vec_map",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "clap-v3"
|
||||
version = "3.0.0-beta.1"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "bfac055d61c39ace5061621530f7f55651a261a4fba296ce1bad06d41a8de65e"
|
||||
dependencies = [
|
||||
"ansi_term 0.12.1",
|
||||
"atty",
|
||||
"bitflags",
|
||||
"clap_derive-v3",
|
||||
"indexmap",
|
||||
"lazy_static",
|
||||
"strsim 0.9.3",
|
||||
"textwrap",
|
||||
"unicode-width",
|
||||
"vec_map",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "clap_derive-v3"
|
||||
version = "3.0.0-beta.1"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "c6dd675567eb3e35787bd2583d129e85fabc7503b0a093d08c51198a307e2091"
|
||||
dependencies = [
|
||||
"heck",
|
||||
"proc-macro-error 0.4.12",
|
||||
"proc-macro2 1.0.37",
|
||||
"quote 1.0.17",
|
||||
"syn 1.0.91",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "cmake"
|
||||
version = "0.1.45"
|
||||
|
@ -1034,6 +1065,12 @@ dependencies = [
|
|||
"uint",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "exitcode"
|
||||
version = "1.1.2"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "de853764b47027c2e862a995c34978ffa63c1501f2e15f987ba11bd4f9bba193"
|
||||
|
||||
[[package]]
|
||||
name = "failure"
|
||||
version = "0.1.8"
|
||||
|
@ -1300,6 +1337,15 @@ dependencies = [
|
|||
"ahash",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "heck"
|
||||
version = "0.3.3"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "6d621efb26863f0e9924c6ac577e8275e5e6b77455db64ffa6c65c904e9e132c"
|
||||
dependencies = [
|
||||
"unicode-segmentation",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "hermit-abi"
|
||||
version = "0.1.19"
|
||||
|
@ -1321,6 +1367,25 @@ version = "0.4.3"
|
|||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "7f24254aa9a54b5c858eaee2f5bccdb46aaf0e486a595ed5fd8f86ba55232a70"
|
||||
|
||||
[[package]]
|
||||
name = "hex-literal"
|
||||
version = "0.2.2"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "d70693199b3cf4552f3fa720b54163927a3ebed2aef240efaf556033ab336a11"
|
||||
dependencies = [
|
||||
"hex-literal-impl",
|
||||
"proc-macro-hack",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "hex-literal-impl"
|
||||
version = "0.2.3"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "59448fc2f82a5fb6907f78c3d69d843e82ff5b051923313cc4438cb0c7b745a8"
|
||||
dependencies = [
|
||||
"proc-macro-hack",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "humantime"
|
||||
version = "2.1.0"
|
||||
|
@ -1393,6 +1458,15 @@ dependencies = [
|
|||
"either",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "itertools"
|
||||
version = "0.8.2"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "f56a2d0bc861f9165be4eb3442afd3c236d8a98afd426f65d92324ae1091a484"
|
||||
dependencies = [
|
||||
"either",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "itoa"
|
||||
version = "0.4.8"
|
||||
|
@ -1729,7 +1803,7 @@ version = "0.3.3"
|
|||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "3fbf404899169771dd6a32c84248b83cd67a26cc7cc957aac87661490e1227e4"
|
||||
dependencies = [
|
||||
"itertools",
|
||||
"itertools 0.7.11",
|
||||
"proc-macro2 0.4.30",
|
||||
"quote 0.6.13",
|
||||
"single",
|
||||
|
@ -1851,19 +1925,45 @@ dependencies = [
|
|||
"toml",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "proc-macro-error"
|
||||
version = "0.4.12"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "18f33027081eba0a6d8aba6d1b1c3a3be58cbb12106341c2d5759fcd9b5277e7"
|
||||
dependencies = [
|
||||
"proc-macro-error-attr 0.4.12",
|
||||
"proc-macro2 1.0.37",
|
||||
"quote 1.0.17",
|
||||
"syn 1.0.91",
|
||||
"version_check",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "proc-macro-error"
|
||||
version = "1.0.4"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "da25490ff9892aab3fcf7c36f08cfb902dd3e71ca0f9f9517bea02a73a5ce38c"
|
||||
dependencies = [
|
||||
"proc-macro-error-attr",
|
||||
"proc-macro-error-attr 1.0.4",
|
||||
"proc-macro2 1.0.37",
|
||||
"quote 1.0.17",
|
||||
"syn 1.0.91",
|
||||
"version_check",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "proc-macro-error-attr"
|
||||
version = "0.4.12"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "8a5b4b77fdb63c1eca72173d68d24501c54ab1269409f6b672c85deb18af69de"
|
||||
dependencies = [
|
||||
"proc-macro2 1.0.37",
|
||||
"quote 1.0.17",
|
||||
"syn 1.0.91",
|
||||
"syn-mid",
|
||||
"version_check",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "proc-macro-error-attr"
|
||||
version = "1.0.4"
|
||||
|
@ -1875,6 +1975,12 @@ dependencies = [
|
|||
"version_check",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "proc-macro-hack"
|
||||
version = "0.5.19"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "dbf0c48bc1d91375ae5c3cd81e3722dff1abcf81a30960240640d223f59fe0e5"
|
||||
|
||||
[[package]]
|
||||
name = "proc-macro2"
|
||||
version = "0.4.30"
|
||||
|
@ -2391,6 +2497,12 @@ version = "0.8.0"
|
|||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "8ea5119cdb4c55b55d432abb513a0429384878c15dde60cc77b1c99de1a95a6a"
|
||||
|
||||
[[package]]
|
||||
name = "strsim"
|
||||
version = "0.9.3"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "6446ced80d6c486436db5c078dde11a9f73d42b57fb273121e160b84f63d894c"
|
||||
|
||||
[[package]]
|
||||
name = "substrate-bn"
|
||||
version = "0.6.0"
|
||||
|
@ -2438,6 +2550,17 @@ dependencies = [
|
|||
"unicode-xid 0.2.2",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "syn-mid"
|
||||
version = "0.5.3"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "baa8e7560a164edb1621a55d18a0c59abf49d360f47aa7b821061dd7eea7fac9"
|
||||
dependencies = [
|
||||
"proc-macro2 1.0.37",
|
||||
"quote 1.0.17",
|
||||
"syn 1.0.91",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "synstructure"
|
||||
version = "0.12.6"
|
||||
|
@ -2619,6 +2742,12 @@ dependencies = [
|
|||
"version_check",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "unicode-segmentation"
|
||||
version = "1.9.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "7e8820f5d777f6224dc4be3632222971ac30164d4a258d595640799554ebfd99"
|
||||
|
||||
[[package]]
|
||||
name = "unicode-width"
|
||||
version = "0.1.9"
|
||||
|
@ -2839,6 +2968,26 @@ dependencies = [
|
|||
"synstructure",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "zkutil"
|
||||
version = "0.5.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "51266e3b8d99e954d29b93a28464ee6ca239302bf38b2308137ff23d9fcce50c"
|
||||
dependencies = [
|
||||
"bellman_ce",
|
||||
"byteorder",
|
||||
"cfg-if 0.1.10",
|
||||
"clap-v3",
|
||||
"exitcode",
|
||||
"hex-literal",
|
||||
"itertools 0.8.2",
|
||||
"num-bigint 0.2.6",
|
||||
"num-traits 0.2.14",
|
||||
"rand 0.4.6",
|
||||
"serde",
|
||||
"serde_json",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "zokrates_abi"
|
||||
version = "0.1.7"
|
||||
|
@ -2856,6 +3005,7 @@ version = "0.1.0"
|
|||
dependencies = [
|
||||
"byteorder",
|
||||
"pretty_assertions 1.2.1",
|
||||
"zkutil",
|
||||
"zokrates_core",
|
||||
"zokrates_field",
|
||||
]
|
||||
|
|
|
@ -1,7 +1,8 @@
|
|||
use zokrates_common::constants::*;
|
||||
|
||||
pub const FLATTENED_CODE_DEFAULT_PATH: &str = "out";
|
||||
pub const R1CS_DEFAULT_PATH: &str = "out.r1cs";
|
||||
pub const CIRCOM_R1CS_DEFAULT_PATH: &str = "out.r1cs";
|
||||
pub const CIRCOM_WITNESS_DEFAULT_PATH: &str = "out.wtns";
|
||||
pub const ABI_SPEC_DEFAULT_PATH: &str = "abi.json";
|
||||
pub const VERIFICATION_KEY_DEFAULT_PATH: &str = "verification.key";
|
||||
pub const PROVING_KEY_DEFAULT_PATH: &str = "proving.key";
|
||||
|
|
|
@ -54,7 +54,7 @@ pub fn subcommand() -> App<'static, 'static> {
|
|||
.value_name("FILE")
|
||||
.takes_value(true)
|
||||
.required(false)
|
||||
.default_value(cli_constants::R1CS_DEFAULT_PATH)
|
||||
.default_value(cli_constants::CIRCOM_R1CS_DEFAULT_PATH)
|
||||
).arg(Arg::with_name("curve")
|
||||
.short("c")
|
||||
.long("curve")
|
||||
|
|
|
@ -5,6 +5,7 @@ use std::fs::File;
|
|||
use std::io::{stdin, BufReader, BufWriter, Read};
|
||||
use std::path::Path;
|
||||
use zokrates_abi::Encode;
|
||||
use zokrates_circom::write_witness;
|
||||
use zokrates_core::ir;
|
||||
use zokrates_core::ir::ProgEnum;
|
||||
use zokrates_core::typed_absy::abi::Abi;
|
||||
|
@ -38,6 +39,13 @@ pub fn subcommand() -> App<'static, 'static> {
|
|||
.takes_value(true)
|
||||
.required(false)
|
||||
.default_value(cli_constants::WITNESS_DEFAULT_PATH)
|
||||
).arg(Arg::with_name("witness")
|
||||
.long("witness")
|
||||
.help("Path of the witness file")
|
||||
.value_name("FILE")
|
||||
.takes_value(true)
|
||||
.required(false)
|
||||
.default_value(cli_constants::CIRCOM_WITNESS_DEFAULT_PATH)
|
||||
).arg(Arg::with_name("arguments")
|
||||
.short("a")
|
||||
.long("arguments")
|
||||
|
@ -182,6 +190,16 @@ fn cli_compute<T: Field, I: Iterator<Item = ir::Statement<T>>>(
|
|||
.write(writer)
|
||||
.map_err(|why| format!("Could not save witness: {:?}", why))?;
|
||||
|
||||
// write witness to file
|
||||
let wtns_path = Path::new(sub_matches.value_of("witness").unwrap());
|
||||
let wtns_file = File::create(&wtns_path)
|
||||
.map_err(|why| format!("Could not create {}: {}", output_path.display(), why))?;
|
||||
|
||||
let mut writer = BufWriter::new(wtns_file);
|
||||
|
||||
write_witness(&mut writer, witness)
|
||||
.map_err(|why| format!("Could not save witness: {:?}", why))?;
|
||||
|
||||
println!("Witness file written to '{}'", output_path.display());
|
||||
Ok(())
|
||||
}
|
||||
|
|
|
@ -5,7 +5,7 @@ use std::io;
|
|||
use std::io::{Read, Write};
|
||||
use zokrates_field::Field;
|
||||
|
||||
#[derive(Clone, Debug, PartialEq)]
|
||||
#[derive(Clone, Debug, PartialEq, Default)]
|
||||
pub struct Witness<T>(pub BTreeMap<FlatVariable, T>);
|
||||
|
||||
impl<T: Field> Witness<T> {
|
||||
|
|
Loading…
Reference in a new issue