1
0
Fork 0
mirror of synced 2025-09-23 12:18:44 +00:00

fix conflict

This commit is contained in:
schaeff 2020-11-23 14:47:00 +00:00
commit 4bbde1f02e
34 changed files with 844 additions and 361 deletions

434
Cargo.lock generated
View file

@ -24,38 +24,6 @@ dependencies = [
"memchr",
]
[[package]]
name = "algebra"
version = "0.1.1-alpha.0"
source = "git+https://github.com/scipr-lab/zexe.git#f4296dfae5ea56202cdc2343090aa83b1d37263f"
dependencies = [
"algebra-core",
]
[[package]]
name = "algebra-core"
version = "0.1.1-alpha.0"
source = "git+https://github.com/scipr-lab/zexe.git#f4296dfae5ea56202cdc2343090aa83b1d37263f"
dependencies = [
"algebra-core-derive",
"derivative",
"field-assembly",
"num-traits 0.2.14",
"rand 0.7.3",
"rustc_version",
"unroll",
]
[[package]]
name = "algebra-core-derive"
version = "0.1.1-alpha.0"
source = "git+https://github.com/scipr-lab/zexe.git#f4296dfae5ea56202cdc2343090aa83b1d37263f"
dependencies = [
"proc-macro2 1.0.24",
"quote 1.0.7",
"syn 1.0.48",
]
[[package]]
name = "ansi_term"
version = "0.11.0"
@ -65,6 +33,163 @@ dependencies = [
"winapi",
]
[[package]]
name = "ark-bls12-377"
version = "0.1.0"
source = "git+https://github.com/arkworks-rs/curves#23e87bf224c23be5c5bccc6084aae31fff8bb83f"
dependencies = [
"ark-ec",
"ark-ff",
"ark-std",
]
[[package]]
name = "ark-bn254"
version = "0.1.0"
source = "git+https://github.com/arkworks-rs/curves#23e87bf224c23be5c5bccc6084aae31fff8bb83f"
dependencies = [
"ark-ec",
"ark-ff",
"ark-std",
]
[[package]]
name = "ark-bw6-761"
version = "0.1.0"
source = "git+https://github.com/arkworks-rs/curves#23e87bf224c23be5c5bccc6084aae31fff8bb83f"
dependencies = [
"ark-bls12-377",
"ark-ec",
"ark-ff",
"ark-std",
]
[[package]]
name = "ark-crypto-primitives"
version = "0.1.0"
source = "git+https://github.com/arkworks-rs/crypto-primitives.git?branch=main#ce5cc89011b394eb006987a24088947d5099d641"
dependencies = [
"ark-ec",
"ark-ff",
"ark-relations",
"ark-snark",
"ark-std",
"bench-utils",
"blake2",
"derivative",
"digest",
"rand 0.7.3",
]
[[package]]
name = "ark-ec"
version = "0.1.0"
source = "git+https://github.com/arkworks-rs/algebra#902c8c2882a8aa6f87395df888b50090e2705cac"
dependencies = [
"ark-ff",
"ark-serialize",
"ark-std",
"derivative",
"num-traits 0.2.14",
"rand 0.7.3",
]
[[package]]
name = "ark-ff"
version = "0.1.0"
source = "git+https://github.com/arkworks-rs/algebra#902c8c2882a8aa6f87395df888b50090e2705cac"
dependencies = [
"ark-ff-asm",
"ark-serialize",
"ark-std",
"derivative",
"num-traits 0.2.14",
"rand 0.7.3",
"rustc_version",
]
[[package]]
name = "ark-ff-asm"
version = "0.1.0"
source = "git+https://github.com/arkworks-rs/algebra#902c8c2882a8aa6f87395df888b50090e2705cac"
dependencies = [
"quote 1.0.7",
"syn 1.0.50",
]
[[package]]
name = "ark-gm17"
version = "0.1.0"
source = "git+https://github.com/arkworks-rs/gm17#4382f9103a18c50cc84dc673740286a7604a2ae5"
dependencies = [
"ark-crypto-primitives",
"ark-ec",
"ark-ff",
"ark-poly",
"ark-relations",
"ark-serialize",
"ark-std",
"bench-utils",
"rand 0.7.3",
]
[[package]]
name = "ark-poly"
version = "0.1.0"
source = "git+https://github.com/arkworks-rs/algebra#902c8c2882a8aa6f87395df888b50090e2705cac"
dependencies = [
"ark-ff",
"ark-serialize",
"ark-std",
"derivative",
"rand 0.7.3",
]
[[package]]
name = "ark-relations"
version = "0.1.0"
source = "git+https://github.com/arkworks-rs/snark#f074e77ab35489da12f2f6cb97d24b7d992b8a35"
dependencies = [
"ark-ff",
"ark-std",
"tracing",
]
[[package]]
name = "ark-serialize"
version = "0.1.0"
source = "git+https://github.com/arkworks-rs/algebra#902c8c2882a8aa6f87395df888b50090e2705cac"
dependencies = [
"ark-serialize-derive",
"ark-std",
]
[[package]]
name = "ark-serialize-derive"
version = "0.1.1-alpha.0"
source = "git+https://github.com/arkworks-rs/algebra#902c8c2882a8aa6f87395df888b50090e2705cac"
dependencies = [
"proc-macro2 1.0.24",
"quote 1.0.7",
"syn 1.0.50",
]
[[package]]
name = "ark-snark"
version = "0.1.0"
source = "git+https://github.com/arkworks-rs/snark#f074e77ab35489da12f2f6cb97d24b7d992b8a35"
dependencies = [
"ark-ff",
"ark-relations",
"ark-std",
"rand 0.7.3",
]
[[package]]
name = "ark-std"
version = "0.1.0"
source = "git+https://github.com/arkworks-rs/utils#0825eeafe7a3fb54be5ca9b90b02b6057adca964"
[[package]]
name = "arrayref"
version = "0.3.6"
@ -110,9 +235,9 @@ checksum = "cdb031dd78e28731d87d56cc8ffef4a8f36ca26c38fe2de700543e627f8a464a"
[[package]]
name = "backtrace"
version = "0.3.54"
version = "0.3.55"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "2baad346b2d4e94a24347adeee9c7a93f412ee94b9cc26e5b59dea23848e9f28"
checksum = "ef5140344c85b01f9bbb4d4b7288a8aa4b3287ccef913a14bcc78a1063623598"
dependencies = [
"addr2line",
"cfg-if 1.0.0",
@ -148,7 +273,7 @@ dependencies = [
[[package]]
name = "bench-utils"
version = "0.1.1-alpha.0"
source = "git+https://github.com/scipr-lab/zexe.git#f4296dfae5ea56202cdc2343090aa83b1d37263f"
source = "git+https://github.com/arkworks-rs/utils#0825eeafe7a3fb54be5ca9b90b02b6057adca964"
[[package]]
name = "bincode"
@ -173,6 +298,18 @@ version = "1.2.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "cf1de2fe8c75bc145a2f577add951f8134889b4795d47466a54a5c846d691693"
[[package]]
name = "blake2"
version = "0.8.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "94cb07b0da6a73955f8fb85d24c466778e70cda767a568229b104f0264089330"
dependencies = [
"byte-tools",
"crypto-mac",
"digest",
"opaque-debug",
]
[[package]]
name = "blake2b_simd"
version = "0.5.11"
@ -231,9 +368,9 @@ checksum = "e3b5ca7a04898ad4bcd41c90c5285445ff5b791899bb1b0abdd2a2aa791211d7"
[[package]]
name = "bytecount"
version = "0.6.0"
version = "0.6.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "b0017894339f586ccb943b01b9555de56770c11cda818e7e3d8bd93f4ed7f46e"
checksum = "c39a773ba75db12126d8d383f1bdbf7eb92ea47ec27dd0557aff1fedf172764c"
[[package]]
name = "byteorder"
@ -247,7 +384,7 @@ version = "0.10.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "b8de60b887edf6d74370fc8eb177040da4847d971d6234c7b13a6da324ef0caf"
dependencies = [
"semver",
"semver 0.9.0",
"serde",
"serde_derive",
"serde_json",
@ -255,9 +392,9 @@ dependencies = [
[[package]]
name = "cc"
version = "1.0.62"
version = "1.0.65"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "f1770ced377336a88a67c473594ccc14eca6f4559217c34f64aac8f83d641b40"
checksum = "95752358c8f7552394baf48cd82695b345628ad3f170d607de3ca03b8dacca15"
dependencies = [
"jobserver",
]
@ -291,9 +428,9 @@ dependencies = [
[[package]]
name = "cmake"
version = "0.1.44"
version = "0.1.45"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "0e56268c17a6248366d66d4a47a3381369d068cce8409bb1716ed77ea32163bb"
checksum = "eb6210b637171dfba4cda12e579ac6dc73f5165ad56133e5d72ef3131f320855"
dependencies = [
"cc",
]
@ -397,6 +534,16 @@ dependencies = [
"lazy_static",
]
[[package]]
name = "crypto-mac"
version = "0.7.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "4434400df11d95d556bac068ddfedd482915eb18fe8bea89bc80b6e4b1c179e5"
dependencies = [
"generic-array",
"subtle",
]
[[package]]
name = "csv"
version = "1.1.4"
@ -426,7 +573,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "7fbaabec2c953050352311293be5c6aba8e141ba19d6811862b232d6fd020484"
dependencies = [
"quote 1.0.7",
"syn 1.0.48",
"syn 1.0.50",
]
[[package]]
@ -437,7 +584,7 @@ checksum = "cb582b60359da160a9477ee80f15c8d784c477e69c217ef2cdd4169c24ea380f"
dependencies = [
"proc-macro2 1.0.24",
"quote 1.0.7",
"syn 1.0.48",
"syn 1.0.50",
]
[[package]]
@ -529,7 +676,7 @@ checksum = "aa4da3c766cd7a0db8242e326e9e4e081edd567072893ed320008189715366a4"
dependencies = [
"proc-macro2 1.0.24",
"quote 1.0.7",
"syn 1.0.48",
"syn 1.0.50",
"synstructure",
]
@ -539,15 +686,6 @@ version = "0.1.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "e88a8acf291dafb59c2d96e8f59828f3838bb1a70398823ade51a84de6a6deed"
[[package]]
name = "ff-fft"
version = "0.1.1-alpha.0"
source = "git+https://github.com/scipr-lab/zexe.git#f4296dfae5ea56202cdc2343090aa83b1d37263f"
dependencies = [
"algebra-core",
"rand 0.7.3",
]
[[package]]
name = "ff_ce"
version = "0.9.0"
@ -582,15 +720,7 @@ dependencies = [
"num-traits 0.2.14",
"proc-macro2 1.0.24",
"quote 1.0.7",
"syn 1.0.48",
]
[[package]]
name = "field-assembly"
version = "0.1.1-alpha.0"
source = "git+https://github.com/scipr-lab/zexe.git#f4296dfae5ea56202cdc2343090aa83b1d37263f"
dependencies = [
"mince",
"syn 1.0.50",
]
[[package]]
@ -759,18 +889,6 @@ version = "0.3.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "9b919933a397b79c37e33b77bb2aa3dc8eb6e165ad809e58ff75bc7db2e34574"
[[package]]
name = "gm17"
version = "0.1.1-alpha.0"
source = "git+https://github.com/scipr-lab/zexe.git#f4296dfae5ea56202cdc2343090aa83b1d37263f"
dependencies = [
"algebra-core",
"bench-utils",
"ff-fft",
"r1cs-core",
"rand 0.7.3",
]
[[package]]
name = "hermit-abi"
version = "0.1.17"
@ -858,9 +976,9 @@ dependencies = [
[[package]]
name = "libssh2-sys"
version = "0.2.19"
version = "0.2.20"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "ca46220853ba1c512fc82826d0834d87b06bcd3c2a42241b7de72f3d2fe17056"
checksum = "df40b13fe7ea1be9b9dffa365a51273816c345fc1811478b57ed7d964fbfc4ce"
dependencies = [
"cc",
"libc",
@ -924,15 +1042,6 @@ dependencies = [
"autocfg",
]
[[package]]
name = "mince"
version = "0.1.1-alpha.0"
source = "git+https://github.com/scipr-lab/zexe.git#f4296dfae5ea56202cdc2343090aa83b1d37263f"
dependencies = [
"quote 1.0.7",
"syn 1.0.48",
]
[[package]]
name = "miniz_oxide"
version = "0.4.3"
@ -1023,9 +1132,9 @@ checksum = "8d3b63360ec3cb337817c2dbd47ab4a0f170d285d8e5a2064600f3def1402397"
[[package]]
name = "once_cell"
version = "1.5.1"
version = "1.5.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "f53cef67919d7d247eb9a2f128ca9e522789967ef1eb4ccd8c71a95a8aedf596"
checksum = "13bd41f508810a131401606d54ac32a467c97172d74ba7662562ebba5ad07fa0"
[[package]]
name = "opaque-debug"
@ -1120,7 +1229,7 @@ dependencies = [
"pest_meta",
"proc-macro2 1.0.24",
"quote 1.0.7",
"syn 1.0.48",
"syn 1.0.50",
]
[[package]]
@ -1136,24 +1245,30 @@ dependencies = [
[[package]]
name = "pin-project"
version = "1.0.1"
version = "1.0.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "ee41d838744f60d959d7074e3afb6b35c7456d0f61cad38a24e35e6553f73841"
checksum = "9ccc2237c2c489783abd8c4c80e5450fc0e98644555b1364da68cc29aa151ca7"
dependencies = [
"pin-project-internal",
]
[[package]]
name = "pin-project-internal"
version = "1.0.1"
version = "1.0.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "81a4ffa594b66bff340084d4081df649a7dc049ac8d7fc458d8e628bfbbb2f86"
checksum = "f8e8d2bf0b23038a4424865103a4df472855692821aab4e4f5c3312d461d9e5f"
dependencies = [
"proc-macro2 1.0.24",
"quote 1.0.7",
"syn 1.0.48",
"syn 1.0.50",
]
[[package]]
name = "pin-project-lite"
version = "0.1.11"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "c917123afa01924fc84bb20c4c03f004d9c38e5127e3c039bbf7f4b9c76a2f6b"
[[package]]
name = "pin-utils"
version = "0.1.0"
@ -1229,14 +1344,6 @@ dependencies = [
"proc-macro2 1.0.24",
]
[[package]]
name = "r1cs-core"
version = "0.1.1-alpha.0"
source = "git+https://github.com/scipr-lab/zexe.git#f4296dfae5ea56202cdc2343090aa83b1d37263f"
dependencies = [
"algebra-core",
]
[[package]]
name = "rand"
version = "0.4.6"
@ -1398,11 +1505,11 @@ checksum = "6e3bad0ee36814ca07d7968269dd4b7ec89ec2da10c4bb613928d3077083c232"
[[package]]
name = "rustc_version"
version = "0.2.3"
version = "0.3.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "138e3e0acb6c9fb258b19b67cb8abd63c00679d2851805ea151465464fe9030a"
checksum = "65c94201b44764d6d1f7e37c15a8289ed55e546c1762c7f1d57f616966e0c181"
dependencies = [
"semver",
"semver 0.11.0",
]
[[package]]
@ -1438,31 +1545,40 @@ version = "0.9.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "1d7eb9ef2c18661902cc47e535f9bc51b78acd254da71d375c2f6720d9a40403"
dependencies = [
"semver-parser",
"semver-parser 0.7.0",
"serde",
]
[[package]]
name = "semver"
version = "0.11.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "f301af10236f6df4160f7c3f04eec6dbc70ace82d23326abad5edee88801c6b6"
dependencies = [
"semver-parser 0.10.1",
]
[[package]]
name = "semver-parser"
version = "0.7.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "388a1df253eca08550bef6c72392cfe7c30914bf41df5269b68cbd6ff8f570a3"
[[package]]
name = "semver-parser"
version = "0.10.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "42ef146c2ad5e5f4b037cd6ce2ebb775401729b19a82040c1beac9d36c7d1428"
dependencies = [
"pest",
]
[[package]]
name = "serde"
version = "1.0.117"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "b88fa983de7720629c9387e9f517353ed404164b1e482c970a90c1a4aaf7dc1a"
[[package]]
name = "serde_bytes"
version = "0.10.5"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "defbb8a83d7f34cc8380751eeb892b825944222888aff18996ea7901f24aec88"
dependencies = [
"serde",
]
[[package]]
name = "serde_derive"
version = "1.0.117"
@ -1471,7 +1587,7 @@ checksum = "cbd1ae72adb44aab48f325a02444a5fc079349a8d804c1fc922aed3f7454c74e"
dependencies = [
"proc-macro2 1.0.24",
"quote 1.0.7",
"syn 1.0.48",
"syn 1.0.50",
]
[[package]]
@ -1545,6 +1661,12 @@ version = "0.8.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "8ea5119cdb4c55b55d432abb513a0429384878c15dde60cc77b1c99de1a95a6a"
[[package]]
name = "subtle"
version = "1.0.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "2d67a5a62ba6e01cb2192ff309324cb4875d0c451d55fe2319433abe7a05a8ee"
[[package]]
name = "syn"
version = "0.15.44"
@ -1558,9 +1680,9 @@ dependencies = [
[[package]]
name = "syn"
version = "1.0.48"
version = "1.0.50"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "cc371affeffc477f42a221a1e4297aedcea33d47d19b61455588bd9d8f6b19ac"
checksum = "443b4178719c5a851e1bde36ce12da21d74a0e60b4d982ec3385a933c812f0f6"
dependencies = [
"proc-macro2 1.0.24",
"quote 1.0.7",
@ -1575,7 +1697,7 @@ checksum = "b834f2d66f734cb897113e34aaff2f1ab4719ca946f9a7358dba8f8064148701"
dependencies = [
"proc-macro2 1.0.24",
"quote 1.0.7",
"syn 1.0.48",
"syn 1.0.50",
"unicode-xid 0.2.1",
]
@ -1623,9 +1745,9 @@ dependencies = [
[[package]]
name = "tinyvec"
version = "1.0.1"
version = "1.1.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "b78a366903f506d2ad52ca8dc552102ffdd3e937ba8a227f024dc1d1eae28575"
checksum = "ccf8dbc19eb42fba10e8feaaec282fb50e2c14b2726d6301dbfeed0f73306a6f"
dependencies = [
"tinyvec_macros",
]
@ -1636,6 +1758,23 @@ version = "0.1.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "cda74da7e1a664f795bb1f8a87ec406fb89a02522cf6e50620d016add6dbbf5c"
[[package]]
name = "tracing"
version = "0.1.21"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "b0987850db3733619253fe60e17cb59b82d37c7e6c0236bb81e4d6b87c879f27"
dependencies = [
"cfg-if 0.1.10",
"pin-project-lite",
"tracing-core",
]
[[package]]
name = "tracing-core"
version = "0.1.17"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "f50de3927f93d202783f4513cda820ab47ef17f624b03c096e86ef00c67e6b5f"
[[package]]
name = "typed-arena"
version = "1.7.0"
@ -1671,9 +1810,9 @@ dependencies = [
[[package]]
name = "unicode-normalization"
version = "0.1.14"
version = "0.1.16"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "b7f98e67a4d84f730d343392f9bfff7d21e3fca562b9cb7a43b768350beeddc6"
checksum = "a13e63ab62dbe32aeee58d1c5408d35c36c392bba5d9d3142287219721afe606"
dependencies = [
"tinyvec",
]
@ -1696,16 +1835,6 @@ version = "0.2.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "f7fe0bb3479651439c9112f72b6c505038574c9fbb575ed1bf3b797fa39dd564"
[[package]]
name = "unroll"
version = "0.1.4"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "85890b49d9724df33edc575c4bacd5b0081977da22c4c4984d0c62ec44ed6e09"
dependencies = [
"quote 0.6.13",
"syn 0.15.44",
]
[[package]]
name = "url"
version = "2.2.0"
@ -1786,7 +1915,7 @@ dependencies = [
"log",
"proc-macro2 1.0.24",
"quote 1.0.7",
"syn 1.0.48",
"syn 1.0.50",
"wasm-bindgen-shared",
]
@ -1820,7 +1949,7 @@ checksum = "f249f06ef7ee334cc3b8ff031bfc11ec99d00f34d86da7498396dc1e3b1498fe"
dependencies = [
"proc-macro2 1.0.24",
"quote 1.0.7",
"syn 1.0.48",
"syn 1.0.50",
"wasm-bindgen-backend",
"wasm-bindgen-shared",
]
@ -1934,9 +2063,14 @@ version = "0.1.0"
name = "zokrates_core"
version = "0.5.2"
dependencies = [
"algebra",
"algebra-core",
"assert_cli",
"ark-bls12-377",
"ark-bn254",
"ark-bw6-761",
"ark-ec",
"ark-ff",
"ark-gm17",
"ark-relations",
"ark-serialize",
"bellman_ce",
"bincode",
"cc",
@ -1945,21 +2079,17 @@ dependencies = [
"csv",
"ff_ce 0.9.0",
"git2",
"glob 0.2.11",
"gm17",
"hex",
"lazy_static",
"num",
"num-bigint",
"pairing_ce",
"pretty_assertions",
"r1cs-core",
"rand 0.4.6",
"rand 0.7.3",
"reduce",
"regex",
"serde",
"serde_bytes",
"serde_derive",
"serde_json",
"typed-arena",
@ -1973,16 +2103,19 @@ dependencies = [
name = "zokrates_core_test"
version = "0.1.3"
dependencies = [
"fs_extra",
"zokrates_test",
"zokrates_test_derive",
]
[[package]]
name = "zokrates_field"
version = "0.3.7"
dependencies = [
"algebra",
"algebra-core",
"ark-bls12-377",
"ark-bn254",
"ark-bw6-761",
"ark-ec",
"ark-ff",
"bellman_ce",
"bincode",
"lazy_static",
@ -2022,7 +2155,6 @@ dependencies = [
"lazy_static",
"pest",
"pest-ast",
"zokrates_field",
"zokrates_parser",
]
@ -2032,14 +2164,13 @@ version = "0.1.7"
dependencies = [
"fs_extra",
"zokrates_test",
"zokrates_test_derive",
]
[[package]]
name = "zokrates_test"
version = "0.1.4"
dependencies = [
"fs_extra",
"glob 0.3.0",
"serde",
"serde_derive",
"serde_json",
@ -2047,3 +2178,10 @@ dependencies = [
"zokrates_field",
"zokrates_fs_resolver",
]
[[package]]
name = "zokrates_test_derive"
version = "0.0.1"
dependencies = [
"glob 0.3.0",
]

View file

@ -318,12 +318,14 @@ main() {
rm -rf $td
cat <<'EOF'
abspath=$(cd "$(dirname "$dest")" && pwd)/$(basename "$dest")
cat <<EOF
ZoKrates was installed successfully!
If this is the first time you're installing ZoKrates run the following:
export PATH=$PATH:$HOME/.zokrates/bin
export PATH=\$PATH:$abspath/bin
EOF
}
main
main "$@" || exit 1

View file

@ -23,6 +23,6 @@
- [JSON ABI](toolbox/abi.md)
- [zokrates.js](toolbox/zokrates_js.md)
- [Tutorial: Proof of preimage](sha256example.md)
- [Tutorial: A zkSNARK RNG](rng_tutorial.md)
- [Testing](testing.md)

View file

@ -0,0 +1,325 @@
# Tutorial: A SNARK Powered RNG
## Prerequisites
Make sure you have followed the instructions in the [Getting Started](gettingstarted.md) chapter and are able to run the "Hello World" example described there.
## Description of the problem
Alice and Bob want to bet on the result of a series of coin tosses. To do so, they need to generate a series of random bits. They proceed as follows:
1. Each of them commits to a 512 bit value. Lets call this value the ***preimage***. They publish the hash of the preimage.
2. Each time they need a new random value, they reveal one bit from their preimage, and agree that the new random value is the result of XORing these
two bits, so that neither of them can control the output.
Note that we are making a few assumptions here:
1. They make sure they do not use all 512 bits of their preimage, as the more they reveal, the easier it gets for the other to brute-force their preimage.
2. They need a way to be convinced that the bit the other revealed is indeed part of their preimage.
In this tutorial you learn how to use Zokrates and zero knowledge proofs to reveal a single bit from the preimage of a hash value.
## Commit to a preimage
The first step is for Alice and Bob to each come up with a preimage value and calculate the hash to commit to it.
There are many ways to calculate a hash, but here we use Zokrates.
1. Create this file under the name `get_hash.zok`:
```javascript
import "hashes/sha256/512bit" as sha256
def main(u32[16] hashMe) -> u32[8]:
u32[8] h = sha256(hashMe[0..8], hashMe[8..16])
return h
```
2. Compile the program to a form that is usable for zero knowledge proofs. This command writes
the binary to `get_hash`. You can see a textual representation, somewhat analogous to assembler
coming from a compiler, at `get_hash.ztf` if you remove the `--light` command line option.
```
zokrates compile -i get_hash.zok -o get_hash --light
```
3. The input to the Zokrates program is sixteen 32 bit values, each in decimal. specify those values
to get a hash. For example, to calculate the hash of `0x00000000000000010000000200000003000000040000000500000006...`
use this command:
```
zokrates compute-witness --light -i get_hash -a 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15
```
The result is:
```
Computing witness...
Witness:
["3592665057","2164530888","1223339564","3041196771","2006723467","2963045520","3851824201","3453903005"]
```
Pick your own value and store it somewhere.
### Detailed explanation
This line imports a Zokrates function from the [standard library](https://github.com/Zokrates/ZoKrates/tree/master/zokrates_stdlib/stdlib).
You can see the specific function we are importing
[here](https://github.com/Zokrates/ZoKrates/blob/master/zokrates_stdlib/stdlib/hashes/sha256/512bit.zok). It will be
called `sha256`.
```javascript
import "hashes/sha256/512bit" as sha256
```
&nbsp;
This is the main function. The input (`u32[16]`) is an array of sixteen values, each an unsigned 32-bit integer (a number
between \\(0\\) and \\( 2^{32} - 1 \\)). As you have seen above, you specify these numbers using the `-a` command
line parameter. The total number of input bits is *32 &times; 16 = 512*.
The output is `u32[8]`, a *32 &times; 8 = 256* bit value.
```javascript
def main(u32[16] hashMe) -> u32[8]:
```
&nbsp;
This line does several things. First, `u32[8] h` defines a variable called `h`, whose type is an array of eight 32-bit unsigned integers.
This variable is initialized using `sha256`, the function we
[imported from the standard library](https://github.com/Zokrates/ZoKrates/blob/master/zokrates_stdlib/stdlib/hashes/sha256/512bit.zok).
The `sha256` function expects to get two arrays of eight values each, so we use a [slice `..`](https://zokrates.github.io/language/types.html#slices)
to divide `hashMe` into two arrays.
```javascript
u32[8] h = sha256(hashMe[0..8], hashMe[8..16])
```
&nbsp;
Finally, return `h` to the caller to display the hash.
```javascript
return h
```
## Reveal a single bit
The next step is to reveal a single bit.
1. Use this program, `reveal_bit.zok`:
```javascript
import "hashes/sha256/512bit" as sha256
import "utils/casts/u32_to_bits" as u32_to_bits
// Reveal a bit from a 512 bit value, and return it with the corresponding hash
// for that value.
//
// WARNING, once enough bits have been revealed it is possible to brute force
// the remaining preimage bits.
def main(private u32[16] preimage, field bitNum) -> (u32[8], bool):
// Convert the preimage to bits
bool[512] preimageBits = [false; 512]
for field i in 0..16 do
bool[32] val = u32_to_bits(preimage[i])
for field bit in 0..32 do
preimageBits[i*32+bit] = val[bit]
endfor
endfor
return sha256(preimage[0..8], preimage[8..16]), preimageBits[bitNum]
```
2. Compile and run as you did the previous program:
```bash
zokrates compile -i reveal_bit.zok -o reveal_bit --light
zokrates compute-witness --light -i reveal_bit -a 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 510
```
3. The output should be similar to:
```
Witness:
["3592665057","2164530888","1223339564","3041196771","2006723467","2963045520","3851824201","3453903005","1"]
```
### Detailed explanation
This line imports a function that converts a `u32` value to an array of 32 booleans.
There are cast functions to convert `u8`s, `u16`s, and `u32`s to boolean arrays and back again,
[you can see them here](https://github.com/Zokrates/ZoKrates/blob/master/zokrates_stdlib/stdlib/utils/casts).
```javascript
import "utils/casts/u32_to_bits" as u32_to_bits
```
&nbsp;
The preimage is declared `private` so it won't be revealed by the zero knowledge proof.
A Zokrates function can return multiple values. In this case, it returns the hash and a boolean which is the
value of the bit being revealed.
```javascript
def main(private u32[16] preimage, field bitNum) -> (u32[8], bool):
```
&nbsp;
To find the value of the bit being revealed, we convert the entire preimage into bits and access it at the index `bitNum`.
The first line defines an array of 512 boolean values (`bool[512]`) called `preimageBits`. It is initialized to
an array of 512 `false` values. The syntax `[<value>; <number>]` initializes the an array of `<number>`
copies of `<value>`. It is necessary to include it here because a Zokrates variable must be initialized
when it is declared.
```javascript
// Convert the secret to bits
bool[512] preimageBits = [false; 512]
```
&nbsp;
This is a [for loop](https://zokrates.github.io/language/control_flow.html#for-loops). For loops
have to have an index of type `field`, and their bounds need to be known at compile time.
In this case, we go over each of the sixteen 32 bit words.
```javascript
for field i in 0..16 do
```
The function we imported, `u32_to_bits`, converts a `u32` value to an array of bits.
```javascript
bool[32] val = u32_to_bits(preimage[i])
```
&nbsp;
The inner loop copies the bits from `val` to `preimageBits`, the bit array for the preimage.
```javascript
for field bit in 0..32 do
preimageBits[i*32+bit] = val[bit]
endfor
endfor
```
&nbsp;
To return multiple values, separate them by commas.
```javascript
return sha256(preimage[0..8], preimage[8..16]), preimageBits[bitNum]
```
## Actually using zero knowledge proofs
The `reveal_bit.zok`program reveals a bit from the preimage, but who runs it?
1. If Alice runs the program, she can feed it her secret preimage and receive the correct result. However, when she sends the output there is no reason
for Bob to trust that she is providing the correct output.
2. If Bob runs the program, he does not have Alice's secret preimage. If Alice discloses her secret preimage, Bob can know the value of all the bits.
Therefore, we need to have Alice run the program and produce the output, but produce it in such a way Bob will know it is the correct output. This is what Zero Knowledge
Proofs give us.
### Set up the environment
1. Create two separate directories, `alice` and `bob`. You will perform the actions of Alice in the `alice` directory,
and the actions of Bob in the `bob` directory.
### Bob's setup stage
2. Compile `reveal_bit.zok` and create the proving and verification keys.
```
zokrates compile -i reveal_bit.zok -o reveal_bit --light
zokrates setup -i reveal_bit --light
```
3. Copy the file `proving.key` to Alice's directory.
### Alice reveals a bit
4. Alice should compile `reveal_bit.zok` independently to make sure it doesn't disclose information she wants to keep secret.
```
zokrates compile -i reveal_bit.zok -o reveal_bit --light
```
5. Next, Alice creates the `witness` file with the values of all the parameters in the program. Using this `witness`,
Bob's `proving.key`, and the compiled program she generates the actual proof.
```
zokrates compute-witness -i reveal_bit -a 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 510 --light
zokrates generate-proof -i reveal_bit
```
6. The proof is created in the file `proof.json`. Copy this file to Bob's directory.
### Bob accepts the proof
7. Finally, Bob verifies the proof:
```
zokrates verify
```
8. As a sanity check, modify any of the values in `proof.json` and see that the verification fails.
## Connecting to Ethereum
So far, Alice and Bob calculated the random bit between themselves. However, it is often useful to have the values
published on the blockchain. To do this, Bob creates a Solidity program:
```
zokrates export-verifier
```
The Solidity program is called `verifier.sol`.
Here are the instructions to use this program when using [Truffle and Ganache](https://www.trufflesuite.com/).
We'll assume they are installed, and the Ganache blockchain is running.
1. Create a new project with `truffle init` and copy `verify.sol` to the subdirectory `contracts`.
1. Identify the version of Solidity used by `verifier.sol`:
```
grep solidity contracts/verifier.sol
```
1. Edit `truffle-config.js`:
* Change `module.exports.compilers.solc.version` to the version required by `verifier.sol`.
* Uncomment `modules.exports.networks.development`. Make sure you delete the comma after the definition.
1. Compile the contract.
```
truffle compile
```
1. Start the Truffle console. The rest of this procedure is done in the JavaScript prompt inside that console.
```
truffle console
```
1. Deploy the Verifier contract.
```javascript
contract = await Verifier.new()
```
1. Read the content of `proof.json`.
```javascript
proof = JSON.parse(fs.readFileSync("path/to/your/proof.json"))
```
1. Verify the proof. Check that you get the result `true`.
```javascript
await contract.verifyTx(proof.proof.a, proof.proof.b, proof.proof.c, proof.inputs)
```
1. Pretend to be Alice and try to cheat. Create `cheat` which flips the result
bit.
```javascript
cheat = [...proof.inputs]
cheat[cheat.length-1] = cheat[cheat.length-1].replace(/[01]$/, cheat[cheat.length-1][65] == '1' ? '0': '1')
```
1. As Bob, try to verify a cheating proof, and check that it fails.
```javascript
await contract.verifyTx(proof.proof.a, proof.proof.b, proof.proof.c, cheat)
```
## Conclusion
At this point you should know how to use Zokrates to create zero knowledge proofs and verify them from the command
line. You should also be able to publish a verifier to a blockchain, generate proofs from the command line, and submit
them using JavaScript.
---------------------------------------------------------------
Original version of this tutorial by Ori Pomerantz qbzzt1@gmail.com

View file

@ -44,7 +44,7 @@ ZoKrates supports multiple backends. The options are the following:
| ---- | -------- | --------------- | ------ |
| Bellman | `--backend bellman` | G16 | ALTBN_128, BLS12_381 |
| Libsnark | `--backend libsnark` | GM17, PGHR13 | ALTBN_128 |
| Zexe | `--backend zexe` | GM17 | ALTBN_128, BLS12_377, BW6_761 |
| Ark | `--backend ark` | GM17 | ALTBN_128, BLS12_377, BW6_761 |
Default: `bellman`

View file

@ -15,7 +15,7 @@ bincode = "0.8.0"
regex = "0.2"
zokrates_field = { version = "0.3", path = "../zokrates_field" }
zokrates_abi = { version = "0.1", path = "../zokrates_abi" }
zokrates_core = { version = "0.5", path = "../zokrates_core", features = ["multicore", "zexe"] }
zokrates_core = { version = "0.5", path = "../zokrates_core", features = ["multicore", "ark"] }
zokrates_fs_resolver = { version = "0.5", path = "../zokrates_fs_resolver"}
serde_json = "1.0"
dirs = "3.0.1"

View file

@ -22,7 +22,7 @@ use zokrates_abi::Encode;
use zokrates_core::compile::{check, compile, CompilationArtifacts, CompileError};
use zokrates_core::ir::{self, ProgEnum};
use zokrates_core::proof_system::{
bellman::Bellman, gm17::GM17, groth16::G16, zexe::Zexe, SolidityCompatibleField,
ark::Ark, bellman::Bellman, gm17::GM17, groth16::G16, SolidityCompatibleField,
};
use zokrates_core::proof_system::{Backend, Scheme, SolidityAbi, SolidityCompatibleScheme};
use zokrates_core::typed_absy::abi::Abi;
@ -850,10 +850,10 @@ fn cli() -> Result<(), String> {
ProgEnum::Bls12_381Program(p) => cli_setup::<_, G16, Bellman>(p, sub_matches),
_ => unreachable!(),
},
Parameters(BackendParameter::Zexe, _, SchemeParameter::GM17) => match prog {
ProgEnum::Bls12_377Program(p) => cli_setup::<_, GM17, Zexe>(p, sub_matches),
ProgEnum::Bw6_761Program(p) => cli_setup::<_, GM17, Zexe>(p, sub_matches),
ProgEnum::Bn128Program(p) => cli_setup::<_, GM17, Zexe>(p, sub_matches),
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),
ProgEnum::Bn128Program(p) => cli_setup::<_, GM17, Ark>(p, sub_matches),
_ => unreachable!(),
},
#[cfg(feature = "libsnark")]
@ -926,16 +926,14 @@ fn cli() -> Result<(), String> {
}
_ => unreachable!(),
},
Parameters(BackendParameter::Zexe, _, SchemeParameter::GM17) => match prog {
Parameters(BackendParameter::Ark, _, SchemeParameter::GM17) => match prog {
ProgEnum::Bls12_377Program(p) => {
cli_generate_proof::<_, GM17, Zexe>(p, sub_matches)
cli_generate_proof::<_, GM17, Ark>(p, sub_matches)
}
ProgEnum::Bw6_761Program(p) => {
cli_generate_proof::<_, GM17, Zexe>(p, sub_matches)
}
ProgEnum::Bn128Program(p) => {
cli_generate_proof::<_, GM17, Zexe>(p, sub_matches)
cli_generate_proof::<_, GM17, Ark>(p, sub_matches)
}
ProgEnum::Bn128Program(p) => cli_generate_proof::<_, GM17, Ark>(p, sub_matches),
_ => unreachable!(),
},
#[cfg(feature = "libsnark")]
@ -1018,20 +1016,18 @@ fn cli() -> Result<(), String> {
SchemeParameter::G16,
) => cli_verify::<Bls12_381Field, G16, Bellman>(sub_matches),
Parameters(
BackendParameter::Zexe,
BackendParameter::Ark,
CurveParameter::Bls12_377,
SchemeParameter::GM17,
) => cli_verify::<Bls12_377Field, GM17, Zexe>(sub_matches),
) => cli_verify::<Bls12_377Field, GM17, Ark>(sub_matches),
Parameters(
BackendParameter::Zexe,
BackendParameter::Ark,
CurveParameter::Bw6_761,
SchemeParameter::GM17,
) => cli_verify::<Bw6_761Field, GM17, Zexe>(sub_matches),
Parameters(
BackendParameter::Zexe,
CurveParameter::Bn128,
SchemeParameter::GM17,
) => cli_verify::<Bn128Field, GM17, Zexe>(sub_matches),
) => cli_verify::<Bw6_761Field, GM17, Ark>(sub_matches),
Parameters(BackendParameter::Ark, CurveParameter::Bn128, SchemeParameter::GM17) => {
cli_verify::<Bn128Field, GM17, Ark>(sub_matches)
}
#[cfg(feature = "libsnark")]
Parameters(
BackendParameter::Libsnark,

View file

@ -1,12 +1,12 @@
pub const BELLMAN: &str = "bellman";
#[cfg(feature = "libsnark")]
pub const LIBSNARK: &str = "libsnark";
pub const ZEXE: &str = "zexe";
pub const ARK: &str = "ark";
#[cfg(feature = "libsnark")]
pub const BACKENDS: &[&str] = &[BELLMAN, LIBSNARK, ZEXE];
pub const BACKENDS: &[&str] = &[BELLMAN, LIBSNARK, ARK];
#[cfg(not(feature = "libsnark"))]
pub const BACKENDS: &[&str] = &[BELLMAN, ZEXE];
pub const BACKENDS: &[&str] = &[BELLMAN, ARK];
pub const BN128: &str = "bn128";
pub const BLS12_381: &str = "bls12_381";

View file

@ -12,7 +12,7 @@ pub enum CurveParameter {
pub enum BackendParameter {
Bellman,
Zexe,
Ark,
#[cfg(feature = "libsnark")]
Libsnark,
}
@ -44,7 +44,7 @@ impl TryFrom<&str> for BackendParameter {
fn try_from(s: &str) -> Result<Self, Self::Error> {
match s {
BELLMAN => Ok(BackendParameter::Bellman),
ZEXE => Ok(BackendParameter::Zexe),
ARK => Ok(BackendParameter::Ark),
#[cfg(feature = "libsnark")]
LIBSNARK => Ok(BackendParameter::Libsnark),
_ => Err(format!("Unknown backend {}", s)),
@ -83,9 +83,9 @@ impl TryFrom<(&str, &str, &str)> for Parameters {
match (&backend, &curve, &proving_scheme) {
(BackendParameter::Bellman, CurveParameter::Bn128, SchemeParameter::G16) => Ok(()),
(BackendParameter::Bellman, CurveParameter::Bls12_381, SchemeParameter::G16) => Ok(()),
(BackendParameter::Zexe, CurveParameter::Bls12_377, SchemeParameter::GM17) => Ok(()),
(BackendParameter::Zexe, CurveParameter::Bw6_761, SchemeParameter::GM17) => Ok(()),
(BackendParameter::Zexe, CurveParameter::Bn128, SchemeParameter::GM17) => Ok(()),
(BackendParameter::Ark, CurveParameter::Bls12_377, SchemeParameter::GM17) => Ok(()),
(BackendParameter::Ark, CurveParameter::Bw6_761, SchemeParameter::GM17) => Ok(()),
(BackendParameter::Ark, CurveParameter::Bn128, SchemeParameter::GM17) => Ok(()),
#[cfg(feature = "libsnark")]
(BackendParameter::Libsnark, CurveParameter::Bn128, SchemeParameter::GM17) => Ok(()),
#[cfg(feature = "libsnark")]

View file

@ -220,7 +220,7 @@ mod integration {
#[cfg(not(feature = "libsnark"))]
let backends = map! {
"bellman" => ["g16"],
"zexe" => ["gm17"]
"ark" => ["gm17"]
};
for (backend, schemes) in backends {
@ -279,7 +279,7 @@ mod integration {
.succeeds()
.unwrap();
if backend != "zexe" {
if backend != "ark" {
for abi_version in &["v1", "v2"] {
// EXPORT-VERIFIER
assert_cli::Assert::command(&[

View file

@ -11,7 +11,7 @@ default = []
libsnark = ["cc", "cmake", "git2"]
wasm = ["bellman_ce/nolog", "bellman_ce/wasm"]
multicore = ["bellman_ce/multicore"]
zexe = ["gm17", "algebra-core", "r1cs-core", "algebra"]
ark = ["ark-ff", "ark-ec", "ark-bn254", "ark-bls12-377", "ark-bw6-761", "ark-gm17", "ark-serialize", "ark-relations"]
[dependencies]
cfg-if = "0.1"
@ -24,7 +24,6 @@ reduce = "0.1.1"
serde = "1.0"
serde_derive = "1.0"
serde_json = "1.0"
serde_bytes = "0.10"
bincode = "0.8.0"
hex = "0.4.2"
regex = "0.2"
@ -37,14 +36,21 @@ 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 }
gm17 = { git = "https://github.com/scipr-lab/zexe.git", default-features = false, optional = true }
algebra-core = { git = "https://github.com/scipr-lab/zexe.git", default-features = false, optional = true }
r1cs-core = { git = "https://github.com/scipr-lab/zexe.git", default-features = false, optional = true }
algebra = { git = "https://github.com/scipr-lab/zexe.git", features = ["bn254", "bls12_377", "bw6_761"], default-features = false, optional = true }
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]
glob = "0.2.11"
assert_cli = "0.5"
wasm-bindgen-test = "^0.3.0"
pretty_assertions = "0.6.1"

View file

@ -24,12 +24,16 @@ extern crate ff_ce as ff;
extern crate pairing_ce as pairing;
cfg_if::cfg_if! {
if #[cfg(feature = "zexe")] {
extern crate algebra as zexe_algebra;
extern crate algebra_core;
extern crate gm17 as zexe_gm17;
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;
extern crate r1cs_core;
}
}

View file

@ -1,20 +1,20 @@
use zexe_gm17::{
prepare_verifying_key, verify_proof, Parameters, PreparedVerifyingKey, Proof as ZexeProof,
use ark_gm17::{
prepare_verifying_key, verify_proof, PreparedVerifyingKey, Proof as ArkProof, ProvingKey,
VerifyingKey,
};
use algebra_core::serialize::{CanonicalDeserialize, CanonicalSerialize};
use zokrates_field::{Bw6_761Field, Field, ZexeFieldExtensions};
use ark_serialize::{CanonicalDeserialize, CanonicalSerialize};
use zokrates_field::{ArkFieldExtensions, Bw6_761Field, Field};
use crate::proof_system::zexe::Computation;
use crate::proof_system::zexe::{parse_fr, parse_g1, parse_g2, parse_g2_fq};
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::zexe::Zexe;
use proof_system::Scheme;
use proof_system::{Backend, Proof, SetupKeypair};
impl<T: Field + ZexeFieldExtensions + NotBw6_761Field> Backend<T, GM17> for Zexe {
impl<T: Field + ArkFieldExtensions + NotBw6_761Field> Backend<T, GM17> for Ark {
fn setup(program: Prog<T>) -> SetupKeypair<<GM17 as Scheme<T>>::VerificationKey> {
let parameters = Computation::without_witness(program).setup();
@ -44,11 +44,10 @@ impl<T: Field + ZexeFieldExtensions + NotBw6_761Field> Backend<T, GM17> for Zexe
proving_key: Vec<u8>,
) -> Proof<<GM17 as Scheme<T>>::ProofPoints> {
let computation = Computation::with_witness(program, witness);
let params =
Parameters::<<T as ZexeFieldExtensions>::ZexeEngine>::deserialize_uncompressed(
&mut proving_key.as_slice(),
)
.unwrap();
let params = ProvingKey::<<T as ArkFieldExtensions>::ArkEngine>::deserialize_uncompressed(
&mut proving_key.as_slice(),
)
.unwrap();
let proof = computation.clone().prove(&params);
let proof_points = ProofPoints {
@ -83,13 +82,13 @@ impl<T: Field + ZexeFieldExtensions + NotBw6_761Field> Backend<T, GM17> for Zexe
.collect(),
};
let zexe_proof = ZexeProof {
let ark_proof = ArkProof {
a: serialization::to_g1::<T>(proof.proof.a),
b: serialization::to_g2::<T>(proof.proof.b),
c: serialization::to_g1::<T>(proof.proof.c),
};
let pvk: PreparedVerifyingKey<<T as ZexeFieldExtensions>::ZexeEngine> =
let pvk: PreparedVerifyingKey<<T as ArkFieldExtensions>::ArkEngine> =
prepare_verifying_key(&vk);
let public_inputs: Vec<_> = proof
@ -98,15 +97,15 @@ impl<T: Field + ZexeFieldExtensions + NotBw6_761Field> Backend<T, GM17> for Zexe
.map(|s| {
T::try_from_str(s.trim_start_matches("0x"), 16)
.unwrap()
.into_zexe()
.into_ark()
})
.collect::<Vec<_>>();
verify_proof(&pvk, &zexe_proof, &public_inputs).unwrap()
verify_proof(&pvk, &ark_proof, &public_inputs).unwrap()
}
}
impl Backend<Bw6_761Field, GM17> for Zexe {
impl Backend<Bw6_761Field, GM17> for Ark {
fn setup(
program: Prog<Bw6_761Field>,
) -> SetupKeypair<<GM17 as Scheme<Bw6_761Field>>::VerificationKey> {
@ -139,7 +138,7 @@ impl Backend<Bw6_761Field, GM17> for Zexe {
) -> Proof<<GM17 as Scheme<Bw6_761Field>>::ProofPoints> {
let computation = Computation::with_witness(program, witness);
let params =
Parameters::<<Bw6_761Field as ZexeFieldExtensions>::ZexeEngine>::deserialize_uncompressed(
ProvingKey::<<Bw6_761Field as ArkFieldExtensions>::ArkEngine>::deserialize_uncompressed(
&mut proving_key.as_slice(),
)
.unwrap();
@ -177,13 +176,13 @@ impl Backend<Bw6_761Field, GM17> for Zexe {
.collect(),
};
let zexe_proof = ZexeProof {
let ark_proof = ArkProof {
a: serialization::to_g1::<Bw6_761Field>(proof.proof.a),
b: serialization::to_g2_fq::<Bw6_761Field>(proof.proof.b),
c: serialization::to_g1::<Bw6_761Field>(proof.proof.c),
};
let pvk: PreparedVerifyingKey<<Bw6_761Field as ZexeFieldExtensions>::ZexeEngine> =
let pvk: PreparedVerifyingKey<<Bw6_761Field as ArkFieldExtensions>::ArkEngine> =
prepare_verifying_key(&vk);
let public_inputs: Vec<_> = proof
@ -192,18 +191,19 @@ impl Backend<Bw6_761Field, GM17> for Zexe {
.map(|s| {
Bw6_761Field::try_from_str(s.trim_start_matches("0x"), 16)
.unwrap()
.into_zexe()
.into_ark()
})
.collect::<Vec<_>>();
verify_proof(&pvk, &zexe_proof, &public_inputs).unwrap()
verify_proof(&pvk, &ark_proof, &public_inputs).unwrap()
}
}
pub mod serialization {
use algebra_core::{FromBytes, PairingEngine};
use ark_ec::PairingEngine;
use ark_ff::FromBytes;
use proof_system::{G1Affine, G2Affine, G2AffineFq};
use zokrates_field::ZexeFieldExtensions;
use zokrates_field::ArkFieldExtensions;
#[inline]
fn decode_hex(value: String) -> Vec<u8> {
@ -212,20 +212,16 @@ pub mod serialization {
bytes
}
pub fn to_g1<T: ZexeFieldExtensions>(
g1: G1Affine,
) -> <T::ZexeEngine as PairingEngine>::G1Affine {
pub fn to_g1<T: ArkFieldExtensions>(g1: G1Affine) -> <T::ArkEngine as PairingEngine>::G1Affine {
let mut bytes = vec![];
bytes.append(&mut decode_hex(g1.0));
bytes.append(&mut decode_hex(g1.1));
bytes.push(0u8); // infinity flag
<T::ZexeEngine as PairingEngine>::G1Affine::read(&*bytes).unwrap()
<T::ArkEngine as PairingEngine>::G1Affine::read(&*bytes).unwrap()
}
pub fn to_g2<T: ZexeFieldExtensions>(
g2: G2Affine,
) -> <T::ZexeEngine as PairingEngine>::G2Affine {
pub fn to_g2<T: ArkFieldExtensions>(g2: G2Affine) -> <T::ArkEngine as PairingEngine>::G2Affine {
let mut bytes = vec![];
bytes.append(&mut decode_hex((g2.0).0));
bytes.append(&mut decode_hex((g2.0).1));
@ -233,18 +229,18 @@ pub mod serialization {
bytes.append(&mut decode_hex((g2.1).1));
bytes.push(0u8); // infinity flag
<T::ZexeEngine as PairingEngine>::G2Affine::read(&*bytes).unwrap()
<T::ArkEngine as PairingEngine>::G2Affine::read(&*bytes).unwrap()
}
pub fn to_g2_fq<T: ZexeFieldExtensions>(
pub fn to_g2_fq<T: ArkFieldExtensions>(
g2: G2AffineFq,
) -> <T::ZexeEngine as PairingEngine>::G2Affine {
) -> <T::ArkEngine as PairingEngine>::G2Affine {
let mut bytes = vec![];
bytes.append(&mut decode_hex(g2.0));
bytes.append(&mut decode_hex(g2.1));
bytes.push(0u8); // infinity flag
<T::ZexeEngine as PairingEngine>::G2Affine::read(&*bytes).unwrap()
<T::ArkEngine as PairingEngine>::G2Affine::read(&*bytes).unwrap()
}
}
@ -271,7 +267,7 @@ mod tests {
private: vec![false],
};
let keypair = <Zexe as Backend<Bls12_377Field, GM17>>::setup(program.clone());
let keypair = <Ark as Backend<Bls12_377Field, GM17>>::setup(program.clone());
let interpreter = Interpreter::default();
let witness = interpreter
@ -279,8 +275,8 @@ mod tests {
.unwrap();
let proof =
<Zexe as Backend<Bls12_377Field, GM17>>::generate_proof(program, witness, keypair.pk);
let ans = <Zexe as Backend<Bls12_377Field, GM17>>::verify(keypair.vk, proof);
<Ark as Backend<Bls12_377Field, GM17>>::generate_proof(program, witness, keypair.pk);
let ans = <Ark as Backend<Bls12_377Field, GM17>>::verify(keypair.vk, proof);
assert!(ans);
}
@ -300,7 +296,7 @@ mod tests {
private: vec![false],
};
let keypair = <Zexe as Backend<Bw6_761Field, GM17>>::setup(program.clone());
let keypair = <Ark as Backend<Bw6_761Field, GM17>>::setup(program.clone());
let interpreter = Interpreter::default();
let witness = interpreter
@ -308,8 +304,8 @@ mod tests {
.unwrap();
let proof =
<Zexe as Backend<Bw6_761Field, GM17>>::generate_proof(program, witness, keypair.pk);
let ans = <Zexe as Backend<Bw6_761Field, GM17>>::verify(keypair.vk, proof);
<Ark as Backend<Bw6_761Field, GM17>>::generate_proof(program, witness, keypair.pk);
let ans = <Ark as Backend<Bw6_761Field, GM17>>::verify(keypair.vk, proof);
assert!(ans);
}

View file

@ -1,26 +1,26 @@
pub mod gm17;
use crate::ir::{CanonicalLinComb, Prog, Statement, Witness};
use zexe_gm17::Proof;
use zexe_gm17::{
use ark_gm17::Proof;
use ark_gm17::{
create_random_proof, generate_random_parameters, prepare_verifying_key, verify_proof,
Parameters,
ProvingKey,
};
use crate::flat_absy::FlatVariable;
use algebra_core::PairingEngine;
use r1cs_core::{
use ark_ec::PairingEngine;
use ark_relations::r1cs::{
ConstraintSynthesizer, ConstraintSystem, ConstraintSystemRef, LinearCombination,
SynthesisError, Variable,
};
use std::collections::BTreeMap;
use zokrates_field::{Field, ZexeFieldExtensions};
use zokrates_field::{ArkFieldExtensions, Field};
pub use self::parse::*;
use rand_0_7::SeedableRng;
pub struct Zexe;
pub struct Ark;
#[derive(Clone)]
pub struct Computation<T> {
@ -44,20 +44,20 @@ impl<T: Field> Computation<T> {
}
}
fn zexe_combination<T: Field + ZexeFieldExtensions>(
fn ark_combination<T: Field + ArkFieldExtensions>(
l: CanonicalLinComb<T>,
cs: &mut ConstraintSystem<<<T as ZexeFieldExtensions>::ZexeEngine as PairingEngine>::Fr>,
cs: &mut ConstraintSystem<<<T as ArkFieldExtensions>::ArkEngine as PairingEngine>::Fr>,
symbols: &mut BTreeMap<FlatVariable, Variable>,
witness: &mut Witness<T>,
) -> Result<
LinearCombination<<<T as ZexeFieldExtensions>::ZexeEngine as PairingEngine>::Fr>,
LinearCombination<<<T as ArkFieldExtensions>::ArkEngine as PairingEngine>::Fr>,
SynthesisError,
> {
let lc =
l.0.into_iter()
.map(|(k, v)| {
(
v.into_zexe(),
v.into_ark(),
symbols
.entry(k)
.or_insert_with(|| {
@ -67,14 +67,14 @@ fn zexe_combination<T: Field + ZexeFieldExtensions>(
.0
.remove(&k)
.ok_or(SynthesisError::AssignmentMissing)?
.into_zexe())
.into_ark())
}),
false => cs.new_witness_variable(|| {
Ok(witness
.0
.remove(&k)
.ok_or(SynthesisError::AssignmentMissing)?
.into_zexe())
.into_ark())
}),
}
.unwrap()
@ -87,10 +87,10 @@ fn zexe_combination<T: Field + ZexeFieldExtensions>(
Ok(lc)
}
impl<T: Field + ZexeFieldExtensions> Prog<T> {
impl<T: Field + ArkFieldExtensions> Prog<T> {
pub fn generate_constraints(
self,
cs: ConstraintSystemRef<<<T as ZexeFieldExtensions>::ZexeEngine as PairingEngine>::Fr>,
cs: ConstraintSystemRef<<<T as ArkFieldExtensions>::ArkEngine as PairingEngine>::Fr>,
witness: Option<Witness<T>>,
) -> Result<(), SynthesisError> {
// mapping from IR variables
@ -98,7 +98,7 @@ impl<T: Field + ZexeFieldExtensions> Prog<T> {
let mut witness = witness.unwrap_or(Witness::empty());
assert!(symbols.insert(FlatVariable::one(), ConstraintSystem::<<<T as ZexeFieldExtensions>::ZexeEngine as PairingEngine>::Fr>::one()).is_none());
assert!(symbols.insert(FlatVariable::one(), ConstraintSystem::<<<T as ArkFieldExtensions>::ArkEngine as PairingEngine>::Fr>::one()).is_none());
match cs {
ConstraintSystemRef::CS(rc) => {
@ -116,14 +116,14 @@ impl<T: Field + ZexeFieldExtensions> Prog<T> {
.0
.remove(&var)
.ok_or(SynthesisError::AssignmentMissing)?
.into_zexe())
.into_ark())
}),
false => cs.new_input_variable(|| {
Ok(witness
.0
.remove(&var)
.ok_or(SynthesisError::AssignmentMissing)?
.into_zexe())
.into_ark())
}),
}
.unwrap();
@ -136,19 +136,19 @@ impl<T: Field + ZexeFieldExtensions> Prog<T> {
for statement in main.statements {
match statement {
Statement::Constraint(quad, lin) => {
let a = zexe_combination(
let a = ark_combination(
quad.left.clone().into_canonical(),
&mut cs,
&mut symbols,
&mut witness,
)?;
let b = zexe_combination(
let b = ark_combination(
quad.right.clone().into_canonical(),
&mut cs,
&mut symbols,
&mut witness,
)?;
let c = zexe_combination(
let c = ark_combination(
lin.into_canonical(),
&mut cs,
&mut symbols,
@ -168,8 +168,8 @@ impl<T: Field + ZexeFieldExtensions> Prog<T> {
}
}
impl<T: Field + ZexeFieldExtensions> Computation<T> {
pub fn prove(self, params: &Parameters<T::ZexeEngine>) -> Proof<T::ZexeEngine> {
impl<T: Field + ArkFieldExtensions> Computation<T> {
pub fn prove(self, params: &ProvingKey<T::ArkEngine>) -> Proof<T::ArkEngine> {
let rng = &mut rand_0_7::rngs::StdRng::from_entropy();
let proof = create_random_proof(self.clone(), params, rng).unwrap();
@ -184,15 +184,15 @@ impl<T: Field + ZexeFieldExtensions> Computation<T> {
proof
}
pub fn public_inputs_values(&self) -> Vec<<T::ZexeEngine as PairingEngine>::Fr> {
pub fn public_inputs_values(&self) -> Vec<<T::ArkEngine as PairingEngine>::Fr> {
self.program
.public_inputs(self.witness.as_ref().unwrap())
.iter()
.map(|v| v.clone().into_zexe())
.map(|v| v.clone().into_ark())
.collect()
}
pub fn setup(self) -> Parameters<T::ZexeEngine> {
pub fn setup(self) -> ProvingKey<T::ArkEngine> {
let rng = &mut rand_0_7::rngs::StdRng::from_entropy();
// run setup phase
@ -200,13 +200,13 @@ impl<T: Field + ZexeFieldExtensions> Computation<T> {
}
}
impl<T: Field + ZexeFieldExtensions>
ConstraintSynthesizer<<<T as ZexeFieldExtensions>::ZexeEngine as PairingEngine>::Fr>
impl<T: Field + ArkFieldExtensions>
ConstraintSynthesizer<<<T as ArkFieldExtensions>::ArkEngine as PairingEngine>::Fr>
for Computation<T>
{
fn generate_constraints(
self,
cs: ConstraintSystemRef<<<T as ZexeFieldExtensions>::ZexeEngine as PairingEngine>::Fr>,
cs: ConstraintSystemRef<<<T as ArkFieldExtensions>::ArkEngine as PairingEngine>::Fr>,
) -> Result<(), SynthesisError> {
self.program.generate_constraints(cs, self.witness)
}
@ -214,11 +214,11 @@ impl<T: Field + ZexeFieldExtensions>
mod parse {
use super::*;
use algebra_core::ToBytes;
use ark_ff::ToBytes;
use proof_system::{Fr, G1Affine, G2Affine, G2AffineFq};
pub fn parse_g1<T: Field + ZexeFieldExtensions>(
e: &<T::ZexeEngine as PairingEngine>::G1Affine,
pub fn parse_g1<T: Field + ArkFieldExtensions>(
e: &<T::ArkEngine as PairingEngine>::G1Affine,
) -> G1Affine {
let mut bytes: Vec<u8> = Vec::new();
e.write(&mut bytes).unwrap();
@ -238,8 +238,8 @@ mod parse {
)
}
pub fn parse_g2<T: Field + ZexeFieldExtensions>(
e: &<T::ZexeEngine as PairingEngine>::G2Affine,
pub fn parse_g2<T: Field + ArkFieldExtensions>(
e: &<T::ArkEngine as PairingEngine>::G2Affine,
) -> G2Affine {
let mut bytes: Vec<u8> = Vec::new();
e.write(&mut bytes).unwrap();
@ -268,8 +268,8 @@ mod parse {
)
}
pub fn parse_g2_fq<T: ZexeFieldExtensions>(
e: &<T::ZexeEngine as PairingEngine>::G2Affine,
pub fn parse_g2_fq<T: ArkFieldExtensions>(
e: &<T::ArkEngine as PairingEngine>::G2Affine,
) -> G2AffineFq {
let mut bytes: Vec<u8> = Vec::new();
e.write(&mut bytes).unwrap();
@ -289,7 +289,7 @@ mod parse {
)
}
pub fn parse_fr<T: ZexeFieldExtensions>(e: &<T::ZexeEngine as PairingEngine>::Fr) -> Fr {
pub fn parse_fr<T: ArkFieldExtensions>(e: &<T::ArkEngine as PairingEngine>::Fr) -> Fr {
let mut bytes: Vec<u8> = Vec::new();
e.write(&mut bytes).unwrap();
bytes.reverse();

View file

@ -1,8 +1,8 @@
#[cfg(feature = "ark")]
pub mod ark;
pub mod bellman;
#[cfg(feature = "libsnark")]
pub mod libsnark;
#[cfg(feature = "zexe")]
pub mod zexe;
mod scheme;
mod solidity;

View file

@ -10,5 +10,4 @@ edition = "2018"
zokrates_test = { version = "0.1", path = "../zokrates_test" }
[build-dependencies]
fs_extra = "1.1.0"
zokrates_test = { version = "0.1", path = "../zokrates_test" }
zokrates_test_derive = { version = "0.0", path = "../zokrates_test_derive" }

View file

@ -1,4 +1,4 @@
use zokrates_test::write_tests;
use zokrates_test_derive::write_tests;
fn main() {
// generate tests

View file

@ -11,14 +11,16 @@ lazy_static = "1.4"
bincode = "0.8.0"
serde_json = "1.0"
bellman_ce = { version = "^0.3", default-features = false }
algebra-core = { git = "https://github.com/scipr-lab/zexe.git", default-features = false }
sha2 = "0.8.0"
num-traits = { version = "0.2", default-features = false }
num-integer = { version = "0.1", default-features = false }
[dependencies.algebra]
git = "https://github.com/scipr-lab/zexe.git"
features = ["bn254", "bls12_377", "bw6_761"]
ark-ff = { git = "https://github.com/arkworks-rs/algebra", default-features = false }
ark-ec = { git = "https://github.com/arkworks-rs/algebra", default-features = false }
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 }
[dev-dependencies]
rand = "0.4"

View file

@ -1,7 +1,9 @@
use algebra::bls12_377::Bls12_377;
extern crate ark_bls12_377;
use ark_bls12_377::Bls12_377;
prime_field!(
b"8444461749428370424248824938781546531375899335154063827935233455917409239041",
"bls12_377"
);
zexe_extensions!(Bls12_377);
ark_extensions!(Bls12_377);

View file

@ -1,4 +1,6 @@
use algebra::bn254::Bn254;
extern crate ark_bn254;
use ark_bn254::Bn254;
use bellman_ce::pairing::bn256::{Bn256, Fq2};
prime_field!(
@ -7,7 +9,7 @@ prime_field!(
);
bellman_extensions!(Bn256, Fq2);
zexe_extensions!(Bn254);
ark_extensions!(Bn254);
#[cfg(test)]
mod tests {

View file

@ -1,8 +1,10 @@
use algebra::bw6_761::BW6_761;
extern crate ark_bw6_761;
use ark_bw6_761::BW6_761;
prime_field!(
b"258664426012969094010652733694893533536393512754914660539884262666720468348340822774968888139573360124440321458177",
"bw6_761"
);
zexe_extensions!(BW6_761);
ark_extensions!(BW6_761);

View file

@ -3,10 +3,12 @@
// @author Dennis Kuhnert <dennis.kuhnert@campus.tu-berlin.de>
// @author Jacob Eberhardt <jacob.eberhardt@tu-berlin.de>
// @date 2017
extern crate algebra_core;
extern crate ark_bls12_377;
extern crate ark_ec;
extern crate ark_ff;
extern crate num_bigint;
use algebra_core::PairingEngine;
use ark_ec::PairingEngine;
use bellman_ce::pairing::ff::ScalarEngine;
use bellman_ce::pairing::Engine;
use num_bigint::BigUint;
@ -31,12 +33,12 @@ pub trait BellmanFieldExtensions {
fn new_fq2(c0: &str, c1: &str) -> <Self::BellmanEngine as Engine>::Fqe;
}
pub trait ZexeFieldExtensions {
/// An associated type to be able to operate with zexe ff traits
type ZexeEngine: PairingEngine;
pub trait ArkFieldExtensions {
/// An associated type to be able to operate with ark ff traits
type ArkEngine: PairingEngine;
fn from_zexe(e: <Self::ZexeEngine as algebra_core::PairingEngine>::Fr) -> Self;
fn into_zexe(self) -> <Self::ZexeEngine as algebra_core::PairingEngine>::Fr;
fn from_ark(e: <Self::ArkEngine as ark_ec::PairingEngine>::Fr) -> Self;
fn into_ark(self) -> <Self::ArkEngine as ark_ec::PairingEngine>::Fr;
}
pub trait Field:
@ -511,24 +513,24 @@ mod prime_field {
};
}
macro_rules! zexe_extensions {
($zexe_type:ty) => {
use crate::ZexeFieldExtensions;
macro_rules! ark_extensions {
($ark_type:ty) => {
use crate::ArkFieldExtensions;
impl ZexeFieldExtensions for FieldPrime {
type ZexeEngine = $zexe_type;
impl ArkFieldExtensions for FieldPrime {
type ArkEngine = $ark_type;
fn from_zexe(e: <Self::ZexeEngine as algebra_core::PairingEngine>::Fr) -> Self {
use algebra_core::{BigInteger, PrimeField};
fn from_ark(e: <Self::ArkEngine as ark_ec::PairingEngine>::Fr) -> Self {
use ark_ff::{BigInteger, PrimeField};
let mut res: Vec<u8> = vec![];
e.into_repr().write_le(&mut res).unwrap();
Self::from_byte_vector(res)
}
fn into_zexe(self) -> <Self::ZexeEngine as algebra_core::PairingEngine>::Fr {
fn into_ark(self) -> <Self::ArkEngine as ark_ec::PairingEngine>::Fr {
use core::str::FromStr;
let s = self.to_dec_string();
<Self::ZexeEngine as algebra_core::PairingEngine>::Fr::from_str(&s).unwrap()
<Self::ArkEngine as ark_ec::PairingEngine>::Fr::from_str(&s).unwrap()
}
}
};

View file

@ -1228,7 +1228,7 @@ dependencies = [
[[package]]
name = "zokrates_js"
version = "1.0.25"
version = "1.0.26"
dependencies = [
"bincode 1.3.1",
"console_error_panic_hook",

View file

@ -1,6 +1,6 @@
[package]
name = "zokrates_js"
version = "1.0.25"
version = "1.0.26"
authors = ["Darko Macesic"]
edition = "2018"

View file

@ -1,6 +1,6 @@
{
"name": "zokrates-js",
"version": "1.0.25",
"version": "1.0.26",
"lockfileVersion": 1,
"requires": true,
"dependencies": {

View file

@ -2,7 +2,7 @@
"name": "zokrates-js",
"main": "index.js",
"author": "Darko Macesic <darem966@gmail.com>",
"version": "1.0.25",
"version": "1.0.26",
"keywords": [
"zokrates",
"wasm-bindgen",

View file

@ -6,7 +6,6 @@ edition = "2018"
[dependencies]
zokrates_parser = { version = "0.1.0", path = "../zokrates_parser" }
zokrates_field = { version = "0.3.0", path = "../zokrates_field" }
pest = "2.0"
pest-ast = "0.3.3"
from-pest = "0.3.1"

View file

@ -9,5 +9,5 @@ zokrates_test = { version = "0.1", path = "../zokrates_test" }
[build-dependencies]
fs_extra = "1.1.0"
zokrates_test = { version = "0.1", path = "../zokrates_test" }
zokrates_test_derive = { version = "0.0", path = "../zokrates_test_derive" }

View file

@ -1,7 +1,7 @@
use fs_extra::copy_items;
use fs_extra::dir::CopyOptions;
use std::env;
use zokrates_test::write_tests;
use zokrates_test_derive::write_tests;
fn main() {
// export stdlib folder to OUT_DIR

View file

@ -11,7 +11,5 @@ zokrates_fs_resolver = { version = "0.5", path = "../zokrates_fs_resolver" }
serde = "1.0"
serde_derive = "1.0"
serde_json = "1.0"
glob = "0.3.0"
fs_extra = "1.1.0"
[lib]

View file

@ -1,7 +1,8 @@
#[macro_use]
extern crate serde_derive;
use std::path::PathBuf;
use std::fs::File;
use std::path::{Path, PathBuf};
use zokrates_core::ir;
use zokrates_field::{Bls12_377Field, Bls12_381Field, Bn128Field, Bw6_761Field, Field};
@ -163,47 +164,3 @@ fn compile_and_run<T: Field>(t: Tests) {
};
}
}
use std::env;
use std::fs::File;
use std::io::{BufWriter, Write};
use std::path::Path;
pub fn write_tests(base: &str) {
use glob::glob;
let base = Path::new(&base);
let out_dir = env::var("OUT_DIR").unwrap();
let destination = Path::new(&out_dir).join("tests.rs");
let test_file = File::create(&destination).unwrap();
let mut writer = BufWriter::new(test_file);
for p in glob(base.join("**/*.json").to_str().unwrap()).unwrap() {
write_test(&mut writer, &p.unwrap(), &base);
}
}
fn write_test<W: Write>(test_file: &mut W, test_path: &Path, base_path: &Path) {
println!("{:?}", test_path);
println!("{:?}", base_path);
let test_name = format!(
"test_{}",
test_path
.strip_prefix(base_path.strip_prefix("./").unwrap())
.unwrap()
.display()
.to_string()
.replace("/", "_")
.replace(".json", "")
.replace(".", "")
);
write!(
test_file,
include_str!("../test_template"),
test_name = test_name,
test_path = test_path.display()
)
.unwrap();
}

View file

@ -0,0 +1,10 @@
[package]
name = "zokrates_test_derive"
version = "0.0.1"
authors = ["schaeff <thibaut@schaeff.fr>"]
edition = "2018"
[dependencies]
glob = "0.3.0"
[lib]

View file

@ -0,0 +1,43 @@
use std::env;
use std::fs::File;
use std::io::{BufWriter, Write};
use std::path::Path;
pub fn write_tests(base: &str) {
use glob::glob;
let base = Path::new(&base);
let out_dir = env::var("OUT_DIR").unwrap();
let destination = Path::new(&out_dir).join("tests.rs");
let test_file = File::create(&destination).unwrap();
let mut writer = BufWriter::new(test_file);
for p in glob(base.join("**/*.json").to_str().unwrap()).unwrap() {
write_test(&mut writer, &p.unwrap(), &base);
}
}
fn write_test<W: Write>(test_file: &mut W, test_path: &Path, base_path: &Path) {
println!("{:?}", test_path);
println!("{:?}", base_path);
let test_name = format!(
"test_{}",
test_path
.strip_prefix(base_path.strip_prefix("./").unwrap())
.unwrap()
.display()
.to_string()
.replace("/", "_")
.replace(".json", "")
.replace(".", "")
);
write!(
test_file,
include_str!("../test_template"),
test_name = test_name,
test_path = test_path.display()
)
.unwrap();
}