diff --git a/.github/workflows/integration.yml b/.github/workflows/integration.yml index ff4831ea2..b86bb9f8b 100644 --- a/.github/workflows/integration.yml +++ b/.github/workflows/integration.yml @@ -184,6 +184,15 @@ jobs: CENO_CROSS_SHARD_LIMIT: 32 run: cargo run --release --package ceno_zkvm --features sanity-check --bin e2e -- --platform=ceno --max-cycle-per-shard=20000 --hints=10 --public-io=4191 examples/target/riscv32im-ceno-zkvm-elf/release/examples/fibonacci + - name: Download KZG params + run: | + if [ ! -f ceno_recursion/src/params/kzg_bn254_23.srs ]; then + curl -fL https://axiom-crypto.s3.amazonaws.com/challenge_0085/kzg_bn254_23.srs \ + -o ceno_recursion/src/params/kzg_bn254_23.srs + else + echo "KZG params already exist" + fi + - name: Run aggregation e2e env: RUSTFLAGS: "-C opt-level=3" diff --git a/.gitignore b/.gitignore index c123c75a3..267346272 100644 --- a/.gitignore +++ b/.gitignore @@ -15,3 +15,4 @@ docs/book # ceno serialized files *.bin *.json +*.srs \ No newline at end of file diff --git a/Cargo.lock b/Cargo.lock index de5c1dc7e..47609c526 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -63,7 +63,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "0cd9d29a6a0bb8d4832ff7685dcbb430011b832f2ccec1af9571a0e75c1f7e9c" dependencies = [ "alloy-eips", - "alloy-primitives", + "alloy-primitives 1.4.0", "alloy-rlp", "alloy-serde", "alloy-trie", @@ -87,7 +87,7 @@ version = "0.2.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "741bdd7499908b3aa0b159bba11e71c8cddd009a2c2eb7a06e825f1ec87900a5" dependencies = [ - "alloy-primitives", + "alloy-primitives 1.4.0", "alloy-rlp", "crc", "serde", @@ -100,7 +100,7 @@ version = "0.2.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "7b82752a889170df67bbb36d42ca63c531eb16274f0d7299ae2a680facba17bd" dependencies = [ - "alloy-primitives", + "alloy-primitives 1.4.0", "alloy-rlp", "serde", ] @@ -111,8 +111,9 @@ version = "0.6.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "9d4769c6ffddca380b0070d71c8b7f30bed375543fe76bb2f74ec0acf4b7cd16" dependencies = [ - "alloy-primitives", + "alloy-primitives 1.4.0", "alloy-rlp", + "k256 0.13.4 (registry+https://github.com/rust-lang/crates.io-index)", "serde", "thiserror 2.0.12", ] @@ -126,7 +127,7 @@ dependencies = [ "alloy-eip2124", "alloy-eip2930", "alloy-eip7702", - "alloy-primitives", + "alloy-primitives 1.4.0", "alloy-rlp", "alloy-serde", "auto_impl", @@ -135,10 +136,49 @@ dependencies = [ "either", "serde", "serde_with", - "sha2", + "sha2 0.10.9", "thiserror 2.0.12", ] +[[package]] +name = "alloy-json-abi" +version = "0.8.26" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4584e3641181ff073e9d5bec5b3b8f78f9749d9fb108a1cfbc4399a4a139c72a" +dependencies = [ + "alloy-primitives 0.8.26", + "alloy-sol-type-parser", + "serde", + "serde_json", +] + +[[package]] +name = "alloy-primitives" +version = "0.8.26" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "777d58b30eb9a4db0e5f59bc30e8c2caef877fee7dc8734cf242a51a60f22e05" +dependencies = [ + "alloy-rlp", + "bytes", + "cfg-if", + "const-hex", + "derive_more 2.0.1", + "foldhash 0.1.5", + "hashbrown 0.15.3", + "indexmap 2.9.0", + "itoa", + "k256 0.13.4 (registry+https://github.com/rust-lang/crates.io-index)", + "keccak-asm", + "paste", + "proptest", + "rand 0.8.5", + "ruint", + "rustc-hash 2.1.1", + "serde", + "sha3", + "tiny-keccak", +] + [[package]] name = "alloy-primitives" version = "1.4.0" @@ -160,7 +200,7 @@ dependencies = [ "proptest", "rand 0.9.2", "ruint", - "rustc-hash", + "rustc-hash 2.1.1", "serde", "sha3", "tiny-keccak", @@ -194,18 +234,92 @@ version = "1.0.36" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "19c3835bdc128f2f3418f5d6c76aec63a245d72973e0eaacc9720aa0787225c5" dependencies = [ - "alloy-primitives", + "alloy-primitives 1.4.0", "serde", "serde_json", ] +[[package]] +name = "alloy-sol-macro" +version = "0.8.26" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e68b32b6fa0d09bb74b4cefe35ccc8269d711c26629bc7cd98a47eeb12fe353f" +dependencies = [ + "alloy-sol-macro-expander", + "alloy-sol-macro-input", + "proc-macro-error2", + "proc-macro2", + "quote", + "syn 2.0.101", +] + +[[package]] +name = "alloy-sol-macro-expander" +version = "0.8.26" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2afe6879ac373e58fd53581636f2cce843998ae0b058ebe1e4f649195e2bd23c" +dependencies = [ + "alloy-json-abi", + "alloy-sol-macro-input", + "const-hex", + "heck", + "indexmap 2.9.0", + "proc-macro-error2", + "proc-macro2", + "quote", + "syn 2.0.101", + "syn-solidity", + "tiny-keccak", +] + +[[package]] +name = "alloy-sol-macro-input" +version = "0.8.26" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c3ba01aee235a8c699d07e5be97ba215607564e71be72f433665329bec307d28" +dependencies = [ + "alloy-json-abi", + "const-hex", + "dunce", + "heck", + "macro-string", + "proc-macro2", + "quote", + "serde_json", + "syn 2.0.101", + "syn-solidity", +] + +[[package]] +name = "alloy-sol-type-parser" +version = "0.8.26" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4c13fc168b97411e04465f03e632f31ef94cad1c7c8951bf799237fd7870d535" +dependencies = [ + "serde", + "winnow 0.7.13", +] + +[[package]] +name = "alloy-sol-types" +version = "0.8.26" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6e960c4b52508ef2ae1e37cae5058e905e9ae099b107900067a503f8c454036f" +dependencies = [ + "alloy-json-abi", + "alloy-primitives 0.8.26", + "alloy-sol-macro", + "const-hex", + "serde", +] + [[package]] name = "alloy-trie" version = "0.9.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "e3412d52bb97c6c6cc27ccc28d4e6e8cf605469101193b50b0bd5813b1f990b5" dependencies = [ - "alloy-primitives", + "alloy-primitives 1.4.0", "alloy-rlp", "arrayvec", "derive_more 2.0.1", @@ -221,7 +335,7 @@ version = "1.0.36" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "cc79013f9ac3a8ddeb60234d43da09e6d6abfc1c9dd29d3fe97adfbece3f4a08" dependencies = [ - "alloy-primitives", + "alloy-primitives 1.4.0", "darling 0.21.3", "proc-macro2", "quote", @@ -331,6 +445,7 @@ checksum = "d69eab57e8d2663efa5c63135b2af4f396d66424f88954c21104125ab6b3e6bc" dependencies = [ "ark-ec", "ark-ff 0.5.0", + "ark-r1cs-std", "ark-std 0.5.0", ] @@ -496,6 +611,35 @@ dependencies = [ "hashbrown 0.15.3", ] +[[package]] +name = "ark-r1cs-std" +version = "0.5.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "941551ef1df4c7a401de7068758db6503598e6f01850bdb2cfdb614a1f9dbea1" +dependencies = [ + "ark-ec", + "ark-ff 0.5.0", + "ark-relations", + "ark-std 0.5.0", + "educe", + "num-bigint 0.4.6", + "num-integer", + "num-traits", + "tracing", +] + +[[package]] +name = "ark-relations" +version = "0.5.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ec46ddc93e7af44bcab5230937635b06fb5744464dd6a7e7b083e80ebd274384" +dependencies = [ + "ark-ff 0.5.0", + "ark-std 0.5.0", + "tracing", + "tracing-subscriber 0.2.25", +] + [[package]] name = "ark-serialize" version = "0.3.0" @@ -785,6 +929,15 @@ dependencies = [ "constant_time_eq", ] +[[package]] +name = "block-buffer" +version = "0.9.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4152116fd6e9dadb291ae18fc1ec3575ed6d84c29642d97890f4b4a3417297e4" +dependencies = [ + "generic-array 0.14.7", +] + [[package]] name = "block-buffer" version = "0.10.4" @@ -953,7 +1106,7 @@ dependencies = [ "tikv-jemallocator", "tracing", "tracing-forest", - "tracing-subscriber", + "tracing-subscriber 0.3.19", "vergen-git2", ] @@ -1047,13 +1200,13 @@ name = "ceno_crypto" version = "0.1.0" dependencies = [ "alloy-consensus", - "alloy-primitives", + "alloy-primitives 1.4.0", "ceno_keccak", "ceno_sha2", "ceno_syscall", "k256 0.13.4 (git+https://github.com/scroll-tech/elliptic-curves?branch=ceno%2Fk256-13.4)", "p256 0.13.2 (git+https://github.com/scroll-tech/elliptic-curves?branch=ceno%2Fk256-13.4)", - "revm-precompile", + "revm-precompile 27.0.0", "substrate-bn 0.6.0 (git+https://github.com/scroll-tech/bn?branch=ceno)", "thiserror 2.0.12", ] @@ -1086,7 +1239,7 @@ dependencies = [ "p256 0.13.2 (git+https://github.com/scroll-tech/elliptic-curves?branch=ceno%2Fk256-13.4)", "rayon", "rrs-succinct", - "rustc-hash", + "rustc-hash 2.1.1", "secp", "serde", "smallvec", @@ -1125,6 +1278,7 @@ dependencies = [ name = "ceno_recursion" version = "0.1.0" dependencies = [ + "anyhow", "bincode 1.3.3", "ceno-examples", "ceno_emul", @@ -1157,7 +1311,7 @@ dependencies = [ "sumcheck", "tracing", "tracing-forest", - "tracing-subscriber", + "tracing-subscriber 0.3.19", "transcript", "whir", "witness", @@ -1233,7 +1387,7 @@ dependencies = [ "proptest", "rand 0.8.5", "rayon", - "rustc-hash", + "rustc-hash 2.1.1", "serde", "serde_json", "smallvec", @@ -1247,7 +1401,7 @@ dependencies = [ "tiny-keccak", "tracing", "tracing-forest", - "tracing-subscriber", + "tracing-subscriber 0.3.19", "transcript", "typenum", "whir", @@ -1694,6 +1848,7 @@ dependencies = [ "lock_api", "once_cell", "parking_lot_core", + "rayon", ] [[package]] @@ -1845,6 +2000,17 @@ dependencies = [ "syn 2.0.101", ] +[[package]] +name = "derive-where" +version = "1.6.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ef941ded77d15ca19b40374869ac6000af1c9f2a4c0f3d4c70926287e6364a8f" +dependencies = [ + "proc-macro2", + "quote", + "syn 2.0.101", +] + [[package]] name = "derive_builder" version = "0.20.2" @@ -1933,7 +2099,7 @@ version = "0.10.7" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "9ed9a281f7bc9b7576e61468ba615a66a5c8cfdff42420a70aa82701a3b1e292" dependencies = [ - "block-buffer", + "block-buffer 0.10.4", "const-oid", "crypto-common", "subtle", @@ -1992,6 +2158,12 @@ version = "0.0.6" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "f678cf4a922c215c63e0de95eb1ff08a958a81d47e485cf9da1e27bf6305cfa5" +[[package]] +name = "dunce" +version = "1.0.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "92773504d58c093f6de2459af4af33faa518c13451eb8f2b5698ed3d36e7c813" + [[package]] name = "dyn-clone" version = "1.0.20" @@ -2133,12 +2305,35 @@ dependencies = [ "windows-sys 0.59.0", ] +[[package]] +name = "ethbloom" +version = "0.13.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c22d4b5885b6aa2fe5e8b9329fb8d232bf739e434e6b87347c63bdd00c120f60" +dependencies = [ + "crunchy", + "fixed-hash", + "tiny-keccak", +] + +[[package]] +name = "ethereum-types" +version = "0.14.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "02d215cbf040552efcbe99a38372fe80ab9d00268e20012b79fcd0f073edd8ee" +dependencies = [ + "ethbloom", + "fixed-hash", + "primitive-types", + "uint", +] + [[package]] name = "examples" version = "0.1.0" dependencies = [ "alloy-consensus", - "alloy-primitives", + "alloy-primitives 1.4.0", "ceno_crypto", "ceno_crypto_primitives", "ceno_keccak", @@ -2149,7 +2344,7 @@ dependencies = [ "k256 0.13.4 (git+https://github.com/scroll-tech/elliptic-curves?branch=ceno%2Fk256-13.4)", "p256 0.13.2 (git+https://github.com/scroll-tech/elliptic-curves?branch=ceno%2Fk256-13.4)", "rand 0.8.5", - "revm-precompile", + "revm-precompile 27.0.0", "substrate-bn 0.6.0 (registry+https://github.com/rust-lang/crates.io-index)", "substrate-bn 0.6.0 (git+https://github.com/scroll-tech/bn?branch=ceno)", "tiny-keccak", @@ -2424,7 +2619,7 @@ dependencies = [ "tikv-jemallocator", "tracing", "tracing-forest", - "tracing-subscriber", + "tracing-subscriber 0.3.19", "transcript", "witness", ] @@ -2493,6 +2688,69 @@ dependencies = [ "halo2_proofs", ] +[[package]] +name = "halo2-axiom" +version = "0.5.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0aee3f8178b78275038e5ea0e2577140056d2c4c87fccaf6777dc0a8eebe455a" +dependencies = [ + "blake2b_simd", + "crossbeam", + "ff 0.13.1", + "group 0.13.0", + "halo2curves-axiom", + "itertools 0.11.0", + "maybe-rayon", + "pairing 0.23.0", + "rand 0.8.5", + "rand_core 0.6.4", + "rayon", + "rustc-hash 1.1.0", + "sha3", + "tracing", +] + +[[package]] +name = "halo2-base" +version = "0.5.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "678cf3adc0a39d7b4d9b82315a655201aa24a430dd1902b162c508047f56ac69" +dependencies = [ + "getset", + "halo2-axiom", + "itertools 0.11.0", + "log", + "num-bigint 0.4.6", + "num-integer", + "num-traits", + "poseidon-primitives", + "rand_chacha 0.3.1", + "rayon", + "rustc-hash 1.1.0", + "serde", + "serde_json", +] + +[[package]] +name = "halo2-ecc" +version = "0.5.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "645c00681fdd1febaf552d8814e9f5a6a142d81a1514102190da07039588b366" +dependencies = [ + "halo2-base", + "itertools 0.11.0", + "num-bigint 0.4.6", + "num-integer", + "num-traits", + "rand 0.8.5", + "rand_chacha 0.3.1", + "rand_core 0.6.4", + "rayon", + "serde", + "serde_json", + "test-case", +] + [[package]] name = "halo2_proofs" version = "0.1.0" @@ -2530,7 +2788,7 @@ dependencies = [ "rayon", "serde", "serde_arrays", - "sha2", + "sha2 0.10.9", "static_assertions", "subtle", "unroll", @@ -2558,7 +2816,7 @@ dependencies = [ "rayon", "serde", "serde_arrays", - "sha2", + "sha2 0.10.9", "static_assertions", "subtle", "unroll", @@ -2602,6 +2860,7 @@ dependencies = [ "allocator-api2", "equivalent", "foldhash 0.1.5", + "serde", ] [[package]] @@ -2928,6 +3187,15 @@ dependencies = [ "either", ] +[[package]] +name = "itertools" +version = "0.11.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b1c173a5686ce8bfa551b3563d0c2170bf24ca44da99c7ca4bfdab5418c3fe57" +dependencies = [ + "either", +] + [[package]] name = "itertools" version = "0.13.0" @@ -2996,7 +3264,7 @@ dependencies = [ "ecdsa 0.16.9 (registry+https://github.com/rust-lang/crates.io-index)", "elliptic-curve", "once_cell", - "sha2", + "sha2 0.10.9", "signature", ] @@ -3012,7 +3280,7 @@ dependencies = [ "elliptic-curve", "hex", "once_cell", - "sha2", + "sha2 0.10.9", ] [[package]] @@ -3087,6 +3355,52 @@ dependencies = [ "libc", ] +[[package]] +name = "libsecp256k1" +version = "0.7.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e79019718125edc905a079a70cfa5f3820bc76139fc91d6f9abc27ea2a887139" +dependencies = [ + "arrayref", + "base64", + "digest 0.9.0", + "libsecp256k1-core", + "libsecp256k1-gen-ecmult", + "libsecp256k1-gen-genmult", + "rand 0.8.5", + "serde", + "sha2 0.9.9", +] + +[[package]] +name = "libsecp256k1-core" +version = "0.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5be9b9bb642d8522a44d533eab56c16c738301965504753b03ad1de3425d5451" +dependencies = [ + "crunchy", + "digest 0.9.0", + "subtle", +] + +[[package]] +name = "libsecp256k1-gen-ecmult" +version = "0.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3038c808c55c87e8a172643a7d87187fc6c4174468159cb3090659d55bcb4809" +dependencies = [ + "libsecp256k1-core", +] + +[[package]] +name = "libsecp256k1-gen-genmult" +version = "0.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3db8d6ba2cec9eacc40e6e8ccc98931840301f1006e95647ceb2dd5c3aa06f7c" +dependencies = [ + "libsecp256k1-core", +] + [[package]] name = "libz-sys" version = "1.1.22" @@ -3142,6 +3456,17 @@ dependencies = [ "hashbrown 0.15.3", ] +[[package]] +name = "macro-string" +version = "0.1.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1b27834086c65ec3f9387b096d66e99f221cf081c2b738042aa252bcd41204e3" +dependencies = [ + "proc-macro2", + "quote", + "syn 2.0.101", +] + [[package]] name = "matchers" version = "0.1.0" @@ -3161,6 +3486,16 @@ dependencies = [ "rawpointer", ] +[[package]] +name = "maybe-rayon" +version = "0.1.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8ea1f30cedd69f0a2954655f7188c6a834246d2bcf1e315e2ac40c4b24dc9519" +dependencies = [ + "cfg-if", + "rayon", +] + [[package]] name = "memchr" version = "2.7.4" @@ -3206,7 +3541,7 @@ dependencies = [ "once_cell", "tracing", "tracing-core", - "tracing-subscriber", + "tracing-subscriber 0.3.19", ] [[package]] @@ -3255,7 +3590,7 @@ dependencies = [ "serde", "sumcheck", "tracing", - "tracing-subscriber", + "tracing-subscriber 0.3.19", "transcript", "whir", "witness", @@ -3524,6 +3859,7 @@ version = "0.7.4" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "77e878c846a8abae00dd069496dbe8751b16ac1c3d6bd2a7283a938e8228f90d" dependencies = [ + "proc-macro-crate 3.4.0", "proc-macro2", "quote", "syn 2.0.101", @@ -3585,10 +3921,16 @@ version = "11.1.5" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "d6790f58c7ff633d8771f42965289203411a5e5c68388703c06e14f24770b41e" +[[package]] +name = "opaque-debug" +version = "0.3.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c08d65885ee38876c4f86fa503fb49d7b507c2b62552df7c70b2fce627e06381" + [[package]] name = "openvm" version = "1.4.1" -source = "git+https://github.com/scroll-tech/openvm.git?branch=feat%2Fv1.4.1-scroll-ext#ac5d1b48b46fc37981f56ed943fa4ae6fb580827" +source = "git+https://github.com/scroll-tech/openvm.git?branch=feat%2Foptional_native_sumcheck#efda734de94847b51d2fdde5fa112013f60c4875" dependencies = [ "bytemuck", "num-bigint 0.4.6", @@ -3601,7 +3943,7 @@ dependencies = [ [[package]] name = "openvm-algebra-circuit" version = "1.4.1" -source = "git+https://github.com/scroll-tech/openvm.git?branch=feat%2Fv1.4.1-scroll-ext#ac5d1b48b46fc37981f56ed943fa4ae6fb580827" +source = "git+https://github.com/scroll-tech/openvm.git?branch=feat%2Foptional_native_sumcheck#efda734de94847b51d2fdde5fa112013f60c4875" dependencies = [ "cfg-if", "derive-new 0.6.0", @@ -3630,7 +3972,7 @@ dependencies = [ [[package]] name = "openvm-algebra-complex-macros" version = "1.4.1" -source = "git+https://github.com/scroll-tech/openvm.git?branch=feat%2Fv1.4.1-scroll-ext#ac5d1b48b46fc37981f56ed943fa4ae6fb580827" +source = "git+https://github.com/scroll-tech/openvm.git?branch=feat%2Foptional_native_sumcheck#efda734de94847b51d2fdde5fa112013f60c4875" dependencies = [ "openvm-macros-common", "quote", @@ -3640,7 +3982,7 @@ dependencies = [ [[package]] name = "openvm-algebra-guest" version = "1.4.1" -source = "git+https://github.com/scroll-tech/openvm.git?branch=feat%2Fv1.4.1-scroll-ext#ac5d1b48b46fc37981f56ed943fa4ae6fb580827" +source = "git+https://github.com/scroll-tech/openvm.git?branch=feat%2Foptional_native_sumcheck#efda734de94847b51d2fdde5fa112013f60c4875" dependencies = [ "halo2curves-axiom", "num-bigint 0.4.6", @@ -3656,7 +3998,7 @@ dependencies = [ [[package]] name = "openvm-algebra-moduli-macros" version = "1.4.1" -source = "git+https://github.com/scroll-tech/openvm.git?branch=feat%2Fv1.4.1-scroll-ext#ac5d1b48b46fc37981f56ed943fa4ae6fb580827" +source = "git+https://github.com/scroll-tech/openvm.git?branch=feat%2Foptional_native_sumcheck#efda734de94847b51d2fdde5fa112013f60c4875" dependencies = [ "num-bigint 0.4.6", "num-prime", @@ -3668,7 +4010,7 @@ dependencies = [ [[package]] name = "openvm-algebra-transpiler" version = "1.4.1" -source = "git+https://github.com/scroll-tech/openvm.git?branch=feat%2Fv1.4.1-scroll-ext#ac5d1b48b46fc37981f56ed943fa4ae6fb580827" +source = "git+https://github.com/scroll-tech/openvm.git?branch=feat%2Foptional_native_sumcheck#efda734de94847b51d2fdde5fa112013f60c4875" dependencies = [ "openvm-algebra-guest", "openvm-instructions", @@ -3682,7 +4024,7 @@ dependencies = [ [[package]] name = "openvm-bigint-circuit" version = "1.4.1" -source = "git+https://github.com/scroll-tech/openvm.git?branch=feat%2Fv1.4.1-scroll-ext#ac5d1b48b46fc37981f56ed943fa4ae6fb580827" +source = "git+https://github.com/scroll-tech/openvm.git?branch=feat%2Foptional_native_sumcheck#efda734de94847b51d2fdde5fa112013f60c4875" dependencies = [ "cfg-if", "derive-new 0.6.0", @@ -3705,7 +4047,7 @@ dependencies = [ [[package]] name = "openvm-bigint-guest" version = "1.4.1" -source = "git+https://github.com/scroll-tech/openvm.git?branch=feat%2Fv1.4.1-scroll-ext#ac5d1b48b46fc37981f56ed943fa4ae6fb580827" +source = "git+https://github.com/scroll-tech/openvm.git?branch=feat%2Foptional_native_sumcheck#efda734de94847b51d2fdde5fa112013f60c4875" dependencies = [ "openvm-platform", "strum_macros", @@ -3714,7 +4056,7 @@ dependencies = [ [[package]] name = "openvm-bigint-transpiler" version = "1.4.1" -source = "git+https://github.com/scroll-tech/openvm.git?branch=feat%2Fv1.4.1-scroll-ext#ac5d1b48b46fc37981f56ed943fa4ae6fb580827" +source = "git+https://github.com/scroll-tech/openvm.git?branch=feat%2Foptional_native_sumcheck#efda734de94847b51d2fdde5fa112013f60c4875" dependencies = [ "openvm-bigint-guest", "openvm-instructions", @@ -3729,7 +4071,7 @@ dependencies = [ [[package]] name = "openvm-build" version = "1.4.1" -source = "git+https://github.com/scroll-tech/openvm.git?branch=feat%2Fv1.4.1-scroll-ext#ac5d1b48b46fc37981f56ed943fa4ae6fb580827" +source = "git+https://github.com/scroll-tech/openvm.git?branch=feat%2Foptional_native_sumcheck#efda734de94847b51d2fdde5fa112013f60c4875" dependencies = [ "cargo_metadata 0.18.1", "eyre", @@ -3741,7 +4083,7 @@ dependencies = [ [[package]] name = "openvm-circuit" version = "1.4.1" -source = "git+https://github.com/scroll-tech/openvm.git?branch=feat%2Fv1.4.1-scroll-ext#ac5d1b48b46fc37981f56ed943fa4ae6fb580827" +source = "git+https://github.com/scroll-tech/openvm.git?branch=feat%2Foptional_native_sumcheck#efda734de94847b51d2fdde5fa112013f60c4875" dependencies = [ "backtrace", "cfg-if", @@ -3769,7 +4111,7 @@ dependencies = [ "p3-baby-bear", "p3-field", "rand 0.8.5", - "rustc-hash", + "rustc-hash 2.1.1", "serde", "serde-big-array", "static_assertions", @@ -3780,7 +4122,7 @@ dependencies = [ [[package]] name = "openvm-circuit-derive" version = "1.4.1" -source = "git+https://github.com/scroll-tech/openvm.git?branch=feat%2Fv1.4.1-scroll-ext#ac5d1b48b46fc37981f56ed943fa4ae6fb580827" +source = "git+https://github.com/scroll-tech/openvm.git?branch=feat%2Foptional_native_sumcheck#efda734de94847b51d2fdde5fa112013f60c4875" dependencies = [ "itertools 0.14.0", "proc-macro2", @@ -3791,7 +4133,7 @@ dependencies = [ [[package]] name = "openvm-circuit-primitives" version = "1.4.1" -source = "git+https://github.com/scroll-tech/openvm.git?branch=feat%2Fv1.4.1-scroll-ext#ac5d1b48b46fc37981f56ed943fa4ae6fb580827" +source = "git+https://github.com/scroll-tech/openvm.git?branch=feat%2Foptional_native_sumcheck#efda734de94847b51d2fdde5fa112013f60c4875" dependencies = [ "derive-new 0.6.0", "itertools 0.14.0", @@ -3809,7 +4151,7 @@ dependencies = [ [[package]] name = "openvm-circuit-primitives-derive" version = "1.4.1" -source = "git+https://github.com/scroll-tech/openvm.git?branch=feat%2Fv1.4.1-scroll-ext#ac5d1b48b46fc37981f56ed943fa4ae6fb580827" +source = "git+https://github.com/scroll-tech/openvm.git?branch=feat%2Foptional_native_sumcheck#efda734de94847b51d2fdde5fa112013f60c4875" dependencies = [ "itertools 0.14.0", "quote", @@ -3819,7 +4161,7 @@ dependencies = [ [[package]] name = "openvm-continuations" version = "1.4.1" -source = "git+https://github.com/scroll-tech/openvm.git?branch=feat%2Fv1.4.1-scroll-ext#ac5d1b48b46fc37981f56ed943fa4ae6fb580827" +source = "git+https://github.com/scroll-tech/openvm.git?branch=feat%2Foptional_native_sumcheck#efda734de94847b51d2fdde5fa112013f60c4875" dependencies = [ "derivative", "openvm-circuit", @@ -3856,7 +4198,7 @@ dependencies = [ "p3-merkle-tree", "p3-symmetric", "p3-util", - "rustc-hash", + "rustc-hash 2.1.1", "serde", "serde_json", "thiserror 1.0.69", @@ -3889,7 +4231,7 @@ dependencies = [ [[package]] name = "openvm-custom-insn" version = "0.1.0" -source = "git+https://github.com/scroll-tech/openvm.git?branch=feat%2Fv1.4.1-scroll-ext#ac5d1b48b46fc37981f56ed943fa4ae6fb580827" +source = "git+https://github.com/scroll-tech/openvm.git?branch=feat%2Foptional_native_sumcheck#efda734de94847b51d2fdde5fa112013f60c4875" dependencies = [ "proc-macro2", "quote", @@ -3899,7 +4241,7 @@ dependencies = [ [[package]] name = "openvm-ecc-circuit" version = "1.4.1" -source = "git+https://github.com/scroll-tech/openvm.git?branch=feat%2Fv1.4.1-scroll-ext#ac5d1b48b46fc37981f56ed943fa4ae6fb580827" +source = "git+https://github.com/scroll-tech/openvm.git?branch=feat%2Foptional_native_sumcheck#efda734de94847b51d2fdde5fa112013f60c4875" dependencies = [ "cfg-if", "derive-new 0.6.0", @@ -3928,7 +4270,7 @@ dependencies = [ [[package]] name = "openvm-ecc-guest" version = "1.4.1" -source = "git+https://github.com/scroll-tech/openvm.git?branch=feat%2Fv1.4.1-scroll-ext#ac5d1b48b46fc37981f56ed943fa4ae6fb580827" +source = "git+https://github.com/scroll-tech/openvm.git?branch=feat%2Foptional_native_sumcheck#efda734de94847b51d2fdde5fa112013f60c4875" dependencies = [ "ecdsa 0.16.9 (registry+https://github.com/rust-lang/crates.io-index)", "elliptic-curve", @@ -3947,7 +4289,7 @@ dependencies = [ [[package]] name = "openvm-ecc-sw-macros" version = "1.4.1" -source = "git+https://github.com/scroll-tech/openvm.git?branch=feat%2Fv1.4.1-scroll-ext#ac5d1b48b46fc37981f56ed943fa4ae6fb580827" +source = "git+https://github.com/scroll-tech/openvm.git?branch=feat%2Foptional_native_sumcheck#efda734de94847b51d2fdde5fa112013f60c4875" dependencies = [ "openvm-macros-common", "quote", @@ -3957,7 +4299,7 @@ dependencies = [ [[package]] name = "openvm-ecc-transpiler" version = "1.4.1" -source = "git+https://github.com/scroll-tech/openvm.git?branch=feat%2Fv1.4.1-scroll-ext#ac5d1b48b46fc37981f56ed943fa4ae6fb580827" +source = "git+https://github.com/scroll-tech/openvm.git?branch=feat%2Foptional_native_sumcheck#efda734de94847b51d2fdde5fa112013f60c4875" dependencies = [ "openvm-ecc-guest", "openvm-instructions", @@ -3971,7 +4313,7 @@ dependencies = [ [[package]] name = "openvm-instructions" version = "1.4.1" -source = "git+https://github.com/scroll-tech/openvm.git?branch=feat%2Fv1.4.1-scroll-ext#ac5d1b48b46fc37981f56ed943fa4ae6fb580827" +source = "git+https://github.com/scroll-tech/openvm.git?branch=feat%2Foptional_native_sumcheck#efda734de94847b51d2fdde5fa112013f60c4875" dependencies = [ "backtrace", "derive-new 0.6.0", @@ -3988,7 +4330,7 @@ dependencies = [ [[package]] name = "openvm-instructions-derive" version = "1.4.1" -source = "git+https://github.com/scroll-tech/openvm.git?branch=feat%2Fv1.4.1-scroll-ext#ac5d1b48b46fc37981f56ed943fa4ae6fb580827" +source = "git+https://github.com/scroll-tech/openvm.git?branch=feat%2Foptional_native_sumcheck#efda734de94847b51d2fdde5fa112013f60c4875" dependencies = [ "quote", "syn 2.0.101", @@ -3997,7 +4339,7 @@ dependencies = [ [[package]] name = "openvm-keccak256-circuit" version = "1.4.1" -source = "git+https://github.com/scroll-tech/openvm.git?branch=feat%2Fv1.4.1-scroll-ext#ac5d1b48b46fc37981f56ed943fa4ae6fb580827" +source = "git+https://github.com/scroll-tech/openvm.git?branch=feat%2Foptional_native_sumcheck#efda734de94847b51d2fdde5fa112013f60c4875" dependencies = [ "cfg-if", "derive-new 0.6.0", @@ -4022,7 +4364,7 @@ dependencies = [ [[package]] name = "openvm-keccak256-guest" version = "1.4.1" -source = "git+https://github.com/scroll-tech/openvm.git?branch=feat%2Fv1.4.1-scroll-ext#ac5d1b48b46fc37981f56ed943fa4ae6fb580827" +source = "git+https://github.com/scroll-tech/openvm.git?branch=feat%2Foptional_native_sumcheck#efda734de94847b51d2fdde5fa112013f60c4875" dependencies = [ "openvm-platform", ] @@ -4030,7 +4372,7 @@ dependencies = [ [[package]] name = "openvm-keccak256-transpiler" version = "1.4.1" -source = "git+https://github.com/scroll-tech/openvm.git?branch=feat%2Fv1.4.1-scroll-ext#ac5d1b48b46fc37981f56ed943fa4ae6fb580827" +source = "git+https://github.com/scroll-tech/openvm.git?branch=feat%2Foptional_native_sumcheck#efda734de94847b51d2fdde5fa112013f60c4875" dependencies = [ "openvm-instructions", "openvm-instructions-derive", @@ -4044,7 +4386,7 @@ dependencies = [ [[package]] name = "openvm-macros-common" version = "1.4.1" -source = "git+https://github.com/scroll-tech/openvm.git?branch=feat%2Fv1.4.1-scroll-ext#ac5d1b48b46fc37981f56ed943fa4ae6fb580827" +source = "git+https://github.com/scroll-tech/openvm.git?branch=feat%2Foptional_native_sumcheck#efda734de94847b51d2fdde5fa112013f60c4875" dependencies = [ "syn 2.0.101", ] @@ -4052,7 +4394,7 @@ dependencies = [ [[package]] name = "openvm-mod-circuit-builder" version = "1.4.1" -source = "git+https://github.com/scroll-tech/openvm.git?branch=feat%2Fv1.4.1-scroll-ext#ac5d1b48b46fc37981f56ed943fa4ae6fb580827" +source = "git+https://github.com/scroll-tech/openvm.git?branch=feat%2Foptional_native_sumcheck#efda734de94847b51d2fdde5fa112013f60c4875" dependencies = [ "itertools 0.14.0", "num-bigint 0.4.6", @@ -4070,7 +4412,7 @@ dependencies = [ [[package]] name = "openvm-native-circuit" version = "1.4.1" -source = "git+https://github.com/scroll-tech/openvm.git?branch=feat%2Fv1.4.1-scroll-ext#ac5d1b48b46fc37981f56ed943fa4ae6fb580827" +source = "git+https://github.com/scroll-tech/openvm.git?branch=feat%2Foptional_native_sumcheck#efda734de94847b51d2fdde5fa112013f60c4875" dependencies = [ "cfg-if", "derive-new 0.6.0", @@ -4101,7 +4443,7 @@ dependencies = [ [[package]] name = "openvm-native-compiler" version = "1.4.1" -source = "git+https://github.com/scroll-tech/openvm.git?branch=feat%2Fv1.4.1-scroll-ext#ac5d1b48b46fc37981f56ed943fa4ae6fb580827" +source = "git+https://github.com/scroll-tech/openvm.git?branch=feat%2Foptional_native_sumcheck#efda734de94847b51d2fdde5fa112013f60c4875" dependencies = [ "backtrace", "itertools 0.14.0", @@ -4115,6 +4457,7 @@ dependencies = [ "openvm-stark-backend", "openvm-stark-sdk", "serde", + "snark-verifier-sdk", "strum", "strum_macros", "zkhash", @@ -4123,7 +4466,7 @@ dependencies = [ [[package]] name = "openvm-native-compiler-derive" version = "1.4.1" -source = "git+https://github.com/scroll-tech/openvm.git?branch=feat%2Fv1.4.1-scroll-ext#ac5d1b48b46fc37981f56ed943fa4ae6fb580827" +source = "git+https://github.com/scroll-tech/openvm.git?branch=feat%2Foptional_native_sumcheck#efda734de94847b51d2fdde5fa112013f60c4875" dependencies = [ "quote", "syn 2.0.101", @@ -4132,11 +4475,12 @@ dependencies = [ [[package]] name = "openvm-native-recursion" version = "1.4.1" -source = "git+https://github.com/scroll-tech/openvm.git?branch=feat%2Fv1.4.1-scroll-ext#ac5d1b48b46fc37981f56ed943fa4ae6fb580827" +source = "git+https://github.com/scroll-tech/openvm.git?branch=feat%2Foptional_native_sumcheck#efda734de94847b51d2fdde5fa112013f60c4875" dependencies = [ "cfg-if", "itertools 0.14.0", "lazy_static", + "once_cell", "openvm-circuit", "openvm-native-circuit", "openvm-native-compiler", @@ -4150,13 +4494,15 @@ dependencies = [ "rand 0.8.5", "serde", "serde_json", + "serde_with", + "snark-verifier-sdk", "tracing", ] [[package]] name = "openvm-native-transpiler" version = "1.4.1" -source = "git+https://github.com/scroll-tech/openvm.git?branch=feat%2Fv1.4.1-scroll-ext#ac5d1b48b46fc37981f56ed943fa4ae6fb580827" +source = "git+https://github.com/scroll-tech/openvm.git?branch=feat%2Foptional_native_sumcheck#efda734de94847b51d2fdde5fa112013f60c4875" dependencies = [ "openvm-instructions", "openvm-transpiler", @@ -4166,7 +4512,7 @@ dependencies = [ [[package]] name = "openvm-pairing-circuit" version = "1.4.1" -source = "git+https://github.com/scroll-tech/openvm.git?branch=feat%2Fv1.4.1-scroll-ext#ac5d1b48b46fc37981f56ed943fa4ae6fb580827" +source = "git+https://github.com/scroll-tech/openvm.git?branch=feat%2Foptional_native_sumcheck#efda734de94847b51d2fdde5fa112013f60c4875" dependencies = [ "cfg-if", "derive-new 0.6.0", @@ -4195,7 +4541,7 @@ dependencies = [ [[package]] name = "openvm-pairing-guest" version = "1.4.1" -source = "git+https://github.com/scroll-tech/openvm.git?branch=feat%2Fv1.4.1-scroll-ext#ac5d1b48b46fc37981f56ed943fa4ae6fb580827" +source = "git+https://github.com/scroll-tech/openvm.git?branch=feat%2Foptional_native_sumcheck#efda734de94847b51d2fdde5fa112013f60c4875" dependencies = [ "halo2curves-axiom", "hex-literal", @@ -4216,7 +4562,7 @@ dependencies = [ [[package]] name = "openvm-pairing-transpiler" version = "1.4.1" -source = "git+https://github.com/scroll-tech/openvm.git?branch=feat%2Fv1.4.1-scroll-ext#ac5d1b48b46fc37981f56ed943fa4ae6fb580827" +source = "git+https://github.com/scroll-tech/openvm.git?branch=feat%2Foptional_native_sumcheck#efda734de94847b51d2fdde5fa112013f60c4875" dependencies = [ "openvm-instructions", "openvm-pairing-guest", @@ -4229,7 +4575,7 @@ dependencies = [ [[package]] name = "openvm-platform" version = "1.4.1" -source = "git+https://github.com/scroll-tech/openvm.git?branch=feat%2Fv1.4.1-scroll-ext#ac5d1b48b46fc37981f56ed943fa4ae6fb580827" +source = "git+https://github.com/scroll-tech/openvm.git?branch=feat%2Foptional_native_sumcheck#efda734de94847b51d2fdde5fa112013f60c4875" dependencies = [ "libm", "openvm-custom-insn", @@ -4239,7 +4585,7 @@ dependencies = [ [[package]] name = "openvm-poseidon2-air" version = "1.4.1" -source = "git+https://github.com/scroll-tech/openvm.git?branch=feat%2Fv1.4.1-scroll-ext#ac5d1b48b46fc37981f56ed943fa4ae6fb580827" +source = "git+https://github.com/scroll-tech/openvm.git?branch=feat%2Foptional_native_sumcheck#efda734de94847b51d2fdde5fa112013f60c4875" dependencies = [ "derivative", "lazy_static", @@ -4257,7 +4603,7 @@ dependencies = [ [[package]] name = "openvm-rv32-adapters" version = "1.4.1" -source = "git+https://github.com/scroll-tech/openvm.git?branch=feat%2Fv1.4.1-scroll-ext#ac5d1b48b46fc37981f56ed943fa4ae6fb580827" +source = "git+https://github.com/scroll-tech/openvm.git?branch=feat%2Foptional_native_sumcheck#efda734de94847b51d2fdde5fa112013f60c4875" dependencies = [ "derive-new 0.6.0", "itertools 0.14.0", @@ -4274,7 +4620,7 @@ dependencies = [ [[package]] name = "openvm-rv32im-circuit" version = "1.4.1" -source = "git+https://github.com/scroll-tech/openvm.git?branch=feat%2Fv1.4.1-scroll-ext#ac5d1b48b46fc37981f56ed943fa4ae6fb580827" +source = "git+https://github.com/scroll-tech/openvm.git?branch=feat%2Foptional_native_sumcheck#efda734de94847b51d2fdde5fa112013f60c4875" dependencies = [ "cfg-if", "derive-new 0.6.0", @@ -4297,7 +4643,7 @@ dependencies = [ [[package]] name = "openvm-rv32im-guest" version = "1.4.1" -source = "git+https://github.com/scroll-tech/openvm.git?branch=feat%2Fv1.4.1-scroll-ext#ac5d1b48b46fc37981f56ed943fa4ae6fb580827" +source = "git+https://github.com/scroll-tech/openvm.git?branch=feat%2Foptional_native_sumcheck#efda734de94847b51d2fdde5fa112013f60c4875" dependencies = [ "openvm-custom-insn", "p3-field", @@ -4307,7 +4653,7 @@ dependencies = [ [[package]] name = "openvm-rv32im-transpiler" version = "1.4.1" -source = "git+https://github.com/scroll-tech/openvm.git?branch=feat%2Fv1.4.1-scroll-ext#ac5d1b48b46fc37981f56ed943fa4ae6fb580827" +source = "git+https://github.com/scroll-tech/openvm.git?branch=feat%2Foptional_native_sumcheck#efda734de94847b51d2fdde5fa112013f60c4875" dependencies = [ "openvm-instructions", "openvm-instructions-derive", @@ -4323,8 +4669,9 @@ dependencies = [ [[package]] name = "openvm-sdk" version = "1.4.1" -source = "git+https://github.com/scroll-tech/openvm.git?branch=feat%2Fv1.4.1-scroll-ext#ac5d1b48b46fc37981f56ed943fa4ae6fb580827" +source = "git+https://github.com/scroll-tech/openvm.git?branch=feat%2Foptional_native_sumcheck#efda734de94847b51d2fdde5fa112013f60c4875" dependencies = [ + "alloy-sol-types", "bitcode", "bon", "cfg-if", @@ -4368,6 +4715,8 @@ dependencies = [ "serde", "serde_json", "serde_with", + "snark-verifier", + "snark-verifier-sdk", "tempfile", "thiserror 1.0.69", "toml", @@ -4377,18 +4726,18 @@ dependencies = [ [[package]] name = "openvm-sha256-air" version = "1.4.1" -source = "git+https://github.com/scroll-tech/openvm.git?branch=feat%2Fv1.4.1-scroll-ext#ac5d1b48b46fc37981f56ed943fa4ae6fb580827" +source = "git+https://github.com/scroll-tech/openvm.git?branch=feat%2Foptional_native_sumcheck#efda734de94847b51d2fdde5fa112013f60c4875" dependencies = [ "openvm-circuit-primitives", "openvm-stark-backend", "rand 0.8.5", - "sha2", + "sha2 0.10.9", ] [[package]] name = "openvm-sha256-circuit" version = "1.4.1" -source = "git+https://github.com/scroll-tech/openvm.git?branch=feat%2Fv1.4.1-scroll-ext#ac5d1b48b46fc37981f56ed943fa4ae6fb580827" +source = "git+https://github.com/scroll-tech/openvm.git?branch=feat%2Foptional_native_sumcheck#efda734de94847b51d2fdde5fa112013f60c4875" dependencies = [ "cfg-if", "derive-new 0.6.0", @@ -4404,14 +4753,14 @@ dependencies = [ "openvm-stark-sdk", "rand 0.8.5", "serde", - "sha2", + "sha2 0.10.9", "strum", ] [[package]] name = "openvm-sha256-guest" version = "1.4.1" -source = "git+https://github.com/scroll-tech/openvm.git?branch=feat%2Fv1.4.1-scroll-ext#ac5d1b48b46fc37981f56ed943fa4ae6fb580827" +source = "git+https://github.com/scroll-tech/openvm.git?branch=feat%2Foptional_native_sumcheck#efda734de94847b51d2fdde5fa112013f60c4875" dependencies = [ "openvm-platform", ] @@ -4419,7 +4768,7 @@ dependencies = [ [[package]] name = "openvm-sha256-transpiler" version = "1.4.1" -source = "git+https://github.com/scroll-tech/openvm.git?branch=feat%2Fv1.4.1-scroll-ext#ac5d1b48b46fc37981f56ed943fa4ae6fb580827" +source = "git+https://github.com/scroll-tech/openvm.git?branch=feat%2Foptional_native_sumcheck#efda734de94847b51d2fdde5fa112013f60c4875" dependencies = [ "openvm-instructions", "openvm-instructions-derive", @@ -4451,10 +4800,11 @@ dependencies = [ "p3-uni-stark", "p3-util", "rayon", - "rustc-hash", + "rustc-hash 2.1.1", "serde", "serde_json", "thiserror 1.0.69", + "tikv-jemallocator", "tracing", ] @@ -4491,14 +4841,14 @@ dependencies = [ "toml", "tracing", "tracing-forest", - "tracing-subscriber", + "tracing-subscriber 0.3.19", "zkhash", ] [[package]] name = "openvm-transpiler" version = "1.4.1" -source = "git+https://github.com/scroll-tech/openvm.git?branch=feat%2Fv1.4.1-scroll-ext#ac5d1b48b46fc37981f56ed943fa4ae6fb580827" +source = "git+https://github.com/scroll-tech/openvm.git?branch=feat%2Foptional_native_sumcheck#efda734de94847b51d2fdde5fa112013f60c4875" dependencies = [ "elf", "eyre", @@ -4533,7 +4883,7 @@ dependencies = [ "ecdsa 0.16.9 (registry+https://github.com/rust-lang/crates.io-index)", "elliptic-curve", "primeorder 0.13.6 (registry+https://github.com/rust-lang/crates.io-index)", - "sha2", + "sha2 0.10.9", ] [[package]] @@ -4546,7 +4896,7 @@ dependencies = [ "ecdsa 0.16.9 (registry+https://github.com/rust-lang/crates.io-index)", "elliptic-curve", "primeorder 0.13.6 (git+https://github.com/scroll-tech/elliptic-curves?branch=ceno%2Fk256-13.4)", - "sha2", + "sha2 0.10.9", ] [[package]] @@ -5052,6 +5402,48 @@ dependencies = [ "ucd-trie", ] +[[package]] +name = "phf" +version = "0.11.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1fd6780a80ae0c52cc120a26a1a42c1ae51b247a253e4e06113d23d2c2edd078" +dependencies = [ + "phf_macros", + "phf_shared", +] + +[[package]] +name = "phf_generator" +version = "0.11.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3c80231409c20246a13fddb31776fb942c38553c51e871f8cbd687a4cfb5843d" +dependencies = [ + "phf_shared", + "rand 0.8.5", +] + +[[package]] +name = "phf_macros" +version = "0.11.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f84ac04429c13a7ff43785d75ad27569f2951ce0ffd30a3321230db2fc727216" +dependencies = [ + "phf_generator", + "phf_shared", + "proc-macro2", + "quote", + "syn 2.0.101", +] + +[[package]] +name = "phf_shared" +version = "0.11.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "67eabc2ef2a60eb7faa00097bd1ffdb5bd28e62bf39990626a582201b7a754e5" +dependencies = [ + "siphasher", +] + [[package]] name = "pin-project-lite" version = "0.2.16" @@ -5127,6 +5519,21 @@ dependencies = [ "serde", ] +[[package]] +name = "poseidon-primitives" +version = "0.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6e4aaeda7a092e21165cc5f0cbc738e72a46f31c03c3cbd87b71ceae9d2d93bc" +dependencies = [ + "bitvec", + "ff 0.13.1", + "lazy_static", + "log", + "rand 0.8.5", + "rand_xorshift", + "thiserror 1.0.69", +] + [[package]] name = "powerfmt" version = "0.2.0" @@ -5356,6 +5763,7 @@ dependencies = [ "libc", "rand_chacha 0.3.1", "rand_core 0.6.4", + "serde", ] [[package]] @@ -5537,6 +5945,168 @@ version = "0.8.5" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "2b15c43186be67a4fd63bee50d0303afffcef381492ebe2c5d87f324e1b8815c" +[[package]] +name = "revm" +version = "24.0.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "01d277408ff8d6f747665ad9e52150ab4caf8d5eaf0d787614cf84633c8337b4" +dependencies = [ + "revm-bytecode", + "revm-context", + "revm-context-interface", + "revm-database", + "revm-database-interface", + "revm-handler", + "revm-inspector", + "revm-interpreter", + "revm-precompile 21.0.0", + "revm-primitives 19.2.0", + "revm-state", +] + +[[package]] +name = "revm-bytecode" +version = "4.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "942fe4724cf552fd28db6b0a2ca5b79e884d40dd8288a4027ed1e9090e0c6f49" +dependencies = [ + "bitvec", + "once_cell", + "phf", + "revm-primitives 19.2.0", + "serde", +] + +[[package]] +name = "revm-context" +version = "5.0.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b01aad49e1233f94cebda48a4e5cef022f7c7ed29b4edf0d202b081af23435ef" +dependencies = [ + "cfg-if", + "derive-where", + "revm-bytecode", + "revm-context-interface", + "revm-database-interface", + "revm-primitives 19.2.0", + "revm-state", + "serde", +] + +[[package]] +name = "revm-context-interface" +version = "5.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1b844f48a411e62c7dde0f757bf5cce49c85b86d6fc1d3b2722c07f2bec4c3ce" +dependencies = [ + "alloy-eip2930", + "alloy-eip7702", + "auto_impl", + "either", + "revm-database-interface", + "revm-primitives 19.2.0", + "revm-state", + "serde", +] + +[[package]] +name = "revm-database" +version = "4.0.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ad3fbe34f6bb00a9c3155723b3718b9cb9f17066ba38f9eb101b678cd3626775" +dependencies = [ + "alloy-eips", + "revm-bytecode", + "revm-database-interface", + "revm-primitives 19.2.0", + "revm-state", + "serde", +] + +[[package]] +name = "revm-database-interface" +version = "4.0.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7b8acd36784a6d95d5b9e1b7be3ce014f1e759abb59df1fa08396b30f71adc2a" +dependencies = [ + "auto_impl", + "revm-primitives 19.2.0", + "revm-state", + "serde", +] + +[[package]] +name = "revm-handler" +version = "5.0.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "481e8c3290ff4fa1c066592fdfeb2b172edfd14d12e6cade6f6f5588cad9359a" +dependencies = [ + "auto_impl", + "revm-bytecode", + "revm-context", + "revm-context-interface", + "revm-database-interface", + "revm-interpreter", + "revm-precompile 21.0.0", + "revm-primitives 19.2.0", + "revm-state", + "serde", +] + +[[package]] +name = "revm-inspector" +version = "5.0.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "fdc1167ef8937d8867888e63581d8ece729a72073d322119ef4627d813d99ecb" +dependencies = [ + "auto_impl", + "revm-context", + "revm-database-interface", + "revm-handler", + "revm-interpreter", + "revm-primitives 19.2.0", + "revm-state", + "serde", + "serde_json", +] + +[[package]] +name = "revm-interpreter" +version = "20.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b5ee65e57375c6639b0f50555e92a4f1b2434349dd32f52e2176f5c711171697" +dependencies = [ + "revm-bytecode", + "revm-context-interface", + "revm-primitives 19.2.0", + "serde", +] + +[[package]] +name = "revm-precompile" +version = "21.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0f9311e735123d8d53a02af2aa81877bba185be7c141be7f931bb3d2f3af449c" +dependencies = [ + "ark-bls12-381", + "ark-bn254", + "ark-ec", + "ark-ff 0.5.0", + "ark-serialize 0.5.0", + "aurora-engine-modexp", + "blst", + "c-kzg", + "cfg-if", + "k256 0.13.4 (registry+https://github.com/rust-lang/crates.io-index)", + "libsecp256k1", + "once_cell", + "p256 0.13.2 (registry+https://github.com/rust-lang/crates.io-index)", + "revm-primitives 19.2.0", + "ripemd", + "secp256k1", + "sha2 0.10.9", +] + [[package]] name = "revm-precompile" version = "27.0.0" @@ -5553,9 +6123,20 @@ dependencies = [ "cfg-if", "k256 0.13.4 (registry+https://github.com/rust-lang/crates.io-index)", "p256 0.13.2 (registry+https://github.com/rust-lang/crates.io-index)", - "revm-primitives", + "revm-primitives 20.2.1", "ripemd", - "sha2", + "sha2 0.10.9", +] + +[[package]] +name = "revm-primitives" +version = "19.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1c1588093530ec4442461163be49c433c07a3235d1ca6f6799fef338dacc50d3" +dependencies = [ + "alloy-primitives 1.4.0", + "num_enum 0.7.4", + "serde", ] [[package]] @@ -5564,11 +6145,23 @@ version = "20.2.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "5aa29d9da06fe03b249b6419b33968ecdf92ad6428e2f012dc57bcd619b5d94e" dependencies = [ - "alloy-primitives", + "alloy-primitives 1.4.0", "num_enum 0.7.4", "once_cell", ] +[[package]] +name = "revm-state" +version = "4.0.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0040c61c30319254b34507383ba33d85f92949933adf6525a2cede05d165e1fa" +dependencies = [ + "bitflags", + "revm-bytecode", + "revm-primitives 19.2.0", + "serde", +] + [[package]] name = "rfc6979" version = "0.4.0" @@ -5688,6 +6281,12 @@ version = "0.1.24" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "719b953e2095829ee67db738b3bfa9fa368c94900df327b3f07fe6e794d2fe1f" +[[package]] +name = "rustc-hash" +version = "1.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "08d43f7aa6b08d49f382cde6a7982047c3426db949b1424bc4b7ec9ae12c6ce2" + [[package]] name = "rustc-hash" version = "2.1.1" @@ -5945,6 +6544,7 @@ version = "1.0.149" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "83fc039473c5595ace860d8c4fafa220ff474b3fc6bfdb4293327f1a37e94d86" dependencies = [ + "indexmap 2.9.0", "itoa", "memchr", "serde", @@ -5993,6 +6593,19 @@ dependencies = [ "syn 2.0.101", ] +[[package]] +name = "sha2" +version = "0.9.9" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4d58a1e1bf39749807d89cf2d98ac2dfa0ff1cb3faa38fbb64dd88ac8013d800" +dependencies = [ + "block-buffer 0.9.0", + "cfg-if", + "cpufeatures", + "digest 0.9.0", + "opaque-debug", +] + [[package]] name = "sha2" version = "0.10.9" @@ -6049,6 +6662,12 @@ dependencies = [ "rand_core 0.6.4", ] +[[package]] +name = "siphasher" +version = "1.0.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "56199f7ddabf13fe5074ce809e7d3f42b42ae711800501b5b16ea82ad029c39d" + [[package]] name = "sketches-ddsketch" version = "0.2.2" @@ -6064,6 +6683,51 @@ dependencies = [ "serde", ] +[[package]] +name = "snark-verifier" +version = "0.2.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c9203c416ff9de0762667270b21573ba5e6edaeda08743b3ca37dc8a5e0a4480" +dependencies = [ + "halo2-base", + "halo2-ecc", + "hex", + "itertools 0.11.0", + "lazy_static", + "num-bigint 0.4.6", + "num-integer", + "num-traits", + "pairing 0.23.0", + "rand 0.8.5", + "revm", + "ruint", + "serde", + "sha3", +] + +[[package]] +name = "snark-verifier-sdk" +version = "0.2.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "290ae6e750d9d5fdf05393bbcae6bf7a63e3408eab023abf7d466156a234ac85" +dependencies = [ + "bincode 1.3.3", + "ethereum-types", + "getset", + "halo2-base", + "hex", + "itertools 0.11.0", + "lazy_static", + "num-bigint 0.4.6", + "num-integer", + "num-traits", + "rand 0.8.5", + "rand_chacha 0.3.1", + "serde", + "serde_json", + "snark-verifier", +] + [[package]] name = "snowbridge-amcl" version = "1.0.2" @@ -6275,6 +6939,18 @@ dependencies = [ "unicode-ident", ] +[[package]] +name = "syn-solidity" +version = "0.8.26" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ab4e6eed052a117409a1a744c8bda9c3ea6934597cf7419f791cb7d590871c4c" +dependencies = [ + "paste", + "proc-macro2", + "quote", + "syn 2.0.101", +] + [[package]] name = "synstructure" version = "0.13.2" @@ -6316,6 +6992,39 @@ dependencies = [ "winapi", ] +[[package]] +name = "test-case" +version = "3.3.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "eb2550dd13afcd286853192af8601920d959b14c401fcece38071d53bf0768a8" +dependencies = [ + "test-case-macros", +] + +[[package]] +name = "test-case-core" +version = "3.3.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "adcb7fd841cd518e279be3d5a3eb0636409487998a4aff22f3de87b81e88384f" +dependencies = [ + "cfg-if", + "proc-macro2", + "quote", + "syn 2.0.101", +] + +[[package]] +name = "test-case-macros" +version = "3.3.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5c89e72a01ed4c579669add59014b9a524d609c0c88c6a585ce37485879f6ffb" +dependencies = [ + "proc-macro2", + "quote", + "syn 2.0.101", + "test-case-core", +] + [[package]] name = "thiserror" version = "1.0.69" @@ -6592,7 +7301,7 @@ dependencies = [ "smallvec", "thiserror 1.0.69", "tracing", - "tracing-subscriber", + "tracing-subscriber 0.3.19", ] [[package]] @@ -6606,6 +7315,15 @@ dependencies = [ "tracing-core", ] +[[package]] +name = "tracing-subscriber" +version = "0.2.25" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0e0d2eaa99c3c2e41547cfa109e910a68ea03823cccad4a0525dcbc9b01e8c71" +dependencies = [ + "tracing-core", +] + [[package]] name = "tracing-subscriber" version = "0.3.19" @@ -7387,7 +8105,7 @@ dependencies = [ "pasta_curves 0.5.1", "rand 0.8.5", "serde", - "sha2", + "sha2 0.10.9", "sha3", "subtle", ] diff --git a/Cargo.toml b/Cargo.toml index 0a75e8c40..b22213fb2 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -92,16 +92,16 @@ ceno_gpu = { git = "https://github.com/scroll-tech/ceno-gpu-mock.git", package = cudarc = { version = "0.17.3", features = ["driver", "cuda-version-from-build-system"] } # ceno-recursion dependencies -openvm = { git = "https://github.com/scroll-tech/openvm.git", branch = "feat/v1.4.1-scroll-ext", default-features = false } -openvm-circuit = { git = "https://github.com/scroll-tech/openvm.git", branch = "feat/v1.4.1-scroll-ext", default-features = false } -openvm-continuations = { git = "https://github.com/scroll-tech/openvm.git", branch = "feat/v1.4.1-scroll-ext", default-features = false } -openvm-instructions = { git = "https://github.com/scroll-tech/openvm.git", branch = "feat/v1.4.1-scroll-ext", default-features = false } -openvm-native-circuit = { git = "https://github.com/scroll-tech/openvm.git", branch = "feat/v1.4.1-scroll-ext", default-features = false } -openvm-native-compiler = { git = "https://github.com/scroll-tech/openvm.git", branch = "feat/v1.4.1-scroll-ext", default-features = false } -openvm-native-compiler-derive = { git = "https://github.com/scroll-tech/openvm.git", branch = "feat/v1.4.1-scroll-ext", default-features = false } -openvm-native-recursion = { git = "https://github.com/scroll-tech/openvm.git", branch = "feat/v1.4.1-scroll-ext", default-features = false } -openvm-rv32im-circuit = { git = "https://github.com/scroll-tech/openvm.git", branch = "feat/v1.4.1-scroll-ext", default-features = false } -openvm-sdk = { git = "https://github.com/scroll-tech/openvm.git", branch = "feat/v1.4.1-scroll-ext", default-features = false } +openvm = { git = "https://github.com/scroll-tech/openvm.git", branch = "feat/optional_native_sumcheck", default-features = false } +openvm-circuit = { git = "https://github.com/scroll-tech/openvm.git", branch = "feat/optional_native_sumcheck", default-features = false } +openvm-continuations = { git = "https://github.com/scroll-tech/openvm.git", branch = "feat/optional_native_sumcheck", default-features = false } +openvm-instructions = { git = "https://github.com/scroll-tech/openvm.git", branch = "feat/optional_native_sumcheck", default-features = false } +openvm-native-circuit = { git = "https://github.com/scroll-tech/openvm.git", branch = "feat/optional_native_sumcheck", default-features = false } +openvm-native-compiler = { git = "https://github.com/scroll-tech/openvm.git", branch = "feat/optional_native_sumcheck", default-features = false } +openvm-native-compiler-derive = { git = "https://github.com/scroll-tech/openvm.git", branch = "feat/optional_native_sumcheck", default-features = false } +openvm-native-recursion = { git = "https://github.com/scroll-tech/openvm.git", branch = "feat/optional_native_sumcheck", default-features = false } +openvm-rv32im-circuit = { git = "https://github.com/scroll-tech/openvm.git", branch = "feat/optional_native_sumcheck", default-features = false } +openvm-sdk = { git = "https://github.com/scroll-tech/openvm.git", branch = "feat/optional_native_sumcheck", features = ["evm-prove", "evm-verify"] } openvm-cuda-backend = { git = "https://github.com/openvm-org/stark-backend.git", tag = "v1.2.1", default-features = false } openvm-stark-backend = { git = "https://github.com/openvm-org/stark-backend.git", tag = "v1.2.1", default-features = false } diff --git a/ceno_cli/src/sdk.rs b/ceno_cli/src/sdk.rs index cbcb601b9..29880230b 100644 --- a/ceno_cli/src/sdk.rs +++ b/ceno_cli/src/sdk.rs @@ -19,15 +19,17 @@ use gkr_iop::cpu::{CpuBackend, CpuProver}; use gkr_iop::gpu::{GpuBackend, GpuProver}; use gkr_iop::hal::ProverBackend; use mpcs::{Basefold, BasefoldRSParams, PolynomialCommitmentScheme, SecurityLevel}; -use openvm_continuations::verifier::internal::types::VmStarkProof; #[cfg(feature = "gpu")] use openvm_cuda_backend::engine::GpuBabyBearPoseidon2Engine as BabyBearPoseidon2Engine; -use openvm_native_circuit::{NativeBuilder, NativeConfig}; -use openvm_sdk::prover::vm::new_local_prover; -use openvm_stark_backend::config::StarkGenericConfig; -use openvm_stark_sdk::config::baby_bear_poseidon2::BabyBearPoseidon2Config; +use openvm_native_circuit::{NativeBuilder, NativeConfig, NativeCpuBuilder}; +use openvm_sdk::{RootSC, prover::vm::new_local_prover}; +use openvm_stark_backend::{config::StarkGenericConfig, proof::Proof}; #[cfg(not(feature = "gpu"))] use openvm_stark_sdk::config::baby_bear_poseidon2::BabyBearPoseidon2Engine; +use openvm_stark_sdk::config::{ + baby_bear_poseidon2::BabyBearPoseidon2Config, + baby_bear_poseidon2_root::BabyBearPoseidon2RootEngine, +}; use serde::Serialize; use std::sync::Arc; @@ -194,7 +196,7 @@ where pub fn compress_to_root_proof( &mut self, base_proofs: Vec>>, - ) -> VmStarkProof { + ) -> Proof { let vb = NativeBuilder::default(); // TODO: cache agg_prover @@ -216,7 +218,20 @@ where "Aggregation must provide existing base layer vk." ); let base_vk = self.zkvm_vk.as_ref().unwrap().clone(); - CenoAggregationProver::new(base_vk, leaf_prover, internal_prover, agg_pk.clone()) + let root_prover = new_local_prover::( + Default::default(), + &agg_pk.root_vm_pk, + agg_pk.root_committed_exe.exe.clone(), + ) + .expect("root prover"); + + CenoAggregationProver::new( + base_vk, + leaf_prover, + internal_prover, + root_prover, + agg_pk.clone(), + ) } else { let agg_prover = CenoAggregationProver::from_base_vk(self.zkvm_vk.clone().unwrap()); self.agg_pk = Some(agg_prover.pk.clone()); diff --git a/ceno_recursion/Cargo.toml b/ceno_recursion/Cargo.toml index 3b978aa56..9f21adb5d 100644 --- a/ceno_recursion/Cargo.toml +++ b/ceno_recursion/Cargo.toml @@ -46,6 +46,7 @@ tracing-subscriber.workspace = true transcript.workspace = true whir.workspace = true witness.workspace = true +anyhow.workspace = true [[bin]] name = "e2e_aggregate" diff --git a/ceno_recursion/src/aggregation/internal.rs b/ceno_recursion/src/aggregation/internal.rs index bd494a0e9..0d57cdd7b 100644 --- a/ceno_recursion/src/aggregation/internal.rs +++ b/ceno_recursion/src/aggregation/internal.rs @@ -3,12 +3,13 @@ /// https://github.com/openvm-org/openvm/blob/main/crates/continuations/src/verifier/common/non_leaf.rs use std::{array, borrow::Borrow}; +use ceno_zkvm::scheme::constants::SEPTIC_EXTENSION_DEGREE; use openvm_circuit::arch::PUBLIC_VALUES_AIR_ID; use openvm_instructions::program::Program; use openvm_native_compiler::{ conversion::CompilerOptions, - ir::{Array, Builder, Config, DIGEST_SIZE, Felt, RVar}, - prelude::Var, + ir::{Array, Builder, Config, DIGEST_SIZE, Felt, RVar, Usize}, + prelude::*, }; use openvm_native_recursion::{ challenger::duplex::DuplexChallengerVariable, fri::TwoAdicFriPcsVariable, stark::StarkVerifier, @@ -21,15 +22,22 @@ use openvm_stark_sdk::{ }; use p3::field::FieldAlgebra; +use crate::{ + aggregation::{ + InternalVmVerifierInput, + types::{InternalVmVerifierExtraPvs, InternalVmVerifierPvs, VmVerifierPvs}, + }, + zkvm_verifier::{ + binding::{SepticExtensionVariable, SepticPointVariable}, + verifier::add_septic_points_in_place, + }, +}; use openvm_continuations::verifier::{ common::{ assert_or_assign_connector_pvs, assert_required_air_for_agg_vm_present, - assert_single_segment_vm_exit_successfully, get_program_commit, types::VmVerifierPvs, - }, - internal::{ - types::{InternalVmVerifierExtraPvs, InternalVmVerifierInput, InternalVmVerifierPvs}, - vars::InternalVmVerifierInputVariable, + assert_single_segment_vm_exit_successfully, get_program_commit, }, + internal::vars::InternalVmVerifierInputVariable, }; use openvm_native_recursion::hints::Hintable; @@ -91,6 +99,16 @@ impl NonLeafVerifierVariables { let pvs = VmVerifierPvs::>::uninit(builder); let leaf_verifier_commit = array::from_fn(|_| builder.uninit()); + let ec_sum = SepticPointVariable { + x: SepticExtensionVariable { + vs: builder.dyn_array(7), + }, + y: SepticExtensionVariable { + vs: builder.dyn_array(7), + }, + is_infinity: Usize::uninit(builder), + }; + builder.range(0, proofs.len()).for_each(|i_vec, builder| { let i = i_vec[0]; let proof = builder.get(proofs, i); @@ -98,26 +116,61 @@ impl NonLeafVerifierVariables { let proof_vm_pvs = self.verify_internal_or_leaf_verifier_proof(builder, &proof); assert_single_segment_vm_exit_successfully(builder, &proof); - builder.if_eq(i, RVar::zero()).then_or_else( |builder| { - builder.assign(&pvs.app_commit, proof_vm_pvs.vm_verifier_pvs.app_commit); + for i in 0..SEPTIC_EXTENSION_DEGREE { + let x = Ext::uninit(builder); + builder.assign(&x, proof_vm_pvs.vm_verifier_pvs.shard_ram_connector.x[i]); + let y = Ext::uninit(builder); + builder.assign(&y, proof_vm_pvs.vm_verifier_pvs.shard_ram_connector.y[i]); + + builder.set(&ec_sum.x.vs, i, x); + builder.set(&ec_sum.y.vs, i, y); + } + let inf = Usize::Var(builder.cast_felt_to_var( + proof_vm_pvs.vm_verifier_pvs.shard_ram_connector.is_infinity, + )); + builder.assign(&ec_sum.is_infinity, inf); + builder.assign( &leaf_verifier_commit, proof_vm_pvs.extra_pvs.leaf_verifier_commit, ); }, |builder| { - builder.assert_eq::<[_; DIGEST_SIZE]>( - pvs.app_commit, - proof_vm_pvs.vm_verifier_pvs.app_commit, - ); + let right = SepticPointVariable { + x: SepticExtensionVariable { + vs: builder.dyn_array(7), + }, + y: SepticExtensionVariable { + vs: builder.dyn_array(7), + }, + is_infinity: Usize::uninit(builder), + }; + + for i in 0..SEPTIC_EXTENSION_DEGREE { + let x = Ext::uninit(builder); + builder.assign(&x, proof_vm_pvs.vm_verifier_pvs.shard_ram_connector.x[i]); + let y = Ext::uninit(builder); + builder.assign(&y, proof_vm_pvs.vm_verifier_pvs.shard_ram_connector.y[i]); + + builder.set(&right.x.vs, i, x); + builder.set(&right.y.vs, i, y); + } + let inf = Usize::Var(builder.cast_felt_to_var( + proof_vm_pvs.vm_verifier_pvs.shard_ram_connector.is_infinity, + )); + builder.assign(&right.is_infinity, inf); + + add_septic_points_in_place(builder, &ec_sum, &right); + builder.assert_eq::<[_; DIGEST_SIZE]>( leaf_verifier_commit, proof_vm_pvs.extra_pvs.leaf_verifier_commit, ); }, ); + assert_or_assign_connector_pvs( builder, &pvs.connector, @@ -125,72 +178,27 @@ impl NonLeafVerifierVariables { &proof_vm_pvs.vm_verifier_pvs.connector, ); - // TODO: sum shard ram ec point in each proof - // // EC sum verification - // let expected_last_shard_id = Usize::uninit(builder); - // builder.assign(&expected_last_shard_id, pv.len() - Usize::from(1)); - - // let shard_id_fs = builder.get(&shard_raw_pi, SHARD_ID_IDX); - // let shard_id_f = builder.get(&shard_id_fs, 0); - // let shard_id = Usize::Var(builder.cast_felt_to_var(shard_id_f)); - // builder.assert_usize_eq(expected_last_shard_id, shard_id); + for i in 0..SEPTIC_EXTENSION_DEGREE { + let x_ext = builder.get(&ec_sum.x.vs, i); + let y_ext = builder.get(&ec_sum.y.vs, i); + let x_fs = builder.ext2felt(x_ext); + let y_fs = builder.ext2felt(y_ext); + let x = builder.get(&x_fs, 0); + let y = builder.get(&y_fs, 0); - // let ec_sum = SepticPointVariable { - // x: SepticExtensionVariable { - // vs: builder.dyn_array(7), - // }, - // y: SepticExtensionVariable { - // vs: builder.dyn_array(7), - // }, - // is_infinity: Usize::uninit(builder), - // }; - // builder.assign(&ec_sum.is_infinity, Usize::from(1)); - - // builder.range(0, pv.len()).for_each(|idx_vec, builder| { - // let shard_pv = builder.get(&pv, idx_vec[0]); - // let x = SepticExtensionVariable { - // vs: shard_pv.slice( - // builder, - // SHARD_RW_SUM_IDX, - // SHARD_RW_SUM_IDX + SEPTIC_EXTENSION_DEGREE, - // ), - // }; - // let y = SepticExtensionVariable { - // vs: shard_pv.slice( - // builder, - // SHARD_RW_SUM_IDX + SEPTIC_EXTENSION_DEGREE, - // SHARD_RW_SUM_IDX + 2 * SEPTIC_EXTENSION_DEGREE, - // ), - // }; - // let shard_ec = SepticPointVariable { - // x: x.clone(), - // y: y.clone(), - // is_infinity: Usize::uninit(builder), - // }; - // let is_x_zero = x.is_zero(builder); - // let is_y_zero = y.is_zero(builder); - // builder.if_eq(is_x_zero, Usize::from(1)).then_or_else( - // |builder| { - // builder - // .if_eq(is_y_zero.clone(), Usize::from(1)) - // .then_or_else( - // |builder| { - // builder.assign(&shard_ec.is_infinity, Usize::from(1)); - // }, - // |builder| { - // builder.assign(&shard_ec.is_infinity, Usize::from(0)); - // }, - // ); - // }, - // |builder| { - // builder.assign(&shard_ec.is_infinity, Usize::from(0)); - // }, - // ); - - // add_septic_points_in_place(builder, &ec_sum, &shard_ec); - // }); - - // add_septic_points_in_place(builder, &ec_sum, &calculated_shard_ec_sum); + builder.assign(&pvs.shard_ram_connector.x[i], x); + builder.assign(&pvs.shard_ram_connector.y[i], y); + } + builder + .if_eq(ec_sum.is_infinity.clone(), Usize::from(1)) + .then_or_else( + |builder| { + builder.assign(&pvs.shard_ram_connector.is_infinity, C::F::ONE); + }, + |builder| { + builder.assign(&pvs.shard_ram_connector.is_infinity, C::F::ZERO); + }, + ); // This is only needed when `is_terminate` but branching here won't save much, so we // always assign it. @@ -301,6 +309,7 @@ impl InternalVmVerifierConfig { internal_pcs, internal_advice, }; + builder.cycle_tracker_start("VerifyProofs"); let (vm_verifier_pvs, leaf_verifier_commit) = non_leaf_verifier.verify_internal_or_leaf_verifier_proofs(&mut builder, &proofs); diff --git a/ceno_recursion/src/aggregation/mod.rs b/ceno_recursion/src/aggregation/mod.rs index 6884103da..80bd79038 100644 --- a/ceno_recursion/src/aggregation/mod.rs +++ b/ceno_recursion/src/aggregation/mod.rs @@ -1,10 +1,13 @@ -use crate::zkvm_verifier::{ - binding::{E, F, ZKVMProofInput, ZKVMProofInputVariable}, - verifier::verify_zkvm_proof, +use crate::{ + aggregation::{root::CenoRootVmVerifierConfig, statics::StaticProverVerifier}, + zkvm_verifier::{ + binding::{E, F, ZKVMProofInput, ZKVMProofInputVariable}, + verifier::verify_zkvm_proof, + }, }; use ceno_zkvm::{ instructions::riscv::constants::{END_PC_IDX, EXIT_CODE_IDX, INIT_PC_IDX}, - scheme::ZKVMProof, + scheme::{ZKVMProof, constants::SEPTIC_EXTENSION_DEGREE}, structs::ZKVMVerifyingKey, }; use ff_ext::BabyBearExt4; @@ -16,83 +19,94 @@ use openvm_circuit::{ system::program::trace::VmCommittedExe, utils::air_test_impl, }; -use openvm_stark_backend::config::{PcsProverData, Val}; +use openvm_stark_backend::{ + config::{PcsProverData, Val}, + verifier::VerificationError, +}; use internal::InternalVmVerifierConfig; use openvm_continuations::{ C, - verifier::{ - common::types::VmVerifierPvs, - internal::types::{InternalVmVerifierInput, InternalVmVerifierPvs, VmStarkProof}, - }, + verifier::{internal::types::InternalVmVerifierInput, root::types::RootVmVerifierInput}, }; #[cfg(feature = "gpu")] use openvm_cuda_backend::engine::GpuBabyBearPoseidon2Engine as BabyBearPoseidon2Engine; -use openvm_native_circuit::{NativeBuilder, NativeConfig}; +use openvm_native_circuit::{NativeBuilder, NativeConfig, NativeCpuBuilder}; use openvm_native_compiler::{ asm::AsmBuilder, conversion::{CompilerOptions, convert_program}, prelude::*, }; -use openvm_native_recursion::hints::Hintable; +use openvm_native_recursion::{halo2::RawEvmProof, hints::Hintable}; use openvm_sdk::{ SC, - commit::AppExecutionCommit, config::DEFAULT_NUM_CHILDREN_INTERNAL, - prover::vm::{new_local_prover, types::VmProvingKey}, + keygen::{RootVerifierProvingKey, perm::AirIdPermutation}, + prover::{ + RootVerifierLocalProver, + vm::{new_local_prover, types::VmProvingKey}, + }, + util::check_max_constraint_degrees, }; use openvm_stark_backend::{ config::{Com, StarkGenericConfig}, engine::StarkEngine, + proof::Proof, }; #[cfg(not(feature = "gpu"))] use openvm_stark_sdk::config::baby_bear_poseidon2::BabyBearPoseidon2Engine; use openvm_stark_sdk::{ config::{ FriParameters, baby_bear_poseidon2::BabyBearPoseidon2Config, + baby_bear_poseidon2_root::BabyBearPoseidon2RootEngine, fri_params::standard_fri_params_with_100_bits_conjectured_security, }, engine::StarkFriEngine, openvm_stark_backend::keygen::types::MultiStarkVerifyingKey, - p3_bn254_fr::Bn254Fr, }; use p3::field::FieldAlgebra; use serde::{Deserialize, Serialize}; -use std::{borrow::Borrow, sync::Arc, time::Instant}; +use std::{fs::File, path::Path, sync::Arc, time::Instant}; pub type RecPcs = Basefold; -use openvm_circuit::{ - arch::{ - CONNECTOR_AIR_ID, PROGRAM_AIR_ID, PROGRAM_CACHED_TRACE_INDEX, PUBLIC_VALUES_AIR_ID, - SingleSegmentVmProver, - hasher::{Hasher, poseidon2::vm_poseidon2_hasher}, - instructions::exe::VmExe, - }, - system::{memory::CHUNK, program::trace::compute_exe_commit}, +use crate::aggregation::types::{InternalVmVerifierPvs, VmVerifierPvs}; +use anyhow::Result; +use openvm_circuit::arch::{ + PUBLIC_VALUES_AIR_ID, PreflightExecutionOutput, SingleSegmentVmProver, instructions::exe::VmExe, }; +use openvm_continuations::RootSC; +use openvm_native_circuit::extension::Native; use openvm_native_compiler::{ asm::AsmConfig, ir::{Builder, Config, Felt}, }; -use openvm_sdk::util::check_max_constraint_degrees; -use openvm_stark_backend::proof::Proof; mod internal; mod root; +mod statics; mod types; pub type InnerConfig = AsmConfig; pub const LEAF_LOG_BLOWUP: usize = 1; pub const INTERNAL_LOG_BLOWUP: usize = 2; pub const ROOT_LOG_BLOWUP: usize = 3; +pub const ROOT_MAX_CONSTRAINT_DEG: usize = (1 << ROOT_LOG_BLOWUP) + 1; +pub const ROOT_NUM_PUBLIC_VALUES: usize = 15; pub const SBOX_SIZE: usize = 7; const VM_MAX_TRACE_HEIGHTS: &[u32] = &[ 4194304, 4, 128, 2097152, 8388608, 4194304, 262144, 8388608, 16777216, 2097152, 16777216, 2097152, 8388608, 262144, 2097152, 1048576, 4194304, 1048576, 262144, ]; +const ROOT_VM_MAX_TRACE_HEIGHTS: &[u32] = &[ + 4194304, 4, 128, 2097152, 8388608, 4194304, 262144, 2097152, 16777216, 2097152, 8388608, + 262144, 2097152, 1048576, 4194304, 1048576, 262144, +]; pub struct CenoAggregationProver { pub base_vk: ZKVMVerifyingKey>, pub leaf_prover: VmInstance, pub internal_prover: VmInstance, + pub root_prover: VmInstance, + pub permuted_root_prover: Option, + pub static_prover_verifier: StaticProverVerifier, pub vk: CenoRecursionVerifierKeys, pub pk: CenoRecursionProvingKeys, } @@ -102,12 +116,16 @@ impl CenoAggregationProver { base_vk: ZKVMVerifyingKey>, leaf_prover: VmInstance, internal_prover: VmInstance, + root_prover: VmInstance, pk: CenoRecursionProvingKeys, ) -> Self { Self { base_vk, leaf_prover, internal_prover, + root_prover, + permuted_root_prover: None, + static_prover_verifier: StaticProverVerifier::new(), vk: pk.get_vk(), pk, } @@ -115,7 +133,7 @@ impl CenoAggregationProver { pub fn from_base_vk(vk: ZKVMVerifyingKey>) -> Self { let vb = NativeBuilder::default(); - let [leaf_fri_params, internal_fri_params, _root_fri_params] = + let [leaf_fri_params, internal_fri_params, root_fri_params] = [LEAF_LOG_BLOWUP, INTERNAL_LOG_BLOWUP, ROOT_LOG_BLOWUP] .map(FriParameters::standard_with_100_bits_conjectured_security); @@ -132,7 +150,7 @@ impl CenoAggregationProver { .with_max_segment_len((1 << 24) - 100) .with_profiling() .without_continuations(), - native: Default::default(), + native: Native(true), }; // Leaf layer keygen @@ -185,7 +203,7 @@ impl CenoAggregationProver { .with_max_segment_len((1 << 24) - 100) .with_profiling() .without_continuations(), - native: Default::default(), + native: Native(true), }; // Internal keygen @@ -216,6 +234,8 @@ impl CenoAggregationProver { internal_program.into(), internal_vm.engine.config().pcs(), )); + let internal_vm_verifier_commit: [F; DIGEST_SIZE] = + internal_committed_exe.get_program_commit().into(); let internal_prover = new_local_prover::( vb.clone(), &internal_vm_pk, @@ -223,28 +243,81 @@ impl CenoAggregationProver { ) .expect("internal prover"); - // TODO: build root program (requires shard ram ec point is zero) - // TODO: add root prover + // Root prover + let root_vm_config = NativeConfig { + system: SystemConfig::new( + SBOX_SIZE.min(ROOT_MAX_CONSTRAINT_DEG), + MemoryConfig { + max_access_adapter_n: 8, + ..Default::default() + }, + ROOT_NUM_PUBLIC_VALUES, + ) + .without_continuations() + .with_max_segment_len((1 << 24) - 100) + .with_profiling(), + native: Native(false), + }; + + let mut root_engine = BabyBearPoseidon2RootEngine::new(root_fri_params); + root_engine.max_constraint_degree = ROOT_MAX_CONSTRAINT_DEG; + + let (root_vm, root_vm_pk) = VirtualMachine::<_, NativeCpuBuilder>::new_with_keygen( + root_engine, + Default::default(), + root_vm_config.clone(), + ) + .expect("root keygen"); + let root_program = CenoRootVmVerifierConfig { + leaf_fri_params, + internal_fri_params, + num_user_public_values: ROOT_NUM_PUBLIC_VALUES, + internal_vm_verifier_commit, + compiler_options: CompilerOptions::default().with_cycle_tracker(), + } + .build_program(&leaf_vm_vk, &internal_vm_vk); + let root_committed_exe = Arc::new(VmCommittedExe::::commit( + root_program.into(), + root_vm.engine.config().pcs(), + )); + let root_vm_pk = Arc::new(VmProvingKey { + fri_params: root_fri_params, + vm_config: root_vm_config, + vm_pk: root_vm_pk, + }); + let root_prover = new_local_prover::( + Default::default(), + &root_vm_pk, + root_committed_exe.exe.clone(), + ) + .expect("root prover"); + // Recursion keys let vk = CenoRecursionVerifierKeys { leaf_vm_vk, leaf_fri_params: leaf_vm_pk.fri_params, internal_vm_vk, internal_fri_params: internal_vm_pk.fri_params, internal_commit: internal_committed_exe.get_program_commit(), + root_vm_vk: root_vm_pk.vm_pk.get_vk(), }; - let pk = CenoRecursionProvingKeys { leaf_vm_pk, leaf_committed_exe, internal_vm_pk, internal_committed_exe, + root_vm_pk, + root_committed_exe, + permuted_root_pk: None, }; Self { base_vk: leaf_vm_verifier_config.vk, leaf_prover, internal_prover, + root_prover, + permuted_root_prover: None, + static_prover_verifier: StaticProverVerifier::new(), vk, pk, } @@ -253,7 +326,7 @@ impl CenoAggregationProver { pub fn generate_root_proof( &mut self, base_proofs: Vec>>, - ) -> VmStarkProof { + ) -> Proof { let aggregation_start_timestamp = Instant::now(); // Construct zkvm proof input @@ -360,16 +433,142 @@ impl CenoAggregationProver { ); println!("Aggregation - Final height: {:?}", internal_node_height); - // TODO: generate root proof from last internal proof + let last_internal = proofs.pop().unwrap(); - // Export e2e stark proof (used in verify_e2e_stark_proof) - VmStarkProof { - inner: proofs.pop().unwrap(), - user_public_values, + // Export last internal proof + let file = File::create( + Path::new(env!("CARGO_MANIFEST_DIR")).join("src/exports/internal_proof.bin"), + ) + .expect("Create export proof file"); + bincode::serialize_into(file, &last_internal).expect("failed to serialize internal proof"); + + // _todo: possible multi-layer wrapping for reducing AIR heights + + let root_input = RootVmVerifierInput { + proofs: vec![last_internal], + public_values: user_public_values, + }; + + // Initiate the root prover with AIR height permutation + // This step is skipped if the permuted root prover is already initiated + // (either from a run of `generate_root_proof`` or with a dummy) + let root_permutation_start_timestamp = Instant::now(); + if self.permuted_root_prover.is_none() { + self.init_root_prover_with_permutation(&root_input); } + println!( + "Root - AIR-permuted root prover is not initiated. Completed initiation at: {:?}", + root_permutation_start_timestamp.elapsed() + ); + + // Generate root proof (AIR-permuted) + let root_start_timestamp = Instant::now(); + let air_permuted_root_proof = SingleSegmentVmProver::prove( + self.permuted_root_prover.as_mut().unwrap(), + root_input.write(), + ROOT_VM_MAX_TRACE_HEIGHTS, + ) + .expect("root proof"); + + // Export root proof + let file = + File::create(Path::new(env!("CARGO_MANIFEST_DIR")).join("src/exports/root_proof.bin")) + .expect("Create export proof file"); + bincode::serialize_into(file, &air_permuted_root_proof) + .expect("failed to serialize root proof"); + + println!( + "Root - Completed root proof at: {:?}", + root_start_timestamp.elapsed() + ); + + air_permuted_root_proof + } + + pub fn prove_static(&mut self, root_proof: &Proof) -> RawEvmProof { + let halo2_proof = self + .static_prover_verifier + .prove_static(root_proof, &self.pk); + + // Export halo2 proof + let file = + File::create(Path::new(env!("CARGO_MANIFEST_DIR")).join("src/exports/halo2_proof.bin")) + .expect("Create export proof file"); + bincode::serialize_into(file, &halo2_proof).expect("failed to serialize halo2 proof"); + + halo2_proof + } + + pub fn verify_static(&mut self, halo2_proof: RawEvmProof) -> Result<()> { + let _ = self.static_prover_verifier.verify_static(halo2_proof); + Ok(()) + } + + pub fn init_root_prover_with_permutation(&mut self, root_input: &RootVmVerifierInput) { + self.root_prover.reset_state(root_input.write()); + let mut trace_heights = ROOT_VM_MAX_TRACE_HEIGHTS.to_vec(); + + let num_public_values = self.root_prover.vm.config().as_ref().num_public_values as u32; + trace_heights[PUBLIC_VALUES_AIR_ID] = num_public_values; + + let state = self + .root_prover + .state + .take() + .expect("vm state should exist"); + let vm = &mut self.root_prover.vm; + vm.transport_init_memory_to_device(&state.memory); + + let PreflightExecutionOutput { + system_records, + record_arenas, + to_state: _, + } = vm + .execute_preflight( + &mut self.root_prover.interpreter, + state, + None, + &trace_heights, + ) + .expect("execute preflight"); + + let ctx = vm + .generate_proving_ctx(system_records, record_arenas) + .expect("proving context"); + let air_heights: Vec = ctx + .into_iter() + .map(|(_, air_ctx)| air_ctx.main_trace_height().next_power_of_two() as u32) + .collect(); + let root_air_perm = AirIdPermutation::compute(&air_heights); + let mut root_vm_pk = self.pk.root_vm_pk.vm_pk.clone(); + root_air_perm.permute(&mut root_vm_pk.per_air); + + let root_permuted_pk = RootVerifierProvingKey { + vm_pk: Arc::new(VmProvingKey { + fri_params: self.pk.root_vm_pk.fri_params, + vm_config: self.pk.root_vm_pk.vm_config.clone(), + vm_pk: root_vm_pk, + }), + root_committed_exe: self.pk.root_committed_exe.clone(), + air_heights, + }; + self.permuted_root_prover = + Some(RootVerifierLocalProver::new(&root_permuted_pk).expect("create a root prover")); + self.pk.permuted_root_pk = Some(Arc::new(root_permuted_pk)); } } +pub fn verify_root_proof( + vk: &CenoRecursionVerifierKeys, + root_proof: &Proof, +) -> Result<(), VerificationError> { + let root_fri_params = + FriParameters::standard_with_100_bits_conjectured_security(ROOT_LOG_BLOWUP); + let root_engine = BabyBearPoseidon2RootEngine::new(root_fri_params); + root_engine.verify(&vk.root_vm_vk, root_proof)?; + Ok(()) +} + /// Config to generate leaf VM verifier program. pub struct CenoLeafVmVerifierConfig { pub vk: ZKVMVerifyingKey>, @@ -387,16 +586,10 @@ impl CenoLeafVmVerifierConfig { builder.cycle_tracker_start("Verify Ceno ZKVM Proof"); let zkvm_proof = ceno_leaf_input.proof; let raw_pi = zkvm_proof.raw_pi.clone(); - let _calculated_shard_ec_sum = verify_zkvm_proof(&mut builder, zkvm_proof, &self.vk); + let shard_ec_sum = verify_zkvm_proof(&mut builder, zkvm_proof, &self.vk); builder.cycle_tracker_end("Verify Ceno ZKVM Proof"); builder.cycle_tracker_start("PV Operations"); - - // TODO: define our own VmVerifierPvs - for i in 0..DIGEST_SIZE { - builder.assign(&stark_pvs.app_commit[i], F::ZERO); - } - let pv = &raw_pi; let init_pc = { let arr = builder.get(pv, INIT_PC_IDX); @@ -414,7 +607,27 @@ impl CenoLeafVmVerifierConfig { builder.assign(&stark_pvs.connector.final_pc, end_pc); builder.assign(&stark_pvs.connector.exit_code, exit_code); - // TODO: assign shard_ec_sum to stark_pvs.shard_ec_sum + for i in 0..SEPTIC_EXTENSION_DEGREE { + let x_ext = builder.get(&shard_ec_sum.x.vs, i); + let y_ext = builder.get(&shard_ec_sum.y.vs, i); + let x_fs = builder.ext2felt(x_ext); + let y_fs = builder.ext2felt(y_ext); + let x = builder.get(&x_fs, 0); + let y = builder.get(&y_fs, 0); + + builder.assign(&stark_pvs.shard_ram_connector.x[i], x); + builder.assign(&stark_pvs.shard_ram_connector.y[i], y); + } + builder + .if_eq(shard_ec_sum.is_infinity, Usize::from(1)) + .then_or_else( + |builder| { + builder.assign(&stark_pvs.shard_ram_connector.is_infinity, F::ONE); + }, + |builder| { + builder.assign(&stark_pvs.shard_ram_connector.is_infinity, F::ZERO); + }, + ); // builder // .if_eq(ceno_leaf_input.is_last, Usize::from(1)) @@ -443,7 +656,6 @@ impl CenoLeafVmVerifierConfig { // ); // builder.assign(&prev_pc, end_pc); // }); - // }); for pv in stark_pvs.flatten() { @@ -468,6 +680,7 @@ pub struct CenoRecursionVerifierKeys { pub internal_vm_vk: MultiStarkVerifyingKey, pub internal_fri_params: FriParameters, pub internal_commit: Com, + pub root_vm_vk: MultiStarkVerifyingKey, } #[derive(Serialize, Deserialize)] @@ -480,6 +693,9 @@ pub struct CenoRecursionProvingKeys { pub leaf_committed_exe: Arc>, pub internal_vm_pk: Arc>, pub internal_committed_exe: Arc>, + pub root_vm_pk: Arc>, + pub root_committed_exe: Arc>, + pub permuted_root_pk: Option>, } impl Clone for CenoRecursionProvingKeys { @@ -489,6 +705,9 @@ impl Clone for CenoRecursionProvingKeys { leaf_committed_exe: self.leaf_committed_exe.clone(), internal_vm_pk: self.internal_vm_pk.clone(), internal_committed_exe: self.internal_committed_exe.clone(), + root_vm_pk: self.root_vm_pk.clone(), + root_committed_exe: self.root_committed_exe.clone(), + permuted_root_pk: self.permuted_root_pk.clone(), } } } @@ -501,6 +720,7 @@ impl CenoRecursionProvingKeys { internal_vm_vk: self.internal_vm_pk.vm_pk.get_vk(), internal_fri_params: self.internal_vm_pk.fri_params, internal_commit: self.internal_committed_exe.get_program_commit(), + root_vm_vk: self.root_vm_pk.vm_pk.get_vk(), } } } @@ -550,104 +770,6 @@ pub(crate) fn chunk_ceno_leaf_proof_inputs( ret } -// Source from OpenVm SDK::verify_e2e_stark_proof with abridged key -// See: https://github.com/openvm-org/openvm -pub fn verify_e2e_stark_proof( - k: &CenoRecursionVerifierKeys, - proof: &VmStarkProof, - _expected_exe_commit: &Bn254Fr, - _expected_vm_commit: &Bn254Fr, -) -> Result { - if proof.inner.per_air.len() < 3 { - return Err("Invalid number of AIRs: expected at least 3".into()); - } else if proof.inner.per_air[0].air_id != PROGRAM_AIR_ID { - return Err("Missing program AIR".into()); - } else if proof.inner.per_air[1].air_id != CONNECTOR_AIR_ID { - return Err("Missing connector AIR".into()); - } else if proof.inner.per_air[2].air_id != PUBLIC_VALUES_AIR_ID { - return Err("Missing public values AIR".into()); - } - let public_values_air_proof_data = &proof.inner.per_air[2]; - - let program_commit = proof.inner.commitments.main_trace[PROGRAM_CACHED_TRACE_INDEX].as_ref(); - let internal_commit: &[_; CHUNK] = &k.internal_commit.into(); - - let (vm_vk, fri_params, vm_commit) = if program_commit == internal_commit { - let internal_pvs: &InternalVmVerifierPvs<_> = public_values_air_proof_data - .public_values - .as_slice() - .borrow(); - if internal_commit != &internal_pvs.extra_pvs.internal_program_commit { - return Err(format!( - "Invalid internal program commit: expected {:?}, got {:?}", - internal_commit, internal_pvs.extra_pvs.internal_program_commit - )); - } - ( - &k.internal_vm_vk, - k.internal_fri_params, - internal_pvs.extra_pvs.leaf_verifier_commit, - ) - } else { - (&k.leaf_vm_vk, k.leaf_fri_params, *program_commit) - }; - let e = BabyBearPoseidon2Engine::new(fri_params); - e.verify(vm_vk, &proof.inner) - .expect("stark e2e proof verification should pass"); - - let pvs: &VmVerifierPvs<_> = - public_values_air_proof_data.public_values[..VmVerifierPvs::::width()].borrow(); - - // _debug: AIR ordering - // if let Some(exit_code) = pvs.connector.exit_code() { - // if exit_code != 0 { - // return Err(format!( - // "Invalid exit code: expected 0, got {}", - // exit_code - // )); - // } - // } else { - // return Err(format!("Program did not terminate")); - // } - - let hasher = vm_poseidon2_hasher(); - let _public_values_root = hasher.merkle_root(&proof.user_public_values); - // _debug: Public value commitment - // if public_values_root != pvs.public_values_commit { - // return Err(format!( - // "Invalid public values root: expected {:?}, got {:?}", - // pvs.public_values_commit, - // public_values_root - // )); - // } - - let exe_commit = compute_exe_commit( - &hasher, - &pvs.app_commit, - &pvs.memory.initial_root, - pvs.connector.initial_pc, - ); - let app_commit = AppExecutionCommit::from_field_commit(exe_commit, vm_commit); - let _exe_commit_bn254 = app_commit.app_exe_commit.to_bn254(); - let _vm_commit_bn254 = app_commit.app_vm_commit.to_bn254(); - - // _debug: execution commit checks - // if exe_commit_bn254 != *expected_exe_commit { - // return Err(eyre::eyre!( - // "Invalid app exe commit: expected {:?}, got {:?}", - // expected_exe_commit, - // exe_commit_bn254 - // )); - // } else if vm_commit_bn254 != *expected_vm_commit { - // return Err(eyre::eyre!( - // "Invalid app vm commit: expected {:?}, got {:?}", - // expected_vm_commit, - // vm_commit_bn254 - // )); - // } - Ok(app_commit) -} - /// Build Ceno's zkVM verifier program from vk in OpenVM's eDSL pub fn build_zkvm_verifier_program( vk: &ZKVMVerifyingKey>, @@ -706,9 +828,10 @@ pub fn verify_proofs( #[cfg(test)] mod tests { - use super::verify_e2e_stark_proof; use crate::{ - aggregation::{CenoAggregationProver, verify_proofs}, + aggregation::{ + CenoAggregationProver, F, RootVmVerifierInput, ZKVMProofInput, verify_proofs, + }, zkvm_verifier::binding::E, }; use ceno_zkvm::{ @@ -717,15 +840,17 @@ mod tests { structs::ZKVMVerifyingKey, }; use mpcs::{Basefold, BasefoldRSParams}; - use openvm_stark_sdk::{config::setup_tracing_with_log_level, p3_bn254_fr::Bn254Fr}; - use p3::field::FieldAlgebra; + use openvm_sdk::SC; + use openvm_stark_backend::proof::Proof; + use openvm_stark_sdk::config::setup_tracing_with_log_level; use std::fs::File; - pub fn aggregation_inner_thread() { + pub fn root_proof_permutation_inner_thread() { setup_tracing_with_log_level(tracing::Level::WARN); let proof_path = "./src/imported/proof.bin"; let vk_path = "./src/imported/vk.bin"; + let internal_proof_path = "./src/exports/internal_proof.bin"; let zkvm_proofs: Vec>> = bincode::deserialize_from(File::open(proof_path).expect("Failed to open proof file")) @@ -734,18 +859,51 @@ mod tests { let vk: ZKVMVerifyingKey> = bincode::deserialize_from(File::open(vk_path).expect("Failed to open vk file")) .expect("Failed to deserialize vk file"); - let mut agg_prover = CenoAggregationProver::from_base_vk(vk); - let root_stark_proof = agg_prover.generate_root_proof(zkvm_proofs); // _debug - verify_e2e_stark_proof( - &agg_prover.vk, - &root_stark_proof, - &Bn254Fr::ZERO, - &Bn254Fr::ZERO, + let internal_proof: Proof = bincode::deserialize_from( + File::open(internal_proof_path).expect("Failed to open proof file"), ) - .expect("Verify e2e stark proof should pass"); + .expect("Failed to deserialize proof file"); + + let zkvm_proof_inputs: Vec = zkvm_proofs + .into_iter() + .enumerate() + .map(|(shard_id, p)| ZKVMProofInput::from_proof(shard_id, p, &agg_prover.base_vk)) + .collect(); + let user_public_values: Vec = zkvm_proof_inputs + .iter() + .flat_map(|p| p.raw_pi.iter().flat_map(|v| v.clone()).collect::>()) + .collect(); + let root_input = RootVmVerifierInput { + proofs: vec![internal_proof], + public_values: user_public_values, + }; + + agg_prover.init_root_prover_with_permutation(&root_input); + } + + pub fn aggregation_inner_thread() { + setup_tracing_with_log_level(tracing::Level::WARN); + + let proof_path = "./src/imported/proof.bin"; + let vk_path = "./src/imported/vk.bin"; + + let zkvm_proofs: Vec>> = + bincode::deserialize_from(File::open(proof_path).expect("Failed to open proof file")) + .expect("Failed to deserialize proof file"); + + let vk: ZKVMVerifyingKey> = + bincode::deserialize_from(File::open(vk_path).expect("Failed to open vk file")) + .expect("Failed to deserialize vk file"); + + let mut agg_prover = CenoAggregationProver::from_base_vk(vk); + let root_proof = agg_prover.generate_root_proof(zkvm_proofs); + let halo2_proof = agg_prover.prove_static(&root_proof); + agg_prover + .verify_static(halo2_proof) + .expect("halo2 proof is ok"); } pub fn verify_single_inner_thread() { @@ -785,9 +943,22 @@ mod tests { #[test] #[ignore = "need to generate proof first"] - pub fn test_aggregation() { + pub fn test_root_proof_permutation() { let stack_size = 256 * 1024 * 1024; // 64 MB + let handler = std::thread::Builder::new() + .stack_size(stack_size) + .spawn(root_proof_permutation_inner_thread) + .expect("Failed to spawn thread"); + + handler.join().expect("Thread panicked"); + } + + #[test] + #[ignore = "need to generate proof first"] + pub fn test_aggregation() { + let stack_size = 1024 * 1024 * 1024; // 512 MB + let handler = std::thread::Builder::new() .stack_size(stack_size) .spawn(aggregation_inner_thread) diff --git a/ceno_recursion/src/aggregation/root.rs b/ceno_recursion/src/aggregation/root.rs index 746672af6..f506e97ac 100644 --- a/ceno_recursion/src/aggregation/root.rs +++ b/ceno_recursion/src/aggregation/root.rs @@ -1,6 +1,170 @@ -// TODO: assert that the shard ram ec point is `PointAtInfinity` +use openvm_continuations::{C, F, SC}; +use openvm_instructions::program::Program; +use openvm_native_compiler::{ + conversion::CompilerOptions, + ir::{Array, Builder, Config, DIGEST_SIZE, Felt, Variable}, +}; +use openvm_native_recursion::{ + fri::TwoAdicFriPcsVariable, hints::Hintable, types::new_from_inner_multi_vk, + utils::const_fri_config, +}; +use openvm_stark_backend::keygen::types::MultiStarkVerifyingKey; +use openvm_stark_sdk::config::FriParameters; +use std::array; -// let is_sum_x_zero = ec_sum.x.is_zero(builder); -// let is_sum_y_zero = ec_sum.y.is_zero(builder); -// builder.assert_usize_eq(is_sum_x_zero, Usize::from(1)); -// builder.assert_usize_eq(is_sum_y_zero, Usize::from(1)); +use crate::aggregation::{SEPTIC_EXTENSION_DEGREE, internal::NonLeafVerifierVariables}; +use openvm_native_compiler::prelude::*; +use openvm_native_recursion::vars::StarkProofVariable; +use openvm_stark_sdk::openvm_stark_backend::{ + config::{StarkGenericConfig, Val}, + proof::Proof, +}; +use p3::field::FieldAlgebra; +use serde::{Deserialize, Serialize}; + +#[derive(Serialize, Deserialize)] +pub struct CenoRootVmVerifierInput { + /// The proofs of leaf verifier or internal verifier in the execution order. + pub proofs: Vec>, + /// Public values to expose directly + pub public_values: Vec>, +} + +#[derive(DslVariable, Clone)] +pub struct CenoRootVmVerifierInputVariable { + /// The proofs of leaf verifier or internal verifier in the execution order. + pub proofs: Array>, + /// Public values to expose + pub public_values: Array>, +} + +impl Hintable for CenoRootVmVerifierInput { + type HintVariable = CenoRootVmVerifierInputVariable; + + fn read(builder: &mut Builder) -> Self::HintVariable { + let proofs = Vec::>::read(builder); + let public_values = Vec::>::read(builder); + Self::HintVariable { + proofs, + public_values, + } + } + + fn write(&self) -> Vec::N>> { + let mut stream = self.proofs.write(); + stream.extend(self.public_values.write()); + stream + } +} + +pub struct CenoRootVmVerifierConfig { + pub leaf_fri_params: FriParameters, + pub internal_fri_params: FriParameters, + pub num_user_public_values: usize, + pub internal_vm_verifier_commit: [F; DIGEST_SIZE], + pub compiler_options: CompilerOptions, +} + +#[derive(Debug)] +pub struct CenoRootVmVerifierPvs { + pub init_pc: T, + pub public_values: Vec, +} +impl CenoRootVmVerifierPvs { + pub fn flatten(self) -> Vec { + let mut ret = vec![]; + ret.extend(vec![self.init_pc]); + ret.extend(self.public_values); + ret + } + + pub fn from_flatten(flatten: Vec) -> Self { + let init_pc = flatten[1]; + let public_values = flatten[1..].to_vec(); + + Self { + init_pc, + public_values, + } + } +} + +impl CenoRootVmVerifierConfig { + pub fn build_program( + &self, + leaf_vm_vk: &MultiStarkVerifyingKey, + internal_vm_vk: &MultiStarkVerifyingKey, + ) -> Program { + let mut builder = Builder::::default(); + + builder.cycle_tracker_start("ReadProofsFromInput"); + let root_verifier_input = CenoRootVmVerifierInput::::read(&mut builder); + builder.cycle_tracker_end("ReadProofsFromInput"); + + let pvs = { + let leaf_advice = new_from_inner_multi_vk(leaf_vm_vk); + let internal_advice = new_from_inner_multi_vk(internal_vm_vk); + let CenoRootVmVerifierInputVariable { + proofs, + public_values, + } = root_verifier_input; + + builder.cycle_tracker_start("InitializePcsConst"); + let leaf_pcs = TwoAdicFriPcsVariable { + config: const_fri_config(&mut builder, &self.leaf_fri_params), + }; + let internal_pcs = TwoAdicFriPcsVariable { + config: const_fri_config(&mut builder, &self.internal_fri_params), + }; + builder.cycle_tracker_end("InitializePcsConst"); + let internal_program_commit = + array::from_fn(|i| builder.eval(self.internal_vm_verifier_commit[i])); + builder.cycle_tracker_start("VerifyProofs"); + let non_leaf_verifier = NonLeafVerifierVariables { + internal_program_commit, + leaf_pcs, + leaf_advice, + internal_pcs, + internal_advice, + }; + let (merged_pvs, _expected_leaf_commit) = + non_leaf_verifier.verify_internal_or_leaf_verifier_proofs(&mut builder, &proofs); + builder.cycle_tracker_end("VerifyProofs"); + + // Assert final ec sum is zero + let z: Felt<_> = builder.constant(::F::ZERO); + for i in 0..SEPTIC_EXTENSION_DEGREE { + builder.assert_felt_eq(merged_pvs.shard_ram_connector.x[i], z); + builder.assert_felt_eq(merged_pvs.shard_ram_connector.y[i], z); + } + let one: Felt<_> = builder.constant(::F::ONE); + builder.assert_felt_eq(merged_pvs.shard_ram_connector.is_infinity, one); + + /* _todo: Change merged pv operations, including checking final ec sum is infinity + // App Program should terminate + builder.assert_felt_eq(merged_pvs.connector.is_terminate, F::ONE); + // App Program should exit successfully + builder.assert_felt_eq(merged_pvs.connector.exit_code, F::ZERO); + */ + + builder.cycle_tracker_start("ExtractPublicValues"); + // builder.assert_usize_eq(public_values.len(), RVar::from(self.num_user_public_values)); + let public_values_vec: Vec> = (0..(self.num_user_public_values - 1)) // The init_pc is read separately + .map(|i| builder.get(&public_values, i)) + .collect(); + builder.cycle_tracker_end("ExtractPublicValues"); + + CenoRootVmVerifierPvs { + init_pc: merged_pvs.connector.initial_pc, + public_values: public_values_vec, + } + }; + + pvs.flatten() + .into_iter() + .for_each(|v| builder.commit_public_value(v)); + + builder.halt(); + builder.compile_isa_with_options(self.compiler_options) + } +} diff --git a/ceno_recursion/src/aggregation/statics.rs b/ceno_recursion/src/aggregation/statics.rs new file mode 100644 index 000000000..438c412bb --- /dev/null +++ b/ceno_recursion/src/aggregation/statics.rs @@ -0,0 +1,196 @@ +use crate::{ + aggregation::{CenoRecursionProvingKeys, root::CenoRootVmVerifierPvs}, + zkvm_verifier::binding::F, +}; +use anyhow::Result; +use openvm_continuations::{ + RootSC, static_verifier::StaticVerifierPvHandler, verifier::common::types::SpecialAirIds, +}; +#[cfg(feature = "gpu")] +use openvm_cuda_backend::engine::GpuBabyBearPoseidon2Engine as BabyBearPoseidon2Engine; +use openvm_native_circuit::NativeConfig; +use openvm_native_compiler::ir::Builder; +use openvm_native_recursion::{ + config::outer::OuterConfig, + halo2::{ + RawEvmProof, + utils::{CacheHalo2ParamsReader, Halo2ParamsReader}, + wrapper::{FallbackEvmVerifier, Halo2WrapperProvingKey}, + }, + vars::StarkProofVariable, +}; +use openvm_sdk::{config::Halo2Config, keygen::Halo2ProvingKey, prover::Halo2Prover}; +use openvm_stark_backend::proof::Proof; +use openvm_stark_sdk::config::baby_bear_poseidon2::BabyBearPoseidon2Config; +use p3::field::FieldAlgebra; +use std::{env, path::Path, sync::Arc}; +pub const HALO2_VERIFIER_K: usize = 23; + +pub struct StaticProverVerifier { + config: Halo2Config, + params_reader: CacheHalo2ParamsReader, + static_pv_handler: StaticPvHandler, + prover: Option, // expensive to construct + verifier: Option, +} + +pub struct StaticPvHandler { + pub _init_pc: F, +} +impl StaticPvHandler { + pub fn init() -> Self { + Self { _init_pc: F::ZERO } + } +} + +impl StaticVerifierPvHandler for StaticPvHandler { + fn handle_public_values( + &self, + builder: &mut Builder, + input: &StarkProofVariable, + special_air_ids: &SpecialAirIds, + ) -> usize { + let pv_air = builder.get(&input.per_air, special_air_ids.public_values_air_id); + let public_values: Vec<_> = pv_air + .public_values + .vec() + .into_iter() + .map(|x| builder.cast_felt_to_var(x)) + .collect(); + let pvs = CenoRootVmVerifierPvs::from_flatten(public_values); + + pvs.public_values.len() + } +} +impl Default for StaticProverVerifier { + fn default() -> Self { + Self::new() + } +} +impl StaticProverVerifier { + pub fn new() -> Self { + let params_reader = + CacheHalo2ParamsReader::new(Path::new(env!("CARGO_MANIFEST_DIR")).join("src/params/")); + let halo2_config = Halo2Config { + verifier_k: HALO2_VERIFIER_K, + wrapper_k: None, // Auto-tuned + profiling: false, + }; + let static_pv_handler = StaticPvHandler::init(); + Self { + config: halo2_config, + params_reader, + static_pv_handler, + prover: None, + verifier: None, + } + } + pub fn init( + &mut self, + root_proof: &Proof, + ceno_recursion_key: &CenoRecursionProvingKeys, + ) { + assert!(ceno_recursion_key.permuted_root_pk.is_some()); + + let verifier = ceno_recursion_key + .permuted_root_pk + .as_ref() + .unwrap() + .keygen_static_verifier( + &self.params_reader.read_params(self.config.verifier_k), + root_proof.clone(), + &self.static_pv_handler, + ); + let dummy_snark = verifier.generate_dummy_snark(&self.params_reader); + let wrapper = if let Some(wrapper_k) = self.config.wrapper_k { + Halo2WrapperProvingKey::keygen(&self.params_reader.read_params(wrapper_k), dummy_snark) + } else { + Halo2WrapperProvingKey::keygen_auto_tune(&self.params_reader, dummy_snark) + }; + + let halo2_pk = Halo2ProvingKey { + verifier: Arc::new(verifier), + wrapper: Arc::new(wrapper), + profiling: self.config.profiling, + }; + + // Update prover/verifier + // let wrapper_k = halo2_pk.wrapper.pinning.metadata.config_params.k; + // let params = self.params_reader.read_params(wrapper_k); + // let static_verifier = halo2_pk.wrapper.generate_fallback_evm_verifier(¶ms); + let prover = Halo2Prover::new(&self.params_reader, halo2_pk); + + self.prover = Some(prover); + // self.verifier = Some(static_verifier); + } + + pub fn prove_static( + &mut self, + root_proof: &Proof, + ceno_recursion_key: &CenoRecursionProvingKeys, + ) -> RawEvmProof { + if self.prover.is_none() { + self.init(root_proof, ceno_recursion_key); + } + self.prover + .as_ref() + .unwrap() + .prove_for_evm(root_proof) + .try_into() + .expect("generate halo2 proof") + } + + pub fn verify_static(&mut self, proof: RawEvmProof) -> Result<()> { + let static_verifier = self + .verifier + .as_ref() + .expect("static verifier must be initiated"); + Halo2WrapperProvingKey::evm_verify(static_verifier, &proof).unwrap(); + Ok(()) + } +} + +#[cfg(test)] +mod tests { + use crate::{aggregation::CenoAggregationProver, zkvm_verifier::binding::E}; + use ceno_zkvm::structs::ZKVMVerifyingKey; + use mpcs::{Basefold, BasefoldRSParams}; + use openvm_continuations::RootSC; + use openvm_stark_backend::proof::Proof; + use openvm_stark_sdk::config::setup_tracing_with_log_level; + use std::fs::File; + + pub fn test_static_verifier_inner_thread() { + setup_tracing_with_log_level(tracing::Level::WARN); + + let vk_path = "./src/imported/vk.bin"; + let vk: ZKVMVerifyingKey> = + bincode::deserialize_from(File::open(vk_path).expect("Failed to open vk file")) + .expect("Failed to deserialize vk file"); + let mut agg_prover = CenoAggregationProver::from_base_vk(vk); + + let root_proof_path = "./src/exports/root_proof.bin"; + let root_proof: Proof = bincode::deserialize_from( + File::open(root_proof_path).expect("Failed to open proof file"), + ) + .expect("Deserialize root proof"); + + let halo2_proof = agg_prover.prove_static(&root_proof); + agg_prover + .verify_static(halo2_proof) + .expect("halo2 proof exists"); + } + + #[test] + #[ignore = "need to generate proof first"] + pub fn test_static_verifier() { + let stack_size = 256 * 1024 * 1024; // 64 MB + + let handler = std::thread::Builder::new() + .stack_size(stack_size) + .spawn(test_static_verifier_inner_thread) + .expect("Failed to spawn thread"); + + handler.join().expect("Thread panicked"); + } +} diff --git a/ceno_recursion/src/aggregation/types.rs b/ceno_recursion/src/aggregation/types.rs index be88a6fb8..cf244aec2 100644 --- a/ceno_recursion/src/aggregation/types.rs +++ b/ceno_recursion/src/aggregation/types.rs @@ -1,38 +1,111 @@ -// TODO: enable this -// #[derive(Debug, Clone, AlignedBorrow)] -// pub struct ContinuationPvs { -// pub sum: SepticPoint, -// } - -// impl ContinuationPvs> { -// pub fn uninit(builder: &mut Builder) -> Self { -// todo!() -// } -// } - -// #[derive(Debug, Clone, AlignedBorrow)] -// #[repr(C)] -// pub struct VmVerifierPvs { -// /// The merged execution state of all the segments this circuit aggregates. -// pub connector: VmConnectorPvs, -// /// The state before/after all the segments this circuit aggregates. -// // (TODO) pub shard_ram_connector: ContinuationPvs, -// /// The merkle root of all public values. This is only meaningful when the last segment is -// /// aggregated by this circuit. -// pub public_values_commit: [T; DIGEST_SIZE], -// } - -// impl VmVerifierPvs> { -// pub fn uninit(builder: &mut Builder) -> Self { -// VmVerifierPvs { -// connector: VmConnectorPvs { -// initial_pc: builder.uninit(), -// final_pc: builder.uninit(), -// exit_code: builder.uninit(), -// is_terminate: builder.uninit(), -// }, -// // shard_ram_connector: builder.uninit(), -// public_values_commit: array::from_fn(|_| builder.uninit()), -// } -// } -// } +use ceno_zkvm::scheme::constants::SEPTIC_EXTENSION_DEGREE; +use openvm_circuit::{circuit_derive::AlignedBorrow, system::connector::VmConnectorPvs}; +use openvm_native_compiler::ir::{Builder, Config, DIGEST_SIZE, Felt, Variable}; +use p3::field::PrimeField32; +use std::{array, borrow::BorrowMut}; + +#[derive(Clone, Copy, AlignedBorrow)] +pub struct ContinuationPvs { + pub x: [T; SEPTIC_EXTENSION_DEGREE], + pub y: [T; SEPTIC_EXTENSION_DEGREE], + pub is_infinity: T, +} + +impl ContinuationPvs> { + pub fn uninit>(builder: &mut Builder) -> Self { + Self { + x: array::from_fn(|_| builder.uninit()), + y: array::from_fn(|_| builder.uninit()), + is_infinity: Felt::uninit(builder), + } + } +} + +#[derive(Clone, Copy, AlignedBorrow)] +#[repr(C)] +pub struct VmVerifierPvs { + /// The merged execution state of all the segments this circuit aggregates. + pub connector: VmConnectorPvs, + /// The state before/after all the segments this circuit aggregates. + pub shard_ram_connector: ContinuationPvs, + /// The merkle root of all public values. This is only meaningful when the last segment is + /// aggregated by this circuit. + pub public_values_commit: [T; DIGEST_SIZE], +} + +impl VmVerifierPvs> { + pub fn uninit>(builder: &mut Builder) -> Self { + VmVerifierPvs { + connector: VmConnectorPvs { + initial_pc: builder.uninit(), + final_pc: builder.uninit(), + exit_code: builder.uninit(), + is_terminate: builder.uninit(), + }, + shard_ram_connector: ContinuationPvs::uninit(builder), + public_values_commit: array::from_fn(|_| builder.uninit()), + } + } +} + +impl VmVerifierPvs> { + pub fn flatten(self) -> Vec> { + let mut v = vec![Felt(0, Default::default()); VmVerifierPvs::::width()]; + *v.as_mut_slice().borrow_mut() = self; + v + } +} + +/// Aggregated state of all segments +#[derive(Clone, Copy, AlignedBorrow)] +#[repr(C)] +pub struct InternalVmVerifierPvs { + pub vm_verifier_pvs: VmVerifierPvs, + pub extra_pvs: InternalVmVerifierExtraPvs, +} + +/// Extra PVs for internal VM verifier except VmVerifierPvs. +#[derive(Clone, Copy, AlignedBorrow)] +#[repr(C)] +pub struct InternalVmVerifierExtraPvs { + /// The commitment of the leaf verifier program. + pub leaf_verifier_commit: [T; DIGEST_SIZE], + /// For recursion verification, a program need its own commitment, but its own commitment + /// cannot be hardcoded inside the program itself. So the commitment has to be read from + /// external and be committed. + pub internal_program_commit: [T; DIGEST_SIZE], +} + +impl InternalVmVerifierPvs> { + pub fn uninit>(builder: &mut Builder) -> Self { + Self { + vm_verifier_pvs: VmVerifierPvs::>::uninit(builder), + extra_pvs: InternalVmVerifierExtraPvs::>::uninit(builder), + } + } +} + +impl InternalVmVerifierPvs> { + pub fn flatten(self) -> Vec> { + let mut v = vec![Felt(0, Default::default()); InternalVmVerifierPvs::::width()]; + *v.as_mut_slice().borrow_mut() = self; + v + } +} + +impl InternalVmVerifierExtraPvs> { + pub fn uninit>(builder: &mut Builder) -> Self { + Self { + leaf_verifier_commit: array::from_fn(|_| builder.uninit()), + internal_program_commit: array::from_fn(|_| builder.uninit()), + } + } +} + +impl InternalVmVerifierExtraPvs> { + pub fn flatten(self) -> Vec> { + let mut v = vec![Felt(0, Default::default()); InternalVmVerifierExtraPvs::::width()]; + *v.as_mut_slice().borrow_mut() = self; + v + } +} diff --git a/ceno_recursion/src/arithmetics/mod.rs b/ceno_recursion/src/arithmetics/mod.rs index 4d78d0315..5635b68d6 100644 --- a/ceno_recursion/src/arithmetics/mod.rs +++ b/ceno_recursion/src/arithmetics/mod.rs @@ -1063,7 +1063,7 @@ mod tests { let system_config = SystemConfig::default() .with_public_values(20) .with_max_segment_len((1 << 22) - 100); - let config = NativeConfig::new(system_config, Native); + let config = NativeConfig::new(system_config, Native(true)); let executor = VmExecutor::::new(config).expect("executor initiation"); let exe = VmExe::new(program); diff --git a/ceno_recursion/src/basefold_verifier/hash.rs b/ceno_recursion/src/basefold_verifier/hash.rs index d13d790ac..d177d20b4 100644 --- a/ceno_recursion/src/basefold_verifier/hash.rs +++ b/ceno_recursion/src/basefold_verifier/hash.rs @@ -74,7 +74,7 @@ mod tests { // configure the VM executor let system_config = SystemConfig::default().with_max_segment_len(1 << 20); - let config = NativeConfig::new(system_config, Native); + let config = NativeConfig::new(system_config, Native(true)); let executor = VmExecutor::new(config).unwrap(); // prepare input diff --git a/ceno_recursion/src/basefold_verifier/mmcs.rs b/ceno_recursion/src/basefold_verifier/mmcs.rs index d4a59e0ad..973a67501 100644 --- a/ceno_recursion/src/basefold_verifier/mmcs.rs +++ b/ceno_recursion/src/basefold_verifier/mmcs.rs @@ -255,7 +255,7 @@ pub mod tests { let system_config = SystemConfig::default() .with_public_values(4) .with_max_segment_len((1 << 25) - 100); - let config = NativeConfig::new(system_config, Native); + let config = NativeConfig::new(system_config, Native(true)); let executor = VmExecutor::::new(config).unwrap(); diff --git a/ceno_recursion/src/basefold_verifier/query_phase.rs b/ceno_recursion/src/basefold_verifier/query_phase.rs index 6bf40113f..a158fa4b7 100644 --- a/ceno_recursion/src/basefold_verifier/query_phase.rs +++ b/ceno_recursion/src/basefold_verifier/query_phase.rs @@ -944,7 +944,7 @@ pub mod tests { let system_config = SystemConfig::default() .with_public_values(4) .with_max_segment_len((1 << 25) - 100); - let config = NativeConfig::new(system_config, Native); + let config = NativeConfig::new(system_config, Native(true)); let exe = VmExe::new(program); let executor = VmExecutor::::new(config.clone()).unwrap(); diff --git a/ceno_recursion/src/basefold_verifier/rs.rs b/ceno_recursion/src/basefold_verifier/rs.rs index c70ce2d49..305753a30 100644 --- a/ceno_recursion/src/basefold_verifier/rs.rs +++ b/ceno_recursion/src/basefold_verifier/rs.rs @@ -274,7 +274,7 @@ pub mod tests { let system_config = SystemConfig::default() .with_public_values(4) .with_max_segment_len((1 << 25) - 100); - let config = NativeConfig::new(system_config, Native); + let config = NativeConfig::new(system_config, Native(true)); let executor = VmExecutor::::new(config).unwrap(); let exe = VmExe::new(program); diff --git a/ceno_recursion/src/basefold_verifier/verifier.rs b/ceno_recursion/src/basefold_verifier/verifier.rs index c343660d0..6ce433eab 100644 --- a/ceno_recursion/src/basefold_verifier/verifier.rs +++ b/ceno_recursion/src/basefold_verifier/verifier.rs @@ -374,7 +374,7 @@ pub mod tests { .with_public_values(4) .with_max_segment_len((1 << 25) - 100) .with_profiling(); - let config = NativeConfig::new(system_config, Native); + let config = NativeConfig::new(system_config, Native(true)); // _debug // let executor = VmExecutor::::new(config); diff --git a/ceno_recursion/src/bin/e2e_aggregate.rs b/ceno_recursion/src/bin/e2e_aggregate.rs index 7f6e94120..ca5235877 100644 --- a/ceno_recursion/src/bin/e2e_aggregate.rs +++ b/ceno_recursion/src/bin/e2e_aggregate.rs @@ -270,5 +270,6 @@ fn main() { let vk = result.vk.expect("PrepSanityCheck should yield vk."); let mut agg_prover = CenoAggregationProver::from_base_vk(vk); - let _ = agg_prover.generate_root_proof(zkvm_proofs); + let root_proof = agg_prover.generate_root_proof(zkvm_proofs); + let _halo2_proof = agg_prover.prove_static(&root_proof); } diff --git a/ceno_recursion/src/exports/.keep b/ceno_recursion/src/exports/.keep new file mode 100644 index 000000000..e69de29bb diff --git a/ceno_recursion/src/extensions/mod.rs b/ceno_recursion/src/extensions/mod.rs index 6e92fbd60..d518774f8 100644 --- a/ceno_recursion/src/extensions/mod.rs +++ b/ceno_recursion/src/extensions/mod.rs @@ -49,7 +49,7 @@ mod tests { .with_public_values(4) .with_max_segment_len((1 << 25) - 100); system_config.profiling = true; - let config = NativeConfig::new(system_config, Native); + let config = NativeConfig::new(system_config, Native(true)); let executor = VmExecutor::::new(config).unwrap(); let exe = VmExe::new(program); diff --git a/ceno_recursion/src/params/.keep b/ceno_recursion/src/params/.keep new file mode 100644 index 000000000..e69de29bb diff --git a/ceno_recursion/src/zkvm_verifier/binding.rs b/ceno_recursion/src/zkvm_verifier/binding.rs index ab7cad5f4..8492e5f18 100644 --- a/ceno_recursion/src/zkvm_verifier/binding.rs +++ b/ceno_recursion/src/zkvm_verifier/binding.rs @@ -11,7 +11,7 @@ use crate::{ }, }; use ceno_zkvm::{ - scheme::{ZKVMChipProof, ZKVMProof}, + scheme::{ZKVMChipProof, ZKVMProof, constants::SEPTIC_EXTENSION_DEGREE}, structs::{EccQuarkProof, TowerProofs, ZKVMVerifyingKey}, }; use gkr_iop::gkr::{GKRProof, layer::sumcheck_layer::LayerProof}; @@ -858,6 +858,27 @@ pub struct SepticPointVariable { pub is_infinity: Usize, } +impl SepticPointVariable { + pub fn zero(builder: &mut Builder) -> Self { + let r = SepticPointVariable { + x: SepticExtensionVariable { + vs: builder.dyn_array(7), + }, + y: SepticExtensionVariable { + vs: builder.dyn_array(7), + }, + is_infinity: Usize::uninit(builder), + }; + let z: Ext = builder.constant(C::EF::ZERO); + for i in 0..SEPTIC_EXTENSION_DEGREE { + builder.set(&r.x.vs, i, z); + builder.set(&r.y.vs, i, z); + } + builder.assign(&r.is_infinity, Usize::from(1)); + r + } +} + pub struct EccQuarkProofInput { pub zerocheck_proof: IOPProof, pub num_instances: usize, diff --git a/ceno_recursion/src/zkvm_verifier/verifier.rs b/ceno_recursion/src/zkvm_verifier/verifier.rs index 6883cdd45..85d13c972 100644 --- a/ceno_recursion/src/zkvm_verifier/verifier.rs +++ b/ceno_recursion/src/zkvm_verifier/verifier.rs @@ -236,15 +236,7 @@ pub fn verify_zkvm_proof>( let witin_openings: Array> = builder.dyn_array(proofs_len.clone()); let fixed_openings: Array> = builder.dyn_array(proofs_len); - let shard_ec_sum = SepticPointVariable { - x: SepticExtensionVariable { - vs: builder.dyn_array(7), - }, - y: SepticExtensionVariable { - vs: builder.dyn_array(7), - }, - is_infinity: Usize::uninit(builder), - }; + let shard_ec_sum = SepticPointVariable::zero(builder); let num_chips_verified: Usize = builder.eval(C::N::ZERO); let num_fixed_openings: Usize = builder.eval(C::N::ZERO); @@ -561,16 +553,7 @@ pub fn verify_chip_proof( &num_var_with_rotation, log2_num_instances.clone() + Usize::from(composed_cs.rotation_vars().unwrap_or(0)), ); - - let shard_ec_sum = SepticPointVariable { - x: SepticExtensionVariable { - vs: builder.dyn_array(7), - }, - y: SepticExtensionVariable { - vs: builder.dyn_array(7), - }, - is_infinity: Usize::uninit(builder), - }; + let shard_ec_sum = SepticPointVariable::zero(builder); if composed_cs.has_ecc_ops() { builder.assert_nonzero(&chip_proof.has_ecc_proof); @@ -1962,7 +1945,11 @@ pub fn septic_ext_squared( builder: &mut Builder, a: &SepticExtensionVariable, ) -> SepticExtensionVariable { + let z: Ext = builder.constant(C::EF::ZERO); let r: Array> = builder.dyn_array(SEPTIC_EXTENSION_DEGREE); + for i in 0..SEPTIC_EXTENSION_DEGREE { + builder.set(&r, i, z); + } let two_ext: Ext = builder.constant(C::EF::TWO); let five_ext: Ext = builder.constant(C::EF::from_canonical_u32(5)); @@ -2041,7 +2028,11 @@ pub fn septic_ext_mul( a: &SepticExtensionVariable, b: &SepticExtensionVariable, ) -> SepticExtensionVariable { + let z: Ext = builder.constant(C::EF::ZERO); let r: Array> = builder.dyn_array(SEPTIC_EXTENSION_DEGREE); + for i in 0..SEPTIC_EXTENSION_DEGREE { + builder.set(&r, i, z); + } let two_ext: Ext = builder.constant(C::EF::TWO); let five_ext: Ext = builder.constant(C::EF::from_canonical_u32(5)); @@ -2292,10 +2283,8 @@ pub fn add_septic_points_in_place( let y_sum = septic_ext_add(builder, &right.y, &left.y); let is_y_sum_zero = y_sum.is_zero(builder); builder.assert_usize_eq(is_y_sum_zero, Usize::from(1)); - let zero_ext_arr: Array> = - builder.dyn_array(SEPTIC_EXTENSION_DEGREE); - builder.assign(&left.x, zero_ext_arr.clone()); - builder.assign(&left.y, zero_ext_arr.clone()); + builder.assign(&left.x, y_sum.clone()); + builder.assign(&left.y, y_sum.clone()); builder.assign(&left.is_infinity, Usize::from(1)); }, );