merge develop
This commit is contained in:
commit
333adeb3ed
40 changed files with 513 additions and 554 deletions
|
@ -20,7 +20,7 @@ jobs:
|
||||||
command: ./scripts/install_libsnark_prerequisites.sh
|
command: ./scripts/install_libsnark_prerequisites.sh
|
||||||
- run:
|
- run:
|
||||||
name: Build
|
name: Build
|
||||||
command: ZOKRATES_HOME=$(pwd)/stdlib/ WITH_LIBSNARK=1 RUSTFLAGS="-D warnings" ./build.sh
|
command: ZOKRATES_HOME=$(pwd)/zokrates_stdlib/stdlib/ WITH_LIBSNARK=1 RUSTFLAGS="-D warnings" ./build.sh
|
||||||
- save_cache:
|
- save_cache:
|
||||||
paths:
|
paths:
|
||||||
- /usr/local/cargo/registry
|
- /usr/local/cargo/registry
|
||||||
|
@ -50,10 +50,10 @@ jobs:
|
||||||
command: ./scripts/install_libsnark_prerequisites.sh
|
command: ./scripts/install_libsnark_prerequisites.sh
|
||||||
- run:
|
- run:
|
||||||
name: Build
|
name: Build
|
||||||
command: ZOKRATES_HOME=$(pwd)/stdlib/ WITH_LIBSNARK=1 RUSTFLAGS="-D warnings" ./build.sh
|
command: ZOKRATES_HOME=$(pwd)/zokrates_stdlib/stdlib/ WITH_LIBSNARK=1 RUSTFLAGS="-D warnings" ./build.sh
|
||||||
- run:
|
- run:
|
||||||
name: Run tests
|
name: Run tests
|
||||||
command: ZOKRATES_HOME=$(pwd)/stdlib/ WITH_LIBSNARK=1 RUSTFLAGS="-D warnings" cargo test --release -- --test-threads=1
|
command: ZOKRATES_HOME=$(pwd)/zokrates_stdlib/stdlib/ WITH_LIBSNARK=1 RUSTFLAGS="-D warnings" cargo test --release -- --test-threads=1
|
||||||
- run:
|
- run:
|
||||||
name: Generate code coverage report
|
name: Generate code coverage report
|
||||||
command: ./scripts/cov.sh
|
command: ./scripts/cov.sh
|
||||||
|
@ -102,7 +102,7 @@ jobs:
|
||||||
command: ./scripts/install_solcjs_deb.sh
|
command: ./scripts/install_solcjs_deb.sh
|
||||||
- run:
|
- run:
|
||||||
name: Run integration tests
|
name: Run integration tests
|
||||||
command: ZOKRATES_HOME=$(pwd)/stdlib/ WITH_LIBSNARK=1 RUSTFLAGS="-D warnings" cargo test --release -- --ignored
|
command: ZOKRATES_HOME=$(pwd)/zokrates_stdlib/stdlib/ WITH_LIBSNARK=1 RUSTFLAGS="-D warnings" cargo test --release -- --ignored
|
||||||
deploy:
|
deploy:
|
||||||
docker:
|
docker:
|
||||||
- image: circleci/python
|
- image: circleci/python
|
||||||
|
|
60
Cargo.lock
generated
60
Cargo.lock
generated
|
@ -70,7 +70,7 @@ name = "backtrace-sys"
|
||||||
version = "0.1.28"
|
version = "0.1.28"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"cc 1.0.30 (registry+https://github.com/rust-lang/crates.io-index)",
|
"cc 1.0.31 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
"libc 0.2.50 (registry+https://github.com/rust-lang/crates.io-index)",
|
"libc 0.2.50 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
]
|
]
|
||||||
|
|
||||||
|
@ -149,7 +149,7 @@ dependencies = [
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "cc"
|
name = "cc"
|
||||||
version = "1.0.30"
|
version = "1.0.31"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"rayon 1.0.3 (registry+https://github.com/rust-lang/crates.io-index)",
|
"rayon 1.0.3 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
|
@ -187,7 +187,7 @@ name = "cmake"
|
||||||
version = "0.1.35"
|
version = "0.1.35"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"cc 1.0.30 (registry+https://github.com/rust-lang/crates.io-index)",
|
"cc 1.0.31 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
]
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
|
@ -314,10 +314,10 @@ dependencies = [
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "curl-sys"
|
name = "curl-sys"
|
||||||
version = "0.4.16"
|
version = "0.4.17"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"cc 1.0.30 (registry+https://github.com/rust-lang/crates.io-index)",
|
"cc 1.0.31 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
"libc 0.2.50 (registry+https://github.com/rust-lang/crates.io-index)",
|
"libc 0.2.50 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
"libz-sys 1.0.25 (registry+https://github.com/rust-lang/crates.io-index)",
|
"libz-sys 1.0.25 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
"openssl-sys 0.9.42 (registry+https://github.com/rust-lang/crates.io-index)",
|
"openssl-sys 0.9.42 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
|
@ -419,6 +419,11 @@ name = "glob"
|
||||||
version = "0.2.11"
|
version = "0.2.11"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "glob"
|
||||||
|
version = "0.3.0"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "hex"
|
name = "hex"
|
||||||
version = "0.3.2"
|
version = "0.3.2"
|
||||||
|
@ -459,8 +464,8 @@ name = "libgit2-sys"
|
||||||
version = "0.7.11"
|
version = "0.7.11"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"cc 1.0.30 (registry+https://github.com/rust-lang/crates.io-index)",
|
"cc 1.0.31 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
"curl-sys 0.4.16 (registry+https://github.com/rust-lang/crates.io-index)",
|
"curl-sys 0.4.17 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
"libc 0.2.50 (registry+https://github.com/rust-lang/crates.io-index)",
|
"libc 0.2.50 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
"libssh2-sys 0.2.11 (registry+https://github.com/rust-lang/crates.io-index)",
|
"libssh2-sys 0.2.11 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
"libz-sys 1.0.25 (registry+https://github.com/rust-lang/crates.io-index)",
|
"libz-sys 1.0.25 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
|
@ -473,7 +478,7 @@ name = "libssh2-sys"
|
||||||
version = "0.2.11"
|
version = "0.2.11"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"cc 1.0.30 (registry+https://github.com/rust-lang/crates.io-index)",
|
"cc 1.0.31 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
"libc 0.2.50 (registry+https://github.com/rust-lang/crates.io-index)",
|
"libc 0.2.50 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
"libz-sys 1.0.25 (registry+https://github.com/rust-lang/crates.io-index)",
|
"libz-sys 1.0.25 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
"openssl-sys 0.9.42 (registry+https://github.com/rust-lang/crates.io-index)",
|
"openssl-sys 0.9.42 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
|
@ -486,7 +491,7 @@ name = "libz-sys"
|
||||||
version = "1.0.25"
|
version = "1.0.25"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"cc 1.0.30 (registry+https://github.com/rust-lang/crates.io-index)",
|
"cc 1.0.31 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
"libc 0.2.50 (registry+https://github.com/rust-lang/crates.io-index)",
|
"libc 0.2.50 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
"pkg-config 0.3.14 (registry+https://github.com/rust-lang/crates.io-index)",
|
"pkg-config 0.3.14 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
"vcpkg 0.2.6 (registry+https://github.com/rust-lang/crates.io-index)",
|
"vcpkg 0.2.6 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
|
@ -605,7 +610,7 @@ name = "openssl-sys"
|
||||||
version = "0.9.42"
|
version = "0.9.42"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"cc 1.0.30 (registry+https://github.com/rust-lang/crates.io-index)",
|
"cc 1.0.31 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
"libc 0.2.50 (registry+https://github.com/rust-lang/crates.io-index)",
|
"libc 0.2.50 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
"pkg-config 0.3.14 (registry+https://github.com/rust-lang/crates.io-index)",
|
"pkg-config 0.3.14 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
"rustc_version 0.2.3 (registry+https://github.com/rust-lang/crates.io-index)",
|
"rustc_version 0.2.3 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
|
@ -929,7 +934,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"proc-macro2 0.4.27 (registry+https://github.com/rust-lang/crates.io-index)",
|
"proc-macro2 0.4.27 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
"quote 0.6.11 (registry+https://github.com/rust-lang/crates.io-index)",
|
"quote 0.6.11 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
"syn 0.15.27 (registry+https://github.com/rust-lang/crates.io-index)",
|
"syn 0.15.29 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
]
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
|
@ -979,7 +984,7 @@ dependencies = [
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "syn"
|
name = "syn"
|
||||||
version = "0.15.27"
|
version = "0.15.29"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"proc-macro2 0.4.27 (registry+https://github.com/rust-lang/crates.io-index)",
|
"proc-macro2 0.4.27 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
|
@ -1103,10 +1108,9 @@ dependencies = [
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "wasmi"
|
name = "wasmi"
|
||||||
version = "0.4.3"
|
version = "0.4.4"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"byteorder 1.3.1 (registry+https://github.com/rust-lang/crates.io-index)",
|
|
||||||
"memory_units 0.3.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
"memory_units 0.3.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
"parity-wasm 0.31.3 (registry+https://github.com/rust-lang/crates.io-index)",
|
"parity-wasm 0.31.3 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
]
|
]
|
||||||
|
@ -1140,7 +1144,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "zokrates_cli"
|
name = "zokrates_cli"
|
||||||
version = "0.4.2"
|
version = "0.4.3"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"assert_cli 0.5.4 (registry+https://github.com/rust-lang/crates.io-index)",
|
"assert_cli 0.5.4 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
"bincode 0.8.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
"bincode 0.8.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
|
@ -1163,7 +1167,7 @@ dependencies = [
|
||||||
"bellman 0.2.0 (git+https://github.com/matterinc/bellman?tag=0.2.0)",
|
"bellman 0.2.0 (git+https://github.com/matterinc/bellman?tag=0.2.0)",
|
||||||
"bimap 0.1.5 (registry+https://github.com/rust-lang/crates.io-index)",
|
"bimap 0.1.5 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
"bincode 0.8.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
"bincode 0.8.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
"cc 1.0.30 (registry+https://github.com/rust-lang/crates.io-index)",
|
"cc 1.0.31 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
"cmake 0.1.35 (registry+https://github.com/rust-lang/crates.io-index)",
|
"cmake 0.1.35 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
"ff 0.5.0 (git+https://github.com/matterinc/ff?tag=0.5)",
|
"ff 0.5.0 (git+https://github.com/matterinc/ff?tag=0.5)",
|
||||||
"git2 0.8.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
"git2 0.8.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
|
@ -1182,7 +1186,7 @@ dependencies = [
|
||||||
"serde_bytes 0.10.5 (registry+https://github.com/rust-lang/crates.io-index)",
|
"serde_bytes 0.10.5 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
"serde_derive 1.0.89 (registry+https://github.com/rust-lang/crates.io-index)",
|
"serde_derive 1.0.89 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
"serde_json 1.0.39 (registry+https://github.com/rust-lang/crates.io-index)",
|
"serde_json 1.0.39 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
"wasmi 0.4.3 (registry+https://github.com/rust-lang/crates.io-index)",
|
"wasmi 0.4.4 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
"zokrates_field 0.3.2",
|
"zokrates_field 0.3.2",
|
||||||
]
|
]
|
||||||
|
|
||||||
|
@ -1210,6 +1214,19 @@ dependencies = [
|
||||||
"tempfile 3.0.7 (registry+https://github.com/rust-lang/crates.io-index)",
|
"tempfile 3.0.7 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
]
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "zokrates_stdlib"
|
||||||
|
version = "0.1.0"
|
||||||
|
dependencies = [
|
||||||
|
"glob 0.3.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
|
"serde 1.0.89 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
|
"serde_derive 1.0.89 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
|
"serde_json 1.0.39 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
|
"zokrates_core 0.3.6",
|
||||||
|
"zokrates_field 0.3.2",
|
||||||
|
"zokrates_fs_resolver 0.4.0",
|
||||||
|
]
|
||||||
|
|
||||||
[metadata]
|
[metadata]
|
||||||
"checksum aho-corasick 0.6.10 (registry+https://github.com/rust-lang/crates.io-index)" = "81ce3d38065e618af2d7b77e10c5ad9a069859b4be3c2250f674af3840d9c8a5"
|
"checksum aho-corasick 0.6.10 (registry+https://github.com/rust-lang/crates.io-index)" = "81ce3d38065e618af2d7b77e10c5ad9a069859b4be3c2250f674af3840d9c8a5"
|
||||||
"checksum ansi_term 0.11.0 (registry+https://github.com/rust-lang/crates.io-index)" = "ee49baf6cb617b853aa8d93bf420db2383fab46d314482ca2803b40d5fde979b"
|
"checksum ansi_term 0.11.0 (registry+https://github.com/rust-lang/crates.io-index)" = "ee49baf6cb617b853aa8d93bf420db2383fab46d314482ca2803b40d5fde979b"
|
||||||
|
@ -1228,7 +1245,7 @@ dependencies = [
|
||||||
"checksum bytecount 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)" = "b92204551573580e078dc80017f36a213eb77a0450e4ddd8cfa0f3f2d1f0178f"
|
"checksum bytecount 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)" = "b92204551573580e078dc80017f36a213eb77a0450e4ddd8cfa0f3f2d1f0178f"
|
||||||
"checksum byteorder 1.3.1 (registry+https://github.com/rust-lang/crates.io-index)" = "a019b10a2a7cdeb292db131fc8113e57ea2a908f6e7894b0c3c671893b65dbeb"
|
"checksum byteorder 1.3.1 (registry+https://github.com/rust-lang/crates.io-index)" = "a019b10a2a7cdeb292db131fc8113e57ea2a908f6e7894b0c3c671893b65dbeb"
|
||||||
"checksum cargo_metadata 0.6.4 (registry+https://github.com/rust-lang/crates.io-index)" = "e5d1b4d380e1bab994591a24c2bdd1b054f64b60bef483a8c598c7c345bc3bbe"
|
"checksum cargo_metadata 0.6.4 (registry+https://github.com/rust-lang/crates.io-index)" = "e5d1b4d380e1bab994591a24c2bdd1b054f64b60bef483a8c598c7c345bc3bbe"
|
||||||
"checksum cc 1.0.30 (registry+https://github.com/rust-lang/crates.io-index)" = "d01c69d08ff207f231f07196e30f84c70f1c815b04f980f8b7b01ff01f05eb92"
|
"checksum cc 1.0.31 (registry+https://github.com/rust-lang/crates.io-index)" = "c9ce8bb087aacff865633f0bd5aeaed910fe2fe55b55f4739527f2e023a2e53d"
|
||||||
"checksum cfg-if 0.1.7 (registry+https://github.com/rust-lang/crates.io-index)" = "11d43355396e872eefb45ce6342e4374ed7bc2b3a502d1b28e36d6e23c05d1f4"
|
"checksum cfg-if 0.1.7 (registry+https://github.com/rust-lang/crates.io-index)" = "11d43355396e872eefb45ce6342e4374ed7bc2b3a502d1b28e36d6e23c05d1f4"
|
||||||
"checksum clap 2.32.0 (registry+https://github.com/rust-lang/crates.io-index)" = "b957d88f4b6a63b9d70d5f454ac8011819c6efa7727858f458ab71c756ce2d3e"
|
"checksum clap 2.32.0 (registry+https://github.com/rust-lang/crates.io-index)" = "b957d88f4b6a63b9d70d5f454ac8011819c6efa7727858f458ab71c756ce2d3e"
|
||||||
"checksum cloudabi 0.0.3 (registry+https://github.com/rust-lang/crates.io-index)" = "ddfc5b9aa5d4507acaf872de71051dfd0e309860e88966e1051e462a077aac4f"
|
"checksum cloudabi 0.0.3 (registry+https://github.com/rust-lang/crates.io-index)" = "ddfc5b9aa5d4507acaf872de71051dfd0e309860e88966e1051e462a077aac4f"
|
||||||
|
@ -1246,7 +1263,7 @@ dependencies = [
|
||||||
"checksum crossbeam-utils 0.6.5 (registry+https://github.com/rust-lang/crates.io-index)" = "f8306fcef4a7b563b76b7dd949ca48f52bc1141aa067d2ea09565f3e2652aa5c"
|
"checksum crossbeam-utils 0.6.5 (registry+https://github.com/rust-lang/crates.io-index)" = "f8306fcef4a7b563b76b7dd949ca48f52bc1141aa067d2ea09565f3e2652aa5c"
|
||||||
"checksum csv 1.0.5 (registry+https://github.com/rust-lang/crates.io-index)" = "9fd1c44c58078cfbeaf11fbb3eac9ae5534c23004ed770cc4bfb48e658ae4f04"
|
"checksum csv 1.0.5 (registry+https://github.com/rust-lang/crates.io-index)" = "9fd1c44c58078cfbeaf11fbb3eac9ae5534c23004ed770cc4bfb48e658ae4f04"
|
||||||
"checksum csv-core 0.1.5 (registry+https://github.com/rust-lang/crates.io-index)" = "fa5cdef62f37e6ffe7d1f07a381bc0db32b7a3ff1cac0de56cb0d81e71f53d65"
|
"checksum csv-core 0.1.5 (registry+https://github.com/rust-lang/crates.io-index)" = "fa5cdef62f37e6ffe7d1f07a381bc0db32b7a3ff1cac0de56cb0d81e71f53d65"
|
||||||
"checksum curl-sys 0.4.16 (registry+https://github.com/rust-lang/crates.io-index)" = "ca79238a79fb294be6173b4057c95b22a718c94c4e38475d5faa82b8383f3502"
|
"checksum curl-sys 0.4.17 (registry+https://github.com/rust-lang/crates.io-index)" = "7b8d8e51964f58c8053337fcef48e1c4608c7ee70c6f2e457674a97dda5a5828"
|
||||||
"checksum difference 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)" = "b3304d19798a8e067e48d8e69b2c37f0b5e9b4e462504ad9e27e9f3fce02bba8"
|
"checksum difference 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)" = "b3304d19798a8e067e48d8e69b2c37f0b5e9b4e462504ad9e27e9f3fce02bba8"
|
||||||
"checksum either 1.5.1 (registry+https://github.com/rust-lang/crates.io-index)" = "c67353c641dc847124ea1902d69bd753dee9bb3beff9aa3662ecf86c971d1fac"
|
"checksum either 1.5.1 (registry+https://github.com/rust-lang/crates.io-index)" = "c67353c641dc847124ea1902d69bd753dee9bb3beff9aa3662ecf86c971d1fac"
|
||||||
"checksum environment 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)" = "1f4b14e20978669064c33b4c1e0fb4083412e40fe56cbea2eae80fd7591503ee"
|
"checksum environment 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)" = "1f4b14e20978669064c33b4c1e0fb4083412e40fe56cbea2eae80fd7591503ee"
|
||||||
|
@ -1259,6 +1276,7 @@ dependencies = [
|
||||||
"checksum futures-cpupool 0.1.8 (registry+https://github.com/rust-lang/crates.io-index)" = "ab90cde24b3319636588d0c35fe03b1333857621051837ed769faefb4c2162e4"
|
"checksum futures-cpupool 0.1.8 (registry+https://github.com/rust-lang/crates.io-index)" = "ab90cde24b3319636588d0c35fe03b1333857621051837ed769faefb4c2162e4"
|
||||||
"checksum git2 0.8.0 (registry+https://github.com/rust-lang/crates.io-index)" = "c7339329bfa14a00223244311560d11f8f489b453fb90092af97f267a6090ab0"
|
"checksum git2 0.8.0 (registry+https://github.com/rust-lang/crates.io-index)" = "c7339329bfa14a00223244311560d11f8f489b453fb90092af97f267a6090ab0"
|
||||||
"checksum glob 0.2.11 (registry+https://github.com/rust-lang/crates.io-index)" = "8be18de09a56b60ed0edf84bc9df007e30040691af7acd1c41874faac5895bfb"
|
"checksum glob 0.2.11 (registry+https://github.com/rust-lang/crates.io-index)" = "8be18de09a56b60ed0edf84bc9df007e30040691af7acd1c41874faac5895bfb"
|
||||||
|
"checksum glob 0.3.0 (registry+https://github.com/rust-lang/crates.io-index)" = "9b919933a397b79c37e33b77bb2aa3dc8eb6e165ad809e58ff75bc7db2e34574"
|
||||||
"checksum hex 0.3.2 (registry+https://github.com/rust-lang/crates.io-index)" = "805026a5d0141ffc30abb3be3173848ad46a1b1664fe632428479619a3644d77"
|
"checksum hex 0.3.2 (registry+https://github.com/rust-lang/crates.io-index)" = "805026a5d0141ffc30abb3be3173848ad46a1b1664fe632428479619a3644d77"
|
||||||
"checksum idna 0.1.5 (registry+https://github.com/rust-lang/crates.io-index)" = "38f09e0f0b1fb55fdee1f17470ad800da77af5186a1a76c026b679358b7e844e"
|
"checksum idna 0.1.5 (registry+https://github.com/rust-lang/crates.io-index)" = "38f09e0f0b1fb55fdee1f17470ad800da77af5186a1a76c026b679358b7e844e"
|
||||||
"checksum itoa 0.4.3 (registry+https://github.com/rust-lang/crates.io-index)" = "1306f3464951f30e30d12373d31c79fbd52d236e5e896fd92f96ec7babbbe60b"
|
"checksum itoa 0.4.3 (registry+https://github.com/rust-lang/crates.io-index)" = "1306f3464951f30e30d12373d31c79fbd52d236e5e896fd92f96ec7babbbe60b"
|
||||||
|
@ -1328,7 +1346,7 @@ dependencies = [
|
||||||
"checksum smallvec 0.6.9 (registry+https://github.com/rust-lang/crates.io-index)" = "c4488ae950c49d403731982257768f48fada354a5203fe81f9bb6f43ca9002be"
|
"checksum smallvec 0.6.9 (registry+https://github.com/rust-lang/crates.io-index)" = "c4488ae950c49d403731982257768f48fada354a5203fe81f9bb6f43ca9002be"
|
||||||
"checksum strsim 0.7.0 (registry+https://github.com/rust-lang/crates.io-index)" = "bb4f380125926a99e52bc279241539c018323fab05ad6368b56f93d9369ff550"
|
"checksum strsim 0.7.0 (registry+https://github.com/rust-lang/crates.io-index)" = "bb4f380125926a99e52bc279241539c018323fab05ad6368b56f93d9369ff550"
|
||||||
"checksum syn 0.14.9 (registry+https://github.com/rust-lang/crates.io-index)" = "261ae9ecaa397c42b960649561949d69311f08eeaea86a65696e6e46517cf741"
|
"checksum syn 0.14.9 (registry+https://github.com/rust-lang/crates.io-index)" = "261ae9ecaa397c42b960649561949d69311f08eeaea86a65696e6e46517cf741"
|
||||||
"checksum syn 0.15.27 (registry+https://github.com/rust-lang/crates.io-index)" = "525bd55255f03c816e5d7f615587bd13030c7103354fadb104993dcee6a788ec"
|
"checksum syn 0.15.29 (registry+https://github.com/rust-lang/crates.io-index)" = "1825685f977249735d510a242a6727b46efe914bb67e38d30c071b1b72b1d5c2"
|
||||||
"checksum tempdir 0.3.7 (registry+https://github.com/rust-lang/crates.io-index)" = "15f2b5fb00ccdf689e0149d1b1b3c03fead81c2b37735d812fa8bddbbf41b6d8"
|
"checksum tempdir 0.3.7 (registry+https://github.com/rust-lang/crates.io-index)" = "15f2b5fb00ccdf689e0149d1b1b3c03fead81c2b37735d812fa8bddbbf41b6d8"
|
||||||
"checksum tempfile 3.0.7 (registry+https://github.com/rust-lang/crates.io-index)" = "b86c784c88d98c801132806dadd3819ed29d8600836c4088e855cdf3e178ed8a"
|
"checksum tempfile 3.0.7 (registry+https://github.com/rust-lang/crates.io-index)" = "b86c784c88d98c801132806dadd3819ed29d8600836c4088e855cdf3e178ed8a"
|
||||||
"checksum termion 1.5.1 (registry+https://github.com/rust-lang/crates.io-index)" = "689a3bdfaab439fd92bc87df5c4c78417d3cbe537487274e9b0b2dce76e92096"
|
"checksum termion 1.5.1 (registry+https://github.com/rust-lang/crates.io-index)" = "689a3bdfaab439fd92bc87df5c4c78417d3cbe537487274e9b0b2dce76e92096"
|
||||||
|
@ -1344,7 +1362,7 @@ dependencies = [
|
||||||
"checksum vcpkg 0.2.6 (registry+https://github.com/rust-lang/crates.io-index)" = "def296d3eb3b12371b2c7d0e83bfe1403e4db2d7a0bba324a12b21c4ee13143d"
|
"checksum vcpkg 0.2.6 (registry+https://github.com/rust-lang/crates.io-index)" = "def296d3eb3b12371b2c7d0e83bfe1403e4db2d7a0bba324a12b21c4ee13143d"
|
||||||
"checksum vec_map 0.8.1 (registry+https://github.com/rust-lang/crates.io-index)" = "05c78687fb1a80548ae3250346c3db86a80a7cdd77bda190189f2d0a0987c81a"
|
"checksum vec_map 0.8.1 (registry+https://github.com/rust-lang/crates.io-index)" = "05c78687fb1a80548ae3250346c3db86a80a7cdd77bda190189f2d0a0987c81a"
|
||||||
"checksum walkdir 2.2.7 (registry+https://github.com/rust-lang/crates.io-index)" = "9d9d7ed3431229a144296213105a390676cc49c9b6a72bd19f3176c98e129fa1"
|
"checksum walkdir 2.2.7 (registry+https://github.com/rust-lang/crates.io-index)" = "9d9d7ed3431229a144296213105a390676cc49c9b6a72bd19f3176c98e129fa1"
|
||||||
"checksum wasmi 0.4.3 (registry+https://github.com/rust-lang/crates.io-index)" = "21ef487a11df1ed468cf613c78798c26282da5c30e9d49f824872d4c77b47d1d"
|
"checksum wasmi 0.4.4 (registry+https://github.com/rust-lang/crates.io-index)" = "f6a891b45c79e9f96fb66cc84a057211ef9cd2e5e8d093f3dbbd480e146a8758"
|
||||||
"checksum winapi 0.3.6 (registry+https://github.com/rust-lang/crates.io-index)" = "92c1eb33641e276cfa214a0522acad57be5c56b10cb348b3c5117db75f3ac4b0"
|
"checksum winapi 0.3.6 (registry+https://github.com/rust-lang/crates.io-index)" = "92c1eb33641e276cfa214a0522acad57be5c56b10cb348b3c5117db75f3ac4b0"
|
||||||
"checksum winapi-i686-pc-windows-gnu 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)" = "ac3b87c63620426dd9b991e5ce0329eff545bccbbb34f3be09ff6fb6ab51b7b6"
|
"checksum winapi-i686-pc-windows-gnu 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)" = "ac3b87c63620426dd9b991e5ce0329eff545bccbbb34f3be09ff6fb6ab51b7b6"
|
||||||
"checksum winapi-util 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)" = "7168bab6e1daee33b4557efd0e95d5ca70a03706d39fa5f3fe7a236f584b03c9"
|
"checksum winapi-util 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)" = "7168bab6e1daee33b4557efd0e95d5ca70a03706d39fa5f3fe7a236f584b03c9"
|
||||||
|
|
|
@ -4,4 +4,5 @@ members = [
|
||||||
"zokrates_core",
|
"zokrates_core",
|
||||||
"zokrates_cli",
|
"zokrates_cli",
|
||||||
"zokrates_fs_resolver",
|
"zokrates_fs_resolver",
|
||||||
|
"zokrates_stdlib",
|
||||||
]
|
]
|
|
@ -29,6 +29,6 @@ RUN curl https://sh.rustup.rs -sSf | sh -s -- --default-toolchain $RUST_TOOLCHAI
|
||||||
&& (cd src;./build_release.sh) \
|
&& (cd src;./build_release.sh) \
|
||||||
&& mv ./src/target/release/zokrates . \
|
&& mv ./src/target/release/zokrates . \
|
||||||
&& mv ./src/zokrates_cli/examples . \
|
&& mv ./src/zokrates_cli/examples . \
|
||||||
&& mv ./src/stdlib/* $ZOKRATES_HOME \
|
&& mv ./src/zokrates_stdlib/stdlib/* $ZOKRATES_HOME \
|
||||||
&& rustup self uninstall -y \
|
&& rustup self uninstall -y \
|
||||||
&& rm -rf src
|
&& rm -rf src
|
|
@ -5,7 +5,7 @@ MAINTAINER JacobEberhardt <jacob.eberhardt@tu-berlin.de>, Thibaut Schaeffer <thi
|
||||||
RUN useradd -u 1000 -m zokrates
|
RUN useradd -u 1000 -m zokrates
|
||||||
|
|
||||||
ENV WITH_LIBSNARK=1
|
ENV WITH_LIBSNARK=1
|
||||||
ENV ZOKRATES_HOME=/home/zokrates/ZoKrates/stdlib/
|
ENV ZOKRATES_HOME=/home/zokrates/ZoKrates/zokrates_stdlib/stdlib/
|
||||||
|
|
||||||
COPY ./scripts/install_libsnark_prerequisites.sh /tmp/
|
COPY ./scripts/install_libsnark_prerequisites.sh /tmp/
|
||||||
RUN /tmp/install_libsnark_prerequisites.sh
|
RUN /tmp/install_libsnark_prerequisites.sh
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
[package]
|
[package]
|
||||||
name = "zokrates_cli"
|
name = "zokrates_cli"
|
||||||
version = "0.4.2"
|
version = "0.4.3"
|
||||||
authors = ["Jacob Eberhardt <jacob.eberhardt@tu-berlin.de>", "Dennis Kuhnert <mail@kyroy.com>", "Thibaut Schaeffer <thibaut@schaeff.fr>"]
|
authors = ["Jacob Eberhardt <jacob.eberhardt@tu-berlin.de>", "Dennis Kuhnert <mail@kyroy.com>", "Thibaut Schaeffer <thibaut@schaeff.fr>"]
|
||||||
repository = "https://github.com/JacobEberhardt/ZoKrates.git"
|
repository = "https://github.com/JacobEberhardt/ZoKrates.git"
|
||||||
edition = "2018"
|
edition = "2018"
|
||||||
|
|
|
@ -162,7 +162,7 @@ pub fn compile_aux<T: Field, R: BufRead, S: BufRead, E: Into<imports::Error>>(
|
||||||
let typed_ast = typed_ast.analyse();
|
let typed_ast = typed_ast.analyse();
|
||||||
|
|
||||||
// flatten input program
|
// flatten input program
|
||||||
let program_flattened = Flattener::new(T::get_required_bits()).flatten_program(typed_ast);
|
let program_flattened = Flattener::flatten(typed_ast);
|
||||||
|
|
||||||
// analyse (constant propagation after call resolution)
|
// analyse (constant propagation after call resolution)
|
||||||
let program_flattened = program_flattened.analyse();
|
let program_flattened = program_flattened.analyse();
|
||||||
|
|
|
@ -36,7 +36,7 @@ impl fmt::Debug for FlatParameter {
|
||||||
}
|
}
|
||||||
|
|
||||||
impl FlatParameter {
|
impl FlatParameter {
|
||||||
pub fn apply_direct_substitution(
|
pub fn apply_substitution(
|
||||||
self,
|
self,
|
||||||
substitution: &HashMap<FlatVariable, FlatVariable>,
|
substitution: &HashMap<FlatVariable, FlatVariable>,
|
||||||
) -> FlatParameter {
|
) -> FlatParameter {
|
||||||
|
|
|
@ -67,15 +67,8 @@ impl fmt::Debug for FlatVariable {
|
||||||
}
|
}
|
||||||
|
|
||||||
impl FlatVariable {
|
impl FlatVariable {
|
||||||
pub fn apply_substitution(
|
pub fn apply_substitution(self, substitution: &HashMap<FlatVariable, FlatVariable>) -> &Self {
|
||||||
self,
|
substitution.get(&self).unwrap()
|
||||||
substitution: &HashMap<FlatVariable, FlatVariable>,
|
|
||||||
should_fallback: bool,
|
|
||||||
) -> Self {
|
|
||||||
match should_fallback {
|
|
||||||
true => substitution.get(&self).unwrap_or(&self).clone(),
|
|
||||||
false => substitution.get(&self).unwrap().clone(),
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn is_output(&self) -> bool {
|
pub fn is_output(&self) -> bool {
|
||||||
|
|
|
@ -213,47 +213,30 @@ impl<T: Field> fmt::Debug for FlatStatement<T> {
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<T: Field> FlatStatement<T> {
|
impl<T: Field> FlatStatement<T> {
|
||||||
pub fn apply_recursive_substitution(
|
pub fn apply_substitution(
|
||||||
self,
|
self,
|
||||||
substitution: &HashMap<FlatVariable, FlatVariable>,
|
substitution: &HashMap<FlatVariable, FlatVariable>,
|
||||||
) -> FlatStatement<T> {
|
|
||||||
self.apply_substitution(substitution, true)
|
|
||||||
}
|
|
||||||
|
|
||||||
pub fn apply_direct_substitution(
|
|
||||||
self,
|
|
||||||
substitution: &HashMap<FlatVariable, FlatVariable>,
|
|
||||||
) -> FlatStatement<T> {
|
|
||||||
self.apply_substitution(substitution, false)
|
|
||||||
}
|
|
||||||
|
|
||||||
fn apply_substitution(
|
|
||||||
self,
|
|
||||||
substitution: &HashMap<FlatVariable, FlatVariable>,
|
|
||||||
should_fallback: bool,
|
|
||||||
) -> FlatStatement<T> {
|
) -> FlatStatement<T> {
|
||||||
match self {
|
match self {
|
||||||
FlatStatement::Definition(id, x) => FlatStatement::Definition(
|
FlatStatement::Definition(id, x) => FlatStatement::Definition(
|
||||||
id.apply_substitution(substitution, should_fallback),
|
*id.apply_substitution(substitution),
|
||||||
x.apply_substitution(substitution, should_fallback),
|
x.apply_substitution(substitution),
|
||||||
),
|
),
|
||||||
FlatStatement::Return(x) => {
|
FlatStatement::Return(x) => FlatStatement::Return(x.apply_substitution(substitution)),
|
||||||
FlatStatement::Return(x.apply_substitution(substitution, should_fallback))
|
|
||||||
}
|
|
||||||
FlatStatement::Condition(x, y) => FlatStatement::Condition(
|
FlatStatement::Condition(x, y) => FlatStatement::Condition(
|
||||||
x.apply_substitution(substitution, should_fallback),
|
x.apply_substitution(substitution),
|
||||||
y.apply_substitution(substitution, should_fallback),
|
y.apply_substitution(substitution),
|
||||||
),
|
),
|
||||||
FlatStatement::Directive(d) => {
|
FlatStatement::Directive(d) => {
|
||||||
let outputs = d
|
let outputs = d
|
||||||
.outputs
|
.outputs
|
||||||
.into_iter()
|
.into_iter()
|
||||||
.map(|o| o.apply_substitution(substitution, should_fallback))
|
.map(|o| *o.apply_substitution(substitution))
|
||||||
.collect();
|
.collect();
|
||||||
let inputs = d
|
let inputs = d
|
||||||
.inputs
|
.inputs
|
||||||
.into_iter()
|
.into_iter()
|
||||||
.map(|i| i.apply_substitution(substitution, should_fallback))
|
.map(|i| i.apply_substitution(substitution))
|
||||||
.collect();
|
.collect();
|
||||||
|
|
||||||
FlatStatement::Directive(DirectiveStatement {
|
FlatStatement::Directive(DirectiveStatement {
|
||||||
|
@ -276,41 +259,26 @@ pub enum FlatExpression<T: Field> {
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<T: Field> FlatExpression<T> {
|
impl<T: Field> FlatExpression<T> {
|
||||||
pub fn apply_recursive_substitution(
|
pub fn apply_substitution(
|
||||||
self,
|
self,
|
||||||
substitution: &HashMap<FlatVariable, FlatVariable>,
|
substitution: &HashMap<FlatVariable, FlatVariable>,
|
||||||
) -> FlatExpression<T> {
|
|
||||||
self.apply_substitution(substitution, true)
|
|
||||||
}
|
|
||||||
|
|
||||||
pub fn apply_direct_substitution(
|
|
||||||
self,
|
|
||||||
substitution: &HashMap<FlatVariable, FlatVariable>,
|
|
||||||
) -> FlatExpression<T> {
|
|
||||||
self.apply_substitution(substitution, false)
|
|
||||||
}
|
|
||||||
|
|
||||||
fn apply_substitution(
|
|
||||||
self,
|
|
||||||
substitution: &HashMap<FlatVariable, FlatVariable>,
|
|
||||||
should_fallback: bool,
|
|
||||||
) -> FlatExpression<T> {
|
) -> FlatExpression<T> {
|
||||||
match self {
|
match self {
|
||||||
e @ FlatExpression::Number(_) => e,
|
e @ FlatExpression::Number(_) => e,
|
||||||
FlatExpression::Identifier(id) => {
|
FlatExpression::Identifier(id) => {
|
||||||
FlatExpression::Identifier(id.apply_substitution(substitution, should_fallback))
|
FlatExpression::Identifier(*id.apply_substitution(substitution))
|
||||||
}
|
}
|
||||||
FlatExpression::Add(e1, e2) => FlatExpression::Add(
|
FlatExpression::Add(e1, e2) => FlatExpression::Add(
|
||||||
box e1.apply_substitution(substitution, should_fallback),
|
box e1.apply_substitution(substitution),
|
||||||
box e2.apply_substitution(substitution, should_fallback),
|
box e2.apply_substitution(substitution),
|
||||||
),
|
),
|
||||||
FlatExpression::Sub(e1, e2) => FlatExpression::Sub(
|
FlatExpression::Sub(e1, e2) => FlatExpression::Sub(
|
||||||
box e1.apply_substitution(substitution, should_fallback),
|
box e1.apply_substitution(substitution),
|
||||||
box e2.apply_substitution(substitution, should_fallback),
|
box e2.apply_substitution(substitution),
|
||||||
),
|
),
|
||||||
FlatExpression::Mult(e1, e2) => FlatExpression::Mult(
|
FlatExpression::Mult(e1, e2) => FlatExpression::Mult(
|
||||||
box e1.apply_substitution(substitution, should_fallback),
|
box e1.apply_substitution(substitution),
|
||||||
box e2.apply_substitution(substitution, should_fallback),
|
box e2.apply_substitution(substitution),
|
||||||
),
|
),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -392,33 +360,18 @@ impl<T: Field> fmt::Display for FlatExpressionList<T> {
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<T: Field> FlatExpressionList<T> {
|
impl<T: Field> FlatExpressionList<T> {
|
||||||
fn apply_substitution(
|
pub fn apply_substitution(
|
||||||
self,
|
self,
|
||||||
substitution: &HashMap<FlatVariable, FlatVariable>,
|
substitution: &HashMap<FlatVariable, FlatVariable>,
|
||||||
should_fallback: bool,
|
|
||||||
) -> FlatExpressionList<T> {
|
) -> FlatExpressionList<T> {
|
||||||
FlatExpressionList {
|
FlatExpressionList {
|
||||||
expressions: self
|
expressions: self
|
||||||
.expressions
|
.expressions
|
||||||
.into_iter()
|
.into_iter()
|
||||||
.map(|e| e.apply_substitution(substitution, should_fallback))
|
.map(|e| e.apply_substitution(substitution))
|
||||||
.collect(),
|
.collect(),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn apply_recursive_substitution(
|
|
||||||
self,
|
|
||||||
substitution: &HashMap<FlatVariable, FlatVariable>,
|
|
||||||
) -> FlatExpressionList<T> {
|
|
||||||
self.apply_substitution(substitution, true)
|
|
||||||
}
|
|
||||||
|
|
||||||
pub fn apply_direct_substitution(
|
|
||||||
self,
|
|
||||||
substitution: &HashMap<FlatVariable, FlatVariable>,
|
|
||||||
) -> FlatExpressionList<T> {
|
|
||||||
self.apply_substitution(substitution, false)
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<T: Field> fmt::Debug for FlatExpressionList<T> {
|
impl<T: Field> fmt::Debug for FlatExpressionList<T> {
|
||||||
|
|
File diff suppressed because it is too large
Load diff
|
@ -103,7 +103,7 @@ impl Optimizer {
|
||||||
// filter out synonyms definitions
|
// filter out synonyms definitions
|
||||||
FlatStatement::Definition(_, FlatExpression::Identifier(_)) => None,
|
FlatStatement::Definition(_, FlatExpression::Identifier(_)) => None,
|
||||||
// substitute all other statements
|
// substitute all other statements
|
||||||
_ => Some(statement.apply_direct_substitution(&self.substitution)),
|
_ => Some(statement.apply_substitution(&self.substitution)),
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
.collect();
|
.collect();
|
||||||
|
@ -112,7 +112,7 @@ impl Optimizer {
|
||||||
let optimized_arguments = funct
|
let optimized_arguments = funct
|
||||||
.arguments
|
.arguments
|
||||||
.into_iter()
|
.into_iter()
|
||||||
.map(|arg| arg.apply_direct_substitution(&self.substitution))
|
.map(|arg| arg.apply_substitution(&self.substitution))
|
||||||
.collect();
|
.collect();
|
||||||
|
|
||||||
FlatFunction {
|
FlatFunction {
|
||||||
|
|
20
zokrates_stdlib/Cargo.toml
Normal file
20
zokrates_stdlib/Cargo.toml
Normal file
|
@ -0,0 +1,20 @@
|
||||||
|
[package]
|
||||||
|
name = "zokrates_stdlib"
|
||||||
|
version = "0.1.0"
|
||||||
|
authors = ["schaeff <thibaut@schaeff.fr>"]
|
||||||
|
edition = "2018"
|
||||||
|
|
||||||
|
[features]
|
||||||
|
default = ["libsnark"]
|
||||||
|
libsnark = ["zokrates_core/libsnark"]
|
||||||
|
|
||||||
|
[dev-dependencies]
|
||||||
|
zokrates_field = { version = "0.3", path = "../zokrates_field" }
|
||||||
|
zokrates_core = { version = "0.3", path = "../zokrates_core" }
|
||||||
|
zokrates_fs_resolver = { version = "0.4", path = "../zokrates_fs_resolver" }
|
||||||
|
serde = "1.0"
|
||||||
|
serde_derive = "1.0"
|
||||||
|
serde_json = "1.0"
|
||||||
|
|
||||||
|
[build-dependencies]
|
||||||
|
glob = "0.3.0"
|
37
zokrates_stdlib/build.rs
Normal file
37
zokrates_stdlib/build.rs
Normal file
|
@ -0,0 +1,37 @@
|
||||||
|
use glob::glob;
|
||||||
|
use std::env;
|
||||||
|
use std::fs::File;
|
||||||
|
use std::io::Write;
|
||||||
|
use std::path::{Path, PathBuf};
|
||||||
|
|
||||||
|
fn main() {
|
||||||
|
let out_dir = env::var("OUT_DIR").unwrap();
|
||||||
|
let destination = Path::new(&out_dir).join("tests.rs");
|
||||||
|
let mut test_file = File::create(&destination).unwrap();
|
||||||
|
|
||||||
|
for directory in glob("./tests/bench/**/*.json").unwrap() {
|
||||||
|
write_test(&mut test_file, &directory.unwrap());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
fn write_test(test_file: &mut File, test_path: &PathBuf) {
|
||||||
|
let test_name = format!(
|
||||||
|
"test_{}",
|
||||||
|
test_path
|
||||||
|
.strip_prefix("tests/bench")
|
||||||
|
.unwrap()
|
||||||
|
.display()
|
||||||
|
.to_string()
|
||||||
|
.replace("/", "_")
|
||||||
|
.replace(".json", "")
|
||||||
|
.replace(".", "")
|
||||||
|
);
|
||||||
|
|
||||||
|
write!(
|
||||||
|
test_file,
|
||||||
|
include_str!("./tests/test_template"),
|
||||||
|
test_name = test_name,
|
||||||
|
test_path = test_path.display()
|
||||||
|
)
|
||||||
|
.unwrap();
|
||||||
|
}
|
1
zokrates_stdlib/src/main.rs
Normal file
1
zokrates_stdlib/src/main.rs
Normal file
|
@ -0,0 +1 @@
|
||||||
|
fn main() {}
|
15
zokrates_stdlib/tests/bench/and.json
Normal file
15
zokrates_stdlib/tests/bench/and.json
Normal file
|
@ -0,0 +1,15 @@
|
||||||
|
{
|
||||||
|
"entry_point": "./stdlib/utils/binary/and.code",
|
||||||
|
"tests": [
|
||||||
|
{
|
||||||
|
"input": {
|
||||||
|
"values": ["0", "0"]
|
||||||
|
},
|
||||||
|
"output": {
|
||||||
|
"Ok": {
|
||||||
|
"values": ["0"]
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
15
zokrates_stdlib/tests/bench/hash/512bitPacked.json
Normal file
15
zokrates_stdlib/tests/bench/hash/512bitPacked.json
Normal file
|
@ -0,0 +1,15 @@
|
||||||
|
{
|
||||||
|
"entry_point": "./stdlib/hashes/sha256/512bitPacked.code",
|
||||||
|
"tests": [
|
||||||
|
{
|
||||||
|
"input": {
|
||||||
|
"values": ["0", "0", "0", "5"]
|
||||||
|
},
|
||||||
|
"output": {
|
||||||
|
"Ok": {
|
||||||
|
"values": ["263561599766550617289250058199814760685", "65303172752238645975888084098459749904"]
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
15
zokrates_stdlib/tests/bench/or.json
Normal file
15
zokrates_stdlib/tests/bench/or.json
Normal file
|
@ -0,0 +1,15 @@
|
||||||
|
{
|
||||||
|
"entry_point": "./stdlib/utils/binary/or.code",
|
||||||
|
"tests": [
|
||||||
|
{
|
||||||
|
"input": {
|
||||||
|
"values": ["0", "0"]
|
||||||
|
},
|
||||||
|
"output": {
|
||||||
|
"Ok": {
|
||||||
|
"values": ["0"]
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
7
zokrates_stdlib/tests/integration.rs
Normal file
7
zokrates_stdlib/tests/integration.rs
Normal file
|
@ -0,0 +1,7 @@
|
||||||
|
#[macro_use]
|
||||||
|
extern crate serde_derive;
|
||||||
|
|
||||||
|
#[macro_use]
|
||||||
|
mod utils;
|
||||||
|
|
||||||
|
include!(concat!(env!("OUT_DIR"), "/tests.rs"));
|
44
zokrates_stdlib/tests/test_template
Normal file
44
zokrates_stdlib/tests/test_template
Normal file
|
@ -0,0 +1,44 @@
|
||||||
|
#[test]
|
||||||
|
#[ignore]
|
||||||
|
#[allow(non_snake_case)]
|
||||||
|
fn {test_name}() {{
|
||||||
|
use zokrates_field::field::{{Field, FieldPrime}};
|
||||||
|
use std::path::PathBuf;
|
||||||
|
use zokrates_fs_resolver::resolve;
|
||||||
|
use zokrates_core::compile::compile;
|
||||||
|
use std::fs::File;
|
||||||
|
use std::io::{{BufReader, Read}};
|
||||||
|
|
||||||
|
let t: utils::Tests = serde_json::from_reader(
|
||||||
|
BufReader::new(
|
||||||
|
File::open(
|
||||||
|
&PathBuf::from("{test_path}")
|
||||||
|
).unwrap()
|
||||||
|
)
|
||||||
|
).unwrap();
|
||||||
|
|
||||||
|
let mut code_reader = BufReader::new(File::open(&t.entry_point).unwrap());
|
||||||
|
|
||||||
|
let bin = compile(
|
||||||
|
&mut code_reader,
|
||||||
|
Some(t.entry_point.parent().unwrap().to_str().unwrap().to_string()),
|
||||||
|
Some(resolve)
|
||||||
|
).unwrap();
|
||||||
|
|
||||||
|
for test in t.tests.into_iter() {{
|
||||||
|
let input = &test.input.values;
|
||||||
|
let output = bin.execute(&input.iter().map(|v| FieldPrime::from_dec_string(v.clone())).collect());
|
||||||
|
|
||||||
|
match utils::compare(output, test.output) {{
|
||||||
|
Err(e) => {{
|
||||||
|
let mut code = File::open(&t.entry_point).unwrap();
|
||||||
|
let mut s = String::new();
|
||||||
|
code.read_to_string(&mut s).unwrap();
|
||||||
|
let context = format!("\n{{}}\nCalled with input ({{}})\n", s, input.iter().map(|i| format!("{{}}", i)).collect::<Vec<_>>().join(", "));
|
||||||
|
panic!("{{}}{{}}", context, e)
|
||||||
|
}},
|
||||||
|
Ok(..) => {{}}
|
||||||
|
}};
|
||||||
|
}}
|
||||||
|
}}
|
||||||
|
|
68
zokrates_stdlib/tests/utils/mod.rs
Normal file
68
zokrates_stdlib/tests/utils/mod.rs
Normal file
|
@ -0,0 +1,68 @@
|
||||||
|
use std::path::PathBuf;
|
||||||
|
use zokrates_core::ir;
|
||||||
|
use zokrates_field::field::{Field, FieldPrime};
|
||||||
|
|
||||||
|
#[derive(Serialize, Deserialize)]
|
||||||
|
pub struct Tests {
|
||||||
|
pub entry_point: PathBuf,
|
||||||
|
pub tests: Vec<Test>,
|
||||||
|
}
|
||||||
|
|
||||||
|
#[derive(Serialize, Deserialize)]
|
||||||
|
pub struct Input {
|
||||||
|
pub values: Vec<Val>,
|
||||||
|
}
|
||||||
|
|
||||||
|
#[derive(Serialize, Deserialize)]
|
||||||
|
pub struct Test {
|
||||||
|
pub input: Input,
|
||||||
|
pub output: TestResult,
|
||||||
|
}
|
||||||
|
|
||||||
|
pub type TestResult = Result<Output, ir::Error>;
|
||||||
|
|
||||||
|
#[derive(PartialEq, Debug)]
|
||||||
|
pub struct ComparableResult(Result<Vec<FieldPrime>, ir::Error>);
|
||||||
|
|
||||||
|
#[derive(Serialize, Deserialize)]
|
||||||
|
pub struct Output {
|
||||||
|
values: Vec<Val>,
|
||||||
|
}
|
||||||
|
|
||||||
|
type Val = String;
|
||||||
|
|
||||||
|
impl From<ir::ExecutionResult<FieldPrime>> for ComparableResult {
|
||||||
|
fn from(r: ir::ExecutionResult<FieldPrime>) -> ComparableResult {
|
||||||
|
ComparableResult(r.map(|v| v.return_values().iter().map(|&x| x.clone()).collect()))
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
impl From<TestResult> for ComparableResult {
|
||||||
|
fn from(r: TestResult) -> ComparableResult {
|
||||||
|
ComparableResult(r.map(|v| {
|
||||||
|
v.values
|
||||||
|
.into_iter()
|
||||||
|
.map(|v| FieldPrime::from_dec_string(v))
|
||||||
|
.collect()
|
||||||
|
}))
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
pub fn compare(
|
||||||
|
result: ir::ExecutionResult<FieldPrime>,
|
||||||
|
expected: TestResult,
|
||||||
|
) -> Result<(), String> {
|
||||||
|
// extract outputs from result
|
||||||
|
let result = ComparableResult::from(result);
|
||||||
|
// deserialize expected result
|
||||||
|
let expected = ComparableResult::from(expected);
|
||||||
|
|
||||||
|
if result != expected {
|
||||||
|
return Err(format!(
|
||||||
|
"Expected {:?} but found {:?}",
|
||||||
|
expected.0, result.0
|
||||||
|
));
|
||||||
|
}
|
||||||
|
|
||||||
|
Ok(())
|
||||||
|
}
|
Loading…
Reference in a new issue