diff --git a/.github/workflows/rust.yml b/.github/workflows/rust.yml index bbb1f6f5..93cbcc29 100644 --- a/.github/workflows/rust.yml +++ b/.github/workflows/rust.yml @@ -24,6 +24,11 @@ jobs: cd zk_prover cargo test --release --features dev-graph -- --nocapture + - name: Test Nova Prover + run: | + cd zk_prover + cargo run --release --example nova_incremental_verifier + - name: Install Foundry uses: foundry-rs/foundry-toolchain@v1 diff --git a/backend/Cargo.lock b/backend/Cargo.lock index 7c8c9eff..c5d76924 100644 --- a/backend/Cargo.lock +++ b/backend/Cargo.lock @@ -12,6 +12,17 @@ dependencies = [ "regex", ] +[[package]] +name = "addchain" +version = "0.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3b2e69442aa5628ea6951fa33e24efe8313f4321a91bd729fc2f75bdfc858570" +dependencies = [ + "num-bigint 0.3.3", + "num-integer", + "num-traits", +] + [[package]] name = "addr2line" version = "0.20.0" @@ -64,6 +75,12 @@ version = "0.1.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "e999941b234f3131b00bc13c22d06e8c5ff726d1b6318ac7eb276997bbb4fef0" +[[package]] +name = "anyhow" +version = "1.0.75" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a4668cab20f66d8d020e1fbc0ebe47217433c1b6c8f2040faf858554e394ace6" + [[package]] name = "ark-std" version = "0.3.0" @@ -72,7 +89,7 @@ checksum = "1df2c09229cbc5a028b1d70e00fdb2acee28b1055dfb5ca73eea49c5a25c4e7c" dependencies = [ "colored", "num-traits", - "rand", + "rand 0.8.5", ] [[package]] @@ -81,6 +98,12 @@ version = "0.3.7" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "6b4930d2cb77ce62f89ee5d5289b4ac049559b1c45539271f5ed4fdc7db34545" +[[package]] +name = "arrayvec" +version = "0.5.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "23b62fc65de8e4e7f52534fb52b0f3ed04746ae267519eef2a83941e8085068b" + [[package]] name = "arrayvec" version = "0.7.4" @@ -181,6 +204,34 @@ version = "0.7.3" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "2dabbe35f96fb9507f7330793dc490461b2962659ac5d427181e451a623751d1" +[[package]] +name = "bellperson" +version = "0.25.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "93eaee4b4753554139ae52ecf0e8b8c128cbc561b32e1bfaa32f70cba8518c1f" +dependencies = [ + "bincode", + "blake2s_simd 1.0.1", + "blstrs", + "byteorder", + "crossbeam-channel", + "digest 0.10.7", + "ec-gpu", + "ec-gpu-gen", + "ff", + "group", + "log", + "memmap2", + "pairing", + "rand 0.8.5", + "rand_core 0.6.4", + "rayon", + "rustversion", + "serde", + "sha2 0.10.7", + "thiserror", +] + [[package]] name = "bincode" version = "1.3.3" @@ -213,9 +264,9 @@ checksum = "bef38d45163c2f1dde094a7dfd33ccf595c92905c8f8f4fdc18d06fb1037718a" [[package]] name = "bitflags" -version = "2.3.3" +version = "2.4.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "630be753d4e58660abd17930c71b647fe46c27ea6b63cc59e1e3851406972e42" +checksum = "b4682ae6287fcf752ecaabbfcc7b6f9b72aa33933dc23a554d853aea8eea8635" [[package]] name = "bitvec" @@ -246,8 +297,30 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "3c2f0dc9a68c6317d884f97cc36cf5a3d20ba14ce404227df55e1af708ab04bc" dependencies = [ "arrayref", - "arrayvec", - "constant_time_eq", + "arrayvec 0.7.4", + "constant_time_eq 0.2.6", +] + +[[package]] +name = "blake2s_simd" +version = "0.5.11" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9e461a7034e85b211a4acb57ee2e6730b32912b06c08cc242243c39fc21ae6a2" +dependencies = [ + "arrayref", + "arrayvec 0.5.2", + "constant_time_eq 0.1.5", +] + +[[package]] +name = "blake2s_simd" +version = "1.0.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6637f448b9e61dfadbdcbae9a885fadee1f3eaffb1f8d3c1965d3ade8bdfd44f" +dependencies = [ + "arrayref", + "arrayvec 0.7.4", + "constant_time_eq 0.2.6", ] [[package]] @@ -275,6 +348,34 @@ version = "0.2.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "8d696c370c750c948ada61c69a0ee2cbbb9c50b1019ddb86d9317157a99c2cae" +[[package]] +name = "blst" +version = "0.3.11" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c94087b935a822949d3291a9989ad2b2051ea141eda0fd4e478a75f6aa3e604b" +dependencies = [ + "cc", + "glob", + "threadpool", + "zeroize", +] + +[[package]] +name = "blstrs" +version = "0.7.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7a8a8ed6fefbeef4a8c7b460e4110e12c5e22a5b7cf32621aae6ad650c4dcf29" +dependencies = [ + "blst", + "byte-slice-cast", + "ff", + "group", + "pairing", + "rand_core 0.6.4", + "serde", + "subtle", +] + [[package]] name = "bs58" version = "0.4.0" @@ -406,7 +507,7 @@ dependencies = [ "hmac", "once_cell", "pbkdf2 0.12.2", - "rand", + "rand 0.8.5", "sha2 0.10.7", "thiserror", ] @@ -448,6 +549,12 @@ version = "0.9.4" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "795bc6e66a8e340f075fcf6227e417a2dc976b92b91f3cdc778bb858778b6747" +[[package]] +name = "constant_time_eq" +version = "0.1.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "245097e9a4535ee1e3e3931fcfcd55a796a44c643e8596ff6566d68f09b87bbc" + [[package]] name = "constant_time_eq" version = "0.2.6" @@ -485,6 +592,15 @@ dependencies = [ "libc", ] +[[package]] +name = "crc32fast" +version = "1.3.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b540bd8bc810d3885c6ea91e2018302f68baba2129ab3e88f32389ee9370880d" +dependencies = [ + "cfg-if", +] + [[package]] name = "crossbeam-channel" version = "0.5.8" @@ -541,7 +657,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "cf4c2f4e1afd912bc40bfd6fed5d9dc1f288e0ba01bfcc835cc5bc3eb13efe15" dependencies = [ "generic-array", - "rand_core", + "rand_core 0.6.4", "subtle", "zeroize", ] @@ -663,16 +779,44 @@ version = "1.0.4" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "56ce8c6da7551ec6c462cbaf3bfbc75131ebbfa1c944aeaa9dab51ca1c5f0c3b" +[[package]] +name = "ec-gpu" +version = "0.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "bd63582de2b59ea1aa48d7c1941b5d87618d95484397521b3acdfa0e1e9f5e45" + +[[package]] +name = "ec-gpu-gen" +version = "0.6.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "892df2aa20abec5b816e15d5d6383892ca142077708efa3067dd3ac44b75c664" +dependencies = [ + "bitvec 1.0.1", + "crossbeam-channel", + "ec-gpu", + "execute", + "ff", + "group", + "hex", + "log", + "num_cpus", + "once_cell", + "rayon", + "sha2 0.10.7", + "thiserror", + "yastl", +] + [[package]] name = "ecc" version = "0.1.0" source = "git+https://github.com/privacy-scaling-explorations/halo2wrong?tag=v2023_04_20#f72db265aa3cebe297c9b9816e940d0e1d400886" dependencies = [ "integer", - "num-bigint", + "num-bigint 0.4.3", "num-integer", "num-traits", - "rand", + "rand 0.8.5", "subtle", ] @@ -709,7 +853,7 @@ dependencies = [ "generic-array", "group", "pkcs8", - "rand_core", + "rand_core 0.6.4", "sec1", "subtle", "zeroize", @@ -744,7 +888,7 @@ dependencies = [ "hex", "k256", "log", - "rand", + "rand 0.8.5", "rlp", "serde", "sha3 0.10.8", @@ -801,7 +945,7 @@ dependencies = [ "hex", "hmac", "pbkdf2 0.11.0", - "rand", + "rand 0.8.5", "scrypt", "serde", "serde_json", @@ -950,7 +1094,7 @@ version = "2.0.7" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "6da5fa198af0d3be20c19192df2bd9590b92ce09a8421e793bec8851270f1b05" dependencies = [ - "arrayvec", + "arrayvec 0.7.4", "bytes", "cargo_metadata", "chrono", @@ -962,7 +1106,7 @@ dependencies = [ "num_enum", "once_cell", "open-fastrlp", - "rand", + "rand 0.8.5", "rlp", "serde", "serde_json", @@ -1065,7 +1209,7 @@ dependencies = [ "eth-keystore", "ethers-core", "hex", - "rand", + "rand 0.8.5", "sha2 0.10.7", "thiserror", "tracing", @@ -1101,6 +1245,43 @@ dependencies = [ "yansi", ] +[[package]] +name = "execute" +version = "0.2.12" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "16d9a9ea4c04632c16bc5c71a2fcc63d308481f7fc67eb1a1ce6315c44a426ae" +dependencies = [ + "execute-command-macro", + "execute-command-tokens", + "generic-array", +] + +[[package]] +name = "execute-command-macro" +version = "0.1.8" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a5fbc65a0cf735106743f4c38c9a3671c1e734b5c2c20d21a3c93c696daa3157" +dependencies = [ + "execute-command-macro-impl", +] + +[[package]] +name = "execute-command-macro-impl" +version = "0.1.9" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "55a9a55d1dab3b07854648d48e366f684aefe2ac78ae28cec3bf65e3cd53d9a3" +dependencies = [ + "execute-command-tokens", + "quote", + "syn 2.0.25", +] + +[[package]] +name = "execute-command-tokens" +version = "0.1.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8ba569491c70ec8471e34aa7e9c0b9e82bb5d2464c0398442d17d3c4af814e5a" + [[package]] name = "eyre" version = "0.6.8" @@ -1127,10 +1308,54 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "ded41244b729663b1e574f1b4fb731469f69f79c17667b5d776b16cda0479449" dependencies = [ "bitvec 1.0.1", - "rand_core", + "byteorder", + "ff_derive", + "rand_core 0.6.4", "subtle", ] +[[package]] +name = "ff_ce" +version = "0.11.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1d3a682c12d0cc98a32ab7540401a5ea1ed21d11571eea11d5829cd721f85ff0" +dependencies = [ + "byteorder", + "ff_derive_ce", + "hex", + "rand 0.4.6", +] + +[[package]] +name = "ff_derive" +version = "0.13.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e9f54704be45ed286151c5e11531316eaef5b8f5af7d597b806fdb8af108d84a" +dependencies = [ + "addchain", + "cfg-if", + "num-bigint 0.3.3", + "num-integer", + "num-traits", + "proc-macro2", + "quote", + "syn 1.0.109", +] + +[[package]] +name = "ff_derive_ce" +version = "0.8.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "50c052fa6d4c2f12305ec364bfb8ef884836f3f61ea015b202372ff996d1ac4b" +dependencies = [ + "num-bigint 0.2.6", + "num-integer", + "num-traits", + "proc-macro2", + "quote", + "syn 1.0.109", +] + [[package]] name = "fixed-hash" version = "0.8.0" @@ -1138,7 +1363,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "835c052cb0c08c1acf6ffd71c022172e18723949c8282f2b9f27efbc51e64534" dependencies = [ "byteorder", - "rand", + "rand 0.8.5", "rustc-hex", "static_assertions", ] @@ -1149,6 +1374,25 @@ version = "0.4.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "0ce7134b9999ecaf8bcd65542e436736ef32ddca1b3e06094cb6ec5755203b80" +[[package]] +name = "flate2" +version = "1.0.27" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c6c98ee8095e9d1dcbf2fcc6d95acccb90d1c81db1e44725c6a984b1dbdfb010" +dependencies = [ + "crc32fast", + "miniz_oxide", +] + +[[package]] +name = "flume" +version = "0.10.14" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1657b4441c3403d9f7b3409e47575237dac27b1b5726df654a6ecbf92f0f7577" +dependencies = [ + "spin 0.9.8", +] + [[package]] name = "fnv" version = "1.0.7" @@ -1179,6 +1423,12 @@ dependencies = [ "percent-encoding", ] +[[package]] +name = "fuchsia-cprng" +version = "0.1.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a06f77d526c1a601b7c4cdd98f54b5eaabffc14d5f2f0296febdc7f357c6d3ba" + [[package]] name = "funty" version = "2.0.0" @@ -1358,7 +1608,9 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "f0f9ef7462f7c099f518d754361858f86d8a07af53ba9af0fe635bbccb151a63" dependencies = [ "ff", - "rand_core", + "rand 0.8.5", + "rand_core 0.6.4", + "rand_xorshift", "subtle", ] @@ -1386,14 +1638,14 @@ name = "halo2_gadgets" version = "0.2.0" source = "git+https://github.com/privacy-scaling-explorations/halo2?tag=v2023_04_20#be955686f86eb618f55d2320c0e042485b313d22" dependencies = [ - "arrayvec", + "arrayvec 0.7.4", "bitvec 1.0.1", "ff", "group", "halo2_proofs", - "halo2curves", + "halo2curves 0.3.2", "lazy_static", - "rand", + "rand 0.8.5", "subtle", "uint", ] @@ -1406,14 +1658,36 @@ dependencies = [ "blake2b_simd", "ff", "group", - "halo2curves", + "halo2curves 0.3.2", "rand_chacha", - "rand_core", + "rand_core 0.6.4", "rayon", "sha3 0.9.1", "tracing", ] +[[package]] +name = "halo2curves" +version = "0.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e6b1142bd1059aacde1b477e0c80c142910f1ceae67fc619311d6a17428007ab" +dependencies = [ + "blake2b_simd", + "ff", + "group", + "lazy_static", + "num-bigint 0.4.3", + "num-traits", + "pasta_curves", + "paste", + "rand 0.8.5", + "rand_core 0.6.4", + "serde", + "serde_arrays", + "static_assertions", + "subtle", +] + [[package]] name = "halo2curves" version = "0.3.2" @@ -1422,12 +1696,12 @@ dependencies = [ "ff", "group", "lazy_static", - "num-bigint", + "num-bigint 0.4.3", "num-traits", "pasta_curves", "paste", - "rand", - "rand_core", + "rand 0.8.5", + "rand_core 0.6.4", "serde", "static_assertions", "subtle", @@ -1439,7 +1713,7 @@ version = "0.1.0" source = "git+https://github.com/privacy-scaling-explorations/halo2wrong?tag=v2023_04_20#f72db265aa3cebe297c9b9816e940d0e1d400886" dependencies = [ "halo2_proofs", - "num-bigint", + "num-bigint 0.4.3", "num-integer", "num-traits", ] @@ -1491,6 +1765,15 @@ name = "hex" version = "0.4.3" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "7f24254aa9a54b5c858eaee2f5bccdb46aaf0e486a595ed5fd8f86ba55232a70" +dependencies = [ + "serde", +] + +[[package]] +name = "hex-literal" +version = "0.3.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7ebdb29d2ea9ed0083cd8cece49bbd968021bd99b0849edb4a9a7ee0fdf6a4e0" [[package]] name = "hex-literal" @@ -1685,10 +1968,10 @@ version = "0.1.0" source = "git+https://github.com/privacy-scaling-explorations/halo2wrong?tag=v2023_04_20#f72db265aa3cebe297c9b9816e940d0e1d400886" dependencies = [ "maingate", - "num-bigint", + "num-bigint 0.4.3", "num-integer", "num-traits", - "rand", + "rand 0.8.5", "subtle", ] @@ -1716,10 +1999,28 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "cb0889898416213fab133e1d33a0e5858a48177452750691bde3666d0fdbaf8b" dependencies = [ "hermit-abi", - "rustix 0.38.3", + "rustix 0.38.11", "windows-sys", ] +[[package]] +name = "itertools" +version = "0.8.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f56a2d0bc861f9165be4eb3442afd3c236d8a98afd426f65d92324ae1091a484" +dependencies = [ + "either", +] + +[[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" @@ -1729,6 +2030,15 @@ dependencies = [ "either", ] +[[package]] +name = "itertools" +version = "0.11.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b1c173a5686ce8bfa551b3563d0c2170bf24ca44da99c7ca4bfdab5418c3fe57" +dependencies = [ + "either", +] + [[package]] name = "itoa" version = "1.0.8" @@ -1778,7 +2088,7 @@ dependencies = [ "diff", "ena", "is-terminal", - "itertools", + "itertools 0.10.5", "lalrpop-util", "petgraph", "regex", @@ -1801,7 +2111,7 @@ version = "1.4.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "e2abad23fbc42b3700f2f279844dc832adb2b2eb069b2df918f455c4e18cc646" dependencies = [ - "spin", + "spin 0.5.2", ] [[package]] @@ -1844,10 +2154,10 @@ version = "0.1.0" source = "git+https://github.com/privacy-scaling-explorations/halo2wrong?tag=v2023_04_20#f72db265aa3cebe297c9b9816e940d0e1d400886" dependencies = [ "halo2wrong", - "num-bigint", + "num-bigint 0.4.3", "num-integer", "num-traits", - "rand", + "rand 0.8.5", "subtle", ] @@ -1866,6 +2176,15 @@ version = "2.5.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "2dffe52ecf27772e601905b7522cb4ef790d2cc203488bbd0e2fe85fcb74566d" +[[package]] +name = "memmap2" +version = "0.5.10" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "83faa42c0a078c393f6b29d5db232d8be22776a891f8f56e5284faee4a20b327" +dependencies = [ + "libc", +] + [[package]] name = "memoffset" version = "0.9.0" @@ -1919,19 +2238,94 @@ dependencies = [ "tempfile", ] +[[package]] +name = "neptune" +version = "10.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "bb9a64337e6d214e2a48db5714ef18cf1e5a7bbff9043838fdf6e57ce5659335" +dependencies = [ + "bellperson", + "blake2s_simd 0.5.11", + "blstrs", + "byteorder", + "ff", + "generic-array", + "itertools 0.8.2", + "log", + "pasta_curves", + "serde", + "trait-set", +] + [[package]] name = "new_debug_unreachable" version = "1.0.4" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "e4a24736216ec316047a1fc4252e27dabb04218aa4a3f37c6e7ddbf1f9782b54" +[[package]] +name = "nova-scotia" +version = "0.5.0" +source = "git+https://github.com/nalinbhardwaj/Nova-Scotia#00085ece0e16c29a12f61866fa3588649620d7f7" +dependencies = [ + "anyhow", + "bellperson", + "byteorder", + "ff", + "hex-literal 0.3.4", + "itertools 0.9.0", + "js-sys", + "nova-snark", + "num-bigint 0.4.3", + "num-traits", + "pasta_curves", + "rayon", + "serde", + "serde_json", + "wasm-bindgen", + "wasm-bindgen-futures", + "wasm-bindgen-rayon", +] + +[[package]] +name = "nova-snark" +version = "0.23.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9e12911ac9672ad436acfc992f09e26a5960513bbe81d1572005cadd8c1be8f4" +dependencies = [ + "bellperson", + "bincode", + "bitvec 1.0.1", + "byteorder", + "digest 0.10.7", + "ff", + "flate2", + "generic-array", + "getrandom", + "halo2curves 0.1.0", + "itertools 0.11.0", + "neptune", + "num-bigint 0.4.3", + "num-integer", + "num-traits", + "pasta-msm", + "pasta_curves", + "rand_chacha", + "rand_core 0.6.4", + "rayon", + "serde", + "sha3 0.10.8", + "subtle", + "thiserror", +] + [[package]] name = "num" version = "0.4.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "43db66d1170d347f9a065114077f7dccb00c1b9478c89384490a3425279a4606" dependencies = [ - "num-bigint", + "num-bigint 0.4.3", "num-complex", "num-integer", "num-iter", @@ -1939,6 +2333,28 @@ dependencies = [ "num-traits", ] +[[package]] +name = "num-bigint" +version = "0.2.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "090c7f9998ee0ff65aa5b723e4009f7b217707f1fb5ea551329cc4d6231fb304" +dependencies = [ + "autocfg", + "num-integer", + "num-traits", +] + +[[package]] +name = "num-bigint" +version = "0.3.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5f6f7833f2cbf2360a6cfd58cd41a53aa7a90bd4c202f5b1c7dd2ed73c57b2c3" +dependencies = [ + "autocfg", + "num-integer", + "num-traits", +] + [[package]] name = "num-bigint" version = "0.4.3" @@ -1948,7 +2364,8 @@ dependencies = [ "autocfg", "num-integer", "num-traits", - "rand", + "rand 0.8.5", + "serde", ] [[package]] @@ -1988,16 +2405,16 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "0638a1c9d0a3c0914158145bc76cff373a75a627e6ecbfb71cbe6f453a5a19b0" dependencies = [ "autocfg", - "num-bigint", + "num-bigint 0.4.3", "num-integer", "num-traits", ] [[package]] name = "num-traits" -version = "0.2.15" +version = "0.2.16" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "578ede34cf02f8924ab9447f50c28075b4d3e5b269972345e7e0372b38c6cdcd" +checksum = "f30b0abd723be7e2ffca1272140fac1a2f084c77ec3e123c192b66af1ee9e6c2" dependencies = [ "autocfg", ] @@ -2060,7 +2477,7 @@ version = "0.1.4" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "786393f80485445794f6043fd3138854dd109cc6c4bd1a6383db304c9ce9b9ce" dependencies = [ - "arrayvec", + "arrayvec 0.7.4", "auto_impl", "bytes", "ethereum-types", @@ -2123,13 +2540,22 @@ dependencies = [ "vcpkg", ] +[[package]] +name = "pairing" +version = "0.23.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "81fec4625e73cf41ef4bb6846cafa6d44736525f442ba45e407c4a000a13996f" +dependencies = [ + "group", +] + [[package]] name = "parity-scale-codec" version = "3.6.3" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "756d439303e94fae44f288ba881ad29670c65b0c4b0e05674ca81061bb65f2c5" dependencies = [ - "arrayvec", + "arrayvec 0.7.4", "bitvec 1.0.1", "byte-slice-cast", "impl-trait-for-tuples", @@ -2172,6 +2598,19 @@ dependencies = [ "windows-targets", ] +[[package]] +name = "pasta-msm" +version = "0.1.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9e85d75eba3e7e9ee3bd11342b669185e194dadda3557934bc1000d9b87159d3" +dependencies = [ + "cc", + "pasta_curves", + "semolina", + "sppark", + "which", +] + [[package]] name = "pasta_curves" version = "0.5.1" @@ -2181,8 +2620,10 @@ dependencies = [ "blake2b_simd", "ff", "group", + "hex", "lazy_static", - "rand", + "rand 0.8.5", + "serde", "static_assertions", "subtle", ] @@ -2261,7 +2702,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "48e4cc64c2ad9ebe670cb8fd69dd50ae301650392e81c05f9bfcb2d5bdbc24b0" dependencies = [ "phf_shared 0.11.2", - "rand", + "rand 0.8.5", ] [[package]] @@ -2348,10 +2789,20 @@ name = "poseidon" version = "0.2.0" source = "git+https://github.com/privacy-scaling-explorations/poseidon?tag=v2023_04_20#807f8f555313f726ca03bdf941f798098f488ba4" dependencies = [ - "halo2curves", + "halo2curves 0.3.2", "subtle", ] +[[package]] +name = "poseidon-rs" +version = "0.0.10" +source = "git+https://github.com/arnaucube/poseidon-rs#f4ba1f7c32905cd2ae5a71e7568564bb150a9862" +dependencies = [ + "ff_ce", + "rand 0.4.6", + "serde_json", +] + [[package]] name = "ppv-lite86" version = "0.2.17" @@ -2452,6 +2903,19 @@ version = "0.7.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "dc33ff2d4973d518d823d61aa239014831e521c75da58e3df4840d3f47749d09" +[[package]] +name = "rand" +version = "0.4.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "552840b97013b1a26992c11eac34bdd778e464601a4c2054b5f0bff7c6761293" +dependencies = [ + "fuchsia-cprng", + "libc", + "rand_core 0.3.1", + "rdrand", + "winapi", +] + [[package]] name = "rand" version = "0.8.5" @@ -2460,7 +2924,7 @@ checksum = "34af8d1a0e25924bc5b7c43c079c942339d8f0a8b57c39049bef581b46327404" dependencies = [ "libc", "rand_chacha", - "rand_core", + "rand_core 0.6.4", ] [[package]] @@ -2470,9 +2934,24 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "e6c10a63a0fa32252be49d21e7709d4d4baf8d231c2dbce1eaa8141b9b127d88" dependencies = [ "ppv-lite86", - "rand_core", + "rand_core 0.6.4", +] + +[[package]] +name = "rand_core" +version = "0.3.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7a6fdeb83b075e8266dcc8762c22776f6877a63111121f5f8c7411e5be7eed4b" +dependencies = [ + "rand_core 0.4.2", ] +[[package]] +name = "rand_core" +version = "0.4.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9c33a3c44ca05fa6f1807d8e6743f3824e8509beca625669633be0acbdf509dc" + [[package]] name = "rand_core" version = "0.6.4" @@ -2482,6 +2961,15 @@ dependencies = [ "getrandom", ] +[[package]] +name = "rand_xorshift" +version = "0.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d25bf25ec5ae4a3f1b92f929810509a2f53d7dca2f50b794ff57e3face536c8f" +dependencies = [ + "rand_core 0.6.4", +] + [[package]] name = "rayon" version = "1.7.0" @@ -2504,6 +2992,15 @@ dependencies = [ "num_cpus", ] +[[package]] +name = "rdrand" +version = "0.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "678054eb77286b51581ba43620cc911abf02758c91f93f479767aed0f90458b2" +dependencies = [ + "rand_core 0.3.1", +] + [[package]] name = "redox_syscall" version = "0.2.16" @@ -2659,7 +3156,7 @@ dependencies = [ "fixed-hash", "hashbrown 0.13.2", "hex", - "hex-literal", + "hex-literal 0.4.1", "primitive-types", "rlp", "ruint", @@ -2764,11 +3261,11 @@ dependencies = [ [[package]] name = "rustix" -version = "0.38.3" +version = "0.38.11" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ac5ffa1efe7548069688cd7028f32591853cd7b5b756d41bcffd2353e4fc75b4" +checksum = "c0c3dde1fc030af041adc40e79c0e7fbcf431dd24870053d187d7c66e4b87453" dependencies = [ - "bitflags 2.3.3", + "bitflags 2.4.0", "errno", "libc", "linux-raw-sys 0.4.3", @@ -2911,6 +3408,16 @@ dependencies = [ "libc", ] +[[package]] +name = "semolina" +version = "0.1.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2b0111fd4fa831becb0606b9a2285ef3bee3c6a70d690209b8ae9514e9befe23" +dependencies = [ + "cc", + "glob", +] + [[package]] name = "semver" version = "1.0.17" @@ -2941,6 +3448,15 @@ dependencies = [ "serde_derive", ] +[[package]] +name = "serde_arrays" +version = "0.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "38636132857f68ec3d5f3eb121166d2af33cb55174c4d5ff645db6165cbef0fd" +dependencies = [ + "serde", +] + [[package]] name = "serde_derive" version = "1.0.171" @@ -3046,7 +3562,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "5e1788eed21689f9cf370582dfc467ef36ed9c707f073528ddafa8d83e3b8500" dependencies = [ "digest 0.10.7", - "rand_core", + "rand_core 0.6.4", ] [[package]] @@ -3077,15 +3593,15 @@ source = "git+https://github.com/privacy-scaling-explorations/snark-verifier#27f dependencies = [ "ecc", "halo2_proofs", - "halo2curves", + "halo2curves 0.3.2", "hex", - "itertools", + "itertools 0.10.5", "lazy_static", - "num-bigint", + "num-bigint 0.4.3", "num-integer", "num-traits", "poseidon", - "rand", + "rand 0.8.5", "revm", "serde", "sha3 0.10.8", @@ -3101,15 +3617,15 @@ dependencies = [ "ecc", "ethereum-types", "halo2_proofs", - "halo2curves", + "halo2curves 0.3.2", "hex", - "itertools", + "itertools 0.10.5", "lazy_static", - "num-bigint", + "num-bigint 0.4.3", "num-integer", "num-traits", "poseidon", - "rand", + "rand 0.8.5", "rand_chacha", "serde", "serde_json", @@ -3132,7 +3648,7 @@ version = "0.3.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "4a94494913728908efa7a25a2dd2e4f037e714897985c24273c40596638ed909" dependencies = [ - "itertools", + "itertools 0.10.5", "lalrpop", "lalrpop-util", "phf", @@ -3146,6 +3662,15 @@ version = "0.5.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "6e63cff320ae2c57904679ba7cb63280a3dc4613885beafb148ee7bf9aa9042d" +[[package]] +name = "spin" +version = "0.9.8" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6980e8d7511241f8acf4aebddbb1ff938df5eebe98691418c4468d0b72a96a67" +dependencies = [ + "lock_api", +] + [[package]] name = "spki" version = "0.7.2" @@ -3156,6 +3681,22 @@ dependencies = [ "der", ] +[[package]] +name = "spmc" +version = "0.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "02a8428da277a8e3a15271d79943e80ccc2ef254e78813a166a08d65e4c3ece5" + +[[package]] +name = "sppark" +version = "0.1.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ba7a6d98937866ea8917015cd4a72d56d6e7feee8979dbccf83fc0c870053c46" +dependencies = [ + "cc", + "which", +] + [[package]] name = "static_assertions" version = "1.1.0" @@ -3206,15 +3747,15 @@ dependencies = [ "byteorder", "crunchy", "lazy_static", - "rand", + "rand 0.8.5", "rustc-hex", ] [[package]] name = "subtle" -version = "2.4.1" +version = "2.5.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6bdef32e8150c2a081110b42772ffe7d7c9032b606bc226c8260fd97e0976601" +checksum = "81cdd64d312baedb58e21336b31bc043b77e01cc99033ce76ef539f78e965ebc" [[package]] name = "summa-backend" @@ -3226,7 +3767,7 @@ dependencies = [ "ethers", "futures", "halo2_proofs", - "num-bigint", + "num-bigint 0.4.3", "reqwest", "serde", "serde_json", @@ -3242,13 +3783,18 @@ dependencies = [ "ark-std", "csv", "ethers", + "ff_ce", "halo2_gadgets", "halo2_proofs", "hex", - "itertools", - "num-bigint", + "itertools 0.10.5", + "nova-scotia", + "nova-snark", + "num-bigint 0.4.3", + "num-traits", "num_cpus", - "rand", + "poseidon-rs", + "rand 0.8.5", "regex", "serde", "serde_json", @@ -3329,6 +3875,15 @@ dependencies = [ "syn 2.0.25", ] +[[package]] +name = "threadpool" +version = "1.8.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d050e60b33d41c19108b32cea32164033a9013fe3b46cbd4457559bfbf77afaa" +dependencies = [ + "num_cpus", +] + [[package]] name = "tiny-keccak" version = "2.0.2" @@ -3490,6 +4045,17 @@ dependencies = [ "tracing", ] +[[package]] +name = "trait-set" +version = "0.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b79e2e9c9ab44c6d7c20d5976961b47e8f49ac199154daa514b77cd1ab536625" +dependencies = [ + "proc-macro2", + "quote", + "syn 1.0.109", +] + [[package]] name = "try-lock" version = "0.2.4" @@ -3606,6 +4172,8 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "7706a72ab36d8cb1f80ffbf0e071533974a60d0a308d01a5d0375bf60499a342" dependencies = [ "cfg-if", + "serde", + "serde_json", "wasm-bindgen-macro", ] @@ -3659,6 +4227,18 @@ dependencies = [ "wasm-bindgen-shared", ] +[[package]] +name = "wasm-bindgen-rayon" +version = "1.0.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "df87c67450805c305d3ae44a3ac537b0253d029153c25afc3ecd2edc36ccafb1" +dependencies = [ + "js-sys", + "rayon", + "spmc", + "wasm-bindgen", +] + [[package]] name = "wasm-bindgen-shared" version = "0.2.87" @@ -3675,6 +4255,18 @@ dependencies = [ "wasm-bindgen", ] +[[package]] +name = "which" +version = "4.4.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "87ba24419a2078cd2b0f2ede2691b6c66d8e47836da3b6db8265ebad47afbfc7" +dependencies = [ + "either", + "home", + "once_cell", + "rustix 0.38.11", +] + [[package]] name = "winapi" version = "0.3.9" @@ -3824,8 +4416,32 @@ version = "0.5.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "09041cd90cf85f7f8b2df60c646f853b7f535ce68f85244eb6731cf89fa498ec" +[[package]] +name = "yastl" +version = "0.1.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8ca6c5a4d66c1a9ea261811cf4773c27343de7e5033e1b75ea3f297dc7db3c1a" +dependencies = [ + "flume", + "scopeguard", +] + [[package]] name = "zeroize" version = "1.6.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "2a0956f1ba7c7909bfb66c2e9e4124ab6f6482560f6628b5aaeba39207c9aad9" +dependencies = [ + "zeroize_derive", +] + +[[package]] +name = "zeroize_derive" +version = "1.4.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ce36e65b0d2999d2aafac989fb249189a141aee1f53c612c1f37d72631959f69" +dependencies = [ + "proc-macro2", + "quote", + "syn 2.0.25", +] diff --git a/zk_prover/Cargo.lock b/zk_prover/Cargo.lock index 8a7d7d46..014c93cc 100644 --- a/zk_prover/Cargo.lock +++ b/zk_prover/Cargo.lock @@ -12,6 +12,17 @@ dependencies = [ "regex", ] +[[package]] +name = "addchain" +version = "0.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3b2e69442aa5628ea6951fa33e24efe8313f4321a91bd729fc2f75bdfc858570" +dependencies = [ + "num-bigint 0.3.3", + "num-integer", + "num-traits", +] + [[package]] name = "addr2line" version = "0.20.0" @@ -87,7 +98,7 @@ checksum = "1df2c09229cbc5a028b1d70e00fdb2acee28b1055dfb5ca73eea49c5a25c4e7c" dependencies = [ "colored", "num-traits", - "rand", + "rand 0.8.5", ] [[package]] @@ -96,6 +107,12 @@ version = "0.3.7" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "6b4930d2cb77ce62f89ee5d5289b4ac049559b1c45539271f5ed4fdc7db34545" +[[package]] +name = "arrayvec" +version = "0.5.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "23b62fc65de8e4e7f52534fb52b0f3ed04746ae267519eef2a83941e8085068b" + [[package]] name = "arrayvec" version = "0.7.4" @@ -207,6 +224,34 @@ version = "0.7.3" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "2dabbe35f96fb9507f7330793dc490461b2962659ac5d427181e451a623751d1" +[[package]] +name = "bellperson" +version = "0.25.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "93eaee4b4753554139ae52ecf0e8b8c128cbc561b32e1bfaa32f70cba8518c1f" +dependencies = [ + "bincode", + "blake2s_simd 1.0.1", + "blstrs", + "byteorder", + "crossbeam-channel", + "digest 0.10.7", + "ec-gpu", + "ec-gpu-gen", + "ff", + "group", + "log", + "memmap2", + "pairing", + "rand 0.8.5", + "rand_core 0.6.4", + "rayon", + "rustversion", + "serde", + "sha2 0.10.7", + "thiserror", +] + [[package]] name = "bincode" version = "1.3.3" @@ -239,9 +284,9 @@ checksum = "bef38d45163c2f1dde094a7dfd33ccf595c92905c8f8f4fdc18d06fb1037718a" [[package]] name = "bitflags" -version = "2.3.3" +version = "2.4.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "630be753d4e58660abd17930c71b647fe46c27ea6b63cc59e1e3851406972e42" +checksum = "b4682ae6287fcf752ecaabbfcc7b6f9b72aa33933dc23a554d853aea8eea8635" [[package]] name = "bitvec" @@ -272,8 +317,30 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "3c2f0dc9a68c6317d884f97cc36cf5a3d20ba14ce404227df55e1af708ab04bc" dependencies = [ "arrayref", - "arrayvec", - "constant_time_eq", + "arrayvec 0.7.4", + "constant_time_eq 0.2.6", +] + +[[package]] +name = "blake2s_simd" +version = "0.5.11" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9e461a7034e85b211a4acb57ee2e6730b32912b06c08cc242243c39fc21ae6a2" +dependencies = [ + "arrayref", + "arrayvec 0.5.2", + "constant_time_eq 0.1.5", +] + +[[package]] +name = "blake2s_simd" +version = "1.0.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6637f448b9e61dfadbdcbae9a885fadee1f3eaffb1f8d3c1965d3ade8bdfd44f" +dependencies = [ + "arrayref", + "arrayvec 0.7.4", + "constant_time_eq 0.2.6", ] [[package]] @@ -301,6 +368,34 @@ version = "0.2.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "8d696c370c750c948ada61c69a0ee2cbbb9c50b1019ddb86d9317157a99c2cae" +[[package]] +name = "blst" +version = "0.3.11" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c94087b935a822949d3291a9989ad2b2051ea141eda0fd4e478a75f6aa3e604b" +dependencies = [ + "cc", + "glob", + "threadpool", + "zeroize", +] + +[[package]] +name = "blstrs" +version = "0.7.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7a8a8ed6fefbeef4a8c7b460e4110e12c5e22a5b7cf32621aae6ad650c4dcf29" +dependencies = [ + "blst", + "byte-slice-cast", + "ff", + "group", + "pairing", + "rand_core 0.6.4", + "serde", + "subtle", +] + [[package]] name = "bs58" version = "0.4.0" @@ -469,7 +564,7 @@ dependencies = [ "hmac", "once_cell", "pbkdf2 0.12.1", - "rand", + "rand 0.8.5", "sha2 0.10.7", "thiserror", ] @@ -523,6 +618,12 @@ version = "0.9.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "520fbf3c07483f94e3e3ca9d0cfd913d7718ef2483d2cfd91c0d9e91474ab913" +[[package]] +name = "constant_time_eq" +version = "0.1.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "245097e9a4535ee1e3e3931fcfcd55a796a44c643e8596ff6566d68f09b87bbc" + [[package]] name = "constant_time_eq" version = "0.2.6" @@ -616,7 +717,7 @@ dependencies = [ "clap", "criterion-plot", "csv", - "itertools", + "itertools 0.10.5", "lazy_static", "num-traits", "oorandom", @@ -638,7 +739,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "2673cc8207403546f45f5fd319a974b1e6983ad1a3ee7e6041650013be041876" dependencies = [ "cast", - "itertools", + "itertools 0.10.5", ] [[package]] @@ -697,7 +798,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "cf4c2f4e1afd912bc40bfd6fed5d9dc1f288e0ba01bfcc835cc5bc3eb13efe15" dependencies = [ "generic-array", - "rand_core", + "rand_core 0.6.4", "subtle", "zeroize", ] @@ -900,16 +1001,44 @@ dependencies = [ "wio", ] +[[package]] +name = "ec-gpu" +version = "0.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "bd63582de2b59ea1aa48d7c1941b5d87618d95484397521b3acdfa0e1e9f5e45" + +[[package]] +name = "ec-gpu-gen" +version = "0.6.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "892df2aa20abec5b816e15d5d6383892ca142077708efa3067dd3ac44b75c664" +dependencies = [ + "bitvec 1.0.1", + "crossbeam-channel", + "ec-gpu", + "execute", + "ff", + "group", + "hex", + "log", + "num_cpus", + "once_cell", + "rayon", + "sha2 0.10.7", + "thiserror", + "yastl", +] + [[package]] name = "ecc" version = "0.1.0" source = "git+https://github.com/privacy-scaling-explorations/halo2wrong?tag=v2023_04_20#f72db265aa3cebe297c9b9816e940d0e1d400886" dependencies = [ "integer", - "num-bigint", + "num-bigint 0.4.3", "num-integer", "num-traits", - "rand", + "rand 0.8.5", "subtle", ] @@ -946,7 +1075,7 @@ dependencies = [ "generic-array", "group", "pkcs8", - "rand_core", + "rand_core 0.6.4", "sec1", "subtle", "zeroize", @@ -981,7 +1110,7 @@ dependencies = [ "hex", "k256", "log", - "rand", + "rand 0.8.5", "rlp", "serde", "sha3 0.10.8", @@ -1038,7 +1167,7 @@ dependencies = [ "hex", "hmac", "pbkdf2 0.11.0", - "rand", + "rand 0.8.5", "scrypt", "serde", "serde_json", @@ -1187,7 +1316,7 @@ version = "2.0.7" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "6da5fa198af0d3be20c19192df2bd9590b92ce09a8421e793bec8851270f1b05" dependencies = [ - "arrayvec", + "arrayvec 0.7.4", "bytes", "cargo_metadata", "chrono", @@ -1199,7 +1328,7 @@ dependencies = [ "num_enum", "once_cell", "open-fastrlp", - "rand", + "rand 0.8.5", "rlp", "serde", "serde_json", @@ -1302,7 +1431,7 @@ dependencies = [ "eth-keystore", "ethers-core", "hex", - "rand", + "rand 0.8.5", "sha2 0.10.7", "thiserror", "tracing", @@ -1338,6 +1467,43 @@ dependencies = [ "yansi", ] +[[package]] +name = "execute" +version = "0.2.12" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "16d9a9ea4c04632c16bc5c71a2fcc63d308481f7fc67eb1a1ce6315c44a426ae" +dependencies = [ + "execute-command-macro", + "execute-command-tokens", + "generic-array", +] + +[[package]] +name = "execute-command-macro" +version = "0.1.8" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a5fbc65a0cf735106743f4c38c9a3671c1e734b5c2c20d21a3c93c696daa3157" +dependencies = [ + "execute-command-macro-impl", +] + +[[package]] +name = "execute-command-macro-impl" +version = "0.1.9" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "55a9a55d1dab3b07854648d48e366f684aefe2ac78ae28cec3bf65e3cd53d9a3" +dependencies = [ + "execute-command-tokens", + "quote", + "syn 2.0.22", +] + +[[package]] +name = "execute-command-tokens" +version = "0.1.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8ba569491c70ec8471e34aa7e9c0b9e82bb5d2464c0398442d17d3c4af814e5a" + [[package]] name = "eyre" version = "0.6.8" @@ -1373,10 +1539,54 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "ded41244b729663b1e574f1b4fb731469f69f79c17667b5d776b16cda0479449" dependencies = [ "bitvec 1.0.1", - "rand_core", + "byteorder", + "ff_derive", + "rand_core 0.6.4", "subtle", ] +[[package]] +name = "ff_ce" +version = "0.11.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1d3a682c12d0cc98a32ab7540401a5ea1ed21d11571eea11d5829cd721f85ff0" +dependencies = [ + "byteorder", + "ff_derive_ce", + "hex", + "rand 0.4.6", +] + +[[package]] +name = "ff_derive" +version = "0.13.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e9f54704be45ed286151c5e11531316eaef5b8f5af7d597b806fdb8af108d84a" +dependencies = [ + "addchain", + "cfg-if", + "num-bigint 0.3.3", + "num-integer", + "num-traits", + "proc-macro2", + "quote", + "syn 1.0.109", +] + +[[package]] +name = "ff_derive_ce" +version = "0.8.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "50c052fa6d4c2f12305ec364bfb8ef884836f3f61ea015b202372ff996d1ac4b" +dependencies = [ + "num-bigint 0.2.6", + "num-integer", + "num-traits", + "proc-macro2", + "quote", + "syn 1.0.109", +] + [[package]] name = "fixed-hash" version = "0.8.0" @@ -1384,7 +1594,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "835c052cb0c08c1acf6ffd71c022172e18723949c8282f2b9f27efbc51e64534" dependencies = [ "byteorder", - "rand", + "rand 0.8.5", "rustc-hex", "static_assertions", ] @@ -1411,6 +1621,15 @@ version = "0.2.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "7bad48618fdb549078c333a7a8528acb57af271d0433bdecd523eb620628364e" +[[package]] +name = "flume" +version = "0.10.14" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1657b4441c3403d9f7b3409e47575237dac27b1b5726df654a6ecbf92f0f7577" +dependencies = [ + "spin 0.9.8", +] + [[package]] name = "fnv" version = "1.0.7" @@ -1487,6 +1706,12 @@ dependencies = [ "pkg-config", ] +[[package]] +name = "fuchsia-cprng" +version = "0.1.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a06f77d526c1a601b7c4cdd98f54b5eaabffc14d5f2f0296febdc7f357c6d3ba" + [[package]] name = "funty" version = "2.0.0" @@ -1676,7 +1901,9 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "f0f9ef7462f7c099f518d754361858f86d8a07af53ba9af0fe635bbccb151a63" dependencies = [ "ff", - "rand_core", + "rand 0.8.5", + "rand_core 0.6.4", + "rand_xorshift", "subtle", ] @@ -1710,14 +1937,14 @@ name = "halo2_gadgets" version = "0.2.0" source = "git+https://github.com/privacy-scaling-explorations/halo2?tag=v2023_04_20#be955686f86eb618f55d2320c0e042485b313d22" dependencies = [ - "arrayvec", + "arrayvec 0.7.4", "bitvec 1.0.1", "ff", "group", "halo2_proofs", - "halo2curves", + "halo2curves 0.3.2", "lazy_static", - "rand", + "rand 0.8.5", "subtle", "uint", ] @@ -1730,16 +1957,38 @@ dependencies = [ "blake2b_simd", "ff", "group", - "halo2curves", + "halo2curves 0.3.2", "plotters", "rand_chacha", - "rand_core", + "rand_core 0.6.4", "rayon", "sha3 0.9.1", "tabbycat", "tracing", ] +[[package]] +name = "halo2curves" +version = "0.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e6b1142bd1059aacde1b477e0c80c142910f1ceae67fc619311d6a17428007ab" +dependencies = [ + "blake2b_simd", + "ff", + "group", + "lazy_static", + "num-bigint 0.4.3", + "num-traits", + "pasta_curves", + "paste", + "rand 0.8.5", + "rand_core 0.6.4", + "serde", + "serde_arrays", + "static_assertions", + "subtle", +] + [[package]] name = "halo2curves" version = "0.3.2" @@ -1748,12 +1997,12 @@ dependencies = [ "ff", "group", "lazy_static", - "num-bigint", + "num-bigint 0.4.3", "num-traits", "pasta_curves", "paste", - "rand", - "rand_core", + "rand 0.8.5", + "rand_core 0.6.4", "serde", "static_assertions", "subtle", @@ -1765,7 +2014,7 @@ version = "0.1.0" source = "git+https://github.com/privacy-scaling-explorations/halo2wrong?tag=v2023_04_20#f72db265aa3cebe297c9b9816e940d0e1d400886" dependencies = [ "halo2_proofs", - "num-bigint", + "num-bigint 0.4.3", "num-integer", "num-traits", ] @@ -1835,6 +2084,15 @@ name = "hex" version = "0.4.3" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "7f24254aa9a54b5c858eaee2f5bccdb46aaf0e486a595ed5fd8f86ba55232a70" +dependencies = [ + "serde", +] + +[[package]] +name = "hex-literal" +version = "0.3.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7ebdb29d2ea9ed0083cd8cece49bbd968021bd99b0849edb4a9a7ee0fdf6a4e0" [[package]] name = "hex-literal" @@ -2060,10 +2318,10 @@ version = "0.1.0" source = "git+https://github.com/privacy-scaling-explorations/halo2wrong?tag=v2023_04_20#f72db265aa3cebe297c9b9816e940d0e1d400886" dependencies = [ "maingate", - "num-bigint", + "num-bigint 0.4.3", "num-integer", "num-traits", - "rand", + "rand 0.8.5", "subtle", ] @@ -2091,10 +2349,28 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "24fddda5af7e54bf7da53067d6e802dbcc381d0a8eef629df528e3ebf68755cb" dependencies = [ "hermit-abi 0.3.1", - "rustix 0.38.2", + "rustix 0.38.11", "windows-sys", ] +[[package]] +name = "itertools" +version = "0.8.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f56a2d0bc861f9165be4eb3442afd3c236d8a98afd426f65d92324ae1091a484" +dependencies = [ + "either", +] + +[[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" @@ -2104,6 +2380,15 @@ dependencies = [ "either", ] +[[package]] +name = "itertools" +version = "0.11.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b1c173a5686ce8bfa551b3563d0c2170bf24ca44da99c7ca4bfdab5418c3fe57" +dependencies = [ + "either", +] + [[package]] name = "itoa" version = "1.0.6" @@ -2159,7 +2444,7 @@ dependencies = [ "diff", "ena", "is-terminal", - "itertools", + "itertools 0.10.5", "lalrpop-util", "petgraph", "regex", @@ -2182,7 +2467,7 @@ version = "1.4.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "e2abad23fbc42b3700f2f279844dc832adb2b2eb069b2df918f455c4e18cc646" dependencies = [ - "spin", + "spin 0.5.2", ] [[package]] @@ -2235,10 +2520,10 @@ version = "0.1.0" source = "git+https://github.com/privacy-scaling-explorations/halo2wrong?tag=v2023_04_20#f72db265aa3cebe297c9b9816e940d0e1d400886" dependencies = [ "halo2wrong", - "num-bigint", + "num-bigint 0.4.3", "num-integer", "num-traits", - "rand", + "rand 0.8.5", "subtle", ] @@ -2257,6 +2542,15 @@ version = "2.5.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "2dffe52ecf27772e601905b7522cb4ef790d2cc203488bbd0e2fe85fcb74566d" +[[package]] +name = "memmap2" +version = "0.5.10" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "83faa42c0a078c393f6b29d5db232d8be22776a891f8f56e5284faee4a20b327" +dependencies = [ + "libc", +] + [[package]] name = "memoffset" version = "0.9.0" @@ -2293,19 +2587,94 @@ dependencies = [ "windows-sys", ] +[[package]] +name = "neptune" +version = "10.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "bb9a64337e6d214e2a48db5714ef18cf1e5a7bbff9043838fdf6e57ce5659335" +dependencies = [ + "bellperson", + "blake2s_simd 0.5.11", + "blstrs", + "byteorder", + "ff", + "generic-array", + "itertools 0.8.2", + "log", + "pasta_curves", + "serde", + "trait-set", +] + [[package]] name = "new_debug_unreachable" version = "1.0.4" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "e4a24736216ec316047a1fc4252e27dabb04218aa4a3f37c6e7ddbf1f9782b54" +[[package]] +name = "nova-scotia" +version = "0.5.0" +source = "git+https://github.com/nalinbhardwaj/Nova-Scotia#00085ece0e16c29a12f61866fa3588649620d7f7" +dependencies = [ + "anyhow", + "bellperson", + "byteorder", + "ff", + "hex-literal 0.3.4", + "itertools 0.9.0", + "js-sys", + "nova-snark", + "num-bigint 0.4.3", + "num-traits", + "pasta_curves", + "rayon", + "serde", + "serde_json", + "wasm-bindgen", + "wasm-bindgen-futures", + "wasm-bindgen-rayon", +] + +[[package]] +name = "nova-snark" +version = "0.23.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9e12911ac9672ad436acfc992f09e26a5960513bbe81d1572005cadd8c1be8f4" +dependencies = [ + "bellperson", + "bincode", + "bitvec 1.0.1", + "byteorder", + "digest 0.10.7", + "ff", + "flate2", + "generic-array", + "getrandom", + "halo2curves 0.1.0", + "itertools 0.11.0", + "neptune", + "num-bigint 0.4.3", + "num-integer", + "num-traits", + "pasta-msm", + "pasta_curves", + "rand_chacha", + "rand_core 0.6.4", + "rayon", + "serde", + "sha3 0.10.8", + "subtle", + "thiserror", +] + [[package]] name = "num" version = "0.4.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "43db66d1170d347f9a065114077f7dccb00c1b9478c89384490a3425279a4606" dependencies = [ - "num-bigint", + "num-bigint 0.4.3", "num-complex", "num-integer", "num-iter", @@ -2313,6 +2682,28 @@ dependencies = [ "num-traits", ] +[[package]] +name = "num-bigint" +version = "0.2.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "090c7f9998ee0ff65aa5b723e4009f7b217707f1fb5ea551329cc4d6231fb304" +dependencies = [ + "autocfg", + "num-integer", + "num-traits", +] + +[[package]] +name = "num-bigint" +version = "0.3.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5f6f7833f2cbf2360a6cfd58cd41a53aa7a90bd4c202f5b1c7dd2ed73c57b2c3" +dependencies = [ + "autocfg", + "num-integer", + "num-traits", +] + [[package]] name = "num-bigint" version = "0.4.3" @@ -2322,7 +2713,8 @@ dependencies = [ "autocfg", "num-integer", "num-traits", - "rand", + "rand 0.8.5", + "serde", ] [[package]] @@ -2362,16 +2754,16 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "0638a1c9d0a3c0914158145bc76cff373a75a627e6ecbfb71cbe6f453a5a19b0" dependencies = [ "autocfg", - "num-bigint", + "num-bigint 0.4.3", "num-integer", "num-traits", ] [[package]] name = "num-traits" -version = "0.2.15" +version = "0.2.16" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "578ede34cf02f8924ab9447f50c28075b4d3e5b269972345e7e0372b38c6cdcd" +checksum = "f30b0abd723be7e2ffca1272140fac1a2f084c77ec3e123c192b66af1ee9e6c2" dependencies = [ "autocfg", ] @@ -2440,7 +2832,7 @@ version = "0.1.4" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "786393f80485445794f6043fd3138854dd109cc6c4bd1a6383db304c9ce9b9ce" dependencies = [ - "arrayvec", + "arrayvec 0.7.4", "auto_impl", "bytes", "ethereum-types", @@ -2459,13 +2851,22 @@ dependencies = [ "syn 1.0.109", ] +[[package]] +name = "pairing" +version = "0.23.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "81fec4625e73cf41ef4bb6846cafa6d44736525f442ba45e407c4a000a13996f" +dependencies = [ + "group", +] + [[package]] name = "parity-scale-codec" version = "3.6.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "2287753623c76f953acd29d15d8100bcab84d29db78fb6f352adb3c53e83b967" dependencies = [ - "arrayvec", + "arrayvec 0.7.4", "bitvec 1.0.1", "byte-slice-cast", "impl-trait-for-tuples", @@ -2508,6 +2909,19 @@ dependencies = [ "windows-targets", ] +[[package]] +name = "pasta-msm" +version = "0.1.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9e85d75eba3e7e9ee3bd11342b669185e194dadda3557934bc1000d9b87159d3" +dependencies = [ + "cc", + "pasta_curves", + "semolina", + "sppark", + "which", +] + [[package]] name = "pasta_curves" version = "0.5.1" @@ -2517,8 +2931,10 @@ dependencies = [ "blake2b_simd", "ff", "group", + "hex", "lazy_static", - "rand", + "rand 0.8.5", + "serde", "static_assertions", "subtle", ] @@ -2626,7 +3042,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "48e4cc64c2ad9ebe670cb8fd69dd50ae301650392e81c05f9bfcb2d5bdbc24b0" dependencies = [ "phf_shared 0.11.2", - "rand", + "rand 0.8.5", ] [[package]] @@ -2772,10 +3188,20 @@ name = "poseidon" version = "0.2.0" source = "git+https://github.com/privacy-scaling-explorations/poseidon.git?tag=v2023_04_20#807f8f555313f726ca03bdf941f798098f488ba4" dependencies = [ - "halo2curves", + "halo2curves 0.3.2", "subtle", ] +[[package]] +name = "poseidon-rs" +version = "0.0.10" +source = "git+https://github.com/arnaucube/poseidon-rs#f4ba1f7c32905cd2ae5a71e7568564bb150a9862" +dependencies = [ + "ff_ce", + "rand 0.4.6", + "serde_json", +] + [[package]] name = "ppv-lite86" version = "0.2.17" @@ -2876,6 +3302,19 @@ version = "0.7.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "dc33ff2d4973d518d823d61aa239014831e521c75da58e3df4840d3f47749d09" +[[package]] +name = "rand" +version = "0.4.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "552840b97013b1a26992c11eac34bdd778e464601a4c2054b5f0bff7c6761293" +dependencies = [ + "fuchsia-cprng", + "libc", + "rand_core 0.3.1", + "rdrand", + "winapi", +] + [[package]] name = "rand" version = "0.8.5" @@ -2884,7 +3323,7 @@ checksum = "34af8d1a0e25924bc5b7c43c079c942339d8f0a8b57c39049bef581b46327404" dependencies = [ "libc", "rand_chacha", - "rand_core", + "rand_core 0.6.4", ] [[package]] @@ -2894,9 +3333,24 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "e6c10a63a0fa32252be49d21e7709d4d4baf8d231c2dbce1eaa8141b9b127d88" dependencies = [ "ppv-lite86", - "rand_core", + "rand_core 0.6.4", +] + +[[package]] +name = "rand_core" +version = "0.3.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7a6fdeb83b075e8266dcc8762c22776f6877a63111121f5f8c7411e5be7eed4b" +dependencies = [ + "rand_core 0.4.2", ] +[[package]] +name = "rand_core" +version = "0.4.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9c33a3c44ca05fa6f1807d8e6743f3824e8509beca625669633be0acbdf509dc" + [[package]] name = "rand_core" version = "0.6.4" @@ -2906,6 +3360,15 @@ dependencies = [ "getrandom", ] +[[package]] +name = "rand_xorshift" +version = "0.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d25bf25ec5ae4a3f1b92f929810509a2f53d7dca2f50b794ff57e3face536c8f" +dependencies = [ + "rand_core 0.6.4", +] + [[package]] name = "rayon" version = "1.7.0" @@ -2928,6 +3391,15 @@ dependencies = [ "num_cpus", ] +[[package]] +name = "rdrand" +version = "0.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "678054eb77286b51581ba43620cc911abf02758c91f93f479767aed0f90458b2" +dependencies = [ + "rand_core 0.3.1", +] + [[package]] name = "redox_syscall" version = "0.2.16" @@ -3068,7 +3540,7 @@ dependencies = [ "fixed-hash", "hashbrown 0.13.2", "hex", - "hex-literal", + "hex-literal 0.4.1", "primitive-types", "rlp", "ruint", @@ -3182,11 +3654,11 @@ dependencies = [ [[package]] name = "rustix" -version = "0.38.2" +version = "0.38.11" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "aabcb0461ebd01d6b79945797c27f8529082226cb630a9865a71870ff63532a4" +checksum = "c0c3dde1fc030af041adc40e79c0e7fbcf431dd24870053d187d7c66e4b87453" dependencies = [ - "bitflags 2.3.3", + "bitflags 2.4.0", "errno", "libc", "linux-raw-sys 0.4.3", @@ -3297,6 +3769,16 @@ dependencies = [ "cc", ] +[[package]] +name = "semolina" +version = "0.1.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2b0111fd4fa831becb0606b9a2285ef3bee3c6a70d690209b8ae9514e9befe23" +dependencies = [ + "cc", + "glob", +] + [[package]] name = "semver" version = "0.11.0" @@ -3345,6 +3827,15 @@ dependencies = [ "serde_derive", ] +[[package]] +name = "serde_arrays" +version = "0.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "38636132857f68ec3d5f3eb121166d2af33cb55174c4d5ff645db6165cbef0fd" +dependencies = [ + "serde", +] + [[package]] name = "serde_cbor" version = "0.11.2" @@ -3451,7 +3942,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "5e1788eed21689f9cf370582dfc467ef36ed9c707f073528ddafa8d83e3b8500" dependencies = [ "digest 0.10.7", - "rand_core", + "rand_core 0.6.4", ] [[package]] @@ -3488,15 +3979,15 @@ source = "git+https://github.com/privacy-scaling-explorations/snark-verifier#5ea dependencies = [ "ecc", "halo2_proofs", - "halo2curves", + "halo2curves 0.3.2", "hex", - "itertools", + "itertools 0.10.5", "lazy_static", - "num-bigint", + "num-bigint 0.4.3", "num-integer", "num-traits", "poseidon", - "rand", + "rand 0.8.5", "revm", "serde", "sha3 0.10.8", @@ -3512,15 +4003,15 @@ dependencies = [ "ecc", "ethereum-types", "halo2_proofs", - "halo2curves", + "halo2curves 0.3.2", "hex", - "itertools", + "itertools 0.10.5", "lazy_static", - "num-bigint", + "num-bigint 0.4.3", "num-integer", "num-traits", "poseidon", - "rand", + "rand 0.8.5", "rand_chacha", "serde", "serde_json", @@ -3543,7 +4034,7 @@ version = "0.3.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "4a94494913728908efa7a25a2dd2e4f037e714897985c24273c40596638ed909" dependencies = [ - "itertools", + "itertools 0.10.5", "lalrpop", "lalrpop-util", "phf", @@ -3557,6 +4048,15 @@ version = "0.5.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "6e63cff320ae2c57904679ba7cb63280a3dc4613885beafb148ee7bf9aa9042d" +[[package]] +name = "spin" +version = "0.9.8" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6980e8d7511241f8acf4aebddbb1ff938df5eebe98691418c4468d0b72a96a67" +dependencies = [ + "lock_api", +] + [[package]] name = "spki" version = "0.7.2" @@ -3567,6 +4067,22 @@ dependencies = [ "der", ] +[[package]] +name = "spmc" +version = "0.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "02a8428da277a8e3a15271d79943e80ccc2ef254e78813a166a08d65e4c3ece5" + +[[package]] +name = "sppark" +version = "0.1.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ba7a6d98937866ea8917015cd4a72d56d6e7feee8979dbccf83fc0c870053c46" +dependencies = [ + "cc", + "which", +] + [[package]] name = "static_assertions" version = "1.1.0" @@ -3623,15 +4139,15 @@ dependencies = [ "byteorder", "crunchy", "lazy_static", - "rand", + "rand 0.8.5", "rustc-hex", ] [[package]] name = "subtle" -version = "2.4.1" +version = "2.5.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6bdef32e8150c2a081110b42772ffe7d7c9032b606bc226c8260fd97e0976601" +checksum = "81cdd64d312baedb58e21336b31bc043b77e01cc99033ce76ef539f78e965ebc" [[package]] name = "summa-solvency" @@ -3641,14 +4157,19 @@ dependencies = [ "criterion", "csv", "ethers", + "ff_ce", "halo2_gadgets", "halo2_proofs", "hex", - "itertools", - "num-bigint", + "itertools 0.10.5", + "nova-scotia", + "nova-snark", + "num-bigint 0.4.3", + "num-traits", "num_cpus", "plotters", - "rand", + "poseidon-rs", + "rand 0.8.5", "regex", "serde", "serde_json", @@ -3750,6 +4271,15 @@ dependencies = [ "syn 2.0.22", ] +[[package]] +name = "threadpool" +version = "1.8.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d050e60b33d41c19108b32cea32164033a9013fe3b46cbd4457559bfbf77afaa" +dependencies = [ + "num_cpus", +] + [[package]] name = "time" version = "0.1.45" @@ -3908,6 +4438,17 @@ dependencies = [ "tracing", ] +[[package]] +name = "trait-set" +version = "0.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b79e2e9c9ab44c6d7c20d5976961b47e8f49ac199154daa514b77cd1ab536625" +dependencies = [ + "proc-macro2", + "quote", + "syn 1.0.109", +] + [[package]] name = "try-lock" version = "0.2.4" @@ -4042,6 +4583,8 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "7706a72ab36d8cb1f80ffbf0e071533974a60d0a308d01a5d0375bf60499a342" dependencies = [ "cfg-if", + "serde", + "serde_json", "wasm-bindgen-macro", ] @@ -4095,6 +4638,18 @@ dependencies = [ "wasm-bindgen-shared", ] +[[package]] +name = "wasm-bindgen-rayon" +version = "1.0.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "df87c67450805c305d3ae44a3ac537b0253d029153c25afc3ecd2edc36ccafb1" +dependencies = [ + "js-sys", + "rayon", + "spmc", + "wasm-bindgen", +] + [[package]] name = "wasm-bindgen-shared" version = "0.2.87" @@ -4117,6 +4672,18 @@ version = "0.1.7" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "9193164d4de03a926d909d3bc7c30543cecb35400c02114792c2cae20d5e2dbb" +[[package]] +name = "which" +version = "4.4.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "87ba24419a2078cd2b0f2ede2691b6c66d8e47836da3b6db8265ebad47afbfc7" +dependencies = [ + "either", + "home", + "once_cell", + "rustix 0.38.11", +] + [[package]] name = "winapi" version = "0.3.9" @@ -4284,6 +4851,16 @@ version = "0.5.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "09041cd90cf85f7f8b2df60c646f853b7f535ce68f85244eb6731cf89fa498ec" +[[package]] +name = "yastl" +version = "0.1.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8ca6c5a4d66c1a9ea261811cf4773c27343de7e5033e1b75ea3f297dc7db3c1a" +dependencies = [ + "flume", + "scopeguard", +] + [[package]] name = "yeslogic-fontconfig-sys" version = "3.2.0" @@ -4301,3 +4878,17 @@ name = "zeroize" version = "1.6.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "2a0956f1ba7c7909bfb66c2e9e4124ab6f6482560f6628b5aaeba39207c9aad9" +dependencies = [ + "zeroize_derive", +] + +[[package]] +name = "zeroize_derive" +version = "1.4.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ce36e65b0d2999d2aafac989fb249189a141aee1f53c612c1f37d72631959f69" +dependencies = [ + "proc-macro2", + "quote", + "syn 2.0.22", +] diff --git a/zk_prover/Cargo.toml b/zk_prover/Cargo.toml index b7660f76..e66502ac 100644 --- a/zk_prover/Cargo.toml +++ b/zk_prover/Cargo.toml @@ -27,6 +27,11 @@ snark-verifier = { git = "https://github.com/privacy-scaling-explorations/snark- itertools = "0.10.3" ethers = { version = "2.0.7", default-features = false, features = ["ethers-solc"] } regex-simple = { version = "1", package = "regex" } +nova-snark = "0.23.0" +nova-scotia = { git = "https://github.com/nalinbhardwaj/Nova-Scotia" } +poseidon-rs = { git = "https://github.com/arnaucube/poseidon-rs" } +ff = {package="ff_ce" , version="0.11", features = ["derive"]} +num-traits = "0.2.16" [dev-dependencies] criterion= "0.3" diff --git a/zk_prover/README.md b/zk_prover/README.md index 640ff405..b3fbf64d 100644 --- a/zk_prover/README.md +++ b/zk_prover/README.md @@ -58,6 +58,22 @@ The verifier are generated based on an unsafe setup. For a production ready veri On top of that the script will also generate a `inclusion_proof_solidity_calldata.json` file that contains some testing calldata to be used within `contracts` and `backend` to test the verifier. Again, in the example, the proof is generated based on the `src/merkle_sum_tree/csv/entry_16.csv` file for a specific `user_index`, which is set to 0 by default. If you want to generate a testing proof for a different file, you can change the path in the script. If you want to generate a proof for a different `user_index`, you can change the `user_index` in the script. +## Incremental Nova Verifier + +The Incremental Nova Verifier is an experimental feature that allows a user to verify a sequence of proofs of inclusion in one shot. More details can be found in the [write up](https://hackmd.io/@summa/HkGMF4Ovn). + +We provide an example to test the Nova verifier. The build folder already contains the artifacts generated by the circuit compilation. If you want to recompile the circuit, you can run the following command: + +``` +circom src/circom/incremental_mst_inclusion.circom --r1cs --wasm -o examples/build --prime bn128 +``` + +To run the Nova Incremental Verifier example run: + +``` +cargo run --release --example nova_incremental_verifier +``` + ## Benches The benchmarking included the following areas: diff --git a/zk_prover/examples/build/incremental_mst_inclusion.r1cs b/zk_prover/examples/build/incremental_mst_inclusion.r1cs new file mode 100644 index 00000000..d7258e5a Binary files /dev/null and b/zk_prover/examples/build/incremental_mst_inclusion.r1cs differ diff --git a/zk_prover/examples/build/incremental_mst_inclusion_js/incremental_mst_inclusion.wasm b/zk_prover/examples/build/incremental_mst_inclusion_js/incremental_mst_inclusion.wasm new file mode 100644 index 00000000..7878c72b Binary files /dev/null and b/zk_prover/examples/build/incremental_mst_inclusion_js/incremental_mst_inclusion.wasm differ diff --git a/zk_prover/examples/nova_incremental_verifier.rs b/zk_prover/examples/nova_incremental_verifier.rs new file mode 100644 index 00000000..7ab36e43 --- /dev/null +++ b/zk_prover/examples/nova_incremental_verifier.rs @@ -0,0 +1,444 @@ +use std::{ + collections::HashMap, + env::current_dir, + fs::File, + io::{BufRead, BufReader}, + time::Instant, +}; + +use ff::{Field, PrimeField}; +use nova_scotia::{ + circom::reader::load_r1cs, create_public_params, create_recursive_circuit, FileLocation, F, S, +}; +use nova_snark::{provider, CompressedSNARK, PublicParams}; +use num_bigint::BigUint; +use serde_json::json; +use summa_solvency::merkle_sum_tree::big_intify_username; + +const N_ASSETS: usize = 2; + +/// In this scenario the Exchange is generating an incremental inclusion proof for a user after 3 rounds. +/// It means that starting from this proof, the user can verify their correct inclusion in the Liabilities Tree for each round up to round 3 in a single proof. +/// +fn run_test(circuit_filepath: String, witness_gen_filepath: String) { + // Liabilities State represents the state of the Liabilities Tree at each step. H(prev_state, root) = liabiltiies_state. It starts at 0 + // The Liabilties State is submitted to the smart contract at each step as part of the Proof of Solvency (not included in this example) + let liabilities_state_0 = Fr::from_str("0").unwrap(); + + // Merkle Proof represents the inclusion proof for the user 0 for each state + let merkle_proof_1 = + build_merkle_proof("examples/states/entry_16_1.csv".to_string(), 0).unwrap(); + let liabilities_state_1 = + build_liabilities_state_cur(liabilities_state_0, merkle_proof_1.root.hash); + + let merkle_proof_2 = + build_merkle_proof("examples/states/entry_16_2.csv".to_string(), 0).unwrap(); + let liabilities_state_2 = + build_liabilities_state_cur(liabilities_state_1, merkle_proof_2.root.hash); + + let merkle_proof_3 = + build_merkle_proof("examples/states/entry_16_3.csv".to_string(), 0).unwrap(); + let liabilities_state_3 = + build_liabilities_state_cur(liabilities_state_2, merkle_proof_3.root.hash); + + // At state 3, the user is requesting an incremental inclusion proof for the first time. The CEX generates it. + type G1 = provider::bn256_grumpkin::bn256::Point; + type G2 = provider::bn256_grumpkin::grumpkin::Point; + + println!( + "Running test with witness generator: {} and group: {}", + witness_gen_filepath, + std::any::type_name::() + ); + + let iteration_count = 3; + let root = current_dir().unwrap(); + + let circuit_file = root.join(circuit_filepath); + let r1cs = load_r1cs::(&FileLocation::PathBuf(circuit_file)); + let witness_generator_file = root.join(witness_gen_filepath); + + let pp: PublicParams = create_public_params(r1cs.clone()); + + println!( + "Number of constraints per step (primary circuit): {}", + pp.num_constraints().0 + ); + println!( + "Number of constraints per step (secondary circuit): {}", + pp.num_constraints().1 + ); + + println!( + "Number of variables per step (primary circuit): {}", + pp.num_variables().0 + ); + println!( + "Number of variables per step (secondary circuit): {}", + pp.num_variables().1 + ); + + // Build the private inputs for each step circuit + let merkle_proofs = vec![ + merkle_proof_1.clone(), + merkle_proof_2.clone(), + merkle_proof_3.clone(), + ]; + + let usernames = merkle_proofs + .iter() + .map(|proof| proof.username.clone()) + .collect::>(); + + let user_balances = merkle_proofs + .iter() + .map(|proof| proof.user_balances.clone()) + .collect::>>(); + + let path_element_hashes = merkle_proofs + .iter() + .map(|proof| proof.path_element_hashes.clone()) + .collect::>>(); + + let path_element_balances = merkle_proofs + .iter() + .map(|proof| proof.path_element_balances.clone()) + .collect::>>>(); + + let path_indices = merkle_proofs + .iter() + .map(|proof| proof.path_indices.clone()) + .collect::>>(); + + let mut private_inputs = Vec::new(); + for i in 0..iteration_count { + let mut private_input = HashMap::new(); + private_input.insert("username".to_string(), json!(usernames[i])); + private_input.insert("user_balances".to_string(), json!(user_balances[i])); + private_input.insert( + "path_element_hashes".to_string(), + json!(path_element_hashes[i]), + ); + private_input.insert( + "path_element_balances".to_string(), + json!(path_element_balances[i]), + ); + private_input.insert("path_indices".to_string(), json!(path_indices[i])); + private_inputs.push(private_input); + } + + // The start public input is [user_state_cur, liabilities_state_cur] which are both 0 at state 0 + let start_public_input = [F::::from(0), F::::from(0)]; + + println!("Creating a RecursiveSNARK..."); + let start = Instant::now(); + let recursive_snark = create_recursive_circuit( + FileLocation::PathBuf(witness_generator_file.clone()), + r1cs.clone(), + private_inputs, + start_public_input.to_vec(), + &pp, + ) + .unwrap(); + println!("RecursiveSNARK creation took {:?}", start.elapsed()); + + // TODO: empty? + let z0_secondary = [F::::from(0)]; + + // verify the recursive SNARK + println!("Verifying a RecursiveSNARK..."); + let start = Instant::now(); + let res = recursive_snark.verify(&pp, iteration_count, &start_public_input, &z0_secondary); + println!( + "RecursiveSNARK::verify: {:?}, took {:?}", + res, + start.elapsed() + ); + assert!(res.is_ok()); + + let z_last = res.unwrap().0; + + // The user has to check the correctness of the liabilities after state 3 according to the Incremental Proof + // The user checks that this is equal to the liabilities state committed by the CEX at state 3 + println!( + "liabilities_state_cur at state 3 as output of the Incremental Proof {:?}", + z_last[1] + ); + println!( + "liabilities state committed by the CEX at state 3 {:?}", + liabilities_state_3 + ); + + // The user also has to check the correctness of the user state after state 3 according to the Incremental Proof + // The user checks that this is equal to the locally computed user_state_cur + let user_state_0 = Fr::from_str("0").unwrap(); + + let user_state_1 = build_user_state_cur( + user_state_0, + merkle_proof_1.username, + merkle_proof_1.user_balances, + ); + let user_state_2 = build_user_state_cur( + user_state_1, + merkle_proof_2.username, + merkle_proof_2.user_balances, + ); + let user_state_3 = build_user_state_cur( + user_state_2, + merkle_proof_3.username, + merkle_proof_3.user_balances, + ); + + println!( + "user_state_cur at state 3 as output of the Incremental Proof {:?}", + z_last[0] + ); + println!( + "user state computed locally by the user starting from their logs {:?}", + user_state_3 + ); + + // produce a compressed SNARK + println!("Generating a CompressedSNARK using Spartan with IPA-PC..."); + let start = Instant::now(); + let (pk, vk) = CompressedSNARK::<_, _, _, _, S, S>::setup(&pp).unwrap(); + let res = CompressedSNARK::<_, _, _, _, S, S>::prove(&pp, &pk, &recursive_snark); + println!( + "CompressedSNARK::prove: {:?}, took {:?}", + res.is_ok(), + start.elapsed() + ); + assert!(res.is_ok()); + let compressed_snark = res.unwrap(); + + // verify the compressed SNARK + println!("Verifying a CompressedSNARK..."); + let start = Instant::now(); + let res = compressed_snark.verify( + &vk, + iteration_count, + start_public_input.to_vec(), + z0_secondary.to_vec(), + ); + println!( + "CompressedSNARK::verify: {:?}, took {:?}", + res.is_ok(), + start.elapsed() + ); + assert!(res.is_ok()); +} + +fn main() { + let circuit_filepath = "examples/build/incremental_mst_inclusion.r1cs".to_string(); + let witness_gen_filepath = + "examples/build/incremental_mst_inclusion_js/incremental_mst_inclusion.wasm".to_string(); + run_test(circuit_filepath.clone(), witness_gen_filepath); +} + +use num_traits::{FromPrimitive, Num}; +use poseidon_rs::{Fr, Poseidon}; + +// Note that we cannot reuse the MerkleSumTree implementation from zk_prover because it is not compatible with circom's Poseidon Hasher +#[derive(Clone, Debug)] +struct Node { + hash: Fr, + balance: [Fr; N_ASSETS], +} + +#[derive(Clone, Debug)] +struct MerkleProof { + username: String, + user_balances: Vec, + path_element_hashes: Vec, + path_element_balances: Vec>, + path_indices: Vec, + root: Node, +} + +impl Node { + /// Constructs a new Node given left and right child hashes. + fn new(left: &Node, right: &Node, hasher: &Poseidon) -> Node { + let mut input = vec![left.hash]; + input.extend(left.balance); + input.push(right.hash); + input.extend(right.balance); + + let mut balance = vec![]; + + // iterate over N_ASSETS + for i in 0..N_ASSETS { + let mut sum = Fr::from_str("0").unwrap(); + sum.add_assign(&left.balance[i]); + sum.add_assign(&right.balance[i]); + + balance.push(sum); + } + + Node { + hash: hasher.hash(input).unwrap(), + balance: balance.try_into().unwrap(), + } + } +} + +/// Generates a Merkle proof of inclusion for a leaf at a given index +fn build_merkle_proof(csv_filepath: String, user_index: usize) -> Option> { + let file = File::open(csv_filepath).expect("Unable to open file"); + let reader = BufReader::new(file); + + let mut leaves = vec![]; + + let hasher = Poseidon::new(); + + let mut captured_username = String::new(); + let mut captured_user_balances = vec![]; + + for (idx, line) in reader.lines().skip(1).enumerate() { + // skipping header + let line = line.expect("Unable to read line"); + let data: Vec<&str> = line.split(';').collect(); + + if data.len() != 2 { + continue; // Invalid line format + } + + let username = big_intify_username(data[0]).to_string(); + + // convert balances to Fr + let balances: Vec = data[1] + .split(',') + .map(|balance_str| Fr::from_str(balance_str).unwrap()) + .collect(); + + assert_eq!(balances.len(), N_ASSETS); + + // capture user's data if the index matches + if idx == user_index { + captured_username = username.to_string(); + captured_user_balances = data[1].split(',').map(|s| s.to_string()).collect(); + } + + let username = Fr::from_str(&username).unwrap(); + + // create a vector input that takes the username and the balances + let mut input = vec![username]; + input.extend(balances.clone()); + + let hash = hasher.hash(input).unwrap(); + + leaves.push(Node { + hash, + balance: balances.try_into().unwrap(), + }); + } + + let mut current_level = leaves.clone(); + + let mut path_element_hashes = vec![]; + let mut path_element_balances = vec![]; + let mut path_indices = vec![]; + + while current_level.len() > 1 { + let mut next_level = vec![]; + + for i in (0..current_level.len()).step_by(2) { + let left = ¤t_level[i]; + let right = if i + 1 < current_level.len() { + ¤t_level[i + 1] + } else { + ¤t_level[i] + }; + + if user_index == i { + path_element_hashes.push(fr_to_string(right.hash).unwrap()); + path_element_balances.push( + right + .balance + .iter() + .map(|fr| fr_to_string(*fr).unwrap()) + .collect(), + ); + path_indices.push("0".to_string()); // 0 means that the right element is the path element + } else if user_index == i + 1 { + path_element_hashes.push(fr_to_string(left.hash).unwrap()); + path_element_balances.push( + left.balance + .iter() + .map(|fr| fr_to_string(*fr).unwrap()) + .collect(), // 1 means that the left element is the path element + ); + path_indices.push("1".to_string()); + } + + let parent = Node::new(left, right, &hasher); + next_level.push(parent); + } + + current_level = next_level; + } + + // fetch the root + let root = current_level[0].clone(); + + Some(MerkleProof { + username: captured_username, + user_balances: captured_user_balances, + path_element_hashes, + path_element_balances, + path_indices, + root, + }) +} + +/// The current liabilities state is obtained by hashing the previous liabilities state and the root hash of the current liabilities tree +fn build_liabilities_state_cur(liabilities_state_prev: Fr, root_hash: Fr) -> Fr { + let hasher = Poseidon::new(); + + let mut input = vec![liabilities_state_prev]; + input.push(root_hash); + + hasher.hash(input).unwrap() +} + +/// The current user state is obtained by hashing the previous user state and the user leaf hash of the current liabilities tree +fn build_user_state_cur(user_state_prev: Fr, username: String, user_balances: Vec) -> Fr { + let hasher = Poseidon::new(); + + let leaf_hash = { + let mut input = vec![Fr::from_str(&username).unwrap()]; + input.extend( + user_balances + .iter() + .map(|balance_str| Fr::from_str(balance_str).unwrap()), + ); + + hasher.hash(input).unwrap() + }; + + let mut input = vec![user_state_prev]; + input.push(leaf_hash); + + hasher.hash(input).unwrap() +} + +/// Converts a Fr to a its decimal string representation +fn fr_to_string(v: Fr) -> Option { + // Convert v to string + let s = v.to_string(); + + // Extract the hexadecimal portion from the string. + // The pattern "Fr(" and ")" should surround the hexadecimal. + if let Some(hex_start) = s.find("Fr(0x") { + let hex_end = s.rfind(')')?; + let hex_str = &s[hex_start + 5..hex_end]; + + // Convert the hexadecimal to a decimal string. + let decimal_str = BigUint::from_str_radix(hex_str, 16) + .ok() + .map(|bigint| bigint.to_str_radix(10)) + .unwrap(); + + return Some(decimal_str); + } + None +} diff --git a/zk_prover/examples/states/entry_16_1.csv b/zk_prover/examples/states/entry_16_1.csv new file mode 100644 index 00000000..11b3f4e7 --- /dev/null +++ b/zk_prover/examples/states/entry_16_1.csv @@ -0,0 +1,17 @@ +username;balances +dxGaEAii;11888,41163 +MBlfbBGI;67823,18651 +lAhWlEWZ;18651,2087 +nuZweYtO;22073,55683 +gbdSwiuY;34897,83296 +RZNneNuP;83296,16881 +YsscHXkp;31699,35479 +RkLzkDun;2087,79731 +HlQlnEYI;30605,11888 +RqkZOFYe;16881,14874 +NjCSRAfD;41163,67823 +pHniJMQY;14874,22073 +dOGIMzKR;10032,10032 +HfMDmNLp;55683,34897 +xPLKzCBl;79731,30605 +AtwIxZHo;35479,31699 \ No newline at end of file diff --git a/zk_prover/examples/states/entry_16_2.csv b/zk_prover/examples/states/entry_16_2.csv new file mode 100644 index 00000000..857a8a85 --- /dev/null +++ b/zk_prover/examples/states/entry_16_2.csv @@ -0,0 +1,17 @@ +username;balances +dxGaEAii;10888,40163 +MBlfbBGI;68823,19651 +lAhWlEWZ;18651,2087 +nuZweYtO;22073,55683 +gbdSwiuY;34897,83296 +RZNneNuP;83296,16881 +YsscHXkp;31699,35479 +RkLzkDun;2087,79731 +HlQlnEYI;30605,11888 +RqkZOFYe;16881,14874 +NjCSRAfD;41163,67823 +pHniJMQY;14874,22073 +dOGIMzKR;10032,10032 +HfMDmNLp;55683,34897 +xPLKzCBl;79731,30605 +AtwIxZHo;35479,31699 diff --git a/zk_prover/examples/states/entry_16_3.csv b/zk_prover/examples/states/entry_16_3.csv new file mode 100644 index 00000000..557fd9e2 --- /dev/null +++ b/zk_prover/examples/states/entry_16_3.csv @@ -0,0 +1,17 @@ +username;balances +dxGaEAii;8888,40163 +MBlfbBGI;68823,19651 +lAhWlEWZ;20651,2087 +nuZweYtO;22073,55683 +gbdSwiuY;34897,83296 +RZNneNuP;83296,16881 +YsscHXkp;31699,35479 +RkLzkDun;2087,79731 +HlQlnEYI;30605,11888 +RqkZOFYe;16881,14874 +NjCSRAfD;41163,67823 +pHniJMQY;14874,22073 +dOGIMzKR;10032,10032 +HfMDmNLp;55683,34897 +xPLKzCBl;79731,30605 +AtwIxZHo;35479,31699 diff --git a/zk_prover/examples/states/entry_16_4.csv b/zk_prover/examples/states/entry_16_4.csv new file mode 100644 index 00000000..f2b1d8e3 --- /dev/null +++ b/zk_prover/examples/states/entry_16_4.csv @@ -0,0 +1,17 @@ +username;balances +dxGaEAii;10888,41163 +MBlfbBGI;68823,19651 +lAhWlEWZ;18651,2087 +nuZweYtO;22073,54683 +gbdSwiuY;34897,83296 +RZNneNuP;83296,16881 +YsscHXkp;31699,35479 +RkLzkDun;2087,79731 +HlQlnEYI;30605,11888 +RqkZOFYe;16881,14874 +NjCSRAfD;41163,67823 +pHniJMQY;14874,22073 +dOGIMzKR;10032,10032 +HfMDmNLp;55683,34897 +xPLKzCBl;79731,30605 +AtwIxZHo;35479,31699 diff --git a/zk_prover/examples/states/entry_16_5.csv b/zk_prover/examples/states/entry_16_5.csv new file mode 100644 index 00000000..55079c61 --- /dev/null +++ b/zk_prover/examples/states/entry_16_5.csv @@ -0,0 +1,17 @@ +username;balances +dxGaEAii;15888,41163 +MBlfbBGI;68823,19651 +lAhWlEWZ;18651,2087 +nuZweYtO;22073,54683 +gbdSwiuY;34897,83296 +RZNneNuP;83296,16881 +YsscHXkp;31699,35479 +RkLzkDun;2087,79731 +HlQlnEYI;30605,11888 +RqkZOFYe;16881,14874 +NjCSRAfD;41163,67823 +pHniJMQY;14874,22073 +dOGIMzKR;10032,10032 +HfMDmNLp;50683,34897 +xPLKzCBl;79731,30605 +AtwIxZHo;35479,31699 diff --git a/zk_prover/src/circom/circomlib/circuits/aliascheck.circom b/zk_prover/src/circom/circomlib/circuits/aliascheck.circom new file mode 100644 index 00000000..1c5a5f87 --- /dev/null +++ b/zk_prover/src/circom/circomlib/circuits/aliascheck.circom @@ -0,0 +1,33 @@ +/* + Copyright 2018 0KIMS association. + + This file is part of circom (Zero Knowledge Circuit Compiler). + + circom is a free software: you can redistribute it and/or modify it + under the terms of the GNU General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + circom is distributed in the hope that it will be useful, but WITHOUT + ANY WARRANTY; without even the implied warranty of MERCHANTABILITY + or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public + License for more details. + + You should have received a copy of the GNU General Public License + along with circom. If not, see . +*/ +pragma circom 2.0.0; + +include "compconstant.circom"; + + +template AliasCheck() { + + signal input in[254]; + + component compConstant = CompConstant(-1); + + for (var i=0; i<254; i++) in[i] ==> compConstant.in[i]; + + compConstant.out === 0; +} diff --git a/zk_prover/src/circom/circomlib/circuits/binsum.circom b/zk_prover/src/circom/circomlib/circuits/binsum.circom new file mode 100644 index 00000000..28c7fcce --- /dev/null +++ b/zk_prover/src/circom/circomlib/circuits/binsum.circom @@ -0,0 +1,101 @@ +/* + Copyright 2018 0KIMS association. + + This file is part of circom (Zero Knowledge Circuit Compiler). + + circom is a free software: you can redistribute it and/or modify it + under the terms of the GNU General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + circom is distributed in the hope that it will be useful, but WITHOUT + ANY WARRANTY; without even the implied warranty of MERCHANTABILITY + or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public + License for more details. + + You should have received a copy of the GNU General Public License + along with circom. If not, see . +*/ + +/* + +Binary Sum +========== + +This component creates a binary sum componet of ops operands and n bits each operand. + +e is Number of carries: Depends on the number of operands in the input. + +Main Constraint: + in[0][0] * 2^0 + in[0][1] * 2^1 + ..... + in[0][n-1] * 2^(n-1) + + + in[1][0] * 2^0 + in[1][1] * 2^1 + ..... + in[1][n-1] * 2^(n-1) + + + .. + + in[ops-1][0] * 2^0 + in[ops-1][1] * 2^1 + ..... + in[ops-1][n-1] * 2^(n-1) + + === + out[0] * 2^0 + out[1] * 2^1 + + out[n+e-1] *2(n+e-1) + +To waranty binary outputs: + + out[0] * (out[0] - 1) === 0 + out[1] * (out[0] - 1) === 0 + . + . + . + out[n+e-1] * (out[n+e-1] - 1) == 0 + + */ + + +/* + This function calculates the number of extra bits in the output to do the full sum. + */ + pragma circom 2.0.0; + +function nbits(a) { + var n = 1; + var r = 0; + while (n-1> k) & 1; + + // Ensure out is binary + out[k] * (out[k] - 1) === 0; + + lout += out[k] * e2; + + e2 = e2+e2; + } + + // Ensure the sum; + + lin === lout; +} diff --git a/zk_prover/src/circom/circomlib/circuits/bitify.circom b/zk_prover/src/circom/circomlib/circuits/bitify.circom new file mode 100644 index 00000000..bfdd4e82 --- /dev/null +++ b/zk_prover/src/circom/circomlib/circuits/bitify.circom @@ -0,0 +1,106 @@ +/* + Copyright 2018 0KIMS association. + + This file is part of circom (Zero Knowledge Circuit Compiler). + + circom is a free software: you can redistribute it and/or modify it + under the terms of the GNU General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + circom is distributed in the hope that it will be useful, but WITHOUT + ANY WARRANTY; without even the implied warranty of MERCHANTABILITY + or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public + License for more details. + + You should have received a copy of the GNU General Public License + along with circom. If not, see . +*/ +pragma circom 2.0.0; + +include "comparators.circom"; +include "aliascheck.circom"; + + +template Num2Bits(n) { + signal input in; + signal output out[n]; + var lc1=0; + + var e2=1; + for (var i = 0; i> i) & 1; + out[i] * (out[i] -1 ) === 0; + lc1 += out[i] * e2; + e2 = e2+e2; + } + + lc1 === in; +} + +template Num2Bits_strict() { + signal input in; + signal output out[254]; + + component aliasCheck = AliasCheck(); + component n2b = Num2Bits(254); + in ==> n2b.in; + + for (var i=0; i<254; i++) { + n2b.out[i] ==> out[i]; + n2b.out[i] ==> aliasCheck.in[i]; + } +} + +template Bits2Num(n) { + signal input in[n]; + signal output out; + var lc1=0; + + var e2 = 1; + for (var i = 0; i out; +} + +template Bits2Num_strict() { + signal input in[254]; + signal output out; + + component aliasCheck = AliasCheck(); + component b2n = Bits2Num(254); + + for (var i=0; i<254; i++) { + in[i] ==> b2n.in[i]; + in[i] ==> aliasCheck.in[i]; + } + + b2n.out ==> out; +} + +template Num2BitsNeg(n) { + signal input in; + signal output out[n]; + var lc1=0; + + component isZero; + + isZero = IsZero(); + + var neg = n == 0 ? 0 : 2**n - in; + + for (var i = 0; i> i) & 1; + out[i] * (out[i] -1 ) === 0; + lc1 += out[i] * 2**i; + } + + in ==> isZero.in; + + + + lc1 + isZero.out * 2**n === 2**n - in; +} diff --git a/zk_prover/src/circom/circomlib/circuits/comparators.circom b/zk_prover/src/circom/circomlib/circuits/comparators.circom new file mode 100644 index 00000000..bfed0320 --- /dev/null +++ b/zk_prover/src/circom/circomlib/circuits/comparators.circom @@ -0,0 +1,141 @@ +/* + Copyright 2018 0KIMS association. + + This file is part of circom (Zero Knowledge Circuit Compiler). + + circom is a free software: you can redistribute it and/or modify it + under the terms of the GNU General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + circom is distributed in the hope that it will be useful, but WITHOUT + ANY WARRANTY; without even the implied warranty of MERCHANTABILITY + or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public + License for more details. + + You should have received a copy of the GNU General Public License + along with circom. If not, see . +*/ +pragma circom 2.0.0; + +include "bitify.circom"; +include "binsum.circom"; + +template IsZero() { + signal input in; + signal output out; + + signal inv; + + inv <-- in!=0 ? 1/in : 0; + + out <== -in*inv +1; + in*out === 0; +} + + +template IsEqual() { + signal input in[2]; + signal output out; + + component isz = IsZero(); + + in[1] - in[0] ==> isz.in; + + isz.out ==> out; +} + +template ForceEqualIfEnabled() { + signal input enabled; + signal input in[2]; + + component isz = IsZero(); + + in[1] - in[0] ==> isz.in; + + (1 - isz.out)*enabled === 0; +} + +/* +// N is the number of bits the input have. +// The MSF is the sign bit. +template LessThan(n) { + signal input in[2]; + signal output out; + + component num2Bits0; + component num2Bits1; + + component adder; + + adder = BinSum(n, 2); + + num2Bits0 = Num2Bits(n); + num2Bits1 = Num2BitsNeg(n); + + in[0] ==> num2Bits0.in; + in[1] ==> num2Bits1.in; + + var i; + for (i=0;i adder.in[0][i]; + num2Bits1.out[i] ==> adder.in[1][i]; + } + + adder.out[n-1] ==> out; +} +*/ + +template LessThan(n) { + assert(n <= 252); + signal input in[2]; + signal output out; + + component n2b = Num2Bits(n+1); + + n2b.in <== in[0]+ (1< out; +} + +// N is the number of bits the input have. +// The MSF is the sign bit. +template GreaterThan(n) { + signal input in[2]; + signal output out; + + component lt = LessThan(n); + + lt.in[0] <== in[1]; + lt.in[1] <== in[0]; + lt.out ==> out; +} + +// N is the number of bits the input have. +// The MSF is the sign bit. +template GreaterEqThan(n) { + signal input in[2]; + signal output out; + + component lt = LessThan(n); + + lt.in[0] <== in[1]; + lt.in[1] <== in[0]+1; + lt.out ==> out; +} + diff --git a/zk_prover/src/circom/circomlib/circuits/compconstant.circom b/zk_prover/src/circom/circomlib/circuits/compconstant.circom new file mode 100644 index 00000000..1bca83a5 --- /dev/null +++ b/zk_prover/src/circom/circomlib/circuits/compconstant.circom @@ -0,0 +1,74 @@ +/* + Copyright 2018 0KIMS association. + + This file is part of circom (Zero Knowledge Circuit Compiler). + + circom is a free software: you can redistribute it and/or modify it + under the terms of the GNU General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + circom is distributed in the hope that it will be useful, but WITHOUT + ANY WARRANTY; without even the implied warranty of MERCHANTABILITY + or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public + License for more details. + + You should have received a copy of the GNU General Public License + along with circom. If not, see . +*/ +pragma circom 2.0.0; + +include "bitify.circom"; + +// Returns 1 if in (in binary) > ct + +template CompConstant(ct) { + signal input in[254]; + signal output out; + + signal parts[127]; + signal sout; + + var clsb; + var cmsb; + var slsb; + var smsb; + + var sum=0; + + var b = (1 << 128) -1; + var a = 1; + var e = 1; + var i; + + for (i=0;i<127; i++) { + clsb = (ct >> (i*2)) & 1; + cmsb = (ct >> (i*2+1)) & 1; + slsb = in[i*2]; + smsb = in[i*2+1]; + + if ((cmsb==0)&&(clsb==0)) { + parts[i] <== -b*smsb*slsb + b*smsb + b*slsb; + } else if ((cmsb==0)&&(clsb==1)) { + parts[i] <== a*smsb*slsb - a*slsb + b*smsb - a*smsb + a; + } else if ((cmsb==1)&&(clsb==0)) { + parts[i] <== b*smsb*slsb - a*smsb + a; + } else { + parts[i] <== -a*smsb*slsb + a; + } + + sum = sum + parts[i]; + + b = b -e; + a = a +e; + e = e*2; + } + + sout <== sum; + + component num2bits = Num2Bits(135); + + num2bits.in <== sout; + + out <== num2bits.out[127]; +} diff --git a/zk_prover/src/circom/circomlib/circuits/mux1.circom b/zk_prover/src/circom/circomlib/circuits/mux1.circom new file mode 100644 index 00000000..444cb849 --- /dev/null +++ b/zk_prover/src/circom/circomlib/circuits/mux1.circom @@ -0,0 +1,48 @@ +/* + Copyright 2018 0KIMS association. + + This file is part of circom (Zero Knowledge Circuit Compiler). + + circom is a free software: you can redistribute it and/or modify it + under the terms of the GNU General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + circom is distributed in the hope that it will be useful, but WITHOUT + ANY WARRANTY; without even the implied warranty of MERCHANTABILITY + or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public + License for more details. + + You should have received a copy of the GNU General Public License + along with circom. If not, see . +*/ +pragma circom 2.0.0; + +template MultiMux1(n) { + signal input c[n][2]; // Constants + signal input s; // Selector + signal output out[n]; + + for (var i=0; i mux.s; + + mux.out[0] ==> out; +} diff --git a/zk_prover/src/circom/circomlib/circuits/poseidon.circom b/zk_prover/src/circom/circomlib/circuits/poseidon.circom new file mode 100644 index 00000000..1c45ab95 --- /dev/null +++ b/zk_prover/src/circom/circomlib/circuits/poseidon.circom @@ -0,0 +1,208 @@ +pragma circom 2.0.0; + +include "./poseidon_constants.circom"; + +template Sigma() { + signal input in; + signal output out; + + signal in2; + signal in4; + + in2 <== in*in; + in4 <== in2*in2; + + out <== in4*in; +} + +template Ark(t, C, r) { + signal input in[t]; + signal output out[t]; + + for (var i=0; i0) { + ark[0].in[j] <== inputs[j-1]; + } else { + ark[0].in[j] <== initialState; + } + } + + for (var r = 0; r < nRoundsF\2-1; r++) { + for (var j=0; j