Initial commit

Plonk working
main
Bazsalanszky 2023-12-05 00:05:53 +01:00
parent 41ad4a6c9d
commit d8312e32f8
No known key found for this signature in database
GPG Key ID: B40814F4EFE23F96
47 changed files with 1114 additions and 16 deletions

0
.devcontainer/devcontainer.json 100644 → 100755
View File

0
.editorconfig 100644 → 100755
View File

0
.github/ISSUE_TEMPLATE/config.yml vendored 100644 → 100755
View File

0
.github/dependabot.yml vendored 100644 → 100755
View File

0
.github/workflows/check.yml vendored 100644 → 100755
View File

0
.github/workflows/release.yml vendored 100644 → 100755
View File

0
.gitignore vendored 100644 → 100755
View File

0
.vscode/tasks.json vendored 100644 → 100755
View File

0
CODEOWNERS 100644 → 100755
View File

676
Cargo.lock generated 100644 → 100755
View File

@ -147,6 +147,12 @@ dependencies = [
"opaque-debug 0.3.0",
]
[[package]]
name = "ahash"
version = "0.4.8"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "0453232ace82dee0dd0b4c87a59bd90f7b53b314f3e0f61fe2ee7c8a16482289"
[[package]]
name = "ahash"
version = "0.7.6"
@ -272,6 +278,344 @@ version = "1.6.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "bddcadddf5e9015d310179a59bb28c4d4b9920ad0f11e8e14dbadf654890c9a6"
[[package]]
name = "ark-bls12-381"
version = "0.4.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "c775f0d12169cba7aae4caeb547bb6a50781c7449a8aa53793827c9ec4abf488"
dependencies = [
"ark-ec 0.4.2",
"ark-ff 0.4.2",
"ark-serialize 0.4.2",
"ark-std 0.4.0",
]
[[package]]
name = "ark-bn254"
version = "0.4.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "a22f4561524cd949590d78d7d4c5df8f592430d221f7f3c9497bbafd8972120f"
dependencies = [
"ark-ec 0.4.2",
"ark-ff 0.4.2",
"ark-std 0.4.0",
]
[[package]]
name = "ark-crypto-primitives"
version = "0.3.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "ff773c0ef8c655c98071d3026a63950798a66b2f45baef22d8334c1756f1bd18"
dependencies = [
"ark-ec 0.3.0",
"ark-ff 0.3.0",
"ark-relations 0.3.0",
"ark-serialize 0.3.0",
"ark-snark 0.3.0",
"ark-std 0.3.0",
"blake2 0.9.2",
"derivative",
"digest 0.9.0",
]
[[package]]
name = "ark-crypto-primitives"
version = "0.4.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "1f3a13b34da09176a8baba701233fdffbaa7c1b1192ce031a3da4e55ce1f1a56"
dependencies = [
"ark-ec 0.4.2",
"ark-ff 0.4.2",
"ark-relations 0.4.0",
"ark-serialize 0.4.2",
"ark-snark 0.4.0",
"ark-std 0.4.0",
"blake2 0.10.6",
"derivative",
"digest 0.10.7",
"sha2 0.10.7",
]
[[package]]
name = "ark-ec"
version = "0.3.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "dea978406c4b1ca13c2db2373b05cc55429c3575b8b21f1b9ee859aa5b03dd42"
dependencies = [
"ark-ff 0.3.0",
"ark-serialize 0.3.0",
"ark-std 0.3.0",
"derivative",
"num-traits",
"zeroize",
]
[[package]]
name = "ark-ec"
version = "0.4.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "defd9a439d56ac24968cca0571f598a61bc8c55f71d50a89cda591cb750670ba"
dependencies = [
"ark-ff 0.4.2",
"ark-poly 0.4.2",
"ark-serialize 0.4.2",
"ark-std 0.4.0",
"derivative",
"hashbrown 0.13.2",
"itertools 0.10.5",
"num-traits",
"zeroize",
]
[[package]]
name = "ark-ff"
version = "0.3.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "6b3235cc41ee7a12aaaf2c575a2ad7b46713a8a50bda2fc3b003a04845c05dd6"
dependencies = [
"ark-ff-asm 0.3.0",
"ark-ff-macros 0.3.0",
"ark-serialize 0.3.0",
"ark-std 0.3.0",
"derivative",
"num-bigint",
"num-traits",
"paste",
"rustc_version 0.3.3",
"zeroize",
]
[[package]]
name = "ark-ff"
version = "0.4.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "ec847af850f44ad29048935519032c33da8aa03340876d351dfab5660d2966ba"
dependencies = [
"ark-ff-asm 0.4.2",
"ark-ff-macros 0.4.2",
"ark-serialize 0.4.2",
"ark-std 0.4.0",
"derivative",
"digest 0.10.7",
"itertools 0.10.5",
"num-bigint",
"num-traits",
"paste",
"rustc_version 0.4.0",
"zeroize",
]
[[package]]
name = "ark-ff-asm"
version = "0.3.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "db02d390bf6643fb404d3d22d31aee1c4bc4459600aef9113833d17e786c6e44"
dependencies = [
"quote",
"syn 1.0.109",
]
[[package]]
name = "ark-ff-asm"
version = "0.4.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "3ed4aa4fe255d0bc6d79373f7e31d2ea147bcf486cba1be5ba7ea85abdb92348"
dependencies = [
"quote",
"syn 1.0.109",
]
[[package]]
name = "ark-ff-macros"
version = "0.3.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "db2fd794a08ccb318058009eefdf15bcaaaaf6f8161eb3345f907222bac38b20"
dependencies = [
"num-bigint",
"num-traits",
"quote",
"syn 1.0.109",
]
[[package]]
name = "ark-ff-macros"
version = "0.4.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "7abe79b0e4288889c4574159ab790824d0033b9fdcb2a112a3182fac2e514565"
dependencies = [
"num-bigint",
"num-traits",
"proc-macro2",
"quote",
"syn 1.0.109",
]
[[package]]
name = "ark-gm17"
version = "0.3.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "94713045868e99a606a89825ff5a901667ba707ad1966a32c7f3a4d4dbcc0e9a"
dependencies = [
"ark-crypto-primitives 0.3.0",
"ark-ec 0.3.0",
"ark-ff 0.3.0",
"ark-poly 0.3.0",
"ark-relations 0.3.0",
"ark-serialize 0.3.0",
"ark-std 0.3.0",
]
[[package]]
name = "ark-groth16"
version = "0.4.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "20ceafa83848c3e390f1cbf124bc3193b3e639b3f02009e0e290809a501b95fc"
dependencies = [
"ark-crypto-primitives 0.4.0",
"ark-ec 0.4.2",
"ark-ff 0.4.2",
"ark-poly 0.4.2",
"ark-relations 0.4.0",
"ark-serialize 0.4.2",
"ark-std 0.4.0",
]
[[package]]
name = "ark-poly"
version = "0.3.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "7b0f78f47537c2f15706db7e98fe64cc1711dbf9def81218194e17239e53e5aa"
dependencies = [
"ark-ff 0.3.0",
"ark-serialize 0.3.0",
"ark-std 0.3.0",
"derivative",
"hashbrown 0.11.2",
]
[[package]]
name = "ark-poly"
version = "0.4.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "d320bfc44ee185d899ccbadfa8bc31aab923ce1558716e1997a1e74057fe86bf"
dependencies = [
"ark-ff 0.4.2",
"ark-serialize 0.4.2",
"ark-std 0.4.0",
"derivative",
"hashbrown 0.13.2",
]
[[package]]
name = "ark-relations"
version = "0.3.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "4cba4c1c99792a6834bd97f7fd76578ec2cd58d2afc5139a17e1d1bec65b38f6"
dependencies = [
"ark-ff 0.3.0",
"ark-std 0.3.0",
"tracing",
]
[[package]]
name = "ark-relations"
version = "0.4.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "00796b6efc05a3f48225e59cb6a2cda78881e7c390872d5786aaf112f31fb4f0"
dependencies = [
"ark-ff 0.4.2",
"ark-std 0.4.0",
"tracing",
]
[[package]]
name = "ark-serialize"
version = "0.3.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "1d6c2b318ee6e10f8c2853e73a83adc0ccb88995aa978d8a3408d492ab2ee671"
dependencies = [
"ark-serialize-derive 0.3.0",
"ark-std 0.3.0",
"digest 0.9.0",
]
[[package]]
name = "ark-serialize"
version = "0.4.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "adb7b85a02b83d2f22f89bd5cac66c9c89474240cb6207cb1efc16d098e822a5"
dependencies = [
"ark-serialize-derive 0.4.2",
"ark-std 0.4.0",
"digest 0.10.7",
"num-bigint",
]
[[package]]
name = "ark-serialize-derive"
version = "0.3.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "8dd4e5f0bf8285d5ed538d27fab7411f3e297908fd93c62195de8bee3f199e82"
dependencies = [
"proc-macro2",
"quote",
"syn 1.0.109",
]
[[package]]
name = "ark-serialize-derive"
version = "0.4.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "ae3281bc6d0fd7e549af32b52511e1302185bd688fd3359fa36423346ff682ea"
dependencies = [
"proc-macro2",
"quote",
"syn 1.0.109",
]
[[package]]
name = "ark-snark"
version = "0.3.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "0dc3dff1a5f67a9c0b34df32b079752d8dd17f1e9d06253da0453db6c1b7cc8a"
dependencies = [
"ark-ff 0.3.0",
"ark-relations 0.3.0",
"ark-std 0.3.0",
]
[[package]]
name = "ark-snark"
version = "0.4.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "84d3cc6833a335bb8a600241889ead68ee89a3cf8448081fb7694c0fe503da63"
dependencies = [
"ark-ff 0.4.2",
"ark-relations 0.4.0",
"ark-serialize 0.4.2",
"ark-std 0.4.0",
]
[[package]]
name = "ark-std"
version = "0.3.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "1df2c09229cbc5a028b1d70e00fdb2acee28b1055dfb5ca73eea49c5a25c4e7c"
dependencies = [
"num-traits",
"rand 0.8.5",
]
[[package]]
name = "ark-std"
version = "0.4.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "94893f1e0c6eeab764ade8dc4c0db24caf4fe7cbbaafc0eba0a9030f447b5185"
dependencies = [
"num-traits",
"rand 0.8.5",
]
[[package]]
name = "array-bytes"
version = "6.1.0"
@ -575,6 +919,17 @@ dependencies = [
"wyz",
]
[[package]]
name = "blake2"
version = "0.9.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "0a4e37d16930f5459780f5621038b6382b9bb37c19016f39fb6b5808d831f174"
dependencies = [
"crypto-mac 0.8.0",
"digest 0.9.0",
"opaque-debug 0.3.0",
]
[[package]]
name = "blake2"
version = "0.10.6"
@ -729,6 +1084,27 @@ version = "0.3.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "e3b5ca7a04898ad4bcd41c90c5285445ff5b791899bb1b0abdd2a2aa791211d7"
[[package]]
name = "bytecheck"
version = "0.6.11"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "8b6372023ac861f6e6dc89c8344a8f398fb42aaba2b5dbc649ca0c0e9dbcb627"
dependencies = [
"bytecheck_derive",
"ptr_meta",
]
[[package]]
name = "bytecheck_derive"
version = "0.6.11"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "a7ec4c6f261935ad534c0c22dbef2201b45918860eb1c574b972bd213a76af61"
dependencies = [
"proc-macro2",
"quote",
"syn 1.0.109",
]
[[package]]
name = "bytemuck"
version = "1.13.1"
@ -1195,7 +1571,7 @@ dependencies = [
"cranelift-codegen",
"cranelift-entity",
"cranelift-frontend",
"itertools",
"itertools 0.10.5",
"log",
"smallvec",
"wasmparser",
@ -1542,6 +1918,28 @@ dependencies = [
"rusticata-macros",
]
[[package]]
name = "derivative"
version = "2.2.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "fcc3dd5e9e9c0b295d6e1e4d811fb6f157d5ffd784b8d202fc62eac8035a770b"
dependencies = [
"proc-macro2",
"quote",
"syn 1.0.109",
]
[[package]]
name = "derive-hex"
version = "0.1.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "4b6618553c32cd1c1f4fbdb9418cc035f3168422f24406ebb08576f6db5ed6ec"
dependencies = [
"proc-macro2",
"quote",
"syn 1.0.109",
]
[[package]]
name = "derive-syn-parse"
version = "0.1.5"
@ -1695,6 +2093,70 @@ version = "1.0.9"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "dcbb2bf8e87535c23f7a8a321e364ce21462d0ff10cb6407820e8e96dfff6653"
[[package]]
name = "dusk-bls12_381"
version = "0.12.3"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "cd8ae7aed4c4fdd83fb311ab92029212dac59c3271df9200cc4e894987a82430"
dependencies = [
"bytecheck",
"dusk-bytes",
"ff 0.13.0",
"group 0.13.0",
"pairing",
"rand_core 0.6.4",
"rkyv",
"subtle",
]
[[package]]
name = "dusk-bytes"
version = "0.1.7"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "d5d209b92f0741edf1d99369bd4c1a1ef2fd0a85e885220f9e3fb0df3c61337f"
dependencies = [
"derive-hex",
]
[[package]]
name = "dusk-jubjub"
version = "0.13.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "1f06d71b570e4072c87121e2f84c6ce444d4603cc010688b55b61c85baa023ad"
dependencies = [
"bitvec",
"bytecheck",
"dusk-bls12_381",
"dusk-bytes",
"ff 0.13.0",
"group 0.13.0",
"rand_core 0.6.4",
"rkyv",
"subtle",
]
[[package]]
name = "dusk-plonk"
version = "0.17.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "afc8f147581deaf3844c8bf4eb9041853bc17d87152c6777d6d245bbbe052a81"
dependencies = [
"bytecheck",
"cfg-if",
"dusk-bls12_381",
"dusk-bytes",
"dusk-jubjub",
"ff 0.13.0",
"hashbrown 0.9.1",
"itertools 0.9.0",
"merlin 3.0.0",
"miniz_oxide",
"msgpacker",
"rand_core 0.6.4",
"rkyv",
"sha2 0.10.7",
]
[[package]]
name = "dyn-clonable"
version = "0.9.0"
@ -1917,7 +2379,7 @@ version = "2.0.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "5f86a749cf851891866c10515ef6c299b5c69661465e9c3bbe7e07a2b77fb0f7"
dependencies = [
"blake2",
"blake2 0.10.6",
"fs-err",
"proc-macro2",
"quote",
@ -2131,7 +2593,7 @@ dependencies = [
"frame-system",
"gethostname",
"handlebars",
"itertools",
"itertools 0.10.5",
"lazy_static",
"linked-hash-map",
"log",
@ -2258,7 +2720,7 @@ dependencies = [
"derive-syn-parse",
"expander",
"frame-support-procedural-tools",
"itertools",
"itertools 0.10.5",
"macro_magic",
"proc-macro-warning",
"proc-macro2",
@ -2668,6 +3130,24 @@ dependencies = [
"crunchy",
]
[[package]]
name = "hashbrown"
version = "0.9.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "d7afe4a420e3fe79967a00898cc1f4db7c8a49a9333a29f8a4bd76a253d5cd04"
dependencies = [
"ahash 0.4.8",
]
[[package]]
name = "hashbrown"
version = "0.11.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "ab5ef0d4909ef3724cc8cce6ccc8572c5c817592e9285f5464f8e86f8bd3726e"
dependencies = [
"ahash 0.7.6",
]
[[package]]
name = "hashbrown"
version = "0.12.3"
@ -3115,6 +3595,15 @@ dependencies = [
"windows-sys 0.48.0",
]
[[package]]
name = "itertools"
version = "0.9.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "284f18f85651fe11e8a991b2adb42cb078325c996ed026d994719efcfca1d54b"
dependencies = [
"either",
]
[[package]]
name = "itertools"
version = "0.10.5"
@ -4160,6 +4649,18 @@ dependencies = [
"zeroize",
]
[[package]]
name = "merlin"
version = "3.0.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "58c38e2799fc0978b65dfff8023ec7843e2330bb462f19198840b34b6582397d"
dependencies = [
"byteorder",
"keccak",
"rand_core 0.6.4",
"zeroize",
]
[[package]]
name = "minimal-lexical"
version = "0.2.1"
@ -4213,6 +4714,25 @@ dependencies = [
"syn 1.0.109",
]
[[package]]
name = "msgpacker"
version = "0.4.3"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "79f77b4108a99ed7e834b46df33537a644ea94863a98a9140017eda1d08249f6"
dependencies = [
"msgpacker-derive",
]
[[package]]
name = "msgpacker-derive"
version = "0.3.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "e926eca5ac0d976018120667ab61ee8a1cff4afdcd202357971b610e7ff57b5a"
dependencies = [
"quote",
"syn 2.0.27",
]
[[package]]
name = "multiaddr"
version = "0.17.1"
@ -4471,6 +4991,7 @@ dependencies = [
"pallet-timestamp",
"pallet-transaction-payment",
"pallet-transaction-payment-rpc-runtime-api",
"pallet_zkp_verify",
"parity-scale-codec",
"scale-info",
"sp-api",
@ -4681,6 +5202,15 @@ dependencies = [
"libm",
]
[[package]]
name = "pairing"
version = "0.23.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "81fec4625e73cf41ef4bb6846cafa6d44736525f442ba45e407c4a000a13996f"
dependencies = [
"group 0.13.0",
]
[[package]]
name = "pallet-aura"
version = "4.0.0-dev"
@ -4861,13 +5391,40 @@ dependencies = [
"sp-weights",
]
[[package]]
name = "pallet_zkp_verify"
version = "4.0.0-dev"
dependencies = [
"ark-bls12-381",
"ark-bn254",
"ark-ec 0.4.2",
"ark-ff 0.4.2",
"ark-gm17",
"ark-groth16",
"ark-serialize 0.4.2",
"ark-snark 0.4.0",
"ark-std 0.4.0",
"dusk-bls12_381",
"dusk-jubjub",
"dusk-plonk",
"frame-benchmarking",
"frame-support",
"frame-system",
"parity-scale-codec",
"rkyv",
"scale-info",
"sp-core",
"sp-io",
"sp-runtime",
]
[[package]]
name = "parity-db"
version = "0.4.10"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "78f19d20a0d2cc52327a88d131fa1c4ea81ea4a04714aedcfeca2dd410049cf8"
dependencies = [
"blake2",
"blake2 0.10.6",
"crc32fast",
"fs2",
"hex",
@ -5229,7 +5786,7 @@ checksum = "59230a63c37f3e18569bdb90e4a89cbf5bf8b06fea0b84e65ea10cc4df47addd"
dependencies = [
"difflib",
"float-cmp",
"itertools",
"itertools 0.10.5",
"normalize-line-endings",
"predicates-core",
"regex",
@ -5399,7 +5956,7 @@ checksum = "119533552c9a7ffacc21e099c24a0ac8bb19c2a2a3f363de84cd9b844feab270"
dependencies = [
"bytes",
"heck",
"itertools",
"itertools 0.10.5",
"lazy_static",
"log",
"multimap",
@ -5420,7 +5977,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "e5d2d8d10f3c6ded6da8b05b5fb3b8a5082514344d56c9f871412d29b4e075b4"
dependencies = [
"anyhow",
"itertools",
"itertools 0.10.5",
"proc-macro2",
"quote",
"syn 1.0.109",
@ -5444,6 +6001,26 @@ dependencies = [
"cc",
]
[[package]]
name = "ptr_meta"
version = "0.1.4"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "0738ccf7ea06b608c10564b31debd4f5bc5e197fc8bfe088f68ae5ce81e7a4f1"
dependencies = [
"ptr_meta_derive",
]
[[package]]
name = "ptr_meta_derive"
version = "0.1.4"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "16b845dbfca988fa33db069c0e230574d15a3088f147a87b64c7589eb662c9ac"
dependencies = [
"proc-macro2",
"quote",
"syn 1.0.109",
]
[[package]]
name = "quick-error"
version = "1.2.3"
@ -5754,6 +6331,15 @@ version = "0.7.4"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "e5ea92a5b6195c6ef2a0295ea818b312502c6fc94dde986c5553242e18fd4ce2"
[[package]]
name = "rend"
version = "0.4.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "a2571463863a6bd50c32f94402933f03457a3fbaf697a707c5be741e459f08fd"
dependencies = [
"bytecheck",
]
[[package]]
name = "resolv-conf"
version = "0.7.0"
@ -5800,6 +6386,33 @@ dependencies = [
"winapi",
]
[[package]]
name = "rkyv"
version = "0.7.42"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "0200c8230b013893c0b2d6213d6ec64ed2b9be2e0e016682b7224ff82cff5c58"
dependencies = [
"bitvec",
"bytecheck",
"hashbrown 0.12.3",
"ptr_meta",
"rend",
"rkyv_derive",
"seahash",
"tinyvec",
]
[[package]]
name = "rkyv_derive"
version = "0.7.42"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "b2e06b915b5c230a17d7a736d1e2e63ee753c256a8614ef3f5147b13a4f5541d"
dependencies = [
"proc-macro2",
"quote",
"syn 1.0.109",
]
[[package]]
name = "rocksdb"
version = "0.21.0"
@ -5889,6 +6502,15 @@ version = "2.1.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "3e75f6a532d0fd9f7f13144f392b6ad56a32696bfcd9c78f797f16bbb6f072d6"
[[package]]
name = "rustc_version"
version = "0.3.3"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "f0dfe2087c51c460008730de8b57e6a320782fbfb312e1f4d520e6c6fae155ee"
dependencies = [
"semver 0.11.0",
]
[[package]]
name = "rustc_version"
version = "0.4.0"
@ -7013,7 +7635,7 @@ dependencies = [
"arrayvec 0.5.2",
"curve25519-dalek 2.1.3",
"getrandom 0.1.16",
"merlin",
"merlin 2.0.1",
"rand 0.7.3",
"rand_core 0.5.1",
"sha2 0.8.2",
@ -7065,6 +7687,12 @@ dependencies = [
"url",
]
[[package]]
name = "seahash"
version = "4.1.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "1c107b6f4780854c8b126e228ea8869f4d7b71260f962fefb57b996b8959ba6b"
[[package]]
name = "sec1"
version = "0.3.0"
@ -7149,7 +7777,16 @@ version = "0.6.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "7a3186ec9e65071a2095434b1f5bb24838d4e8e130f584c790f6033c79943537"
dependencies = [
"semver-parser",
"semver-parser 0.7.0",
]
[[package]]
name = "semver"
version = "0.11.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "f301af10236f6df4160f7c3f04eec6dbc70ace82d23326abad5edee88801c6b6"
dependencies = [
"semver-parser 0.10.2",
]
[[package]]
@ -7167,6 +7804,15 @@ version = "0.7.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "388a1df253eca08550bef6c72392cfe7c30914bf41df5269b68cbd6ff8f570a3"
[[package]]
name = "semver-parser"
version = "0.10.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "00b0bef5b7f9e0df16536d3961cfb6e84331c065b4066afb39768d0e319411f7"
dependencies = [
"pest",
]
[[package]]
name = "serde"
version = "1.0.176"
@ -7374,12 +8020,12 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "5ccba027ba85743e09d15c03296797cad56395089b832b48b5a5217880f57733"
dependencies = [
"aes-gcm 0.9.4",
"blake2",
"blake2 0.10.6",
"chacha20poly1305",
"curve25519-dalek 4.0.0-rc.1",
"rand_core 0.6.4",
"ring",
"rustc_version",
"rustc_version 0.4.0",
"sha2 0.10.7",
"subtle",
]
@ -7448,7 +8094,7 @@ version = "4.0.0-dev"
source = "git+https://github.com/paritytech/substrate.git?branch=polkadot-v1.0.0#948fbd2fd1233dc26dbb9f9bbc1d2cca2c03945d"
dependencies = [
"Inflector",
"blake2",
"blake2 0.10.6",
"expander",
"proc-macro-crate",
"proc-macro2",
@ -7600,7 +8246,7 @@ source = "git+https://github.com/paritytech/substrate.git?branch=polkadot-v1.0.0
dependencies = [
"array-bytes",
"bitflags 1.3.2",
"blake2",
"blake2 0.10.6",
"bounded-collections",
"bs58",
"dyn-clonable",
@ -7612,7 +8258,7 @@ dependencies = [
"lazy_static",
"libsecp256k1",
"log",
"merlin",
"merlin 2.0.1",
"parity-scale-codec",
"parking_lot 0.12.1",
"paste",

3
Cargo.toml 100644 → 100755
View File

@ -1,7 +1,8 @@
[workspace]
members = [
members = [
"node",
"pallets/template",
"pallets/zkp_verify",
"runtime",
]
[profile.release]

0
Containerfile 100644 → 100755
View File

0
LICENSE 100644 → 100755
View File

0
README.md 100644 → 100755
View File

0
docs/rust-setup.md 100644 → 100755
View File

0
flake.lock 100644 → 100755
View File

0
flake.nix 100644 → 100755
View File

0
node/Cargo.toml 100644 → 100755
View File

0
node/build.rs 100644 → 100755
View File

0
node/src/benchmarking.rs 100644 → 100755
View File

0
node/src/chain_spec.rs 100644 → 100755
View File

0
node/src/cli.rs 100644 → 100755
View File

0
node/src/command.rs 100644 → 100755
View File

0
node/src/lib.rs 100644 → 100755
View File

0
node/src/main.rs 100644 → 100755
View File

0
node/src/rpc.rs 100644 → 100755
View File

0
node/src/service.rs 100644 → 100755
View File

0
pallets/template/Cargo.toml 100644 → 100755
View File

0
pallets/template/README.md 100644 → 100755
View File

View File

0
pallets/template/src/lib.rs 100644 → 100755
View File

0
pallets/template/src/mock.rs 100644 → 100755
View File

0
pallets/template/src/tests.rs 100644 → 100755
View File

0
pallets/template/src/weights.rs 100644 → 100755
View File

View File

@ -0,0 +1,55 @@
[package]
name = "pallet_zkp_verify"
version = "4.0.0-dev"
description = "FRAME pallet template for defining custom runtime logic."
authors = ["Substrate DevHub <https://github.com/substrate-developer-hub>"]
homepage = "https://substrate.io"
edition = "2021"
license = "MIT-0"
publish = false
repository = "https://github.com/substrate-developer-hub/substrate-node-template/"
[package.metadata.docs.rs]
targets = ["x86_64-unknown-linux-gnu"]
[dependencies]
codec = { package = "parity-scale-codec", version = "3.6.1", default-features = false, features = [
"derive",
] }
scale-info = { version = "2.5.0", default-features = false, features = ["derive"] }
frame-benchmarking = { version = "4.0.0-dev", default-features = false, optional = true, git = "https://github.com/paritytech/substrate.git", branch = "polkadot-v1.0.0" }
frame-support = { version = "4.0.0-dev", default-features = false, git = "https://github.com/paritytech/substrate.git", branch = "polkadot-v1.0.0" }
frame-system = { version = "4.0.0-dev", default-features = false, git = "https://github.com/paritytech/substrate.git", branch = "polkadot-v1.0.0" }
ark-ec = { version = "^0.4.0", default-features = false }
ark-ff = { version = "^0.4.0", default-features = false }
ark-groth16 = { version = "^0.4.0", default-features = false }
ark-gm17 = { version = "^0.3.0", default-features = false }
ark-bn254 = { version = "^0.4.0", features = ["curve"], default-features = false }
ark-snark = { version = "0.4.0", default-features = false }
ark-bls12-381 = { version = "0.4.0", features = ["curve"], default-features = false }
ark-std = { version = "0.4.0", default-features = false }
ark-serialize = { version = "0.4.0", features = [ "derive" ], default-features = false }
dusk-jubjub = { version ="0.13.1", default-features = false}
dusk-plonk = {version = "0.17.0", features = ["rkyv-impl","alloc"], default-features = false }
dusk-bls12_381 = {version = "0.12.3", features = ["rkyv-impl","pairings","alloc"], default-features = false}
rkyv = { version = "0.7.42", features = ["validation","size_32"], default-features = false }
[dev-dependencies]
sp-core = { version = "21.0.0", git = "https://github.com/paritytech/substrate.git", branch = "polkadot-v1.0.0" }
sp-io = { version = "23.0.0", git = "https://github.com/paritytech/substrate.git", branch = "polkadot-v1.0.0" }
sp-runtime = { version = "24.0.0", git = "https://github.com/paritytech/substrate.git", branch = "polkadot-v1.0.0" }
[features]
default = ["std"]
std = [
"codec/std",
"frame-benchmarking?/std",
"frame-support/std",
"frame-system/std",
"scale-info/std",
]
runtime-benchmarks = ["frame-benchmarking/runtime-benchmarks"]
try-runtime = ["frame-support/try-runtime"]

View File

@ -0,0 +1 @@
License: MIT-0

View File

@ -0,0 +1,35 @@
//! Benchmarking setup for pallet-zkp_verify
#![cfg(feature = "runtime-benchmarks")]
use super::*;
#[allow(unused)]
use crate::Pallet as ZKPVerify;
use frame_benchmarking::v2::*;
use frame_system::RawOrigin;
#[benchmarks]
mod benchmarks {
use super::*;
#[benchmark]
fn do_something() {
let value = 100u32.into();
let caller: T::AccountId = whitelisted_caller();
#[extrinsic_call]
do_something(RawOrigin::Signed(caller), value);
assert_eq!(Something::<T>::get(), Some(value));
}
#[benchmark]
fn cause_error() {
Something::<T>::put(100u32);
let caller: T::AccountId = whitelisted_caller();
#[extrinsic_call]
cause_error(RawOrigin::Signed(caller));
assert_eq!(Something::<T>::get(), Some(101u32));
}
impl_benchmark_test_suite!(ZKPVerify, crate::mock::new_test_ext(), crate::mock::Test);
}

View File

@ -0,0 +1,177 @@
#![cfg_attr(not(feature = "std"), no_std)]
/// Edit this file to define custom logic or remove it if it is not needed.
/// Learn more about FRAME and the core library of Substrate FRAME pallets:
/// <https://docs.substrate.io/reference/frame-pallets/>
pub use pallet::*;
use dusk_plonk::prelude::{Proof, Verifier, BlsScalar};
use rkyv::Deserialize;
#[cfg(test)]
mod mock;
#[cfg(test)]
mod tests;
#[cfg(feature = "runtime-benchmarks")]
mod benchmarking;
pub mod weights;
pub use weights::*;
#[frame_support::pallet]
pub mod pallet {
use super::*;
use frame_support::pallet_prelude::*;
use frame_system::pallet_prelude::*;
use ark_bn254::{Bn254, Fq, Fq2, Fr, G1Affine, G2Affine, Config as Bn254Config};
use ark_ec::bn::Bn;
use ark_gm17::{prepare_verifying_key as gm17_prepare_verification_key, Proof as gm17_proof, VerifyingKey as gm17_verification_key, verify_proof as gm17_verify_proof, GM17};
use ark_groth16::{prepare_verifying_key as g16_prepare_verification_key, Proof as g16_proof, VerifyingKey as g16_verification_key, Groth16};
use ark_ff::{Field, Zero, vec,Fp};
use ark_snark::SNARK;
use ark_bls12_381::{Bls12_381, Fr as BlsFr};
use ark_serialize::{CanonicalDeserialize, Compress, Validate};
use ark_std::{
io::{Cursor},
vec::Vec,
};
#[pallet::pallet]
pub struct Pallet<T>(_);
/// Configure the pallet by specifying the parameters and types on which it depends.
#[pallet::config]
pub trait Config: frame_system::Config {
/// Because this pallet emits events, it depends on the runtime's definition of an event.
type RuntimeEvent: From<Event<Self>> + IsType<<Self as frame_system::Config>::RuntimeEvent>;
/// Type representing the weight of this pallet
type WeightInfo: WeightInfo;
}
// The pallet's runtime storage items.
// https://docs.substrate.io/main-docs/build/runtime-storage/
#[pallet::storage]
#[pallet::getter(fn something)]
// Learn more about declaring storage items:
// https://docs.substrate.io/main-docs/build/runtime-storage/#declaring-storage-items
pub type Something<T> = StorageValue<_, u32>;
// Pallets use events to inform users when important changes are made.
// https://docs.substrate.io/main-docs/build/events-errors/
#[pallet::event]
#[pallet::generate_deposit(pub(super) fn deposit_event)]
pub enum Event<T: Config> {
/// Event documentation should end with an array that provides descriptive names for event
/// parameters. [something, who]
ValidationSuccess { who: T::AccountId },
}
#[pallet::error]
pub enum Error<T> {
ValidationFailed,
}
// Dispatchable functions allows users to interact with the pallet and invoke state changes.
// These functions materialize as "extrinsics", which are often compared to transactions.
// Dispatchable functions must be annotated with a weight and must return a DispatchResult.
#[pallet::call]
impl<T: Config> Pallet<T> {
#[pallet::call_index(0)]
#[pallet::weight(T::WeightInfo::cause_error())]
pub fn verify_proof(origin: OriginFor<T>, vk: Vec<u8>,inputs: Vec<u8>,proof: Vec<u8>) -> DispatchResult {
let who = ensure_signed(origin)?;
let cursor = Cursor::new(&vk);
let vk = <Groth16<Bls12_381> as SNARK<BlsFr>>::VerifyingKey::deserialize_with_mode(
cursor,
Compress::No,
Validate::No,
).unwrap();
let cursor = Cursor::new(&inputs);
let inputs: ark_ff::Fp<ark_ff::MontBackend<ark_bls12_381::FrConfig, 4>, 4> =
Fp::deserialize_with_mode(cursor, Compress::No, Validate::No).unwrap();
let cursor = Cursor::new(&proof);
let proof =
<Groth16<Bls12_381> as SNARK<BlsFr>>::Proof::deserialize_with_mode(
cursor,
Compress::No,
Validate::No,
).unwrap();
let result = Groth16::<Bls12_381>::verify(&vk, &[inputs], &proof).unwrap();
if(result){
Self::deposit_event(Event::ValidationSuccess { who });
Ok(())
}else{
Err(Error::<T>::ValidationFailed.into())
}
}
#[pallet::call_index(1)]
#[pallet::weight(T::WeightInfo::cause_error())]
pub fn verify_proof_plonk(origin: OriginFor<T>, vk: Vec<u8>, inputs: Vec<u8>,proof: Vec<u8>) -> DispatchResult {
let who = ensure_signed(origin)?;
let verifier: Verifier = Verifier::try_from_bytes(&vk[..]).expect("Failed to load verifier");
let archived = rkyv::check_archived_root::<Proof>(&proof[..]).unwrap();
let proof: Proof = archived.deserialize(&mut rkyv::Infallible).unwrap();
let archived = rkyv::check_archived_root::<Vec<BlsScalar>>(&inputs[..]).unwrap();
let inputs: Vec<BlsScalar> = archived.deserialize(&mut rkyv::Infallible).unwrap();
let verification =verifier.verify(&proof, &inputs);
let result = verification.is_ok();
if(result){
Self::deposit_event(Event::ValidationSuccess { who });
Ok(())
}else{
Err(Error::<T>::ValidationFailed.into())
}
}
/*#[pallet::call_index(1)]
#[pallet::weight(T::WeightInfo::cause_error())]
pub fn verify_proof_gm17(origin: OriginFor<T>, vk: Vec<u8>, inputs: Vec<u8>,proof: Vec<u8>) -> DispatchResult {
let who = ensure_signed(origin)?;
let cursor = Cursor::new(&vk);
let pvk = <GM17<Bls12_381> as SNARK<BlsFr>>::VerifyingKey::deserialize_with_mode(
cursor,
Compress::No,
Validate::No,
).unwrap();
let cursor = Cursor::new(&inputs);
let inputs: ark_ff::Fp<ark_ff::MontBackend<ark_bls12_381::FrConfig, 4>, 4> =
Fp::deserialize_with_mode(cursor, Compress::No, Validate::No).unwrap();
let cursor = Cursor::new(&proof);
let proof =
<GM17<Bls12_381> as SNARK<BlsFr>>::Proof::deserialize_with_mode(
cursor,
Compress::No,
Validate::No,
)
.unwrap();
let result = gm17_verify_proof(&vk, &proof, &[inputs]).unwrap();
if(result){
Ok(())
}else{
Err(Error::<T>::NoneValue.into())
}
}*/
}
}

View File

@ -0,0 +1,54 @@
use crate as pallet_zkp_verify;
use frame_support::traits::{ConstU16, ConstU64};
use sp_core::H256;
use sp_runtime::{
traits::{BlakeTwo256, IdentityLookup},
BuildStorage,
};
type Block = frame_system::mocking::MockBlock<Test>;
// Configure a mock runtime to test the pallet.
frame_support::construct_runtime!(
pub enum Test
{
System: frame_system,
TemplateModule: pallet_template,
}
);
impl frame_system::Config for Test {
type BaseCallFilter = frame_support::traits::Everything;
type BlockWeights = ();
type BlockLength = ();
type DbWeight = ();
type RuntimeOrigin = RuntimeOrigin;
type RuntimeCall = RuntimeCall;
type Nonce = u64;
type Hash = H256;
type Hashing = BlakeTwo256;
type AccountId = u64;
type Lookup = IdentityLookup<Self::AccountId>;
type Block = Block;
type RuntimeEvent = RuntimeEvent;
type BlockHashCount = ConstU64<250>;
type Version = ();
type PalletInfo = PalletInfo;
type AccountData = ();
type OnNewAccount = ();
type OnKilledAccount = ();
type SystemWeightInfo = ();
type SS58Prefix = ConstU16<42>;
type OnSetCode = ();
type MaxConsumers = frame_support::traits::ConstU32<16>;
}
impl pallet_template::Config for Test {
type RuntimeEvent = RuntimeEvent;
type WeightInfo = ();
}
// Build genesis storage according to the mock runtime.
pub fn new_test_ext() -> sp_io::TestExternalities {
frame_system::GenesisConfig::<Test>::default().build_storage().unwrap().into()
}

View File

@ -0,0 +1,27 @@
use crate::{mock::*, Error, Event};
use frame_support::{assert_noop, assert_ok};
#[test]
fn it_works_for_default_value() {
new_test_ext().execute_with(|| {
// Go past genesis block so events get deposited
System::set_block_number(1);
// Dispatch a signed extrinsic.
assert_ok!(TemplateModule::do_something(RuntimeOrigin::signed(1), 42));
// Read pallet storage and assert an expected result.
assert_eq!(TemplateModule::something(), Some(42));
// Assert that the correct event was deposited
System::assert_last_event(Event::SomethingStored { something: 42, who: 1 }.into());
});
}
#[test]
fn correct_error_for_none_value() {
new_test_ext().execute_with(|| {
// Ensure the expected error is thrown when no value is present.
assert_noop!(
TemplateModule::cause_error(RuntimeOrigin::signed(1)),
Error::<Test>::NoneValue
);
});
}

View File

@ -0,0 +1,90 @@
//! Autogenerated weights for pallet_template
//!
//! THIS FILE WAS AUTO-GENERATED USING THE SUBSTRATE BENCHMARK CLI VERSION 4.0.0-dev
//! DATE: 2023-04-06, STEPS: `50`, REPEAT: `20`, LOW RANGE: `[]`, HIGH RANGE: `[]`
//! WORST CASE MAP SIZE: `1000000`
//! HOSTNAME: `Alexs-MacBook-Pro-2.local`, CPU: `<UNKNOWN>`
//! EXECUTION: Some(Wasm), WASM-EXECUTION: Compiled, CHAIN: Some("dev"), DB CACHE: 1024
// Executed Command:
// ../../target/release/node-template
// benchmark
// pallet
// --chain
// dev
// --pallet
// pallet_template
// --extrinsic
// *
// --steps=50
// --repeat=20
// --wasm-execution=compiled
// --output
// pallets/template/src/weights.rs
// --template
// ../../.maintain/frame-weight-template.hbs
#![cfg_attr(rustfmt, rustfmt_skip)]
#![allow(unused_parens)]
#![allow(unused_imports)]
use frame_support::{traits::Get, weights::{Weight, constants::RocksDbWeight}};
use core::marker::PhantomData;
/// Weight functions needed for pallet_template.
pub trait WeightInfo {
fn do_something() -> Weight;
fn cause_error() -> Weight;
}
/// Weights for pallet_template using the Substrate node and recommended hardware.
pub struct SubstrateWeight<T>(PhantomData<T>);
impl<T: frame_system::Config> WeightInfo for SubstrateWeight<T> {
/// Storage: TemplateModule Something (r:0 w:1)
/// Proof: TemplateModule Something (max_values: Some(1), max_size: Some(4), added: 499, mode: MaxEncodedLen)
fn do_something() -> Weight {
// Proof Size summary in bytes:
// Measured: `0`
// Estimated: `0`
// Minimum execution time: 8_000_000 picoseconds.
Weight::from_parts(9_000_000, 0)
.saturating_add(T::DbWeight::get().writes(1_u64))
}
/// Storage: TemplateModule Something (r:1 w:1)
/// Proof: TemplateModule Something (max_values: Some(1), max_size: Some(4), added: 499, mode: MaxEncodedLen)
fn cause_error() -> Weight {
// Proof Size summary in bytes:
// Measured: `32`
// Estimated: `1489`
// Minimum execution time: 6_000_000 picoseconds.
Weight::from_parts(6_000_000, 1489)
.saturating_add(T::DbWeight::get().reads(1_u64))
.saturating_add(T::DbWeight::get().writes(1_u64))
}
}
// For backwards compatibility and tests
impl WeightInfo for () {
/// Storage: TemplateModule Something (r:0 w:1)
/// Proof: TemplateModule Something (max_values: Some(1), max_size: Some(4), added: 499, mode: MaxEncodedLen)
fn do_something() -> Weight {
// Proof Size summary in bytes:
// Measured: `0`
// Estimated: `0`
// Minimum execution time: 8_000_000 picoseconds.
Weight::from_parts(9_000_000, 0)
.saturating_add(RocksDbWeight::get().writes(1_u64))
}
/// Storage: TemplateModule Something (r:1 w:1)
/// Proof: TemplateModule Something (max_values: Some(1), max_size: Some(4), added: 499, mode: MaxEncodedLen)
fn cause_error() -> Weight {
// Proof Size summary in bytes:
// Measured: `32`
// Estimated: `1489`
// Minimum execution time: 6_000_000 picoseconds.
Weight::from_parts(6_000_000, 1489)
.saturating_add(RocksDbWeight::get().reads(1_u64))
.saturating_add(RocksDbWeight::get().writes(1_u64))
}
}

1
runtime/Cargo.toml 100644 → 100755
View File

@ -49,6 +49,7 @@ frame-system-benchmarking = { version = "4.0.0-dev", default-features = false, g
# Local Dependencies
pallet-template = { version = "4.0.0-dev", default-features = false, path = "../pallets/template" }
pallet_zkp_verify = { version = "4.0.0-dev", default-features = false, path = "../pallets/zkp_verify" }
[build-dependencies]
substrate-wasm-builder = { version = "5.0.0-dev", git = "https://github.com/paritytech/substrate.git", optional = true , branch = "polkadot-v1.0.0" }

0
runtime/build.rs 100644 → 100755
View File

11
runtime/src/lib.rs 100644 → 100755
View File

@ -49,6 +49,9 @@ pub use sp_runtime::{Perbill, Permill};
/// Import the template pallet.
pub use pallet_template;
/// Import the ZKP verifier pallet.
pub use pallet_zkp_verify;
/// An index to a block.
pub type BlockNumber = u32;
@ -274,6 +277,12 @@ impl pallet_template::Config for Runtime {
type WeightInfo = pallet_template::weights::SubstrateWeight<Runtime>;
}
/// Configure the pallet-zkp_verify in pallets/zkp_verify.
impl pallet_zkp_verify::Config for Runtime {
type RuntimeEvent = RuntimeEvent;
type WeightInfo = pallet_zkp_verify::weights::SubstrateWeight<Runtime>;
}
// Create the runtime by composing the FRAME pallets that were previously configured.
construct_runtime!(
pub struct Runtime {
@ -286,6 +295,7 @@ construct_runtime!(
Sudo: pallet_sudo,
// Include the custom logic from the pallet-template in the runtime.
TemplateModule: pallet_template,
ZKPVerifyModule: pallet_zkp_verify,
}
);
@ -334,6 +344,7 @@ mod benches {
[pallet_timestamp, Timestamp]
[pallet_sudo, Sudo]
[pallet_template, TemplateModule]
[pallet_zkp_verify, ZKPVerifyModule]
);
}

0
rust-toolchain.toml 100644 → 100755
View File

0
rustfmt.toml 100644 → 100755
View File

0
shell.nix 100644 → 100755
View File