fix conflicts
This commit is contained in:
commit
52d50d12ad
22 changed files with 642 additions and 1528 deletions
331
Cargo.lock
generated
331
Cargo.lock
generated
|
@ -1,5 +1,14 @@
|
|||
# This file is automatically @generated by Cargo.
|
||||
# It is not intended for manual editing.
|
||||
[[package]]
|
||||
name = "addr2line"
|
||||
version = "0.12.1"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "a49806b9dadc843c61e7c97e72490ad7f7220ae249012fbda9ad0609457c0543"
|
||||
dependencies = [
|
||||
"gimli",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "aho-corasick"
|
||||
version = "0.6.10"
|
||||
|
@ -60,26 +69,17 @@ checksum = "f8aac770f1885fd7e387acedd76065302551364496e46b3dd00860b2f8359b9d"
|
|||
|
||||
[[package]]
|
||||
name = "backtrace"
|
||||
version = "0.3.46"
|
||||
version = "0.3.48"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "b1e692897359247cc6bb902933361652380af0f1b7651ae5c5013407f30e109e"
|
||||
checksum = "0df2f85c8a2abbe3b7d7e748052fdd9b76a0458fdeb16ad4223f5eca78c7c130"
|
||||
dependencies = [
|
||||
"backtrace-sys",
|
||||
"addr2line",
|
||||
"cfg-if",
|
||||
"libc",
|
||||
"object",
|
||||
"rustc-demangle",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "backtrace-sys"
|
||||
version = "0.1.36"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "78848718ee1255a2485d1309ad9cdecfc2e7d0362dd11c6829364c6b35ae1bc7"
|
||||
dependencies = [
|
||||
"cc",
|
||||
"libc",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "bellman_ce"
|
||||
version = "0.3.4"
|
||||
|
@ -110,9 +110,9 @@ dependencies = [
|
|||
|
||||
[[package]]
|
||||
name = "bit-vec"
|
||||
version = "0.6.1"
|
||||
version = "0.6.2"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "a4523a10839ffae575fb08aa3423026c8cb4687eef43952afb956229d4f246f7"
|
||||
checksum = "5f0dc55f2d8a1a85650ac47858bb001b4c0dd73d79e3c455a842925e68d29cd3"
|
||||
|
||||
[[package]]
|
||||
name = "bitflags"
|
||||
|
@ -154,9 +154,9 @@ dependencies = [
|
|||
|
||||
[[package]]
|
||||
name = "bstr"
|
||||
version = "0.2.12"
|
||||
version = "0.2.13"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "2889e6d50f394968c8bf4240dc3f2a7eb4680844d27308f798229ac9d4725f41"
|
||||
checksum = "31accafdb70df7871592c058eca3985b71104e15ac32f64706022c58867da931"
|
||||
dependencies = [
|
||||
"lazy_static",
|
||||
"memchr",
|
||||
|
@ -166,9 +166,9 @@ dependencies = [
|
|||
|
||||
[[package]]
|
||||
name = "bumpalo"
|
||||
version = "3.2.1"
|
||||
version = "3.4.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "12ae9db68ad7fac5fe51304d20f016c911539251075a214f8e663babefa35187"
|
||||
checksum = "2e8c087f005730276d1096a652e92a8bacee2e2472bcc9715a74d2bec38b5820"
|
||||
|
||||
[[package]]
|
||||
name = "byte-tools"
|
||||
|
@ -203,9 +203,9 @@ dependencies = [
|
|||
|
||||
[[package]]
|
||||
name = "cc"
|
||||
version = "1.0.52"
|
||||
version = "1.0.54"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "c3d87b23d6a92cd03af510a5ade527033f6aa6fa92161e2d5863a907d4c5e31d"
|
||||
checksum = "7bbb73db36c1246e9034e307d0fba23f9a2e251faa47ade70c1bd252220c8311"
|
||||
dependencies = [
|
||||
"jobserver",
|
||||
]
|
||||
|
@ -218,9 +218,9 @@ checksum = "4785bdd1c96b2a846b2bd7cc02e86b6b3dbf14e7e53446c4f54c92a361040822"
|
|||
|
||||
[[package]]
|
||||
name = "clap"
|
||||
version = "2.33.0"
|
||||
version = "2.33.1"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "5067f5bb2d80ef5d68b4c87db81601f0b75bca627bc2ef76b141d7b846a3c6d9"
|
||||
checksum = "bdfa80d47f954d53a35a64987ca1422f495b8d6483c0fe9f7117b36c2a792129"
|
||||
dependencies = [
|
||||
"ansi_term",
|
||||
"atty",
|
||||
|
@ -233,9 +233,9 @@ dependencies = [
|
|||
|
||||
[[package]]
|
||||
name = "cmake"
|
||||
version = "0.1.42"
|
||||
version = "0.1.44"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "81fb25b677f8bf1eb325017cb6bb8452f87969db0fedb4f757b297bee78a7c62"
|
||||
checksum = "0e56268c17a6248366d66d4a47a3381369d068cce8409bb1716ed77ea32163bb"
|
||||
dependencies = [
|
||||
"cc",
|
||||
]
|
||||
|
@ -319,9 +319,9 @@ dependencies = [
|
|||
|
||||
[[package]]
|
||||
name = "crossbeam-queue"
|
||||
version = "0.2.1"
|
||||
version = "0.2.2"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "c695eeca1e7173472a32221542ae469b3e9aac3a4fc81f7696bcad82029493db"
|
||||
checksum = "ab6bffe714b6bb07e42f201352c34f51fefd355ace793f9e638ebd52d23f98d2"
|
||||
dependencies = [
|
||||
"cfg-if",
|
||||
"crossbeam-utils",
|
||||
|
@ -414,9 +414,9 @@ dependencies = [
|
|||
|
||||
[[package]]
|
||||
name = "failure"
|
||||
version = "0.1.7"
|
||||
version = "0.1.8"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "b8529c2421efa3066a5cbd8063d2244603824daccb6936b079010bb2aa89464b"
|
||||
checksum = "d32e9bd16cc02eae7db7ef620b392808b89f6a5e16bb3497d159c6b92a0f4f86"
|
||||
dependencies = [
|
||||
"backtrace",
|
||||
"failure_derive",
|
||||
|
@ -424,13 +424,13 @@ dependencies = [
|
|||
|
||||
[[package]]
|
||||
name = "failure_derive"
|
||||
version = "0.1.7"
|
||||
version = "0.1.8"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "030a733c8287d6213886dd487564ff5c8f6aae10278b3588ed177f9d18f8d231"
|
||||
checksum = "aa4da3c766cd7a0db8242e326e9e4e081edd567072893ed320008189715366a4"
|
||||
dependencies = [
|
||||
"proc-macro2 1.0.10",
|
||||
"quote 1.0.3",
|
||||
"syn 1.0.17",
|
||||
"proc-macro2 1.0.18",
|
||||
"quote 1.0.6",
|
||||
"syn 1.0.30",
|
||||
"synstructure",
|
||||
]
|
||||
|
||||
|
@ -447,7 +447,6 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
|
|||
checksum = "83c0a6a2c53b0bd6d8cae976816dc8a171e0554c03f304e3dac110473e0219fd"
|
||||
dependencies = [
|
||||
"byteorder",
|
||||
"ff_derive_ce 0.7.0",
|
||||
"hex",
|
||||
"rand 0.4.6",
|
||||
]
|
||||
|
@ -459,25 +458,11 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
|
|||
checksum = "40ced6646e4e98a53da162e38ffe9c865edbd7a2f9ff197067b0a8bf1114bf8a"
|
||||
dependencies = [
|
||||
"byteorder",
|
||||
"ff_derive_ce 0.8.0",
|
||||
"ff_derive_ce",
|
||||
"hex",
|
||||
"rand 0.4.6",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "ff_derive_ce"
|
||||
version = "0.7.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "7543567f0c51910363eb5706ee2f5368a64e79a8ae607d0332aa60bae03a1bb1"
|
||||
dependencies = [
|
||||
"num-bigint 0.2.6",
|
||||
"num-integer",
|
||||
"num-traits 0.2.11",
|
||||
"proc-macro2 1.0.10",
|
||||
"quote 1.0.3",
|
||||
"syn 1.0.17",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "ff_derive_ce"
|
||||
version = "0.8.0"
|
||||
|
@ -487,9 +472,9 @@ dependencies = [
|
|||
"num-bigint 0.2.6",
|
||||
"num-integer",
|
||||
"num-traits 0.2.11",
|
||||
"proc-macro2 1.0.10",
|
||||
"quote 1.0.3",
|
||||
"syn 1.0.17",
|
||||
"proc-macro2 1.0.18",
|
||||
"quote 1.0.6",
|
||||
"syn 1.0.30",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
|
@ -516,9 +501,9 @@ checksum = "a06f77d526c1a601b7c4cdd98f54b5eaabffc14d5f2f0296febdc7f357c6d3ba"
|
|||
|
||||
[[package]]
|
||||
name = "futures"
|
||||
version = "0.3.4"
|
||||
version = "0.3.5"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "5c329ae8753502fb44ae4fc2b622fa2a94652c41e795143765ba0927f92ab780"
|
||||
checksum = "1e05b85ec287aac0dc34db7d4a569323df697f9c55b99b15d6b4ef8cde49f613"
|
||||
dependencies = [
|
||||
"futures-channel",
|
||||
"futures-core",
|
||||
|
@ -531,9 +516,9 @@ dependencies = [
|
|||
|
||||
[[package]]
|
||||
name = "futures-channel"
|
||||
version = "0.3.4"
|
||||
version = "0.3.5"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "f0c77d04ce8edd9cb903932b608268b3fffec4163dc053b3b402bf47eac1f1a8"
|
||||
checksum = "f366ad74c28cca6ba456d95e6422883cfb4b252a83bed929c83abfdbbf2967d5"
|
||||
dependencies = [
|
||||
"futures-core",
|
||||
"futures-sink",
|
||||
|
@ -541,15 +526,15 @@ dependencies = [
|
|||
|
||||
[[package]]
|
||||
name = "futures-core"
|
||||
version = "0.3.4"
|
||||
version = "0.3.5"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "f25592f769825e89b92358db00d26f965761e094951ac44d3663ef25b7ac464a"
|
||||
checksum = "59f5fff90fd5d971f936ad674802482ba441b6f09ba5e15fd8b39145582ca399"
|
||||
|
||||
[[package]]
|
||||
name = "futures-executor"
|
||||
version = "0.3.4"
|
||||
version = "0.3.5"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "f674f3e1bcb15b37284a90cedf55afdba482ab061c407a9c0ebbd0f3109741ba"
|
||||
checksum = "10d6bb888be1153d3abeb9006b11b02cf5e9b209fda28693c31ae1e4e012e314"
|
||||
dependencies = [
|
||||
"futures-core",
|
||||
"futures-task",
|
||||
|
@ -559,27 +544,30 @@ dependencies = [
|
|||
|
||||
[[package]]
|
||||
name = "futures-io"
|
||||
version = "0.3.4"
|
||||
version = "0.3.5"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "a638959aa96152c7a4cddf50fcb1e3fede0583b27157c26e67d6f99904090dc6"
|
||||
checksum = "de27142b013a8e869c14957e6d2edeef89e97c289e69d042ee3a49acd8b51789"
|
||||
|
||||
[[package]]
|
||||
name = "futures-sink"
|
||||
version = "0.3.4"
|
||||
version = "0.3.5"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "3466821b4bc114d95b087b850a724c6f83115e929bc88f1fa98a3304a944c8a6"
|
||||
checksum = "3f2032893cb734c7a05d85ce0cc8b8c4075278e93b24b66f9de99d6eb0fa8acc"
|
||||
|
||||
[[package]]
|
||||
name = "futures-task"
|
||||
version = "0.3.4"
|
||||
version = "0.3.5"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "7b0a34e53cf6cdcd0178aa573aed466b646eb3db769570841fda0c7ede375a27"
|
||||
checksum = "bdb66b5f09e22019b1ab0830f7785bcea8e7a42148683f99214f73f8ec21a626"
|
||||
dependencies = [
|
||||
"once_cell",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "futures-util"
|
||||
version = "0.3.4"
|
||||
version = "0.3.5"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "22766cf25d64306bedf0384da004d05c9974ab104fcc4528f1236181c18004c5"
|
||||
checksum = "8764574ff08b701a084482c3c7031349104b07ac897393010494beaa18ce32c6"
|
||||
dependencies = [
|
||||
"futures-channel",
|
||||
"futures-core",
|
||||
|
@ -587,6 +575,7 @@ dependencies = [
|
|||
"futures-sink",
|
||||
"futures-task",
|
||||
"memchr",
|
||||
"pin-project",
|
||||
"pin-utils",
|
||||
"slab",
|
||||
]
|
||||
|
@ -612,10 +601,16 @@ dependencies = [
|
|||
]
|
||||
|
||||
[[package]]
|
||||
name = "git2"
|
||||
version = "0.13.4"
|
||||
name = "gimli"
|
||||
version = "0.21.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "2be62b002b81549c68d31792d7dce5752c3658ea85715f4032ebbf9a6fdb0bb6"
|
||||
checksum = "bcc8e0c9bce37868955864dbecd2b1ab2bdf967e6f28066d65aaac620444b65c"
|
||||
|
||||
[[package]]
|
||||
name = "git2"
|
||||
version = "0.13.6"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "11e4b2082980e751c4bf4273e9cbb4a02c655729c8ee8a79f66cad03c8f4d31e"
|
||||
dependencies = [
|
||||
"bitflags",
|
||||
"libc",
|
||||
|
@ -640,9 +635,9 @@ checksum = "9b919933a397b79c37e33b77bb2aa3dc8eb6e165ad809e58ff75bc7db2e34574"
|
|||
|
||||
[[package]]
|
||||
name = "hermit-abi"
|
||||
version = "0.1.11"
|
||||
version = "0.1.13"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "8a0d737e0f947a1864e93d33fdef4af8445a00d1ed8dc0c8ddb73139ea6abf15"
|
||||
checksum = "91780f809e750b0a89f5544be56617ff6b1227ee485bcb06ebe10cdf89bd3b71"
|
||||
dependencies = [
|
||||
"libc",
|
||||
]
|
||||
|
@ -690,9 +685,9 @@ dependencies = [
|
|||
|
||||
[[package]]
|
||||
name = "js-sys"
|
||||
version = "0.3.37"
|
||||
version = "0.3.40"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "6a27d435371a2fa5b6d2b028a74bbdb1234f308da363226a2854ca3ff8ba7055"
|
||||
checksum = "ce10c23ad2ea25ceca0093bd3192229da4c5b3c0f2de499c1ecac0d98d452177"
|
||||
dependencies = [
|
||||
"wasm-bindgen",
|
||||
]
|
||||
|
@ -705,15 +700,15 @@ checksum = "e2abad23fbc42b3700f2f279844dc832adb2b2eb069b2df918f455c4e18cc646"
|
|||
|
||||
[[package]]
|
||||
name = "libc"
|
||||
version = "0.2.69"
|
||||
version = "0.2.71"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "99e85c08494b21a9054e7fe1374a732aeadaff3980b6990b94bfd3a70f690005"
|
||||
checksum = "9457b06509d27052635f90d6466700c65095fdf75409b3fbdd903e988b886f49"
|
||||
|
||||
[[package]]
|
||||
name = "libgit2-sys"
|
||||
version = "0.12.4+1.0.0"
|
||||
version = "0.12.7+1.0.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "ef2870ecd7b50a76391b108edc2c62283ad2b62e5b1ab4d5263ef1cd04ef1c44"
|
||||
checksum = "bcd07968649bcb7b9351ecfde53ca4d27673cccfdf57c84255ec18710f3153e0"
|
||||
dependencies = [
|
||||
"cc",
|
||||
"libc",
|
||||
|
@ -725,9 +720,9 @@ dependencies = [
|
|||
|
||||
[[package]]
|
||||
name = "libssh2-sys"
|
||||
version = "0.2.16"
|
||||
version = "0.2.17"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "7bb70f29dc7c31d32c97577f13f41221af981b31248083e347b7f2c39225a6bc"
|
||||
checksum = "d45f516b9b19ea6c940b9f36d36734062a153a2b4cc9ef31d82c54bb9780f525"
|
||||
dependencies = [
|
||||
"cc",
|
||||
"libc",
|
||||
|
@ -879,6 +874,18 @@ dependencies = [
|
|||
"libc",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "object"
|
||||
version = "0.19.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "9cbca9424c482ee628fa549d9c812e2cd22f1180b9222c9200fdfa6eb31aecb2"
|
||||
|
||||
[[package]]
|
||||
name = "once_cell"
|
||||
version = "1.4.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "0b631f7e854af39a1739f401cf34a8a013dfe09eac4fa4dba91e9768bd28168d"
|
||||
|
||||
[[package]]
|
||||
name = "opaque-debug"
|
||||
version = "0.2.3"
|
||||
|
@ -893,9 +900,9 @@ checksum = "77af24da69f9d9341038eba93a073b1fdaaa1b788221b00a69bce9e762cb32de"
|
|||
|
||||
[[package]]
|
||||
name = "openssl-sys"
|
||||
version = "0.9.55"
|
||||
version = "0.9.57"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "7717097d810a0f2e2323f9e5d11e71608355e24828410b55b9d4f18aa5f9a5d8"
|
||||
checksum = "7410fef80af8ac071d4f63755c0ab89ac3df0fd1ea91f1d1f37cf5cec4395990"
|
||||
dependencies = [
|
||||
"autocfg",
|
||||
"cc",
|
||||
|
@ -961,9 +968,9 @@ checksum = "99b8db626e31e5b81787b9783425769681b347011cc59471e33ea46d2ea0cf55"
|
|||
dependencies = [
|
||||
"pest",
|
||||
"pest_meta",
|
||||
"proc-macro2 1.0.10",
|
||||
"quote 1.0.3",
|
||||
"syn 1.0.17",
|
||||
"proc-macro2 1.0.18",
|
||||
"quote 1.0.6",
|
||||
"syn 1.0.30",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
|
@ -977,6 +984,26 @@ dependencies = [
|
|||
"sha-1",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "pin-project"
|
||||
version = "0.4.18"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "0c6fb74a77eb289e3c553afc6705e84d3fd4d9ad2d34b77b2b7de0fccbad98a3"
|
||||
dependencies = [
|
||||
"pin-project-internal",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "pin-project-internal"
|
||||
version = "0.4.18"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "e1ebfd15fd00460b95468c674083f070343b430217859f5e8ec3933a65e4130c"
|
||||
dependencies = [
|
||||
"proc-macro2 1.0.18",
|
||||
"quote 1.0.6",
|
||||
"syn 1.0.30",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "pin-utils"
|
||||
version = "0.1.0"
|
||||
|
@ -991,9 +1018,9 @@ checksum = "05da548ad6865900e60eaba7f589cc0783590a92e940c26953ff81ddbab2d677"
|
|||
|
||||
[[package]]
|
||||
name = "ppv-lite86"
|
||||
version = "0.2.6"
|
||||
version = "0.2.8"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "74490b50b9fbe561ac330df47c08f3f33073d2d00c150f719147d7c54522fa1b"
|
||||
checksum = "237a5ed80e274dbc66f86bd59c1e25edc039660be53194b5fe0a482e0f2612ea"
|
||||
|
||||
[[package]]
|
||||
name = "proc-macro2"
|
||||
|
@ -1006,9 +1033,9 @@ dependencies = [
|
|||
|
||||
[[package]]
|
||||
name = "proc-macro2"
|
||||
version = "1.0.10"
|
||||
version = "1.0.18"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "df246d292ff63439fea9bc8c0a270bed0e390d5ebd4db4ba15aba81111b5abe3"
|
||||
checksum = "beae6331a816b1f65d04c45b078fd8e6c93e8071771f41b8163255bbd8d7c8fa"
|
||||
dependencies = [
|
||||
"unicode-xid 0.2.0",
|
||||
]
|
||||
|
@ -1033,11 +1060,11 @@ dependencies = [
|
|||
|
||||
[[package]]
|
||||
name = "quote"
|
||||
version = "1.0.3"
|
||||
version = "1.0.6"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "2bdc6c187c65bca4260c9011c9e3132efe4909da44726bad24cf7572ae338d7f"
|
||||
checksum = "54a21852a652ad6f610c9510194f398ff6f8692e334fd1145fed931f7fbe44ea"
|
||||
dependencies = [
|
||||
"proc-macro2 1.0.10",
|
||||
"proc-macro2 1.0.18",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
|
@ -1178,9 +1205,9 @@ checksum = "4c691c0e608126e00913e33f0ccf3727d5fc84573623b8d65b2df340b5201783"
|
|||
|
||||
[[package]]
|
||||
name = "ryu"
|
||||
version = "1.0.4"
|
||||
version = "1.0.5"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "ed3d612bc64430efeb3f7ee6ef26d590dce0c43249217bddc62112540c7941e1"
|
||||
checksum = "71d301d4193d031abdd79ff7e3dd721168a9572ef3fe51a1517aba235bd8f86e"
|
||||
|
||||
[[package]]
|
||||
name = "same-file"
|
||||
|
@ -1238,9 +1265,9 @@ checksum = "388a1df253eca08550bef6c72392cfe7c30914bf41df5269b68cbd6ff8f570a3"
|
|||
|
||||
[[package]]
|
||||
name = "serde"
|
||||
version = "1.0.106"
|
||||
version = "1.0.111"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "36df6ac6412072f67cf767ebbde4133a5b2e88e76dc6187fa7104cd16f783399"
|
||||
checksum = "c9124df5b40cbd380080b2cc6ab894c040a3070d995f5c9dc77e18c34a8ae37d"
|
||||
|
||||
[[package]]
|
||||
name = "serde_bytes"
|
||||
|
@ -1253,20 +1280,20 @@ dependencies = [
|
|||
|
||||
[[package]]
|
||||
name = "serde_derive"
|
||||
version = "1.0.106"
|
||||
version = "1.0.111"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "9e549e3abf4fb8621bd1609f11dfc9f5e50320802273b12f3811a67e6716ea6c"
|
||||
checksum = "3f2c3ac8e6ca1e9c80b8be1023940162bf81ae3cffbb1809474152f2ce1eb250"
|
||||
dependencies = [
|
||||
"proc-macro2 1.0.10",
|
||||
"quote 1.0.3",
|
||||
"syn 1.0.17",
|
||||
"proc-macro2 1.0.18",
|
||||
"quote 1.0.6",
|
||||
"syn 1.0.30",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "serde_json"
|
||||
version = "1.0.51"
|
||||
version = "1.0.53"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "da07b57ee2623368351e9a0488bb0b261322a15a6e0ae53e243cbdc0f4208da9"
|
||||
checksum = "993948e75b189211a9b31a7528f950c6adc21f9720b6438ff80a7fa2f864cea2"
|
||||
dependencies = [
|
||||
"itoa",
|
||||
"ryu",
|
||||
|
@ -1287,9 +1314,9 @@ dependencies = [
|
|||
|
||||
[[package]]
|
||||
name = "sha2"
|
||||
version = "0.8.1"
|
||||
version = "0.8.2"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "27044adfd2e1f077f649f59deb9490d3941d674002f7d062870a60ebe9bd47a0"
|
||||
checksum = "a256f46ea78a0c0d9ff00077504903ac881a1dafdc20da66545699e7776b3e69"
|
||||
dependencies = [
|
||||
"block-buffer",
|
||||
"digest",
|
||||
|
@ -1353,12 +1380,12 @@ dependencies = [
|
|||
|
||||
[[package]]
|
||||
name = "syn"
|
||||
version = "1.0.17"
|
||||
version = "1.0.30"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "0df0eb663f387145cab623dea85b09c2c5b4b0aef44e945d928e682fce71bb03"
|
||||
checksum = "93a56fabc59dce20fe48b6c832cc249c713e7ed88fa28b0ee0a3bfcaae5fe4e2"
|
||||
dependencies = [
|
||||
"proc-macro2 1.0.10",
|
||||
"quote 1.0.3",
|
||||
"proc-macro2 1.0.18",
|
||||
"quote 1.0.6",
|
||||
"unicode-xid 0.2.0",
|
||||
]
|
||||
|
||||
|
@ -1368,9 +1395,9 @@ version = "0.12.3"
|
|||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "67656ea1dc1b41b1451851562ea232ec2e5a80242139f7e679ceccfb5d61f545"
|
||||
dependencies = [
|
||||
"proc-macro2 1.0.10",
|
||||
"quote 1.0.3",
|
||||
"syn 1.0.17",
|
||||
"proc-macro2 1.0.18",
|
||||
"quote 1.0.6",
|
||||
"syn 1.0.30",
|
||||
"unicode-xid 0.2.0",
|
||||
]
|
||||
|
||||
|
@ -1504,21 +1531,21 @@ checksum = "b4ae116fef2b7fea257ed6440d3cfcff7f190865f170cdad00bb6465bf18ecba"
|
|||
|
||||
[[package]]
|
||||
name = "vcpkg"
|
||||
version = "0.2.8"
|
||||
version = "0.2.9"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "3fc439f2794e98976c88a2a2dafce96b930fe8010b0a256b3c2199a773933168"
|
||||
checksum = "55d1e41d56121e07f1e223db0a4def204e45c85425f6a16d462fd07c8d10d74c"
|
||||
|
||||
[[package]]
|
||||
name = "vec_map"
|
||||
version = "0.8.1"
|
||||
version = "0.8.2"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "05c78687fb1a80548ae3250346c3db86a80a7cdd77bda190189f2d0a0987c81a"
|
||||
checksum = "f1bddf1187be692e79c5ffeab891132dfb0f236ed36a43c7ed39f1165ee20191"
|
||||
|
||||
[[package]]
|
||||
name = "version_check"
|
||||
version = "0.9.1"
|
||||
version = "0.9.2"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "078775d0255232fb988e6fccf26ddc9d1ac274299aaedcedce21c6f72cc533ce"
|
||||
checksum = "b5a972e5669d67ba988ce3dc826706fb0a8b01471c088cb0b6110b805cc36aed"
|
||||
|
||||
[[package]]
|
||||
name = "void"
|
||||
|
@ -1545,9 +1572,9 @@ checksum = "cccddf32554fecc6acb585f82a32a72e28b48f8c4c1883ddfeeeaa96f7d8e519"
|
|||
|
||||
[[package]]
|
||||
name = "wasm-bindgen"
|
||||
version = "0.2.60"
|
||||
version = "0.2.63"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "2cc57ce05287f8376e998cbddfb4c8cb43b84a7ec55cf4551d7c00eef317a47f"
|
||||
checksum = "4c2dc4aa152834bc334f506c1a06b866416a8b6697d5c9f75b9a689c8486def0"
|
||||
dependencies = [
|
||||
"cfg-if",
|
||||
"wasm-bindgen-macro",
|
||||
|
@ -1555,24 +1582,24 @@ dependencies = [
|
|||
|
||||
[[package]]
|
||||
name = "wasm-bindgen-backend"
|
||||
version = "0.2.60"
|
||||
version = "0.2.63"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "d967d37bf6c16cca2973ca3af071d0a2523392e4a594548155d89a678f4237cd"
|
||||
checksum = "ded84f06e0ed21499f6184df0e0cb3494727b0c5da89534e0fcc55c51d812101"
|
||||
dependencies = [
|
||||
"bumpalo",
|
||||
"lazy_static",
|
||||
"log",
|
||||
"proc-macro2 1.0.10",
|
||||
"quote 1.0.3",
|
||||
"syn 1.0.17",
|
||||
"proc-macro2 1.0.18",
|
||||
"quote 1.0.6",
|
||||
"syn 1.0.30",
|
||||
"wasm-bindgen-shared",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "wasm-bindgen-futures"
|
||||
version = "0.4.10"
|
||||
version = "0.4.13"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "7add542ea1ac7fdaa9dc25e031a6af33b7d63376292bd24140c637d00d1c312a"
|
||||
checksum = "64487204d863f109eb77e8462189d111f27cb5712cc9fdb3461297a76963a2f6"
|
||||
dependencies = [
|
||||
"cfg-if",
|
||||
"js-sys",
|
||||
|
@ -1582,38 +1609,38 @@ dependencies = [
|
|||
|
||||
[[package]]
|
||||
name = "wasm-bindgen-macro"
|
||||
version = "0.2.60"
|
||||
version = "0.2.63"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "8bd151b63e1ea881bb742cd20e1d6127cef28399558f3b5d415289bc41eee3a4"
|
||||
checksum = "838e423688dac18d73e31edce74ddfac468e37b1506ad163ffaf0a46f703ffe3"
|
||||
dependencies = [
|
||||
"quote 1.0.3",
|
||||
"quote 1.0.6",
|
||||
"wasm-bindgen-macro-support",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "wasm-bindgen-macro-support"
|
||||
version = "0.2.60"
|
||||
version = "0.2.63"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "d68a5b36eef1be7868f668632863292e37739656a80fc4b9acec7b0bd35a4931"
|
||||
checksum = "3156052d8ec77142051a533cdd686cba889537b213f948cd1d20869926e68e92"
|
||||
dependencies = [
|
||||
"proc-macro2 1.0.10",
|
||||
"quote 1.0.3",
|
||||
"syn 1.0.17",
|
||||
"proc-macro2 1.0.18",
|
||||
"quote 1.0.6",
|
||||
"syn 1.0.30",
|
||||
"wasm-bindgen-backend",
|
||||
"wasm-bindgen-shared",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "wasm-bindgen-shared"
|
||||
version = "0.2.60"
|
||||
version = "0.2.63"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "daf76fe7d25ac79748a37538b7daeed1c7a6867c92d3245c12c6222e4a20d639"
|
||||
checksum = "c9ba19973a58daf4db6f352eda73dc0e289493cd29fb2632eb172085b6521acd"
|
||||
|
||||
[[package]]
|
||||
name = "wasm-bindgen-test"
|
||||
version = "0.3.10"
|
||||
version = "0.3.13"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "648da3460c6d2aa04b715a936329e2e311180efe650b2127d6267f4193ccac14"
|
||||
checksum = "0f0dfda4d3b3f8acbc3c291b09208081c203af457fb14a229783b06e2f128aa7"
|
||||
dependencies = [
|
||||
"console_error_panic_hook",
|
||||
"js-sys",
|
||||
|
@ -1625,19 +1652,19 @@ dependencies = [
|
|||
|
||||
[[package]]
|
||||
name = "wasm-bindgen-test-macro"
|
||||
version = "0.3.10"
|
||||
version = "0.3.13"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "cf2f86cd78a2aa7b1fb4bb6ed854eccb7f9263089c79542dca1576a1518a8467"
|
||||
checksum = "2c2e18093f11c19ca4e188c177fecc7c372304c311189f12c2f9bea5b7324ac7"
|
||||
dependencies = [
|
||||
"proc-macro2 1.0.10",
|
||||
"quote 1.0.3",
|
||||
"proc-macro2 1.0.18",
|
||||
"quote 1.0.6",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "web-sys"
|
||||
version = "0.3.37"
|
||||
version = "0.3.40"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "2d6f51648d8c56c366144378a33290049eafdd784071077f6fe37dae64c1c4cb"
|
||||
checksum = "7b72fe77fd39e4bd3eaa4412fd299a0be6b3dfe9d2597e2f1c20beb968f41d17"
|
||||
dependencies = [
|
||||
"js-sys",
|
||||
"wasm-bindgen",
|
||||
|
@ -1687,7 +1714,7 @@ dependencies = [
|
|||
|
||||
[[package]]
|
||||
name = "zokrates_cli"
|
||||
version = "0.5.2"
|
||||
version = "0.5.3"
|
||||
dependencies = [
|
||||
"assert_cli",
|
||||
"bincode",
|
||||
|
@ -1709,7 +1736,7 @@ version = "0.1.0"
|
|||
|
||||
[[package]]
|
||||
name = "zokrates_core"
|
||||
version = "0.4.2"
|
||||
version = "0.4.3"
|
||||
dependencies = [
|
||||
"assert_cli",
|
||||
"bellman_ce",
|
||||
|
@ -1742,7 +1769,7 @@ dependencies = [
|
|||
|
||||
[[package]]
|
||||
name = "zokrates_core_test"
|
||||
version = "0.1.1"
|
||||
version = "0.1.2"
|
||||
dependencies = [
|
||||
"fs_extra",
|
||||
"zokrates_test",
|
||||
|
@ -1758,16 +1785,14 @@ dependencies = [
|
|||
|
||||
[[package]]
|
||||
name = "zokrates_field"
|
||||
version = "0.3.5"
|
||||
version = "0.3.6"
|
||||
dependencies = [
|
||||
"bellman_ce",
|
||||
"bincode",
|
||||
"ff_ce 0.9.0",
|
||||
"lazy_static",
|
||||
"num-bigint 0.2.6",
|
||||
"num-integer",
|
||||
"num-traits 0.2.11",
|
||||
"pairing_ce",
|
||||
"rand 0.4.6",
|
||||
"serde",
|
||||
"serde_derive",
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
[package]
|
||||
name = "zokrates_cli"
|
||||
version = "0.5.2"
|
||||
version = "0.5.3"
|
||||
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"
|
||||
edition = "2018"
|
||||
|
|
|
@ -222,8 +222,10 @@ fn cli_compute<T: Field>(ir_prog: ir::Prog<T>, sub_matches: &ArgMatches) -> Resu
|
|||
}
|
||||
.map_err(|e| format!("Could not parse argument: {}", e))?;
|
||||
|
||||
let witness = ir_prog
|
||||
.execute(&arguments.encode())
|
||||
let interpreter = ir::Interpreter::default();
|
||||
|
||||
let witness = interpreter
|
||||
.execute(&ir_prog, &arguments.encode())
|
||||
.map_err(|e| format!("Execution failed: {}", e))?;
|
||||
|
||||
use zokrates_abi::Decode;
|
||||
|
@ -956,9 +958,10 @@ mod tests {
|
|||
let artifacts: CompilationArtifacts<Bn128Field> =
|
||||
compile(source, path, Some(&resolver)).unwrap();
|
||||
|
||||
let _ = artifacts
|
||||
.prog()
|
||||
.execute(&vec![Bn128Field::from(0)])
|
||||
let interpreter = ir::Interpreter::default();
|
||||
|
||||
let _ = interpreter
|
||||
.execute(&artifacts.prog(), &vec![Bn128Field::from(0)])
|
||||
.unwrap();
|
||||
}
|
||||
}
|
||||
|
@ -984,9 +987,10 @@ mod tests {
|
|||
let artifacts: CompilationArtifacts<Bn128Field> =
|
||||
compile(source, path, Some(&resolver)).unwrap();
|
||||
|
||||
let _ = artifacts
|
||||
.prog()
|
||||
.execute(&vec![Bn128Field::from(0)])
|
||||
let interpreter = ir::Interpreter::default();
|
||||
|
||||
let _ = interpreter
|
||||
.execute(&artifacts.prog(), &vec![Bn128Field::from(0)])
|
||||
.unwrap();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
[package]
|
||||
name = "zokrates_core"
|
||||
version = "0.4.2"
|
||||
version = "0.4.3"
|
||||
authors = ["Jacob Eberhardt <jacob.eberhardt@tu-berlin.de>", "Dennis Kuhnert <mail@kyroy.com>"]
|
||||
repository = "https://github.com/JacobEberhardt/ZoKrates"
|
||||
readme = "README.md"
|
||||
|
@ -27,14 +27,14 @@ bincode = "0.8.0"
|
|||
hex = "0.4.2"
|
||||
regex = "0.2"
|
||||
pairing_ce = "^0.21"
|
||||
ff_ce = "0.9"
|
||||
ff_ce = "^0.9"
|
||||
zokrates_field = { version = "0.3.0", path = "../zokrates_field" }
|
||||
zokrates_pest_ast = { version = "0.1.0", path = "../zokrates_pest_ast" }
|
||||
zokrates_embed = { path = "../zokrates_embed" }
|
||||
zokrates_common = { path = "../zokrates_common" }
|
||||
rand = "0.4"
|
||||
csv = "1"
|
||||
bellman_ce = { version = "^0.3", default-features = false}
|
||||
bellman_ce = { version = "^0.3", default-features = false }
|
||||
|
||||
[dev-dependencies]
|
||||
glob = "0.2.11"
|
||||
|
|
|
@ -330,6 +330,7 @@ mod tests {
|
|||
#[cfg(test)]
|
||||
mod sha256 {
|
||||
use super::*;
|
||||
use ir::Interpreter;
|
||||
|
||||
#[test]
|
||||
fn generate_sha256_constraints() {
|
||||
|
@ -402,7 +403,9 @@ mod tests {
|
|||
.map(|i| Bn128Field::from(i))
|
||||
.collect();
|
||||
|
||||
prog.execute(&input).unwrap();
|
||||
let interpreter = Interpreter::default();
|
||||
|
||||
interpreter.execute(&prog, &input).unwrap();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -118,6 +118,108 @@ impl<'ast, T: Field> Flattener<'ast, T> {
|
|||
}
|
||||
}
|
||||
|
||||
// Let's assume b = [1, 1, 1, 0]
|
||||
//
|
||||
// 1. Init `sizeUnknown = true`
|
||||
// As long as `sizeUnknown` is `true` we don't yet know if a is <= than b.
|
||||
// 2. Loop over `b`:
|
||||
// * b[0] = 1
|
||||
// when `b` is 1 we check wether `a` is 0 in that particular run and update
|
||||
// `sizeUnknown` accordingly:
|
||||
// `sizeUnknown = sizeUnknown && a[0]`
|
||||
// * b[1] = 1
|
||||
// `sizrUnknown = sizeUnknown && a[1]`
|
||||
// * b[2] = 1
|
||||
// `sizeUnknown = sizeUnknown && a[2]`
|
||||
// * b[3] = 0
|
||||
// we need to enforce that `a` is 0 in case `sizeUnknown`is still `true`,
|
||||
// otherwise `a` can be {0,1}:
|
||||
// `true == (!sizeUnknown || !a[3])`
|
||||
// ```
|
||||
// **true => a -> 0
|
||||
// sizeUnkown *
|
||||
// **false => a -> {0,1}
|
||||
// ```
|
||||
fn strict_le_check(
|
||||
&mut self,
|
||||
statements_flattened: &mut Vec<FlatStatement<T>>,
|
||||
b: &[bool],
|
||||
a: Vec<FlatVariable>,
|
||||
) {
|
||||
let len = b.len();
|
||||
assert_eq!(a.len(), T::get_required_bits());
|
||||
assert_eq!(a.len(), b.len());
|
||||
|
||||
let mut is_not_smaller_run = vec![];
|
||||
let mut size_unknown = vec![];
|
||||
|
||||
for _ in 0..len {
|
||||
is_not_smaller_run.push(self.use_sym());
|
||||
size_unknown.push(self.use_sym());
|
||||
}
|
||||
|
||||
// init size_unknown = true
|
||||
statements_flattened.push(FlatStatement::Definition(
|
||||
size_unknown[0],
|
||||
FlatExpression::Number(T::from(1)),
|
||||
));
|
||||
|
||||
for (i, b) in b.iter().enumerate() {
|
||||
if *b {
|
||||
statements_flattened.push(FlatStatement::Definition(
|
||||
is_not_smaller_run[i],
|
||||
a[i].clone().into(),
|
||||
));
|
||||
|
||||
// don't need to update size_unknown in the last round
|
||||
if i < len - 1 {
|
||||
statements_flattened.push(FlatStatement::Definition(
|
||||
size_unknown[i + 1],
|
||||
FlatExpression::Mult(
|
||||
box size_unknown[i].into(),
|
||||
box is_not_smaller_run[i].into(),
|
||||
),
|
||||
));
|
||||
}
|
||||
} else {
|
||||
// don't need to update size_unknown in the last round
|
||||
if i < len - 1 {
|
||||
statements_flattened.push(
|
||||
// sizeUnknown is not changing in this case
|
||||
// We sill have to assign the old value to the variable of the current run
|
||||
// This trivial definition will later be removed by the optimiser
|
||||
FlatStatement::Definition(
|
||||
size_unknown[i + 1].into(),
|
||||
size_unknown[i].into(),
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
let or_left = FlatExpression::Sub(
|
||||
box FlatExpression::Number(T::from(1)),
|
||||
box size_unknown[i].clone().into(),
|
||||
);
|
||||
let or_right: FlatExpression<_> = FlatExpression::Sub(
|
||||
box FlatExpression::Number(T::from(1)),
|
||||
box a[i].clone().into(),
|
||||
);
|
||||
|
||||
let and_name = self.use_sym();
|
||||
let and = FlatExpression::Mult(box or_left.clone(), box or_right.clone());
|
||||
statements_flattened.push(FlatStatement::Definition(and_name, and));
|
||||
let or = FlatExpression::Sub(
|
||||
box FlatExpression::Add(box or_left, box or_right),
|
||||
box and_name.into(),
|
||||
);
|
||||
|
||||
statements_flattened.push(FlatStatement::Condition(
|
||||
FlatExpression::Number(T::from(1)),
|
||||
or,
|
||||
));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// Flatten an if/else expression
|
||||
///
|
||||
/// # Arguments
|
||||
|
@ -708,6 +810,13 @@ impl<'ast, T: Field> Flattener<'ast, T> {
|
|||
));
|
||||
}
|
||||
|
||||
// check that the decomposition is in the field with a strict `< p` checks
|
||||
self.strict_le_check(
|
||||
statements_flattened,
|
||||
&T::max_value_bit_vector_be(),
|
||||
sub_bits_be.clone(),
|
||||
);
|
||||
|
||||
// sum(sym_b{i} * 2**i)
|
||||
let mut expr = FlatExpression::Number(T::from(0));
|
||||
|
||||
|
|
|
@ -1,16 +1,42 @@
|
|||
use crate::flat_absy::flat_variable::FlatVariable;
|
||||
use crate::ir::{LinComb, Prog, QuadComb, Statement, Witness};
|
||||
use crate::solvers::Executable;
|
||||
use ir::Directive;
|
||||
use solvers::Solver;
|
||||
use std::collections::BTreeMap;
|
||||
use std::fmt;
|
||||
use zokrates_embed::generate_sha256_round_witness;
|
||||
use zokrates_field::Field;
|
||||
|
||||
pub type ExecutionResult<T> = Result<Witness<T>, Error>;
|
||||
|
||||
impl<T: Field> Prog<T> {
|
||||
pub fn execute(&self, inputs: &Vec<T>) -> ExecutionResult<T> {
|
||||
let main = &self.main;
|
||||
self.check_inputs(&inputs)?;
|
||||
impl<T: Field> Prog<T> {}
|
||||
|
||||
pub struct Interpreter {
|
||||
/// Whether we should try to give out-of-range bit decompositions when the input is not a single summand.
|
||||
/// Used to do targetted testing of `<` flattening, making sure the bit decomposition we base the result on is unique.
|
||||
should_try_out_of_range: bool,
|
||||
}
|
||||
|
||||
impl Default for Interpreter {
|
||||
fn default() -> Interpreter {
|
||||
Interpreter {
|
||||
should_try_out_of_range: false,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
impl Interpreter {
|
||||
pub fn try_out_of_range() -> Interpreter {
|
||||
Interpreter {
|
||||
should_try_out_of_range: true,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
impl Interpreter {
|
||||
pub fn execute<T: Field>(&self, program: &Prog<T>, inputs: &Vec<T>) -> ExecutionResult<T> {
|
||||
let main = &program.main;
|
||||
self.check_inputs(&program, &inputs)?;
|
||||
let mut witness = BTreeMap::new();
|
||||
witness.insert(FlatVariable::one(), T::one());
|
||||
for (arg, value) in main.arguments.iter().zip(inputs.iter()) {
|
||||
|
@ -36,20 +62,29 @@ impl<T: Field> Prog<T> {
|
|||
}
|
||||
},
|
||||
Statement::Directive(ref d) => {
|
||||
let input_values: Vec<T> = d
|
||||
.inputs
|
||||
.iter()
|
||||
.map(|i| i.evaluate(&witness).unwrap())
|
||||
.collect();
|
||||
match d.solver.execute(&input_values) {
|
||||
Ok(res) => {
|
||||
for (i, o) in d.outputs.iter().enumerate() {
|
||||
witness.insert(o.clone(), res[i].clone());
|
||||
}
|
||||
continue;
|
||||
match (&d.solver, &d.inputs, self.should_try_out_of_range) {
|
||||
(Solver::Bits(bitwidth), inputs, true)
|
||||
if inputs[0].0.len() > 1 && *bitwidth == T::get_required_bits() =>
|
||||
{
|
||||
Self::try_solve_out_of_range(&d, &mut witness)
|
||||
}
|
||||
Err(_) => return Err(Error::Solver),
|
||||
};
|
||||
_ => {
|
||||
let inputs: Vec<_> = d
|
||||
.inputs
|
||||
.iter()
|
||||
.map(|i| i.evaluate(&witness).unwrap())
|
||||
.collect();
|
||||
match self.execute_solver(&d.solver, &inputs) {
|
||||
Ok(res) => {
|
||||
for (i, o) in d.outputs.iter().enumerate() {
|
||||
witness.insert(o.clone(), res[i].clone());
|
||||
}
|
||||
continue;
|
||||
}
|
||||
Err(_) => return Err(Error::Solver),
|
||||
};
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -57,16 +92,90 @@ impl<T: Field> Prog<T> {
|
|||
Ok(Witness(witness))
|
||||
}
|
||||
|
||||
fn check_inputs<U>(&self, inputs: &Vec<U>) -> Result<(), Error> {
|
||||
if self.main.arguments.len() == inputs.len() {
|
||||
fn try_solve_out_of_range<T: Field>(d: &Directive<T>, witness: &mut BTreeMap<FlatVariable, T>) {
|
||||
use num::traits::Pow;
|
||||
|
||||
// we target the `2a - 2b` part of the `<` check by only returning out-of-range results
|
||||
// when the input is not a single summand
|
||||
let value = d.inputs[0].evaluate(&witness).unwrap();
|
||||
let candidate = value.to_biguint() + T::max_value().to_biguint() + T::from(1).to_biguint();
|
||||
let input = if candidate < T::from(2).to_biguint().pow(T::get_required_bits()) {
|
||||
candidate
|
||||
} else {
|
||||
value.to_biguint()
|
||||
};
|
||||
|
||||
let mut num = input.clone();
|
||||
let mut res = vec![];
|
||||
let bits = T::get_required_bits();
|
||||
for i in (0..bits).rev() {
|
||||
if T::from(2).to_biguint().pow(i as usize) <= num {
|
||||
num = num - T::from(2).to_biguint().pow(i as usize);
|
||||
res.push(T::one());
|
||||
} else {
|
||||
res.push(T::zero());
|
||||
}
|
||||
}
|
||||
assert_eq!(num, T::zero().to_biguint());
|
||||
for (i, o) in d.outputs.iter().enumerate() {
|
||||
witness.insert(o.clone(), res[i].clone());
|
||||
}
|
||||
}
|
||||
|
||||
fn check_inputs<T: Field, U>(&self, program: &Prog<T>, inputs: &Vec<U>) -> Result<(), Error> {
|
||||
if program.main.arguments.len() == inputs.len() {
|
||||
Ok(())
|
||||
} else {
|
||||
Err(Error::WrongInputCount {
|
||||
expected: self.main.arguments.len(),
|
||||
expected: program.main.arguments.len(),
|
||||
received: inputs.len(),
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
fn execute_solver<T: Field>(&self, s: &Solver, inputs: &Vec<T>) -> Result<Vec<T>, String> {
|
||||
use solvers::Signed;
|
||||
let (expected_input_count, expected_output_count) = s.get_signature();
|
||||
assert!(inputs.len() == expected_input_count);
|
||||
|
||||
let res = match s {
|
||||
Solver::ConditionEq => match inputs[0].is_zero() {
|
||||
true => vec![T::zero(), T::one()],
|
||||
false => vec![T::one(), T::one() / inputs[0].clone()],
|
||||
},
|
||||
Solver::Bits(bit_width) => {
|
||||
let mut num = inputs[0].clone();
|
||||
let mut res = vec![];
|
||||
|
||||
for i in (0..*bit_width).rev() {
|
||||
if T::from(2).pow(i) <= num {
|
||||
num = num - T::from(2).pow(i);
|
||||
res.push(T::one());
|
||||
} else {
|
||||
res.push(T::zero());
|
||||
}
|
||||
}
|
||||
assert_eq!(num, T::zero());
|
||||
res
|
||||
}
|
||||
Solver::Div => vec![inputs[0].clone() / inputs[1].clone()],
|
||||
Solver::Sha256Round => {
|
||||
let i = &inputs[0..512];
|
||||
let h = &inputs[512..];
|
||||
let i: Vec<_> = i.iter().map(|x| x.clone().into_bellman()).collect();
|
||||
let h: Vec<_> = h.iter().map(|x| x.clone().into_bellman()).collect();
|
||||
assert!(h.len() == 256);
|
||||
generate_sha256_round_witness::<T::BellmanEngine>(&i, &h)
|
||||
.into_iter()
|
||||
.map(|x| T::from_bellman(x))
|
||||
.collect()
|
||||
}
|
||||
};
|
||||
|
||||
assert_eq!(res.len(), expected_output_count);
|
||||
|
||||
Ok(res)
|
||||
}
|
||||
}
|
||||
|
||||
impl<T: Field> LinComb<T> {
|
||||
|
@ -125,3 +234,77 @@ impl fmt::Debug for Error {
|
|||
write!(f, "{}", self)
|
||||
}
|
||||
}
|
||||
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
use super::*;
|
||||
use zokrates_field::Bn128Field;
|
||||
|
||||
mod eq_condition {
|
||||
|
||||
// Wanted: (Y = (X != 0) ? 1 : 0)
|
||||
// # Y = if X == 0 then 0 else 1 fi
|
||||
// # M = if X == 0 then 1 else 1/X fi
|
||||
|
||||
use super::*;
|
||||
|
||||
#[test]
|
||||
fn execute() {
|
||||
let cond_eq = Solver::ConditionEq;
|
||||
let inputs = vec![0];
|
||||
let interpreter = Interpreter::default();
|
||||
let r = interpreter
|
||||
.execute_solver(
|
||||
&cond_eq,
|
||||
&inputs.iter().map(|&i| Bn128Field::from(i)).collect(),
|
||||
)
|
||||
.unwrap();
|
||||
let res: Vec<Bn128Field> = vec![0, 1].iter().map(|&i| Bn128Field::from(i)).collect();
|
||||
assert_eq!(r, &res[..]);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn execute_non_eq() {
|
||||
let cond_eq = Solver::ConditionEq;
|
||||
let inputs = vec![1];
|
||||
let interpreter = Interpreter::default();
|
||||
let r = interpreter
|
||||
.execute_solver(
|
||||
&cond_eq,
|
||||
&inputs.iter().map(|&i| Bn128Field::from(i)).collect(),
|
||||
)
|
||||
.unwrap();
|
||||
let res: Vec<Bn128Field> = vec![1, 1].iter().map(|&i| Bn128Field::from(i)).collect();
|
||||
assert_eq!(r, &res[..]);
|
||||
}
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn bits_of_one() {
|
||||
let inputs = vec![Bn128Field::from(1)];
|
||||
let interpreter = Interpreter::default();
|
||||
let res = interpreter
|
||||
.execute_solver(&Solver::Bits(Bn128Field::get_required_bits()), &inputs)
|
||||
.unwrap();
|
||||
assert_eq!(res[253], Bn128Field::from(1));
|
||||
for i in 0..253 {
|
||||
assert_eq!(res[i], Bn128Field::from(0));
|
||||
}
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn bits_of_42() {
|
||||
let inputs = vec![Bn128Field::from(42)];
|
||||
let interpreter = Interpreter::default();
|
||||
let res = interpreter
|
||||
.execute_solver(&Solver::Bits(Bn128Field::get_required_bits()), &inputs)
|
||||
.unwrap();
|
||||
assert_eq!(res[253], Bn128Field::from(0));
|
||||
assert_eq!(res[252], Bn128Field::from(1));
|
||||
assert_eq!(res[251], Bn128Field::from(0));
|
||||
assert_eq!(res[250], Bn128Field::from(1));
|
||||
assert_eq!(res[249], Bn128Field::from(0));
|
||||
assert_eq!(res[248], Bn128Field::from(1));
|
||||
assert_eq!(res[247], Bn128Field::from(0));
|
||||
}
|
||||
}
|
||||
|
|
|
@ -15,7 +15,7 @@ pub use self::expression::QuadComb;
|
|||
pub use self::expression::{CanonicalLinComb, LinComb};
|
||||
pub use self::serialize::ProgEnum;
|
||||
|
||||
pub use self::interpreter::{Error, ExecutionResult};
|
||||
pub use self::interpreter::{Error, ExecutionResult, Interpreter};
|
||||
pub use self::witness::Witness;
|
||||
|
||||
#[derive(Debug, Serialize, Deserialize, Clone, Hash)]
|
||||
|
|
|
@ -347,7 +347,7 @@ contract Verifier {
|
|||
#[cfg(test)]
|
||||
mod tests {
|
||||
use crate::flat_absy::FlatVariable;
|
||||
use crate::ir::{Function, Prog, Statement};
|
||||
use crate::ir::{Function, Interpreter, Prog, Statement};
|
||||
|
||||
use super::*;
|
||||
use zokrates_field::Bn128Field;
|
||||
|
@ -368,12 +368,14 @@ mod tests {
|
|||
};
|
||||
|
||||
let keypair = G16::setup(program.clone());
|
||||
let witness = program
|
||||
.clone()
|
||||
.execute(&vec![Bn128Field::from(42)])
|
||||
|
||||
let interpreter = Interpreter::default();
|
||||
|
||||
let witness = interpreter
|
||||
.execute(&program, &vec![Bn128Field::from(42)])
|
||||
.unwrap();
|
||||
|
||||
let proof = G16::generate_proof(program.clone(), witness, keypair.pk);
|
||||
let proof = G16::generate_proof(program, witness, keypair.pk);
|
||||
let ans = <G16 as ProofSystem<Bn128Field>>::verify(keypair.vk, proof);
|
||||
|
||||
assert!(ans);
|
||||
|
|
|
@ -284,6 +284,7 @@ mod parse {
|
|||
mod tests {
|
||||
use super::*;
|
||||
use crate::ir::{Function, LinComb};
|
||||
use ir::Interpreter;
|
||||
use zokrates_field::Bn128Field;
|
||||
|
||||
mod prove {
|
||||
|
@ -301,7 +302,9 @@ mod tests {
|
|||
private: vec![],
|
||||
};
|
||||
|
||||
let witness = program.clone().execute(&vec![]).unwrap();
|
||||
let interpreter = Interpreter::default();
|
||||
|
||||
let witness = interpreter.execute(&program, &vec![]).unwrap();
|
||||
let computation = Computation::with_witness(program, witness);
|
||||
|
||||
let params = computation.clone().setup();
|
||||
|
@ -323,7 +326,12 @@ mod tests {
|
|||
private: vec![true],
|
||||
};
|
||||
|
||||
let witness = program.clone().execute(&vec![Bn128Field::from(0)]).unwrap();
|
||||
let interpreter = Interpreter::default();
|
||||
|
||||
let witness = interpreter
|
||||
.execute(&program, &vec![Bn128Field::from(0)])
|
||||
.unwrap();
|
||||
|
||||
let computation = Computation::with_witness(program, witness);
|
||||
|
||||
let params = computation.clone().setup();
|
||||
|
@ -345,7 +353,12 @@ mod tests {
|
|||
private: vec![false],
|
||||
};
|
||||
|
||||
let witness = program.clone().execute(&vec![Bn128Field::from(0)]).unwrap();
|
||||
let interpreter = Interpreter::default();
|
||||
|
||||
let witness = interpreter
|
||||
.execute(&program, &vec![Bn128Field::from(0)])
|
||||
.unwrap();
|
||||
|
||||
let computation = Computation::with_witness(program, witness);
|
||||
|
||||
let params = computation.clone().setup();
|
||||
|
@ -367,7 +380,9 @@ mod tests {
|
|||
private: vec![],
|
||||
};
|
||||
|
||||
let witness = program.clone().execute(&vec![]).unwrap();
|
||||
let interpreter = Interpreter::default();
|
||||
|
||||
let witness = interpreter.execute(&program, &vec![]).unwrap();
|
||||
let computation = Computation::with_witness(program, witness);
|
||||
|
||||
let params = computation.clone().setup();
|
||||
|
@ -401,9 +416,10 @@ mod tests {
|
|||
private: vec![true, false],
|
||||
};
|
||||
|
||||
let witness = program
|
||||
.clone()
|
||||
.execute(&vec![Bn128Field::from(3), Bn128Field::from(4)])
|
||||
let interpreter = Interpreter::default();
|
||||
|
||||
let witness = interpreter
|
||||
.execute(&program, &vec![Bn128Field::from(3), Bn128Field::from(4)])
|
||||
.unwrap();
|
||||
let computation = Computation::with_witness(program, witness);
|
||||
|
||||
|
@ -426,7 +442,12 @@ mod tests {
|
|||
private: vec![false],
|
||||
};
|
||||
|
||||
let witness = program.clone().execute(&vec![Bn128Field::from(3)]).unwrap();
|
||||
let interpreter = Interpreter::default();
|
||||
|
||||
let witness = interpreter
|
||||
.execute(&program, &vec![Bn128Field::from(3)])
|
||||
.unwrap();
|
||||
|
||||
let computation = Computation::with_witness(program, witness);
|
||||
|
||||
let params = computation.clone().setup();
|
||||
|
@ -450,9 +471,10 @@ mod tests {
|
|||
private: vec![true, false],
|
||||
};
|
||||
|
||||
let witness = program
|
||||
.clone()
|
||||
.execute(&vec![Bn128Field::from(3), Bn128Field::from(4)])
|
||||
let interpreter = Interpreter::default();
|
||||
|
||||
let witness = interpreter
|
||||
.execute(&program, &vec![Bn128Field::from(3), Bn128Field::from(4)])
|
||||
.unwrap();
|
||||
let computation = Computation::with_witness(program, witness);
|
||||
|
||||
|
|
|
@ -1,5 +1,4 @@
|
|||
use std::fmt;
|
||||
use zokrates_embed::generate_sha256_round_witness;
|
||||
use zokrates_field::Field;
|
||||
|
||||
#[derive(Clone, PartialEq, Debug, Serialize, Deserialize, Hash, Eq)]
|
||||
|
@ -27,51 +26,6 @@ impl Signed for Solver {
|
|||
}
|
||||
}
|
||||
|
||||
impl<T: Field> Executable<T> for Solver {
|
||||
fn execute(&self, inputs: &Vec<T>) -> Result<Vec<T>, String> {
|
||||
let (expected_input_count, expected_output_count) = self.get_signature();
|
||||
assert!(inputs.len() == expected_input_count);
|
||||
|
||||
let res = match self {
|
||||
Solver::ConditionEq => match inputs[0].is_zero() {
|
||||
true => vec![T::zero(), T::one()],
|
||||
false => vec![T::one(), T::one() / inputs[0].clone()],
|
||||
},
|
||||
Solver::Bits(bit_width) => {
|
||||
let mut num = inputs[0].clone();
|
||||
let mut res = vec![];
|
||||
|
||||
for i in (0..*bit_width).rev() {
|
||||
if T::from(2).pow(i) <= num {
|
||||
num = num - T::from(2).pow(i);
|
||||
res.push(T::one());
|
||||
} else {
|
||||
res.push(T::zero());
|
||||
}
|
||||
}
|
||||
assert_eq!(num, T::zero());
|
||||
res
|
||||
}
|
||||
Solver::Div => vec![inputs[0].clone() / inputs[1].clone()],
|
||||
Solver::Sha256Round => {
|
||||
let i = &inputs[0..512];
|
||||
let h = &inputs[512..];
|
||||
let i: Vec<_> = i.iter().map(|x| x.clone().into_bellman()).collect();
|
||||
let h: Vec<_> = h.iter().map(|x| x.clone().into_bellman()).collect();
|
||||
assert!(h.len() == 256);
|
||||
generate_sha256_round_witness::<T::BellmanEngine>(&i, &h)
|
||||
.into_iter()
|
||||
.map(|x| T::from_bellman(x))
|
||||
.collect()
|
||||
}
|
||||
};
|
||||
|
||||
assert_eq!(res.len(), expected_output_count);
|
||||
|
||||
Ok(res)
|
||||
}
|
||||
}
|
||||
|
||||
impl Solver {
|
||||
pub fn bits(width: usize) -> Self {
|
||||
Solver::Bits(width)
|
||||
|
@ -85,67 +39,3 @@ pub trait Executable<T: Field>: Signed {
|
|||
pub trait Signed {
|
||||
fn get_signature(&self) -> (usize, usize);
|
||||
}
|
||||
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
use super::*;
|
||||
use zokrates_field::Bn128Field;
|
||||
|
||||
mod eq_condition {
|
||||
|
||||
// Wanted: (Y = (X != 0) ? 1 : 0)
|
||||
// # Y = if X == 0 then 0 else 1 fi
|
||||
// # M = if X == 0 then 1 else 1/X fi
|
||||
|
||||
use super::*;
|
||||
|
||||
#[test]
|
||||
fn execute() {
|
||||
let cond_eq = Solver::ConditionEq;
|
||||
let inputs = vec![0];
|
||||
let r = cond_eq
|
||||
.execute(&inputs.iter().map(|&i| Bn128Field::from(i)).collect())
|
||||
.unwrap();
|
||||
let res: Vec<Bn128Field> = vec![0, 1].iter().map(|&i| Bn128Field::from(i)).collect();
|
||||
assert_eq!(r, &res[..]);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn execute_non_eq() {
|
||||
let cond_eq = Solver::ConditionEq;
|
||||
let inputs = vec![1];
|
||||
let r = cond_eq
|
||||
.execute(&inputs.iter().map(|&i| Bn128Field::from(i)).collect())
|
||||
.unwrap();
|
||||
let res: Vec<Bn128Field> = vec![1, 1].iter().map(|&i| Bn128Field::from(i)).collect();
|
||||
assert_eq!(r, &res[..]);
|
||||
}
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn bits_of_one() {
|
||||
let inputs = vec![Bn128Field::from(1)];
|
||||
let res = Solver::Bits(Bn128Field::get_required_bits())
|
||||
.execute(&inputs)
|
||||
.unwrap();
|
||||
assert_eq!(res[253], Bn128Field::from(1));
|
||||
for i in 0..252 {
|
||||
assert_eq!(res[i], Bn128Field::from(0));
|
||||
}
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn bits_of_42() {
|
||||
let inputs = vec![Bn128Field::from(42)];
|
||||
let res = Solver::Bits(Bn128Field::get_required_bits())
|
||||
.execute(&inputs)
|
||||
.unwrap();
|
||||
assert_eq!(res[253], Bn128Field::from(0));
|
||||
assert_eq!(res[252], Bn128Field::from(1));
|
||||
assert_eq!(res[251], Bn128Field::from(0));
|
||||
assert_eq!(res[250], Bn128Field::from(1));
|
||||
assert_eq!(res[249], Bn128Field::from(0));
|
||||
assert_eq!(res[248], Bn128Field::from(1));
|
||||
assert_eq!(res[247], Bn128Field::from(0));
|
||||
}
|
||||
}
|
||||
|
|
39
zokrates_core/tests/out_of_range.rs
Normal file
39
zokrates_core/tests/out_of_range.rs
Normal file
|
@ -0,0 +1,39 @@
|
|||
extern crate zokrates_common;
|
||||
extern crate zokrates_core;
|
||||
extern crate zokrates_field;
|
||||
|
||||
use std::io;
|
||||
use zokrates_common::Resolver;
|
||||
use zokrates_core::{
|
||||
compile::{compile, CompilationArtifacts},
|
||||
ir::Interpreter,
|
||||
};
|
||||
use zokrates_field::Bn128Field;
|
||||
|
||||
#[test]
|
||||
fn out_of_range() {
|
||||
let source = r#"
|
||||
def main(private field a) -> (field):
|
||||
field x = if a < 5555 then 3333 else 4444 fi
|
||||
x == 3333
|
||||
return 1
|
||||
"#
|
||||
.to_string();
|
||||
|
||||
// let's try to prove that "10000 < 5555" is true by exploiting
|
||||
// the fact that `2*10000 - 2*5555` has two distinct bit decompositions
|
||||
// we chose the one which is out of range, ie the sum check features an overflow
|
||||
|
||||
let res: CompilationArtifacts<Bn128Field> = compile(
|
||||
source,
|
||||
"./path/to/file".into(),
|
||||
None::<&dyn Resolver<io::Error>>,
|
||||
)
|
||||
.unwrap();
|
||||
|
||||
let interpreter = Interpreter::try_out_of_range();
|
||||
|
||||
assert!(interpreter
|
||||
.execute(&res.prog(), &vec![Bn128Field::from(10000)])
|
||||
.is_err());
|
||||
}
|
|
@ -5,7 +5,7 @@ extern crate zokrates_core;
|
|||
extern crate zokrates_field;
|
||||
use wasm_bindgen_test::*;
|
||||
use zokrates_core::flat_absy::FlatVariable;
|
||||
use zokrates_core::ir::{Function, Prog, Statement};
|
||||
use zokrates_core::ir::{Function, Interpreter, Prog, Statement};
|
||||
use zokrates_core::proof_system::ProofSystem;
|
||||
use zokrates_field::Bn128Field;
|
||||
|
||||
|
@ -26,9 +26,10 @@ fn generate_proof() {
|
|||
private: vec![false],
|
||||
};
|
||||
|
||||
let witness = program
|
||||
.clone()
|
||||
.execute(&vec![Bn128Field::from(42)])
|
||||
let interpreter = Interpreter::default();
|
||||
|
||||
let witness = interpreter
|
||||
.execute(&program, &vec![Bn128Field::from(42)])
|
||||
.unwrap();
|
||||
|
||||
let keys = G16::setup(program.clone());
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
[package]
|
||||
name = "zokrates_core_test"
|
||||
version = "0.1.1"
|
||||
version = "0.1.2"
|
||||
authors = ["schaeff <thibaut@schaeff.fr>"]
|
||||
edition = "2018"
|
||||
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
[package]
|
||||
name = "zokrates_field"
|
||||
version = "0.3.5"
|
||||
version = "0.3.6"
|
||||
authors = ["Thibaut Schaeffer <thibaut@schaeff.fr>", "Guillaume Ballet <gballet@gmail.com>"]
|
||||
edition = "2018"
|
||||
|
||||
|
@ -10,12 +10,10 @@ serde_derive = "1.0"
|
|||
lazy_static = "1.4"
|
||||
bincode = "0.8.0"
|
||||
serde_json = "1.0"
|
||||
bellman_ce = { version = "^0.3", default-features = false}
|
||||
sha2 = "0.8.0"
|
||||
num-traits = { version = "0.2", default-features = false }
|
||||
num-integer = { version = "0.1", default-features = false }
|
||||
pairing_ce = "^0.21"
|
||||
ff_ce = { features = ["derive"], version = "0.9" }
|
||||
bellman_ce = { version = "^0.3", default-features = false }
|
||||
|
||||
[dev-dependencies]
|
||||
rand = "0.4"
|
||||
|
|
|
@ -21,6 +21,15 @@ mod tests {
|
|||
use super::*;
|
||||
use bincode::{deserialize, serialize, Infinite};
|
||||
|
||||
#[test]
|
||||
fn max_value_bits() {
|
||||
let bits = FieldPrime::max_value_bit_vector_be();
|
||||
assert_eq!(
|
||||
bits[0..10].to_vec(),
|
||||
vec![true, true, false, false, false, false, false, true, true, false]
|
||||
);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn positive_number() {
|
||||
assert_eq!(
|
||||
|
@ -372,6 +381,7 @@ mod tests {
|
|||
|
||||
extern crate rand;
|
||||
use bellman_ce::pairing::bn256::Fr;
|
||||
|
||||
use rand::{thread_rng, Rng};
|
||||
use Field;
|
||||
|
||||
|
|
|
@ -6,6 +6,7 @@
|
|||
|
||||
use bellman_ce::pairing::ff::ScalarEngine;
|
||||
use bellman_ce::pairing::Engine;
|
||||
use num_bigint::BigUint;
|
||||
use num_traits::{One, Zero};
|
||||
use serde::{Deserialize, Serialize};
|
||||
use std::convert::From;
|
||||
|
@ -86,6 +87,25 @@ pub trait Field:
|
|||
fn id() -> [u8; 4];
|
||||
/// the name of the curve associated with this field
|
||||
fn name() -> &'static str;
|
||||
/// Returns this `Field`'s largest value as a big-endian bit vector
|
||||
fn max_value_bit_vector_be() -> Vec<bool> {
|
||||
fn bytes_to_bits(bytes: &[u8]) -> Vec<bool> {
|
||||
bytes
|
||||
.iter()
|
||||
.flat_map(|&v| (0..8).rev().map(move |i| (v >> i) & 1 == 1))
|
||||
.collect()
|
||||
}
|
||||
|
||||
let field_bytes_le = Self::into_byte_vector(&Self::max_value());
|
||||
// reverse for big-endianess
|
||||
let field_bytes_be = field_bytes_le.into_iter().rev().collect::<Vec<u8>>();
|
||||
let field_bits_be = bytes_to_bits(&field_bytes_be);
|
||||
|
||||
let field_bits_be = &field_bits_be[field_bits_be.len() - Self::get_required_bits()..];
|
||||
field_bits_be.to_vec()
|
||||
}
|
||||
/// Returns the value as a BigUint
|
||||
fn to_biguint(&self) -> BigUint;
|
||||
}
|
||||
|
||||
#[macro_use]
|
||||
|
@ -115,6 +135,10 @@ mod prime_field {
|
|||
impl Field for FieldPrime {
|
||||
type BellmanEngine = $bellman_type;
|
||||
|
||||
fn to_biguint(&self) -> BigUint {
|
||||
self.value.to_biguint().unwrap()
|
||||
}
|
||||
|
||||
fn into_byte_vector(&self) -> Vec<u8> {
|
||||
match self.value.to_biguint() {
|
||||
Option::Some(val) => val.to_bytes_le(),
|
||||
|
|
1200
zokrates_js/Cargo.lock
generated
1200
zokrates_js/Cargo.lock
generated
File diff suppressed because it is too large
Load diff
|
@ -1,6 +1,6 @@
|
|||
[package]
|
||||
name = "zokrates_js"
|
||||
version = "1.0.21"
|
||||
version = "1.0.22"
|
||||
authors = ["Darko Macesic"]
|
||||
edition = "2018"
|
||||
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
"name": "zokrates-js",
|
||||
"main": "index.js",
|
||||
"author": "Darko Macesic <darem966@gmail.com>",
|
||||
"version": "1.0.21",
|
||||
"version": "1.0.22",
|
||||
"keywords": [
|
||||
"zokrates",
|
||||
"wasm-bindgen",
|
||||
|
|
|
@ -138,8 +138,10 @@ pub fn compute_witness(artifacts: JsValue, args: JsValue) -> Result<JsValue, JsV
|
|||
.map(|parsed| Inputs::Abi(parsed))
|
||||
.map_err(|why| JsValue::from_str(&format!("{}", why.to_string())))?;
|
||||
|
||||
let witness = program_flattened
|
||||
.execute(&inputs.encode())
|
||||
let interpreter = ir::Interpreter::default();
|
||||
|
||||
let witness = interpreter
|
||||
.execute(&program_flattened, &inputs.encode())
|
||||
.map_err(|err| JsValue::from_str(&format!("Execution failed: {}", err)))?;
|
||||
|
||||
let return_values: serde_json::Value =
|
||||
|
|
|
@ -111,10 +111,12 @@ fn compile_and_run<T: Field>(t: Tests) {
|
|||
_ => {}
|
||||
};
|
||||
|
||||
let interpreter = zokrates_core::ir::Interpreter::default();
|
||||
|
||||
for test in t.tests.into_iter() {
|
||||
let input = &test.input.values;
|
||||
|
||||
let output = bin.execute(&(input.iter().cloned().map(parse_val).collect()));
|
||||
let output = interpreter.execute(bin, &(input.iter().cloned().map(parse_val).collect()));
|
||||
|
||||
match compare(output, test.output) {
|
||||
Err(e) => {
|
||||
|
|
Loading…
Reference in a new issue