Merge branch 'develop' of github.com:Zokrates/ZoKrates into remove-array-ssa
This commit is contained in:
commit
952a0092ca
74 changed files with 399 additions and 323 deletions
|
@ -75,7 +75,7 @@ jobs:
|
|||
- v4-cargo-cache-{{ arch }}-{{ checksum "Cargo.lock" }}
|
||||
- run:
|
||||
name: Test on firefox
|
||||
command: GECKODRIVER=geckodriver cd zokrates_core && wasm-pack test --firefox --headless -- --features wasm
|
||||
command: GECKODRIVER=geckodriver cd zokrates_core && wasm-pack test --firefox --headless -- --no-default-features --features "wasm bellman"
|
||||
integration_test:
|
||||
docker:
|
||||
- image: zokrates/env:latest
|
||||
|
|
2
.gitignore
vendored
2
.gitignore
vendored
|
@ -1,6 +1,6 @@
|
|||
# Generated by Cargo
|
||||
# will have compiled files and executables
|
||||
/target/
|
||||
target
|
||||
|
||||
# ZoKrates default files
|
||||
out
|
||||
|
|
5
Cargo.lock
generated
5
Cargo.lock
generated
|
@ -1578,6 +1578,9 @@ name = "serde"
|
|||
version = "1.0.117"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "b88fa983de7720629c9387e9f517353ed404164b1e482c970a90c1a4aaf7dc1a"
|
||||
dependencies = [
|
||||
"serde_derive",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "serde_derive"
|
||||
|
@ -2042,6 +2045,7 @@ version = "0.6.2"
|
|||
dependencies = [
|
||||
"assert_cli",
|
||||
"bincode",
|
||||
"cfg-if 0.1.10",
|
||||
"clap",
|
||||
"dirs",
|
||||
"fs_extra",
|
||||
|
@ -2090,7 +2094,6 @@ dependencies = [
|
|||
"reduce",
|
||||
"regex",
|
||||
"serde",
|
||||
"serde_derive",
|
||||
"serde_json",
|
||||
"typed-arena",
|
||||
"wasm-bindgen-test",
|
||||
|
|
|
@ -5,7 +5,7 @@ authors = ["Thibaut Schaeffer <thibaut@schaeff.fr>"]
|
|||
edition = "2018"
|
||||
|
||||
[dependencies]
|
||||
zokrates_field = { version = "0.3", path = "../zokrates_field" }
|
||||
zokrates_field = { version = "0.3", path = "../zokrates_field", default-features = false }
|
||||
zokrates_core = { version = "0.5", path = "../zokrates_core", default-features = false }
|
||||
serde = "1.0"
|
||||
serde_derive = "1.0"
|
||||
|
|
|
@ -6,16 +6,19 @@ repository = "https://github.com/JacobEberhardt/ZoKrates.git"
|
|||
edition = "2018"
|
||||
|
||||
[features]
|
||||
default = []
|
||||
default = ["bellman", "ark"]
|
||||
libsnark = ["zokrates_core/libsnark"]
|
||||
bellman = ["zokrates_core/bellman"]
|
||||
ark = ["zokrates_core/ark"]
|
||||
|
||||
[dependencies]
|
||||
cfg-if = "0.1"
|
||||
clap = "2.26.2"
|
||||
bincode = "0.8.0"
|
||||
regex = "0.2"
|
||||
zokrates_field = { version = "0.3", path = "../zokrates_field" }
|
||||
zokrates_field = { version = "0.3", path = "../zokrates_field", default-features = false }
|
||||
zokrates_abi = { version = "0.1", path = "../zokrates_abi" }
|
||||
zokrates_core = { version = "0.5", path = "../zokrates_core", features = ["multicore", "ark"] }
|
||||
zokrates_core = { version = "0.5", path = "../zokrates_core", default-features = false }
|
||||
zokrates_fs_resolver = { version = "0.5", path = "../zokrates_fs_resolver"}
|
||||
serde_json = "1.0"
|
||||
dirs = "3.0.1"
|
||||
|
|
|
@ -21,18 +21,24 @@ use std::string::String;
|
|||
use zokrates_abi::Encode;
|
||||
use zokrates_core::compile::{check, compile, CompilationArtifacts, CompileError};
|
||||
use zokrates_core::ir::{self, ProgEnum};
|
||||
|
||||
use zokrates_core::proof_system::{
|
||||
ark::Ark, bellman::Bellman, gm17::GM17, groth16::G16, SolidityCompatibleField,
|
||||
gm17::GM17, groth16::G16, pghr13::PGHR13, SolidityCompatibleField,
|
||||
};
|
||||
use zokrates_core::proof_system::{Backend, Scheme, SolidityAbi, SolidityCompatibleScheme};
|
||||
use zokrates_core::proof_system::{SolidityAbi, SolidityCompatibleScheme};
|
||||
use zokrates_core::typed_absy::abi::Abi;
|
||||
use zokrates_core::typed_absy::{types::Signature, Type};
|
||||
use zokrates_field::{Bls12_377Field, Bls12_381Field, Bn128Field, Bw6_761Field, Field};
|
||||
use zokrates_fs_resolver::FileSystemResolver;
|
||||
|
||||
#[cfg(feature = "ark")]
|
||||
use zokrates_core::proof_system::ark::Ark;
|
||||
#[cfg(feature = "bellman")]
|
||||
use zokrates_core::proof_system::bellman::Bellman;
|
||||
#[cfg(feature = "libsnark")]
|
||||
use {
|
||||
zokrates_core::proof_system::libsnark::Libsnark, zokrates_core::proof_system::pghr13::PGHR13,
|
||||
};
|
||||
use zokrates_core::proof_system::libsnark::Libsnark;
|
||||
#[cfg(any(feature = "bellman", feature = "ark", feature = "libsnark"))]
|
||||
use zokrates_core::proof_system::{Backend, Scheme};
|
||||
|
||||
fn main() {
|
||||
cli().unwrap_or_else(|e| {
|
||||
|
@ -41,6 +47,7 @@ fn main() {
|
|||
})
|
||||
}
|
||||
|
||||
#[cfg(any(feature = "bellman", feature = "ark", feature = "libsnark"))]
|
||||
fn cli_generate_proof<T: Field, S: Scheme<T>, B: Backend<T, S>>(
|
||||
program: ir::Prog<T>,
|
||||
sub_matches: &ArgMatches,
|
||||
|
@ -115,6 +122,7 @@ fn cli_export_verifier<T: SolidityCompatibleField, S: SolidityCompatibleScheme<T
|
|||
Ok(())
|
||||
}
|
||||
|
||||
#[cfg(any(feature = "bellman", feature = "ark", feature = "libsnark"))]
|
||||
fn cli_setup<T: Field, S: Scheme<T>, B: Backend<T, S>>(
|
||||
program: ir::Prog<T>,
|
||||
sub_matches: &ArgMatches,
|
||||
|
@ -397,6 +405,7 @@ fn cli_check<T: Field>(sub_matches: &ArgMatches) -> Result<(), String> {
|
|||
Ok(())
|
||||
}
|
||||
|
||||
#[cfg(any(feature = "bellman", feature = "ark", feature = "libsnark"))]
|
||||
fn cli_verify<T: Field, S: Scheme<T>, B: Backend<T, S>>(
|
||||
sub_matches: &ArgMatches,
|
||||
) -> Result<(), String> {
|
||||
|
@ -821,6 +830,7 @@ fn cli() -> Result<(), String> {
|
|||
ProgEnum::Bw6_761Program(p) => cli_compute(p, sub_matches)?,
|
||||
}
|
||||
}
|
||||
#[cfg(any(feature = "bellman", feature = "ark", feature = "libsnark"))]
|
||||
("setup", Some(sub_matches)) => {
|
||||
// read compiled program
|
||||
let path = Path::new(sub_matches.value_of("input").unwrap());
|
||||
|
@ -842,11 +852,13 @@ fn cli() -> Result<(), String> {
|
|||
))?;
|
||||
|
||||
match parameters {
|
||||
#[cfg(feature = "bellman")]
|
||||
Parameters(BackendParameter::Bellman, _, SchemeParameter::G16) => match prog {
|
||||
ProgEnum::Bn128Program(p) => cli_setup::<_, G16, Bellman>(p, sub_matches),
|
||||
ProgEnum::Bls12_381Program(p) => cli_setup::<_, G16, Bellman>(p, sub_matches),
|
||||
_ => unreachable!(),
|
||||
},
|
||||
#[cfg(feature = "ark")]
|
||||
Parameters(BackendParameter::Ark, _, SchemeParameter::GM17) => match prog {
|
||||
ProgEnum::Bls12_377Program(p) => cli_setup::<_, GM17, Ark>(p, sub_matches),
|
||||
ProgEnum::Bw6_761Program(p) => cli_setup::<_, GM17, Ark>(p, sub_matches),
|
||||
|
@ -887,13 +899,13 @@ fn cli() -> Result<(), String> {
|
|||
(CurveParameter::Bn128, SchemeParameter::GM17) => {
|
||||
cli_export_verifier::<Bn128Field, GM17>(sub_matches)
|
||||
}
|
||||
#[cfg(feature = "libsnark")]
|
||||
(CurveParameter::Bn128, SchemeParameter::PGHR13) => {
|
||||
cli_export_verifier::<Bn128Field, PGHR13>(sub_matches)
|
||||
}
|
||||
_ => Err(format!("Could not export verifier with given parameters (curve: {}, scheme: {}): not supported", curve, scheme))
|
||||
}?
|
||||
}
|
||||
#[cfg(any(feature = "bellman", feature = "ark", feature = "libsnark"))]
|
||||
("generate-proof", Some(sub_matches)) => {
|
||||
let program_path = Path::new(sub_matches.value_of("input").unwrap());
|
||||
let program_file = File::open(&program_path)
|
||||
|
@ -914,6 +926,7 @@ fn cli() -> Result<(), String> {
|
|||
))?;
|
||||
|
||||
match parameters {
|
||||
#[cfg(feature = "bellman")]
|
||||
Parameters(BackendParameter::Bellman, _, SchemeParameter::G16) => match prog {
|
||||
ProgEnum::Bn128Program(p) => {
|
||||
cli_generate_proof::<_, G16, Bellman>(p, sub_matches)
|
||||
|
@ -923,6 +936,7 @@ fn cli() -> Result<(), String> {
|
|||
}
|
||||
_ => unreachable!(),
|
||||
},
|
||||
#[cfg(feature = "ark")]
|
||||
Parameters(BackendParameter::Ark, _, SchemeParameter::GM17) => match prog {
|
||||
ProgEnum::Bls12_377Program(p) => {
|
||||
cli_generate_proof::<_, GM17, Ark>(p, sub_matches)
|
||||
|
@ -994,6 +1008,7 @@ fn cli() -> Result<(), String> {
|
|||
_ => unreachable!(),
|
||||
}
|
||||
}
|
||||
#[cfg(any(feature = "bellman", feature = "ark", feature = "libsnark"))]
|
||||
("verify", Some(sub_matches)) => {
|
||||
let parameters = Parameters::try_from((
|
||||
sub_matches.value_of("backend").unwrap(),
|
||||
|
@ -1002,26 +1017,31 @@ fn cli() -> Result<(), String> {
|
|||
))?;
|
||||
|
||||
match parameters {
|
||||
#[cfg(feature = "bellman")]
|
||||
Parameters(
|
||||
BackendParameter::Bellman,
|
||||
CurveParameter::Bn128,
|
||||
SchemeParameter::G16,
|
||||
) => cli_verify::<Bn128Field, G16, Bellman>(sub_matches),
|
||||
#[cfg(feature = "bellman")]
|
||||
Parameters(
|
||||
BackendParameter::Bellman,
|
||||
CurveParameter::Bls12_381,
|
||||
SchemeParameter::G16,
|
||||
) => cli_verify::<Bls12_381Field, G16, Bellman>(sub_matches),
|
||||
#[cfg(feature = "ark")]
|
||||
Parameters(
|
||||
BackendParameter::Ark,
|
||||
CurveParameter::Bls12_377,
|
||||
SchemeParameter::GM17,
|
||||
) => cli_verify::<Bls12_377Field, GM17, Ark>(sub_matches),
|
||||
#[cfg(feature = "ark")]
|
||||
Parameters(
|
||||
BackendParameter::Ark,
|
||||
CurveParameter::Bw6_761,
|
||||
SchemeParameter::GM17,
|
||||
) => cli_verify::<Bw6_761Field, GM17, Ark>(sub_matches),
|
||||
#[cfg(feature = "ark")]
|
||||
Parameters(BackendParameter::Ark, CurveParameter::Bn128, SchemeParameter::GM17) => {
|
||||
cli_verify::<Bn128Field, GM17, Ark>(sub_matches)
|
||||
}
|
||||
|
|
|
@ -1,12 +1,36 @@
|
|||
pub const BELLMAN: &str = "bellman";
|
||||
#[cfg(feature = "libsnark")]
|
||||
pub const LIBSNARK: &str = "libsnark";
|
||||
pub const ARK: &str = "ark";
|
||||
|
||||
#[cfg(feature = "libsnark")]
|
||||
pub const BACKENDS: &[&str] = &[BELLMAN, LIBSNARK, ARK];
|
||||
#[cfg(not(feature = "libsnark"))]
|
||||
pub const BACKENDS: &[&str] = &[BELLMAN, ARK];
|
||||
pub const BACKENDS: &[&str] = if cfg!(feature = "libsnark") {
|
||||
if cfg!(feature = "ark") {
|
||||
if cfg!(feature = "bellman") {
|
||||
&[BELLMAN, LIBSNARK, ARK]
|
||||
} else {
|
||||
&[LIBSNARK, ARK]
|
||||
}
|
||||
} else {
|
||||
if cfg!(feature = "bellman") {
|
||||
&[BELLMAN, LIBSNARK]
|
||||
} else {
|
||||
&[LIBSNARK]
|
||||
}
|
||||
}
|
||||
} else {
|
||||
if cfg!(feature = "ark") {
|
||||
if cfg!(feature = "bellman") {
|
||||
&[BELLMAN, ARK]
|
||||
} else {
|
||||
&[ARK]
|
||||
}
|
||||
} else {
|
||||
if cfg!(feature = "bellman") {
|
||||
&[BELLMAN]
|
||||
} else {
|
||||
&[]
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
pub const BN128: &str = "bn128";
|
||||
pub const BLS12_381: &str = "bls12_381";
|
||||
|
@ -15,11 +39,7 @@ pub const BW6_761: &str = "bw6_761";
|
|||
pub const CURVES: &[&str] = &[BN128, BLS12_381, BLS12_377, BW6_761];
|
||||
|
||||
pub const G16: &str = "g16";
|
||||
#[cfg(feature = "libsnark")]
|
||||
pub const PGHR13: &str = "pghr13";
|
||||
pub const GM17: &str = "gm17";
|
||||
|
||||
#[cfg(feature = "libsnark")]
|
||||
pub const SCHEMES: &[&str] = &[G16, PGHR13, GM17];
|
||||
#[cfg(not(feature = "libsnark"))]
|
||||
pub const SCHEMES: &[&str] = &[G16, GM17];
|
||||
|
|
|
@ -11,7 +11,9 @@ pub enum CurveParameter {
|
|||
}
|
||||
|
||||
pub enum BackendParameter {
|
||||
#[cfg(feature = "bellman")]
|
||||
Bellman,
|
||||
#[cfg(feature = "ark")]
|
||||
Ark,
|
||||
#[cfg(feature = "libsnark")]
|
||||
Libsnark,
|
||||
|
@ -20,7 +22,6 @@ pub enum BackendParameter {
|
|||
pub enum SchemeParameter {
|
||||
G16,
|
||||
GM17,
|
||||
#[cfg(feature = "libsnark")]
|
||||
PGHR13,
|
||||
}
|
||||
|
||||
|
@ -43,7 +44,9 @@ impl TryFrom<&str> for BackendParameter {
|
|||
|
||||
fn try_from(s: &str) -> Result<Self, Self::Error> {
|
||||
match s {
|
||||
#[cfg(feature = "bellman")]
|
||||
BELLMAN => Ok(BackendParameter::Bellman),
|
||||
#[cfg(feature = "ark")]
|
||||
ARK => Ok(BackendParameter::Ark),
|
||||
#[cfg(feature = "libsnark")]
|
||||
LIBSNARK => Ok(BackendParameter::Libsnark),
|
||||
|
@ -59,7 +62,6 @@ impl TryFrom<&str> for SchemeParameter {
|
|||
match s {
|
||||
G16 => Ok(SchemeParameter::G16),
|
||||
GM17 => Ok(SchemeParameter::GM17),
|
||||
#[cfg(feature = "libsnark")]
|
||||
PGHR13 => Ok(SchemeParameter::PGHR13),
|
||||
_ => Err(format!("Unknown proving scheme {}", s)),
|
||||
}
|
||||
|
@ -81,10 +83,15 @@ impl TryFrom<(&str, &str, &str)> for Parameters {
|
|||
let proving_scheme = SchemeParameter::try_from(s.2)?;
|
||||
|
||||
match (&backend, &curve, &proving_scheme) {
|
||||
#[cfg(feature = "bellman")]
|
||||
(BackendParameter::Bellman, CurveParameter::Bn128, SchemeParameter::G16) => Ok(()),
|
||||
#[cfg(feature = "bellman")]
|
||||
(BackendParameter::Bellman, CurveParameter::Bls12_381, SchemeParameter::G16) => Ok(()),
|
||||
#[cfg(feature = "ark")]
|
||||
(BackendParameter::Ark, CurveParameter::Bls12_377, SchemeParameter::GM17) => Ok(()),
|
||||
#[cfg(feature = "ark")]
|
||||
(BackendParameter::Ark, CurveParameter::Bw6_761, SchemeParameter::GM17) => Ok(()),
|
||||
#[cfg(feature = "ark")]
|
||||
(BackendParameter::Ark, CurveParameter::Bn128, SchemeParameter::GM17) => Ok(()),
|
||||
#[cfg(feature = "libsnark")]
|
||||
(BackendParameter::Libsnark, CurveParameter::Bn128, SchemeParameter::GM17) => Ok(()),
|
||||
|
@ -94,6 +101,6 @@ impl TryFrom<(&str, &str, &str)> for Parameters {
|
|||
"Unsupported combination of parameters (backend: {}, curve: {}, proving scheme: {})",
|
||||
s.0, s.1, s.2
|
||||
)),
|
||||
}.map(|_| Parameters(backend, curve, proving_scheme))
|
||||
}.map(|_: ()| Parameters(backend, curve, proving_scheme))
|
||||
}
|
||||
}
|
||||
|
|
|
@ -214,7 +214,8 @@ mod integration {
|
|||
#[cfg(feature = "libsnark")]
|
||||
let backends = map! {
|
||||
"bellman" => ["g16"],
|
||||
"libsnark" => ["gm17", "pghr13"]
|
||||
"libsnark" => ["pghr13"],
|
||||
"ark" => ["gm17"]
|
||||
};
|
||||
|
||||
#[cfg(not(feature = "libsnark"))]
|
||||
|
|
|
@ -1,17 +1,19 @@
|
|||
[package]
|
||||
name = "zokrates_core"
|
||||
version = "0.5.2"
|
||||
edition = "2018"
|
||||
authors = ["Jacob Eberhardt <jacob.eberhardt@tu-berlin.de>", "Dennis Kuhnert <mail@kyroy.com>"]
|
||||
repository = "https://github.com/JacobEberhardt/ZoKrates"
|
||||
readme = "README.md"
|
||||
build = "build.rs"
|
||||
|
||||
[features]
|
||||
default = []
|
||||
default = ["bellman", "ark"]
|
||||
libsnark = ["cc", "cmake", "git2"]
|
||||
bellman = ["bellman_ce", "pairing_ce", "ff_ce", "zokrates_field/bellman"]
|
||||
wasm = ["bellman_ce/nolog", "bellman_ce/wasm"]
|
||||
multicore = ["bellman_ce/multicore"]
|
||||
ark = ["ark-ff", "ark-ec", "ark-bn254", "ark-bls12-377", "ark-bw6-761", "ark-gm17", "ark-serialize", "ark-relations"]
|
||||
ark = ["ark-ff", "ark-ec", "ark-bn254", "ark-bls12-377", "ark-bw6-761", "ark-gm17", "ark-serialize", "ark-relations", "zokrates_field/ark"]
|
||||
|
||||
[dependencies]
|
||||
cfg-if = "0.1"
|
||||
|
@ -21,34 +23,32 @@ lazy_static = "1.4"
|
|||
typed-arena = "1.4.1"
|
||||
reduce = "0.1.1"
|
||||
# serialization and deserialization
|
||||
serde = "1.0"
|
||||
serde_derive = "1.0"
|
||||
serde = { version = "1.0", features = ["derive"] }
|
||||
serde_json = "1.0"
|
||||
bincode = "0.8.0"
|
||||
hex = "0.4.2"
|
||||
regex = "0.2"
|
||||
pairing_ce = "^0.21"
|
||||
ff_ce = "^0.9"
|
||||
zokrates_field = { version = "0.3.0", path = "../zokrates_field" }
|
||||
zokrates_field = { version = "0.3.0", path = "../zokrates_field", default-features = false }
|
||||
zokrates_pest_ast = { version = "0.1.0", path = "../zokrates_pest_ast" }
|
||||
zokrates_common = { path = "../zokrates_common" }
|
||||
rand_0_4 = { version = "0.4", package = "rand" }
|
||||
rand_0_7 = { version = "0.7", package = "rand" }
|
||||
csv = "1"
|
||||
bellman_ce = { version = "^0.3", default-features = false }
|
||||
|
||||
# bellman
|
||||
bellman_ce = { version = "^0.3", default-features = false, optional = true }
|
||||
pairing_ce = { version = "^0.21", optional = true }
|
||||
ff_ce = { version = "^0.9", optional = true }
|
||||
|
||||
# ark
|
||||
ark-ff = { git = "https://github.com/arkworks-rs/algebra", default-features = false, optional = true }
|
||||
ark-ec = { git = "https://github.com/arkworks-rs/algebra", default-features = false, optional = true }
|
||||
|
||||
ark-bn254 = { git = "https://github.com/arkworks-rs/curves", features = ["curve"], default-features = false, optional = true }
|
||||
ark-bls12-377 = { git = "https://github.com/arkworks-rs/curves", features = ["curve"], default-features = false, optional = true }
|
||||
ark-bw6-761 = { git = "https://github.com/arkworks-rs/curves", default-features = false, optional = true }
|
||||
|
||||
|
||||
ark-gm17 = { git = "https://github.com/arkworks-rs/gm17", default-features = false, optional = true }
|
||||
ark-serialize = { git = "https://github.com/arkworks-rs/algebra", default-features = false, optional = true }
|
||||
ark-relations = { git = "https://github.com/arkworks-rs/snark", default-features = false, optional = true }
|
||||
#algebra = { git = "https://github.com/scipr-lab/ark.git", features = ["bn254", "bls12_377", "bw6_761"], default-features = false, optional = true }
|
||||
|
||||
[dev-dependencies]
|
||||
wasm-bindgen-test = "^0.3.0"
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
use absy;
|
||||
use imports;
|
||||
use crate::absy;
|
||||
use crate::imports;
|
||||
|
||||
use num::ToPrimitive;
|
||||
use num_bigint::BigUint;
|
||||
|
@ -23,7 +23,7 @@ impl<'ast> From<pest::File<'ast>> for absy::Module<'ast> {
|
|||
|
||||
impl<'ast> From<pest::ImportDirective<'ast>> for absy::ImportNode<'ast> {
|
||||
fn from(import: pest::ImportDirective<'ast>) -> absy::ImportNode<'ast> {
|
||||
use absy::NodeValue;
|
||||
use crate::absy::NodeValue;
|
||||
|
||||
match import {
|
||||
pest::ImportDirective::Main(import) => {
|
||||
|
@ -48,7 +48,7 @@ impl<'ast> From<pest::ImportDirective<'ast>> for absy::ImportNode<'ast> {
|
|||
|
||||
impl<'ast> From<pest::StructDefinition<'ast>> for absy::SymbolDeclarationNode<'ast> {
|
||||
fn from(definition: pest::StructDefinition<'ast>) -> absy::SymbolDeclarationNode<'ast> {
|
||||
use absy::NodeValue;
|
||||
use crate::absy::NodeValue;
|
||||
|
||||
let span = definition.span;
|
||||
|
||||
|
@ -73,7 +73,7 @@ impl<'ast> From<pest::StructDefinition<'ast>> for absy::SymbolDeclarationNode<'a
|
|||
|
||||
impl<'ast> From<pest::StructField<'ast>> for absy::StructDefinitionFieldNode<'ast> {
|
||||
fn from(field: pest::StructField<'ast>) -> absy::StructDefinitionFieldNode {
|
||||
use absy::NodeValue;
|
||||
use crate::absy::NodeValue;
|
||||
|
||||
let span = field.span;
|
||||
|
||||
|
@ -87,7 +87,7 @@ impl<'ast> From<pest::StructField<'ast>> for absy::StructDefinitionFieldNode<'as
|
|||
|
||||
impl<'ast> From<pest::Function<'ast>> for absy::SymbolDeclarationNode<'ast> {
|
||||
fn from(function: pest::Function<'ast>) -> absy::SymbolDeclarationNode<'ast> {
|
||||
use absy::NodeValue;
|
||||
use crate::absy::NodeValue;
|
||||
|
||||
let span = function.span;
|
||||
|
||||
|
@ -136,7 +136,7 @@ impl<'ast> From<pest::Function<'ast>> for absy::SymbolDeclarationNode<'ast> {
|
|||
|
||||
impl<'ast> From<pest::Parameter<'ast>> for absy::ParameterNode<'ast> {
|
||||
fn from(param: pest::Parameter<'ast>) -> absy::ParameterNode<'ast> {
|
||||
use absy::NodeValue;
|
||||
use crate::absy::NodeValue;
|
||||
|
||||
let private = param
|
||||
.visibility
|
||||
|
@ -166,7 +166,7 @@ fn statements_from_statement(statement: pest::Statement) -> Vec<absy::StatementN
|
|||
}
|
||||
|
||||
fn statements_from_definition(definition: pest::DefinitionStatement) -> Vec<absy::StatementNode> {
|
||||
use absy::NodeValue;
|
||||
use crate::absy::NodeValue;
|
||||
|
||||
let lhs = definition.lhs;
|
||||
|
||||
|
@ -240,7 +240,7 @@ fn statements_from_definition(definition: pest::DefinitionStatement) -> Vec<absy
|
|||
|
||||
impl<'ast> From<pest::ReturnStatement<'ast>> for absy::StatementNode<'ast> {
|
||||
fn from(statement: pest::ReturnStatement<'ast>) -> absy::StatementNode<'ast> {
|
||||
use absy::NodeValue;
|
||||
use crate::absy::NodeValue;
|
||||
|
||||
absy::Statement::Return(
|
||||
absy::ExpressionList {
|
||||
|
@ -258,7 +258,7 @@ impl<'ast> From<pest::ReturnStatement<'ast>> for absy::StatementNode<'ast> {
|
|||
|
||||
impl<'ast> From<pest::AssertionStatement<'ast>> for absy::StatementNode<'ast> {
|
||||
fn from(statement: pest::AssertionStatement<'ast>) -> absy::StatementNode<'ast> {
|
||||
use absy::NodeValue;
|
||||
use crate::absy::NodeValue;
|
||||
|
||||
absy::Statement::Assertion(absy::ExpressionNode::from(statement.expression))
|
||||
.span(statement.span)
|
||||
|
@ -267,7 +267,7 @@ impl<'ast> From<pest::AssertionStatement<'ast>> for absy::StatementNode<'ast> {
|
|||
|
||||
impl<'ast> From<pest::IterationStatement<'ast>> for absy::StatementNode<'ast> {
|
||||
fn from(statement: pest::IterationStatement<'ast>) -> absy::StatementNode<'ast> {
|
||||
use absy::NodeValue;
|
||||
use crate::absy::NodeValue;
|
||||
let from = absy::ExpressionNode::from(statement.from);
|
||||
let to = absy::ExpressionNode::from(statement.to);
|
||||
let index = statement.index.span.as_str();
|
||||
|
@ -302,7 +302,7 @@ impl<'ast> From<pest::Expression<'ast>> for absy::ExpressionNode<'ast> {
|
|||
|
||||
impl<'ast> From<pest::BinaryExpression<'ast>> for absy::ExpressionNode<'ast> {
|
||||
fn from(expression: pest::BinaryExpression<'ast>) -> absy::ExpressionNode<'ast> {
|
||||
use absy::NodeValue;
|
||||
use crate::absy::NodeValue;
|
||||
match expression.op {
|
||||
pest::BinaryOperator::Add => absy::Expression::Add(
|
||||
box absy::ExpressionNode::from(*expression.left),
|
||||
|
@ -391,7 +391,7 @@ impl<'ast> From<pest::BinaryExpression<'ast>> for absy::ExpressionNode<'ast> {
|
|||
|
||||
impl<'ast> From<pest::TernaryExpression<'ast>> for absy::ExpressionNode<'ast> {
|
||||
fn from(expression: pest::TernaryExpression<'ast>) -> absy::ExpressionNode<'ast> {
|
||||
use absy::NodeValue;
|
||||
use crate::absy::NodeValue;
|
||||
absy::Expression::IfElse(
|
||||
box absy::ExpressionNode::from(*expression.first),
|
||||
box absy::ExpressionNode::from(*expression.second),
|
||||
|
@ -403,7 +403,7 @@ impl<'ast> From<pest::TernaryExpression<'ast>> for absy::ExpressionNode<'ast> {
|
|||
|
||||
impl<'ast> From<pest::Spread<'ast>> for absy::SpreadNode<'ast> {
|
||||
fn from(spread: pest::Spread<'ast>) -> absy::SpreadNode<'ast> {
|
||||
use absy::NodeValue;
|
||||
use crate::absy::NodeValue;
|
||||
absy::Spread {
|
||||
expression: absy::ExpressionNode::from(spread.expression),
|
||||
}
|
||||
|
@ -413,7 +413,7 @@ impl<'ast> From<pest::Spread<'ast>> for absy::SpreadNode<'ast> {
|
|||
|
||||
impl<'ast> From<pest::Range<'ast>> for absy::RangeNode<'ast> {
|
||||
fn from(range: pest::Range<'ast>) -> absy::RangeNode<'ast> {
|
||||
use absy::NodeValue;
|
||||
use crate::absy::NodeValue;
|
||||
|
||||
let from = range.from.map(|e| absy::ExpressionNode::from(e.0));
|
||||
|
||||
|
@ -453,7 +453,7 @@ impl<'ast> From<pest::SpreadOrExpression<'ast>> for absy::SpreadOrExpression<'as
|
|||
|
||||
impl<'ast> From<pest::InlineArrayExpression<'ast>> for absy::ExpressionNode<'ast> {
|
||||
fn from(array: pest::InlineArrayExpression<'ast>) -> absy::ExpressionNode<'ast> {
|
||||
use absy::NodeValue;
|
||||
use crate::absy::NodeValue;
|
||||
absy::Expression::InlineArray(
|
||||
array
|
||||
.expressions
|
||||
|
@ -467,7 +467,7 @@ impl<'ast> From<pest::InlineArrayExpression<'ast>> for absy::ExpressionNode<'ast
|
|||
|
||||
impl<'ast> From<pest::InlineStructExpression<'ast>> for absy::ExpressionNode<'ast> {
|
||||
fn from(s: pest::InlineStructExpression<'ast>) -> absy::ExpressionNode<'ast> {
|
||||
use absy::NodeValue;
|
||||
use crate::absy::NodeValue;
|
||||
absy::Expression::InlineStruct(
|
||||
s.ty.span.as_str().to_string(),
|
||||
s.members
|
||||
|
@ -486,7 +486,7 @@ impl<'ast> From<pest::InlineStructExpression<'ast>> for absy::ExpressionNode<'as
|
|||
|
||||
impl<'ast> From<pest::ArrayInitializerExpression<'ast>> for absy::ExpressionNode<'ast> {
|
||||
fn from(initializer: pest::ArrayInitializerExpression<'ast>) -> absy::ExpressionNode<'ast> {
|
||||
use absy::NodeValue;
|
||||
use crate::absy::NodeValue;
|
||||
|
||||
let value = absy::ExpressionNode::from(*initializer.value);
|
||||
let count: absy::ExpressionNode<'ast> = absy::ExpressionNode::from(initializer.count);
|
||||
|
@ -501,7 +501,7 @@ impl<'ast> From<pest::ArrayInitializerExpression<'ast>> for absy::ExpressionNode
|
|||
|
||||
impl<'ast> From<pest::UnaryExpression<'ast>> for absy::ExpressionNode<'ast> {
|
||||
fn from(unary: pest::UnaryExpression<'ast>) -> absy::ExpressionNode<'ast> {
|
||||
use absy::NodeValue;
|
||||
use crate::absy::NodeValue;
|
||||
|
||||
match unary.op {
|
||||
pest::UnaryOperator::Not(_) => {
|
||||
|
@ -514,7 +514,7 @@ impl<'ast> From<pest::UnaryExpression<'ast>> for absy::ExpressionNode<'ast> {
|
|||
|
||||
impl<'ast> From<pest::PostfixExpression<'ast>> for absy::ExpressionNode<'ast> {
|
||||
fn from(expression: pest::PostfixExpression<'ast>) -> absy::ExpressionNode<'ast> {
|
||||
use absy::NodeValue;
|
||||
use crate::absy::NodeValue;
|
||||
|
||||
let id_str = expression.id.span.as_str();
|
||||
let id = absy::ExpressionNode::from(expression.id);
|
||||
|
@ -548,7 +548,7 @@ impl<'ast> From<pest::PostfixExpression<'ast>> for absy::ExpressionNode<'ast> {
|
|||
|
||||
impl<'ast> From<pest::ConstantExpression<'ast>> for absy::ExpressionNode<'ast> {
|
||||
fn from(expression: pest::ConstantExpression<'ast>) -> absy::ExpressionNode<'ast> {
|
||||
use absy::NodeValue;
|
||||
use crate::absy::NodeValue;
|
||||
match expression {
|
||||
pest::ConstantExpression::BooleanLiteral(c) => {
|
||||
absy::Expression::BooleanConstant(c.value.parse().unwrap()).span(c.span)
|
||||
|
@ -575,14 +575,14 @@ impl<'ast> From<pest::ConstantExpression<'ast>> for absy::ExpressionNode<'ast> {
|
|||
|
||||
impl<'ast> From<pest::IdentifierExpression<'ast>> for absy::ExpressionNode<'ast> {
|
||||
fn from(expression: pest::IdentifierExpression<'ast>) -> absy::ExpressionNode<'ast> {
|
||||
use absy::NodeValue;
|
||||
use crate::absy::NodeValue;
|
||||
absy::Expression::Identifier(expression.span.as_str()).span(expression.span)
|
||||
}
|
||||
}
|
||||
|
||||
impl<'ast> From<pest::IdentifierExpression<'ast>> for absy::AssigneeNode<'ast> {
|
||||
fn from(expression: pest::IdentifierExpression<'ast>) -> absy::AssigneeNode<'ast> {
|
||||
use absy::NodeValue;
|
||||
use crate::absy::NodeValue;
|
||||
|
||||
absy::Assignee::Identifier(expression.span.as_str()).span(expression.span)
|
||||
}
|
||||
|
@ -590,7 +590,7 @@ impl<'ast> From<pest::IdentifierExpression<'ast>> for absy::AssigneeNode<'ast> {
|
|||
|
||||
impl<'ast> From<pest::Assignee<'ast>> for absy::AssigneeNode<'ast> {
|
||||
fn from(assignee: pest::Assignee<'ast>) -> absy::AssigneeNode<'ast> {
|
||||
use absy::NodeValue;
|
||||
use crate::absy::NodeValue;
|
||||
|
||||
let a = absy::AssigneeNode::from(assignee.id);
|
||||
let span = assignee.span;
|
||||
|
@ -611,8 +611,8 @@ impl<'ast> From<pest::Assignee<'ast>> for absy::AssigneeNode<'ast> {
|
|||
|
||||
impl<'ast> From<pest::Type<'ast>> for absy::UnresolvedTypeNode {
|
||||
fn from(t: pest::Type<'ast>) -> absy::UnresolvedTypeNode {
|
||||
use absy::types::UnresolvedType;
|
||||
use absy::NodeValue;
|
||||
use crate::absy::types::UnresolvedType;
|
||||
use crate::absy::NodeValue;
|
||||
|
||||
match t {
|
||||
pest::Type::Basic(t) => match t {
|
||||
|
@ -673,8 +673,8 @@ impl<'ast> From<pest::Type<'ast>> for absy::UnresolvedTypeNode {
|
|||
#[cfg(test)]
|
||||
mod tests {
|
||||
use super::*;
|
||||
use absy::types::{UnresolvedSignature, UnresolvedType};
|
||||
use absy::NodeValue;
|
||||
use crate::absy::types::{UnresolvedSignature, UnresolvedType};
|
||||
use crate::absy::NodeValue;
|
||||
|
||||
#[test]
|
||||
fn return_forty_two() {
|
||||
|
|
|
@ -15,7 +15,7 @@ pub use crate::absy::node::{Node, NodeValue};
|
|||
pub use crate::absy::parameter::{Parameter, ParameterNode};
|
||||
use crate::absy::types::{FunctionIdentifier, UnresolvedSignature, UnresolvedType, UserTypeId};
|
||||
pub use crate::absy::variable::{Variable, VariableNode};
|
||||
use embed::FlatEmbed;
|
||||
use crate::embed::FlatEmbed;
|
||||
use std::path::PathBuf;
|
||||
|
||||
use crate::imports::ImportNode;
|
||||
|
|
|
@ -2,7 +2,7 @@ use crate::parser::Position;
|
|||
use std::fmt;
|
||||
use zokrates_pest_ast::Span;
|
||||
|
||||
#[derive(Clone, Serialize, Deserialize)]
|
||||
#[derive(Clone)]
|
||||
pub struct Node<T> {
|
||||
pub start: Position,
|
||||
pub end: Position,
|
||||
|
@ -72,9 +72,9 @@ impl<V: NodeValue> From<V> for Node<V> {
|
|||
}
|
||||
}
|
||||
|
||||
use crate::absy::types::UnresolvedType;
|
||||
use crate::absy::*;
|
||||
use crate::imports::*;
|
||||
use absy::types::UnresolvedType;
|
||||
|
||||
impl<'ast> NodeValue for Expression<'ast> {}
|
||||
impl<'ast> NodeValue for ExpressionList<'ast> {}
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
use absy::UnresolvedTypeNode;
|
||||
use crate::absy::UnresolvedTypeNode;
|
||||
use std::fmt;
|
||||
|
||||
pub type Identifier<'ast> = &'ast str;
|
||||
|
@ -7,7 +7,7 @@ pub type MemberId = String;
|
|||
|
||||
pub type UserTypeId = String;
|
||||
|
||||
#[derive(Clone, PartialEq, Serialize, Deserialize, Debug)]
|
||||
#[derive(Clone, PartialEq, Debug)]
|
||||
pub enum UnresolvedType {
|
||||
FieldElement,
|
||||
Boolean,
|
||||
|
@ -41,9 +41,9 @@ pub use self::signature::UnresolvedSignature;
|
|||
mod signature {
|
||||
use std::fmt;
|
||||
|
||||
use absy::UnresolvedTypeNode;
|
||||
use crate::absy::UnresolvedTypeNode;
|
||||
|
||||
#[derive(Clone, PartialEq, Serialize, Deserialize)]
|
||||
#[derive(Clone, PartialEq)]
|
||||
pub struct UnresolvedSignature {
|
||||
pub inputs: Vec<UnresolvedTypeNode>,
|
||||
pub outputs: Vec<UnresolvedTypeNode>,
|
||||
|
|
|
@ -3,21 +3,21 @@
|
|||
//! @file compile.rs
|
||||
//! @author Thibaut Schaeffer <thibaut@schaeff.fr>
|
||||
//! @date 2018
|
||||
use absy::{Module, ModuleId, Program};
|
||||
use flatten::Flattener;
|
||||
use imports::{self, Importer};
|
||||
use ir;
|
||||
use macros;
|
||||
use crate::absy::{Module, ModuleId, Program};
|
||||
use crate::flatten::Flattener;
|
||||
use crate::imports::{self, Importer};
|
||||
use crate::ir;
|
||||
use crate::macros;
|
||||
use crate::semantics::{self, Checker};
|
||||
use crate::static_analysis::Analyse;
|
||||
use crate::typed_absy::abi::Abi;
|
||||
use crate::zir::ZirProgram;
|
||||
use macros::process_macros;
|
||||
use semantics::{self, Checker};
|
||||
use static_analysis::Analyse;
|
||||
use std::collections::HashMap;
|
||||
use std::fmt;
|
||||
use std::io;
|
||||
use std::path::PathBuf;
|
||||
use typed_absy::abi::Abi;
|
||||
use typed_arena::Arena;
|
||||
use zir::ZirProgram;
|
||||
use zokrates_common::Resolver;
|
||||
use zokrates_field::Field;
|
||||
use zokrates_pest_ast as pest;
|
||||
|
@ -301,8 +301,8 @@ mod test {
|
|||
|
||||
mod abi {
|
||||
use super::*;
|
||||
use typed_absy::abi::*;
|
||||
use typed_absy::types::*;
|
||||
use crate::typed_absy::abi::*;
|
||||
use crate::typed_absy::types::*;
|
||||
|
||||
#[test]
|
||||
fn use_struct_declaration_types() {
|
||||
|
|
|
@ -1,10 +1,10 @@
|
|||
use crate::solvers::Solver;
|
||||
use flat_absy::{
|
||||
use crate::flat_absy::{
|
||||
FlatDirective, FlatExpression, FlatExpressionList, FlatFunction, FlatParameter, FlatStatement,
|
||||
FlatVariable,
|
||||
};
|
||||
use crate::solvers::Solver;
|
||||
use crate::typed_absy::types::{FunctionKey, Signature, Type};
|
||||
use std::collections::HashMap;
|
||||
use typed_absy::types::{FunctionKey, Signature, Type};
|
||||
use zokrates_field::Field;
|
||||
|
||||
/// A low level function that contains non-deterministic introduction of variables. It is carried out as is until
|
||||
|
|
|
@ -2,7 +2,7 @@ use crate::flat_absy::flat_variable::FlatVariable;
|
|||
use std::collections::HashMap;
|
||||
use std::fmt;
|
||||
|
||||
#[derive(Clone, PartialEq, Serialize, Deserialize)]
|
||||
#[derive(Clone, PartialEq)]
|
||||
pub struct FlatParameter {
|
||||
pub id: FlatVariable,
|
||||
pub private: bool,
|
||||
|
|
|
@ -1,3 +1,4 @@
|
|||
use serde::{Deserialize, Serialize};
|
||||
use std::collections::HashMap;
|
||||
use std::fmt;
|
||||
|
||||
|
|
|
@ -11,7 +11,7 @@ pub mod flat_variable;
|
|||
pub use self::flat_parameter::FlatParameter;
|
||||
pub use self::flat_variable::FlatVariable;
|
||||
|
||||
use solvers::Solver;
|
||||
use crate::solvers::Solver;
|
||||
use std::collections::HashMap;
|
||||
use std::fmt;
|
||||
use zokrates_field::Field;
|
||||
|
@ -209,7 +209,7 @@ impl<T: Field> fmt::Display for FlatDirective<T> {
|
|||
}
|
||||
}
|
||||
|
||||
#[derive(Clone, PartialEq, Serialize, Deserialize, Eq, Hash)]
|
||||
#[derive(Clone, PartialEq, Eq, Hash)]
|
||||
pub enum FlatExpression<T> {
|
||||
Number(T),
|
||||
Identifier(FlatVariable),
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
use flat_absy::*;
|
||||
use crate::flat_absy::*;
|
||||
use zokrates_field::Field;
|
||||
|
||||
pub fn flat_expression_from_bits<T: Field>(v: Vec<FlatExpression<T>>) -> FlatExpression<T> {
|
||||
|
|
|
@ -1,4 +1,5 @@
|
|||
use crate::flat_absy::FlatVariable;
|
||||
use serde::{Deserialize, Serialize};
|
||||
use std::collections::btree_map::{BTreeMap, Entry};
|
||||
use std::fmt;
|
||||
use std::ops::{Add, Div, Mul, Sub};
|
||||
|
@ -358,7 +359,7 @@ mod tests {
|
|||
}
|
||||
}
|
||||
|
||||
mod try {
|
||||
mod try_summand {
|
||||
use super::*;
|
||||
|
||||
#[test]
|
||||
|
|
|
@ -1,7 +1,8 @@
|
|||
use crate::flat_absy::flat_variable::FlatVariable;
|
||||
use crate::ir::Directive;
|
||||
use crate::ir::{LinComb, Prog, QuadComb, Statement, Witness};
|
||||
use ir::Directive;
|
||||
use solvers::Solver;
|
||||
use crate::solvers::Solver;
|
||||
use serde::{Deserialize, Serialize};
|
||||
use std::collections::BTreeMap;
|
||||
use std::fmt;
|
||||
use zokrates_field::Field;
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
use crate::flat_absy::flat_parameter::FlatParameter;
|
||||
use crate::flat_absy::FlatVariable;
|
||||
use crate::solvers::Solver;
|
||||
use serde::{Deserialize, Serialize};
|
||||
use std::fmt;
|
||||
use zokrates_field::Field;
|
||||
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
use crate::ir::Prog;
|
||||
use bincode::{deserialize_from, serialize_into, Infinite};
|
||||
use ir::Prog;
|
||||
use std::io::{Read, Write};
|
||||
use zokrates_field::*;
|
||||
|
||||
|
@ -70,7 +70,7 @@ impl ProgEnum {
|
|||
#[cfg(test)]
|
||||
mod tests {
|
||||
use super::*;
|
||||
use ir;
|
||||
use crate::ir;
|
||||
use std::io::{Cursor, Seek, SeekFrom};
|
||||
use zokrates_field::{Bls12_381Field, Bn128Field};
|
||||
|
||||
|
|
|
@ -1,39 +1,10 @@
|
|||
#![feature(box_patterns, box_syntax)]
|
||||
|
||||
extern crate cfg_if;
|
||||
extern crate num;
|
||||
extern crate num_bigint;
|
||||
extern crate reduce; // better reduce function than Iter.fold
|
||||
extern crate serde; // serialization deserialization
|
||||
extern crate serde_json;
|
||||
extern crate typed_arena;
|
||||
#[macro_use]
|
||||
extern crate serde_derive;
|
||||
extern crate bincode;
|
||||
extern crate csv;
|
||||
extern crate hex;
|
||||
extern crate lazy_static;
|
||||
extern crate rand_0_4;
|
||||
extern crate regex;
|
||||
extern crate zokrates_common;
|
||||
extern crate zokrates_field;
|
||||
extern crate zokrates_pest_ast;
|
||||
|
||||
extern crate bellman_ce as bellman;
|
||||
extern crate ff_ce as ff;
|
||||
extern crate pairing_ce as pairing;
|
||||
|
||||
cfg_if::cfg_if! {
|
||||
if #[cfg(feature = "ark")] {
|
||||
extern crate ark_bls12_377;
|
||||
extern crate ark_bn254;
|
||||
extern crate ark_bw6_761;
|
||||
extern crate ark_gm17;
|
||||
extern crate ark_ff;
|
||||
extern crate ark_ec;
|
||||
extern crate ark_serialize;
|
||||
extern crate ark_relations;
|
||||
extern crate rand_0_7;
|
||||
if #[cfg(feature = "bellman")] {
|
||||
extern crate bellman_ce as bellman;
|
||||
extern crate ff_ce as ff;
|
||||
extern crate pairing_ce as pairing;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -12,7 +12,7 @@
|
|||
use crate::flat_absy::flat_variable::FlatVariable;
|
||||
use crate::ir::folder::*;
|
||||
use crate::ir::*;
|
||||
use solvers::Solver;
|
||||
use crate::solvers::Solver;
|
||||
use std::collections::hash_map::{Entry, HashMap};
|
||||
use zokrates_field::Field;
|
||||
|
||||
|
|
|
@ -48,7 +48,7 @@ impl<T: Field> Folder<T> for DuplicateOptimizer {
|
|||
#[cfg(test)]
|
||||
mod tests {
|
||||
use super::*;
|
||||
use flat_absy::FlatVariable;
|
||||
use crate::flat_absy::FlatVariable;
|
||||
use zokrates_field::Bn128Field;
|
||||
|
||||
#[test]
|
||||
|
|
|
@ -1,3 +1,3 @@
|
|||
mod tokenize;
|
||||
|
||||
pub use parser::tokenize::Position;
|
||||
pub use crate::parser::tokenize::Position;
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
use std::fmt;
|
||||
|
||||
#[derive(Clone, PartialEq, Copy, Serialize, Deserialize)]
|
||||
#[derive(Clone, PartialEq, Copy)]
|
||||
pub struct Position {
|
||||
pub line: usize,
|
||||
pub col: usize,
|
||||
|
|
|
@ -6,13 +6,13 @@ use ark_gm17::{
|
|||
use ark_serialize::{CanonicalDeserialize, CanonicalSerialize};
|
||||
use zokrates_field::{ArkFieldExtensions, Bw6_761Field, Field};
|
||||
|
||||
use crate::ir::{Prog, Witness};
|
||||
use crate::proof_system::ark::Ark;
|
||||
use crate::proof_system::ark::Computation;
|
||||
use crate::proof_system::ark::{parse_fr, parse_g1, parse_g2, parse_g2_fq};
|
||||
use ir::{Prog, Witness};
|
||||
use proof_system::ark::Ark;
|
||||
use proof_system::gm17::{NotBw6_761Field, ProofPoints, VerificationKey, GM17};
|
||||
use proof_system::Scheme;
|
||||
use proof_system::{Backend, Proof, SetupKeypair};
|
||||
use crate::proof_system::gm17::{NotBw6_761Field, ProofPoints, VerificationKey, GM17};
|
||||
use crate::proof_system::Scheme;
|
||||
use crate::proof_system::{Backend, Proof, SetupKeypair};
|
||||
|
||||
impl<T: Field + ArkFieldExtensions + NotBw6_761Field> Backend<T, GM17> for Ark {
|
||||
fn setup(program: Prog<T>) -> SetupKeypair<<GM17 as Scheme<T>>::VerificationKey> {
|
||||
|
@ -200,9 +200,9 @@ impl Backend<Bw6_761Field, GM17> for Ark {
|
|||
}
|
||||
|
||||
pub mod serialization {
|
||||
use crate::proof_system::{G1Affine, G2Affine, G2AffineFq};
|
||||
use ark_ec::PairingEngine;
|
||||
use ark_ff::FromBytes;
|
||||
use proof_system::{G1Affine, G2Affine, G2AffineFq};
|
||||
use zokrates_field::ArkFieldExtensions;
|
||||
|
||||
#[inline]
|
||||
|
|
|
@ -214,8 +214,8 @@ impl<T: Field + ArkFieldExtensions>
|
|||
|
||||
mod parse {
|
||||
use super::*;
|
||||
use crate::proof_system::{Fr, G1Affine, G2Affine, G2AffineFq};
|
||||
use ark_ff::ToBytes;
|
||||
use proof_system::{Fr, G1Affine, G2Affine, G2AffineFq};
|
||||
|
||||
pub fn parse_g1<T: Field + ArkFieldExtensions>(
|
||||
e: &<T::ArkEngine as PairingEngine>::G1Affine,
|
||||
|
|
|
@ -4,16 +4,16 @@ use bellman::groth16::{
|
|||
};
|
||||
use pairing::{CurveAffine, Engine};
|
||||
|
||||
use proof_system::{Backend, Proof, SetupKeypair};
|
||||
use crate::proof_system::{Backend, Proof, SetupKeypair};
|
||||
use zokrates_field::BellmanFieldExtensions;
|
||||
use zokrates_field::Field;
|
||||
|
||||
use crate::ir::{Prog, Witness};
|
||||
use crate::proof_system::bellman::Bellman;
|
||||
use crate::proof_system::bellman::Computation;
|
||||
use crate::proof_system::bellman::{parse_fr, parse_g1, parse_g2};
|
||||
use ir::{Prog, Witness};
|
||||
use proof_system::bellman::Bellman;
|
||||
use proof_system::groth16::{ProofPoints, VerificationKey, G16};
|
||||
use proof_system::Scheme;
|
||||
use crate::proof_system::groth16::{ProofPoints, VerificationKey, G16};
|
||||
use crate::proof_system::Scheme;
|
||||
|
||||
const G16_WARNING: &str = "WARNING: You are using the G16 scheme which is subject to malleability. See zokrates.github.io/toolbox/proving_schemes.html#g16-malleability for implications.";
|
||||
|
||||
|
@ -109,7 +109,7 @@ impl<T: Field + BellmanFieldExtensions> Backend<T, G16> for Bellman {
|
|||
mod serialization {
|
||||
use pairing::{from_hex, CurveAffine, Engine};
|
||||
|
||||
use proof_system::{G1Affine, G2Affine};
|
||||
use crate::proof_system::{G1Affine, G2Affine};
|
||||
use zokrates_field::BellmanFieldExtensions;
|
||||
|
||||
pub fn to_g1<T: BellmanFieldExtensions>(
|
||||
|
|
|
@ -205,7 +205,7 @@ mod parse {
|
|||
use lazy_static::lazy_static;
|
||||
|
||||
use super::*;
|
||||
use proof_system::{Fr, G1Affine, G2Affine};
|
||||
use crate::proof_system::{Fr, G1Affine, G2Affine};
|
||||
use regex::Regex;
|
||||
|
||||
lazy_static! {
|
||||
|
@ -260,8 +260,8 @@ mod parse {
|
|||
#[cfg(test)]
|
||||
mod tests {
|
||||
use super::*;
|
||||
use crate::ir::Interpreter;
|
||||
use crate::ir::{Function, LinComb};
|
||||
use ir::Interpreter;
|
||||
use zokrates_field::Bn128Field;
|
||||
|
||||
mod prove {
|
||||
|
|
|
@ -1,11 +1,11 @@
|
|||
use ir::{Prog, Witness};
|
||||
use proof_system::gm17::{ProofPoints, VerificationKey, GM17};
|
||||
use proof_system::libsnark::ffi::{Buffer, ProofResult, SetupResult};
|
||||
use proof_system::libsnark::{
|
||||
use crate::ir::{Prog, Witness};
|
||||
use crate::proof_system::gm17::{ProofPoints, VerificationKey, GM17};
|
||||
use crate::proof_system::libsnark::ffi::{Buffer, ProofResult, SetupResult};
|
||||
use crate::proof_system::libsnark::{
|
||||
prepare_generate_proof, prepare_public_inputs, prepare_setup, serialization::*, Libsnark,
|
||||
};
|
||||
use proof_system::Scheme;
|
||||
use proof_system::{Backend, G1Affine, G2Affine, Proof, SetupKeypair};
|
||||
use crate::proof_system::Scheme;
|
||||
use crate::proof_system::{Backend, G1Affine, G2Affine, Proof, SetupKeypair};
|
||||
use std::io::{BufReader, BufWriter, Write};
|
||||
use zokrates_field::{Bn128Field, Field};
|
||||
|
||||
|
|
|
@ -2,8 +2,8 @@ mod ffi;
|
|||
pub mod gm17;
|
||||
pub mod pghr13;
|
||||
|
||||
use flat_absy::FlatVariable;
|
||||
use ir::{self, Statement};
|
||||
use crate::flat_absy::FlatVariable;
|
||||
use crate::ir::{self, Statement};
|
||||
use std::cmp::max;
|
||||
use std::collections::HashMap;
|
||||
use zokrates_field::Field;
|
||||
|
@ -305,7 +305,7 @@ pub fn r1cs_program<T: Field>(
|
|||
}
|
||||
|
||||
pub mod serialization {
|
||||
use proof_system::{G1Affine, G2Affine};
|
||||
use crate::proof_system::{G1Affine, G2Affine};
|
||||
use std::io::Read;
|
||||
use std::io::Write;
|
||||
|
||||
|
|
|
@ -1,13 +1,13 @@
|
|||
use proof_system::libsnark::ffi::{Buffer, ProofResult, SetupResult};
|
||||
use proof_system::libsnark::{
|
||||
use crate::proof_system::libsnark::ffi::{Buffer, ProofResult, SetupResult};
|
||||
use crate::proof_system::libsnark::{
|
||||
prepare_generate_proof, prepare_public_inputs, prepare_setup, Libsnark,
|
||||
};
|
||||
use proof_system::{Backend, G1Affine, G2Affine, Proof, SetupKeypair};
|
||||
use crate::proof_system::{Backend, G1Affine, G2Affine, Proof, SetupKeypair};
|
||||
|
||||
use ir::{Prog, Witness};
|
||||
use proof_system::libsnark::serialization::{read_g1, read_g2, write_g1, write_g2};
|
||||
use proof_system::pghr13::{ProofPoints, VerificationKey, PGHR13};
|
||||
use proof_system::Scheme;
|
||||
use crate::ir::{Prog, Witness};
|
||||
use crate::proof_system::libsnark::serialization::{read_g1, read_g2, write_g1, write_g2};
|
||||
use crate::proof_system::pghr13::{ProofPoints, VerificationKey, PGHR13};
|
||||
use crate::proof_system::Scheme;
|
||||
use std::io::{BufReader, BufWriter, Write};
|
||||
use zokrates_field::Bn128Field;
|
||||
use zokrates_field::Field;
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
#[cfg(feature = "ark")]
|
||||
pub mod ark;
|
||||
#[cfg(feature = "bellman")]
|
||||
pub mod bellman;
|
||||
#[cfg(feature = "libsnark")]
|
||||
pub mod libsnark;
|
||||
|
@ -12,7 +13,7 @@ pub use self::solidity::*;
|
|||
|
||||
use crate::ir;
|
||||
use serde::de::DeserializeOwned;
|
||||
use serde::Serialize;
|
||||
use serde::{Deserialize, Serialize};
|
||||
use zokrates_field::Field;
|
||||
|
||||
#[derive(Serialize)]
|
||||
|
@ -33,6 +34,7 @@ pub struct Proof<T> {
|
|||
pub inputs: Vec<String>,
|
||||
}
|
||||
|
||||
#[allow(dead_code)]
|
||||
impl<T: Serialize + DeserializeOwned> Proof<T> {
|
||||
fn new(proof: T, inputs: Vec<String>) -> Self {
|
||||
Proof { proof, inputs }
|
||||
|
|
|
@ -1,11 +1,12 @@
|
|||
use proof_system::scheme::Scheme;
|
||||
use proof_system::solidity::{
|
||||
use crate::proof_system::scheme::Scheme;
|
||||
use crate::proof_system::solidity::{
|
||||
SolidityAbi, SOLIDITY_G2_ADDITION_LIB, SOLIDITY_PAIRING_LIB, SOLIDITY_PAIRING_LIB_V2,
|
||||
};
|
||||
use proof_system::{
|
||||
use crate::proof_system::{
|
||||
G1Affine, G2Affine, G2AffineFq, SolidityCompatibleField, SolidityCompatibleScheme,
|
||||
};
|
||||
use regex::Regex;
|
||||
use serde::{Deserialize, Serialize};
|
||||
use zokrates_field::{Bls12_377Field, Bls12_381Field, Bn128Field, Bw6_761Field, Field};
|
||||
|
||||
pub trait NotBw6_761Field {}
|
||||
|
|
|
@ -1,9 +1,10 @@
|
|||
use proof_system::scheme::Scheme;
|
||||
use proof_system::solidity::{
|
||||
use crate::proof_system::scheme::Scheme;
|
||||
use crate::proof_system::solidity::{
|
||||
SolidityAbi, SOLIDITY_G2_ADDITION_LIB, SOLIDITY_PAIRING_LIB, SOLIDITY_PAIRING_LIB_V2,
|
||||
};
|
||||
use proof_system::{G1Affine, G2Affine, SolidityCompatibleField, SolidityCompatibleScheme};
|
||||
use crate::proof_system::{G1Affine, G2Affine, SolidityCompatibleField, SolidityCompatibleScheme};
|
||||
use regex::Regex;
|
||||
use serde::{Deserialize, Serialize};
|
||||
use zokrates_field::Field;
|
||||
|
||||
pub struct G16;
|
||||
|
|
|
@ -1,9 +1,10 @@
|
|||
use proof_system::scheme::Scheme;
|
||||
use proof_system::solidity::{
|
||||
use crate::proof_system::scheme::Scheme;
|
||||
use crate::proof_system::solidity::{
|
||||
SolidityAbi, SOLIDITY_G2_ADDITION_LIB, SOLIDITY_PAIRING_LIB, SOLIDITY_PAIRING_LIB_V2,
|
||||
};
|
||||
use proof_system::{G1Affine, G2Affine, SolidityCompatibleField, SolidityCompatibleScheme};
|
||||
use crate::proof_system::{G1Affine, G2Affine, SolidityCompatibleField, SolidityCompatibleScheme};
|
||||
use regex::Regex;
|
||||
use serde::{Deserialize, Serialize};
|
||||
use zokrates_field::Field;
|
||||
|
||||
pub struct PGHR13;
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
use proof_system::Scheme;
|
||||
use crate::proof_system::Scheme;
|
||||
use zokrates_field::{Bn128Field, Field};
|
||||
|
||||
pub trait SolidityCompatibleField: Field {}
|
||||
|
|
|
@ -18,8 +18,8 @@ use crate::parser::Position;
|
|||
use crate::absy::types::{UnresolvedSignature, UnresolvedType, UserTypeId};
|
||||
use crate::typed_absy::types::{FunctionKey, Signature, StructLocation, Type};
|
||||
|
||||
use crate::typed_absy::types::{ArrayType, StructMember};
|
||||
use std::hash::{Hash, Hasher};
|
||||
use typed_absy::types::{ArrayType, StructMember};
|
||||
|
||||
#[derive(PartialEq, Debug)]
|
||||
pub struct ErrorInner {
|
||||
|
@ -2365,9 +2365,9 @@ impl<'ast> Checker<'ast> {
|
|||
#[cfg(test)]
|
||||
mod tests {
|
||||
use super::*;
|
||||
use absy;
|
||||
use crate::absy;
|
||||
use crate::typed_absy;
|
||||
use num_bigint::BigUint;
|
||||
use typed_absy;
|
||||
use zokrates_field::Bn128Field;
|
||||
|
||||
const MODULE_ID: &str = "";
|
||||
|
|
|
@ -1,3 +1,4 @@
|
|||
use serde::{Deserialize, Serialize};
|
||||
use std::fmt;
|
||||
use zokrates_field::Field;
|
||||
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
use crate::typed_absy;
|
||||
use crate::typed_absy::types::{StructType, UBitwidth};
|
||||
use crate::zir;
|
||||
use std::marker::PhantomData;
|
||||
use typed_absy;
|
||||
use typed_absy::types::{StructType, UBitwidth};
|
||||
use zir;
|
||||
use zokrates_field::Field;
|
||||
|
||||
pub struct Flattener<T: Field> {
|
||||
|
@ -318,7 +318,7 @@ pub fn fold_array_expression_inner<'ast, T: Field>(
|
|||
|
||||
assert_eq!(consequence.len(), alternative.len());
|
||||
|
||||
use zir::IfElse;
|
||||
use crate::zir::IfElse;
|
||||
|
||||
consequence
|
||||
.into_iter()
|
||||
|
@ -406,7 +406,7 @@ pub fn fold_struct_expression_inner<'ast, T: Field>(
|
|||
|
||||
assert_eq!(consequence.len(), alternative.len());
|
||||
|
||||
use zir::IfElse;
|
||||
use crate::zir::IfElse;
|
||||
|
||||
consequence
|
||||
.into_iter()
|
||||
|
|
|
@ -16,9 +16,9 @@
|
|||
|
||||
//! where any call in `main` must be to `_SHA_256_ROUND` or `_UNPACK`
|
||||
|
||||
use crate::typed_absy::types::{FunctionKey, FunctionKeyHash, Type, UBitwidth};
|
||||
use crate::typed_absy::{folder::*, *};
|
||||
use std::collections::HashMap;
|
||||
use typed_absy::types::{FunctionKey, FunctionKeyHash, Type, UBitwidth};
|
||||
use typed_absy::{folder::*, *};
|
||||
use zokrates_field::Field;
|
||||
|
||||
#[derive(Debug, PartialEq, Eq, Hash, Clone)]
|
||||
|
@ -603,8 +603,8 @@ impl<'ast, T: Field> Folder<'ast, T> for Inliner<'ast, T> {
|
|||
#[cfg(test)]
|
||||
mod tests {
|
||||
use super::*;
|
||||
use crate::typed_absy::types::{FunctionKey, Signature, Type};
|
||||
use std::path::PathBuf;
|
||||
use typed_absy::types::{FunctionKey, Signature, Type};
|
||||
use zokrates_field::Bn128Field;
|
||||
|
||||
#[test]
|
||||
|
|
|
@ -30,7 +30,7 @@ use self::variable_write_remover::VariableWriteRemover;
|
|||
use crate::flat_absy::FlatProg;
|
||||
use crate::ir::Prog;
|
||||
use crate::typed_absy::TypedProgram;
|
||||
use zir::ZirProgram;
|
||||
use crate::zir::ZirProgram;
|
||||
use zokrates_field::Field;
|
||||
|
||||
pub trait Analyse {
|
||||
|
|
|
@ -19,9 +19,9 @@
|
|||
//! In the case that a loop bound cannot be reduced to a constant, we detect it by noticing that the unroll does
|
||||
//! not make progress anymore.
|
||||
|
||||
use static_analysis::propagation::Propagator;
|
||||
use static_analysis::unroll::{Output, Unroller};
|
||||
use typed_absy::TypedProgram;
|
||||
use crate::static_analysis::propagation::Propagator;
|
||||
use crate::static_analysis::unroll::{Output, Unroller};
|
||||
use crate::typed_absy::TypedProgram;
|
||||
use zokrates_field::Field;
|
||||
|
||||
pub struct PropagatedUnroller;
|
||||
|
@ -61,8 +61,8 @@ impl PropagatedUnroller {
|
|||
#[cfg(test)]
|
||||
mod tests {
|
||||
use super::*;
|
||||
use typed_absy::types::{FunctionKey, Signature};
|
||||
use typed_absy::*;
|
||||
use crate::typed_absy::types::{FunctionKey, Signature};
|
||||
use crate::typed_absy::*;
|
||||
use zokrates_field::Bn128Field;
|
||||
|
||||
#[test]
|
||||
|
|
|
@ -11,10 +11,10 @@
|
|||
//! @date 2018
|
||||
|
||||
use crate::typed_absy::folder::*;
|
||||
use crate::typed_absy::types::Type;
|
||||
use crate::typed_absy::*;
|
||||
use std::collections::HashMap;
|
||||
use std::convert::TryFrom;
|
||||
use typed_absy::types::Type;
|
||||
use zokrates_field::Field;
|
||||
|
||||
pub struct Propagator<'ast, T: Field> {
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
use typed_absy::folder::fold_statement;
|
||||
use typed_absy::identifier::CoreIdentifier;
|
||||
use typed_absy::*;
|
||||
use crate::typed_absy::folder::fold_statement;
|
||||
use crate::typed_absy::identifier::CoreIdentifier;
|
||||
use crate::typed_absy::*;
|
||||
use zokrates_field::Field;
|
||||
|
||||
pub struct ReturnBinder;
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
use crate::zir::folder::*;
|
||||
use crate::zir::*;
|
||||
use std::collections::HashMap;
|
||||
use zir::folder::*;
|
||||
use zokrates_field::Field;
|
||||
|
||||
#[derive(Default)]
|
||||
|
@ -467,8 +467,7 @@ mod tests {
|
|||
use super::*;
|
||||
use zokrates_field::Bn128Field;
|
||||
|
||||
extern crate pretty_assertions;
|
||||
use self::pretty_assertions::assert_eq;
|
||||
use pretty_assertions::assert_eq;
|
||||
|
||||
macro_rules! uint_test {
|
||||
( $left_max:expr, $left_reduce:expr, $right_max:expr, $right_reduce:expr, $method:ident, $res_max:expr ) => {{
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
use crate::flat_absy::FlatVariable;
|
||||
use crate::ir::folder::Folder;
|
||||
use crate::ir::Directive;
|
||||
use crate::ir::Prog;
|
||||
use flat_absy::FlatVariable;
|
||||
use ir::folder::Folder;
|
||||
use ir::Directive;
|
||||
use std::collections::HashSet;
|
||||
use zokrates_field::Field;
|
||||
|
||||
|
@ -54,9 +54,9 @@ impl<T: Field> Folder<T> for UnconstrainedVariableDetector {
|
|||
#[cfg(test)]
|
||||
mod tests {
|
||||
use super::*;
|
||||
use flat_absy::FlatVariable;
|
||||
use ir::{Function, LinComb, Prog, QuadComb, Statement};
|
||||
use solvers::Solver;
|
||||
use crate::flat_absy::FlatVariable;
|
||||
use crate::ir::{Function, LinComb, Prog, QuadComb, Statement};
|
||||
use crate::solvers::Solver;
|
||||
use zokrates_field::Bn128Field;
|
||||
|
||||
#[test]
|
||||
|
|
|
@ -5,11 +5,11 @@
|
|||
//! @date 2018
|
||||
|
||||
use crate::typed_absy::folder::*;
|
||||
use crate::typed_absy::identifier::CoreIdentifier;
|
||||
use crate::typed_absy::types::{MemberId, Type};
|
||||
use crate::typed_absy::*;
|
||||
use std::collections::HashMap;
|
||||
use std::collections::HashSet;
|
||||
use typed_absy::identifier::CoreIdentifier;
|
||||
use zokrates_field::Field;
|
||||
|
||||
pub enum Output<'ast, T: Field> {
|
||||
|
|
|
@ -10,7 +10,7 @@
|
|||
//! if(index == 0, a[0], if(index == 1, a[1], ...))
|
||||
//! ```
|
||||
|
||||
use typed_absy::{folder::*, *};
|
||||
use crate::typed_absy::{folder::*, *};
|
||||
use zokrates_field::Field;
|
||||
|
||||
pub struct VariableReadRemover<'ast, T: Field> {
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
use typed_absy::types::Signature;
|
||||
use typed_absy::Type;
|
||||
use crate::typed_absy::{Signature, Type};
|
||||
use serde::{Deserialize, Serialize};
|
||||
|
||||
#[derive(Serialize, Deserialize, Debug, Eq, PartialEq)]
|
||||
pub struct AbiInput {
|
||||
|
@ -29,12 +29,12 @@ impl Abi {
|
|||
#[cfg(test)]
|
||||
mod tests {
|
||||
use super::*;
|
||||
use std::collections::HashMap;
|
||||
use typed_absy::types::{ArrayType, FunctionKey, StructMember, StructType};
|
||||
use typed_absy::{
|
||||
use crate::typed_absy::types::{ArrayType, FunctionKey, StructMember, StructType};
|
||||
use crate::typed_absy::{
|
||||
Parameter, Type, TypedFunction, TypedFunctionSymbol, TypedModule, TypedProgram, UBitwidth,
|
||||
Variable,
|
||||
};
|
||||
use std::collections::HashMap;
|
||||
use zokrates_field::Bn128Field;
|
||||
|
||||
#[test]
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
use crate::typed_absy::types::FunctionKeyHash;
|
||||
use crate::typed_absy::TypedModuleId;
|
||||
use std::fmt;
|
||||
use typed_absy::types::FunctionKeyHash;
|
||||
use typed_absy::TypedModuleId;
|
||||
|
||||
#[derive(Debug, PartialEq, Clone, Hash, Eq)]
|
||||
pub enum CoreIdentifier<'ast> {
|
||||
|
|
|
@ -18,18 +18,18 @@ pub use self::identifier::CoreIdentifier;
|
|||
pub use self::parameter::Parameter;
|
||||
pub use self::types::{Signature, StructType, Type, UBitwidth};
|
||||
pub use self::variable::Variable;
|
||||
pub use crate::typed_absy::uint::{bitwidth, UExpression, UExpressionInner, UMetadata};
|
||||
use std::path::PathBuf;
|
||||
pub use typed_absy::uint::{bitwidth, UExpression, UExpressionInner, UMetadata};
|
||||
|
||||
use crate::embed::FlatEmbed;
|
||||
use crate::typed_absy::types::{FunctionKey, MemberId};
|
||||
use embed::FlatEmbed;
|
||||
use std::collections::HashMap;
|
||||
use std::convert::TryFrom;
|
||||
use std::fmt;
|
||||
use zokrates_field::Field;
|
||||
|
||||
pub use self::folder::Folder;
|
||||
use typed_absy::abi::{Abi, AbiInput};
|
||||
use crate::typed_absy::abi::{Abi, AbiInput};
|
||||
|
||||
pub use self::identifier::Identifier;
|
||||
|
||||
|
|
|
@ -1,3 +1,4 @@
|
|||
use serde::{de::Error, ser::SerializeMap, Deserialize, Deserializer, Serialize, Serializer};
|
||||
use std::fmt;
|
||||
use std::path::{Path, PathBuf};
|
||||
|
||||
|
@ -125,7 +126,7 @@ pub enum Type {
|
|||
Uint(UBitwidth),
|
||||
}
|
||||
|
||||
impl Serialize for Type {
|
||||
impl serde::Serialize for Type {
|
||||
fn serialize<S>(&self, s: S) -> Result<<S as Serializer>::Ok, <S as Serializer>::Error>
|
||||
where
|
||||
S: Serializer,
|
||||
|
@ -155,7 +156,7 @@ impl Serialize for Type {
|
|||
}
|
||||
}
|
||||
|
||||
impl<'de> Deserialize<'de> for Type {
|
||||
impl<'de> serde::Deserialize<'de> for Type {
|
||||
fn deserialize<D>(d: D) -> Result<Self, <D as Deserializer<'de>>::Error>
|
||||
where
|
||||
D: Deserializer<'de>,
|
||||
|
@ -361,9 +362,9 @@ impl<'ast> FunctionKey<'ast> {
|
|||
}
|
||||
|
||||
pub use self::signature::Signature;
|
||||
use serde::de::Error;
|
||||
use serde::ser::SerializeMap;
|
||||
use serde::{Deserialize, Deserializer, Serialize, Serializer};
|
||||
// use serde::de::Error;
|
||||
// use serde::ser::SerializeMap;
|
||||
// use serde::{Deserializer, Serializer};
|
||||
|
||||
pub mod signature {
|
||||
use super::*;
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
use typed_absy::types::{FunctionKey, UBitwidth};
|
||||
use typed_absy::*;
|
||||
use crate::typed_absy::types::{FunctionKey, UBitwidth};
|
||||
use crate::typed_absy::*;
|
||||
use zokrates_field::Field;
|
||||
|
||||
type Bitwidth = usize;
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
use crate::typed_absy::types::Type;
|
||||
use crate::typed_absy::types::{StructType, UBitwidth};
|
||||
use crate::typed_absy::Identifier;
|
||||
use std::fmt;
|
||||
use typed_absy::types::{StructType, UBitwidth};
|
||||
|
||||
#[derive(Clone, PartialEq, Hash, Eq)]
|
||||
pub struct Variable<'ast> {
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
use typed_absy;
|
||||
use zir;
|
||||
use crate::typed_absy;
|
||||
use crate::zir;
|
||||
|
||||
impl<'ast> From<typed_absy::types::FunctionKey<'ast>> for zir::types::FunctionKey<'ast> {
|
||||
fn from(k: typed_absy::types::FunctionKey<'ast>) -> zir::types::FunctionKey<'ast> {
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
use crate::zir::types::MemberId;
|
||||
use std::fmt;
|
||||
use zir::types::MemberId;
|
||||
|
||||
use typed_absy::Identifier as CoreIdentifier;
|
||||
use crate::typed_absy::Identifier as CoreIdentifier;
|
||||
|
||||
#[derive(Debug, PartialEq, Clone, Hash, Eq)]
|
||||
pub enum Identifier<'ast> {
|
||||
|
|
|
@ -9,14 +9,14 @@ mod variable;
|
|||
pub use self::parameter::Parameter;
|
||||
pub use self::types::Type;
|
||||
pub use self::variable::Variable;
|
||||
pub use crate::zir::uint::{ShouldReduce, UExpression, UExpressionInner, UMetadata};
|
||||
use std::path::PathBuf;
|
||||
pub use zir::uint::{ShouldReduce, UExpression, UExpressionInner, UMetadata};
|
||||
|
||||
use embed::FlatEmbed;
|
||||
use crate::embed::FlatEmbed;
|
||||
use crate::zir::types::{FunctionKey, Signature};
|
||||
use std::collections::HashMap;
|
||||
use std::convert::TryFrom;
|
||||
use std::fmt;
|
||||
use zir::types::{FunctionKey, Signature};
|
||||
use zokrates_field::Field;
|
||||
|
||||
pub use self::folder::Folder;
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
use crate::zir::Variable;
|
||||
use std::fmt;
|
||||
use zir::Variable;
|
||||
|
||||
#[derive(Clone, PartialEq)]
|
||||
pub struct Parameter<'ast> {
|
||||
|
|
|
@ -1,3 +1,4 @@
|
|||
use serde::{Deserialize, Serialize};
|
||||
use std::fmt;
|
||||
|
||||
pub type Identifier<'ast> = &'ast str;
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
use zir::identifier::Identifier;
|
||||
use zir::types::UBitwidth;
|
||||
use zir::{BooleanExpression, FieldElementExpression};
|
||||
use crate::zir::identifier::Identifier;
|
||||
use crate::zir::types::UBitwidth;
|
||||
use crate::zir::{BooleanExpression, FieldElementExpression};
|
||||
use zokrates_field::Field;
|
||||
|
||||
impl<'ast, T: Field> UExpression<'ast, T> {
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
use crate::zir::types::{Type, UBitwidth};
|
||||
use crate::zir::Identifier;
|
||||
use std::fmt;
|
||||
use zir::types::{Type, UBitwidth};
|
||||
use zir::Identifier;
|
||||
|
||||
#[derive(Clone, PartialEq, Hash, Eq)]
|
||||
pub struct Variable<'ast> {
|
||||
|
|
|
@ -4,23 +4,30 @@ version = "0.3.7"
|
|||
authors = ["Thibaut Schaeffer <thibaut@schaeff.fr>", "Guillaume Ballet <gballet@gmail.com>"]
|
||||
edition = "2018"
|
||||
|
||||
[features]
|
||||
default = ["ark", "bellman"]
|
||||
ark = ["ark-ff", "ark-ec", "ark-bn254", "ark-bls12-377", "ark-bw6-761"]
|
||||
bellman = ["bellman_ce"]
|
||||
|
||||
[dependencies]
|
||||
serde = "1.0"
|
||||
serde_derive = "1.0"
|
||||
lazy_static = "1.4"
|
||||
bincode = "0.8.0"
|
||||
serde_json = "1.0"
|
||||
bellman_ce = { version = "^0.3", default-features = false }
|
||||
sha2 = "0.8.0"
|
||||
num-traits = { version = "0.2", default-features = false }
|
||||
num-integer = { version = "0.1", default-features = false }
|
||||
|
||||
ark-ff = { git = "https://github.com/arkworks-rs/algebra", default-features = false }
|
||||
ark-ec = { git = "https://github.com/arkworks-rs/algebra", default-features = false }
|
||||
# bellman
|
||||
bellman_ce = { version = "^0.3", default-features = false, optional = true }
|
||||
|
||||
ark-bn254 = { git = "https://github.com/arkworks-rs/curves", features = ["curve"], default-features = false }
|
||||
ark-bls12-377 = { git = "https://github.com/arkworks-rs/curves", features = ["curve"], default-features = false }
|
||||
ark-bw6-761 = { git = "https://github.com/arkworks-rs/curves", default-features = false }
|
||||
# ark
|
||||
ark-ff = { git = "https://github.com/arkworks-rs/algebra", default-features = false, optional = true }
|
||||
ark-ec = { git = "https://github.com/arkworks-rs/algebra", default-features = false, optional = true }
|
||||
ark-bn254 = { git = "https://github.com/arkworks-rs/curves", features = ["curve"], default-features = false, optional = true }
|
||||
ark-bls12-377 = { git = "https://github.com/arkworks-rs/curves", features = ["curve"], default-features = false, optional = true }
|
||||
ark-bw6-761 = { git = "https://github.com/arkworks-rs/curves", default-features = false, optional = true }
|
||||
|
||||
[dev-dependencies]
|
||||
rand = "0.4"
|
||||
|
|
|
@ -1,9 +1,7 @@
|
|||
extern crate ark_bls12_377;
|
||||
|
||||
use ark_bls12_377::Bls12_377;
|
||||
|
||||
prime_field!(
|
||||
b"8444461749428370424248824938781546531375899335154063827935233455917409239041",
|
||||
"bls12_377"
|
||||
);
|
||||
ark_extensions!(Bls12_377);
|
||||
|
||||
#[cfg(feature = "ark")]
|
||||
ark_extensions!(ark_bls12_377::Bls12_377);
|
||||
|
|
|
@ -1,7 +1,9 @@
|
|||
use bellman_ce::pairing::bls12_381::{Bls12, Fq2};
|
||||
|
||||
prime_field!(
|
||||
b"52435875175126190479447740508185965837690552500527637822603658699938581184513",
|
||||
"bls12_381"
|
||||
);
|
||||
|
||||
#[cfg(feature = "bellman")]
|
||||
use bellman_ce::pairing::bls12_381::{Bls12, Fq2};
|
||||
#[cfg(feature = "bellman")]
|
||||
bellman_extensions!(Bls12, Fq2);
|
||||
|
|
|
@ -1,14 +1,16 @@
|
|||
extern crate ark_bn254;
|
||||
|
||||
use ark_bn254::Bn254;
|
||||
use bellman_ce::pairing::bn256::{Bn256, Fq2};
|
||||
|
||||
prime_field!(
|
||||
b"21888242871839275222246405745257275088548364400416034343698204186575808495617",
|
||||
"bn128"
|
||||
);
|
||||
|
||||
#[cfg(feature = "bellman")]
|
||||
use bellman_ce::pairing::bn256::{Bn256, Fq2};
|
||||
#[cfg(feature = "bellman")]
|
||||
bellman_extensions!(Bn256, Fq2);
|
||||
|
||||
#[cfg(feature = "ark")]
|
||||
use ark_bn254::Bn254;
|
||||
#[cfg(feature = "ark")]
|
||||
ark_extensions!(Bn254);
|
||||
|
||||
#[cfg(test)]
|
||||
|
@ -379,6 +381,7 @@ mod tests {
|
|||
);
|
||||
}
|
||||
|
||||
#[cfg(feature = "bellman")]
|
||||
mod bellman {
|
||||
use super::*;
|
||||
|
||||
|
|
|
@ -1,10 +1,9 @@
|
|||
extern crate ark_bw6_761;
|
||||
|
||||
use ark_bw6_761::BW6_761;
|
||||
|
||||
prime_field!(
|
||||
b"258664426012969094010652733694893533536393512754914660539884262666720468348340822774968888139573360124440321458177",
|
||||
"bw6_761"
|
||||
);
|
||||
|
||||
#[cfg(feature = "ark")]
|
||||
use ark_bw6_761::BW6_761;
|
||||
#[cfg(feature = "ark")]
|
||||
ark_extensions!(BW6_761);
|
||||
|
|
|
@ -3,14 +3,15 @@
|
|||
// @author Dennis Kuhnert <dennis.kuhnert@campus.tu-berlin.de>
|
||||
// @author Jacob Eberhardt <jacob.eberhardt@tu-berlin.de>
|
||||
// @date 2017
|
||||
extern crate ark_bls12_377;
|
||||
extern crate ark_ec;
|
||||
extern crate ark_ff;
|
||||
|
||||
extern crate num_bigint;
|
||||
|
||||
#[cfg(feature = "ark")]
|
||||
use ark_ec::PairingEngine;
|
||||
use bellman_ce::pairing::ff::ScalarEngine;
|
||||
use bellman_ce::pairing::Engine;
|
||||
|
||||
#[cfg(feature = "bellman")]
|
||||
use bellman_ce::pairing::{ff::ScalarEngine, Engine};
|
||||
|
||||
use num_bigint::BigUint;
|
||||
use num_traits::{CheckedDiv, One, Zero};
|
||||
use serde::{Deserialize, Serialize};
|
||||
|
@ -24,6 +25,7 @@ pub trait Pow<RHS> {
|
|||
fn pow(self, _: RHS) -> Self::Output;
|
||||
}
|
||||
|
||||
#[cfg(feature = "bellman")]
|
||||
pub trait BellmanFieldExtensions {
|
||||
/// An associated type to be able to operate with Bellman ff traits
|
||||
type BellmanEngine: Engine;
|
||||
|
@ -33,6 +35,7 @@ pub trait BellmanFieldExtensions {
|
|||
fn new_fq2(c0: &str, c1: &str) -> <Self::BellmanEngine as Engine>::Fqe;
|
||||
}
|
||||
|
||||
#[cfg(feature = "ark")]
|
||||
pub trait ArkFieldExtensions {
|
||||
/// An associated type to be able to operate with ark ff traits
|
||||
type ArkEngine: PairingEngine;
|
||||
|
@ -520,6 +523,7 @@ mod prime_field {
|
|||
};
|
||||
}
|
||||
|
||||
#[cfg(feature = "bellman")]
|
||||
macro_rules! bellman_extensions {
|
||||
($bellman_type:ty, $fq2_type:ident) => {
|
||||
use crate::BellmanFieldExtensions;
|
||||
|
@ -554,6 +558,7 @@ mod prime_field {
|
|||
};
|
||||
}
|
||||
|
||||
#[cfg(feature = "ark")]
|
||||
macro_rules! ark_extensions {
|
||||
($ark_type:ty) => {
|
||||
use crate::ArkFieldExtensions;
|
||||
|
|
138
zokrates_js/Cargo.lock
generated
138
zokrates_js/Cargo.lock
generated
|
@ -25,26 +25,85 @@ dependencies = [
|
|||
]
|
||||
|
||||
[[package]]
|
||||
name = "algebra"
|
||||
version = "0.1.1-alpha.0"
|
||||
source = "git+https://github.com/scipr-lab/zexe.git#85cac1770dddd4da79e9993c5d1dcb5732db08f5"
|
||||
name = "ark-bls12-377"
|
||||
version = "0.1.0"
|
||||
source = "git+https://github.com/arkworks-rs/curves#23e87bf224c23be5c5bccc6084aae31fff8bb83f"
|
||||
dependencies = [
|
||||
"algebra-core",
|
||||
"ark-ec",
|
||||
"ark-ff",
|
||||
"ark-std",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "algebra-core"
|
||||
version = "0.1.1-alpha.0"
|
||||
source = "git+https://github.com/scipr-lab/zexe.git#85cac1770dddd4da79e9993c5d1dcb5732db08f5"
|
||||
name = "ark-bn254"
|
||||
version = "0.1.0"
|
||||
source = "git+https://github.com/arkworks-rs/curves#23e87bf224c23be5c5bccc6084aae31fff8bb83f"
|
||||
dependencies = [
|
||||
"ark-ec",
|
||||
"ark-ff",
|
||||
"ark-std",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "ark-bw6-761"
|
||||
version = "0.1.0"
|
||||
source = "git+https://github.com/arkworks-rs/curves#23e87bf224c23be5c5bccc6084aae31fff8bb83f"
|
||||
dependencies = [
|
||||
"ark-bls12-377",
|
||||
"ark-ec",
|
||||
"ark-ff",
|
||||
"ark-std",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "ark-ec"
|
||||
version = "0.1.0"
|
||||
source = "git+https://github.com/arkworks-rs/algebra#9bc541722707e1ac495e82fbf86446bbfde38a82"
|
||||
dependencies = [
|
||||
"ark-ff",
|
||||
"ark-serialize",
|
||||
"ark-std",
|
||||
"derivative",
|
||||
"num-traits 0.2.12",
|
||||
"rand 0.7.3",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "ark-ff"
|
||||
version = "0.1.0"
|
||||
source = "git+https://github.com/arkworks-rs/algebra#9bc541722707e1ac495e82fbf86446bbfde38a82"
|
||||
dependencies = [
|
||||
"ark-ff-asm",
|
||||
"ark-serialize",
|
||||
"ark-std",
|
||||
"derivative",
|
||||
"field-assembly",
|
||||
"num-traits 0.2.12",
|
||||
"rand 0.7.3",
|
||||
"rustc_version",
|
||||
"unroll",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "ark-ff-asm"
|
||||
version = "0.1.0"
|
||||
source = "git+https://github.com/arkworks-rs/algebra#9bc541722707e1ac495e82fbf86446bbfde38a82"
|
||||
dependencies = [
|
||||
"quote 1.0.7",
|
||||
"syn 1.0.34",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "ark-serialize"
|
||||
version = "0.1.0"
|
||||
source = "git+https://github.com/arkworks-rs/algebra#9bc541722707e1ac495e82fbf86446bbfde38a82"
|
||||
dependencies = [
|
||||
"ark-std",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "ark-std"
|
||||
version = "0.1.0"
|
||||
source = "git+https://github.com/arkworks-rs/utils#f6974ac72f59339b7ab798a728a84c5a7b8bac45"
|
||||
|
||||
[[package]]
|
||||
name = "autocfg"
|
||||
version = "1.0.0"
|
||||
|
@ -288,14 +347,6 @@ dependencies = [
|
|||
"syn 1.0.34",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "field-assembly"
|
||||
version = "0.1.1-alpha.0"
|
||||
source = "git+https://github.com/scipr-lab/zexe.git#85cac1770dddd4da79e9993c5d1dcb5732db08f5"
|
||||
dependencies = [
|
||||
"mince",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "from-pest"
|
||||
version = "0.3.1"
|
||||
|
@ -490,15 +541,6 @@ version = "2.3.3"
|
|||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "3728d817d99e5ac407411fa471ff9800a778d88a24685968b36824eaf4bee400"
|
||||
|
||||
[[package]]
|
||||
name = "mince"
|
||||
version = "0.1.1-alpha.0"
|
||||
source = "git+https://github.com/scipr-lab/zexe.git#85cac1770dddd4da79e9993c5d1dcb5732db08f5"
|
||||
dependencies = [
|
||||
"quote 1.0.7",
|
||||
"syn 1.0.34",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "miniz_oxide"
|
||||
version = "0.4.0"
|
||||
|
@ -856,9 +898,9 @@ checksum = "4c691c0e608126e00913e33f0ccf3727d5fc84573623b8d65b2df340b5201783"
|
|||
|
||||
[[package]]
|
||||
name = "rustc_version"
|
||||
version = "0.2.3"
|
||||
version = "0.3.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "138e3e0acb6c9fb258b19b67cb8abd63c00679d2851805ea151465464fe9030a"
|
||||
checksum = "65c94201b44764d6d1f7e37c15a8289ed55e546c1762c7f1d57f616966e0c181"
|
||||
dependencies = [
|
||||
"semver",
|
||||
]
|
||||
|
@ -871,18 +913,21 @@ checksum = "71d301d4193d031abdd79ff7e3dd721168a9572ef3fe51a1517aba235bd8f86e"
|
|||
|
||||
[[package]]
|
||||
name = "semver"
|
||||
version = "0.9.0"
|
||||
version = "0.11.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "1d7eb9ef2c18661902cc47e535f9bc51b78acd254da71d375c2f6720d9a40403"
|
||||
checksum = "f301af10236f6df4160f7c3f04eec6dbc70ace82d23326abad5edee88801c6b6"
|
||||
dependencies = [
|
||||
"semver-parser",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "semver-parser"
|
||||
version = "0.7.0"
|
||||
version = "0.10.1"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "388a1df253eca08550bef6c72392cfe7c30914bf41df5269b68cbd6ff8f570a3"
|
||||
checksum = "42ef146c2ad5e5f4b037cd6ce2ebb775401729b19a82040c1beac9d36c7d1428"
|
||||
dependencies = [
|
||||
"pest",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "serde"
|
||||
|
@ -893,15 +938,6 @@ dependencies = [
|
|||
"serde_derive",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "serde_bytes"
|
||||
version = "0.10.5"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "defbb8a83d7f34cc8380751eeb892b825944222888aff18996ea7901f24aec88"
|
||||
dependencies = [
|
||||
"serde",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "serde_derive"
|
||||
version = "1.0.114"
|
||||
|
@ -1042,16 +1078,6 @@ version = "0.2.1"
|
|||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "f7fe0bb3479651439c9112f72b6c505038574c9fbb575ed1bf3b797fa39dd564"
|
||||
|
||||
[[package]]
|
||||
name = "unroll"
|
||||
version = "0.1.4"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "85890b49d9724df33edc575c4bacd5b0081977da22c4c4984d0c62ec44ed6e09"
|
||||
dependencies = [
|
||||
"quote 0.6.13",
|
||||
"syn 0.15.44",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "utf8-ranges"
|
||||
version = "1.0.4"
|
||||
|
@ -1192,8 +1218,6 @@ dependencies = [
|
|||
"reduce",
|
||||
"regex",
|
||||
"serde",
|
||||
"serde_bytes",
|
||||
"serde_derive",
|
||||
"serde_json",
|
||||
"typed-arena",
|
||||
"zokrates_common",
|
||||
|
@ -1205,8 +1229,11 @@ dependencies = [
|
|||
name = "zokrates_field"
|
||||
version = "0.3.7"
|
||||
dependencies = [
|
||||
"algebra",
|
||||
"algebra-core",
|
||||
"ark-bls12-377",
|
||||
"ark-bn254",
|
||||
"ark-bw6-761",
|
||||
"ark-ec",
|
||||
"ark-ff",
|
||||
"bellman_ce",
|
||||
"bincode 0.8.0",
|
||||
"lazy_static",
|
||||
|
@ -1251,6 +1278,5 @@ dependencies = [
|
|||
"lazy_static",
|
||||
"pest",
|
||||
"pest-ast",
|
||||
"zokrates_field",
|
||||
"zokrates_parser",
|
||||
]
|
||||
|
|
|
@ -13,8 +13,8 @@ js-sys = "0.3.33"
|
|||
serde = { version = "^1.0.59", features = ["derive"] }
|
||||
serde_json = "1.0"
|
||||
wasm-bindgen = { version = "0.2.46", features = ["serde-serialize"] }
|
||||
zokrates_core = { path = "../zokrates_core", features = ["wasm"], default-features = false }
|
||||
zokrates_core = { path = "../zokrates_core", features = ["wasm", "bellman"], default-features = false }
|
||||
zokrates_common = { path = "../zokrates_common" }
|
||||
zokrates_field = { path = "../zokrates_field" }
|
||||
zokrates_field = { path = "../zokrates_field", default-features = false, features = ["bellman"] }
|
||||
zokrates_abi = { path = "../zokrates_abi" }
|
||||
console_error_panic_hook = "0.1.5"
|
Loading…
Reference in a new issue