merge featurize, fix conflicts
This commit is contained in:
commit
77ac5aa55c
78 changed files with 350 additions and 1564 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::ConcreteSignature, ConcreteType};
|
||||
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,
|
||||
|
@ -400,6 +408,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> {
|
||||
|
@ -824,6 +833,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());
|
||||
|
@ -845,11 +855,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),
|
||||
|
@ -890,13 +902,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)
|
||||
|
@ -917,6 +929,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)
|
||||
|
@ -926,6 +939,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)
|
||||
|
@ -997,6 +1011,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(),
|
||||
|
@ -1005,26 +1020,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,6 @@
|
|||
use absy;
|
||||
use imports;
|
||||
use crate::absy;
|
||||
use crate::imports;
|
||||
|
||||
use num_bigint::BigUint;
|
||||
use zokrates_pest_ast as pest;
|
||||
|
||||
|
@ -21,7 +22,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) => {
|
||||
|
@ -46,7 +47,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;
|
||||
|
||||
|
@ -71,7 +72,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<'ast> {
|
||||
use absy::NodeValue;
|
||||
use crate::absy::NodeValue;
|
||||
|
||||
let span = field.span;
|
||||
|
||||
|
@ -85,7 +86,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;
|
||||
|
||||
|
@ -149,7 +150,7 @@ impl<'ast> From<pest::IdentifierExpression<'ast>> for absy::ConstantGenericNode<
|
|||
|
||||
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
|
||||
|
@ -179,7 +180,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;
|
||||
|
||||
|
@ -253,7 +254,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 {
|
||||
|
@ -271,7 +272,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)
|
||||
|
@ -280,7 +281,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();
|
||||
|
@ -315,7 +316,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),
|
||||
|
@ -404,7 +405,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),
|
||||
|
@ -416,7 +417,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),
|
||||
}
|
||||
|
@ -426,7 +427,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));
|
||||
|
||||
|
@ -466,7 +467,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
|
||||
|
@ -480,7 +481,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
|
||||
|
@ -499,7 +500,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::from(initializer.count);
|
||||
|
@ -509,7 +510,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(_) => {
|
||||
|
@ -522,7 +523,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);
|
||||
|
@ -556,7 +557,7 @@ impl<'ast> From<pest::PostfixExpression<'ast>> for absy::ExpressionNode<'ast> {
|
|||
|
||||
impl<'ast> From<pest::DecimalLiteralExpression<'ast>> for absy::ExpressionNode<'ast> {
|
||||
fn from(expression: pest::DecimalLiteralExpression<'ast>) -> absy::ExpressionNode<'ast> {
|
||||
use absy::NodeValue;
|
||||
use crate::absy::NodeValue;
|
||||
|
||||
match expression.suffix {
|
||||
Some(suffix) => match suffix {
|
||||
|
@ -584,7 +585,7 @@ impl<'ast> From<pest::DecimalLiteralExpression<'ast>> for absy::ExpressionNode<'
|
|||
|
||||
impl<'ast> From<pest::HexLiteralExpression<'ast>> for absy::ExpressionNode<'ast> {
|
||||
fn from(expression: pest::HexLiteralExpression<'ast>) -> absy::ExpressionNode<'ast> {
|
||||
use absy::NodeValue;
|
||||
use crate::absy::NodeValue;
|
||||
|
||||
match expression.value {
|
||||
pest::HexNumberExpression::U32(e) => {
|
||||
|
@ -603,7 +604,8 @@ impl<'ast> From<pest::HexLiteralExpression<'ast>> for absy::ExpressionNode<'ast>
|
|||
|
||||
impl<'ast> From<pest::LiteralExpression<'ast>> for absy::ExpressionNode<'ast> {
|
||||
fn from(expression: pest::LiteralExpression<'ast>) -> absy::ExpressionNode<'ast> {
|
||||
use absy::NodeValue;
|
||||
use crate::absy::NodeValue;
|
||||
|
||||
match expression {
|
||||
pest::LiteralExpression::BooleanLiteral(c) => {
|
||||
absy::Expression::BooleanConstant(c.value.parse().unwrap()).span(c.span)
|
||||
|
@ -616,14 +618,14 @@ impl<'ast> From<pest::LiteralExpression<'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)
|
||||
}
|
||||
|
@ -631,7 +633,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;
|
||||
|
@ -652,8 +654,8 @@ impl<'ast> From<pest::Assignee<'ast>> for absy::AssigneeNode<'ast> {
|
|||
|
||||
impl<'ast> From<pest::Type<'ast>> for absy::UnresolvedTypeNode<'ast> {
|
||||
fn from(t: pest::Type<'ast>) -> absy::UnresolvedTypeNode<'ast> {
|
||||
use absy::types::UnresolvedType;
|
||||
use absy::NodeValue;
|
||||
use crate::absy::types::UnresolvedType;
|
||||
use crate::absy::NodeValue;
|
||||
|
||||
match t {
|
||||
pest::Type::Basic(t) => match t {
|
||||
|
@ -700,8 +702,8 @@ impl<'ast> From<pest::Type<'ast>> for absy::UnresolvedTypeNode<'ast> {
|
|||
#[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,5 +1,5 @@
|
|||
use absy::ExpressionNode;
|
||||
use absy::UnresolvedTypeNode;
|
||||
use crate::absy::ExpressionNode;
|
||||
use crate::absy::UnresolvedTypeNode;
|
||||
use std::fmt;
|
||||
|
||||
pub type Identifier<'ast> = &'ast str;
|
||||
|
@ -42,7 +42,7 @@ pub use self::signature::UnresolvedSignature;
|
|||
mod signature {
|
||||
use std::fmt;
|
||||
|
||||
use absy::UnresolvedTypeNode;
|
||||
use crate::absy::UnresolvedTypeNode;
|
||||
|
||||
#[derive(Clone, PartialEq)]
|
||||
pub struct UnresolvedSignature<'ast> {
|
||||
|
|
|
@ -3,22 +3,22 @@
|
|||
//! @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;
|
||||
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;
|
||||
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;
|
||||
|
@ -296,8 +296,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,11 +1,11 @@
|
|||
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::{ConcreteFunctionKey, ConcreteSignature, ConcreteType};
|
||||
use crate::typed_absy::TypedModuleId;
|
||||
use std::collections::HashMap;
|
||||
use typed_absy::types::{ConcreteFunctionKey, ConcreteSignature, ConcreteType};
|
||||
use typed_absy::TypedModuleId;
|
||||
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,11 +18,11 @@ use crate::parser::Position;
|
|||
|
||||
use crate::absy::types::{UnresolvedSignature, UnresolvedType, UserTypeId};
|
||||
|
||||
use std::hash::{Hash, Hasher};
|
||||
use typed_absy::types::{
|
||||
use crate::typed_absy::types::{
|
||||
ArrayType, Constant, DeclarationArrayType, DeclarationFunctionKey, DeclarationSignature,
|
||||
DeclarationStructMember, DeclarationStructType, DeclarationType, StructLocation,
|
||||
};
|
||||
use std::hash::{Hash, Hasher};
|
||||
|
||||
use std::convert::TryInto;
|
||||
|
||||
|
@ -3226,8 +3226,8 @@ impl<'ast, T: Field> Checker<'ast, T> {
|
|||
#[cfg(test)]
|
||||
mod tests {
|
||||
use super::*;
|
||||
use absy;
|
||||
use typed_absy;
|
||||
use crate::absy;
|
||||
use crate::typed_absy;
|
||||
use zokrates_field::Bn128Field;
|
||||
|
||||
const MODULE_ID: &str = "";
|
||||
|
@ -5187,7 +5187,7 @@ mod tests {
|
|||
|
||||
mod structs {
|
||||
use super::*;
|
||||
use typed_absy::types::StructMember;
|
||||
use crate::typed_absy::types::StructMember;
|
||||
|
||||
/// solver function to create a module at location "" with a single symbol `Foo { foo: field }`
|
||||
fn create_module_with_foo(
|
||||
|
|
|
@ -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::UBitwidth;
|
||||
use crate::zir;
|
||||
use std::marker::PhantomData;
|
||||
use typed_absy;
|
||||
use typed_absy::types::UBitwidth;
|
||||
use zir;
|
||||
use zokrates_field::Field;
|
||||
|
||||
use std::convert::{TryFrom, TryInto};
|
||||
|
@ -322,7 +322,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()
|
||||
|
@ -419,7 +419,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()
|
||||
|
|
|
@ -23,7 +23,7 @@ use self::variable_access_remover::VariableAccessRemover;
|
|||
use crate::flat_absy::FlatProg;
|
||||
use crate::ir::Prog;
|
||||
use crate::typed_absy::{abi::Abi, TypedProgram};
|
||||
use zir::ZirProgram;
|
||||
use crate::zir::ZirProgram;
|
||||
use zokrates_field::Field;
|
||||
|
||||
pub trait Analyse {
|
||||
|
|
|
@ -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> {
|
||||
|
|
|
@ -25,16 +25,16 @@
|
|||
// - The body of the function is in SSA form
|
||||
// - The return value(s) are assigned to internal variables
|
||||
|
||||
use embed::FlatEmbed;
|
||||
use static_analysis::reducer::CallCache;
|
||||
use static_analysis::reducer::Output;
|
||||
use static_analysis::reducer::ShallowTransformer;
|
||||
use static_analysis::reducer::Versions;
|
||||
use typed_absy::types::ConcreteGenericsAssignment;
|
||||
use typed_absy::CoreIdentifier;
|
||||
use typed_absy::Identifier;
|
||||
use typed_absy::TypedAssignee;
|
||||
use typed_absy::{
|
||||
use crate::embed::FlatEmbed;
|
||||
use crate::static_analysis::reducer::CallCache;
|
||||
use crate::static_analysis::reducer::Output;
|
||||
use crate::static_analysis::reducer::ShallowTransformer;
|
||||
use crate::static_analysis::reducer::Versions;
|
||||
use crate::typed_absy::types::ConcreteGenericsAssignment;
|
||||
use crate::typed_absy::CoreIdentifier;
|
||||
use crate::typed_absy::Identifier;
|
||||
use crate::typed_absy::TypedAssignee;
|
||||
use crate::typed_absy::{
|
||||
ConcreteFunctionKey, ConcreteSignature, ConcreteVariable, DeclarationFunctionKey, Signature,
|
||||
Type, TypedExpression, TypedFunction, TypedFunctionSymbol, TypedProgram, TypedStatement,
|
||||
Variable,
|
||||
|
@ -83,7 +83,7 @@ pub fn inline_call<'a, 'ast, T: Field>(
|
|||
> {
|
||||
use std::convert::TryFrom;
|
||||
|
||||
use typed_absy::Typed;
|
||||
use crate::typed_absy::Typed;
|
||||
|
||||
// we infer a signature based on inputs and outputs
|
||||
// this is where we could handle explicit annotations
|
||||
|
|
|
@ -13,16 +13,15 @@
|
|||
|
||||
mod inline;
|
||||
mod shallow_ssa;
|
||||
mod unroll;
|
||||
|
||||
use self::inline::{inline_call, InlineError};
|
||||
use crate::typed_absy::result_folder::*;
|
||||
use crate::typed_absy::types::ConcreteGenericsAssignment;
|
||||
use crate::typed_absy::types::GGenericsAssignment;
|
||||
use crate::typed_absy::Folder;
|
||||
use std::collections::HashMap;
|
||||
use typed_absy::result_folder::*;
|
||||
use typed_absy::types::ConcreteGenericsAssignment;
|
||||
use typed_absy::types::GGenericsAssignment;
|
||||
use typed_absy::Folder;
|
||||
|
||||
use typed_absy::{
|
||||
use crate::typed_absy::{
|
||||
ArrayExpression, ArrayExpressionInner, BooleanExpression, ConcreteFunctionKey, CoreIdentifier,
|
||||
DeclarationFunctionKey, FieldElementExpression, FunctionCall, Identifier, StructExpression,
|
||||
StructExpressionInner, Type, Typed, TypedExpression, TypedExpressionList, TypedFunction,
|
||||
|
@ -36,7 +35,7 @@ use zokrates_field::Field;
|
|||
|
||||
use self::shallow_ssa::ShallowTransformer;
|
||||
|
||||
use static_analysis::Propagator;
|
||||
use crate::static_analysis::Propagator;
|
||||
|
||||
use std::fmt;
|
||||
|
||||
|
@ -668,13 +667,13 @@ fn compute_hash<'ast, T: Field>(f: &TypedFunction<'ast, T>) -> u64 {
|
|||
#[cfg(test)]
|
||||
mod tests {
|
||||
use super::*;
|
||||
use crate::typed_absy::types::Constant;
|
||||
use crate::typed_absy::types::DeclarationSignature;
|
||||
use crate::typed_absy::{
|
||||
ArrayExpressionInner, DeclarationFunctionKey, DeclarationType, DeclarationVariable,
|
||||
FieldElementExpression, Identifier, Type, TypedExpression, TypedExpressionList, UBitwidth,
|
||||
UExpression, UExpressionInner, Variable,
|
||||
};
|
||||
use typed_absy::types::Constant;
|
||||
use typed_absy::types::DeclarationSignature;
|
||||
use zokrates_field::Bn128Field;
|
||||
|
||||
#[test]
|
||||
|
@ -1596,7 +1595,7 @@ mod tests {
|
|||
// expected:
|
||||
// Error: Incompatible
|
||||
|
||||
use typed_absy::types::{ConcreteFunctionKey, ConcreteSignature, ConcreteType};
|
||||
use crate::typed_absy::types::{ConcreteFunctionKey, ConcreteSignature, ConcreteType};
|
||||
|
||||
let foo_signature = DeclarationSignature::new()
|
||||
.inputs(vec![DeclarationType::array(
|
||||
|
|
|
@ -25,9 +25,9 @@
|
|||
// return b_3 // we leave versions b_1 and b_2 to make b accessible and modifiable inside the for-loop
|
||||
|
||||
use crate::typed_absy::folder::*;
|
||||
use crate::typed_absy::types::ConcreteGenericsAssignment;
|
||||
use crate::typed_absy::types::{MemberId, Type};
|
||||
use crate::typed_absy::*;
|
||||
use typed_absy::types::ConcreteGenericsAssignment;
|
||||
|
||||
use std::collections::HashSet;
|
||||
|
||||
|
@ -584,7 +584,7 @@ impl<'ast, 'a, T: Field> Folder<'ast, T> for ShallowTransformer<'ast, 'a> {
|
|||
#[cfg(test)]
|
||||
mod tests {
|
||||
use super::*;
|
||||
use typed_absy::types::DeclarationSignature;
|
||||
use crate::typed_absy::types::DeclarationSignature;
|
||||
use zokrates_field::Bn128Field;
|
||||
mod normal {
|
||||
use super::*;
|
||||
|
@ -1200,7 +1200,7 @@ mod tests {
|
|||
|
||||
mod for_loop {
|
||||
use super::*;
|
||||
use typed_absy::types::GGenericsAssignment;
|
||||
use crate::typed_absy::types::GGenericsAssignment;
|
||||
#[test]
|
||||
fn treat_loop() {
|
||||
// def main<K>(field a) -> field:
|
||||
|
@ -1408,7 +1408,7 @@ mod tests {
|
|||
|
||||
mod function_call {
|
||||
use super::*;
|
||||
use typed_absy::types::GGenericsAssignment;
|
||||
use crate::typed_absy::types::GGenericsAssignment;
|
||||
// test that function calls are left in
|
||||
#[test]
|
||||
fn treat_calls() {
|
||||
|
|
|
@ -1 +0,0 @@
|
|||
|
|
@ -1,5 +1,5 @@
|
|||
use typed_absy::TypedModule;
|
||||
use typed_absy::{TypedFunctionSymbol, TypedProgram};
|
||||
use crate::typed_absy::TypedModule;
|
||||
use crate::typed_absy::{TypedFunctionSymbol, TypedProgram};
|
||||
use zokrates_field::Field;
|
||||
|
||||
pub struct Trimmer;
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
use crate::zir::folder::*;
|
||||
use crate::zir::*;
|
||||
use std::collections::HashMap;
|
||||
use zir::folder::*;
|
||||
use zokrates_field::Field;
|
||||
|
||||
#[derive(Default)]
|
||||
|
@ -504,8 +504,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]
|
||||
|
|
|
@ -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 VariableAccessRemover<'ast, T: Field> {
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
use typed_absy::types::ConcreteSignature;
|
||||
use typed_absy::types::ConcreteType;
|
||||
use crate::typed_absy::types::{ConcreteSignature, ConcreteType};
|
||||
use serde::{Deserialize, Serialize};
|
||||
|
||||
#[derive(Serialize, Deserialize, Debug, Eq, PartialEq)]
|
||||
pub struct AbiInput {
|
||||
|
@ -29,14 +29,15 @@ impl Abi {
|
|||
#[cfg(test)]
|
||||
mod tests {
|
||||
use super::*;
|
||||
use std::collections::HashMap;
|
||||
use typed_absy::types::{
|
||||
use crate::typed_absy::types::{
|
||||
ConcreteArrayType, ConcreteFunctionKey, ConcreteStructMember, ConcreteStructType, UBitwidth,
|
||||
};
|
||||
use typed_absy::{
|
||||
use crate::typed_absy::{
|
||||
parameter::DeclarationParameter, variable::DeclarationVariable, ConcreteType,
|
||||
TypedFunction, TypedFunctionSymbol, TypedModule, TypedProgram,
|
||||
};
|
||||
use std::collections::HashMap;
|
||||
use std::collections::HashMap;
|
||||
use zokrates_field::Bn128Field;
|
||||
|
||||
#[test]
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
// Generic walk through a typed AST. Not mutating in place
|
||||
|
||||
use crate::typed_absy::types::{ArrayType, StructMember, StructType};
|
||||
use crate::typed_absy::*;
|
||||
use typed_absy::types::{ArrayType, StructMember, StructType};
|
||||
use zokrates_field::Field;
|
||||
|
||||
pub trait Folder<'ast, T: Field>: Sized {
|
||||
|
|
|
@ -1,12 +1,12 @@
|
|||
use num_bigint::BigUint;
|
||||
use std::convert::TryFrom;
|
||||
use std::fmt;
|
||||
use typed_absy::types::{ArrayType, Type};
|
||||
use typed_absy::UBitwidth;
|
||||
use typed_absy::{
|
||||
use crate::typed_absy::types::{ArrayType, Type};
|
||||
use crate::typed_absy::UBitwidth;
|
||||
use crate::typed_absy::{
|
||||
ArrayExpression, ArrayExpressionInner, BooleanExpression, FieldElementExpression, IfElse,
|
||||
Select, StructExpression, Typed, TypedExpression, UExpression, UExpressionInner,
|
||||
};
|
||||
use num_bigint::BigUint;
|
||||
use std::convert::TryFrom;
|
||||
use std::fmt;
|
||||
use zokrates_field::Field;
|
||||
|
||||
impl<'ast, T: Field> TypedExpression<'ast, T> {
|
||||
|
|
|
@ -23,25 +23,26 @@ pub use self::types::{
|
|||
DeclarationSignature, DeclarationType, GArrayType, GStructType, GType, GenericIdentifier,
|
||||
Signature, StructType, Type, UBitwidth,
|
||||
};
|
||||
use typed_absy::types::ConcreteGenericsAssignment;
|
||||
use crate::typed_absy::types::ConcreteGenericsAssignment;
|
||||
|
||||
pub use self::variable::{ConcreteVariable, DeclarationVariable, GVariable, Variable};
|
||||
use std::path::PathBuf;
|
||||
|
||||
pub use typed_absy::integer::IntExpression;
|
||||
pub use typed_absy::uint::{bitwidth, UExpression, UExpressionInner, UMetadata};
|
||||
pub use crate::typed_absy::integer::IntExpression;
|
||||
pub use crate::typed_absy::uint::{bitwidth, UExpression, UExpressionInner, UMetadata};
|
||||
|
||||
use crate::embed::FlatEmbed;
|
||||
|
||||
use embed::FlatEmbed;
|
||||
use std::collections::HashMap;
|
||||
use std::convert::{TryFrom, TryInto};
|
||||
use std::fmt;
|
||||
|
||||
pub use typed_absy::types::{ArrayType, FunctionKey, MemberId};
|
||||
pub use crate::typed_absy::types::{ArrayType, FunctionKey, MemberId};
|
||||
|
||||
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,6 +1,6 @@
|
|||
use crate::typed_absy::types::Constant;
|
||||
use crate::typed_absy::GVariable;
|
||||
use std::fmt;
|
||||
use typed_absy::types::Constant;
|
||||
|
||||
#[derive(Clone, PartialEq, Eq, Hash)]
|
||||
pub struct GParameter<'ast, S> {
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
// Generic walk through a typed AST. Not mutating in place
|
||||
|
||||
use crate::typed_absy::types::{ArrayType, StructMember, StructType};
|
||||
use crate::typed_absy::*;
|
||||
use typed_absy::types::{ArrayType, StructMember, StructType};
|
||||
use zokrates_field::Field;
|
||||
|
||||
pub trait ResultFolder<'ast, T: Field>: Sized {
|
||||
|
|
|
@ -1,9 +1,10 @@
|
|||
use crate::typed_absy::{TryFrom, TryInto};
|
||||
use crate::typed_absy::{TypedModuleId, UExpression, UExpressionInner};
|
||||
use serde::{de::Error, ser::SerializeMap, Deserialize, Deserializer, Serialize, Serializer};
|
||||
use std::collections::BTreeMap;
|
||||
use std::fmt;
|
||||
use std::hash::{Hash, Hasher};
|
||||
use std::path::{Path, PathBuf};
|
||||
use typed_absy::{TryFrom, TryInto};
|
||||
use typed_absy::{TypedModuleId, UExpression, UExpressionInner};
|
||||
|
||||
pub type GenericIdentifier<'ast> = &'ast str;
|
||||
|
||||
|
@ -819,9 +820,6 @@ impl<'ast> ConcreteFunctionKey<'ast> {
|
|||
}
|
||||
|
||||
pub use self::signature::{ConcreteSignature, DeclarationSignature, GSignature, Signature};
|
||||
use serde::de::Error;
|
||||
use serde::ser::SerializeMap;
|
||||
use serde::{Deserialize, Deserializer, Serialize, Serializer};
|
||||
|
||||
pub mod signature {
|
||||
use super::*;
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
use typed_absy::types::UBitwidth;
|
||||
use typed_absy::*;
|
||||
use crate::typed_absy::types::UBitwidth;
|
||||
use crate::typed_absy::*;
|
||||
use zokrates_field::Field;
|
||||
|
||||
type Bitwidth = usize;
|
||||
|
|
|
@ -1,9 +1,9 @@
|
|||
use crate::typed_absy::types::GType;
|
||||
use crate::typed_absy::types::{Constant, GStructType, UBitwidth};
|
||||
use crate::typed_absy::Identifier;
|
||||
use crate::typed_absy::UExpression;
|
||||
use crate::typed_absy::{TryFrom, TryInto};
|
||||
use std::fmt;
|
||||
use typed_absy::types::{Constant, GStructType, UBitwidth};
|
||||
use typed_absy::UExpression;
|
||||
use typed_absy::{TryFrom, TryInto};
|
||||
|
||||
#[derive(Clone, PartialEq, Hash, Eq)]
|
||||
pub struct GVariable<'ast, S> {
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
use typed_absy;
|
||||
use zir;
|
||||
use crate::typed_absy;
|
||||
use crate::zir;
|
||||
|
||||
impl<'ast> From<typed_absy::types::ConcreteFunctionKey<'ast>> for zir::types::FunctionKey<'ast> {
|
||||
fn from(k: typed_absy::types::ConcreteFunctionKey<'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, TryInto};
|
||||
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,5 +1,6 @@
|
|||
use crate::zir::ZirModuleId;
|
||||
use serde::{Deserialize, Serialize};
|
||||
use std::fmt;
|
||||
use zir::ZirModuleId;
|
||||
|
||||
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)]
|
||||
|
@ -339,6 +341,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;
|
||||
|
@ -488,6 +491,7 @@ mod prime_field {
|
|||
};
|
||||
}
|
||||
|
||||
#[cfg(feature = "bellman")]
|
||||
macro_rules! bellman_extensions {
|
||||
($bellman_type:ty, $fq2_type:ident) => {
|
||||
use crate::BellmanFieldExtensions;
|
||||
|
@ -522,6 +526,7 @@ mod prime_field {
|
|||
};
|
||||
}
|
||||
|
||||
#[cfg(feature = "ark")]
|
||||
macro_rules! ark_extensions {
|
||||
($ark_type:ty) => {
|
||||
use crate::ArkFieldExtensions;
|
||||
|
|
1263
zokrates_js/Cargo.lock
generated
1263
zokrates_js/Cargo.lock
generated
File diff suppressed because it is too large
Load diff
|
@ -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