diff --git a/Cargo.lock b/Cargo.lock index 7367eee..0206922 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -40,13 +40,14 @@ dependencies = [ [[package]] name = "ahash" -version = "0.8.3" +version = "0.8.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2c99f64d1e06488f620f932677e24bc6e2897582980441ae90a671415bd7ec2f" +checksum = "91429305e9f0a25f6205c5b8e0d2db09e0708a7a6df0f42212bb56c32c8ac97a" dependencies = [ "cfg-if", "once_cell", "version_check", + "zerocopy", ] [[package]] @@ -186,6 +187,110 @@ version = "1.0.75" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "a4668cab20f66d8d020e1fbc0ebe47217433c1b6c8f2040faf858554e394ace6" +[[package]] +name = "ark-ff" +version = "0.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6b3235cc41ee7a12aaaf2c575a2ad7b46713a8a50bda2fc3b003a04845c05dd6" +dependencies = [ + "ark-ff-asm 0.3.0", + "ark-ff-macros 0.3.0", + "ark-serialize 0.3.0", + "ark-std 0.3.0", + "derivative", + "num-bigint", + "num-traits", + "paste", + "rustc_version 0.3.3", + "zeroize", +] + +[[package]] +name = "ark-ff" +version = "0.4.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ec847af850f44ad29048935519032c33da8aa03340876d351dfab5660d2966ba" +dependencies = [ + "ark-ff-asm 0.4.2", + "ark-ff-macros 0.4.2", + "ark-serialize 0.4.2", + "ark-std 0.4.0", + "derivative", + "digest 0.10.7", + "itertools 0.10.5", + "num-bigint", + "num-traits", + "paste", + "rustc_version 0.4.0", + "zeroize", +] + +[[package]] +name = "ark-ff-asm" +version = "0.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "db02d390bf6643fb404d3d22d31aee1c4bc4459600aef9113833d17e786c6e44" +dependencies = [ + "quote", + "syn 1.0.109", +] + +[[package]] +name = "ark-ff-asm" +version = "0.4.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3ed4aa4fe255d0bc6d79373f7e31d2ea147bcf486cba1be5ba7ea85abdb92348" +dependencies = [ + "quote", + "syn 1.0.109", +] + +[[package]] +name = "ark-ff-macros" +version = "0.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "db2fd794a08ccb318058009eefdf15bcaaaaf6f8161eb3345f907222bac38b20" +dependencies = [ + "num-bigint", + "num-traits", + "quote", + "syn 1.0.109", +] + +[[package]] +name = "ark-ff-macros" +version = "0.4.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7abe79b0e4288889c4574159ab790824d0033b9fdcb2a112a3182fac2e514565" +dependencies = [ + "num-bigint", + "num-traits", + "proc-macro2", + "quote", + "syn 1.0.109", +] + +[[package]] +name = "ark-serialize" +version = "0.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1d6c2b318ee6e10f8c2853e73a83adc0ccb88995aa978d8a3408d492ab2ee671" +dependencies = [ + "ark-std 0.3.0", + "digest 0.9.0", +] + +[[package]] +name = "ark-serialize" +version = "0.4.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "adb7b85a02b83d2f22f89bd5cac66c9c89474240cb6207cb1efc16d098e822a5" +dependencies = [ + "ark-std 0.4.0", + "digest 0.10.7", + "num-bigint", +] + [[package]] name = "ark-std" version = "0.3.0" @@ -197,6 +302,16 @@ dependencies = [ "rand", ] +[[package]] +name = "ark-std" +version = "0.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "94893f1e0c6eeab764ade8dc4c0db24caf4fe7cbbaafc0eba0a9030f447b5185" +dependencies = [ + "num-traits", + "rand", +] + [[package]] name = "array-init" version = "2.1.0" @@ -298,7 +413,7 @@ checksum = "b6d7b9decdf35d8908a7e3ef02f64c5e9b1695e230154c0e8de3969142d9b94c" dependencies = [ "futures", "pharos", - "rustc_version", + "rustc_version 0.4.0", ] [[package]] @@ -676,7 +791,7 @@ checksum = "e7daec1a2a2129eeba1644b220b4647ec537b0b5d4bfd6876fcc5a540056b592" dependencies = [ "camino", "cargo-platform", - "semver", + "semver 1.0.20", "serde", "serde_json", "thiserror", @@ -1212,6 +1327,17 @@ dependencies = [ "powerfmt", ] +[[package]] +name = "derivative" +version = "2.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "fcc3dd5e9e9c0b295d6e1e4d811fb6f157d5ffd784b8d202fc62eac8035a770b" +dependencies = [ + "proc-macro2", + "quote", + "syn 1.0.109", +] + [[package]] name = "derive_more" version = "0.99.17" @@ -1221,7 +1347,7 @@ dependencies = [ "convert_case", "proc-macro2", "quote", - "rustc_version", + "rustc_version 0.4.0", "syn 1.0.109", ] @@ -1641,7 +1767,7 @@ checksum = "0e53451ea4a8128fbce33966da71132cf9e1040dcfd2a2084fd7733ada7b2045" dependencies = [ "ethers-core", "reqwest", - "semver", + "semver 1.0.20", "serde", "serde_json", "thiserror", @@ -1750,7 +1876,7 @@ dependencies = [ "path-slash", "rayon", "regex", - "semver", + "semver 1.0.20", "serde", "serde_json", "solang-parser", @@ -1779,6 +1905,17 @@ version = "2.0.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "25cbce373ec4653f1a01a31e8a5e5ec0c622dc27ff9c4e6606eefef5cbbed4a5" +[[package]] +name = "fastrlp" +version = "0.3.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "139834ddba373bbdd213dffe02c8d110508dcf1726c2be27e8d1f7d7e1856418" +dependencies = [ + "arrayvec", + "auto_impl", + "bytes", +] + [[package]] name = "ff" version = "0.13.0" @@ -2079,57 +2216,36 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "eabb4a44450da02c90444cf74558da904edde8fb4e9035a9a6a4e15445af0bd7" [[package]] -name = "halo2-base" -version = "0.4.0" -source = "git+https://github.com/axiom-crypto/halo2-lib.git?branch=community-edition#980b39bcca5b3327aaef6c8d73577d9381bfa899" +name = "halo2-axiom" +version = "0.4.1" +source = "git+https://github.com/axiom-crypto/halo2.git#f335ffc4440620e3afaa5ba3373764b60a528c51" dependencies = [ - "ark-std", - "getset", - "halo2_proofs 0.2.0 (git+https://github.com/privacy-scaling-explorations/halo2.git?rev=7a21656)", - "halo2_proofs 0.2.0 (git+https://github.com/axiom-crypto/halo2.git)", + "blake2b_simd", + "crossbeam", + "ff", + "group", + "halo2curves-axiom", "itertools 0.11.0", - "log", - "num-bigint", - "num-integer", - "num-traits", - "poseidon-rs", + "maybe-rayon", + "pairing", "rand", - "rand_chacha", - "rayon", - "rustc-hash", - "serde", - "serde_json", -] - -[[package]] -name = "halo2-base" -version = "0.4.0" -source = "git+https://github.com/axiom-crypto/halo2-lib.git?branch=develop#ff0cadf7b38d2fd5e9a57781641789ac71516227" -dependencies = [ - "getset", - "halo2_proofs 0.2.0 (git+https://github.com/axiom-crypto/halo2.git)", - "itertools 0.11.0", - "log", - "num-bigint", - "num-integer", - "num-traits", - "poseidon-rs", - "rand_chacha", - "rayon", + "rand_core", "rustc-hash", - "serde", - "serde_json", + "sha3 0.10.8", + "tracing", ] [[package]] name = "halo2-base" version = "0.4.0" -source = "git+https://github.com/axiom-crypto/halo2-lib.git?branch=feat/zkevm-sha256#fd90273b5f948bc9e1d5ea7ff08a49126221041e" +source = "git+https://github.com/MynaWallet/halo2-lib.git?branch=sha256#6f924e7b8a9fad7d84a6238c1f0095cb337ce4c5" dependencies = [ - "ark-std", + "ark-std 0.3.0", "getset", - "halo2_proofs 0.2.0 (git+https://github.com/axiom-crypto/halo2.git)", + "halo2-axiom", + "halo2_proofs", "itertools 0.11.0", + "jemallocator", "log", "num-bigint", "num-integer", @@ -2147,19 +2263,22 @@ dependencies = [ name = "halo2-circuits" version = "0.1.0" dependencies = [ + "bincode", "clap 4.2.1", "console_error_panic_hook", "criterion", "env_logger", "getrandom", "getset", - "halo2-base 0.4.0 (git+https://github.com/axiom-crypto/halo2-lib.git?branch=community-edition)", + "halo2-base", + "halo2-ecc", "halo2-rsa", "halo2-sha256-unoptimized", "itertools 0.11.0", "num-bigint", "num-traits", "openssl", + "pse-poseidon", "rand", "rayon", "rsa", @@ -2175,28 +2294,9 @@ dependencies = [ [[package]] name = "halo2-ecc" version = "0.4.0" -source = "git+https://github.com/axiom-crypto/halo2-lib.git?branch=community-edition#980b39bcca5b3327aaef6c8d73577d9381bfa899" -dependencies = [ - "halo2-base 0.4.0 (git+https://github.com/axiom-crypto/halo2-lib.git?branch=community-edition)", - "itertools 0.10.5", - "num-bigint", - "num-integer", - "num-traits", - "rand", - "rand_chacha", - "rand_core", - "rayon", - "serde", - "serde_json", - "test-case", -] - -[[package]] -name = "halo2-ecc" -version = "0.4.0" -source = "git+https://github.com/axiom-crypto/halo2-lib.git?branch=develop#ff0cadf7b38d2fd5e9a57781641789ac71516227" +source = "git+https://github.com/MynaWallet/halo2-lib.git?branch=sha256#6f924e7b8a9fad7d84a6238c1f0095cb337ce4c5" dependencies = [ - "halo2-base 0.4.0 (git+https://github.com/axiom-crypto/halo2-lib.git?branch=develop)", + "halo2-base", "itertools 0.10.5", "num-bigint", "num-integer", @@ -2213,11 +2313,11 @@ dependencies = [ [[package]] name = "halo2-rsa" version = "0.1.0" -source = "git+https://github.com/MynaWallet/halo2-rsa.git?branch=main#231d5421011276dfb7d6a6f84144a2dea9c9e3fe" +source = "git+https://github.com/MynaWallet/halo2-rsa.git#7a2a439d76f4c5bffad34a203ab8504428e098f0" dependencies = [ "env_logger", - "halo2-base 0.4.0 (git+https://github.com/axiom-crypto/halo2-lib.git?branch=community-edition)", - "halo2-ecc 0.4.0 (git+https://github.com/axiom-crypto/halo2-lib.git?branch=community-edition)", + "halo2-base", + "halo2-ecc", "num-bigint", "num-traits", "rand", @@ -2228,13 +2328,13 @@ dependencies = [ [[package]] name = "halo2-sha256-unoptimized" version = "0.1.0" -source = "git+https://github.com/zkpdf/halo2-sha256-unoptimized.git?branch=main#ec2d2b28cdb7dd38cb9896b09720d09923fcc2f2" +source = "git+https://github.com/MynaWallet/halo2-sha256-unoptimized.git#6cc3f01cbd25d10d6ada64f9710b7e109041cda2" dependencies = [ "console_error_panic_hook", "env_logger", "generic-array", "getrandom", - "halo2-base 0.4.0 (git+https://github.com/axiom-crypto/halo2-lib.git?branch=community-edition)", + "halo2-base", "hex", "itertools 0.10.5", "num-bigint", @@ -2254,7 +2354,7 @@ dependencies = [ "blake2b_simd", "ff", "group", - "halo2curves 0.1.0", + "halo2curves", "maybe-rayon", "rand_chacha", "rand_core", @@ -2262,25 +2362,6 @@ dependencies = [ "tracing", ] -[[package]] -name = "halo2_proofs" -version = "0.2.0" -source = "git+https://github.com/axiom-crypto/halo2.git#4b42325623c9cfea02441ce0cffa17ebf962b3bb" -dependencies = [ - "blake2b_simd", - "crossbeam", - "ff", - "group", - "halo2curves 0.4.0", - "maybe-rayon", - "pairing", - "rand", - "rand_core", - "rustc-hash", - "sha3 0.10.8", - "tracing", -] - [[package]] name = "halo2curves" version = "0.1.0" @@ -2302,9 +2383,10 @@ dependencies = [ ] [[package]] -name = "halo2curves" -version = "0.4.0" -source = "git+https://github.com/axiom-crypto/halo2curves.git?branch=main#e185711b6ba8f3e22f2af8bf24a5fc84b781ca46" +name = "halo2curves-axiom" +version = "0.4.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4d82f25182a221a5c79ce8d41d1dd3910f10626d7e9d0f9f9e9336e2545b7d1f" dependencies = [ "blake2b_simd", "ff", @@ -2671,6 +2753,26 @@ version = "1.0.9" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "af150ab688ff2122fcef229be89cb50dd66af9e01a4ff320cc137eecc9bacc38" +[[package]] +name = "jemalloc-sys" +version = "0.5.4+5.3.0-patched" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ac6c1946e1cea1788cbfde01c993b52a10e2da07f4bac608228d1bed20bfebf2" +dependencies = [ + "cc", + "libc", +] + +[[package]] +name = "jemallocator" +version = "0.5.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a0de374a9f8e63150e6f5e8a60cc14c668226d7a347d8aee1a45766e3c4dd3bc" +dependencies = [ + "jemalloc-sys", + "libc", +] + [[package]] name = "jobserver" version = "0.1.27" @@ -3349,6 +3451,17 @@ version = "2.3.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "9b2a4787296e9989611394c33f193f676704af1686e70b8f8033ab5ba9a35a94" +[[package]] +name = "pest" +version = "2.7.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ae9cee2a55a544be8b89dc6848072af97a20f2422603c10865be2a42b580fff5" +dependencies = [ + "memchr", + "thiserror", + "ucd-trie", +] + [[package]] name = "petgraph" version = "0.6.4" @@ -3366,7 +3479,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "e9567389417feee6ce15dd6527a8a1ecac205ef62c2932bcf3d9f6fc5b78b414" dependencies = [ "futures", - "rustc_version", + "rustc_version 0.4.0", ] [[package]] @@ -3624,13 +3737,24 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "7c003ac8c77cb07bb74f5f198bce836a689bcd5a42574612bf14d17bfd08c20e" dependencies = [ "bitflags 2.4.1", + "lazy_static", "num-traits", "rand", "rand_chacha", "rand_xorshift", + "regex-syntax 0.7.5", "unarray", ] +[[package]] +name = "pse-poseidon" +version = "0.2.0" +source = "git+https://github.com/axiom-crypto/pse-poseidon.git#19d3b09481bda0e95e7c005906365d070fceb752" +dependencies = [ + "halo2curves-axiom", + "subtle", +] + [[package]] name = "quote" version = "1.0.33" @@ -3972,8 +4096,16 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "95294d6e3a6192f3aabf91c38f56505a625aa495533442744185a36d75a790c4" dependencies = [ "alloy-rlp", + "ark-ff 0.3.0", + "ark-ff 0.4.2", + "bytes", + "fastrlp", + "num-bigint", + "parity-scale-codec", + "primitive-types", "proptest", "rand", + "rlp", "ruint-macro", "serde", "valuable", @@ -4039,13 +4171,22 @@ version = "2.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "3e75f6a532d0fd9f7f13144f392b6ad56a32696bfcd9c78f797f16bbb6f072d6" +[[package]] +name = "rustc_version" +version = "0.3.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f0dfe2087c51c460008730de8b57e6a320782fbfb312e1f4d520e6c6fae155ee" +dependencies = [ + "semver 0.11.0", +] + [[package]] name = "rustc_version" version = "0.4.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "bfa0f585226d2e68097d4f95d113b15b83a82e819ab25717ec0590d9584ef366" dependencies = [ - "semver", + "semver 1.0.20", ] [[package]] @@ -4215,6 +4356,15 @@ dependencies = [ "cc", ] +[[package]] +name = "semver" +version = "0.11.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f301af10236f6df4160f7c3f04eec6dbc70ace82d23326abad5edee88801c6b6" +dependencies = [ + "semver-parser", +] + [[package]] name = "semver" version = "1.0.20" @@ -4224,6 +4374,15 @@ dependencies = [ "serde", ] +[[package]] +name = "semver-parser" +version = "0.10.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "00b0bef5b7f9e0df16536d3961cfb6e84331c065b4066afb39768d0e319411f7" +dependencies = [ + "pest", +] + [[package]] name = "send_wrapper" version = "0.4.0" @@ -4439,10 +4598,10 @@ dependencies = [ [[package]] name = "snark-verifier" version = "0.1.6" -source = "git+https://github.com/axiom-crypto/snark-verifier.git?branch=community-edition#7011e8ce0c2f7e79ab9629aa528cfb6837cdeafe" +source = "git+https://github.com/MynaWallet/snark-verifier.git?branch=release-0.1.6-rc0#fe8d0005c6146a03cc1c01cffc1f955ff73ba639" dependencies = [ - "halo2-base 0.4.0 (git+https://github.com/axiom-crypto/halo2-lib.git?branch=community-edition)", - "halo2-ecc 0.4.0 (git+https://github.com/axiom-crypto/halo2-lib.git?branch=community-edition)", + "halo2-base", + "halo2-ecc", "hex", "itertools 0.11.0", "lazy_static", @@ -4452,40 +4611,23 @@ dependencies = [ "pairing", "rand", "revm", + "ruint", "serde", "sha3 0.10.8", ] -[[package]] -name = "snark-verifier" -version = "0.1.7" -source = "git+https://github.com/axiom-crypto/snark-verifier.git?branch=develop#624b003c656e44b14202d4b8a16a2f7bc4e71eeb" -dependencies = [ - "halo2-base 0.4.0 (git+https://github.com/axiom-crypto/halo2-lib.git?branch=develop)", - "halo2-ecc 0.4.0 (git+https://github.com/axiom-crypto/halo2-lib.git?branch=develop)", - "hex", - "itertools 0.11.0", - "lazy_static", - "num-bigint", - "num-integer", - "num-traits", - "pairing", - "rand", - "serde", -] - [[package]] name = "snark-verifier-sdk" version = "0.1.6" -source = "git+https://github.com/axiom-crypto/snark-verifier.git?branch=community-edition#7011e8ce0c2f7e79ab9629aa528cfb6837cdeafe" +source = "git+https://github.com/MynaWallet/snark-verifier.git?branch=release-0.1.6-rc0#fe8d0005c6146a03cc1c01cffc1f955ff73ba639" dependencies = [ - "ark-std", + "ark-std 0.3.0", "bincode", "ethereum-types", "getset", - "halo2-base 0.4.0 (git+https://github.com/axiom-crypto/halo2-lib.git?branch=community-edition)", + "halo2-base", "hex", - "itertools 0.10.5", + "itertools 0.11.0", "lazy_static", "num-bigint", "num-integer", @@ -4494,7 +4636,7 @@ dependencies = [ "rand_chacha", "serde", "serde_json", - "snark-verifier 0.1.6", + "snark-verifier", ] [[package]] @@ -4634,7 +4776,7 @@ dependencies = [ "hex", "once_cell", "reqwest", - "semver", + "semver 1.0.20", "serde", "serde_json", "sha2", @@ -5156,6 +5298,12 @@ version = "1.17.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "42ff0bf0c66b8238c6f3b578df37d0b7848e55df8577b3f74f92a69acceeb825" +[[package]] +name = "ucd-trie" +version = "0.1.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ed646292ffc8188ef8ea4d1e0e0150fb15a5c2e12ad9b8fc191ae7a8a7f3c4b9" + [[package]] name = "uint" version = "0.9.5" @@ -5680,7 +5828,7 @@ dependencies = [ "js-sys", "log", "pharos", - "rustc_version", + "rustc_version 0.4.0", "send_wrapper 0.6.0", "thiserror", "wasm-bindgen", @@ -5721,6 +5869,26 @@ version = "0.5.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "09041cd90cf85f7f8b2df60c646f853b7f535ce68f85244eb6731cf89fa498ec" +[[package]] +name = "zerocopy" +version = "0.7.25" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8cd369a67c0edfef15010f980c3cbe45d7f651deac2cd67ce097cd801de16557" +dependencies = [ + "zerocopy-derive", +] + +[[package]] +name = "zerocopy-derive" +version = "0.7.25" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c2f140bda219a26ccc0cdb03dba58af72590c53b22642577d88a927bc5c87d6b" +dependencies = [ + "proc-macro2", + "quote", + "syn 2.0.38", +] + [[package]] name = "zeroize" version = "1.6.0" @@ -5764,12 +5932,12 @@ dependencies = [ [[package]] name = "zkevm-hashes" version = "0.2.0" -source = "git+https://github.com/axiom-crypto/halo2-lib.git?branch=feat/zkevm-sha256#fd90273b5f948bc9e1d5ea7ff08a49126221041e" +source = "git+https://github.com/MynaWallet/halo2-lib.git?branch=sha256#6f924e7b8a9fad7d84a6238c1f0095cb337ce4c5" dependencies = [ "array-init", "ethers-core", "getset", - "halo2-base 0.4.0 (git+https://github.com/axiom-crypto/halo2-lib.git?branch=feat/zkevm-sha256)", + "halo2-base", "itertools 0.11.0", "lazy_static", "log", @@ -5777,7 +5945,7 @@ dependencies = [ "rand", "rayon", "sha3 0.10.8", - "snark-verifier 0.1.7", + "snark-verifier", ] [[package]] diff --git a/packages/halo2-circuits/Cargo.lock b/packages/halo2-circuits/Cargo.lock index edb6a88..9087bde 100644 --- a/packages/halo2-circuits/Cargo.lock +++ b/packages/halo2-circuits/Cargo.lock @@ -19,13 +19,14 @@ checksum = "f26201604c87b1e01bd3d98f8d5d9a8fcbb815e8cedb41ffccbeb4bf593a35fe" [[package]] name = "ahash" -version = "0.8.3" +version = "0.8.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2c99f64d1e06488f620f932677e24bc6e2897582980441ae90a671415bd7ec2f" +checksum = "91429305e9f0a25f6205c5b8e0d2db09e0708a7a6df0f42212bb56c32c8ac97a" dependencies = [ "cfg-if", "once_cell", "version_check", + "zerocopy", ] [[package]] @@ -80,7 +81,7 @@ checksum = "c0391754c09fab4eae3404d19d0d297aa1c670c1775ab51d8a5312afeca23157" dependencies = [ "proc-macro2", "quote", - "syn 2.0.33", + "syn 2.0.39", ] [[package]] @@ -129,6 +130,110 @@ dependencies = [ "windows-sys 0.45.0", ] +[[package]] +name = "ark-ff" +version = "0.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6b3235cc41ee7a12aaaf2c575a2ad7b46713a8a50bda2fc3b003a04845c05dd6" +dependencies = [ + "ark-ff-asm 0.3.0", + "ark-ff-macros 0.3.0", + "ark-serialize 0.3.0", + "ark-std 0.3.0", + "derivative", + "num-bigint", + "num-traits", + "paste", + "rustc_version 0.3.3", + "zeroize", +] + +[[package]] +name = "ark-ff" +version = "0.4.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ec847af850f44ad29048935519032c33da8aa03340876d351dfab5660d2966ba" +dependencies = [ + "ark-ff-asm 0.4.2", + "ark-ff-macros 0.4.2", + "ark-serialize 0.4.2", + "ark-std 0.4.0", + "derivative", + "digest 0.10.7", + "itertools 0.10.5", + "num-bigint", + "num-traits", + "paste", + "rustc_version 0.4.0", + "zeroize", +] + +[[package]] +name = "ark-ff-asm" +version = "0.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "db02d390bf6643fb404d3d22d31aee1c4bc4459600aef9113833d17e786c6e44" +dependencies = [ + "quote", + "syn 1.0.109", +] + +[[package]] +name = "ark-ff-asm" +version = "0.4.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3ed4aa4fe255d0bc6d79373f7e31d2ea147bcf486cba1be5ba7ea85abdb92348" +dependencies = [ + "quote", + "syn 1.0.109", +] + +[[package]] +name = "ark-ff-macros" +version = "0.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "db2fd794a08ccb318058009eefdf15bcaaaaf6f8161eb3345f907222bac38b20" +dependencies = [ + "num-bigint", + "num-traits", + "quote", + "syn 1.0.109", +] + +[[package]] +name = "ark-ff-macros" +version = "0.4.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7abe79b0e4288889c4574159ab790824d0033b9fdcb2a112a3182fac2e514565" +dependencies = [ + "num-bigint", + "num-traits", + "proc-macro2", + "quote", + "syn 1.0.109", +] + +[[package]] +name = "ark-serialize" +version = "0.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1d6c2b318ee6e10f8c2853e73a83adc0ccb88995aa978d8a3408d492ab2ee671" +dependencies = [ + "ark-std 0.3.0", + "digest 0.9.0", +] + +[[package]] +name = "ark-serialize" +version = "0.4.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "adb7b85a02b83d2f22f89bd5cac66c9c89474240cb6207cb1efc16d098e822a5" +dependencies = [ + "ark-std 0.4.0", + "digest 0.10.7", + "num-bigint", +] + [[package]] name = "ark-std" version = "0.3.0" @@ -140,6 +245,16 @@ dependencies = [ "rand", ] +[[package]] +name = "ark-std" +version = "0.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "94893f1e0c6eeab764ade8dc4c0db24caf4fe7cbbaafc0eba0a9030f447b5185" +dependencies = [ + "num-traits", + "rand", +] + [[package]] name = "array-init" version = "2.1.0" @@ -268,7 +383,7 @@ version = "0.66.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "f2b84e06fc203107bfbad243f4aba2af864eb7db3b1cf46ea0a023b0b433d2a7" dependencies = [ - "bitflags 2.4.0", + "bitflags 2.4.1", "cexpr", "clang-sys", "lazy_static", @@ -281,7 +396,7 @@ dependencies = [ "regex", "rustc-hash", "shlex", - "syn 2.0.33", + "syn 2.0.39", "which", ] @@ -293,9 +408,9 @@ checksum = "bef38d45163c2f1dde094a7dfd33ccf595c92905c8f8f4fdc18d06fb1037718a" [[package]] name = "bitflags" -version = "2.4.0" +version = "2.4.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b4682ae6287fcf752ecaabbfcc7b6f9b72aa33933dc23a554d853aea8eea8635" +checksum = "327762f6e5a765692301e5bb513e0d9fef63be86bbc14528052b1cd3e6f03e07" [[package]] name = "bitvec" @@ -371,9 +486,9 @@ checksum = "c3ac9f8b63eca6fd385229b3675f6cc0dc5c8a5c8a54a59d4f52ffd670d87b0c" [[package]] name = "byteorder" -version = "1.4.3" +version = "1.5.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "14c189c53d098945499cdfa7ecc63567cf3886b3332b312a5b4585d8d3a6a610" +checksum = "1fd0f2584146f6f2ef48085050886acf353beff7305ebd1ae69500e27c67f64b" [[package]] name = "bytes" @@ -521,7 +636,7 @@ dependencies = [ "heck", "proc-macro2", "quote", - "syn 2.0.33", + "syn 2.0.39", ] [[package]] @@ -586,13 +701,14 @@ dependencies = [ [[package]] name = "const-hex" -version = "1.9.1" +version = "1.10.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c37be52ef5e3b394db27a2341010685ad5103c72ac15ce2e9420a7e8f93f342c" +checksum = "a5104de16b218eddf8e34ffe2f86f74bfa4e61e95a1b89732fccf6325efd0557" dependencies = [ "cfg-if", "cpufeatures", "hex", + "proptest", "serde", ] @@ -622,9 +738,9 @@ checksum = "6245d59a3e82a7fc217c5828a6692dbc6dfb63a0c8c90495621f7b9d79704a0e" [[package]] name = "cpufeatures" -version = "0.2.9" +version = "0.2.11" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a17b76ff3a4162b0b27f354a0c87015ddad39d35f9c0c36607a3bdd175dde1f1" +checksum = "ce420fe07aecd3e67c5f910618fe65e94158f6dcc0adf44e00d69ce2bdfe0fd0" dependencies = [ "libc", ] @@ -750,9 +866,9 @@ dependencies = [ [[package]] name = "crypto-bigint" -version = "0.5.3" +version = "0.5.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "740fe28e594155f10cfc383984cbefd529d7396050557148f79cb0f621204124" +checksum = "0dc92fb57ca44df6db8059111ab3af99a63d5d0f8375d9972e319a379c6bab76" dependencies = [ "generic-array", "rand_core", @@ -820,6 +936,17 @@ dependencies = [ "powerfmt", ] +[[package]] +name = "derivative" +version = "2.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "fcc3dd5e9e9c0b295d6e1e4d811fb6f157d5ffd784b8d202fc62eac8035a770b" +dependencies = [ + "proc-macro2", + "quote", + "syn 1.0.109", +] + [[package]] name = "derive_more" version = "0.99.17" @@ -829,7 +956,7 @@ dependencies = [ "convert_case", "proc-macro2", "quote", - "rustc_version", + "rustc_version 0.4.0", "syn 1.0.109", ] @@ -862,14 +989,14 @@ checksum = "487585f4d0c6655fe74905e2504d8ad6908e4db67f744eb140876906c2f3175d" dependencies = [ "proc-macro2", "quote", - "syn 2.0.33", + "syn 2.0.39", ] [[package]] name = "ecdsa" -version = "0.16.8" +version = "0.16.9" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a4b1e0c257a9e9f25f90ff76d7a68360ed497ee519c8e428d1825ef0000799d4" +checksum = "ee27f32b5c5292967d2d4a9d7f1e0b0aed2c15daded5a60300e4abb9d8020bca" dependencies = [ "der 0.7.8", "digest 0.10.7", @@ -887,12 +1014,12 @@ checksum = "a26ae43d7bcc3b814de94796a5e736d4029efb0ee900c12e2d54c993ad1a1e07" [[package]] name = "elliptic-curve" -version = "0.13.6" +version = "0.13.7" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d97ca172ae9dc9f9b779a6e3a65d308f2af74e5b8c921299075bdb4a0370e914" +checksum = "e9775b22bc152ad86a0cf23f0f348b884b26add12bf741e7ffc4d4ab2ab4d205" dependencies = [ "base16ct", - "crypto-bigint 0.5.3", + "crypto-bigint 0.5.5", "digest 0.10.7", "ff", "generic-array", @@ -912,14 +1039,14 @@ checksum = "c2ad8cef1d801a4686bfd8919f0b30eac4c8e48968c437a6405ded4fb5272d2b" dependencies = [ "proc-macro2", "quote", - "syn 2.0.33", + "syn 2.0.39", ] [[package]] name = "env_logger" -version = "0.10.0" +version = "0.10.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "85cdab6a89accf66733ad5a1693a4dcced6aeff64602b634530dd73c1f3ee9f0" +checksum = "95b3f3e67048839cb0d0781f445682a35113da7121f7c949db0e2be96a4fbece" dependencies = [ "humantime", "is-terminal", @@ -936,9 +1063,9 @@ checksum = "5443807d6dff69373d433ab9ef5378ad8df50ca6298caf15de6e52e24aaf54d5" [[package]] name = "errno" -version = "0.3.5" +version = "0.3.7" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ac3e13f66a2f95e32a39eaa81f6b95d42878ca0e1db0c7543723dfe12557e860" +checksum = "f258a7194e7f7c2a7837a8913aeab7fd8c383457034fa20ce4dd3dcb813e8eb8" dependencies = [ "libc", "windows-sys 0.48.0", @@ -994,9 +1121,9 @@ dependencies = [ [[package]] name = "ethers-core" -version = "2.0.10" +version = "2.0.11" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c0a17f0708692024db9956b31d7a20163607d2745953f5ae8125ab368ba280ad" +checksum = "2f03e0bdc216eeb9e355b90cf610ef6c5bb8aca631f97b5ae9980ce34ea7878d" dependencies = [ "arrayvec", "bytes", @@ -1025,6 +1152,17 @@ version = "2.0.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "25cbce373ec4653f1a01a31e8a5e5ec0c622dc27ff9c4e6606eefef5cbbed4a5" +[[package]] +name = "fastrlp" +version = "0.3.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "139834ddba373bbdd213dffe02c8d110508dcf1726c2be27e8d1f7d7e1856418" +dependencies = [ + "arrayvec", + "auto_impl", + "bytes", +] + [[package]] name = "ff" version = "0.13.0" @@ -1082,9 +1220,9 @@ dependencies = [ [[package]] name = "getrandom" -version = "0.2.10" +version = "0.2.11" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "be4136b2a15dd319360be1c07d9933517ccf0be8f16bf62a3bee4f0d618df427" +checksum = "fe9006bed769170c11f845cf00c7c1e9092aeb3f268e007c3e760ac68008070f" dependencies = [ "cfg-if", "js-sys", @@ -1135,56 +1273,33 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "eabb4a44450da02c90444cf74558da904edde8fb4e9035a9a6a4e15445af0bd7" [[package]] -name = "halo2-base" +name = "halo2-axiom" version = "0.4.0" -source = "git+https://github.com/axiom-crypto/halo2-lib.git?branch=community-edition#980b39bcca5b3327aaef6c8d73577d9381bfa899" +source = "git+https://github.com/axiom-crypto/halo2.git#e841084b8fb5cffd1390b4901e89812c861dffb1" dependencies = [ - "ark-std", - "getset", - "halo2_proofs 0.2.0 (git+https://github.com/privacy-scaling-explorations/halo2.git?rev=7a21656)", - "halo2_proofs 0.2.0 (git+https://github.com/axiom-crypto/halo2.git)", + "blake2b_simd", + "crossbeam", + "ff", + "group", + "halo2curves-axiom", "itertools 0.11.0", - "log", - "num-bigint", - "num-integer", - "num-traits", - "poseidon-rs", + "maybe-rayon", + "pairing", "rand", - "rand_chacha", - "rayon", - "rustc-hash", - "serde", - "serde_json", -] - -[[package]] -name = "halo2-base" -version = "0.4.0" -source = "git+https://github.com/axiom-crypto/halo2-lib.git?branch=develop#bf71f0e30ff1da8b9ef67dfbb0824e298a89d5a9" -dependencies = [ - "getset", - "halo2_proofs 0.2.0 (git+https://github.com/axiom-crypto/halo2.git)", - "itertools 0.11.0", - "log", - "num-bigint", - "num-integer", - "num-traits", - "poseidon-rs", - "rand_chacha", - "rayon", + "rand_core", "rustc-hash", - "serde", - "serde_json", + "sha3 0.10.8", + "tracing", ] [[package]] name = "halo2-base" version = "0.4.0" -source = "git+https://github.com/axiom-crypto/halo2-lib.git?branch=feat/zkevm-sha256#adf331ecdd8ae492bced80d3157ae9c3b66fde04" dependencies = [ - "ark-std", + "ark-std 0.3.0", "getset", - "halo2_proofs 0.2.0 (git+https://github.com/axiom-crypto/halo2.git)", + "halo2-axiom", + "halo2_proofs", "itertools 0.11.0", "log", "num-bigint", @@ -1209,13 +1324,14 @@ dependencies = [ "env_logger", "getrandom", "getset", - "halo2-base 0.4.0 (git+https://github.com/axiom-crypto/halo2-lib.git?branch=community-edition)", + "halo2-base", + "halo2-ecc", "halo2-rsa", - "halo2-sha256-unoptimized", "itertools 0.11.0", "num-bigint", "num-traits", "openssl", + "pse-poseidon", "rand", "rayon", "rsa", @@ -1231,28 +1347,8 @@ dependencies = [ [[package]] name = "halo2-ecc" version = "0.4.0" -source = "git+https://github.com/axiom-crypto/halo2-lib.git?branch=community-edition#980b39bcca5b3327aaef6c8d73577d9381bfa899" -dependencies = [ - "halo2-base 0.4.0 (git+https://github.com/axiom-crypto/halo2-lib.git?branch=community-edition)", - "itertools 0.10.5", - "num-bigint", - "num-integer", - "num-traits", - "rand", - "rand_chacha", - "rand_core", - "rayon", - "serde", - "serde_json", - "test-case", -] - -[[package]] -name = "halo2-ecc" -version = "0.4.0" -source = "git+https://github.com/axiom-crypto/halo2-lib.git?branch=develop#bf71f0e30ff1da8b9ef67dfbb0824e298a89d5a9" dependencies = [ - "halo2-base 0.4.0 (git+https://github.com/axiom-crypto/halo2-lib.git?branch=develop)", + "halo2-base", "itertools 0.10.5", "num-bigint", "num-integer", @@ -1269,11 +1365,10 @@ dependencies = [ [[package]] name = "halo2-rsa" version = "0.1.0" -source = "git+https://github.com/MynaWallet/halo2-rsa.git?branch=main#231d5421011276dfb7d6a6f84144a2dea9c9e3fe" dependencies = [ "env_logger", - "halo2-base 0.4.0 (git+https://github.com/axiom-crypto/halo2-lib.git?branch=community-edition)", - "halo2-ecc 0.4.0 (git+https://github.com/axiom-crypto/halo2-lib.git?branch=community-edition)", + "halo2-base", + "halo2-ecc", "num-bigint", "num-traits", "rand", @@ -1281,27 +1376,6 @@ dependencies = [ "sha2", ] -[[package]] -name = "halo2-sha256-unoptimized" -version = "0.1.0" -source = "git+https://github.com/zkpdf/halo2-sha256-unoptimized.git?branch=main#ec2d2b28cdb7dd38cb9896b09720d09923fcc2f2" -dependencies = [ - "console_error_panic_hook", - "env_logger", - "generic-array", - "getrandom", - "halo2-base 0.4.0 (git+https://github.com/axiom-crypto/halo2-lib.git?branch=community-edition)", - "hex", - "itertools 0.10.5", - "num-bigint", - "num-traits", - "rand", - "rayon", - "rsa", - "serde", - "sha2", -] - [[package]] name = "halo2_proofs" version = "0.2.0" @@ -1310,7 +1384,7 @@ dependencies = [ "blake2b_simd", "ff", "group", - "halo2curves 0.1.0", + "halo2curves", "maybe-rayon", "rand_chacha", "rand_core", @@ -1318,25 +1392,6 @@ dependencies = [ "tracing", ] -[[package]] -name = "halo2_proofs" -version = "0.2.0" -source = "git+https://github.com/axiom-crypto/halo2.git#4b42325623c9cfea02441ce0cffa17ebf962b3bb" -dependencies = [ - "blake2b_simd", - "crossbeam", - "ff", - "group", - "halo2curves 0.4.0", - "maybe-rayon", - "pairing", - "rand", - "rand_core", - "rustc-hash", - "sha3 0.10.8", - "tracing", -] - [[package]] name = "halo2curves" version = "0.1.0" @@ -1358,9 +1413,10 @@ dependencies = [ ] [[package]] -name = "halo2curves" -version = "0.4.0" -source = "git+https://github.com/axiom-crypto/halo2curves.git?branch=main#e185711b6ba8f3e22f2af8bf24a5fc84b781ca46" +name = "halo2curves-axiom" +version = "0.4.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4d82f25182a221a5c79ce8d41d1dd3910f10626d7e9d0f9f9e9336e2545b7d1f" dependencies = [ "blake2b_simd", "ff", @@ -1389,9 +1445,9 @@ checksum = "8a9ee70c43aaf417c914396645a0fa852624801b24ebb7ae78fe8272889ac888" [[package]] name = "hashbrown" -version = "0.14.1" +version = "0.14.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7dfda62a12f55daeae5015f81b0baea145391cb4520f86c248fc615d72640d12" +checksum = "f93e7192158dbcda357bdec5fb5788eebf8bbac027f3f33e719d29135ae84156" dependencies = [ "ahash", "allocator-api2", @@ -1414,9 +1470,9 @@ dependencies = [ [[package]] name = "hermit-abi" -version = "0.3.2" +version = "0.3.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "443144c8cdadd93ebf52ddb4056d257f5b52c04d3c804e657d19eb73fc33668b" +checksum = "d77f7ec81a6d05a3abb01ab6eb7590f6083d08449fe5a1c8b1e620283546ccb7" [[package]] name = "hex" @@ -1507,12 +1563,12 @@ dependencies = [ [[package]] name = "indexmap" -version = "2.0.2" +version = "2.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8adf3ddd720272c6ea8bf59463c04e0f93d0bbf7c5439b691bca2987e0270897" +checksum = "d530e1a18b1cb4c484e6e34556a0d948706958449fca0cab753d649f2bce3d1f" dependencies = [ "equivalent", - "hashbrown 0.14.1", + "hashbrown 0.14.2", ] [[package]] @@ -1521,7 +1577,7 @@ version = "0.4.9" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "cb0889898416213fab133e1d33a0e5858a48177452750691bde3666d0fdbaf8b" dependencies = [ - "hermit-abi 0.3.2", + "hermit-abi 0.3.3", "rustix", "windows-sys 0.48.0", ] @@ -1552,18 +1608,18 @@ checksum = "af150ab688ff2122fcef229be89cb50dd66af9e01a4ff320cc137eecc9bacc38" [[package]] name = "js-sys" -version = "0.3.64" +version = "0.3.65" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c5f195fe497f702db0f318b07fdd68edb16955aed830df8363d837542f8f935a" +checksum = "54c0c35952f67de54bb584e9fd912b3023117cbafc0a77d8f3dee1fb5f572fe8" dependencies = [ "wasm-bindgen", ] [[package]] name = "k256" -version = "0.13.1" +version = "0.13.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "cadb76004ed8e97623117f3df85b17aaa6626ab0b0831e6573f104df16cd1bcc" +checksum = "3f01b677d82ef7a676aa37e099defd83a28e15687112cafdd112d60236b6115b" dependencies = [ "cfg-if", "ecdsa", @@ -1598,9 +1654,9 @@ checksum = "830d08ce1d1d941e6b30645f1a0eb5643013d835ce3779a5fc208261dbe10f55" [[package]] name = "libc" -version = "0.2.148" +version = "0.2.150" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9cdc71e17332e86d2e1d38c1f99edcb6288ee11b815fb1a4b049eaa2114d369b" +checksum = "89d92a4743f9a61002fae18374ed11e7973f530cb3a3255fb354818118b2203c" [[package]] name = "libloading" @@ -1614,15 +1670,15 @@ dependencies = [ [[package]] name = "libm" -version = "0.2.7" +version = "0.2.8" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f7012b1bbb0719e1097c47611d3898568c546d597c2e74d66f6087edd5233ff4" +checksum = "4ec2a862134d2a7d32d7983ddcdd1c4923530833c9f2ea1a44fc5fa473989058" [[package]] name = "linux-raw-sys" -version = "0.4.10" +version = "0.4.11" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "da2479e8c062e40bf0066ffa0bc823de0a9368974af99c9f6df941d2c231e03f" +checksum = "969488b55f8ac402214f3f5fd243ebb7206cf82de60d3172994707a4bcc2b829" [[package]] name = "log" @@ -1672,9 +1728,9 @@ dependencies = [ [[package]] name = "mio" -version = "0.8.8" +version = "0.8.9" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "927a765cd3fc26206e66b296465fa9d3e5ab003e651c1b3c060e7956d96b19d2" +checksum = "3dce281c5e46beae905d4de1870d8b1509a9142b62eedf18b443b011ca8343d0" dependencies = [ "libc", "wasi", @@ -1779,9 +1835,9 @@ dependencies = [ [[package]] name = "num-traits" -version = "0.2.16" +version = "0.2.17" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f30b0abd723be7e2ffca1272140fac1a2f084c77ec3e123c192b66af1ee9e6c2" +checksum = "39e3200413f237f41ab11ad6d161bc7239c84dcb631773ccd7de3dfe4b5c267c" dependencies = [ "autocfg", "libm", @@ -1793,29 +1849,29 @@ version = "1.16.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "4161fcb6d602d4d2081af7c3a45852d875a03dd337a6bfdd6e06407b61342a43" dependencies = [ - "hermit-abi 0.3.2", + "hermit-abi 0.3.3", "libc", ] [[package]] name = "num_enum" -version = "0.7.0" +version = "0.7.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "70bf6736f74634d299d00086f02986875b3c2d924781a6a2cb6c201e73da0ceb" +checksum = "683751d591e6d81200c39fb0d1032608b77724f34114db54f571ff1317b337c0" dependencies = [ "num_enum_derive", ] [[package]] name = "num_enum_derive" -version = "0.7.0" +version = "0.7.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "56ea360eafe1022f7cc56cd7b869ed57330fb2453d0c7831d99b74c65d2f5597" +checksum = "6c11e44798ad209ccdd91fc192f0526a369a01234f7373e1b141c96d7cee4f0e" dependencies = [ - "proc-macro-crate", + "proc-macro-crate 2.0.0", "proc-macro2", "quote", - "syn 2.0.33", + "syn 2.0.39", ] [[package]] @@ -1881,11 +1937,11 @@ dependencies = [ [[package]] name = "openssl" -version = "0.10.57" +version = "0.10.59" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bac25ee399abb46215765b1cb35bc0212377e58a061560d8b29b024fd0430e7c" +checksum = "7a257ad03cd8fb16ad4172fedf8094451e1af1c4b70097636ef2eac9a5f0cc33" dependencies = [ - "bitflags 2.4.0", + "bitflags 2.4.1", "cfg-if", "foreign-types", "libc", @@ -1902,14 +1958,14 @@ checksum = "a948666b637a0f465e8564c73e89d4dde00d72d4d473cc972f390fc3dcee7d9c" dependencies = [ "proc-macro2", "quote", - "syn 2.0.33", + "syn 2.0.39", ] [[package]] name = "openssl-sys" -version = "0.9.93" +version = "0.9.95" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "db4d56a4c0478783083cfafcc42493dd4a981d41669da64b4572a2a089b51b1d" +checksum = "40a4130519a360279579c2053038317e40eff64d13fd3f004f9e1b72b8a6aaf9" dependencies = [ "cc", "libc", @@ -1952,7 +2008,7 @@ version = "3.6.5" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "312270ee71e1cd70289dacf597cab7b207aa107d2f28191c2ae45b2ece18a260" dependencies = [ - "proc-macro-crate", + "proc-macro-crate 1.3.1", "proc-macro2", "quote", "syn 1.0.109", @@ -1994,6 +2050,17 @@ dependencies = [ "base64ct", ] +[[package]] +name = "pest" +version = "2.7.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ae9cee2a55a544be8b89dc6848072af97a20f2422603c10865be2a42b580fff5" +dependencies = [ + "memchr", + "thiserror", + "ucd-trie", +] + [[package]] name = "pin-project-lite" version = "0.2.13" @@ -2099,7 +2166,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "ae005bd773ab59b4725093fd7df83fd7892f7d8eafb48dbd7de6e024e4215f9d" dependencies = [ "proc-macro2", - "syn 2.0.33", + "syn 2.0.39", ] [[package]] @@ -2123,7 +2190,16 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "7f4c021e1093a56626774e81216a4ce732a735e5bad4868a03f3ed65ca0c3919" dependencies = [ "once_cell", - "toml_edit", + "toml_edit 0.19.15", +] + +[[package]] +name = "proc-macro-crate" +version = "2.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7e8366a6159044a37876a2b9817124296703c586a5c92e2c53751fa06d8d43e8" +dependencies = [ + "toml_edit 0.20.7", ] [[package]] @@ -2152,27 +2228,38 @@ dependencies = [ [[package]] name = "proc-macro2" -version = "1.0.67" +version = "1.0.69" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3d433d9f1a3e8c1263d9456598b16fec66f4acc9a74dacffd35c7bb09b3a1328" +checksum = "134c189feb4956b20f6f547d2cf727d4c0fe06722b20a0eec87ed445a97f92da" dependencies = [ "unicode-ident", ] [[package]] name = "proptest" -version = "1.3.1" +version = "1.4.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7c003ac8c77cb07bb74f5f198bce836a689bcd5a42574612bf14d17bfd08c20e" +checksum = "31b476131c3c86cb68032fdc5cb6d5a1045e3e42d96b69fa599fd77701e1f5bf" dependencies = [ - "bitflags 2.4.0", + "bitflags 2.4.1", + "lazy_static", "num-traits", "rand", "rand_chacha", "rand_xorshift", + "regex-syntax", "unarray", ] +[[package]] +name = "pse-poseidon" +version = "0.2.0" +source = "git+https://github.com/axiom-crypto/pse-poseidon.git#19d3b09481bda0e95e7c005906365d070fceb752" +dependencies = [ + "halo2curves-axiom", + "subtle", +] + [[package]] name = "quote" version = "1.0.33" @@ -2229,9 +2316,9 @@ dependencies = [ [[package]] name = "rayon" -version = "1.7.0" +version = "1.8.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1d2df5196e37bcc87abebc0053e20787d73847bb33134a69841207dd0a47f03b" +checksum = "9c27db03db7734835b3f53954b534c91069375ce6ccaa2e065441e07d9b6cdb1" dependencies = [ "either", "rayon-core", @@ -2239,30 +2326,28 @@ dependencies = [ [[package]] name = "rayon-core" -version = "1.11.0" +version = "1.12.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4b8f95bd6966f5c87776639160a66bd8ab9895d9d4ab01ddba9fc60661aebe8d" +checksum = "5ce3fb6ad83f861aac485e76e1985cd109d9a3713802152be56c3b1f0e0658ed" dependencies = [ - "crossbeam-channel", "crossbeam-deque", "crossbeam-utils", - "num_cpus", ] [[package]] name = "redox_syscall" -version = "0.3.5" +version = "0.4.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "567664f262709473930a4bf9e51bf2ebf3348f2e748ccc50dea20646858f8f29" +checksum = "4722d768eff46b75989dd134e5c353f0d6296e5aaa3132e776cbdb56be7731aa" dependencies = [ "bitflags 1.3.2", ] [[package]] name = "regex" -version = "1.10.1" +version = "1.10.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "aaac441002f822bc9705a681810a4dd2963094b9ca0ddc41cb963a4c189189ea" +checksum = "380b951a9c5e80ddfd6136919eef32310721aa4aacd4889a8d39124b026ab343" dependencies = [ "aho-corasick", "memchr", @@ -2272,9 +2357,9 @@ dependencies = [ [[package]] name = "regex-automata" -version = "0.4.2" +version = "0.4.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5011c7e263a695dc8ca064cddb722af1be54e517a280b12a5356f98366899e5d" +checksum = "5f804c7828047e88b2d32e2d7fe5a105da8ee3264f01902f796c8e067dc2483f" dependencies = [ "aho-corasick", "memchr", @@ -2333,11 +2418,11 @@ dependencies = [ "alloy-primitives", "alloy-rlp", "auto_impl", - "bitflags 2.4.0", + "bitflags 2.4.1", "bitvec", "c-kzg", "enumn", - "hashbrown 0.14.1", + "hashbrown 0.14.2", "hex", "once_cell", ] @@ -2426,8 +2511,16 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "95294d6e3a6192f3aabf91c38f56505a625aa495533442744185a36d75a790c4" dependencies = [ "alloy-rlp", + "ark-ff 0.3.0", + "ark-ff 0.4.2", + "bytes", + "fastrlp", + "num-bigint", + "parity-scale-codec", + "primitive-types", "proptest", "rand", + "rlp", "ruint-macro", "serde", "valuable", @@ -2458,13 +2551,22 @@ version = "2.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "3e75f6a532d0fd9f7f13144f392b6ad56a32696bfcd9c78f797f16bbb6f072d6" +[[package]] +name = "rustc_version" +version = "0.3.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f0dfe2087c51c460008730de8b57e6a320782fbfb312e1f4d520e6c6fae155ee" +dependencies = [ + "semver 0.11.0", +] + [[package]] name = "rustc_version" version = "0.4.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "bfa0f585226d2e68097d4f95d113b15b83a82e819ab25717ec0590d9584ef366" dependencies = [ - "semver", + "semver 1.0.20", ] [[package]] @@ -2478,11 +2580,11 @@ dependencies = [ [[package]] name = "rustix" -version = "0.38.19" +version = "0.38.24" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "745ecfa778e66b2b63c88a61cb36e0eea109e803b0b86bf9879fbc77c70e86ed" +checksum = "9ad981d6c340a49cdc40a1028d9c6084ec7e9fa33fcb839cab656a267071e234" dependencies = [ - "bitflags 2.4.0", + "bitflags 2.4.1", "errno", "libc", "linux-raw-sys", @@ -2512,9 +2614,9 @@ dependencies = [ [[package]] name = "scale-info" -version = "2.9.0" +version = "2.10.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "35c0a159d0c45c12b20c5a844feb1fe4bea86e28f17b92a5f0c42193634d3782" +checksum = "7f7d66a1128282b7ef025a8ead62a4a9fcf017382ec53b8ffbf4d7bf77bd3c60" dependencies = [ "cfg-if", "derive_more", @@ -2524,11 +2626,11 @@ dependencies = [ [[package]] name = "scale-info-derive" -version = "2.9.0" +version = "2.10.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "912e55f6d20e0e80d63733872b40e1227c0bce1e1ab81ba67d696339bfd7fd29" +checksum = "abf2c68b89cafb3b8d918dd07b42be0da66ff202cf1155c5739a4e0c1ea0dc19" dependencies = [ - "proc-macro-crate", + "proc-macro-crate 1.3.1", "proc-macro2", "quote", "syn 1.0.109", @@ -2572,17 +2674,35 @@ dependencies = [ "cc", ] +[[package]] +name = "semver" +version = "0.11.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f301af10236f6df4160f7c3f04eec6dbc70ace82d23326abad5edee88801c6b6" +dependencies = [ + "semver-parser", +] + [[package]] name = "semver" version = "1.0.20" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "836fa6a3e1e547f9a2c4040802ec865b5d85f4014efe00555d7090a3dcaa1090" +[[package]] +name = "semver-parser" +version = "0.10.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "00b0bef5b7f9e0df16536d3961cfb6e84331c065b4066afb39768d0e319411f7" +dependencies = [ + "pest", +] + [[package]] name = "serde" -version = "1.0.188" +version = "1.0.192" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "cf9e0fcba69a370eed61bcf2b728575f726b50b55cba78064753d708ddc7549e" +checksum = "bca2a08484b285dcb282d0f67b26cadc0df8b19f8c12502c13d966bf9482f001" dependencies = [ "serde_derive", ] @@ -2598,20 +2718,20 @@ dependencies = [ [[package]] name = "serde_derive" -version = "1.0.188" +version = "1.0.192" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4eca7ac642d82aa35b60049a6eccb4be6be75e599bd2e9adb5f875a737654af2" +checksum = "d6c7207fbec9faa48073f3e3074cbe553af6ea512d7c21ba46e434e70ea9fbc1" dependencies = [ "proc-macro2", "quote", - "syn 2.0.33", + "syn 2.0.39", ] [[package]] name = "serde_json" -version = "1.0.107" +version = "1.0.108" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6b420ce6e3d8bd882e9b243c6eed35dbc9a6110c9769e74b584e0d68d1f20c65" +checksum = "3d1c7e3eac408d115102c4c24ad393e0821bb3a5df4d506a80f85f7a742a526b" dependencies = [ "itoa", "ryu", @@ -2620,9 +2740,9 @@ dependencies = [ [[package]] name = "sha2" -version = "0.10.7" +version = "0.10.8" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "479fb9d862239e610720565ca91403019f2f00410f1864c5aa7479b950a76ed8" +checksum = "793db75ad2bcafc3ffa7c68b215fee268f537982cd901d132f89c6343f3a3dc8" dependencies = [ "cfg-if", "cpufeatures", @@ -2659,9 +2779,9 @@ checksum = "a7cee0529a6d40f580e7a5e6c495c8fbfe21b7b52795ed4bb5e62cdf92bc6380" [[package]] name = "signature" -version = "2.1.0" +version = "2.2.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5e1788eed21689f9cf370582dfc467ef36ed9c707f073528ddafa8d83e3b8500" +checksum = "77549399552de45a898a580c1b41d445bf730df867cc44e6c0233bbc4b8329de" dependencies = [ "digest 0.10.7", "rand_core", @@ -2669,9 +2789,9 @@ dependencies = [ [[package]] name = "smallvec" -version = "1.11.0" +version = "1.11.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "62bb4feee49fdd9f707ef802e22365a35de4b7b299de4763d44bfea899442ff9" +checksum = "4dccd0940a2dcdf68d092b8cbab7dc0ad8fa938bf95787e1b916b0e3d0e8e970" [[package]] name = "smol_str" @@ -2685,10 +2805,9 @@ dependencies = [ [[package]] name = "snark-verifier" version = "0.1.6" -source = "git+https://github.com/axiom-crypto/snark-verifier.git?branch=community-edition#7011e8ce0c2f7e79ab9629aa528cfb6837cdeafe" dependencies = [ - "halo2-base 0.4.0 (git+https://github.com/axiom-crypto/halo2-lib.git?branch=community-edition)", - "halo2-ecc 0.4.0 (git+https://github.com/axiom-crypto/halo2-lib.git?branch=community-edition)", + "halo2-base", + "halo2-ecc", "hex", "itertools 0.11.0", "lazy_static", @@ -2698,40 +2817,22 @@ dependencies = [ "pairing", "rand", "revm", + "ruint", "serde", "sha3 0.10.8", ] -[[package]] -name = "snark-verifier" -version = "0.1.7" -source = "git+https://github.com/axiom-crypto/snark-verifier.git?branch=develop#624b003c656e44b14202d4b8a16a2f7bc4e71eeb" -dependencies = [ - "halo2-base 0.4.0 (git+https://github.com/axiom-crypto/halo2-lib.git?branch=develop)", - "halo2-ecc 0.4.0 (git+https://github.com/axiom-crypto/halo2-lib.git?branch=develop)", - "hex", - "itertools 0.11.0", - "lazy_static", - "num-bigint", - "num-integer", - "num-traits", - "pairing", - "rand", - "serde", -] - [[package]] name = "snark-verifier-sdk" version = "0.1.6" -source = "git+https://github.com/axiom-crypto/snark-verifier.git?branch=community-edition#7011e8ce0c2f7e79ab9629aa528cfb6837cdeafe" dependencies = [ - "ark-std", + "ark-std 0.3.0", "bincode", "ethereum-types", "getset", - "halo2-base 0.4.0 (git+https://github.com/axiom-crypto/halo2-lib.git?branch=community-edition)", + "halo2-base", "hex", - "itertools 0.10.5", + "itertools 0.11.0", "lazy_static", "num-bigint", "num-integer", @@ -2740,14 +2841,14 @@ dependencies = [ "rand_chacha", "serde", "serde_json", - "snark-verifier 0.1.6", + "snark-verifier", ] [[package]] name = "socket2" -version = "0.5.4" +version = "0.5.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4031e820eb552adee9295814c0ced9e5cf38ddf1e8b7d566d6de8e2538ea989e" +checksum = "7b5fac59a5cb5dd637972e5fca70daf0523c9067fcdc4842f053dae04a18f8e9" dependencies = [ "libc", "windows-sys 0.48.0", @@ -2802,15 +2903,15 @@ dependencies = [ [[package]] name = "strum_macros" -version = "0.25.2" +version = "0.25.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ad8d03b598d3d0fff69bf533ee3ef19b8eeb342729596df84bcc7e1f96ec4059" +checksum = "23dc1fa9ac9c169a78ba62f0b841814b7abae11bdd047b9c58f893439e309ea0" dependencies = [ "heck", "proc-macro2", "quote", "rustversion", - "syn 2.0.33", + "syn 2.0.39", ] [[package]] @@ -2845,9 +2946,9 @@ dependencies = [ [[package]] name = "syn" -version = "2.0.33" +version = "2.0.39" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9caece70c63bfba29ec2fed841a09851b14a235c60010fa4de58089b6c025668" +checksum = "23e78b90f2fcf45d3e842032ce32e3f2d1545ba6636271dcbf24fa306d87be7a" dependencies = [ "proc-macro2", "quote", @@ -2874,9 +2975,9 @@ checksum = "55937e1799185b12863d447f42597ed69d9928686b8d88a1df17376a097d8369" [[package]] name = "tempfile" -version = "3.8.0" +version = "3.8.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "cb94d2f3cc536af71caac6b6fcebf65860b347e7ce0cc9ebe8f70d3e521054ef" +checksum = "7ef1adac450ad7f4b3c28589471ade84f25f731a7a0fe30d71dfa9f60fd808e5" dependencies = [ "cfg-if", "fastrand", @@ -2887,45 +2988,43 @@ dependencies = [ [[package]] name = "termcolor" -version = "1.3.0" +version = "1.4.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6093bad37da69aab9d123a8091e4be0aa4a03e4d601ec641c327398315f62b64" +checksum = "ff1bc3d3f05aff0403e8ac0d92ced918ec05b666a43f83297ccef5bea8a3d449" dependencies = [ "winapi-util", ] [[package]] name = "test-case" -version = "3.2.1" +version = "3.3.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c8f1e820b7f1d95a0cdbf97a5df9de10e1be731983ab943e56703ac1b8e9d425" +checksum = "eb2550dd13afcd286853192af8601920d959b14c401fcece38071d53bf0768a8" dependencies = [ "test-case-macros", ] [[package]] name = "test-case-core" -version = "3.2.1" +version = "3.3.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "54c25e2cb8f5fcd7318157634e8838aa6f7e4715c96637f969fabaccd1ef5462" +checksum = "adcb7fd841cd518e279be3d5a3eb0636409487998a4aff22f3de87b81e88384f" dependencies = [ "cfg-if", - "proc-macro-error", "proc-macro2", "quote", - "syn 2.0.33", + "syn 2.0.39", ] [[package]] name = "test-case-macros" -version = "3.2.1" +version = "3.3.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "37cfd7bbc88a0104e304229fba519bdc45501a30b760fb72240342f1289ad257" +checksum = "5c89e72a01ed4c579669add59014b9a524d609c0c88c6a585ce37485879f6ffb" dependencies = [ - "proc-macro-error", "proc-macro2", "quote", - "syn 2.0.33", + "syn 2.0.39", "test-case-core", ] @@ -2937,22 +3036,22 @@ checksum = "222a222a5bfe1bba4a77b45ec488a741b3cb8872e5e499451fd7d0129c9c7c3d" [[package]] name = "thiserror" -version = "1.0.49" +version = "1.0.50" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1177e8c6d7ede7afde3585fd2513e611227efd6481bd78d2e82ba1ce16557ed4" +checksum = "f9a7210f5c9a7156bb50aa36aed4c95afb51df0df00713949448cf9e97d382d2" dependencies = [ "thiserror-impl", ] [[package]] name = "thiserror-impl" -version = "1.0.49" +version = "1.0.50" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "10712f02019e9288794769fba95cd6847df9874d49d871d062172f9dd41bc4cc" +checksum = "266b2e40bc00e5a6c09c3584011e08b06f123c00362c92b975ba9843aaaa14b8" dependencies = [ "proc-macro2", "quote", - "syn 2.0.33", + "syn 2.0.39", ] [[package]] @@ -3014,9 +3113,9 @@ dependencies = [ [[package]] name = "tokio" -version = "1.33.0" +version = "1.34.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4f38200e3ef7995e5ef13baec2f432a6da0aa9ac495b2c0e8f3b7eec2c92d653" +checksum = "d0c014766411e834f7af5b8f4cf46257aab4036ca95e9d2c144a10f59ad6f5b9" dependencies = [ "backtrace", "bytes", @@ -3031,20 +3130,20 @@ dependencies = [ [[package]] name = "tokio-macros" -version = "2.1.0" +version = "2.2.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "630bdcf245f78637c13ec01ffae6187cca34625e8c63150d424b59e55af2675e" +checksum = "5b8a1e28f2deaa14e508979454cb3a223b10b938b45af148bc0986de36f1923b" dependencies = [ "proc-macro2", "quote", - "syn 2.0.33", + "syn 2.0.39", ] [[package]] name = "toml_datetime" -version = "0.6.3" +version = "0.6.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7cda73e2f1397b1262d6dfdcef8aafae14d1de7748d66822d3bfeeb6d03e5e4b" +checksum = "3550f4e9685620ac18a50ed434eb3aec30db8ba93b0287467bca5826ea25baf1" [[package]] name = "toml_edit" @@ -3052,18 +3151,28 @@ version = "0.19.15" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "1b5bb770da30e5cbfde35a2d7b9b8a2c4b8ef89548a7a6aeab5c9a576e3e7421" dependencies = [ - "indexmap 2.0.2", + "indexmap 2.1.0", + "toml_datetime", + "winnow", +] + +[[package]] +name = "toml_edit" +version = "0.20.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "70f427fce4d84c72b5b732388bf4a9f4531b53f74e2887e3ecb2481f68f66d81" +dependencies = [ + "indexmap 2.1.0", "toml_datetime", "winnow", ] [[package]] name = "tracing" -version = "0.1.37" +version = "0.1.40" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8ce8c33a8d48bd45d624a6e523445fd21ec13d3653cd51f681abf67418f54eb8" +checksum = "c3523ab5a71916ccf420eebdf5521fcef02141234bbc0b8a49f2fdc4544364ef" dependencies = [ - "cfg-if", "pin-project-lite", "tracing-attributes", "tracing-core", @@ -3071,29 +3180,35 @@ dependencies = [ [[package]] name = "tracing-attributes" -version = "0.1.26" +version = "0.1.27" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5f4f31f56159e98206da9efd823404b79b6ef3143b4a7ab76e67b1751b25a4ab" +checksum = "34704c8d6ebcbc939824180af020566b01a7c01f80641264eba0999f6c2b6be7" dependencies = [ "proc-macro2", "quote", - "syn 2.0.33", + "syn 2.0.39", ] [[package]] name = "tracing-core" -version = "0.1.31" +version = "0.1.32" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0955b8137a1df6f1a2e9a37d8a6656291ff0297c1a97c24e0d8425fe2312f79a" +checksum = "c06d3da6113f116aaee68e4d601191614c9053067f9ab7f6edbcb161237daa54" dependencies = [ "once_cell", ] [[package]] name = "typenum" -version = "1.16.0" +version = "1.17.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "42ff0bf0c66b8238c6f3b578df37d0b7848e55df8577b3f74f92a69acceeb825" + +[[package]] +name = "ucd-trie" +version = "0.1.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "497961ef93d974e23eb6f433eb5fe1b7930b659f06d12dec6fc44a8f554c0bba" +checksum = "ed646292ffc8188ef8ea4d1e0e0150fb15a5c2e12ad9b8fc191ae7a8a7f3c4b9" [[package]] name = "uint" @@ -3173,9 +3288,9 @@ checksum = "9c8d87e72b64a3b4db28d11ce29237c246188f4f51057d65a7eab63b7987e423" [[package]] name = "wasm-bindgen" -version = "0.2.87" +version = "0.2.88" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7706a72ab36d8cb1f80ffbf0e071533974a60d0a308d01a5d0375bf60499a342" +checksum = "7daec296f25a1bae309c0cd5c29c4b260e510e6d813c286b19eaadf409d40fce" dependencies = [ "cfg-if", "wasm-bindgen-macro", @@ -3183,24 +3298,24 @@ dependencies = [ [[package]] name = "wasm-bindgen-backend" -version = "0.2.87" +version = "0.2.88" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5ef2b6d3c510e9625e5fe6f509ab07d66a760f0885d858736483c32ed7809abd" +checksum = "e397f4664c0e4e428e8313a469aaa58310d302159845980fd23b0f22a847f217" dependencies = [ "bumpalo", "log", "once_cell", "proc-macro2", "quote", - "syn 2.0.33", + "syn 2.0.39", "wasm-bindgen-shared", ] [[package]] name = "wasm-bindgen-macro" -version = "0.2.87" +version = "0.2.88" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "dee495e55982a3bd48105a7b947fd2a9b4a8ae3010041b9e0faab3f9cd028f1d" +checksum = "5961017b3b08ad5f3fe39f1e79877f8ee7c23c5e5fd5eb80de95abc41f1f16b2" dependencies = [ "quote", "wasm-bindgen-macro-support", @@ -3208,28 +3323,28 @@ dependencies = [ [[package]] name = "wasm-bindgen-macro-support" -version = "0.2.87" +version = "0.2.88" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "54681b18a46765f095758388f2d0cf16eb8d4169b639ab575a8f5693af210c7b" +checksum = "c5353b8dab669f5e10f5bd76df26a9360c748f054f862ff5f3f8aae0c7fb3907" dependencies = [ "proc-macro2", "quote", - "syn 2.0.33", + "syn 2.0.39", "wasm-bindgen-backend", "wasm-bindgen-shared", ] [[package]] name = "wasm-bindgen-shared" -version = "0.2.87" +version = "0.2.88" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ca6ad05a4870b2bf5fe995117d3728437bd27d7cd5f06f13c17443ef369775a1" +checksum = "0d046c5d029ba91a1ed14da14dca44b68bf2f124cfbaf741c54151fdb3e0750b" [[package]] name = "web-sys" -version = "0.3.64" +version = "0.3.65" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9b85cbef8c220a6abc02aefd892dfc0fc23afb1c6a426316ec33253a3877249b" +checksum = "5db499c5f66323272151db0e666cd34f78617522fb0c1604d31a27c50c206a85" dependencies = [ "js-sys", "wasm-bindgen", @@ -3412,9 +3527,9 @@ checksum = "ed94fce61571a4006852b7389a063ab983c02eb1bb37b47f8272ce92d06d9538" [[package]] name = "winnow" -version = "0.5.17" +version = "0.5.19" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a3b801d0e0a6726477cc207f60162da452f3a95adb368399bef20a946e06f65c" +checksum = "829846f3e3db426d4cee4510841b71a8e58aa2a76b1132579487ae430ccd9c7b" dependencies = [ "memchr", ] @@ -3446,11 +3561,31 @@ dependencies = [ "time", ] +[[package]] +name = "zerocopy" +version = "0.7.26" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e97e415490559a91254a2979b4829267a57d2fcd741a98eee8b722fb57289aa0" +dependencies = [ + "zerocopy-derive", +] + +[[package]] +name = "zerocopy-derive" +version = "0.7.26" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "dd7e48ccf166952882ca8bd778a43502c64f33bf94c12ebe2a7f08e5a0f6689f" +dependencies = [ + "proc-macro2", + "quote", + "syn 2.0.39", +] + [[package]] name = "zeroize" -version = "1.6.0" +version = "1.7.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2a0956f1ba7c7909bfb66c2e9e4124ab6f6482560f6628b5aaeba39207c9aad9" +checksum = "525b4ec142c6b68a2d10f01f7bbf6755599ca3f81ea53b8431b7dd348f5fdb2d" dependencies = [ "zeroize_derive", ] @@ -3463,18 +3598,17 @@ checksum = "ce36e65b0d2999d2aafac989fb249189a141aee1f53c612c1f37d72631959f69" dependencies = [ "proc-macro2", "quote", - "syn 2.0.33", + "syn 2.0.39", ] [[package]] name = "zkevm-hashes" version = "0.2.0" -source = "git+https://github.com/axiom-crypto/halo2-lib.git?branch=feat/zkevm-sha256#adf331ecdd8ae492bced80d3157ae9c3b66fde04" dependencies = [ "array-init", "ethers-core", "getset", - "halo2-base 0.4.0 (git+https://github.com/axiom-crypto/halo2-lib.git?branch=feat/zkevm-sha256)", + "halo2-base", "itertools 0.11.0", "lazy_static", "log", @@ -3482,5 +3616,5 @@ dependencies = [ "rand", "rayon", "sha3 0.10.8", - "snark-verifier 0.1.7", + "snark-verifier", ] diff --git a/packages/halo2-circuits/Cargo.toml b/packages/halo2-circuits/Cargo.toml index 48feebd..035ff95 100644 --- a/packages/halo2-circuits/Cargo.toml +++ b/packages/halo2-circuits/Cargo.toml @@ -2,7 +2,7 @@ name = "halo2-circuits" version = "0.1.0" edition = "2021" -authors = ["hiroism007"] +authors = ["hiroism007", "chokermaxx"] # See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html @@ -11,29 +11,17 @@ num-bigint = { version = "0.4", features = ["rand"] } sha2 = "0.10.6" rand = "0.8.5" rsa = { version = "0.6.1", features = ["serde"] } -halo2-rsa = { branch = "main", default-features = false, features = [ - "halo2-axiom", - "display", -], git = "https://github.com/MynaWallet/halo2-rsa.git" } -halo2-base = { branch = "community-edition", default-features = false, features = [ - "halo2-axiom", - "display", - "test-utils", -], git = "https://github.com/axiom-crypto/halo2-lib.git" } -zkevm-hashes = { branch = "feat/zkevm-sha256", default-features = false, features = [ - "halo2-axiom", - "display", -], git = "https://github.com/axiom-crypto/halo2-lib.git" } -halo2-sha256-unoptimized = { branch = "main", default-features = false, features = [ - "halo2-axiom", - "display", -], git = "https://github.com/zkpdf/halo2-sha256-unoptimized.git" } -snark-verifier-sdk = { branch = "community-edition", default-features = false, features = [ +halo2-rsa = { git = "https://github.com/MynaWallet/halo2-rsa.git" } +halo2-base = { git = "https://github.com/MynaWallet/halo2-lib.git", branch = "sha256" } +halo2-ecc = { git = "https://github.com/MynaWallet/halo2-lib.git", branch = "sha256" } +zkevm-hashes = { git = "https://github.com/MynaWallet/halo2-lib.git", branch = "sha256" } +snark-verifier-sdk = { default-features = false, features = [ "halo2-axiom", "display", "loader_evm", "loader_halo2", -], git = "https://github.com/axiom-crypto/snark-verifier.git" } + "revm" +], git = "https://github.com/MynaWallet/snark-verifier.git", branch = "release-0.1.6-rc0" } x509-parser = { version = "0.15", features = ["verify"] } openssl = "0.10" num-traits = "0.2.15" @@ -50,6 +38,9 @@ tokio = { version = "1.16", features = [ "rt-multi-thread", "macros", ] } +pse-poseidon = { git = "https://github.com/axiom-crypto/pse-poseidon.git" } +halo2-sha256-unoptimized = { git = "https://github.com/MynaWallet/halo2-sha256-unoptimized.git" } +bincode = "1" [target.'cfg(target_family = "wasm")'.dependencies] getrandom = { version = "0.2", features = ["js"] } @@ -65,4 +56,4 @@ criterion = "0.4" default = ["halo2-axiom", "display"] display = ["halo2-base/display"] halo2-pse = ["halo2-base/halo2-pse"] -halo2-axiom = ["halo2-base/halo2-axiom"] +halo2-axiom = ["halo2-base/halo2-axiom"] \ No newline at end of file diff --git a/packages/halo2-circuits/README.md b/packages/halo2-circuits/README.md index b162acc..481965c 100644 --- a/packages/halo2-circuits/README.md +++ b/packages/halo2-circuits/README.md @@ -57,23 +57,69 @@ You can refer to these repos of RSA verification circuits. - [zk-email-verify](https://github.com/zkemail/zk-email-verify) - [zkCert](https://github.com/zkCert/halo2-zkcert) -## Example Usage +# Usage +## For off-chain verification +### Create the directory where proofs are stored +```bash +mkdir -p build/app +``` + +### Generate the common reference string +```bash +cargo run app trusted-setup +``` + +### Generate pk & vk +```bash +cargo run app keys +``` + +### Generate a proof +```bash +cargo run app prove +``` +### Run the verification code written in Rust +```bash +cargo run app verify +``` + +### Run the verification code written in Solidity +This fails because of the big proof size. +```bash +cargo run app evm +``` + +## For on-chain verification +Run `cargo run app keys` first. + +### Create the directory where proofs are stored +```bash +mkdir -p build/agg +``` + +### Generate a proof that's ready to be aggregated +```bash +cargo run app snark +``` +### Generate pk & vk ```bash -# `k`: degree that expresses the size of circuit (i.e., 2^k is the number of rows in the circuit) -cargo run -r gen-params --k 17 +cargo run agg keys ``` +### Generate a proof ```bash -cargo run -r gen-rsa-keys # generate pk +cargo run agg prove ``` +### Run the verification code written in Rust ```bash -cargo run -r prove-rsa # verify rsa locally +cargo run agg verify ``` -You need to install solc 0.8.19 or 0.8.20 locally. +### Run the verification code written in Solidity +This succeeds because of the tiny proof size. ```bash -cargo run -r gen-rsa-verify-evm-proof # generate a verifier contract and proof inputs for evm +cargo run agg evm ``` diff --git a/packages/halo2-circuits/rustfmt.toml b/packages/halo2-circuits/rustfmt.toml new file mode 100644 index 0000000..8e98b09 --- /dev/null +++ b/packages/halo2-circuits/rustfmt.toml @@ -0,0 +1,14 @@ +edition = "2021" +version = "Two" +tab_spaces = 4 +use_small_heuristics = "Max" +max_width = 120 +wrap_comments = true +comment_width = 120 +format_code_in_doc_comments = true +doc_comment_code_block_width = 120 +normalize_doc_attributes = true +imports_granularity = "Crate" +hex_literal_case = "Upper" +condense_wildcard_suffixes = true +use_try_shorthand = true diff --git a/packages/halo2-circuits/src/bin/cli.rs b/packages/halo2-circuits/src/bin/cli.rs index 4ae51e7..205c493 100644 --- a/packages/halo2-circuits/src/bin/cli.rs +++ b/packages/halo2-circuits/src/bin/cli.rs @@ -1,18 +1,34 @@ use clap::{Parser, Subcommand}; use halo2_base::{ - gates::circuit::builder::BaseCircuitBuilder, halo2_proofs::halo2curves::bn256::Fr, - halo2_proofs::plonk::Circuit, utils::fs::gen_srs, + gates::circuit::{builder::BaseCircuitBuilder, CircuitBuilderStage}, + halo2_proofs::{ + halo2curves::bn256::{Bn256, Fr, G1Affine}, + plonk::{keygen_pk, keygen_vk, verify_proof, Circuit, VerifyingKey}, + poly::{ + commitment::Params, + kzg::{commitment::ParamsKZG, multiopen::VerifierSHPLONK, strategy::AccumulatorStrategy}, + }, + transcript::TranscriptReadBuffer, + SerdeFormat, + }, }; -use halo2_circuits::helpers::*; +use halo2_circuits::circuit; +use rand::rngs::OsRng; use snark_verifier_sdk::{ evm::{evm_verify, gen_evm_proof_shplonk, gen_evm_verifier_shplonk, write_calldata}, - gen_pk, - halo2::gen_snark_shplonk, - read_pk, CircuitExt, + halo2::{ + aggregation::{AggregationCircuit, AggregationConfigParams, VerifierUniversality}, + gen_snark_shplonk, read_snark, + }, + read_pk, + snark_verifier::system::halo2::transcript::evm::EvmTranscript, + CircuitExt, SHPLONK, +}; +use std::{ + fs::File, + io::{BufReader, BufWriter, Read, Write}, + path::Path, }; -use std::env; -use std::fs::remove_file; -use std::path::Path; #[derive(Parser, Debug, Clone)] #[command(author, version, about, long_about = None)] @@ -23,185 +39,484 @@ struct Cli { #[derive(Debug, Subcommand, Clone)] enum Commands { - /// Generate a setup paramter - GenParams { - /// k parameter for circuit. - #[arg(long)] - k: u32, - #[arg(short, long, default_value = "./params")] - params_path: String, + #[command(subcommand)] + App(AppCommands), + #[command(subcommand)] + Agg(AggCommands), +} + +#[derive(Debug, Subcommand, Clone)] +enum AppCommands { + /// Generate a trusted setup paramter + TrustedSetup { + /// trusted setup parameters path. input + #[arg(short, long, default_value = "./build/app/trusted_setup")] + trusted_setup_path: String, + }, + /// Generate the proving key and the verification key for RSA circuit + Keys { + /// trusted setup parameters path. input + #[arg(short, long, default_value = "./build/app/trusted_setup")] + trusted_setup_path: String, + /// verification key path. output + #[arg(long, default_value = "./build/app/vk")] + vk_path: String, + /// proving key path. output + #[arg(long, default_value = "./build/app/pk")] + pk_path: String, }, - /// Generate proving keys for RSA circuit - GenRsaKeys { - /// k parameter for circuit. - #[arg(long, default_value = "17")] - k: u32, - /// setup parameters path - #[arg(short, long, default_value = "./params")] - params_path: String, - /// proving key path - #[arg(long, default_value = "./build/rsa.pk")] + Prove { + /// trusted setup parameters path. input + #[arg(short, long, default_value = "./build/app/trusted_setup")] + trusted_setup_path: String, + /// proving key path. input + #[arg(long, default_value = "./build/app/pk")] pk_path: String, + /// proof path. output + #[arg(long, default_value = "./build/app/proof")] + proof_path: String, + // citizen's certificate. input #[arg(long, default_value = "./certs/myna_cert.pem")] verify_cert_path: String, + // nation's certificate. input #[arg(long, default_value = "./certs/ca_cert.pem")] issuer_cert_path: String, + #[arg(default_value = "42")] + password: u64, }, - ProveRsa { - /// k parameter for circuit. - #[arg(long, default_value = "17")] - k: u32, - /// setup parameters path - #[arg(short, long, default_value = "./params")] - params_path: String, - /// proving key path - #[arg(long, default_value = "./build/rsa.pk")] - pk_path: String, + Verify { + /// trusted setup parameters path. input + #[arg(short, long, default_value = "./build/app/trusted_setup")] + trusted_setup_path: String, + /// verification key path. input + #[arg(long, default_value = "./build/app/vk")] + vk_path: String, + /// proof path. input + #[arg(long, default_value = "./build/app/proof")] + proof_path: String, + // citizen's certificate. inut #[arg(long, default_value = "./certs/myna_cert.pem")] verify_cert_path: String, + // nation's certificate. input #[arg(long, default_value = "./certs/ca_cert.pem")] issuer_cert_path: String, - /// output proof file - #[arg(long, default_value = "./build/myna_verify_rsa.proof")] + #[arg(default_value = "42")] + password: u64, + }, + Evm { + /// trusted setup parameters path. input + #[arg(short, long, default_value = "./build/app/trusted_setup")] + trusted_setup_path: String, + /// verification key path. input + #[arg(long, default_value = "./build/app/vk")] + vk_path: String, + /// proof path. input + #[arg(long, default_value = "./build/app/proof")] proof_path: String, + /// verifier.sol path. output + #[arg(short, long, default_value = "./build/app/verifier.sol")] + solidity_path: String, + /// calldata path. output + #[arg(long, default_value = "./build/app/calldata.txt")] + calldata_path: String, }, - GenRsaVerifyEVMProof { - /// k parameter for circuit. - #[arg(long, default_value = "17")] - k: u32, - /// setup parameters path - #[arg(short, long, default_value = "./params")] - params_path: String, - /// proving key path - #[arg(long, default_value = "./build/rsa.pk")] + Snark { + /// trusted setup parameters path. input + #[arg(short, long, default_value = "./build/app/trusted_setup")] + trusted_setup_path: String, + /// proving key path. input + #[arg(long, default_value = "./build/app/pk")] pk_path: String, + /// partial proof path. output + #[arg(long, default_value = "./build/app/snark")] + snark_path: String, + // citizen's certificate. input #[arg(long, default_value = "./certs/myna_cert.pem")] verify_cert_path: String, + // nation's certificate. input #[arg(long, default_value = "./certs/ca_cert.pem")] issuer_cert_path: String, - /// output proof file - #[arg(long, default_value = "./build/myna_verify_rsa.proof")] + #[arg(default_value = "42")] + password: u64, + }, +} + +#[derive(Debug, Subcommand, Clone)] +enum AggCommands { + /// Generate a trusted setup paramter + TrustedSetup { + /// trusted setup parameters path. input + #[arg(short, long, default_value = "./build/agg/trusted_setup")] + trusted_setup_path: String, + }, + Keys { + /// trusted setup parameters path. input + #[arg(short, long, default_value = "./build/agg/trusted_setup")] + trusted_setup_path: String, + /// partial proof path. input + #[arg(long, default_value = "./build/app/snark")] + snark_path: String, + /// verification key path. output + #[arg(long, default_value = "./build/agg/vk")] + vk_path: String, + /// proving key path. output + #[arg(long, default_value = "./build/agg/pk")] + pk_path: String, + /// break points path. output + #[arg(long, default_value = "./build/agg/break_points")] + break_points_path: String, + }, + Prove { + /// trusted setup parameters path. input + #[arg(short, long, default_value = "./build/agg/trusted_setup")] + trusted_setup_path: String, + /// proving key path. input + #[arg(long, default_value = "./build/agg/pk")] + pk_path: String, + /// partial proof path. input + #[arg(long, default_value = "./build/app/snark")] + snark_path: String, + /// break points path. input + #[arg(long, default_value = "./build/agg/break_points")] + break_points_path: String, + /// proof path. output + #[arg(long, default_value = "./build/agg/proof")] proof_path: String, }, + Verify { + /// trusted setup parameters path. input + #[arg(short, long, default_value = "./build/agg/trusted_setup")] + trusted_setup_path: String, + /// verification key path. input + #[arg(long, default_value = "./build/agg/vk")] + vk_path: String, + /// proof path. input + #[arg(long, default_value = "./build/agg/proof")] + proof_path: String, + /// partial proof path. input + #[arg(long, default_value = "./build/app/snark")] + snark_path: String, + }, + Evm { + /// trusted setup parameters path. input + #[arg(short, long, default_value = "./build/agg/trusted_setup")] + trusted_setup_path: String, + /// verification key path. input + #[arg(long, default_value = "./build/agg/vk")] + vk_path: String, + /// proof path. input + #[arg(long, default_value = "./build/agg/proof")] + proof_path: String, + /// partial proof path. input + #[arg(long, default_value = "./build/app/snark")] + snark_path: String, + /// verifier.sol path. output + #[arg(short, long, default_value = "./build/agg/verifier.sol")] + solidity_path: String, + /// calldata path. output + #[arg(long, default_value = "./build/agg/calldata.txt")] + calldata_path: String, + }, } -#[tokio::main] -async fn main() { +const AGGREGATION_CONFIG: AggregationConfigParams = + AggregationConfigParams { degree: 23, num_advice: 7, num_fixed: 1, num_lookup_advice: 1, lookup_bits: 22 }; + +fn main() { let cli = Cli::parse(); match cli.command { - Commands::GenParams { k, params_path } => { - env::set_var("PARAMS_DIR", params_path); - gen_srs(k); - } - Commands::GenRsaKeys { - k, - params_path, - pk_path, - verify_cert_path, - issuer_cert_path, - } => { - env::set_var("PARAMS_DIR", params_path); - let params = gen_srs(k); - - let (tbs, signature_bigint) = extract_tbs_and_sig(&verify_cert_path); - let public_key_modulus = extract_public_key(&issuer_cert_path); - - let builder = create_default_rsa_circuit_with_instances( - k as usize, - tbs, - public_key_modulus, - signature_bigint, - ); - - if Path::new(&pk_path).exists() { - match remove_file(&pk_path) { - Ok(_) => println!("File found, overwriting..."), - Err(e) => println!("An error occurred: {}", e), + Commands::App(command) => match command { + AppCommands::TrustedSetup { trusted_setup_path } => { + let trusted_setup_path = Path::new(&trusted_setup_path); + if trusted_setup_path.exists() { + println!("Trusted setup already exists. Overwriting..."); } + + let mut file = + BufWriter::new(File::create(trusted_setup_path).expect("Failed to create a trusted setup")); + let trusted_setup_file = ParamsKZG::::setup(circuit::K as u32, OsRng); + trusted_setup_file.write(&mut file).expect("Failed to write a trusted setup"); } - gen_pk(¶ms, &builder, Some(Path::new(&pk_path))); - } - Commands::ProveRsa { - k, - params_path, - pk_path, - verify_cert_path, - issuer_cert_path, - proof_path, - } => { - env::set_var("PARAMS_DIR", params_path); - let params = gen_srs(k); - - let (tbs, signature_bigint) = extract_tbs_and_sig(&verify_cert_path); - let public_key_modulus = extract_public_key(&issuer_cert_path); - - let builder = create_default_rsa_circuit_with_instances( - k as usize, - tbs, - public_key_modulus, - signature_bigint, - ); - let pk = - read_pk::>(Path::new(&pk_path), builder.params()).unwrap(); - - if Path::new(&proof_path).exists() { - match remove_file(&proof_path) { - Ok(_) => println!("File found, overwriting..."), - Err(e) => println!("An error occurred: {}", e), - } + AppCommands::Keys { trusted_setup_path, pk_path, vk_path } => { + let circuit = circuit::ProofOfJapaneseResidence::new( + "./certs/ca_cert.pem".into(), + "./certs/myna_cert.pem".into(), + 0xA42.into(), + ); + + let mut trusted_setup_file = File::open(trusted_setup_path).expect("Couldn't open the trusted setup"); + let trusted_setup = + ParamsKZG::::read_custom(&mut trusted_setup_file, SerdeFormat::RawBytes).unwrap(); + + let vk = keygen_vk(&trusted_setup, &circuit).unwrap(); + let mut vk_file = BufWriter::new(File::create(vk_path).unwrap()); + vk.write(&mut vk_file, SerdeFormat::RawBytes).unwrap(); + + let pk = keygen_pk(&trusted_setup, vk, &circuit).unwrap(); + let mut pk_file = BufWriter::new(File::create(pk_path).unwrap()); + pk.write(&mut pk_file, SerdeFormat::RawBytes).unwrap(); + } + AppCommands::Prove { + verify_cert_path, + issuer_cert_path, + password, + trusted_setup_path, + pk_path, + proof_path, + } => { + let circuit = circuit::ProofOfJapaneseResidence::new( + issuer_cert_path.into(), + verify_cert_path.into(), + password.into(), + ); + let instance_column = circuit.instance_column(); + + let mut trusted_setup_file = File::open(trusted_setup_path).expect("Couldn't open the trusted setup"); + let trusted_setup = + ParamsKZG::::read_custom(&mut trusted_setup_file, SerdeFormat::RawBytes).unwrap(); + + let pk = read_pk::(pk_path.as_ref(), circuit.params()) + .expect("pk not found"); + + let mut proof_file = BufWriter::new(File::create(proof_path).unwrap()); + let proof = gen_evm_proof_shplonk(&trusted_setup, &pk, circuit, vec![instance_column]); + proof_file.write_all(&proof).unwrap(); } - gen_snark_shplonk(¶ms, &pk, builder.clone(), Some(Path::new(&proof_path))); - } - Commands::GenRsaVerifyEVMProof { - k, - params_path, - pk_path, - verify_cert_path, - issuer_cert_path, - proof_path, - } => { - env::set_var("PARAMS_DIR", params_path); - let params = gen_srs(k); - - let (tbs, signature_bigint) = extract_tbs_and_sig(&verify_cert_path); - let public_key_modulus = extract_public_key(&issuer_cert_path); - - let builder = create_default_rsa_circuit_with_instances( - k as usize, - tbs, - public_key_modulus, - signature_bigint, - ); - let pk = - read_pk::>(Path::new(&pk_path), builder.params()).unwrap(); - - if Path::new(&proof_path).exists() { - match remove_file(&proof_path) { - Ok(_) => println!("File found, overwriting..."), - Err(e) => println!("An error occurred: {}", e), + AppCommands::Verify { + proof_path, + verify_cert_path, + issuer_cert_path, + password, + trusted_setup_path, + vk_path, + } => { + let circuit = circuit::ProofOfJapaneseResidence::new( + issuer_cert_path.into(), + verify_cert_path.into(), + password.into(), + ); + + let mut trusted_setup_file = File::open(trusted_setup_path).expect("Couldn't open the trusted setup"); + let trusted_setup = + ParamsKZG::::read_custom(&mut trusted_setup_file, SerdeFormat::RawBytes).unwrap(); + + let mut vk_file = File::open(vk_path).expect("vk not found."); + let vk = VerifyingKey::::read::<_, circuit::ProofOfJapaneseResidence>( + &mut vk_file, + SerdeFormat::RawBytes, + circuit.params(), + ) + .unwrap(); + + let proof_file = File::open(&proof_path).unwrap(); + let mut proof = TranscriptReadBuffer::<_, _, _>::init(&proof_file); + let result = verify_proof::<_, VerifierSHPLONK<'_, Bn256>, _, EvmTranscript<_, _, _, _>, _>( + &trusted_setup, + &vk, + AccumulatorStrategy::new(&trusted_setup), + &[&[&circuit.instance_column()]], + &mut proof, + ); + assert!(result.is_ok(), "Verification failed!"); + println!("Verification succeeded!"); + } + AppCommands::Evm { trusted_setup_path, vk_path, proof_path, solidity_path, calldata_path } => { + let circuit = circuit::ProofOfJapaneseResidence::new( + "./certs/ca_cert.pem".into(), + "./certs/myna_cert.pem".into(), + 0xA42.into(), + ); + + let mut trusted_setup_file = File::open(trusted_setup_path).expect("Couldn't open the trusted setup"); + let trusted_setup = + ParamsKZG::::read_custom(&mut trusted_setup_file, SerdeFormat::RawBytes).unwrap(); + + let mut proof_file = File::open(&proof_path).expect("proof not found."); + let mut proof: Vec = Vec::new(); + proof_file.read_to_end(&mut proof).unwrap(); + + let mut vk_file = File::open(vk_path).expect("vk not found."); + let vk = VerifyingKey::::read::<_, circuit::ProofOfJapaneseResidence>( + &mut vk_file, + SerdeFormat::RawBytes, + circuit.params(), + ) + .unwrap(); + + write_calldata(&[circuit.instance_column()], &proof, Path::new(&calldata_path)).unwrap(); + + let verifier = gen_evm_verifier_shplonk::>( + &trusted_setup, + &vk, + vec![circuit.instance_column().len()], + Some(Path::new(&solidity_path)), + ); + + evm_verify(verifier, vec![circuit.instance_column()], proof.clone()); + } + AppCommands::Snark { + issuer_cert_path, + verify_cert_path, + password, + trusted_setup_path, + pk_path, + snark_path, + } => { + let circuit = circuit::ProofOfJapaneseResidence::new( + issuer_cert_path.into(), + verify_cert_path.into(), + password.into(), + ); + + let mut trusted_setup_file = File::open(trusted_setup_path).expect("Couldn't open the trusted setup"); + let trusted_setup = + ParamsKZG::::read_custom(&mut trusted_setup_file, SerdeFormat::RawBytes).unwrap(); + + let pk = read_pk::(pk_path.as_ref(), circuit.params()) + .expect("pk not found."); + + gen_snark_shplonk(&trusted_setup, &pk, circuit, Some(&snark_path)); + } + }, + Commands::Agg(command) => match command { + AggCommands::TrustedSetup { trusted_setup_path } => { + let trusted_setup_path = Path::new(&trusted_setup_path); + if trusted_setup_path.exists() { + println!("Trusted setup already exists. Overwriting..."); } + + let mut file = + BufWriter::new(File::create(trusted_setup_path).expect("Failed to create a trusted setup")); + let trusted_setup_file = ParamsKZG::::setup(AGGREGATION_CONFIG.degree, OsRng); + trusted_setup_file.write(&mut file).expect("Failed to write a trusted setup"); + } + AggCommands::Keys { trusted_setup_path, break_points_path, snark_path, pk_path, vk_path } => { + let snark = read_snark(&snark_path).expect("proof not found."); + + let mut trusted_setup_file = File::open(trusted_setup_path).expect("Couldn't open the trusted setup"); + let trusted_setup = + ParamsKZG::::read_custom(&mut trusted_setup_file, SerdeFormat::RawBytes).unwrap(); + + let circuit = AggregationCircuit::new::( + CircuitBuilderStage::Keygen, + AGGREGATION_CONFIG, + &trusted_setup, + vec![snark], + VerifierUniversality::None, + ); + + let vk = keygen_vk(&trusted_setup, &circuit).unwrap(); + let mut vk_file = BufWriter::new(File::create(vk_path).unwrap()); + vk.write(&mut vk_file, SerdeFormat::RawBytes).unwrap(); + + let pk = keygen_pk(&trusted_setup, vk, &circuit).unwrap(); + let mut pk_file = BufWriter::new(File::create(pk_path).unwrap()); + pk.write(&mut pk_file, SerdeFormat::RawBytes).unwrap(); + + let mut break_points_file = BufWriter::new(File::create(break_points_path).unwrap()); + bincode::serialize_into(&mut break_points_file, &circuit.break_points()).unwrap(); + } + AggCommands::Prove { trusted_setup_path, pk_path, break_points_path, snark_path, proof_path } => { + let mut trusted_setup_file = File::open(trusted_setup_path).expect("Couldn't open the trusted setup"); + let trusted_setup = + ParamsKZG::::read_custom(&mut trusted_setup_file, SerdeFormat::RawBytes).unwrap(); + + let pk = read_pk::(pk_path.as_ref(), AGGREGATION_CONFIG).expect("pk not found."); + let snark = read_snark(&snark_path).expect("proof not fonud."); + + let break_points_file = BufReader::new(File::open(break_points_path).expect("break points not found.")); + let break_points = bincode::deserialize_from(break_points_file).unwrap(); + + let circuit = AggregationCircuit::new::( + CircuitBuilderStage::Prover, + AGGREGATION_CONFIG, + &trusted_setup, + vec![snark], + VerifierUniversality::None, + ) + .use_break_points(break_points); + let instance_columns = circuit.instances(); + + let mut proof_file = BufWriter::new(File::create(proof_path).unwrap()); + let proof = gen_evm_proof_shplonk(&trusted_setup, &pk, circuit, instance_columns); + proof_file.write_all(&proof).unwrap(); } - gen_snark_shplonk(¶ms, &pk, builder.clone(), Some(Path::new(&proof_path))); + AggCommands::Verify { snark_path, proof_path, trusted_setup_path, vk_path } => { + let mut trusted_setup_file = File::open(trusted_setup_path).expect("Couldn't open the trusted setup"); + let trusted_setup = + ParamsKZG::::read_custom(&mut trusted_setup_file, SerdeFormat::RawBytes).unwrap(); - let deployment_code = gen_evm_verifier_shplonk::>( - ¶ms, - pk.get_vk(), - builder.num_instance(), - Some(Path::new("./build/VerifyRsa.sol")), - ); + let snark = read_snark(&snark_path).expect("proof not found."); - let proof = gen_evm_proof_shplonk(¶ms, &pk, builder.clone(), builder.instances()); + let circuit = AggregationCircuit::new::( + CircuitBuilderStage::Prover, + AGGREGATION_CONFIG, + &trusted_setup, + vec![snark], + VerifierUniversality::None, + ); - println!("Size of the contract: {} bytes", deployment_code.len()); - println!("Deploying contract..."); + let mut vk_file = File::open(vk_path).expect("vk not found."); + let vk = VerifyingKey::::read::<_, AggregationCircuit>( + &mut vk_file, + SerdeFormat::RawBytes, + AGGREGATION_CONFIG, + ) + .expect("vk not found."); - evm_verify(deployment_code, builder.instances(), proof.clone()); + let proof_file = File::open(&proof_path).expect("proof not found."); + let mut proof = TranscriptReadBuffer::<_, _, _>::init(&proof_file); - println!("Verification success!"); + let instances = circuit.instances(); + let instance_refs: Vec<&[Fr]> = instances.iter().map(|x| x.as_ref()).collect(); - write_calldata(&builder.instances(), &proof, Path::new("./build/calldata.txt")).unwrap(); - println!("Succesfully generate calldata!"); - - } + let result = verify_proof::<_, VerifierSHPLONK<'_, Bn256>, _, EvmTranscript<_, _, _, _>, _>( + &trusted_setup, + &vk, + AccumulatorStrategy::new(&trusted_setup), + &[&instance_refs], + &mut proof, + ); + assert!(result.is_ok(), "Verification failed!"); + println!("Verification succeeded!"); + } + AggCommands::Evm { trusted_setup_path, vk_path, proof_path, snark_path, solidity_path, calldata_path } => { + let mut trusted_setup_file = File::open(trusted_setup_path).expect("Couldn't open the trusted setup"); + let trusted_setup = + ParamsKZG::::read_custom(&mut trusted_setup_file, SerdeFormat::RawBytes).unwrap(); + + let snark = read_snark(&snark_path).expect("proof not found."); + + let mut vk_file = File::open(vk_path).expect("vk not found."); + let vk = VerifyingKey::::read::<_, AggregationCircuit>( + &mut vk_file, + SerdeFormat::RawBytes, + AGGREGATION_CONFIG, + ) + .expect("vk not found."); + + let mut proof_file = File::open(&proof_path).expect("proof not found."); + let mut proof: Vec = Vec::new(); + proof_file.read_to_end(&mut proof).unwrap(); + + let circuit = AggregationCircuit::new::( + CircuitBuilderStage::Prover, + AGGREGATION_CONFIG, + &trusted_setup, + vec![snark], + VerifierUniversality::None, + ); + + write_calldata(&circuit.instances(), &proof, Path::new(&calldata_path)).unwrap(); + + let verifier = gen_evm_verifier_shplonk::( + &trusted_setup, + &vk, + circuit.num_instance(), + Some(Path::new(&solidity_path)), + ); + evm_verify(verifier, circuit.instances(), proof); + } + }, } } diff --git a/packages/halo2-circuits/src/circuit.rs b/packages/halo2-circuits/src/circuit.rs new file mode 100644 index 0000000..a3abb4e --- /dev/null +++ b/packages/halo2-circuits/src/circuit.rs @@ -0,0 +1,354 @@ +use crate::helpers::{read_citizen_cert, read_nation_cert}; +use halo2_base::{ + gates::{ + circuit::{builder::BaseCircuitBuilder, BaseCircuitParams, BaseConfig}, + GateInstructions, RangeChip, RangeInstructions, + }, + halo2_proofs::{ + circuit::{Layouter, SimpleFloorPlanner}, + halo2curves::bn256::Fr, + plonk::{Circuit, ConstraintSystem, Error, Selector}, + }, + poseidon::hasher::{spec::OptimizedPoseidonSpec, PoseidonHasher}, + AssignedValue, Context, QuantumCell, +}; +use halo2_rsa::{BigUintConfig, BigUintInstructions, RSAConfig, RSAInstructions, RSAPubE, RSAPublicKey, RSASignature}; +use num_bigint::BigUint; +use num_traits::One; +use pse_poseidon::Poseidon; +use snark_verifier_sdk::CircuitExt; +use std::path::PathBuf; +use zkevm_hashes::sha256::vanilla::columns::Sha256CircuitConfig; + +#[derive(Debug, Clone)] +pub struct PublicInput { + // 2048 bits + pub nation_pubkey: BigUint, + // little endian + pub sha256: [Fr; 2], +} + +#[derive(Debug, Clone)] +pub struct PrivateInput { + // 2048 bits + pub nation_sig: BigUint, + pub password: Fr, +} + +const RSA_KEY_SIZE: usize = 2048; +const PUBKEY_BEGINS: usize = 2216; +const E: usize = 65537; +pub const K: usize = 12; +pub const LOOKUP_BITS: usize = K - 1; +const LIMB_BITS: usize = 64; +const SHA256_BLOCK_BITS: usize = 512; +const TBS_CERT_MAX_BITS: usize = 2048 * 8; + +pub fn biguint_to_fr(src: BigUint) -> Fr { + let mut buf = [0; 32]; + buf[0..src.to_bytes_le().len()].copy_from_slice(&src.to_bytes_le()); + Fr::from_bytes(&buf).expect("a BigUint was too big to fit in a Fr") +} + +pub fn slice_bits( + ctx: &mut Context, + range_chip: &RangeChip, + src_limbs: &[AssignedValue], + src_limb_width: usize, + dest_limb_width: usize, + since: usize, + until: usize, +) -> Vec> { + assert!(0 < src_limb_width); + assert!(0 < dest_limb_width); + assert!(254 > src_limb_width); + + assert!(254 > dest_limb_width); + let zero_part = (ctx.load_zero(), 0); + let mut parts: Vec<(AssignedValue, usize)> = Vec::new(); + + // split src into parts + let mut read_bits = since; + while read_bits < until { + let read_limbs = read_bits / src_limb_width; + let part_offset = read_bits % src_limb_width; + let part_width = (src_limb_width - read_bits % src_limb_width) + .min(dest_limb_width - (read_bits - since) % dest_limb_width) + .min(until - read_bits); + let part_biguint = (BigUint::from_bytes_le(&src_limbs[read_limbs].value().to_bytes()) >> part_offset) + % (BigUint::one() << part_width); + let part_witness = ctx.load_witness(biguint_to_fr(part_biguint)); + range_chip.range_check(ctx, part_witness, part_width); + parts.push((part_witness, part_width)); + read_bits += part_width; + } + + // constrain against dest + let mut dest_parts: Vec<(AssignedValue, usize)> = Vec::new(); + let mut dest_limbs: Vec> = Vec::new(); + for (i, part) in parts.iter().cloned().enumerate() { + dest_parts.push(part); + + if dest_parts.iter().map(|(_, part_width)| *part_width).sum::() == dest_limb_width + || i == parts.len() - 1 + { + let dest_limb = range_chip.gate().inner_product( + ctx, + dest_parts.iter().map(|(part_witness, _)| part_witness.clone()), + std::iter::once(&zero_part) + .chain(dest_parts.iter()) + .scan(BigUint::one(), |acc, (_, part_width)| { + *acc <<= *part_width; + Some(acc.clone()) + }) + .map(|part_base| QuantumCell::Constant(biguint_to_fr(part_base))), + ); + dest_limbs.push(dest_limb); + dest_parts.clear(); + } + } + + // constrain against src + let first_part_width = since % src_limb_width; + if 0 < first_part_width { + let first_part_witness = ctx.load_witness(biguint_to_fr( + BigUint::from_bytes_le(&src_limbs[since / src_limb_width].value().to_bytes()) + % (BigUint::one() << first_part_width), + )); + parts.insert(0, (first_part_witness, first_part_width)); + } else { + parts.insert(0, zero_part.clone()); + }; + + let last_part_offset = until % src_limb_width; + if 0 < last_part_offset { + let last_part_witness = ctx.load_witness(biguint_to_fr( + BigUint::from_bytes_le(&src_limbs[until / src_limb_width].value().to_bytes()) >> last_part_offset, + )); + let last_part_width = src_limb_width - last_part_offset; + parts.push((last_part_witness, last_part_width)); + } else { + parts.push(zero_part.clone()); + } + + let mut src_parts: Vec<(AssignedValue, usize)> = Vec::new(); + let mut read_limbs = since / src_limb_width; + for part in parts { + src_parts.push(part); + + if src_parts.iter().map(|(_, part_width)| *part_width).sum::() == src_limb_width { + let src_limb = range_chip.gate().inner_product( + ctx, + src_parts.iter().map(|(part_witness, _)| part_witness.clone()), + std::iter::once(&zero_part) + .chain(src_parts.iter()) + .scan(BigUint::one(), |acc, (_, part_width)| { + *acc <<= *part_width; + Some(acc.clone()) + }) + .map(|part_base| QuantumCell::Constant(biguint_to_fr(part_base))), + ); + + ctx.constrain_equal(&src_limbs[read_limbs], &src_limb); + src_parts.clear(); + read_limbs += 1; + } + } + + dest_limbs +} + +#[derive(Debug, Clone)] +pub struct Config { + halo2base: BaseConfig, + sha256: Sha256CircuitConfig, +} + +#[derive(Debug, Clone)] +pub struct ProofOfJapaneseResidence { + pub tbs_cert: Vec, + // 2048 bits + pub nation_sig: BigUint, + // 2048 bits + pub nation_pubkey: BigUint, + pub user_secret: Fr, + pub citizen_pubkey: BigUint, +} + +impl Circuit for ProofOfJapaneseResidence { + type Config = Config; + type Params = BaseCircuitParams; + type FloorPlanner = SimpleFloorPlanner; + + fn without_witnesses(&self) -> Self { + unreachable!() + } + + fn params(&self) -> Self::Params { + Self::Params { + k: K, + num_advice_per_phase: vec![101], + num_fixed: 1, + num_lookup_advice_per_phase: vec![6, 0, 0], + lookup_bits: Some(LOOKUP_BITS), + num_instance_columns: 1, + } + } + + fn configure_with_params(meta: &mut ConstraintSystem, params: BaseCircuitParams) -> Self::Config { + Self::Config { halo2base: BaseConfig::configure(meta, params), sha256: Sha256CircuitConfig::new(meta) } + } + + fn configure(_: &mut ConstraintSystem) -> Self::Config { + unreachable!("halo2-base says I must not call configure"); + } + + fn synthesize(&self, config: Self::Config, mut layouter: impl Layouter) -> Result<(), Error> { + dbg!(self.tbs_cert.len()); + + let mut assigned_blocks = Vec::new(); + layouter.assign_region( + || "SHA256", + |mut region| { + assigned_blocks = config.sha256.multi_sha256( + &mut region, + vec![self.tbs_cert.clone()], + Some(TBS_CERT_MAX_BITS / SHA256_BLOCK_BITS), + ); + Ok(()) + }, + )?; + + // let mut final_block = None; + // for (i, block) in assigned_blocks.iter().enumerate() { + // block.is_final().value().map(|is_final| { + // if Fr::zero() < is_final.evaluate() { + // final_block = Some(block); + // } + // }); + + // // if let Some(_) = final_block { + // // dbg!(i); + // // break; + // // } + // } + // let final_block = final_block.expect("zkevm-hashes failed to generate a SHA256 hash"); + + // The final block appears in [20] because of the length of certs/myna_cert.pem. + // TODO: Support pem with dynamic length. + let sha256out = &assigned_blocks[20].output(); + + let mut halo2base = BaseCircuitBuilder::new(false).use_params(self.params()); + + let mut lock = halo2base.core_mut().copy_manager.lock().unwrap(); + let sha256lo = lock.load_external_assigned(sha256out.lo()); + let sha256hi = lock.load_external_assigned(sha256out.hi()); + let tbs_cert_32s: Vec> = assigned_blocks + .iter() + .flat_map(|assigned_block| { + assigned_block.word_values().clone().map(|cell| lock.load_external_assigned(cell)) + }) + .collect(); + std::mem::drop(lock); + + let range_chip = halo2base.range_chip(); + let ctx = halo2base.main(0); + + let biguint_chip: BigUintConfig = BigUintConfig::construct(range_chip.clone(), LIMB_BITS); + let rsa_chip = RSAConfig::construct(biguint_chip, RSA_KEY_SIZE, 5); + let mut poseidon = PoseidonHasher::new(OptimizedPoseidonSpec::::new::<8, 57, 0>()); + poseidon.initialize_consts(ctx, rsa_chip.gate()); + + // load public inputs + let nation_pubkey = rsa_chip + .assign_public_key(ctx, RSAPublicKey::new(self.nation_pubkey.clone(), RSAPubE::Fix(E.into()))) + .unwrap(); + + // load private inputs + let nation_sig = rsa_chip.assign_signature(ctx, RSASignature::new(self.nation_sig.clone())).unwrap(); + let user_secret = ctx.load_witness(self.user_secret); + + let sha256ed_64s = slice_bits(ctx, rsa_chip.range(), &[sha256lo, sha256hi], 128, 64, 0, 256); + let is_nation_sig_valid = + rsa_chip.verify_pkcs1v15_signature(ctx, &nation_pubkey, &sha256ed_64s, &nation_sig).unwrap(); + rsa_chip.biguint_config().gate().assert_is_const(ctx, &is_nation_sig_valid, &Fr::one()); + + let mut identity_commitment_preimage = vec![user_secret]; + let citizen_pubkey = + slice_bits(ctx, rsa_chip.range(), &tbs_cert_32s, 32, 253, PUBKEY_BEGINS, PUBKEY_BEGINS + RSA_KEY_SIZE); + identity_commitment_preimage.extend(citizen_pubkey); + let identity_commitment = poseidon.hash_fix_len_array(ctx, rsa_chip.gate(), &identity_commitment_preimage); + + halo2base.assigned_instances[0].extend(nation_pubkey.n.limbs().to_vec()); + halo2base.assigned_instances[0].push(identity_commitment); + + dbg!(halo2base.calculate_params(None)); + halo2base.synthesize(config.halo2base, layouter).unwrap(); + + Ok(()) + } +} + +impl ProofOfJapaneseResidence { + pub fn new(nation_cert_path: PathBuf, citizen_cert_path: PathBuf, user_secret: Fr) -> Self { + let nation_pubkey = read_nation_cert(nation_cert_path.to_str().unwrap()); + let (nation_sig, tbs_cert, citizen_pubkey) = read_citizen_cert(citizen_cert_path.to_str().unwrap()); + + Self { tbs_cert: tbs_cert.to_bytes_le(), user_secret, nation_sig, nation_pubkey, citizen_pubkey } + } + + pub fn instance_column(&self) -> Vec { + let mut instance_column: Vec = self.nation_pubkey.iter_u64_digits().map(Fr::from).collect(); + let mut hasher = Poseidon::::new(8, 57); + let mut preimage = vec![self.user_secret]; + + for i in 0..=(2048 / 253) { + let limb = (self.citizen_pubkey.clone() >> (i * 253)) % (BigUint::one() << 253); + preimage.push(biguint_to_fr(limb)); + } + + hasher.update(&preimage); + let identity_commitment = hasher.squeeze(); + instance_column.push(identity_commitment); + + instance_column + } +} + +impl CircuitExt for ProofOfJapaneseResidence { + /// Return the number of instances of the circuit. + /// This may depend on extra circuit parameters but NOT on private witnesses. + fn num_instance(&self) -> Vec { + vec![self.instance_column().len()] + } + + fn instances(&self) -> Vec> { + vec![self.instance_column()] + } + + fn accumulator_indices() -> Option> { + None + } + + /// Output the simple selector columns (before selector compression) of the circuit + fn selectors(config: &Self::Config) -> Vec { + config.halo2base.gate().basic_gates[0].iter().map(|basic| basic.q_enable).collect() + } +} + +#[cfg(test)] +mod tests { + use super::*; + use halo2_base::halo2_proofs::dev::MockProver; + + #[test] + fn mock() { + let circuit = + ProofOfJapaneseResidence::new("./certs/ca_cert.pem".into(), "./certs/myna_cert.pem".into(), 0xA42.into()); + let instance_column = circuit.instance_column(); + + MockProver::run(K as u32, &circuit, vec![instance_column]) + .expect("The circuit generation failed") + .assert_satisfied(); + } +} diff --git a/packages/halo2-circuits/src/helpers.rs b/packages/halo2-circuits/src/helpers.rs index 8f05158..b6f6057 100644 --- a/packages/halo2-circuits/src/helpers.rs +++ b/packages/halo2-circuits/src/helpers.rs @@ -1,43 +1,15 @@ -use halo2_base::{ - gates::{circuit::builder::BaseCircuitBuilder, GateInstructions}, - halo2_proofs::halo2curves::bn256::Fr, - utils::fs::gen_srs, - AssignedValue, - QuantumCell::{Constant, Existing}, -}; -use halo2_rsa::{ - BigUintConfig, BigUintInstructions, RSAConfig, RSAInstructions, RSAPubE, RSAPublicKey, - RSASignature, -}; -use halo2_sha256_unoptimized::Sha256Chip; -use snark_verifier_sdk::{gen_pk, halo2::gen_snark_shplonk, Snark}; - -use itertools::Itertools; use num_bigint::BigUint; -use openssl::ssl::{SslConnector, SslMethod}; -use sha2::{Digest, Sha256}; -use std::fs::File; -use std::io::Read; -use std::io::Write; -use std::net::TcpStream; -use std::vec; -use x509_parser::pem::parse_x509_pem; -use x509_parser::public_key::PublicKey; +use std::{fs::File, io::Read}; +use x509_parser::{pem::parse_x509_pem, public_key::PublicKey}; -pub fn extract_public_key(cert_path: &str) -> BigUint { +pub fn read_nation_cert(cert_path: &str) -> BigUint { println!("{:?}", cert_path); let mut cert_file = File::open(cert_path).expect("Failed to open cert pem file"); let mut cert_pem_buffer = Vec::new(); - cert_file - .read_to_end(&mut cert_pem_buffer) - .expect("Failed to read cert PEM file"); + cert_file.read_to_end(&mut cert_pem_buffer).expect("Failed to read cert PEM file"); - let cert_pem = parse_x509_pem(&cert_pem_buffer) - .expect("Failed to parse cert") - .1; - let cert = cert_pem - .parse_x509() - .expect("Failed to parse PEM certificate"); + let cert_pem = parse_x509_pem(&cert_pem_buffer).expect("Failed to parse cert").1; + let cert = cert_pem.parse_x509().expect("Failed to parse PEM certificate"); match cert.public_key().parsed().unwrap() { PublicKey::RSA(public_key) => BigUint::from_bytes_be(public_key.modulus), @@ -45,105 +17,32 @@ pub fn extract_public_key(cert_path: &str) -> BigUint { } } -pub fn extract_tbs_and_sig(cert_path: &str) -> (Vec, BigUint) { +// returns +// - nation's signature +// - citizen's tbs certificate +// - citizen's public key +pub fn read_citizen_cert(cert_path: &str) -> (BigUint, BigUint, BigUint) { // Read the PEM certificate from a file let mut cert_file = File::open(cert_path).expect("Failed to open PEM file"); let mut cert_pem_buffer = Vec::new(); - cert_file - .read_to_end(&mut cert_pem_buffer) - .expect("Failed to read PEM file"); + cert_file.read_to_end(&mut cert_pem_buffer).expect("Failed to read PEM file"); // Parse the PEM certificate using x509-parser - let cert_pem = parse_x509_pem(&cert_pem_buffer) - .unwrap_or_else(|e| panic!("Failed to parse PEM ${:?} {:?}", &cert_path, e)) - .1; - let cert = cert_pem - .parse_x509() - .expect("Failed to parse PEM certificate"); + let cert_pem = + parse_x509_pem(&cert_pem_buffer).unwrap_or_else(|e| panic!("Failed to parse PEM ${:?} {:?}", &cert_path, e)).1; + let cert = cert_pem.parse_x509().expect("Failed to parse PEM certificate"); // Extract the TBS (To-Be-Signed) data from the certificate - let tbs = cert.tbs_certificate.as_ref(); + let tbs_bytes = cert.tbs_certificate.as_ref(); + let tbs_biguint = BigUint::from_bytes_le(tbs_bytes); // println!("TBS (To-Be-Signed): {:x?}", tbs); // Extract the signature from cert 3 - let signature_bytes = &cert.signature_value; - let signature_bigint = BigUint::from_bytes_be(&signature_bytes.data); - // println!("Signature: {:?}", signature_bigint); - - (tbs.to_vec(), signature_bigint) -} - -pub fn create_default_rsa_circuit_with_instances( - k: usize, - tbs: Vec, - public_key_modulus: BigUint, - signature_bigint: BigUint, -) -> BaseCircuitBuilder { - // Circuit inputs - let limb_bits = 64; - let default_bits = 2048; - let exp_bits = 5; // UNUSED - let default_e = 65537_u32; - - let mut builder = BaseCircuitBuilder::new(false); - // Set rows - builder.set_k(k); - builder.set_lookup_bits(k - 1); - builder.set_instance_columns(1); - - let range = builder.range_chip(); - let ctx = builder.main(0); - - let bigint_chip = BigUintConfig::construct(range.clone(), limb_bits); - let rsa_chip = RSAConfig::construct(bigint_chip.clone(), default_bits, exp_bits); - - // Hash in pure Rust vs in-circuit - let hashed_tbs = Sha256::digest(tbs); - println!("Hashed TBS: {:?}", hashed_tbs); - let mut hashed_bytes: Vec> = hashed_tbs - .iter() - .map(|limb| ctx.load_witness(Fr::from(*limb as u64))) - .collect_vec(); - hashed_bytes.reverse(); - let bytes_bits = hashed_bytes.len() * 8; - let limb_bits = bigint_chip.limb_bits(); - let limb_bytes = limb_bits / 8; - let mut hashed_u64s = vec![]; - let bases = (0..limb_bytes) - .map(|i| Fr::from(1u64 << (8 * i))) - .map(Constant) - .collect_vec(); - for i in 0..(bytes_bits / limb_bits) { - let left = hashed_bytes[limb_bytes * i..limb_bytes * (i + 1)] - .iter() - .map(|x| Existing(*x)) - .collect_vec(); - let sum = bigint_chip.gate().inner_product(ctx, left, bases.clone()); - hashed_u64s.push(sum); - } - - // Generate values to be fed into the circuit (Pure Rust) - // Verify Cert - let e_fix = RSAPubE::Fix(BigUint::from(default_e)); - let public_key = RSAPublicKey::new(public_key_modulus.clone(), e_fix); // cloning might be slow - let public_key = rsa_chip.assign_public_key(ctx, public_key).unwrap(); - - let signature = RSASignature::new(signature_bigint.clone()); // cloning might be slow - let signature = rsa_chip.assign_signature(ctx, signature).unwrap(); - - let is_valid = rsa_chip - .verify_pkcs1v15_signature(ctx, &public_key, &hashed_u64s, &signature) - .unwrap(); - rsa_chip - .biguint_config() - .gate() - .assert_is_const(ctx, &is_valid, &Fr::one()); + let nation_sig_bytes = &cert.signature_value; + let nation_sig_biguint = BigUint::from_bytes_be(&nation_sig_bytes.data); - // Insert input hash as public instance for circuit - hashed_bytes.reverse(); - builder.assigned_instances[0].extend(hashed_bytes); + let citizen_pubkey_bytes = cert.tbs_certificate.subject_pki.subject_public_key.as_ref(); + let citizen_pubkey_biguint = BigUint::from_bytes_le(&citizen_pubkey_bytes[9..256 + 9]); - let circuit_params = builder.calculate_params(Some(10)); - println!("Circuit params: {:?}", circuit_params); - builder.use_params(circuit_params) + (nation_sig_biguint, tbs_biguint, citizen_pubkey_biguint) } diff --git a/packages/halo2-circuits/src/lib.rs b/packages/halo2-circuits/src/lib.rs index da63098..2c13e3f 100644 --- a/packages/halo2-circuits/src/lib.rs +++ b/packages/halo2-circuits/src/lib.rs @@ -1,18 +1,2 @@ -use halo2_base::{ - gates::{ - circuit::{builder::BaseCircuitBuilder, BaseConfig, CircuitBuilderStage}, - flex_gate::MultiPhaseThreadBreakPoints, - }, - halo2_proofs::{ - circuit::{Layouter, SimpleFloorPlanner}, - halo2curves::bn256::{Bn256, Fr}, - plonk::{self, Circuit, ConstraintSystem, Selector}, - poly::kzg::commitment::ParamsKZG, - }, -}; -use itertools::Itertools; -use snark_verifier_sdk::{ - halo2::aggregation::{AggregationCircuit, AggregationConfigParams, VerifierUniversality}, - CircuitExt, Snark, SHPLONK, -}; +pub mod circuit; pub mod helpers;