wip
This commit is contained in:
parent
efb2c8a492
commit
30483984a8
27 changed files with 805 additions and 362 deletions
183
Cargo.lock
generated
183
Cargo.lock
generated
|
@ -168,8 +168,8 @@ version = "0.3.0"
|
|||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "db02d390bf6643fb404d3d22d31aee1c4bc4459600aef9113833d17e786c6e44"
|
||||
dependencies = [
|
||||
"quote 1.0.15",
|
||||
"syn 1.0.86",
|
||||
"quote 1.0.17",
|
||||
"syn 1.0.90",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
|
@ -180,8 +180,8 @@ checksum = "db2fd794a08ccb318058009eefdf15bcaaaaf6f8161eb3345f907222bac38b20"
|
|||
dependencies = [
|
||||
"num-bigint 0.4.3",
|
||||
"num-traits 0.2.14",
|
||||
"quote 1.0.15",
|
||||
"syn 1.0.86",
|
||||
"quote 1.0.17",
|
||||
"syn 1.0.90",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
|
@ -220,7 +220,7 @@ dependencies = [
|
|||
[[package]]
|
||||
name = "ark-marlin"
|
||||
version = "0.3.0"
|
||||
source = "git+https://github.com/nirvantyagi/marlin?branch=chacha-rng-dependency#eb8001b9e97da275c96bfa9340ac5f2dd58ca9f9"
|
||||
source = "git+https://github.com/nirvantyagi/marlin?branch=chacha-rng-dependency#0fdd2adbcbb1bc83c3e43b91fa7df900fce85b20"
|
||||
dependencies = [
|
||||
"ark-ff",
|
||||
"ark-poly",
|
||||
|
@ -324,8 +324,8 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
|
|||
checksum = "8dd4e5f0bf8285d5ed538d27fab7411f3e297908fd93c62195de8bee3f199e82"
|
||||
dependencies = [
|
||||
"proc-macro2 1.0.36",
|
||||
"quote 1.0.15",
|
||||
"syn 1.0.86",
|
||||
"quote 1.0.17",
|
||||
"syn 1.0.90",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
|
@ -403,8 +403,8 @@ checksum = "7862e21c893d65a1650125d157eaeec691439379a1cee17ee49031b79236ada4"
|
|||
dependencies = [
|
||||
"proc-macro-error",
|
||||
"proc-macro2 1.0.36",
|
||||
"quote 1.0.15",
|
||||
"syn 1.0.86",
|
||||
"quote 1.0.17",
|
||||
"syn 1.0.90",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
|
@ -644,7 +644,7 @@ checksum = "4acbb09d9ee8e23699b9634375c72795d095bf268439da88562cf9b501f181fa"
|
|||
dependencies = [
|
||||
"camino",
|
||||
"cargo-platform",
|
||||
"semver 1.0.6",
|
||||
"semver 1.0.7",
|
||||
"serde",
|
||||
"serde_json",
|
||||
]
|
||||
|
@ -723,9 +723,9 @@ checksum = "245097e9a4535ee1e3e3931fcfcd55a796a44c643e8596ff6566d68f09b87bbc"
|
|||
|
||||
[[package]]
|
||||
name = "cpufeatures"
|
||||
version = "0.2.1"
|
||||
version = "0.2.2"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "95059428f66df56b63431fdb4e1947ed2190586af5c5a8a8b71122bdf5a7f469"
|
||||
checksum = "59a6001667ab124aebae2a495118e11d30984c3a653e99d86d58971708cf5e4b"
|
||||
dependencies = [
|
||||
"libc",
|
||||
]
|
||||
|
@ -862,12 +862,12 @@ dependencies = [
|
|||
|
||||
[[package]]
|
||||
name = "ctor"
|
||||
version = "0.1.21"
|
||||
version = "0.1.22"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "ccc0a48a9b826acdf4028595adc9db92caea352f7af011a3034acd172a52a0aa"
|
||||
checksum = "f877be4f7c9f246b183111634f75baa039715e3f46ce860677d3b19a69fb229c"
|
||||
dependencies = [
|
||||
"quote 1.0.15",
|
||||
"syn 1.0.86",
|
||||
"quote 1.0.17",
|
||||
"syn 1.0.90",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
|
@ -877,8 +877,8 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
|
|||
checksum = "fcc3dd5e9e9c0b295d6e1e4d811fb6f157d5ffd784b8d202fc62eac8035a770b"
|
||||
dependencies = [
|
||||
"proc-macro2 1.0.36",
|
||||
"quote 1.0.15",
|
||||
"syn 1.0.86",
|
||||
"quote 1.0.17",
|
||||
"syn 1.0.90",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
|
@ -932,9 +932,9 @@ dependencies = [
|
|||
|
||||
[[package]]
|
||||
name = "dirs-sys"
|
||||
version = "0.3.6"
|
||||
version = "0.3.7"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "03d86534ed367a67548dc68113a0f5db55432fdfbb6e6f9d77704397d95d5780"
|
||||
checksum = "1b1d1d91c932ef41c0f2663aa8b0ca0342d444d842c06914aa0a7e352d0bada6"
|
||||
dependencies = [
|
||||
"libc",
|
||||
"redox_users",
|
||||
|
@ -987,8 +987,6 @@ dependencies = [
|
|||
[[package]]
|
||||
name = "ethabi"
|
||||
version = "17.0.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "b69517146dfab88e9238c00c724fd8e277951c3cc6f22b016d72f422a832213e"
|
||||
dependencies = [
|
||||
"ethereum-types",
|
||||
"hex 0.4.3",
|
||||
|
@ -1045,8 +1043,8 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
|
|||
checksum = "aa4da3c766cd7a0db8242e326e9e4e081edd567072893ed320008189715366a4"
|
||||
dependencies = [
|
||||
"proc-macro2 1.0.36",
|
||||
"quote 1.0.15",
|
||||
"syn 1.0.86",
|
||||
"quote 1.0.17",
|
||||
"syn 1.0.90",
|
||||
"synstructure",
|
||||
]
|
||||
|
||||
|
@ -1098,8 +1096,8 @@ dependencies = [
|
|||
"num-integer",
|
||||
"num-traits 0.2.14",
|
||||
"proc-macro2 1.0.36",
|
||||
"quote 1.0.15",
|
||||
"syn 1.0.86",
|
||||
"quote 1.0.17",
|
||||
"syn 1.0.90",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
|
@ -1251,9 +1249,9 @@ dependencies = [
|
|||
|
||||
[[package]]
|
||||
name = "getrandom"
|
||||
version = "0.2.5"
|
||||
version = "0.2.6"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "d39cd93900197114fa1fcb7ae84ca742095eed9442088988ae74fa744e930e77"
|
||||
checksum = "9be70c98951c83b8d2f8f60d7065fa6d5146873094452a1008da8c2f1e4205ad"
|
||||
dependencies = [
|
||||
"cfg-if 1.0.0",
|
||||
"js-sys",
|
||||
|
@ -1391,8 +1389,18 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
|
|||
checksum = "11d7a9f6330b71fea57921c9b61c47ee6e84f72d394754eff6163ae67e7395eb"
|
||||
dependencies = [
|
||||
"proc-macro2 1.0.36",
|
||||
"quote 1.0.15",
|
||||
"syn 1.0.86",
|
||||
"quote 1.0.17",
|
||||
"syn 1.0.90",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "indexmap"
|
||||
version = "1.8.1"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "0f647032dfaa1f8b6dc29bd3edb7bbef4861b8b8007ebb118d6db284fd59f6ee"
|
||||
dependencies = [
|
||||
"autocfg",
|
||||
"hashbrown 0.11.2",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
|
@ -1460,9 +1468,9 @@ dependencies = [
|
|||
|
||||
[[package]]
|
||||
name = "libc"
|
||||
version = "0.2.119"
|
||||
version = "0.2.121"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "1bf2e165bb3457c8e098ea76f3e3bc9db55f87aa90d52d0e6be741470916aaa4"
|
||||
checksum = "efaa7b300f3b5fe8eb6bf21ce3895e1751d9665086af2d64b42f19701015ff4f"
|
||||
|
||||
[[package]]
|
||||
name = "libgit2-sys"
|
||||
|
@ -1506,9 +1514,9 @@ dependencies = [
|
|||
|
||||
[[package]]
|
||||
name = "log"
|
||||
version = "0.4.14"
|
||||
version = "0.4.16"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "51b9bbe6c47d51fc3e1a9b945965946b4c44142ab8792c50835a980d362c2710"
|
||||
checksum = "6389c490849ff5bc16be905ae24bc913a9c8892e19b2341dbc175e14c341c2b8"
|
||||
dependencies = [
|
||||
"cfg-if 1.0.0",
|
||||
]
|
||||
|
@ -1697,8 +1705,8 @@ checksum = "3b0498641e53dd6ac1a4f22547548caa6864cc4933784319cd1775271c5a46ce"
|
|||
dependencies = [
|
||||
"proc-macro-crate",
|
||||
"proc-macro2 1.0.36",
|
||||
"quote 1.0.15",
|
||||
"syn 1.0.86",
|
||||
"quote 1.0.17",
|
||||
"syn 1.0.90",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
|
@ -1769,9 +1777,9 @@ dependencies = [
|
|||
|
||||
[[package]]
|
||||
name = "parity-scale-codec"
|
||||
version = "3.0.0"
|
||||
version = "3.1.2"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "2a7f3fcf5e45fc28b84dcdab6b983e77f197ec01f325a33f404ba6855afd1070"
|
||||
checksum = "e8b44461635bbb1a0300f100a841e571e7d919c81c73075ef5d152ffdb521066"
|
||||
dependencies = [
|
||||
"arrayvec 0.7.2",
|
||||
"bitvec",
|
||||
|
@ -1783,21 +1791,21 @@ dependencies = [
|
|||
|
||||
[[package]]
|
||||
name = "parity-scale-codec-derive"
|
||||
version = "3.0.0"
|
||||
version = "3.1.2"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "2c6e626dc84025ff56bf1476ed0e30d10c84d7f89a475ef46ebabee1095a8fba"
|
||||
checksum = "c45ed1f39709f5a89338fab50e59816b2e8815f5bb58276e7ddf9afd495f73f8"
|
||||
dependencies = [
|
||||
"proc-macro-crate",
|
||||
"proc-macro2 1.0.36",
|
||||
"quote 1.0.15",
|
||||
"syn 1.0.86",
|
||||
"quote 1.0.17",
|
||||
"syn 1.0.90",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "paste"
|
||||
version = "1.0.6"
|
||||
version = "1.0.7"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "0744126afe1a6dd7f394cb50a716dbe086cb06e255e53d8d0185d82828358fb5"
|
||||
checksum = "0c520e05135d6e763148b6426a837e239041653ba7becd2e538c076c738025fc"
|
||||
|
||||
[[package]]
|
||||
name = "percent-encoding"
|
||||
|
@ -1846,8 +1854,8 @@ dependencies = [
|
|||
"pest",
|
||||
"pest_meta",
|
||||
"proc-macro2 1.0.36",
|
||||
"quote 1.0.15",
|
||||
"syn 1.0.86",
|
||||
"quote 1.0.17",
|
||||
"syn 1.0.90",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
|
@ -1944,8 +1952,8 @@ checksum = "da25490ff9892aab3fcf7c36f08cfb902dd3e71ca0f9f9517bea02a73a5ce38c"
|
|||
dependencies = [
|
||||
"proc-macro-error-attr",
|
||||
"proc-macro2 1.0.36",
|
||||
"quote 1.0.15",
|
||||
"syn 1.0.86",
|
||||
"quote 1.0.17",
|
||||
"syn 1.0.90",
|
||||
"version_check",
|
||||
]
|
||||
|
||||
|
@ -1956,7 +1964,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
|
|||
checksum = "a1be40180e52ecc98ad80b184934baf3d0d29f979574e439af5a55274b35f869"
|
||||
dependencies = [
|
||||
"proc-macro2 1.0.36",
|
||||
"quote 1.0.15",
|
||||
"quote 1.0.17",
|
||||
"version_check",
|
||||
]
|
||||
|
||||
|
@ -2000,9 +2008,9 @@ dependencies = [
|
|||
|
||||
[[package]]
|
||||
name = "quote"
|
||||
version = "1.0.15"
|
||||
version = "1.0.17"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "864d3e96a899863136fc6e99f3d7cae289dafe43bf2c5ac19b70df7210c0a145"
|
||||
checksum = "632d02bff7f874a36f33ea8bb416cd484b90cc66c1194b1a1110d067a7013f58"
|
||||
dependencies = [
|
||||
"proc-macro2 1.0.36",
|
||||
]
|
||||
|
@ -2082,21 +2090,22 @@ dependencies = [
|
|||
|
||||
[[package]]
|
||||
name = "redox_syscall"
|
||||
version = "0.2.11"
|
||||
version = "0.2.12"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "8380fe0152551244f0747b1bf41737e0f8a74f97a14ccefd1148187271634f3c"
|
||||
checksum = "8ae183fc1b06c149f0c1793e1eb447c8b04bfe46d48e9e48bfb8d2d7ed64ecf0"
|
||||
dependencies = [
|
||||
"bitflags",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "redox_users"
|
||||
version = "0.4.0"
|
||||
version = "0.4.2"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "528532f3d801c87aec9def2add9ca802fe569e44a544afe633765267840abe64"
|
||||
checksum = "7776223e2696f1aa4c6b0170e83212f47296a00424305117d013dfe86fb0fe55"
|
||||
dependencies = [
|
||||
"getrandom",
|
||||
"redox_syscall",
|
||||
"thiserror",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
|
@ -2162,7 +2171,7 @@ dependencies = [
|
|||
[[package]]
|
||||
name = "revm"
|
||||
version = "1.2.0"
|
||||
source = "git+https://github.com/bluealloy/revm#858ae0837657ee446ef422032969b00a0ce0c8be"
|
||||
source = "git+https://github.com/bluealloy/revm#8c17fd471f0f8a6b8569623af964488a152f7eb3"
|
||||
dependencies = [
|
||||
"arrayref",
|
||||
"auto_impl",
|
||||
|
@ -2178,7 +2187,7 @@ dependencies = [
|
|||
[[package]]
|
||||
name = "revm_precompiles"
|
||||
version = "0.4.0"
|
||||
source = "git+https://github.com/bluealloy/revm#858ae0837657ee446ef422032969b00a0ce0c8be"
|
||||
source = "git+https://github.com/bluealloy/revm#8c17fd471f0f8a6b8569623af964488a152f7eb3"
|
||||
dependencies = [
|
||||
"bytes",
|
||||
"num 0.4.0",
|
||||
|
@ -2276,18 +2285,18 @@ checksum = "d29ab0c6d3fc0ee92fe66e2d99f700eab17a8d57d1c1d3b748380fb20baa78cd"
|
|||
|
||||
[[package]]
|
||||
name = "secp256k1"
|
||||
version = "0.21.3"
|
||||
version = "0.22.1"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "9c42e6f1735c5f00f51e43e28d6634141f2bcad10931b2609ddd74a86d751260"
|
||||
checksum = "26947345339603ae8395f68e2f3d85a6b0a8ddfe6315818e80b8504415099db0"
|
||||
dependencies = [
|
||||
"secp256k1-sys",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "secp256k1-sys"
|
||||
version = "0.4.2"
|
||||
version = "0.5.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "957da2573cde917463ece3570eab4a0b3f19de6f1646cde62e6fd3868f566036"
|
||||
checksum = "07b5b9d7322572e1f3aeed208668ce87789b3645dbb73082c5ce99a004103a35"
|
||||
dependencies = [
|
||||
"cc",
|
||||
]
|
||||
|
@ -2303,9 +2312,9 @@ dependencies = [
|
|||
|
||||
[[package]]
|
||||
name = "semver"
|
||||
version = "1.0.6"
|
||||
version = "1.0.7"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "a4a3381e03edd24287172047536f20cabde766e2cd3e65e6b00fb3af51c4f38d"
|
||||
checksum = "d65bd28f48be7196d222d95b9243287f48d27aca604e08497513019ff0502cc4"
|
||||
dependencies = [
|
||||
"serde",
|
||||
]
|
||||
|
@ -2345,8 +2354,8 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
|
|||
checksum = "08597e7152fcd306f41838ed3e37be9eaeed2b61c42e2117266a554fab4662f9"
|
||||
dependencies = [
|
||||
"proc-macro2 1.0.36",
|
||||
"quote 1.0.15",
|
||||
"syn 1.0.86",
|
||||
"quote 1.0.17",
|
||||
"syn 1.0.90",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
|
@ -2355,6 +2364,7 @@ version = "1.0.79"
|
|||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "8e8d9fa5c3b304765ce1fd9c4c8a3de2c8db365a5b91be52f186efc675681d95"
|
||||
dependencies = [
|
||||
"indexmap",
|
||||
"itoa 1.0.1",
|
||||
"ryu",
|
||||
"serde",
|
||||
|
@ -2512,12 +2522,12 @@ dependencies = [
|
|||
|
||||
[[package]]
|
||||
name = "syn"
|
||||
version = "1.0.86"
|
||||
version = "1.0.90"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "8a65b3f4ffa0092e9887669db0eae07941f023991ab58ea44da8fe8e2d511c6b"
|
||||
checksum = "704df27628939572cd88d33f171cd6f896f4eaca85252c6e0a72d8d8287ee86f"
|
||||
dependencies = [
|
||||
"proc-macro2 1.0.36",
|
||||
"quote 1.0.15",
|
||||
"quote 1.0.17",
|
||||
"unicode-xid 0.2.2",
|
||||
]
|
||||
|
||||
|
@ -2528,8 +2538,8 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
|
|||
checksum = "f36bdaa60a83aca3921b5259d5400cbf5e90fc51931376a9bd4a0eb79aa7210f"
|
||||
dependencies = [
|
||||
"proc-macro2 1.0.36",
|
||||
"quote 1.0.15",
|
||||
"syn 1.0.86",
|
||||
"quote 1.0.17",
|
||||
"syn 1.0.90",
|
||||
"unicode-xid 0.2.2",
|
||||
]
|
||||
|
||||
|
@ -2597,8 +2607,8 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
|
|||
checksum = "aa32fd3f627f367fe16f893e2597ae3c05020f8bba2666a4e6ea73d377e5714b"
|
||||
dependencies = [
|
||||
"proc-macro2 1.0.36",
|
||||
"quote 1.0.15",
|
||||
"syn 1.0.86",
|
||||
"quote 1.0.17",
|
||||
"syn 1.0.90",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
|
@ -2662,8 +2672,8 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
|
|||
checksum = "2e65ce065b4b5c53e73bb28912318cb8c9e9ad3921f1d669eb0e68b4c8143a2b"
|
||||
dependencies = [
|
||||
"proc-macro2 1.0.36",
|
||||
"quote 1.0.15",
|
||||
"syn 1.0.86",
|
||||
"quote 1.0.17",
|
||||
"syn 1.0.90",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
|
@ -2829,8 +2839,8 @@ dependencies = [
|
|||
"lazy_static",
|
||||
"log",
|
||||
"proc-macro2 1.0.36",
|
||||
"quote 1.0.15",
|
||||
"syn 1.0.86",
|
||||
"quote 1.0.17",
|
||||
"syn 1.0.90",
|
||||
"wasm-bindgen-shared",
|
||||
]
|
||||
|
||||
|
@ -2852,7 +2862,7 @@ version = "0.2.79"
|
|||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "2f4203d69e40a52ee523b2529a773d5ffc1dc0071801c87b3d270b471b80ed01"
|
||||
dependencies = [
|
||||
"quote 1.0.15",
|
||||
"quote 1.0.17",
|
||||
"wasm-bindgen-macro-support",
|
||||
]
|
||||
|
||||
|
@ -2863,8 +2873,8 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
|
|||
checksum = "bfa8a30d46208db204854cadbb5d4baf5fcf8071ba5bf48190c3e59937962ebc"
|
||||
dependencies = [
|
||||
"proc-macro2 1.0.36",
|
||||
"quote 1.0.15",
|
||||
"syn 1.0.86",
|
||||
"quote 1.0.17",
|
||||
"syn 1.0.90",
|
||||
"wasm-bindgen-backend",
|
||||
"wasm-bindgen-shared",
|
||||
]
|
||||
|
@ -2896,7 +2906,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
|
|||
checksum = "d0e560d44db5e73b69a9757a15512fe7e1ef93ed2061c928871a4025798293dd"
|
||||
dependencies = [
|
||||
"proc-macro2 1.0.36",
|
||||
"quote 1.0.15",
|
||||
"quote 1.0.17",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
|
@ -2951,9 +2961,9 @@ dependencies = [
|
|||
|
||||
[[package]]
|
||||
name = "zeroize"
|
||||
version = "1.5.3"
|
||||
version = "1.5.4"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "50344758e2f40e3a1fcfc8f6f91aa57b5f8ebd8d27919fe6451f15aaaf9ee608"
|
||||
checksum = "7eb5728b8afd3f280a869ce1d4c554ffaed35f45c231fc41bfbd0381bef50317"
|
||||
dependencies = [
|
||||
"zeroize_derive",
|
||||
]
|
||||
|
@ -2965,8 +2975,8 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
|
|||
checksum = "3f8f187641dad4f680d25c4bfc4225b418165984179f26ca76ec4fb6441d3a17"
|
||||
dependencies = [
|
||||
"proc-macro2 1.0.36",
|
||||
"quote 1.0.15",
|
||||
"syn 1.0.86",
|
||||
"quote 1.0.17",
|
||||
"syn 1.0.90",
|
||||
"synstructure",
|
||||
]
|
||||
|
||||
|
@ -2992,11 +3002,13 @@ dependencies = [
|
|||
"clap",
|
||||
"dirs",
|
||||
"env_logger",
|
||||
"ethabi",
|
||||
"fs_extra",
|
||||
"glob 0.2.11",
|
||||
"hex 0.3.2",
|
||||
"lazy_static",
|
||||
"log",
|
||||
"primitive-types",
|
||||
"rand 0.4.6",
|
||||
"regex 0.2.11",
|
||||
"serde",
|
||||
|
@ -3009,6 +3021,7 @@ dependencies = [
|
|||
"zokrates_core",
|
||||
"zokrates_field",
|
||||
"zokrates_fs_resolver",
|
||||
"zokrates_solidity_test",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
|
@ -3156,7 +3169,7 @@ dependencies = [
|
|||
"ethabi",
|
||||
"hex 0.4.3",
|
||||
"primitive-types",
|
||||
"rand 0.8.5",
|
||||
"rand 0.4.6",
|
||||
"revm",
|
||||
"serde_json",
|
||||
"solc",
|
||||
|
|
|
@ -9,4 +9,4 @@ zokrates_field = { version = "0.5", path = "../zokrates_field", default-features
|
|||
zokrates_core = { version = "0.6", path = "../zokrates_core", default-features = false }
|
||||
serde = "1.0"
|
||||
serde_derive = "1.0"
|
||||
serde_json = "1.0"
|
||||
serde_json = { version = "1.0", features = ["preserve_order"] }
|
||||
|
|
|
@ -23,7 +23,7 @@ zokrates_abi = { version = "0.1", path = "../zokrates_abi" }
|
|||
zokrates_core = { version = "0.6", path = "../zokrates_core", default-features = false }
|
||||
typed-arena = "1.4.1"
|
||||
zokrates_fs_resolver = { version = "0.5", path = "../zokrates_fs_resolver"}
|
||||
serde_json = "1.0"
|
||||
serde_json = { version = "1.0", features = ["preserve_order"] }
|
||||
serde = { version = "1.0", features = ["derive"] }
|
||||
dirs = "3.0.1"
|
||||
lazy_static = "1.4.0"
|
||||
|
@ -37,6 +37,9 @@ sha2 = "0.10.0"
|
|||
glob = "0.2.11"
|
||||
assert_cli = "0.5"
|
||||
tempdir = "0.3"
|
||||
zokrates_solidity_test = { version = "0.1", path = "../zokrates_solidity_test", default-features = false }
|
||||
ethabi = { path = "../../ethabi/ethabi" }
|
||||
primitive-types = { version = "0.11", features = ["rlp"] }
|
||||
|
||||
[build-dependencies]
|
||||
fs_extra = "1.1.0"
|
||||
|
|
|
@ -1,5 +1,7 @@
|
|||
import "hashes/sha256/512bitPacked" as sha256packed
|
||||
|
||||
def main(private field a, private field b, private field c, private field d) -> field[2]:
|
||||
def main(private field a, private field b, private field c, private field d):
|
||||
field[2] h = sha256packed([a, b, c, d])
|
||||
return h
|
||||
assert(h[0] == 263561599766550617289250058199814760685)
|
||||
assert(h[1] == 65303172752238645975888084098459749904)
|
||||
return
|
|
@ -71,6 +71,10 @@ pub fn exec(sub_matches: &ArgMatches) -> Result<(), String> {
|
|||
(CurveParameter::Bn128, SchemeParameter::PGHR13) => {
|
||||
cli_export_verifier::<Bn128Field, PGHR13>(sub_matches)
|
||||
}
|
||||
(CurveParameter::Bn128, SchemeParameter::MARLIN) => {
|
||||
println!("export with marlin");
|
||||
cli_export_verifier::<Bn128Field, Marlin>(sub_matches)
|
||||
}
|
||||
_ => Err(format!("Could not export verifier with given parameters (curve: {}, scheme: {}): not supported", curve, scheme))
|
||||
}
|
||||
}
|
||||
|
@ -89,6 +93,7 @@ fn cli_export_verifier<T: SolidityCompatibleField, S: SolidityCompatibleScheme<T
|
|||
let vk = serde_json::from_reader(reader)
|
||||
.map_err(|why| format!("Could not deserialize verification key: {}", why))?;
|
||||
|
||||
println!("exp");
|
||||
let verifier = S::export_solidity_verifier(vk);
|
||||
|
||||
//write output file
|
||||
|
|
|
@ -1,8 +1,15 @@
|
|||
use crate::constants::JSON_PROOF_PATH;
|
||||
use crate::constants::{self, JSON_PROOF_PATH};
|
||||
use crate::helpers::{CurveParameter, SchemeParameter};
|
||||
use clap::{App, Arg, ArgMatches, SubCommand};
|
||||
use serde_json::Value;
|
||||
use std::convert::TryInto;
|
||||
use std::fs::File;
|
||||
use std::path::Path;
|
||||
use zokrates_core::proof_system::{
|
||||
marlin, Backend, Marlin, Proof, Scheme, SolidityCompatibleField, SolidityCompatibleScheme, G16,
|
||||
GM17, PGHR13,
|
||||
};
|
||||
use zokrates_field::{Bls12_381Field, Bn128Field, Field};
|
||||
|
||||
pub fn subcommand() -> App<'static, 'static> {
|
||||
SubCommand::with_name("print-proof")
|
||||
|
@ -27,24 +34,87 @@ pub fn subcommand() -> App<'static, 'static> {
|
|||
.possible_values(&["remix", "json"])
|
||||
.required(true),
|
||||
)
|
||||
.arg(
|
||||
Arg::with_name("proving-scheme")
|
||||
.short("s")
|
||||
.long("proving-scheme")
|
||||
.help("Proving scheme to use in the setup. Available options are G16 (default), PGHR13 and GM17")
|
||||
.value_name("FILE")
|
||||
.takes_value(true)
|
||||
.required(false)
|
||||
.default_value(constants::G16)
|
||||
)
|
||||
.arg(
|
||||
Arg::with_name("curve")
|
||||
.short("c")
|
||||
.long("curve")
|
||||
.help("Curve to be used in the verification")
|
||||
.takes_value(true)
|
||||
.required(false)
|
||||
.possible_values(constants::CURVES)
|
||||
.default_value(constants::BN128)
|
||||
)
|
||||
}
|
||||
|
||||
pub fn exec(sub_matches: &ArgMatches) -> Result<(), String> {
|
||||
let curve = sub_matches.value_of("curve").unwrap();
|
||||
let scheme = sub_matches.value_of("proving-scheme").unwrap();
|
||||
|
||||
let parameters: (CurveParameter, SchemeParameter) =
|
||||
(curve.try_into().unwrap(), scheme.try_into().unwrap());
|
||||
|
||||
println!(
|
||||
"Printing proof at location {:?} using proving scheme {:?} and curve {:?}",
|
||||
sub_matches
|
||||
.values_of("proof-path")
|
||||
.clone()
|
||||
.unwrap()
|
||||
.next()
|
||||
.unwrap(),
|
||||
parameters.1,
|
||||
parameters.0
|
||||
);
|
||||
|
||||
match parameters {
|
||||
(CurveParameter::Bn128, SchemeParameter::PGHR13) => {
|
||||
cli_print_proof::<Bn128Field, PGHR13>(sub_matches)
|
||||
}
|
||||
(CurveParameter::Bn128, SchemeParameter::G16) => {
|
||||
cli_print_proof::<Bn128Field, G16>(sub_matches)
|
||||
}
|
||||
(CurveParameter::Bn128, SchemeParameter::GM17) => {
|
||||
cli_print_proof::<Bn128Field, GM17>(sub_matches)
|
||||
}
|
||||
(CurveParameter::Bn128, SchemeParameter::MARLIN) => {
|
||||
cli_print_proof::<Bn128Field, Marlin>(sub_matches)
|
||||
}
|
||||
_ => Err(format!("Could not print proof with given parameters (curve: {}, scheme: {}): only bn128 is supported", curve, scheme))
|
||||
}
|
||||
}
|
||||
|
||||
fn cli_print_proof<T: SolidityCompatibleField, S: SolidityCompatibleScheme<T>>(
|
||||
sub_matches: &ArgMatches,
|
||||
) -> Result<(), String> {
|
||||
let format = sub_matches.value_of("format").unwrap();
|
||||
let path = Path::new(sub_matches.value_of("proof-path").unwrap());
|
||||
|
||||
let file =
|
||||
File::open(&path).map_err(|why| format!("Couldn't open {}: {}", path.display(), why))?;
|
||||
|
||||
let proof_object: Value = serde_json::from_reader(file).map_err(|why| format!("{:?}", why))?;
|
||||
let proof: Proof<T, S> = serde_json::from_reader(file).map_err(|why| format!("{:?}", why))?;
|
||||
|
||||
let inputs = serde_json::to_value(&proof.inputs).unwrap();
|
||||
|
||||
let res = S::Proof::from(proof.proof);
|
||||
let proof_object = serde_json::to_value(&res).unwrap();
|
||||
|
||||
match format {
|
||||
"json" => {
|
||||
println!("~~~~~~~~ Copy the output below for valid ABIv2 format ~~~~~~~~");
|
||||
println!();
|
||||
print!("{}", proof_object["proof"]);
|
||||
print!("{}", inputs);
|
||||
print!(",");
|
||||
println!("{}", proof_object["inputs"]);
|
||||
println!("{}", proof_object);
|
||||
println!();
|
||||
println!("~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~");
|
||||
}
|
||||
|
@ -52,12 +122,12 @@ pub fn exec(sub_matches: &ArgMatches) -> Result<(), String> {
|
|||
println!("~~~~~~~~ Copy the output below for valid ABIv1 format ~~~~~~~~");
|
||||
println!();
|
||||
|
||||
for (_, value) in proof_object["proof"].as_object().unwrap().iter() {
|
||||
for (_, value) in proof_object.as_object().unwrap().iter() {
|
||||
print!("{}", value);
|
||||
print!(",");
|
||||
}
|
||||
|
||||
println!("{}", proof_object["inputs"]);
|
||||
println!("{}", inputs);
|
||||
println!();
|
||||
println!("~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~");
|
||||
}
|
||||
|
|
30
zokrates_cli/tests/contract/package-lock.json
generated
30
zokrates_cli/tests/contract/package-lock.json
generated
|
@ -256,9 +256,9 @@
|
|||
"integrity": "sha512-3YDiu347mtVtjpyV3u5kVqQLP242c06zwDOgpeRnybmXlYYsLbtTrUBUm8i8srONt+FWobl5aibnU1030PeeuA=="
|
||||
},
|
||||
"balanced-match": {
|
||||
"version": "1.0.0",
|
||||
"resolved": "https://registry.npmjs.org/balanced-match/-/balanced-match-1.0.0.tgz",
|
||||
"integrity": "sha1-ibTRmasr7kneFk6gK4nORi1xt2c="
|
||||
"version": "1.0.2",
|
||||
"resolved": "https://registry.npmjs.org/balanced-match/-/balanced-match-1.0.2.tgz",
|
||||
"integrity": "sha512-3oSeUO0TMV67hN1AmbXsK4yaqU7tjiHlbxRDZOpH0KW9+CeX4bRAaX0Anxt0tx2MrpRpWwQaPwIlISEJhYU5Pw=="
|
||||
},
|
||||
"base-x": {
|
||||
"version": "3.0.8",
|
||||
|
@ -1035,6 +1035,11 @@
|
|||
"unpipe": "~1.0.0"
|
||||
}
|
||||
},
|
||||
"follow-redirects": {
|
||||
"version": "1.14.9",
|
||||
"resolved": "https://registry.npmjs.org/follow-redirects/-/follow-redirects-1.14.9.tgz",
|
||||
"integrity": "sha512-MQDfihBQYMcyy5dhRDJUHcw7lb2Pv/TuE6xP1vyraLukNDHKbDxDNaOE3NbCAdKQApno+GPRyo1YAp89yCjK4w=="
|
||||
},
|
||||
"forever-agent": {
|
||||
"version": "0.6.1",
|
||||
"resolved": "https://registry.npmjs.org/forever-agent/-/forever-agent-0.6.1.tgz",
|
||||
|
@ -1102,9 +1107,9 @@
|
|||
}
|
||||
},
|
||||
"glob": {
|
||||
"version": "7.1.6",
|
||||
"resolved": "https://registry.npmjs.org/glob/-/glob-7.1.6.tgz",
|
||||
"integrity": "sha512-LwaxwyZ72Lk7vZINtNNrywX0ZuLyStrdDtabefZKAY5ZGJhVtgdznluResxNmPitE0SAO+O26sWTHeKSI2wMBA==",
|
||||
"version": "7.2.0",
|
||||
"resolved": "https://registry.npmjs.org/glob/-/glob-7.2.0.tgz",
|
||||
"integrity": "sha512-lmLf6gtyrPq8tTjSmrO94wBeQbFR3HbLHbuyD69wuyQkImp2hWqMGB47OX65FBkPffO641IP9jWa1z4ivqG26Q==",
|
||||
"requires": {
|
||||
"fs.realpath": "^1.0.0",
|
||||
"inflight": "^1.0.4",
|
||||
|
@ -1504,9 +1509,9 @@
|
|||
"integrity": "sha1-9sAMHAsIIkblxNmd+4x8CDsrWCo="
|
||||
},
|
||||
"minimatch": {
|
||||
"version": "3.0.4",
|
||||
"resolved": "https://registry.npmjs.org/minimatch/-/minimatch-3.0.4.tgz",
|
||||
"integrity": "sha512-yJHVQEhyqPLUTgt9B83PXu6W3rx4MvvHvSUvToogpwoGDOUQ+yDrR0HRot+yOCdCO7u4hX3pWft6kWBBcqh0UA==",
|
||||
"version": "3.1.2",
|
||||
"resolved": "https://registry.npmjs.org/minimatch/-/minimatch-3.1.2.tgz",
|
||||
"integrity": "sha512-J7p63hRiAjw1NDEww1W7i37+ByIrOWO5XQQAzZ3VOcL0PNybwpfmV/N05zFAzwQ9USyEcX6t3UO+K5aqBQOIHw==",
|
||||
"requires": {
|
||||
"brace-expansion": "^1.1.7"
|
||||
}
|
||||
|
@ -2048,12 +2053,13 @@
|
|||
}
|
||||
},
|
||||
"solc": {
|
||||
"version": "0.6.12",
|
||||
"resolved": "https://registry.npmjs.org/solc/-/solc-0.6.12.tgz",
|
||||
"integrity": "sha512-Lm0Ql2G9Qc7yPP2Ba+WNmzw2jwsrd3u4PobHYlSOxaut3TtUbj9+5ZrT6f4DUpNPEoBaFUOEg9Op9C0mk7ge9g==",
|
||||
"version": "0.8.0",
|
||||
"resolved": "https://registry.npmjs.org/solc/-/solc-0.8.0.tgz",
|
||||
"integrity": "sha512-ypgvqYZhb/i5BM6cw9/5QkSlDJm/rLynsbWGP3kz6HeB6oNxPK6UMiB7jMr+tNVbQbBM/8l47vrI3XaDCHShjQ==",
|
||||
"requires": {
|
||||
"command-exists": "^1.2.8",
|
||||
"commander": "3.0.2",
|
||||
"follow-redirects": "^1.12.1",
|
||||
"fs-extra": "^0.30.0",
|
||||
"js-sha3": "0.8.0",
|
||||
"memorystream": "^0.3.1",
|
||||
|
|
|
@ -55,7 +55,7 @@ let jsonContractSource = {
|
|||
})
|
||||
.send({
|
||||
from: accounts[0],
|
||||
gas: '2000000'
|
||||
gas: '20000000'
|
||||
})
|
||||
.on('receipt', (tx) => {
|
||||
if (tx.status == true) {
|
||||
|
@ -64,7 +64,7 @@ let jsonContractSource = {
|
|||
})
|
||||
.then(newContractInstance => {
|
||||
contract = newContractInstance;
|
||||
Promise.all([makeTransaction(accounts[0], true), makeTransaction(accounts[0], false)]);
|
||||
Promise.all([makeTransaction(accounts[0], true)]);
|
||||
})
|
||||
.catch(err => {
|
||||
console.log(err);
|
||||
|
@ -94,6 +94,8 @@ let jsonContractSource = {
|
|||
}
|
||||
}
|
||||
|
||||
console.log("PROOF:", proof)
|
||||
|
||||
verifyTx(proof, account, correct).on('receipt', handleReceipt)
|
||||
.catch(handleError);
|
||||
}
|
||||
|
@ -102,9 +104,11 @@ let jsonContractSource = {
|
|||
var args = proof[0];
|
||||
args = proof[1].length > 0 ? [args, proof[1]] : [args];
|
||||
|
||||
console.log(args);
|
||||
|
||||
return contract.methods.verifyTx(...args).send({
|
||||
from: account,
|
||||
gas: 5000000
|
||||
gas: '20000000'
|
||||
});
|
||||
}
|
||||
|
||||
|
|
|
@ -1,11 +1,16 @@
|
|||
extern crate assert_cli;
|
||||
extern crate ethabi;
|
||||
extern crate primitive_types;
|
||||
extern crate rand;
|
||||
extern crate serde_json;
|
||||
extern crate zokrates_solidity_test;
|
||||
|
||||
#[cfg(test)]
|
||||
mod integration {
|
||||
|
||||
use glob::glob;
|
||||
use serde_json::from_reader;
|
||||
use primitive_types::U256;
|
||||
use serde_json::{from_reader, json};
|
||||
use std::fs;
|
||||
use std::fs::File;
|
||||
use std::io::{BufReader, Read};
|
||||
|
@ -13,7 +18,13 @@ mod integration {
|
|||
use std::path::Path;
|
||||
use tempdir::TempDir;
|
||||
use zokrates_abi::{parse_strict, Encode};
|
||||
use zokrates_core::proof_system::marlin::SolidityProof;
|
||||
use zokrates_core::proof_system::{
|
||||
Fr, G1Affine, Marlin, Proof, Scheme, SolidityCompatibleField, SolidityCompatibleScheme,
|
||||
ToToken, G16, GM17, PGHR13, SOLIDITY_G2_ADDITION_LIB,
|
||||
};
|
||||
use zokrates_core::typed_absy::abi::Abi;
|
||||
use zokrates_field::Bn128Field;
|
||||
|
||||
macro_rules! map(
|
||||
{
|
||||
|
@ -27,7 +38,7 @@ mod integration {
|
|||
);
|
||||
|
||||
#[test]
|
||||
#[ignore]
|
||||
//#[ignore]
|
||||
fn test_compile_and_witness_dir() {
|
||||
// install nodejs dependencies for the verification contract tester
|
||||
install_nodejs_deps();
|
||||
|
@ -43,12 +54,15 @@ mod integration {
|
|||
let prog = dir.join(program_name).with_extension("zok");
|
||||
let witness = dir.join(program_name).with_extension("expected.witness");
|
||||
let json_input = dir.join(program_name).with_extension("arguments.json");
|
||||
test_compile_and_witness(
|
||||
program_name.to_str().unwrap(),
|
||||
&prog,
|
||||
&json_input,
|
||||
&witness,
|
||||
);
|
||||
|
||||
if program_name.to_str().unwrap() == "simple_mul" {
|
||||
test_compile_and_witness(
|
||||
program_name.to_str().unwrap(),
|
||||
&prog,
|
||||
&json_input,
|
||||
&witness,
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -56,10 +70,10 @@ mod integration {
|
|||
fn install_nodejs_deps() {
|
||||
let out_dir = concat!(env!("OUT_DIR"), "/contract");
|
||||
|
||||
assert_cli::Assert::command(&["npm", "install"])
|
||||
.current_dir(out_dir)
|
||||
.succeeds()
|
||||
.unwrap();
|
||||
// assert_cli::Assert::command(&["npm", "install"])
|
||||
// .current_dir(out_dir)
|
||||
// .succeeds()
|
||||
// .unwrap();
|
||||
}
|
||||
|
||||
fn test_compile_and_witness(
|
||||
|
@ -68,6 +82,8 @@ mod integration {
|
|||
inputs_path: &Path,
|
||||
expected_witness_path: &Path,
|
||||
) {
|
||||
println!("test {}", program_name);
|
||||
|
||||
let tmp_dir = TempDir::new(".tmp").unwrap();
|
||||
let tmp_base = tmp_dir.path();
|
||||
let test_case_path = tmp_base.join(program_name);
|
||||
|
@ -96,7 +112,7 @@ mod integration {
|
|||
|
||||
// prepare compile arguments
|
||||
let compile = vec![
|
||||
"../target/release/zokrates",
|
||||
"../target/debug/zokrates",
|
||||
"compile",
|
||||
"-i",
|
||||
program_path.to_str().unwrap(),
|
||||
|
@ -112,9 +128,8 @@ mod integration {
|
|||
assert_cli::Assert::command(&compile).succeeds().unwrap();
|
||||
|
||||
// COMPUTE_WITNESS
|
||||
|
||||
let compute = vec![
|
||||
"../target/release/zokrates",
|
||||
"../target/debug/zokrates",
|
||||
"compute-witness",
|
||||
"-i",
|
||||
flattened_path.to_str().unwrap(),
|
||||
|
@ -161,7 +176,7 @@ mod integration {
|
|||
.collect();
|
||||
|
||||
let mut compute_inline = vec![
|
||||
"../target/release/zokrates",
|
||||
"../target/debug/zokrates",
|
||||
"compute-witness",
|
||||
"-i",
|
||||
flattened_path.to_str().unwrap(),
|
||||
|
@ -220,16 +235,16 @@ mod integration {
|
|||
|
||||
#[cfg(not(feature = "libsnark"))]
|
||||
let backends = map! {
|
||||
"bellman" => vec!["g16"],
|
||||
"ark" => vec!["g16", "gm17", "marlin"]
|
||||
"bellman" => vec![],
|
||||
"ark" => vec!["marlin"]
|
||||
};
|
||||
|
||||
// GENERATE A UNIVERSAL SETUP
|
||||
assert_cli::Assert::command(&[
|
||||
"../target/release/zokrates",
|
||||
"../target/debug/zokrates",
|
||||
"universal-setup",
|
||||
"--size",
|
||||
"15",
|
||||
"5",
|
||||
"--proving-scheme",
|
||||
"marlin",
|
||||
])
|
||||
|
@ -238,9 +253,10 @@ mod integration {
|
|||
|
||||
for (backend, schemes) in backends {
|
||||
for scheme in &schemes {
|
||||
println!("test with {}, {}", backend, scheme);
|
||||
// SETUP
|
||||
let setup = assert_cli::Assert::command(&[
|
||||
"../target/release/zokrates",
|
||||
"../target/debug/zokrates",
|
||||
"setup",
|
||||
"-i",
|
||||
flattened_path.to_str().unwrap(),
|
||||
|
@ -258,10 +274,12 @@ mod integration {
|
|||
.doesnt_contain("This program is too small to generate a setup with Marlin")
|
||||
.execute();
|
||||
|
||||
println!("{:?}", setup);
|
||||
|
||||
if setup.is_ok() {
|
||||
// GENERATE-PROOF
|
||||
assert_cli::Assert::command(&[
|
||||
"../target/release/zokrates",
|
||||
"../target/debug/zokrates",
|
||||
"generate-proof",
|
||||
"-i",
|
||||
flattened_path.to_str().unwrap(),
|
||||
|
@ -281,7 +299,7 @@ mod integration {
|
|||
|
||||
// CLI VERIFICATION
|
||||
assert_cli::Assert::command(&[
|
||||
"../target/release/zokrates",
|
||||
"../target/debug/zokrates",
|
||||
"verify",
|
||||
"--backend",
|
||||
backend,
|
||||
|
@ -295,38 +313,183 @@ mod integration {
|
|||
.succeeds()
|
||||
.unwrap();
|
||||
|
||||
if scheme != &"marlin" {
|
||||
// EXPORT-VERIFIER
|
||||
assert_cli::Assert::command(&[
|
||||
"../target/release/zokrates",
|
||||
"export-verifier",
|
||||
"-i",
|
||||
verification_key_path.to_str().unwrap(),
|
||||
"-o",
|
||||
verification_contract_path.to_str().unwrap(),
|
||||
"--proving-scheme",
|
||||
scheme,
|
||||
])
|
||||
.succeeds()
|
||||
.unwrap();
|
||||
// EXPORT-VERIFIER
|
||||
println!("export verifier");
|
||||
assert_cli::Assert::command(&[
|
||||
"../target/debug/zokrates",
|
||||
"export-verifier",
|
||||
"-i",
|
||||
verification_key_path.to_str().unwrap(),
|
||||
"-o",
|
||||
verification_contract_path.to_str().unwrap(),
|
||||
"--proving-scheme",
|
||||
scheme,
|
||||
])
|
||||
.succeeds()
|
||||
.unwrap();
|
||||
|
||||
// TEST VERIFIER
|
||||
assert_cli::Assert::command(&[
|
||||
"node",
|
||||
"test.js",
|
||||
verification_contract_path.to_str().unwrap(),
|
||||
proof_path.to_str().unwrap(),
|
||||
scheme,
|
||||
])
|
||||
.current_dir(concat!(env!("OUT_DIR"), "/contract"))
|
||||
.succeeds()
|
||||
.unwrap();
|
||||
// TEST VERIFIER
|
||||
// Get the contract
|
||||
let contract_str =
|
||||
std::fs::read_to_string(verification_contract_path.to_str().unwrap())
|
||||
.unwrap();
|
||||
match *scheme {
|
||||
"marlin" => {
|
||||
// Get the proof
|
||||
let proof: Proof<Bn128Field, Marlin> = serde_json::from_reader(
|
||||
File::open(proof_path.to_str().unwrap()).unwrap(),
|
||||
)
|
||||
.unwrap();
|
||||
|
||||
test_solidity_verifier(contract_str, proof);
|
||||
}
|
||||
"g16" => {
|
||||
// Get the proof
|
||||
let proof: Proof<Bn128Field, G16> = serde_json::from_reader(
|
||||
File::open(proof_path.to_str().unwrap()).unwrap(),
|
||||
)
|
||||
.unwrap();
|
||||
|
||||
test_solidity_verifier(contract_str, proof);
|
||||
}
|
||||
"gm17" => {
|
||||
// Get the proof
|
||||
let proof: Proof<Bn128Field, GM17> = serde_json::from_reader(
|
||||
File::open(proof_path.to_str().unwrap()).unwrap(),
|
||||
)
|
||||
.unwrap();
|
||||
|
||||
test_solidity_verifier(contract_str, proof);
|
||||
}
|
||||
"pghr13" => {
|
||||
// Get the proof
|
||||
let proof: Proof<Bn128Field, PGHR13> = serde_json::from_reader(
|
||||
File::open(proof_path.to_str().unwrap()).unwrap(),
|
||||
)
|
||||
.unwrap();
|
||||
|
||||
test_solidity_verifier(contract_str, proof);
|
||||
}
|
||||
_ => unreachable!(),
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
fn test_solidity_verifier<S: SolidityCompatibleScheme<Bn128Field> + ToToken<Bn128Field>>(
|
||||
src: String,
|
||||
proof: Proof<Bn128Field, S>,
|
||||
) {
|
||||
use ethabi::Token;
|
||||
use rand::{SeedableRng, StdRng};
|
||||
use zokrates_solidity_test::{address::*, contract::*, evm::*, to_be_bytes};
|
||||
|
||||
// Setup EVM
|
||||
let mut rng = StdRng::from_seed(&[0]);
|
||||
let mut evm = Evm::new();
|
||||
let deployer = Address::random(&mut rng);
|
||||
evm.create_account(&deployer, 0);
|
||||
|
||||
let g2_lib_config = format!(
|
||||
r#"
|
||||
{{
|
||||
"language": "Solidity",
|
||||
"sources": {{
|
||||
"input.sol": {{ "content": {} }}
|
||||
}},
|
||||
"settings": {{
|
||||
"optimizer": {{ "enabled": {} }},
|
||||
"outputSelection": {{
|
||||
"*": {{
|
||||
"*": [
|
||||
"evm.bytecode.object", "abi"
|
||||
],
|
||||
"": [ "*" ] }} }}
|
||||
}}
|
||||
}}"#,
|
||||
json!(SOLIDITY_G2_ADDITION_LIB),
|
||||
true
|
||||
);
|
||||
|
||||
println!("compile lib");
|
||||
let g2_lib = Contract::compile_from_config(&g2_lib_config, "BN256G2").unwrap();
|
||||
|
||||
// Deploy lib
|
||||
let create_result = evm
|
||||
.deploy(g2_lib.encode_create_contract_bytes(&[]).unwrap(), &deployer)
|
||||
.unwrap();
|
||||
let lib_addr = create_result.addr.clone();
|
||||
|
||||
let solc_config = format!(
|
||||
r#"
|
||||
{{
|
||||
"language": "Solidity",
|
||||
"sources": {{
|
||||
"input.sol": {{ "content": {} }}
|
||||
}},
|
||||
"settings": {{
|
||||
"optimizer": {{ "enabled": {} }},
|
||||
"libraries": {{ "input.sol" : {{
|
||||
"BN256G2": "0x{}"
|
||||
}}
|
||||
}} ,
|
||||
"outputSelection": {{
|
||||
"*": {{
|
||||
"*": [
|
||||
"evm.bytecode.object", "abi"
|
||||
],
|
||||
"": [ "*" ] }} }}
|
||||
}}
|
||||
}}"#,
|
||||
json!(src),
|
||||
true,
|
||||
lib_addr.as_token()
|
||||
);
|
||||
|
||||
let contract = Contract::compile_from_config(&solc_config, "Verifier").unwrap();
|
||||
|
||||
// Deploy contract
|
||||
let create_result = evm
|
||||
.deploy(
|
||||
contract.encode_create_contract_bytes(&[]).unwrap(),
|
||||
&deployer,
|
||||
)
|
||||
.unwrap();
|
||||
let contract_addr = create_result.addr.clone();
|
||||
//println!("Contract deploy gas cost: {}", create_result.gas);
|
||||
|
||||
let solidity_proof = S::Proof::from(proof.proof);
|
||||
|
||||
let proof_token = S::to_token(solidity_proof);
|
||||
|
||||
let input_token = Token::Array(
|
||||
proof
|
||||
.inputs
|
||||
.iter()
|
||||
.map(|s| {
|
||||
let bytes = hex::decode(s.trim_start_matches("0x")).unwrap();
|
||||
debug_assert_eq!(bytes.len(), 32);
|
||||
Token::Uint(U256::from(&bytes[..]))
|
||||
})
|
||||
.collect::<Vec<_>>(),
|
||||
);
|
||||
|
||||
let inputs = [proof_token, input_token];
|
||||
|
||||
// Call verify function on contract
|
||||
let result = evm
|
||||
.call(
|
||||
contract
|
||||
.encode_call_contract_bytes("verifyTx", &inputs)
|
||||
.unwrap(),
|
||||
&contract_addr,
|
||||
&deployer,
|
||||
)
|
||||
.unwrap();
|
||||
assert_eq!(&result.out, &to_be_bytes(&U256::from(1)));
|
||||
}
|
||||
|
||||
fn test_compile_and_smtlib2(
|
||||
program_name: &str,
|
||||
program_path: &Path,
|
||||
|
@ -345,7 +508,7 @@ mod integration {
|
|||
|
||||
// prepare compile arguments
|
||||
let compile = vec![
|
||||
"../target/release/zokrates",
|
||||
"../target/debug/zokrates",
|
||||
"compile",
|
||||
"-i",
|
||||
program_path.to_str().unwrap(),
|
||||
|
@ -360,7 +523,7 @@ mod integration {
|
|||
|
||||
// prepare generate-smtlib2 arguments
|
||||
let gen = vec![
|
||||
"../target/release/zokrates",
|
||||
"../target/debug/zokrates",
|
||||
"generate-smtlib2",
|
||||
"-i",
|
||||
flattened_path.to_str().unwrap(),
|
||||
|
|
|
@ -25,7 +25,7 @@ typed-arena = "1.4.1"
|
|||
reduce = "0.1.1"
|
||||
# serialization and deserialization
|
||||
serde = { version = "1.0", features = ["derive"] }
|
||||
serde_json = "1.0"
|
||||
serde_json = { version = "1.0", features = ["preserve_order"] }
|
||||
serde_cbor = "0.11.2"
|
||||
hex = "0.4.2"
|
||||
regex = "0.2"
|
||||
|
@ -61,12 +61,12 @@ ark-poly-commit = { version = "^0.3.0", default-features = false, optional = tru
|
|||
ark-crypto-primitives = { version = "^0.3.0", default-features = false, optional = true }
|
||||
sha3 = { version = "0.9", optional = true }
|
||||
digest = { version = "0.9", optional = true }
|
||||
ethabi = { path = "../../ethabi/ethabi" }
|
||||
primitive-types = { version = "0.11", features = ["rlp"] }
|
||||
|
||||
[dev-dependencies]
|
||||
wasm-bindgen-test = "^0.3.0"
|
||||
pretty_assertions = "0.6.1"
|
||||
ethabi = "17.0.0"
|
||||
primitive-types = { version = "0.11", features = ["rlp"] }
|
||||
zokrates_fs_resolver = { version = "0.5", path = "../zokrates_fs_resolver"}
|
||||
zokrates_solidity_test = { path = "../zokrates_solidity_test"}
|
||||
|
||||
|
|
|
@ -95,6 +95,10 @@ impl<T, I: IntoIterator<Item = Statement<T>>> ProgIterator<T, I> {
|
|||
pub fn returns(&self) -> Vec<FlatVariable> {
|
||||
(0..self.return_count).map(FlatVariable::public).collect()
|
||||
}
|
||||
|
||||
pub fn public_count(&self) -> usize {
|
||||
self.arguments.iter().filter(|a| !a.private).count() + self.return_count
|
||||
}
|
||||
}
|
||||
|
||||
impl<T: Field, I: IntoIterator<Item = Statement<T>>> ProgIterator<T, I> {
|
||||
|
|
|
@ -46,7 +46,7 @@ impl<T: Field + ArkFieldExtensions + NotBw6_761Field> Backend<T, GM17> for Ark {
|
|||
program: ProgIterator<T, I>,
|
||||
witness: Witness<T>,
|
||||
proving_key: Vec<u8>,
|
||||
) -> Proof<<GM17 as Scheme<T>>::ProofPoints> {
|
||||
) -> Proof<T, GM17> {
|
||||
let computation = Computation::with_witness(program, witness);
|
||||
|
||||
let inputs = computation
|
||||
|
@ -72,10 +72,7 @@ impl<T: Field + ArkFieldExtensions + NotBw6_761Field> Backend<T, GM17> for Ark {
|
|||
Proof::new(proof_points, inputs)
|
||||
}
|
||||
|
||||
fn verify(
|
||||
vk: <GM17 as Scheme<T>>::VerificationKey,
|
||||
proof: Proof<<GM17 as Scheme<T>>::ProofPoints>,
|
||||
) -> bool {
|
||||
fn verify(vk: <GM17 as Scheme<T>>::VerificationKey, proof: Proof<T, GM17>) -> bool {
|
||||
let vk = VerifyingKey {
|
||||
h_g2: serialization::to_g2::<T>(vk.h),
|
||||
g_alpha_g1: serialization::to_g1::<T>(vk.g_alpha),
|
||||
|
@ -142,7 +139,7 @@ impl Backend<Bw6_761Field, GM17> for Ark {
|
|||
program: ProgIterator<Bw6_761Field, I>,
|
||||
witness: Witness<Bw6_761Field>,
|
||||
proving_key: Vec<u8>,
|
||||
) -> Proof<<GM17 as Scheme<Bw6_761Field>>::ProofPoints> {
|
||||
) -> Proof<Bw6_761Field, GM17> {
|
||||
let computation = Computation::with_witness(program, witness);
|
||||
|
||||
let inputs = computation
|
||||
|
@ -171,7 +168,7 @@ impl Backend<Bw6_761Field, GM17> for Ark {
|
|||
|
||||
fn verify(
|
||||
vk: <GM17 as Scheme<Bw6_761Field>>::VerificationKey,
|
||||
proof: Proof<<GM17 as Scheme<Bw6_761Field>>::ProofPoints>,
|
||||
proof: Proof<Bw6_761Field, GM17>,
|
||||
) -> bool {
|
||||
let vk = VerifyingKey {
|
||||
h_g2: serialization::to_g2_fq::<Bw6_761Field>(vk.h),
|
||||
|
|
|
@ -24,7 +24,7 @@ impl<T: Field + ArkFieldExtensions + NotBw6_761Field> Backend<T, G16> for Ark {
|
|||
program: ProgIterator<T, I>,
|
||||
witness: Witness<T>,
|
||||
proving_key: Vec<u8>,
|
||||
) -> Proof<<G16 as Scheme<T>>::ProofPoints> {
|
||||
) -> Proof<T, G16> {
|
||||
println!("{}", G16_WARNING);
|
||||
|
||||
let computation = Computation::with_witness(program, witness);
|
||||
|
@ -52,10 +52,7 @@ impl<T: Field + ArkFieldExtensions + NotBw6_761Field> Backend<T, G16> for Ark {
|
|||
Proof::new(proof_points, inputs)
|
||||
}
|
||||
|
||||
fn verify(
|
||||
vk: <G16 as Scheme<T>>::VerificationKey,
|
||||
proof: Proof<<G16 as Scheme<T>>::ProofPoints>,
|
||||
) -> bool {
|
||||
fn verify(vk: <G16 as Scheme<T>>::VerificationKey, proof: Proof<T, G16>) -> bool {
|
||||
let vk = VerifyingKey {
|
||||
alpha_g1: serialization::to_g1::<T>(vk.alpha),
|
||||
beta_g2: serialization::to_g2::<T>(vk.beta),
|
||||
|
@ -120,7 +117,7 @@ impl Backend<Bw6_761Field, G16> for Ark {
|
|||
program: ProgIterator<Bw6_761Field, I>,
|
||||
witness: Witness<Bw6_761Field>,
|
||||
proving_key: Vec<u8>,
|
||||
) -> Proof<<G16 as Scheme<Bw6_761Field>>::ProofPoints> {
|
||||
) -> Proof<Bw6_761Field, G16> {
|
||||
println!("{}", G16_WARNING);
|
||||
|
||||
let computation = Computation::with_witness(program, witness);
|
||||
|
@ -148,7 +145,7 @@ impl Backend<Bw6_761Field, G16> for Ark {
|
|||
|
||||
fn verify(
|
||||
vk: <G16 as Scheme<Bw6_761Field>>::VerificationKey,
|
||||
proof: Proof<<G16 as Scheme<Bw6_761Field>>::ProofPoints>,
|
||||
proof: Proof<Bw6_761Field, G16>,
|
||||
) -> bool {
|
||||
let vk = VerifyingKey {
|
||||
alpha_g1: serialization::to_g1::<Bw6_761Field>(vk.alpha),
|
||||
|
|
|
@ -212,10 +212,10 @@ impl<T: Field + ArkFieldExtensions> Backend<T, marlin::Marlin> for Ark {
|
|||
program: ProgIterator<T, I>,
|
||||
witness: Witness<T>,
|
||||
proving_key: Vec<u8>,
|
||||
) -> Proof<<marlin::Marlin as Scheme<T>>::ProofPoints> {
|
||||
) -> Proof<T, marlin::Marlin> {
|
||||
let computation = Computation::with_witness(program, witness);
|
||||
|
||||
let rng = &mut rand_0_8::rngs::StdRng::from_entropy();
|
||||
let rng = &mut rand_0_8::rngs::StdRng::from_seed([0; 32]);
|
||||
|
||||
let pk = IndexProverKey::<
|
||||
<<T as ArkFieldExtensions>::ArkEngine as PairingEngine>::Fr,
|
||||
|
@ -240,8 +240,7 @@ impl<T: Field + ArkFieldExtensions> Backend<T, marlin::Marlin> for Ark {
|
|||
|
||||
let proof = MarlinInst::<T>::prove(&pk, computation, rng).unwrap();
|
||||
|
||||
let mut serialized_proof: Vec<u8> = Vec::new();
|
||||
proof.serialize_uncompressed(&mut serialized_proof).unwrap();
|
||||
assert!(proof.pc_proof.evals.is_none());
|
||||
|
||||
Proof::new(
|
||||
ProofPoints {
|
||||
|
@ -257,26 +256,17 @@ impl<T: Field + ArkFieldExtensions> Backend<T, marlin::Marlin> for Ark {
|
|||
.map(|shifted_comm| parse_g1::<T>(&shifted_comm.0)),
|
||||
)
|
||||
})
|
||||
.collect::<Vec<_>>()
|
||||
.try_into()
|
||||
.unwrap()
|
||||
.collect()
|
||||
})
|
||||
.collect::<Vec<_>>()
|
||||
.try_into()
|
||||
.unwrap(),
|
||||
evaluations: proof.evaluations.into_iter().map(T::from_ark).collect(),
|
||||
pc_proof_proof: proof
|
||||
.pc_proof
|
||||
.proof
|
||||
.collect(),
|
||||
evaluations: proof
|
||||
.evaluations
|
||||
.into_iter()
|
||||
.map(|p| (parse_g1::<T>(&p.w), p.random_v.map(T::from_ark)))
|
||||
.collect::<Vec<_>>()
|
||||
.try_into()
|
||||
.unwrap(),
|
||||
pc_proof_evals: proof
|
||||
.pc_proof
|
||||
.evals
|
||||
.map(|evals| evals.into_iter().map(T::from_ark).collect()),
|
||||
.map(|e| parse_fr::<T>(&e))
|
||||
.collect(),
|
||||
pc_lc_opening_1: parse_g1::<T>(&proof.pc_proof.proof[0].w),
|
||||
pc_lc_opening_1_degree: parse_fr::<T>(&proof.pc_proof.proof[0].random_v.unwrap()),
|
||||
pc_lc_opening_2: parse_g1::<T>(&proof.pc_proof.proof[1].w),
|
||||
prover_messages_count: proof.prover_messages.len(),
|
||||
},
|
||||
inputs,
|
||||
|
@ -285,7 +275,7 @@ impl<T: Field + ArkFieldExtensions> Backend<T, marlin::Marlin> for Ark {
|
|||
|
||||
fn verify(
|
||||
vk: <marlin::Marlin as Scheme<T>>::VerificationKey,
|
||||
proof: Proof<<marlin::Marlin as Scheme<T>>::ProofPoints>,
|
||||
proof: Proof<T, marlin::Marlin>,
|
||||
) -> bool {
|
||||
let inputs: Vec<_> = proof
|
||||
.inputs
|
||||
|
@ -323,23 +313,32 @@ impl<T: Field + ArkFieldExtensions> Backend<T, marlin::Marlin> for Ark {
|
|||
.proof
|
||||
.evaluations
|
||||
.into_iter()
|
||||
.map(|v| v.into_ark())
|
||||
.map(|v| {
|
||||
T::try_from_str(v.trim_start_matches("0x"), 16)
|
||||
.unwrap()
|
||||
.into_ark()
|
||||
})
|
||||
.collect(),
|
||||
prover_messages: vec![ProverMsg::EmptyMessage; proof.proof.prover_messages_count],
|
||||
pc_proof: BatchLCProof {
|
||||
proof: proof
|
||||
.proof
|
||||
.pc_proof_proof
|
||||
.iter()
|
||||
.map(|(w, random_v)| KZG10Proof {
|
||||
w: serialization::to_g1::<T>(w.clone()),
|
||||
random_v: random_v.clone().map(|v| v.into_ark()),
|
||||
})
|
||||
.collect(),
|
||||
evals: proof
|
||||
.proof
|
||||
.pc_proof_evals
|
||||
.map(|evals| evals.into_iter().map(|eval| eval.into_ark()).collect()),
|
||||
proof: vec![
|
||||
KZG10Proof {
|
||||
w: serialization::to_g1::<T>(proof.proof.pc_lc_opening_1),
|
||||
random_v: Some(
|
||||
T::try_from_str(
|
||||
proof.proof.pc_lc_opening_1_degree.trim_start_matches("0x"),
|
||||
16,
|
||||
)
|
||||
.unwrap()
|
||||
.into_ark(),
|
||||
),
|
||||
},
|
||||
KZG10Proof {
|
||||
w: serialization::to_g1::<T>(proof.proof.pc_lc_opening_2),
|
||||
random_v: None,
|
||||
},
|
||||
],
|
||||
evals: None,
|
||||
},
|
||||
};
|
||||
|
||||
|
|
|
@ -25,7 +25,7 @@ impl<T: Field + BellmanFieldExtensions> Backend<T, G16> for Bellman {
|
|||
program: ProgIterator<T, I>,
|
||||
witness: Witness<T>,
|
||||
proving_key: Vec<u8>,
|
||||
) -> Proof<<G16 as Scheme<T>>::ProofPoints> {
|
||||
) -> Proof<T, G16> {
|
||||
println!("{}", G16_WARNING);
|
||||
|
||||
let computation = Computation::with_witness(program, witness);
|
||||
|
@ -47,10 +47,7 @@ impl<T: Field + BellmanFieldExtensions> Backend<T, G16> for Bellman {
|
|||
Proof::new(proof_points, public_inputs)
|
||||
}
|
||||
|
||||
fn verify(
|
||||
vk: <G16 as Scheme<T>>::VerificationKey,
|
||||
proof: Proof<<G16 as Scheme<T>>::ProofPoints>,
|
||||
) -> bool {
|
||||
fn verify(vk: <G16 as Scheme<T>>::VerificationKey, proof: Proof<T, G16>) -> bool {
|
||||
let vk = VerifyingKey {
|
||||
alpha_g1: serialization::to_g1::<T>(vk.alpha),
|
||||
beta_g1: <T::BellmanEngine as Engine>::G1Affine::one(), // not used during verification
|
||||
|
|
|
@ -13,6 +13,7 @@ pub use self::solidity::*;
|
|||
|
||||
use crate::ir;
|
||||
|
||||
use primitive_types::U256;
|
||||
use serde::de::DeserializeOwned;
|
||||
use serde::{Deserialize, Serialize};
|
||||
use zokrates_field::{Bls12_377Field, Bls12_381Field, Bn128Field, Field};
|
||||
|
@ -43,14 +44,14 @@ impl<V: Serialize + DeserializeOwned> SetupKeypair<V> {
|
|||
}
|
||||
|
||||
#[derive(Serialize, Deserialize)]
|
||||
pub struct Proof<T> {
|
||||
pub proof: T,
|
||||
pub inputs: Vec<String>,
|
||||
pub struct Proof<T: Field, S: Scheme<T>> {
|
||||
pub proof: S::ProofPoints,
|
||||
pub inputs: Vec<Fr>,
|
||||
}
|
||||
|
||||
#[allow(dead_code)]
|
||||
impl<T: Serialize + DeserializeOwned> Proof<T> {
|
||||
fn new(proof: T, inputs: Vec<String>) -> Self {
|
||||
impl<T: Field, S: Scheme<T>> Proof<T, S> {
|
||||
fn new(proof: S::ProofPoints, inputs: Vec<String>) -> Self {
|
||||
Proof { proof, inputs }
|
||||
}
|
||||
}
|
||||
|
@ -60,7 +61,7 @@ pub type Fq = String;
|
|||
pub type Fq2 = (String, String);
|
||||
|
||||
#[derive(Serialize, Deserialize, Clone, Debug)]
|
||||
pub struct G1Affine(Fq, Fq);
|
||||
pub struct G1Affine(pub Fq, pub Fq);
|
||||
|
||||
// When G2 is defined on Fq2 field
|
||||
#[derive(Serialize, Deserialize, Clone)]
|
||||
|
@ -93,14 +94,39 @@ impl ToString for G2Affine {
|
|||
}
|
||||
}
|
||||
|
||||
/// Helper methods for parsing group structure
|
||||
pub fn encode_g1_element(g: &G1Affine) -> (U256, U256) {
|
||||
(
|
||||
U256::from(&hex::decode(&g.0.trim_start_matches("0x")).unwrap()[..]),
|
||||
U256::from(&hex::decode(&g.1.trim_start_matches("0x")).unwrap()[..]),
|
||||
)
|
||||
}
|
||||
|
||||
pub fn encode_g2_element(g: &G2Affine) -> ((U256, U256), (U256, U256)) {
|
||||
(
|
||||
(
|
||||
U256::from(&hex::decode(&g.0 .0.trim_start_matches("0x")).unwrap()[..]),
|
||||
U256::from(&hex::decode(&g.0 .1.trim_start_matches("0x")).unwrap()[..]),
|
||||
),
|
||||
(
|
||||
U256::from(&hex::decode(&g.1 .0.trim_start_matches("0x")).unwrap()[..]),
|
||||
U256::from(&hex::decode(&g.1 .1.trim_start_matches("0x")).unwrap()[..]),
|
||||
),
|
||||
)
|
||||
}
|
||||
|
||||
pub fn encode_fr_element(f: &Fr) -> U256 {
|
||||
U256::from(&hex::decode(&f.trim_start_matches("0x")).unwrap()[..])
|
||||
}
|
||||
|
||||
pub trait Backend<T: Field, S: Scheme<T>> {
|
||||
fn generate_proof<I: IntoIterator<Item = ir::Statement<T>>>(
|
||||
program: ir::ProgIterator<T, I>,
|
||||
witness: ir::Witness<T>,
|
||||
proving_key: Vec<u8>,
|
||||
) -> Proof<S::ProofPoints>;
|
||||
) -> Proof<T, S>;
|
||||
|
||||
fn verify(vk: S::VerificationKey, proof: Proof<S::ProofPoints>) -> bool;
|
||||
fn verify(vk: S::VerificationKey, proof: Proof<T, S>) -> bool;
|
||||
}
|
||||
pub trait NonUniversalBackend<T: Field, S: NonUniversalScheme<T>>: Backend<T, S> {
|
||||
fn setup<I: IntoIterator<Item = ir::Statement<T>>>(
|
||||
|
|
|
@ -1,9 +1,10 @@
|
|||
use crate::proof_system::scheme::{NonUniversalScheme, Scheme};
|
||||
use crate::proof_system::solidity::{solidity_pairing_lib, SOLIDITY_G2_ADDITION_LIB};
|
||||
use crate::proof_system::{
|
||||
G1Affine, G2Affine, G2AffineFq, NotBw6_761Field, SolidityCompatibleField,
|
||||
SolidityCompatibleScheme,
|
||||
encode_g1_element, encode_g2_element, G1Affine, G2Affine, G2AffineFq, NotBw6_761Field,
|
||||
SolidityCompatibleField, SolidityCompatibleScheme, ToToken,
|
||||
};
|
||||
use ethabi::Token;
|
||||
use regex::Regex;
|
||||
use serde::{Deserialize, Serialize};
|
||||
use zokrates_field::{Bw6_761Field, Field};
|
||||
|
@ -42,7 +43,35 @@ impl Scheme<Bw6_761Field> for GM17 {
|
|||
type ProofPoints = ProofPoints<G1Affine, G2AffineFq>;
|
||||
}
|
||||
|
||||
impl<T: SolidityCompatibleField + NotBw6_761Field> ToToken<T> for GM17 {
|
||||
fn to_token(proof: Self::Proof) -> Token {
|
||||
let a = {
|
||||
let (x, y) = encode_g1_element(&proof.a);
|
||||
Token::Tuple(vec![Token::Uint(x), Token::Uint(y)])
|
||||
};
|
||||
|
||||
let b = {
|
||||
let ((x0, y0), (x1, y1)) = encode_g2_element(&proof.b);
|
||||
Token::Tuple(vec![
|
||||
Token::FixedArray(vec![Token::Uint(x0), Token::Uint(y0)]),
|
||||
Token::FixedArray(vec![Token::Uint(x1), Token::Uint(y1)]),
|
||||
])
|
||||
};
|
||||
|
||||
let c = {
|
||||
let (x, y) = encode_g1_element(&proof.c);
|
||||
Token::Tuple(vec![Token::Uint(x), Token::Uint(y)])
|
||||
};
|
||||
|
||||
let proof_tokens = vec![a, b, c];
|
||||
|
||||
Token::Tuple(proof_tokens)
|
||||
}
|
||||
}
|
||||
|
||||
impl<T: SolidityCompatibleField + NotBw6_761Field> SolidityCompatibleScheme<T> for GM17 {
|
||||
type Proof = Self::ProofPoints;
|
||||
|
||||
fn export_solidity_verifier(vk: <GM17 as Scheme<T>>::VerificationKey) -> String {
|
||||
let (mut template_text, solidity_pairing_lib) =
|
||||
(String::from(CONTRACT_TEMPLATE), solidity_pairing_lib(true));
|
||||
|
|
|
@ -1,8 +1,10 @@
|
|||
use crate::proof_system::scheme::{NonUniversalScheme, Scheme};
|
||||
use crate::proof_system::solidity::solidity_pairing_lib;
|
||||
use crate::proof_system::{
|
||||
G1Affine, G2Affine, MpcScheme, SolidityCompatibleField, SolidityCompatibleScheme,
|
||||
encode_g1_element, encode_g2_element, G1Affine, G2Affine, MpcScheme, SolidityCompatibleField,
|
||||
SolidityCompatibleScheme, ToToken,
|
||||
};
|
||||
use ethabi::Token;
|
||||
use regex::Regex;
|
||||
use serde::{Deserialize, Serialize};
|
||||
use zokrates_field::Field;
|
||||
|
@ -33,7 +35,35 @@ impl<T: Field> Scheme<T> for G16 {
|
|||
impl<T: Field> NonUniversalScheme<T> for G16 {}
|
||||
impl<T: Field> MpcScheme<T> for G16 {}
|
||||
|
||||
impl<T: SolidityCompatibleField> ToToken<T> for G16 {
|
||||
fn to_token(proof: Self::Proof) -> Token {
|
||||
let a = {
|
||||
let (x, y) = encode_g1_element(&proof.a);
|
||||
Token::Tuple(vec![Token::Uint(x), Token::Uint(y)])
|
||||
};
|
||||
|
||||
let b = {
|
||||
let ((x0, y0), (x1, y1)) = encode_g2_element(&proof.b);
|
||||
Token::Tuple(vec![
|
||||
Token::FixedArray(vec![Token::Uint(x0), Token::Uint(y0)]),
|
||||
Token::FixedArray(vec![Token::Uint(x1), Token::Uint(y1)]),
|
||||
])
|
||||
};
|
||||
|
||||
let c = {
|
||||
let (x, y) = encode_g1_element(&proof.c);
|
||||
Token::Tuple(vec![Token::Uint(x), Token::Uint(y)])
|
||||
};
|
||||
|
||||
let proof_tokens = vec![a, b, c];
|
||||
|
||||
Token::Tuple(proof_tokens)
|
||||
}
|
||||
}
|
||||
|
||||
impl<T: SolidityCompatibleField> SolidityCompatibleScheme<T> for G16 {
|
||||
type Proof = Self::ProofPoints;
|
||||
|
||||
fn export_solidity_verifier(vk: <G16 as Scheme<T>>::VerificationKey) -> String {
|
||||
let (mut template_text, solidity_pairing_lib_sans_bn256g2) =
|
||||
(String::from(CONTRACT_TEMPLATE), solidity_pairing_lib(false));
|
||||
|
|
|
@ -1,23 +1,56 @@
|
|||
use crate::proof_system::ark::parse_fr;
|
||||
use crate::proof_system::scheme::{Scheme, UniversalScheme};
|
||||
use crate::proof_system::solidity::{
|
||||
solidity_pairing_lib, SolidityCompatibleField, SolidityCompatibleScheme,
|
||||
};
|
||||
use crate::proof_system::{Fr, G1Affine, G2Affine, NotBw6_761Field};
|
||||
use crate::proof_system::{
|
||||
encode_fr_element, encode_g1_element, Fr, G1Affine, G2Affine, NotBw6_761Field, ToToken,
|
||||
};
|
||||
use ethabi::Token;
|
||||
use serde::{Deserialize, Serialize};
|
||||
use zokrates_field::Field;
|
||||
use zokrates_field::{ArkFieldExtensions, Field};
|
||||
|
||||
#[allow(clippy::upper_case_acronyms)]
|
||||
pub struct Marlin;
|
||||
|
||||
#[derive(Serialize, Deserialize)]
|
||||
pub struct ProofPoints<Fr, G1> {
|
||||
pub commitments: [[(G1, Option<G1>); 2]; 3],
|
||||
pub commitments: Vec<Vec<(G1, Option<G1>)>>,
|
||||
pub evaluations: Vec<Fr>,
|
||||
pub pc_proof_proof: [(G1, Option<Fr>); 2],
|
||||
pub pc_proof_evals: Option<Vec<Fr>>,
|
||||
pub pc_lc_opening_1: G1,
|
||||
pub pc_lc_opening_1_degree: Fr,
|
||||
pub pc_lc_opening_2: G1,
|
||||
pub prover_messages_count: usize,
|
||||
}
|
||||
|
||||
#[derive(Serialize, Deserialize)]
|
||||
pub struct SolidityProof<Fr, G1> {
|
||||
pub comms_1: Vec<G1>,
|
||||
pub comms_2: Vec<G1>,
|
||||
pub degree_bound_comms_2_g1: G1,
|
||||
pub comms_3: Vec<G1>,
|
||||
pub degree_bound_comms_3_g2: G1,
|
||||
pub evals: Vec<Fr>,
|
||||
pub batch_lc_proof_1: G1,
|
||||
pub batch_lc_proof_1_r: Fr,
|
||||
pub batch_lc_proof_2: G1,
|
||||
}
|
||||
|
||||
impl<Fr: Clone, G1: Clone> From<ProofPoints<Fr, G1>> for SolidityProof<Fr, G1> {
|
||||
fn from(p: ProofPoints<Fr, G1>) -> Self {
|
||||
SolidityProof {
|
||||
comms_1: p.commitments[0].clone().into_iter().map(|x| x.0).collect(),
|
||||
comms_2: p.commitments[1].clone().into_iter().map(|x| x.0).collect(),
|
||||
degree_bound_comms_2_g1: p.commitments[1][1].1.clone().unwrap(),
|
||||
comms_3: p.commitments[2].clone().into_iter().map(|x| x.0).collect(),
|
||||
degree_bound_comms_3_g2: p.commitments[2][0].1.clone().unwrap(),
|
||||
evals: p.evaluations,
|
||||
batch_lc_proof_1: p.pc_lc_opening_1,
|
||||
batch_lc_proof_1_r: p.pc_lc_opening_1_degree,
|
||||
batch_lc_proof_2: p.pc_lc_opening_2,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#[derive(Serialize, Deserialize)]
|
||||
pub struct KZGVerifierKey<G1, G2> {
|
||||
/// The generator of G1.
|
||||
|
@ -51,12 +84,93 @@ pub struct VerificationKey<Fr, G1, G2> {
|
|||
|
||||
impl<T: Field> Scheme<T> for Marlin {
|
||||
type VerificationKey = VerificationKey<Fr, G1Affine, G2Affine>;
|
||||
type ProofPoints = ProofPoints<T, G1Affine>;
|
||||
type ProofPoints = ProofPoints<Fr, G1Affine>;
|
||||
}
|
||||
|
||||
impl<T: Field> UniversalScheme<T> for Marlin {}
|
||||
|
||||
impl<T: SolidityCompatibleField + NotBw6_761Field> SolidityCompatibleScheme<T> for Marlin {
|
||||
impl<T: SolidityCompatibleField + ArkFieldExtensions + NotBw6_761Field> ToToken<T> for Marlin {
|
||||
fn to_token(proof: Self::Proof) -> Token {
|
||||
let comms_1_token = Token::Array(
|
||||
proof
|
||||
.comms_1
|
||||
.iter()
|
||||
.map(encode_g1_element)
|
||||
.map(|(x, y)| Token::Tuple(vec![Token::Uint(x), Token::Uint(y)]))
|
||||
.collect(),
|
||||
);
|
||||
|
||||
let comms_2_token = Token::Array(
|
||||
proof
|
||||
.comms_2
|
||||
.iter()
|
||||
.map(encode_g1_element)
|
||||
.map(|(x, y)| Token::Tuple(vec![Token::Uint(x), Token::Uint(y)]))
|
||||
.collect(),
|
||||
);
|
||||
|
||||
let degree_bound_comms_2_g1_token = {
|
||||
let (x, y) = encode_g1_element(&proof.degree_bound_comms_2_g1);
|
||||
Token::Tuple(vec![Token::Uint(x), Token::Uint(y)])
|
||||
};
|
||||
|
||||
let comms_3_token = Token::Array(
|
||||
proof
|
||||
.comms_3
|
||||
.iter()
|
||||
.map(encode_g1_element)
|
||||
.map(|(x, y)| Token::Tuple(vec![Token::Uint(x), Token::Uint(y)]))
|
||||
.collect(),
|
||||
);
|
||||
|
||||
let degree_bound_comms_3_g2_token = {
|
||||
let (x, y) = encode_g1_element(&proof.degree_bound_comms_3_g2);
|
||||
Token::Tuple(vec![Token::Uint(x), Token::Uint(y)])
|
||||
};
|
||||
|
||||
let evals_token = Token::Array(
|
||||
proof
|
||||
.evals
|
||||
.into_iter()
|
||||
.map(|f| encode_fr_element(&f))
|
||||
.map(Token::Uint)
|
||||
.collect::<Vec<_>>(),
|
||||
);
|
||||
|
||||
let pc_lc_opening_1_token = {
|
||||
let (x, y) = encode_g1_element(&proof.batch_lc_proof_1);
|
||||
Token::Tuple(vec![Token::Uint(x), Token::Uint(y)])
|
||||
};
|
||||
|
||||
let degree_bound_pc_lc_opening_1_token =
|
||||
Token::Uint(encode_fr_element(&proof.batch_lc_proof_1_r));
|
||||
|
||||
let pc_lc_opening_2_token = {
|
||||
let (x, y) = encode_g1_element(&proof.batch_lc_proof_2);
|
||||
Token::Tuple(vec![Token::Uint(x), Token::Uint(y)])
|
||||
};
|
||||
|
||||
let proof_tokens = vec![
|
||||
comms_1_token,
|
||||
comms_2_token,
|
||||
degree_bound_comms_2_g1_token,
|
||||
comms_3_token,
|
||||
degree_bound_comms_3_g2_token,
|
||||
evals_token,
|
||||
pc_lc_opening_1_token,
|
||||
degree_bound_pc_lc_opening_1_token,
|
||||
pc_lc_opening_2_token,
|
||||
];
|
||||
|
||||
Token::Tuple(proof_tokens)
|
||||
}
|
||||
}
|
||||
|
||||
impl<T: SolidityCompatibleField + NotBw6_761Field + ArkFieldExtensions> SolidityCompatibleScheme<T>
|
||||
for Marlin
|
||||
{
|
||||
type Proof = SolidityProof<Fr, G1Affine>;
|
||||
|
||||
fn export_solidity_verifier(vk: <Marlin as Scheme<T>>::VerificationKey) -> String {
|
||||
let (template, solidity_pairing_lib) =
|
||||
(String::from(CONTRACT_TEMPLATE), solidity_pairing_lib(false));
|
||||
|
@ -176,6 +290,10 @@ impl<T: SolidityCompatibleField + NotBw6_761Field> SolidityCompatibleScheme<T> f
|
|||
};
|
||||
size.to_string()
|
||||
})
|
||||
.replace(
|
||||
"<%num_instance_variables%>",
|
||||
&vk.num_instance_variables.to_string(),
|
||||
)
|
||||
.replace("<%x_root%>", &vk.x_root_of_unity.to_string())
|
||||
.replace(
|
||||
"<%f_mod%>",
|
||||
|
@ -229,7 +347,12 @@ contract Verifier {
|
|||
vk.g1_shift = Pairing.G1Point(<%vk_g1_shift%>);
|
||||
vk.g2_shift = Pairing.G1Point(<%vk_g2_shift%>);
|
||||
}
|
||||
function verify(uint256[] memory input, Proof memory proof) public view returns (bool) {
|
||||
|
||||
function verifyTx(Proof memory proof, uint256[] memory input) public view returns (bool) {
|
||||
return verifyTxAux(input, proof);
|
||||
}
|
||||
|
||||
function verifyTxAux(uint256[] memory input, Proof memory proof) internal view returns (bool) {
|
||||
VerifierKey memory vk = verifierKey();
|
||||
for (uint i = 0; i < input.length; i++) {
|
||||
require(input[i] < <%f_mod%>);
|
||||
|
@ -632,118 +755,15 @@ mod tests {
|
|||
use crate::ir::{Interpreter, Prog, QuadComb, Statement};
|
||||
use crate::proof_system::ark::{parse_fr, Ark};
|
||||
use crate::proof_system::{Backend, Fr, Proof, UniversalBackend};
|
||||
use zokrates_field::ArkFieldExtensions;
|
||||
|
||||
use super::*;
|
||||
use ethabi::token::{LenientTokenizer, StrictTokenizer, Tokenizer};
|
||||
use ethabi::Token;
|
||||
use primitive_types::U256;
|
||||
use primitive_types::{H160, U256};
|
||||
use rand_0_8::{rngs::StdRng, SeedableRng};
|
||||
use zokrates_field::Bn128Field;
|
||||
use zokrates_solidity_test::{address::Address, contract::Contract, evm::Evm, to_be_bytes};
|
||||
|
||||
/// Helper methods for parsing group structure
|
||||
pub fn encode_g1_element(g: &G1Affine) -> Token {
|
||||
Token::Tuple(vec![
|
||||
Token::Uint(U256::from(
|
||||
&hex::decode(&g.0.trim_start_matches("0x")).unwrap()[..],
|
||||
)),
|
||||
Token::Uint(U256::from(
|
||||
&hex::decode(&g.1.trim_start_matches("0x")).unwrap()[..],
|
||||
)),
|
||||
])
|
||||
}
|
||||
|
||||
//pub fn encode_g2_element(g: &G2Affine) -> Token {
|
||||
// Token::Tuple(vec![
|
||||
// Token::FixedArray(vec![
|
||||
// Token::Uint(U256::from(&hex::decode(&g.0.0.trim_start_matches("0x")).unwrap()[..])),
|
||||
// Token::Uint(U256::from(&hex::decode(&g.0.1.trim_start_matches("0x")).unwrap()[..])),
|
||||
// ]),
|
||||
// Token::FixedArray(vec![
|
||||
// Token::Uint(U256::from(&hex::decode(&g.1.0.trim_start_matches("0x")).unwrap()[..])),
|
||||
// Token::Uint(U256::from(&hex::decode(&g.1.1.trim_start_matches("0x")).unwrap()[..])),
|
||||
// ]),
|
||||
// ])
|
||||
//}
|
||||
|
||||
pub fn encode_fr_element(f: &Fr) -> Token {
|
||||
Token::Uint(U256::from(
|
||||
&hex::decode(&f.trim_start_matches("0x")).unwrap()[..],
|
||||
))
|
||||
}
|
||||
|
||||
fn encode_verify_input(
|
||||
proof: Proof<<Marlin as Scheme<Bn128Field>>::ProofPoints>,
|
||||
) -> Vec<Token> {
|
||||
let input = Token::Array(
|
||||
proof
|
||||
.inputs
|
||||
.iter()
|
||||
.map(|s| {
|
||||
let bytes = hex::decode(s.trim_start_matches("0x")).unwrap();
|
||||
debug_assert_eq!(bytes.len(), 32);
|
||||
Token::Uint(U256::from(&bytes[..]))
|
||||
})
|
||||
.collect::<Vec<_>>(),
|
||||
);
|
||||
|
||||
let comms_1_token = Token::Array(
|
||||
proof.proof.commitments[0]
|
||||
.iter()
|
||||
.map(|(c, _)| encode_g1_element(c))
|
||||
.collect::<Vec<_>>(),
|
||||
);
|
||||
|
||||
let comms_2_token = Token::Array(
|
||||
proof.proof.commitments[1]
|
||||
.iter()
|
||||
.map(|(c, _)| encode_g1_element(c))
|
||||
.collect::<Vec<_>>(),
|
||||
);
|
||||
|
||||
let degree_bound_comms_2_g1_token =
|
||||
encode_g1_element(proof.proof.commitments[1][1].1.as_ref().unwrap());
|
||||
|
||||
let comms_3_token = Token::Array(
|
||||
proof.proof.commitments[2]
|
||||
.iter()
|
||||
.map(|(c, _)| encode_g1_element(c))
|
||||
.collect::<Vec<_>>(),
|
||||
);
|
||||
|
||||
let degree_bound_comms_3_g2_token =
|
||||
encode_g1_element(proof.proof.commitments[2][0].1.as_ref().unwrap());
|
||||
|
||||
let evals_token = Token::Array(
|
||||
proof
|
||||
.proof
|
||||
.evaluations
|
||||
.into_iter()
|
||||
.map(|f| encode_fr_element(&parse_fr::<Bn128Field>(&Bn128Field::into_ark(f))))
|
||||
.collect::<Vec<_>>(),
|
||||
);
|
||||
|
||||
let pc_lc_opening_1_token = encode_g1_element(&proof.proof.pc_proof_proof[0].0);
|
||||
let degree_bound_pc_lc_opening_1_token = encode_fr_element(&parse_fr::<Bn128Field>(
|
||||
&Bn128Field::into_ark(proof.proof.pc_proof_proof[0].1.clone().unwrap()),
|
||||
));
|
||||
let pc_lc_opening_2_token = encode_g1_element(&proof.proof.pc_proof_proof[1].0);
|
||||
|
||||
let proof_tokens = vec![
|
||||
comms_1_token,
|
||||
comms_2_token,
|
||||
degree_bound_comms_2_g1_token,
|
||||
comms_3_token,
|
||||
degree_bound_comms_3_g2_token,
|
||||
evals_token,
|
||||
pc_lc_opening_1_token,
|
||||
degree_bound_pc_lc_opening_1_token,
|
||||
pc_lc_opening_2_token,
|
||||
];
|
||||
|
||||
vec![input, Token::Tuple(proof_tokens)]
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn verify_solidity_bn128() {
|
||||
let program: Prog<Bn128Field> = Prog {
|
||||
|
@ -768,7 +788,7 @@ mod tests {
|
|||
let interpreter = Interpreter::default();
|
||||
|
||||
let witness = interpreter
|
||||
.execute(program.clone(), &[Bn128Field::from(42)])
|
||||
.execute(program.clone(), &[Bn128Field::from(42u32)])
|
||||
.unwrap();
|
||||
|
||||
let proof = <Ark as Backend<Bn128Field, Marlin>>::generate_proof(
|
||||
|
@ -777,8 +797,8 @@ mod tests {
|
|||
keypair.pk,
|
||||
);
|
||||
|
||||
//let ans = <Ark as Backend<Bn128Field, Marlin>>::verify(keypair.vk, proof);
|
||||
//assert!(ans);
|
||||
// let ans = <Ark as Backend<Bn128Field, Marlin>>::verify(keypair.vk, proof);
|
||||
// assert!(ans);
|
||||
|
||||
let mut src =
|
||||
<Marlin as SolidityCompatibleScheme<Bn128Field>>::export_solidity_verifier(keypair.vk);
|
||||
|
@ -808,7 +828,7 @@ mod tests {
|
|||
// Setup EVM
|
||||
let mut rng = StdRng::seed_from_u64(0u64);
|
||||
let mut evm = Evm::new();
|
||||
let deployer = Address::random(&mut rng);
|
||||
let deployer = Address::from(H160::zero());
|
||||
evm.create_account(&deployer, 0);
|
||||
|
||||
// Deploy contract
|
||||
|
@ -821,11 +841,27 @@ mod tests {
|
|||
let contract_addr = create_result.addr.clone();
|
||||
//println!("Contract deploy gas cost: {}", create_result.gas);
|
||||
|
||||
let solidity_proof =
|
||||
<Marlin as SolidityCompatibleScheme<Bn128Field>>::Proof::from(proof.proof);
|
||||
let proof_token = <Marlin as ToToken<Bn128Field>>::to_token(solidity_proof);
|
||||
let input_token = Token::Array(
|
||||
proof
|
||||
.inputs
|
||||
.iter()
|
||||
.map(|s| {
|
||||
let bytes = hex::decode(s.trim_start_matches("0x")).unwrap();
|
||||
debug_assert_eq!(bytes.len(), 32);
|
||||
Token::Uint(U256::from(&bytes[..]))
|
||||
})
|
||||
.collect::<Vec<_>>(),
|
||||
);
|
||||
let inputs = [proof_token, input_token];
|
||||
|
||||
// Call verify function on contract
|
||||
let result = evm
|
||||
.call(
|
||||
contract
|
||||
.encode_call_contract_bytes("verify", &encode_verify_input(proof))
|
||||
.encode_call_contract_bytes("verifyTx", &inputs)
|
||||
.unwrap(),
|
||||
&contract_addr,
|
||||
&deployer,
|
||||
|
|
|
@ -1,6 +1,10 @@
|
|||
use crate::proof_system::scheme::{NonUniversalScheme, Scheme};
|
||||
use crate::proof_system::solidity::solidity_pairing_lib;
|
||||
use crate::proof_system::{G1Affine, G2Affine, SolidityCompatibleField, SolidityCompatibleScheme};
|
||||
use crate::proof_system::{
|
||||
encode_g1_element, encode_g2_element, G1Affine, G2Affine, SolidityCompatibleField,
|
||||
SolidityCompatibleScheme, ToToken,
|
||||
};
|
||||
use ethabi::Token;
|
||||
use regex::Regex;
|
||||
use serde::{Deserialize, Serialize};
|
||||
use zokrates_field::Field;
|
||||
|
@ -39,7 +43,60 @@ impl<T: Field> Scheme<T> for PGHR13 {
|
|||
|
||||
impl<T: Field> NonUniversalScheme<T> for PGHR13 {}
|
||||
|
||||
impl<T: SolidityCompatibleField> ToToken<T> for PGHR13 {
|
||||
fn to_token(proof: Self::Proof) -> Token {
|
||||
let a = {
|
||||
let (x, y) = encode_g1_element(&proof.a);
|
||||
Token::Tuple(vec![Token::Uint(x), Token::Uint(y)])
|
||||
};
|
||||
|
||||
let a_p = {
|
||||
let (x, y) = encode_g1_element(&proof.a_p);
|
||||
Token::Tuple(vec![Token::Uint(x), Token::Uint(y)])
|
||||
};
|
||||
|
||||
let b = {
|
||||
let ((x0, y0), (x1, y1)) = encode_g2_element(&proof.b);
|
||||
Token::Tuple(vec![
|
||||
Token::FixedArray(vec![Token::Uint(x0), Token::Uint(y0)]),
|
||||
Token::FixedArray(vec![Token::Uint(x1), Token::Uint(y1)]),
|
||||
])
|
||||
};
|
||||
|
||||
let b_p = {
|
||||
let (x, y) = encode_g1_element(&proof.b_p);
|
||||
Token::Tuple(vec![Token::Uint(x), Token::Uint(y)])
|
||||
};
|
||||
|
||||
let c = {
|
||||
let (x, y) = encode_g1_element(&proof.c);
|
||||
Token::Tuple(vec![Token::Uint(x), Token::Uint(y)])
|
||||
};
|
||||
|
||||
let c_p = {
|
||||
let (x, y) = encode_g1_element(&proof.c_p);
|
||||
Token::Tuple(vec![Token::Uint(x), Token::Uint(y)])
|
||||
};
|
||||
|
||||
let h = {
|
||||
let (x, y) = encode_g1_element(&proof.h);
|
||||
Token::Tuple(vec![Token::Uint(x), Token::Uint(y)])
|
||||
};
|
||||
|
||||
let k = {
|
||||
let (x, y) = encode_g1_element(&proof.k);
|
||||
Token::Tuple(vec![Token::Uint(x), Token::Uint(y)])
|
||||
};
|
||||
|
||||
let proof_tokens = vec![a, a_p, b, b_p, c, c_p, h, k];
|
||||
|
||||
Token::Tuple(proof_tokens)
|
||||
}
|
||||
}
|
||||
|
||||
impl<T: SolidityCompatibleField> SolidityCompatibleScheme<T> for PGHR13 {
|
||||
type Proof = Self::ProofPoints;
|
||||
|
||||
fn export_solidity_verifier(vk: <PGHR13 as Scheme<T>>::VerificationKey) -> String {
|
||||
let (mut template_text, solidity_pairing_lib) =
|
||||
(String::from(CONTRACT_TEMPLATE), solidity_pairing_lib(false));
|
||||
|
|
|
@ -1,12 +1,18 @@
|
|||
use crate::proof_system::Scheme;
|
||||
use serde::{de::DeserializeOwned, Serialize};
|
||||
use zokrates_field::{Bn128Field, Field};
|
||||
|
||||
pub trait SolidityCompatibleField: Field {}
|
||||
impl SolidityCompatibleField for Bn128Field {}
|
||||
|
||||
pub trait SolidityCompatibleScheme<T: SolidityCompatibleField>: Scheme<T> {
|
||||
type Proof: From<Self::ProofPoints> + Serialize + DeserializeOwned;
|
||||
|
||||
fn export_solidity_verifier(vk: Self::VerificationKey) -> String;
|
||||
}
|
||||
pub trait ToToken<T: SolidityCompatibleField>: SolidityCompatibleScheme<T> {
|
||||
fn to_token(proof: Self::Proof) -> ethabi::Token;
|
||||
}
|
||||
|
||||
pub const SOLIDITY_G2_ADDITION_LIB: &str = r#"// SPDX-License-Identifier: LGPL-3.0-only
|
||||
// This file is LGPL3 Licensed
|
||||
|
|
|
@ -13,7 +13,7 @@ serde = "1.0"
|
|||
serde_derive = "1.0"
|
||||
lazy_static = "1.4"
|
||||
bincode = "0.8.0"
|
||||
serde_json = "1.0"
|
||||
serde_json = { version = "1.0", features = ["preserve_order"] }
|
||||
sha2 = "0.8.0"
|
||||
num-traits = { version = "0.2", default-features = false }
|
||||
num-integer = { version = "0.1", default-features = false }
|
||||
|
|
|
@ -10,7 +10,7 @@ crate-type = ["cdylib"]
|
|||
[dependencies]
|
||||
js-sys = "0.3.33"
|
||||
serde = { version = "^1.0.59", features = ["derive"] }
|
||||
serde_json = "1.0"
|
||||
serde_json = { version = "1.0", features = ["preserve_order"] }
|
||||
wasm-bindgen = { version = "0.2.46", features = ["serde-serialize"] }
|
||||
typed-arena = "1.4.1"
|
||||
zokrates_core = { path = "../zokrates_core", features = ["wasm", "bellman"], default-features = false }
|
||||
|
|
|
@ -7,12 +7,12 @@ edition = "2018"
|
|||
# Modeled after the testing pipeline of the Fe project: https://github.com/ethereum/fe/
|
||||
|
||||
[dependencies]
|
||||
ethabi = "17.0.0"
|
||||
ethabi = { path = "../../ethabi/ethabi" }
|
||||
primitive-types = { version = "0.11", features = ["rlp"] }
|
||||
hex = { version = "0.4" }
|
||||
bytes = { version = "1.1", default-features = false }
|
||||
serde_json = { version = "1.0" }
|
||||
rand = { version = "0.8" }
|
||||
rand = { version = "0.4" }
|
||||
|
||||
revm = { git = "https://github.com/bluealloy/revm", version = "1.2" }
|
||||
solc = { git = "https://github.com/g-r-a-n-t/solc-rust", rev = "52d4146" }
|
||||
|
|
|
@ -86,8 +86,11 @@ impl Contract {
|
|||
["object"]
|
||||
.to_string()
|
||||
.replace("\"", "");
|
||||
let binary = hex::decode(&hex_code)
|
||||
.map_err(|_| Box::new(EvmTestError("decode hex binary failed".to_string())))?;
|
||||
|
||||
let binary = hex::decode(&hex_code).map_err(|e| {
|
||||
println!("{}", e);
|
||||
Box::new(EvmTestError("decode hex binary failed".to_string()))
|
||||
})?;
|
||||
binary
|
||||
};
|
||||
let abi = {
|
||||
|
@ -131,9 +134,7 @@ impl Contract {
|
|||
) -> Result<Vec<u8>, Error> {
|
||||
match self.abi.functions.get(fn_name) {
|
||||
Some(f) => {
|
||||
//let c = f[0].inputs.iter().map(|p| p.kind.clone()).collect::<Vec<_>>();
|
||||
//println!("{:?}", c);
|
||||
let call_binary = f[0].encode_input(input).map_err(|_| {
|
||||
let call_binary = f[0].encode_input(input).map_err(|e| {
|
||||
Box::new(EvmTestError(
|
||||
"abi function failed to encode inputs".to_string(),
|
||||
))
|
||||
|
|
|
@ -75,7 +75,6 @@ mod tests {
|
|||
)
|
||||
.unwrap();
|
||||
assert_eq!(&get_result.out, &to_be_bytes(&U256::from(0)));
|
||||
println!("{:?}", get_result);
|
||||
|
||||
// Call set function on contract
|
||||
let set_result = evm
|
||||
|
@ -90,7 +89,6 @@ mod tests {
|
|||
&deployer,
|
||||
)
|
||||
.unwrap();
|
||||
println!("{:?}", set_result);
|
||||
|
||||
// Call get function on contract
|
||||
let get_result = evm
|
||||
|
|
|
@ -11,7 +11,7 @@ zokrates_fs_resolver = { version = "0.5", path = "../zokrates_fs_resolver" }
|
|||
zokrates_abi = { version = "0.1", path = "../zokrates_abi" }
|
||||
serde = "1.0"
|
||||
serde_derive = "1.0"
|
||||
serde_json = "1.0"
|
||||
serde_json = { version = "1.0", features = ["preserve_order"] }
|
||||
typed-arena = "1.4.1"
|
||||
|
||||
[lib]
|
||||
|
|
Loading…
Reference in a new issue