diff --git a/.github/dependabot.yml b/.github/dependabot.yml index 993078a27f..d9cc194302 100644 --- a/.github/dependabot.yml +++ b/.github/dependabot.yml @@ -5,8 +5,15 @@ updates: schedule: interval: "weekly" target-branch: "dev" + ignore: + - dependency-name: "axum" + versions: ["> 0.7.4"] - package-ecosystem: "docker" directory: "/cli/docker" schedule: interval: "weekly" - target-branch: "dev" \ No newline at end of file + target-branch: "dev" + - package-ecosystem: "github-actions" + directory: "/" + schedule: + interval: "weekly" diff --git a/.github/workflows/docker-gnark.yml b/.github/workflows/docker-gnark.yml new file mode 100644 index 0000000000..8f9ca2b854 --- /dev/null +++ b/.github/workflows/docker-gnark.yml @@ -0,0 +1,39 @@ +name: Docker Gnark + +on: + push: + branches: [main] + pull_request: + branches: + - "**" + paths: + - "recursion/gnark-ffi/**" + - "recursion/gnark-cli/**" + - "!recursion/gnark-ffi/assets/**" + merge_group: + +jobs: + test-docker: + name: Test + runs-on: runs-on,runner=64cpu-linux-arm64,spot=false + env: + CARGO_NET_GIT_FETCH_WITH_CLI: "true" + steps: + - name: Checkout sources + uses: actions/checkout@v4 + + - name: Setup CI + uses: ./.github/actions/setup + + - name: Build docker image + run: | + docker build -t sp1-gnark -f ./Dockerfile.gnark-ffi . + + - name: Run cargo test + uses: actions-rs/cargo@v1 + env: + SP1_GNARK_IMAGE: sp1-gnark + with: + command: test + toolchain: nightly-2024-04-17 + args: --release -p sp1-prover -- --exact tests::test_e2e diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 50358ee7d1..075774d3e9 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -20,7 +20,7 @@ concurrency: jobs: plonk: name: Plonk Native - runs-on: runs-on,cpu=64,ram=256,family=m7i+m7a,hdd=80,image=ubuntu22-full-x64 + runs-on: runs-on,cpu=64,ram=256,family=m7i+m7a,hdd=80,image=ubuntu22-full-x64,spot=false env: CARGO_NET_GIT_FETCH_WITH_CLI: "true" steps: @@ -39,9 +39,10 @@ jobs: env: RUSTFLAGS: -Copt-level=3 -Cdebug-assertions -Coverflow-checks=y -Cdebuginfo=0 -C target-cpu=native RUST_BACKTRACE: 1 + plonk-docker: name: Plonk Docker - runs-on: runs-on,cpu=64,ram=256,family=m7i+m7a,hdd=80,image=ubuntu22-full-x64 + runs-on: runs-on,cpu=64,ram=256,family=m7i+m7a,hdd=80,image=ubuntu22-full-x64,spot=false env: CARGO_NET_GIT_FETCH_WITH_CLI: "true" steps: @@ -60,6 +61,7 @@ jobs: env: RUSTFLAGS: -Copt-level=3 -Cdebug-assertions -Coverflow-checks=y -Cdebuginfo=0 -C target-cpu=native RUST_BACKTRACE: 1 + check-branch: name: Check branch runs-on: ubuntu-latest @@ -69,3 +71,71 @@ jobs: run: | echo "ERROR: You can only merge to main from dev, release/*, or hotfix/*." exit 1 + + ssz-withdrawals: + name: Example (SSZ Withdrawals) + runs-on: runs-on,runner=64cpu-linux-arm64,spot=false + env: + CARGO_NET_GIT_FETCH_WITH_CLI: "true" + steps: + - name: Checkout sources + uses: actions/checkout@v4 + + - name: Setup CI + uses: ./.github/actions/setup + + - name: Install SP1 toolchain + run: | + curl -L https://sp1.succinct.xyz | bash + ~/.sp1/bin/sp1up + ~/.sp1/bin/cargo-prove prove --version + + - name: Install SP1 CLI + run: | + cd cli + cargo install --force --locked --path . + cd ~ + + - name: Run script + run: | + cd examples/ssz-withdrawals/program + cargo add sp1-zkvm --path $GITHUB_WORKSPACE/zkvm/entrypoint + cargo prove build + cd ../script + cargo remove sp1-sdk + cargo add sp1-sdk --path $GITHUB_WORKSPACE/sdk + SP1_DEV=1 RUST_LOG=info cargo run --release + + tendermint: + name: Example (Tendermint) + runs-on: runs-on,runner=64cpu-linux-arm64,spot=false + env: + CARGO_NET_GIT_FETCH_WITH_CLI: "true" + steps: + - name: Checkout sources + uses: actions/checkout@v4 + + - name: Setup CI + uses: ./.github/actions/setup + + - name: Install SP1 toolchain + run: | + curl -L https://sp1.succinct.xyz | bash + ~/.sp1/bin/sp1up + ~/.sp1/bin/cargo-prove prove --version + + - name: Install SP1 CLI + run: | + cd cli + cargo install --force --locked --path . + cd ~ + + - name: Run script + run: | + cd examples/tendermint/program + cargo add sp1-zkvm --path $GITHUB_WORKSPACE/zkvm/entrypoint + cargo prove build + cd ../script + cargo remove sp1-sdk + cargo add sp1-sdk --path $GITHUB_WORKSPACE/sdk + SP1_DEV=1 RUST_LOG=info cargo run --release diff --git a/.github/workflows/pr.yml b/.github/workflows/pr.yml index ac6a248770..1a670e47cd 100644 --- a/.github/workflows/pr.yml +++ b/.github/workflows/pr.yml @@ -16,6 +16,7 @@ on: - "zkvm/**" - "tests/**" - "examples/**" + - "Cargo.toml" - ".github/workflows/**" merge_group: @@ -26,7 +27,7 @@ concurrency: jobs: test-x86: name: Test (x86-64) - runs-on: runs-on,runner=64cpu-linux-x64 + runs-on: runs-on,runner=64cpu-linux-x64,spot=false env: CARGO_NET_GIT_FETCH_WITH_CLI: "true" steps: @@ -57,7 +58,7 @@ jobs: test-arm: name: Test (ARM) - runs-on: runs-on,runner=64cpu-linux-arm64 + runs-on: runs-on,runner=64cpu-linux-arm64,spot=false env: CARGO_NET_GIT_FETCH_WITH_CLI: "true" steps: @@ -86,31 +87,6 @@ jobs: FRI_QUERIES: 1 SP1_DEV: 1 - test-docker: - name: Test Docker - runs-on: runs-on,runner=64cpu-linux-arm64 - env: - CARGO_NET_GIT_FETCH_WITH_CLI: "true" - steps: - - name: Checkout sources - uses: actions/checkout@v4 - - - name: Setup CI - uses: ./.github/actions/setup - - - name: Build docker image - run: | - docker build -t sp1-gnark -f ./Dockerfile.gnark-ffi . - - - name: Run cargo test - uses: actions-rs/cargo@v1 - env: - SP1_GNARK_IMAGE: sp1-gnark - with: - command: test - toolchain: nightly-2024-04-17 - args: --release -p sp1-prover -- --exact tests::test_e2e - lint: name: Formatting & Clippy runs-on: runs-on,runner=8cpu-linux-x64 @@ -161,6 +137,7 @@ jobs: run: | cd cli cargo install --force --locked --path . + ~/.sp1/bin/cargo-prove prove install-toolchain cd ~ - name: Run cargo check @@ -194,7 +171,7 @@ jobs: - name: Run cargo prove new run: | - cargo prove new fibonacci + cargo prove new fibonacci --version dev - name: Build program and run script run: | diff --git a/.github/workflows/release-plz.yml b/.github/workflows/release-plz.yml new file mode 100644 index 0000000000..f54af577f5 --- /dev/null +++ b/.github/workflows/release-plz.yml @@ -0,0 +1,29 @@ +name: Release Plz + +permissions: + pull-requests: write + contents: write + +on: + push: + branches: + - main + +jobs: + release-plz: + name: Release-plz + runs-on: ubuntu-latest + steps: + - name: Checkout repository + uses: actions/checkout@v4 + with: + fetch-depth: 0 + - name: Install Rust toolchain + uses: dtolnay/rust-toolchain@stable + - name: Run release-plz + uses: MarcoIeni/release-plz-action@v0.5 + with: + command: release + env: + GITHUB_TOKEN: ${{ secrets.RELEASE_PLZ_TOKEN }} + CARGO_REGISTRY_TOKEN: ${{ secrets.CARGO_REGISTRY_TOKEN }} diff --git a/Cargo.lock b/Cargo.lock index e1703793e1..5999233b8e 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -119,7 +119,7 @@ dependencies = [ "proc-macro-error", "proc-macro2", "quote", - "syn 2.0.66", + "syn 2.0.67", ] [[package]] @@ -135,7 +135,7 @@ dependencies = [ "proc-macro-error", "proc-macro2", "quote", - "syn 2.0.66", + "syn 2.0.67", "syn-solidity", "tiny-keccak", ] @@ -151,7 +151,7 @@ dependencies = [ "heck", "proc-macro2", "quote", - "syn 2.0.66", + "syn 2.0.67", "syn-solidity", ] @@ -229,9 +229,9 @@ dependencies = [ [[package]] name = "anstyle-query" -version = "1.0.3" +version = "1.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a64c907d4e79225ac72e2a354c9ce84d50ebb4586dee56c82b3ee73004f537f5" +checksum = "ad186efb764318d35165f1758e7dcef3b10628e26d41a44bc5550652e6804391" dependencies = [ "windows-sys 0.52.0", ] @@ -266,7 +266,7 @@ dependencies = [ "ark-serialize 0.3.0", "ark-std 0.3.0", "derivative", - "num-bigint 0.4.5", + "num-bigint 0.4.6", "num-traits", "paste", "rustc_version 0.3.3", @@ -286,7 +286,7 @@ dependencies = [ "derivative", "digest 0.10.7", "itertools 0.10.5", - "num-bigint 0.4.5", + "num-bigint 0.4.6", "num-traits", "paste", "rustc_version 0.4.0", @@ -319,7 +319,7 @@ version = "0.3.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "db2fd794a08ccb318058009eefdf15bcaaaaf6f8161eb3345f907222bac38b20" dependencies = [ - "num-bigint 0.4.5", + "num-bigint 0.4.6", "num-traits", "quote", "syn 1.0.109", @@ -331,7 +331,7 @@ version = "0.4.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "7abe79b0e4288889c4574159ab790824d0033b9fdcb2a112a3182fac2e514565" dependencies = [ - "num-bigint 0.4.5", + "num-bigint 0.4.6", "num-traits", "proc-macro2", "quote", @@ -356,7 +356,7 @@ checksum = "adb7b85a02b83d2f22f89bd5cac66c9c89474240cb6207cb1efc16d098e822a5" dependencies = [ "ark-std 0.4.0", "digest 0.10.7", - "num-bigint 0.4.5", + "num-bigint 0.4.6", ] [[package]] @@ -393,13 +393,13 @@ checksum = "96d30a06541fbafbc7f82ed10c06164cfbd2c401138f6addd8404629c4b16711" [[package]] name = "async-trait" -version = "0.1.80" +version = "0.1.81" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c6fa2087f2753a7da8cc1c0dbfcf89579dd57458e36769de5ac750b4671737ca" +checksum = "6e0c28dcc82d7c8ead5cb13beb15405b57b8546e93215673ff8ca0349a028107" dependencies = [ "proc-macro2", "quote", - "syn 2.0.66", + "syn 2.0.67", ] [[package]] @@ -427,7 +427,7 @@ checksum = "3c87f3f15e7794432337fc718554eaa4dc8f04c9677a950ffe366f20a162ae42" dependencies = [ "proc-macro2", "quote", - "syn 2.0.66", + "syn 2.0.67", ] [[package]] @@ -438,9 +438,9 @@ checksum = "0c4b4d0bd25bd0b74681c0ad21497610ce1b7c91b1022cd21c80c6fbdd9476b0" [[package]] name = "axum" -version = "0.7.5" +version = "0.7.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3a6c9af12842a67734c9a2e355436e5d03b22383ed60cf13cd0c18fbfe3dcbcf" +checksum = "1236b4b292f6c4d6dc34604bb5120d85c3fe1d1aa596bd5cc52ca054d13e7b9e" dependencies = [ "async-trait", "axum-core", @@ -462,7 +462,7 @@ dependencies = [ "serde_json", "serde_path_to_error", "serde_urlencoded", - "sync_wrapper 1.0.1", + "sync_wrapper 0.1.2", "tokio", "tower", "tower-layer", @@ -493,9 +493,9 @@ dependencies = [ [[package]] name = "backtrace" -version = "0.3.72" +version = "0.3.73" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "17c6a35df3749d2e8bb1b7b21a976d82b15548788d2735b9d82f329268f71a11" +checksum = "5cc23269a4f8976d0a4d2e7109211a419fe30e8d88d677cd60b6bc79c5732e0a" dependencies = [ "addr2line", "cc", @@ -561,7 +561,7 @@ dependencies = [ "bitflags 2.5.0", "cexpr", "clang-sys", - "itertools 0.10.5", + "itertools 0.12.1", "lazy_static", "lazycell", "log", @@ -571,7 +571,7 @@ dependencies = [ "regex", "rustc-hash", "shlex", - "syn 2.0.66", + "syn 2.0.67", "which", ] @@ -694,9 +694,9 @@ checksum = "c3ac9f8b63eca6fd385229b3675f6cc0dc5c8a5c8a54a59d4f52ffd670d87b0c" [[package]] name = "bytemuck" -version = "1.16.0" +version = "1.16.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "78834c15cb5d5efe3452d58b1e8ba890dd62d21907f867f383358198e56ebca5" +checksum = "b236fc92302c97ed75b38da1f4917b5cdda4984745740f153a5d3059e48d725e" [[package]] name = "byteorder" @@ -753,13 +753,12 @@ checksum = "37b2a672a2cb129a2e41c10b1224bb368f9f37a2b16b612598138befd7b37eb5" [[package]] name = "cc" -version = "1.0.99" +version = "1.1.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "96c51067fd44124faa7f870b4b1c969379ad32b2ba805aa959430ceaa384f695" +checksum = "324c74f2155653c90b04f25b2a47a8a631360cb908f92a772695f430c7e31052" dependencies = [ "jobserver", "libc", - "once_cell", ] [[package]] @@ -829,9 +828,9 @@ dependencies = [ [[package]] name = "clang-sys" -version = "1.8.0" +version = "1.8.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a483f3cbf7cec2e153d424d0e92329d816becc6421389bd494375c6065921b9b" +checksum = "0b023947811758c97c59bf9d1c188fd619ad4718dcaa767947df1cadb14f39f4" dependencies = [ "glob", "libc", @@ -840,9 +839,9 @@ dependencies = [ [[package]] name = "clap" -version = "4.5.7" +version = "4.5.9" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5db83dced34638ad474f39f250d7fea9598bdd239eaced1bdf45d597da0f433f" +checksum = "64acc1846d54c1fe936a78dc189c34e28d3f5afc348403f28ecf53660b9b8462" dependencies = [ "clap_builder", "clap_derive", @@ -850,9 +849,9 @@ dependencies = [ [[package]] name = "clap_builder" -version = "4.5.7" +version = "4.5.9" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f7e204572485eb3fbf28f871612191521df159bc3e15a9f5064c66dba3a8c05f" +checksum = "6fb8393d67ba2e7bfaf28a23458e4e2b543cc73a99595511eb207fdb8aede942" dependencies = [ "anstream", "anstyle", @@ -862,21 +861,27 @@ dependencies = [ [[package]] name = "clap_derive" -version = "4.5.5" +version = "4.5.8" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c780290ccf4fb26629baa7a1081e68ced113f1d3ec302fa5948f1c381ebf06c6" +checksum = "2bac35c6dafb060fd4d275d9a4ffae97917c13a6327903a8be2153cd964f7085" dependencies = [ "heck", "proc-macro2", "quote", - "syn 2.0.66", + "syn 2.0.67", ] [[package]] name = "clap_lex" -version = "0.7.0" +version = "0.7.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4b82cf0babdbd58558212896d1a4272303a57bdb245c2bf1147185fb45640e70" + +[[package]] +name = "cobs" +version = "0.2.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "98cc8fbded0c607b7ba9dd60cd98df59af97e84d24e49c8557331cfc26d301ce" +checksum = "67ba02a97a2bd10f4b59b25c7973101c79642302776489e030cd13cdab09ed15" [[package]] name = "coins-bip32" @@ -1126,15 +1131,14 @@ dependencies = [ [[package]] name = "curve25519-dalek" -version = "4.1.2" +version = "4.1.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0a677b8922c94e01bdbb12126b0bc852f00447528dee1782229af9c720c3f348" +checksum = "97fb8b7c4503de7d6ae7b42ab72a5a59857b4c937ec27a3d4539dba95b5ab2be" dependencies = [ "cfg-if", "cpufeatures", "curve25519-dalek-derive", "fiat-crypto", - "platforms", "rustc_version 0.4.0", "subtle", "zeroize", @@ -1148,7 +1152,7 @@ checksum = "f46882e17999c6cc590af592290432be3bce0428cb0d5f8b6715e4dc7b383eb3" dependencies = [ "proc-macro2", "quote", - "syn 2.0.66", + "syn 2.0.67", ] [[package]] @@ -1172,7 +1176,7 @@ dependencies = [ "proc-macro2", "quote", "strsim", - "syn 2.0.66", + "syn 2.0.67", ] [[package]] @@ -1183,7 +1187,7 @@ checksum = "733cabb43482b1a1b53eee8583c2b9e8684d592215ea83efd305dd31bc2f0178" dependencies = [ "darling_core", "quote", - "syn 2.0.66", + "syn 2.0.67", ] [[package]] @@ -1219,15 +1223,15 @@ dependencies = [ [[package]] name = "derive_more" -version = "0.99.17" +version = "0.99.18" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4fb810d30a7c1953f91334de7244731fc3f3c10d7fe163338a35b9f640960321" +checksum = "5f33878137e4dafd7fa914ad4e259e18a4e8e532b9617a2d0150262bf53abfce" dependencies = [ "convert_case", "proc-macro2", "quote", "rustc_version 0.4.0", - "syn 1.0.109", + "syn 2.0.67", ] [[package]] @@ -1343,6 +1347,12 @@ dependencies = [ "zeroize", ] +[[package]] +name = "embedded-io" +version = "0.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ef1a6892d9eef45c8fa6b9e0086428a2cca8491aca8f787c534a3d6d0bcb3ced" + [[package]] name = "encode_unicode" version = "0.3.6" @@ -1524,7 +1534,7 @@ dependencies = [ "regex", "serde", "serde_json", - "syn 2.0.66", + "syn 2.0.67", "toml", "walkdir", ] @@ -1542,7 +1552,7 @@ dependencies = [ "proc-macro2", "quote", "serde_json", - "syn 2.0.66", + "syn 2.0.67", ] [[package]] @@ -1568,7 +1578,7 @@ dependencies = [ "serde", "serde_json", "strum", - "syn 2.0.66", + "syn 2.0.67", "tempfile", "thiserror", "tiny-keccak", @@ -1843,7 +1853,7 @@ checksum = "87750cf4b7a4c0625b1529e4c543c2182106e4dedc60a2a6455e00d212c489ac" dependencies = [ "proc-macro2", "quote", - "syn 2.0.66", + "syn 2.0.67", ] [[package]] @@ -1914,9 +1924,9 @@ dependencies = [ [[package]] name = "generic-array" -version = "1.0.0" +version = "1.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "fe739944a5406424e080edccb6add95685130b9f160d5407c639c7df0c5836b0" +checksum = "96512db27971c2c3eece70a1e106fbe6c87760234e31e8f7e5634912fe52794a" dependencies = [ "serde", "typenum", @@ -2078,6 +2088,7 @@ checksum = "e5274423e17b7c9fc20b6e7e208532f9b19825d82dfd615708b70edd83df41f1" dependencies = [ "ahash", "allocator-api2", + "serde", ] [[package]] @@ -2176,12 +2187,12 @@ dependencies = [ [[package]] name = "http-body-util" -version = "0.1.1" +version = "0.1.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0475f8b2ac86659c21b64320d5d653f9efe42acd2a4e560073ec61a155a34f1d" +checksum = "793429d76616a256bcb62c2a2ec2bed781c8307e797e2598c50010f2bee2544f" dependencies = [ "bytes", - "futures-core", + "futures-util", "http 1.1.0", "http-body 1.0.0", "pin-project-lite", @@ -2189,9 +2200,9 @@ dependencies = [ [[package]] name = "httparse" -version = "1.8.0" +version = "1.9.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d897f394bad6a705d5f4104762e116a75639e470d80901eed05a860a95cb1904" +checksum = "0fcc0b4a115bf80b728eb8ea024ad5bd707b615bfed49e0665b6e0f86fd082d9" [[package]] name = "httpdate" @@ -2201,9 +2212,9 @@ checksum = "df3b46402a9d5adb4c86a0cf463f42e19994e3ee891101b1841f30a545cb49a9" [[package]] name = "hyper" -version = "0.14.28" +version = "0.14.29" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bf96e135eb83a2a8ddf766e426a841d8ddd7449d5f00d34ea02b41d2f19eef80" +checksum = "f361cde2f109281a220d4307746cdfd5ee3f410da58a70377762396775634b33" dependencies = [ "bytes", "futures-channel", @@ -2252,7 +2263,7 @@ checksum = "ec3efd23720e2049821a693cbc7e65ea87c72f1c58ff2f9522ff332b1491e590" dependencies = [ "futures-util", "http 0.2.12", - "hyper 0.14.28", + "hyper 0.14.29", "rustls 0.21.12", "tokio", "tokio-rustls 0.24.1", @@ -2260,19 +2271,20 @@ dependencies = [ [[package]] name = "hyper-rustls" -version = "0.26.0" +version = "0.27.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a0bea761b46ae2b24eb4aef630d8d1c398157b6fc29e6350ecf090a0b70c952c" +checksum = "5ee4be2c948921a1a5320b629c4193916ed787a7f7f293fd3f7f5a6c9de74155" dependencies = [ "futures-util", "http 1.1.0", "hyper 1.3.1", "hyper-util", - "rustls 0.22.4", + "rustls 0.23.10", "rustls-pki-types", "tokio", - "tokio-rustls 0.25.0", + "tokio-rustls 0.26.0", "tower-service", + "webpki-roots 0.26.3", ] [[package]] @@ -2584,11 +2596,11 @@ dependencies = [ [[package]] name = "lazy_static" -version = "1.4.0" +version = "1.5.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e2abad23fbc42b3700f2f279844dc832adb2b2eb069b2df918f455c4e18cc646" +checksum = "bbd2bcb4c963f2ddae06a2efc7e9f3591312473c50c6685e1f298068316e66fe" dependencies = [ - "spin 0.5.2", + "spin 0.9.8", ] [[package]] @@ -2671,9 +2683,9 @@ dependencies = [ [[package]] name = "log" -version = "0.4.21" +version = "0.4.22" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "90ed8c1e510134f979dbc4f070f87d4313098b704861a105fe34231c70a3901c" +checksum = "a7a70ba024b9dc04c27ea2f0c0548feb474ec5c54bba33a7f72f873a39d07b24" [[package]] name = "matchers" @@ -2692,9 +2704,9 @@ checksum = "0e7465ac9959cc2b1404e8e2367b43684a6d13790fe23056cc8c6c5a6b7bcb94" [[package]] name = "memchr" -version = "2.7.2" +version = "2.7.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6c8640c5d730cb13ebd907d8d04b52f55ac9a2eec55b440c8892f40d56c76c1d" +checksum = "78ca9ab1a0babb1e7d5695e3530886289c18cf2f87ec19a575a0abdce112e3a3" [[package]] name = "memuse" @@ -2716,9 +2728,9 @@ checksum = "68354c5c6bd36d73ff3feceb05efa59b6acb7626617f4962be322a825e61f79a" [[package]] name = "miniz_oxide" -version = "0.7.3" +version = "0.7.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "87dfd01fe195c66b572b37921ad8803d010623c0aca821bea2302239d155cdae" +checksum = "b8a240ddb74feaf34a79a7add65a741f3167852fba007066dcac1ca548d89c08" dependencies = [ "adler", ] @@ -2767,6 +2779,15 @@ dependencies = [ "minimal-lexical", ] +[[package]] +name = "ntapi" +version = "0.4.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e8a3895c6391c39d7fe7ebc444a87eb2991b2a0bc718fdabd071eec617fc68e4" +dependencies = [ + "winapi", +] + [[package]] name = "nu-ansi-term" version = "0.46.0" @@ -2783,7 +2804,7 @@ version = "0.4.3" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "35bd024e8b2ff75562e5f34e7f4905839deb4b22955ef5e73d2fea1b9813cb23" dependencies = [ - "num-bigint 0.4.5", + "num-bigint 0.4.6", "num-complex", "num-integer", "num-iter", @@ -2804,9 +2825,9 @@ dependencies = [ [[package]] name = "num-bigint" -version = "0.4.5" +version = "0.4.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c165a9ab64cf766f73521c0dd2cfdff64f488b8f0b3e621face3462d3db536d7" +checksum = "a5e44f723f1133c9deac646763579fdb3ac745e418f2a7af9cd0c431da1f20b9" dependencies = [ "num-integer", "num-traits", @@ -2855,7 +2876,7 @@ version = "0.4.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "f83d14da390562dca69fc84082e73e548e1ad308d24accdedd2720017cb37824" dependencies = [ - "num-bigint 0.4.5", + "num-bigint 0.4.6", "num-integer", "num-traits", ] @@ -2919,7 +2940,7 @@ dependencies = [ "proc-macro-crate 3.1.0", "proc-macro2", "quote", - "syn 2.0.66", + "syn 2.0.67", ] [[package]] @@ -2939,9 +2960,9 @@ checksum = "830b246a0e5f20af87141b25c173cd1b609bd7779a4617d6ec582abaf90870f3" [[package]] name = "object" -version = "0.35.0" +version = "0.36.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b8ec7ab813848ba4522158d5517a6093db1ded27575b070f4177b8d12b41db5e" +checksum = "576dfe1fc8f9df304abb159d767a29d0476f7750fbf8aa7ad07816004a207434" dependencies = [ "memchr", ] @@ -2952,6 +2973,12 @@ version = "1.19.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "3fdb12b2476b595f9358c5161aa467c2438859caa136dec86c26fdd2efe17b92" +[[package]] +name = "oneshot" +version = "0.1.8" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e296cf87e61c9cfc1a61c3c63a0f7f286ed4554e0e22be84e8a38e1d264a2a29" + [[package]] name = "oorandom" version = "11.1.3" @@ -3006,7 +3033,7 @@ checksum = "a948666b637a0f465e8564c73e89d4dde00d72d4d473cc972f390fc3dcee7d9c" dependencies = [ "proc-macro2", "quote", - "syn 2.0.66", + "syn 2.0.67", ] [[package]] @@ -3041,8 +3068,9 @@ checksum = "b15813163c1d831bf4a13c3610c05c0d03b39feb07f7e09fa234dac9b15aaf39" [[package]] name = "p3-air" -version = "0.1.0" -source = "git+https://github.com/Plonky3/Plonky3.git?rev=88ea2b866e41329817e4761429b4a5a2a9751c07#88ea2b866e41329817e4761429b4a5a2a9751c07" +version = "0.1.3-succinct" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "45e909ef66fa5d77ff0fd3cb5af4b33b27fa6fb68d02b9b1e70edbc29383e565" dependencies = [ "p3-field", "p3-matrix", @@ -3050,10 +3078,11 @@ dependencies = [ [[package]] name = "p3-baby-bear" -version = "0.1.0" -source = "git+https://github.com/Plonky3/Plonky3.git?rev=88ea2b866e41329817e4761429b4a5a2a9751c07#88ea2b866e41329817e4761429b4a5a2a9751c07" +version = "0.1.3-succinct" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "46965470aac1cddfe52f535424b59d52f2fffef0fdeb9dbed19da39b1d8f048a" dependencies = [ - "num-bigint 0.4.5", + "num-bigint 0.4.6", "p3-field", "p3-mds", "p3-poseidon2", @@ -3064,8 +3093,9 @@ dependencies = [ [[package]] name = "p3-blake3" -version = "0.1.0" -source = "git+https://github.com/Plonky3/Plonky3.git?rev=88ea2b866e41329817e4761429b4a5a2a9751c07#88ea2b866e41329817e4761429b4a5a2a9751c07" +version = "0.1.3-succinct" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "36ef32d6ea21dd5cf9fec8a31bf0c64e6ceee8901dbf50966b83a443093c2aba" dependencies = [ "blake3", "p3-symmetric", @@ -3073,11 +3103,12 @@ dependencies = [ [[package]] name = "p3-bn254-fr" -version = "0.1.0" -source = "git+https://github.com/Plonky3/Plonky3.git?rev=88ea2b866e41329817e4761429b4a5a2a9751c07#88ea2b866e41329817e4761429b4a5a2a9751c07" +version = "0.1.3-succinct" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7e3edfca6be3b3109adf8e3330baec30c3fc5f9f4d63d27aaec1b471ca51ed67" dependencies = [ "ff 0.13.0", - "num-bigint 0.4.5", + "num-bigint 0.4.6", "p3-field", "p3-poseidon2", "p3-symmetric", @@ -3087,8 +3118,9 @@ dependencies = [ [[package]] name = "p3-challenger" -version = "0.1.0" -source = "git+https://github.com/Plonky3/Plonky3.git?rev=88ea2b866e41329817e4761429b4a5a2a9751c07#88ea2b866e41329817e4761429b4a5a2a9751c07" +version = "0.1.3-succinct" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a6662ea899a5d848b60c699944491d72757873b5e1fd46798e4712f90a03a4e9" dependencies = [ "p3-field", "p3-maybe-rayon", @@ -3099,8 +3131,9 @@ dependencies = [ [[package]] name = "p3-commit" -version = "0.1.0" -source = "git+https://github.com/Plonky3/Plonky3.git?rev=88ea2b866e41329817e4761429b4a5a2a9751c07#88ea2b866e41329817e4761429b4a5a2a9751c07" +version = "0.1.3-succinct" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "fc3563918b5cc44ef5280bf9b51753e70dc78802de25e3fb81ed6c94617ccb6e" dependencies = [ "itertools 0.12.1", "p3-challenger", @@ -3112,8 +3145,9 @@ dependencies = [ [[package]] name = "p3-dft" -version = "0.1.0" -source = "git+https://github.com/Plonky3/Plonky3.git?rev=88ea2b866e41329817e4761429b4a5a2a9751c07#88ea2b866e41329817e4761429b4a5a2a9751c07" +version = "0.1.3-succinct" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "510095701819d83c9509fe825bbf1ebfe50426ae75149df5fe1dcfd18261323a" dependencies = [ "p3-field", "p3-matrix", @@ -3124,11 +3158,12 @@ dependencies = [ [[package]] name = "p3-field" -version = "0.1.0" -source = "git+https://github.com/Plonky3/Plonky3.git?rev=88ea2b866e41329817e4761429b4a5a2a9751c07#88ea2b866e41329817e4761429b4a5a2a9751c07" +version = "0.1.3-succinct" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "61f1977a0a65789f719aa824119c332c4676b000bdbfe94d312fb6244a70d601" dependencies = [ "itertools 0.12.1", - "num-bigint 0.4.5", + "num-bigint 0.4.6", "num-traits", "p3-util", "rand", @@ -3137,8 +3172,9 @@ dependencies = [ [[package]] name = "p3-fri" -version = "0.1.0" -source = "git+https://github.com/Plonky3/Plonky3.git?rev=88ea2b866e41329817e4761429b4a5a2a9751c07#88ea2b866e41329817e4761429b4a5a2a9751c07" +version = "0.1.3-succinct" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c22ddb958f200d9289cc73ff68847b0167ca0c14557b791dd9e318f98c2d1b28" dependencies = [ "itertools 0.12.1", "p3-challenger", @@ -3155,8 +3191,9 @@ dependencies = [ [[package]] name = "p3-interpolation" -version = "0.1.0" -source = "git+https://github.com/Plonky3/Plonky3.git?rev=88ea2b866e41329817e4761429b4a5a2a9751c07#88ea2b866e41329817e4761429b4a5a2a9751c07" +version = "0.1.3-succinct" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d032cda212f6b408d7d5b0b9a8270a9455acb93742fe55a0880d82be8e90e500" dependencies = [ "p3-field", "p3-matrix", @@ -3165,8 +3202,9 @@ dependencies = [ [[package]] name = "p3-keccak" -version = "0.1.0" -source = "git+https://github.com/Plonky3/Plonky3.git?rev=88ea2b866e41329817e4761429b4a5a2a9751c07#88ea2b866e41329817e4761429b4a5a2a9751c07" +version = "0.1.3-succinct" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7c56abdd5a8a780049d2f8e92cea1df57b55a2ef50a40d1103f2732f7a00e4b1" dependencies = [ "p3-symmetric", "tiny-keccak", @@ -3174,8 +3212,9 @@ dependencies = [ [[package]] name = "p3-keccak-air" -version = "0.1.0" -source = "git+https://github.com/Plonky3/Plonky3.git?rev=88ea2b866e41329817e4761429b4a5a2a9751c07#88ea2b866e41329817e4761429b4a5a2a9751c07" +version = "0.1.3-succinct" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e8398f1694ccc38513df0b8cab5f9ef7325423f27cd9e4fa20bdc77d5079cf1b" dependencies = [ "p3-air", "p3-field", @@ -3183,12 +3222,15 @@ dependencies = [ "p3-maybe-rayon", "p3-util", "tracing", + "tracing-forest", + "tracing-subscriber", ] [[package]] name = "p3-matrix" -version = "0.1.0" -source = "git+https://github.com/Plonky3/Plonky3.git?rev=88ea2b866e41329817e4761429b4a5a2a9751c07#88ea2b866e41329817e4761429b4a5a2a9751c07" +version = "0.1.3-succinct" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d548ee0b834f8e2ebc5037073acd101a3b0ca41a2d1d28a15ba0ccd9059495b0" dependencies = [ "itertools 0.12.1", "p3-field", @@ -3201,16 +3243,18 @@ dependencies = [ [[package]] name = "p3-maybe-rayon" -version = "0.1.0" -source = "git+https://github.com/Plonky3/Plonky3.git?rev=88ea2b866e41329817e4761429b4a5a2a9751c07#88ea2b866e41329817e4761429b4a5a2a9751c07" +version = "0.1.3-succinct" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "55f5575d3d61bedb3e05681abb0f36b8bb339d65aa395d50756bfa64e9cd3f46" dependencies = [ "rayon", ] [[package]] name = "p3-mds" -version = "0.1.0" -source = "git+https://github.com/Plonky3/Plonky3.git?rev=88ea2b866e41329817e4761429b4a5a2a9751c07#88ea2b866e41329817e4761429b4a5a2a9751c07" +version = "0.1.3-succinct" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6a6e57ed310d59245f93e24ee805ea7aa16fc9c505551b76a15f5e50f29d177e" dependencies = [ "itertools 0.12.1", "p3-dft", @@ -3223,8 +3267,9 @@ dependencies = [ [[package]] name = "p3-merkle-tree" -version = "0.1.0" -source = "git+https://github.com/Plonky3/Plonky3.git?rev=88ea2b866e41329817e4761429b4a5a2a9751c07#88ea2b866e41329817e4761429b4a5a2a9751c07" +version = "0.1.3-succinct" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "af46b41cba75d483ec8a553cbab1d2d794935ae3403d75394acfa4fb2c977cce" dependencies = [ "itertools 0.12.1", "p3-commit", @@ -3239,8 +3284,9 @@ dependencies = [ [[package]] name = "p3-poseidon2" -version = "0.1.0" -source = "git+https://github.com/Plonky3/Plonky3.git?rev=88ea2b866e41329817e4761429b4a5a2a9751c07#88ea2b866e41329817e4761429b4a5a2a9751c07" +version = "0.1.3-succinct" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "adaba6f14c197203530e233badce0ca1126ba3bf3c9ff766505b497bdad0bee1" dependencies = [ "gcd", "p3-field", @@ -3251,8 +3297,9 @@ dependencies = [ [[package]] name = "p3-symmetric" -version = "0.1.0" -source = "git+https://github.com/Plonky3/Plonky3.git?rev=88ea2b866e41329817e4761429b4a5a2a9751c07#88ea2b866e41329817e4761429b4a5a2a9751c07" +version = "0.1.3-succinct" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "57ecc4282566eb14f48be7707f6745c4dff6be664984d59ec0fb1849cd82b5c2" dependencies = [ "itertools 0.12.1", "p3-field", @@ -3261,8 +3308,9 @@ dependencies = [ [[package]] name = "p3-uni-stark" -version = "0.1.0" -source = "git+https://github.com/Plonky3/Plonky3.git?rev=88ea2b866e41329817e4761429b4a5a2a9751c07#88ea2b866e41329817e4761429b4a5a2a9751c07" +version = "0.1.3-succinct" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1af5c038b22b058bf1d49fb1ea3dd6c240a3e46c3278fde5c444e0034f7ffe37" dependencies = [ "itertools 0.12.1", "p3-air", @@ -3273,14 +3321,18 @@ dependencies = [ "p3-matrix", "p3-maybe-rayon", "p3-util", + "postcard", "serde", "tracing", + "tracing-forest", + "tracing-subscriber", ] [[package]] name = "p3-util" -version = "0.1.0" -source = "git+https://github.com/Plonky3/Plonky3.git?rev=88ea2b866e41329817e4761429b4a5a2a9751c07#88ea2b866e41329817e4761429b4a5a2a9751c07" +version = "0.1.3-succinct" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "79f3fef0e00d9d7246385e758c4cd39b4efcbbcea31752471491ab502631385e" dependencies = [ "serde", ] @@ -3451,7 +3503,7 @@ checksum = "2f38a4412a78282e09a2cf38d195ea5420d15ba0602cb375210efbc877243965" dependencies = [ "proc-macro2", "quote", - "syn 2.0.66", + "syn 2.0.67", ] [[package]] @@ -3482,12 +3534,6 @@ version = "0.3.30" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "d231b230927b5e4ad203db57bbcbee2802f6bce620b1e4a9024a07d94e2907ec" -[[package]] -name = "platforms" -version = "3.4.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "db23d408679286588f4d4644f965003d056e3dd5abcaaa938116871d7ce2fee7" - [[package]] name = "plotters" version = "0.3.6" @@ -3522,6 +3568,17 @@ version = "1.6.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "7170ef9988bc169ba16dd36a7fa041e5c4cbeb6a35b76d4c03daded371eae7c0" +[[package]] +name = "postcard" +version = "1.0.8" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a55c51ee6c0db07e68448e336cf8ea4131a620edefebf9893e759b2d793420f8" +dependencies = [ + "cobs", + "embedded-io", + "serde", +] + [[package]] name = "powerfmt" version = "0.2.0" @@ -3541,7 +3598,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "5f12335488a2f3b0a83b14edad48dca9879ce89b2edd10e80237e4e852dd645e" dependencies = [ "proc-macro2", - "syn 2.0.66", + "syn 2.0.67", ] [[package]] @@ -3603,9 +3660,9 @@ dependencies = [ [[package]] name = "proc-macro2" -version = "1.0.85" +version = "1.0.86" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "22244ce15aa966053a896d1accb3a6e68469b97c7f33f284b99f0d576879fc23" +checksum = "5e719e8df665df0d1c8fbfd238015744736151d4445ec0836b8e628aae103b77" dependencies = [ "unicode-ident", ] @@ -3624,7 +3681,7 @@ dependencies = [ "rand", "rand_chacha", "rand_xorshift", - "regex-syntax 0.8.3", + "regex-syntax 0.8.4", "rusty-fork", "tempfile", "unarray", @@ -3647,10 +3704,19 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "81bddcdb20abf9501610992b6759a4c888aef7d1a7247ef75e2404275ac24af1" dependencies = [ "anyhow", - "itertools 0.10.5", + "itertools 0.12.1", "proc-macro2", "quote", - "syn 2.0.66", + "syn 2.0.67", +] + +[[package]] +name = "psm" +version = "0.1.21" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5787f7cda34e3033a72192c018bc5883100330f362ef279a8cbccfce8bb4e874" +dependencies = [ + "cc", ] [[package]] @@ -3659,6 +3725,53 @@ version = "1.2.3" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "a1d01941d82fa2ab50be1e79e6714289dd7cde78eba4c074bc5a4374f650dfe0" +[[package]] +name = "quinn" +version = "0.11.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e4ceeeeabace7857413798eb1ffa1e9c905a9946a57d81fb69b4b71c4d8eb3ad" +dependencies = [ + "bytes", + "pin-project-lite", + "quinn-proto", + "quinn-udp", + "rustc-hash", + "rustls 0.23.10", + "thiserror", + "tokio", + "tracing", +] + +[[package]] +name = "quinn-proto" +version = "0.11.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ddf517c03a109db8100448a4be38d498df8a210a99fe0e1b9eaf39e78c640efe" +dependencies = [ + "bytes", + "rand", + "ring 0.17.8", + "rustc-hash", + "rustls 0.23.10", + "slab", + "thiserror", + "tinyvec", + "tracing", +] + +[[package]] +name = "quinn-udp" +version = "0.5.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9096629c45860fc7fb143e125eb826b5e721e10be3263160c7d60ca832cf8c46" +dependencies = [ + "libc", + "once_cell", + "socket2", + "tracing", + "windows-sys 0.52.0", +] + [[package]] name = "quote" version = "1.0.36" @@ -3744,9 +3857,9 @@ dependencies = [ [[package]] name = "redox_syscall" -version = "0.5.1" +version = "0.5.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "469052894dcb553421e483e4209ee581a45100d31b4018de03e5a7ad86374a7e" +checksum = "c82cf8cff14456045f55ec4241383baeff27af886adb72ffb2162f99911de0fd" dependencies = [ "bitflags 2.5.0", ] @@ -3764,14 +3877,14 @@ dependencies = [ [[package]] name = "regex" -version = "1.10.4" +version = "1.10.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c117dbdfde9c8308975b6a18d71f3f385c89461f7b3fb054288ecf2a2058ba4c" +checksum = "b91213439dad192326a0d7c6ee3955910425f441d7038e0d6933b0aec5c4517f" dependencies = [ "aho-corasick", "memchr", - "regex-automata 0.4.6", - "regex-syntax 0.8.3", + "regex-automata 0.4.7", + "regex-syntax 0.8.4", ] [[package]] @@ -3785,13 +3898,13 @@ dependencies = [ [[package]] name = "regex-automata" -version = "0.4.6" +version = "0.4.7" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "86b83b8b9847f9bf95ef68afb0b8e6cdb80f498442f5179a29fad448fcc1eaea" +checksum = "38caf58cc5ef2fed281f89292ef23f6365465ed9a41b7a7754eb4e26496c92df" dependencies = [ "aho-corasick", "memchr", - "regex-syntax 0.8.3", + "regex-syntax 0.8.4", ] [[package]] @@ -3802,9 +3915,9 @@ checksum = "f162c6dd7b008981e4d40210aca20b4bd0f9b60ca9271061b07f78537722f2e1" [[package]] name = "regex-syntax" -version = "0.8.3" +version = "0.8.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "adad44e29e4c806119491a7f06f03de4d1af22c3a680dd47f1e6e179439d1f56" +checksum = "7a66a03ae7c801facd77a29370b4faec201768915ac14a721ba36f20bc9c209b" [[package]] name = "reqwest" @@ -3820,7 +3933,7 @@ dependencies = [ "h2 0.3.26", "http 0.2.12", "http-body 0.4.6", - "hyper 0.14.28", + "hyper 0.14.29", "hyper-rustls 0.24.2", "ipnet", "js-sys", @@ -3849,9 +3962,9 @@ dependencies = [ [[package]] name = "reqwest" -version = "0.12.4" +version = "0.12.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "566cafdd92868e0939d3fb961bd0dc25fcfaaed179291093b3d43e6b3150ea10" +checksum = "c7d6d2a27d57148378eb5e111173f4276ad26340ecc5c49a4a2152167a2d6a37" dependencies = [ "base64 0.22.1", "bytes", @@ -3863,7 +3976,7 @@ dependencies = [ "http-body 1.0.0", "http-body-util", "hyper 1.3.1", - "hyper-rustls 0.26.0", + "hyper-rustls 0.27.2", "hyper-tls", "hyper-util", "ipnet", @@ -3874,17 +3987,18 @@ dependencies = [ "once_cell", "percent-encoding", "pin-project-lite", - "rustls 0.22.4", + "quinn", + "rustls 0.23.10", "rustls-pemfile 2.1.2", "rustls-pki-types", "serde", "serde_json", "serde_urlencoded", - "sync_wrapper 0.1.2", + "sync_wrapper 1.0.1", "system-configuration", "tokio", "tokio-native-tls", - "tokio-rustls 0.25.0", + "tokio-rustls 0.26.0", "tokio-util", "tower-service", "url", @@ -3892,20 +4006,20 @@ dependencies = [ "wasm-bindgen-futures", "wasm-streams", "web-sys", - "webpki-roots 0.26.1", + "webpki-roots 0.26.3", "winreg 0.52.0", ] [[package]] name = "reqwest-middleware" -version = "0.3.1" +version = "0.3.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a45d100244a467870f6cb763c4484d010a6bed6bd610b3676e3825d93fb4cfbd" +checksum = "39346a33ddfe6be00cbc17a34ce996818b97b230b87229f10114693becca1268" dependencies = [ "anyhow", "async-trait", "http 1.1.0", - "reqwest 0.12.4", + "reqwest 0.12.5", "serde", "thiserror", "tower-service", @@ -3983,9 +4097,10 @@ dependencies = [ ] [[package]] -name = "rrs-lib" +name = "rrs-succinct" version = "0.1.0" -source = "git+https://github.com/GregAC/rrs.git#b23afc16b4e6a1fb5c4a73eb1e337e9400816507" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3372685893a9f67d18e98e792d690017287fd17379a83d798d958e517d380fa9" dependencies = [ "downcast-rs", "num_enum 0.5.11", @@ -4003,7 +4118,7 @@ dependencies = [ "ark-ff 0.4.2", "bytes", "fastrlp", - "num-bigint 0.4.5", + "num-bigint 0.4.6", "num-traits", "parity-scale-codec", "primitive-types", @@ -4085,11 +4200,11 @@ dependencies = [ [[package]] name = "rustls" -version = "0.22.4" +version = "0.23.10" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bf4ef73721ac7bcd79b2b315da7779d8fc09718c6b3d2d1b2d94850eb8c18432" +checksum = "05cff451f60db80f490f3c182b77c35260baace73209e9cdbbe526bfe3a4d402" dependencies = [ - "log", + "once_cell", "ring 0.17.8", "rustls-pki-types", "rustls-webpki 0.102.4", @@ -4339,29 +4454,29 @@ checksum = "cd0b0ec5f1c1ca621c432a25813d8d60c88abe6d3e08a3eb9cf37d97a0fe3d73" [[package]] name = "serde" -version = "1.0.203" +version = "1.0.204" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7253ab4de971e72fb7be983802300c30b5a7f0c2e56fab8abfc6a214307c0094" +checksum = "bc76f558e0cbb2a839d37354c575f1dc3fdc6546b5be373ba43d95f231bf7c12" dependencies = [ "serde_derive", ] [[package]] name = "serde_derive" -version = "1.0.203" +version = "1.0.204" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "500cbc0ebeb6f46627f50f3f5811ccf6bf00643be300b4c3eabc0ef55dc5b5ba" +checksum = "e0cd7e117be63d3c3678776753929474f3b04a43a080c744d6b0ae2a8c28e222" dependencies = [ "proc-macro2", "quote", - "syn 2.0.66", + "syn 2.0.67", ] [[package]] name = "serde_json" -version = "1.0.117" +version = "1.0.120" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "455182ea6142b14f93f4bc5320a2b31c1f266b66a4a5c858b013302a5d8cbfc3" +checksum = "4e0d21c9a8cae1235ad58a00c11cb40d4b1e5c784f1ef2c537876ed6ffd8b7c5" dependencies = [ "itoa", "ryu", @@ -4401,9 +4516,9 @@ dependencies = [ [[package]] name = "serde_with" -version = "3.8.1" +version = "3.9.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0ad483d2ab0149d5a5ebcd9972a3852711e0153d863bf5a5d0391d28883c4a20" +checksum = "69cecfa94848272156ea67b2b1a53f20fc7bc638c4a46d2f8abde08f05f4b857" dependencies = [ "base64 0.22.1", "chrono", @@ -4419,14 +4534,14 @@ dependencies = [ [[package]] name = "serde_with_macros" -version = "3.8.1" +version = "3.9.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "65569b702f41443e8bc8bbb1c5779bd0450bbe723b56198980e80ec45780bce2" +checksum = "a8fee4991ef4f274617a51ad4af30519438dacb2f56ac773b08a1922ff743350" dependencies = [ "darling", "proc-macro2", "quote", - "syn 2.0.66", + "syn 2.0.67", ] [[package]] @@ -4451,7 +4566,7 @@ checksum = "82fe9db325bcef1fbcde82e078a5cc4efdf787e96b3b9cf45b50b529f2083d67" dependencies = [ "proc-macro2", "quote", - "syn 2.0.66", + "syn 2.0.67", ] [[package]] @@ -4525,7 +4640,7 @@ version = "0.6.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "adc4e5204eb1910f40f9cfa375f6f05b68c3abac4b6fd879c8ff5e7ae8a0a085" dependencies = [ - "num-bigint 0.4.5", + "num-bigint 0.4.6", "num-traits", "thiserror", "time", @@ -4572,9 +4687,18 @@ dependencies = [ "windows-sys 0.52.0", ] +[[package]] +name = "sp1-build" +version = "1.0.0-rc.1" +dependencies = [ + "anyhow", + "cargo_metadata", + "clap", +] + [[package]] name = "sp1-cli" -version = "0.1.0" +version = "1.0.0-rc.1" dependencies = [ "anstyle", "anyhow", @@ -4586,9 +4710,10 @@ dependencies = [ "hex", "indicatif", "rand", - "reqwest 0.12.4", + "reqwest 0.12.5", "serde", "serde_json", + "sp1-build", "sp1-core", "sp1-prover", "sp1-sdk", @@ -4601,7 +4726,7 @@ dependencies = [ [[package]] name = "sp1-core" -version = "0.1.0" +version = "1.0.0-rc.1" dependencies = [ "anyhow", "arrayref", @@ -4613,14 +4738,15 @@ dependencies = [ "curve25519-dalek", "elf", "elliptic-curve", - "generic-array 1.0.0", + "generic-array 1.1.0", + "hashbrown 0.14.5", "hex", "itertools 0.13.0", "k256", "log", "nohash-hasher", "num", - "num-bigint 0.4.5", + "num-bigint 0.4.6", "num_cpus", "p3-air", "p3-baby-bear", @@ -4641,7 +4767,7 @@ dependencies = [ "p3-util", "rand", "rayon-scan", - "rrs-lib", + "rrs-succinct", "serde", "serde_with", "size", @@ -4663,7 +4789,7 @@ dependencies = [ [[package]] name = "sp1-derive" -version = "0.1.0" +version = "1.0.0-rc.1" dependencies = [ "proc-macro2", "quote", @@ -4672,7 +4798,7 @@ dependencies = [ [[package]] name = "sp1-eval" -version = "0.1.0" +version = "1.0.0-rc.1" dependencies = [ "clap", "csv", @@ -4683,31 +4809,29 @@ dependencies = [ [[package]] name = "sp1-helper" -version = "0.1.0" +version = "1.0.0-rc.1" dependencies = [ "cargo_metadata", "chrono", + "sp1-build", ] [[package]] -name = "sp1-precompiles" -version = "0.1.0" +name = "sp1-lib" +version = "1.0.0-rc.1" dependencies = [ "anyhow", "bincode", "cfg-if", - "getrandom", "hex", "k256", - "num", - "rand", "serde", "snowbridge-amcl", ] [[package]] name = "sp1-primitives" -version = "0.1.0" +version = "1.0.0-rc.1" dependencies = [ "itertools 0.13.0", "lazy_static", @@ -4719,33 +4843,25 @@ dependencies = [ [[package]] name = "sp1-prover" -version = "0.1.0" +version = "1.0.0-rc.1" dependencies = [ "anyhow", - "backtrace", "bincode", - "bytemuck", "clap", "dirs", - "futures", "hex", - "indicatif", "itertools 0.13.0", - "num-bigint 0.4.5", + "num-bigint 0.4.6", + "oneshot", "p3-baby-bear", "p3-bn254-fr", "p3-challenger", "p3-commit", "p3-field", - "p3-util", - "rand", "rayon", - "reqwest 0.12.4", "serde", "serde_json", "serial_test", - "sha2", - "size", "sp1-core", "sp1-primitives", "sp1-recursion-circuit", @@ -4756,14 +4872,13 @@ dependencies = [ "subtle-encoding", "tempfile", "thiserror", - "tokio", "tracing", "tracing-subscriber", ] [[package]] name = "sp1-recursion-circuit" -version = "0.1.0" +version = "1.0.0-rc.1" dependencies = [ "bincode", "ff 0.13.0", @@ -4794,7 +4909,7 @@ dependencies = [ [[package]] name = "sp1-recursion-compiler" -version = "0.1.0" +version = "1.0.0-rc.1" dependencies = [ "backtrace", "itertools 0.13.0", @@ -4814,6 +4929,7 @@ dependencies = [ "rand", "serde", "sp1-core", + "sp1-primitives", "sp1-recursion-core", "sp1-recursion-derive", "tracing", @@ -4821,13 +4937,14 @@ dependencies = [ [[package]] name = "sp1-recursion-core" -version = "0.1.0" +version = "1.0.0-rc.1" dependencies = [ "arrayref", "backtrace", "ff 0.13.0", "hashbrown 0.14.5", "itertools 0.13.0", + "num_cpus", "p3-air", "p3-baby-bear", "p3-bn254-fr", @@ -4855,16 +4972,25 @@ dependencies = [ [[package]] name = "sp1-recursion-derive" -version = "0.1.0" +version = "1.0.0-rc.1" dependencies = [ "proc-macro2", "quote", "syn 1.0.109", ] +[[package]] +name = "sp1-recursion-gnark-cli" +version = "1.0.0-rc.1" +dependencies = [ + "bincode", + "clap", + "sp1-recursion-gnark-ffi", +] + [[package]] name = "sp1-recursion-gnark-ffi" -version = "0.1.0" +version = "1.0.0-rc.1" dependencies = [ "anyhow", "bincode", @@ -4873,7 +4999,7 @@ dependencies = [ "cfg-if", "hex", "log", - "num-bigint 0.4.5", + "num-bigint 0.4.6", "p3-baby-bear", "p3-field", "p3-symmetric", @@ -4888,7 +5014,7 @@ dependencies = [ [[package]] name = "sp1-recursion-program" -version = "0.1.0" +version = "1.0.0-rc.1" dependencies = [ "itertools 0.13.0", "p3-air", @@ -4907,14 +5033,16 @@ dependencies = [ "rand", "serde", "sp1-core", + "sp1-primitives", "sp1-recursion-compiler", "sp1-recursion-core", + "stacker", "tracing", ] [[package]] name = "sp1-sdk" -version = "0.1.0" +version = "1.0.0-rc.1" dependencies = [ "alloy-sol-types", "anyhow", @@ -4925,15 +5053,18 @@ dependencies = [ "dirs", "ethers", "futures", + "hashbrown 0.14.5", "hex", "indicatif", "log", - "num-bigint 0.4.5", + "num-bigint 0.4.6", + "p3-baby-bear", "p3-commit", "p3-field", + "p3-fri", "p3-matrix", "prost", - "reqwest 0.12.4", + "reqwest 0.12.5", "reqwest-middleware", "serde", "serde_json", @@ -4942,22 +5073,22 @@ dependencies = [ "sp1-prover", "strum", "strum_macros", + "sysinfo", "tempfile", "thiserror", "tokio", "tracing", - "twirp", + "twirp-rs", "vergen", ] [[package]] name = "sp1-zkvm" -version = "0.1.0" +version = "1.0.0-rc.1" dependencies = [ "bincode", "cfg-if", "getrandom", - "k256", "lazy_static", "libm", "once_cell", @@ -4966,7 +5097,7 @@ dependencies = [ "rand", "serde", "sha2", - "sp1-precompiles", + "sp1-lib", "sp1-primitives", ] @@ -4992,6 +5123,19 @@ dependencies = [ "der", ] +[[package]] +name = "stacker" +version = "0.1.15" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c886bd4480155fd3ef527d45e9ac8dd7118a898a46530b7b94c3e21866259fce" +dependencies = [ + "cc", + "cfg-if", + "libc", + "psm", + "winapi", +] + [[package]] name = "static_assertions" version = "1.1.0" @@ -5006,9 +5150,9 @@ checksum = "7da8b5736845d9f2fcb837ea5d9e2628564b3b043a70948a3f0b778838c5fb4f" [[package]] name = "strum" -version = "0.26.2" +version = "0.26.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5d8cec3501a5194c432b2b7976db6b7d10ec95c253208b45f83f7136aa985e29" +checksum = "8fec0f0aef304996cf250b31b5a10dee7980c85da9d759361292b8bca5a18f06" dependencies = [ "strum_macros", ] @@ -5023,14 +5167,14 @@ dependencies = [ "proc-macro2", "quote", "rustversion", - "syn 2.0.66", + "syn 2.0.67", ] [[package]] name = "subtle" -version = "2.5.0" +version = "2.6.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "81cdd64d312baedb58e21336b31bc043b77e01cc99033ce76ef539f78e965ebc" +checksum = "0d0208408ba0c3df17ed26eb06992cb1a1268d41b2c0e12e65203fbe3972cee5" [[package]] name = "subtle-encoding" @@ -5054,9 +5198,9 @@ dependencies = [ [[package]] name = "syn" -version = "2.0.66" +version = "2.0.67" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c42f3f41a2de00b01c0aaad383c5a45241efc8b2d1eda5661812fda5f3cdcff5" +checksum = "ff8655ed1d86f3af4ee3fd3263786bc14245ad17c4c7e85ba7187fb3ae028c90" dependencies = [ "proc-macro2", "quote", @@ -5072,7 +5216,7 @@ dependencies = [ "paste", "proc-macro2", "quote", - "syn 2.0.66", + "syn 2.0.67", ] [[package]] @@ -5087,6 +5231,21 @@ version = "1.0.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "a7065abeca94b6a8a577f9bd45aa0867a2238b74e8eb67cf10d492bc39351394" +[[package]] +name = "sysinfo" +version = "0.30.13" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0a5b4ddaee55fb2bea2bf0e5000747e5f5c0de765e5a5ff87f4cd106439f4bb3" +dependencies = [ + "cfg-if", + "core-foundation-sys", + "libc", + "ntapi", + "once_cell", + "rayon", + "windows", +] + [[package]] name = "system-configuration" version = "0.5.1" @@ -5116,9 +5275,9 @@ checksum = "55937e1799185b12863d447f42597ed69d9928686b8d88a1df17376a097d8369" [[package]] name = "target-lexicon" -version = "0.12.14" +version = "0.12.15" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e1fc403891a21bcfb7c37834ba66a547a8f402146eba7265b5a6d88059c9ff2f" +checksum = "4873307b7c257eddcb50c9bedf158eb669578359fb28428bef438fec8e6ba7c2" [[package]] name = "tempfile" @@ -5149,7 +5308,7 @@ checksum = "46c3384250002a6d5af4d114f2845d37b57521033f30d5c3f46c4d70e1197533" dependencies = [ "proc-macro2", "quote", - "syn 2.0.66", + "syn 2.0.67", ] [[package]] @@ -5256,7 +5415,7 @@ checksum = "5f5ae998a069d4b5aba8ee9dad856af7d520c3699e6159b185c2acd48155d39a" dependencies = [ "proc-macro2", "quote", - "syn 2.0.66", + "syn 2.0.67", ] [[package]] @@ -5281,11 +5440,11 @@ dependencies = [ [[package]] name = "tokio-rustls" -version = "0.25.0" +version = "0.26.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "775e0c0f0adb3a2f22a00c4745d728b479985fc15ee7ca6a2608388c5569860f" +checksum = "0c7bc40d0e5a97695bb96e27995cd3a08538541b0a846f65bba7a359f36700d4" dependencies = [ - "rustls 0.22.4", + "rustls 0.23.10", "rustls-pki-types", "tokio", ] @@ -5305,14 +5464,14 @@ dependencies = [ [[package]] name = "toml" -version = "0.8.13" +version = "0.8.14" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a4e43f8cc456c9704c851ae29c67e17ef65d2c30017c17a9765b89c382dc8bba" +checksum = "6f49eb2ab21d2f26bd6db7bf383edc527a7ebaee412d17af4d40fdccd442f335" dependencies = [ "serde", "serde_spanned", "toml_datetime", - "toml_edit 0.22.13", + "toml_edit 0.22.14", ] [[package]] @@ -5348,15 +5507,15 @@ dependencies = [ [[package]] name = "toml_edit" -version = "0.22.13" +version = "0.22.14" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c127785850e8c20836d49732ae6abfa47616e60bf9d9f57c43c250361a9db96c" +checksum = "f21c7aaf97f1bd9ca9d4f9e73b0a6c74bd5afef56f2bc931943a6e1c37e04e38" dependencies = [ "indexmap 2.2.6", "serde", "serde_spanned", "toml_datetime", - "winnow 0.6.9", + "winnow 0.6.13", ] [[package]] @@ -5407,7 +5566,7 @@ checksum = "34704c8d6ebcbc939824180af020566b01a7c01f80641264eba0999f6c2b6be7" dependencies = [ "proc-macro2", "quote", - "syn 2.0.66", + "syn 2.0.67", ] [[package]] @@ -5479,9 +5638,10 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "e421abadd41a4225275504ea4d6566923418b7f05506fbc9c0fe86ba7396114b" [[package]] -name = "twirp" +name = "twirp-rs" version = "0.3.0" -source = "git+https://github.com/github/twirp-rs.git?rev=c85f31f9c54957374e7dcb3534fc52cff0aa2dc5#c85f31f9c54957374e7dcb3534fc52cff0aa2dc5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "dfa3161d8eee0abcad4e762f4215381a430cc1281870d575b0f1e4fbfc74b8ce" dependencies = [ "async-trait", "axum", @@ -5491,7 +5651,7 @@ dependencies = [ "http-body-util", "hyper 1.3.1", "prost", - "reqwest 0.12.4", + "reqwest 0.12.5", "serde", "serde_json", "thiserror", @@ -5553,9 +5713,9 @@ dependencies = [ [[package]] name = "unicode-width" -version = "0.1.12" +version = "0.1.13" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "68f5e5f3158ecfd4b8ff6fe086db7c8467a2dfdac97fe420f2b7c4aa97af66d6" +checksum = "0336d538f7abc86d282a4189614dfaa90810dfc2c6f6427eaf88e16311dd225d" [[package]] name = "unicode-xid" @@ -5577,9 +5737,9 @@ checksum = "8ecb6da28b8a351d773b68d5825ac39017e680750f980f3a1a85cd8dd28a47c1" [[package]] name = "url" -version = "2.5.0" +version = "2.5.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "31e6302e3bb753d46e83516cae55ae196fc0c309407cf11ab35cc51a4c2a4633" +checksum = "22784dbdf76fdde8af1aeda5622b546b422b6fc585325248a2bf9f5e41e94d6c" dependencies = [ "form_urlencoded", "idna", @@ -5588,9 +5748,9 @@ dependencies = [ [[package]] name = "utf8parse" -version = "0.2.1" +version = "0.2.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "711b9620af191e0cdc7468a8d14e709c3dcdb115b36f838e601583af800a370a" +checksum = "06abde3611657adf66d383f00b093d7faecc7fa57071cce2578660c9f1010821" [[package]] name = "uuid" @@ -5688,7 +5848,7 @@ dependencies = [ "once_cell", "proc-macro2", "quote", - "syn 2.0.66", + "syn 2.0.67", "wasm-bindgen-shared", ] @@ -5722,7 +5882,7 @@ checksum = "e94f17b526d0a461a191c78ea52bbce64071ed5c04c9ffe424dcb38f74171bb7" dependencies = [ "proc-macro2", "quote", - "syn 2.0.66", + "syn 2.0.67", "wasm-bindgen-backend", "wasm-bindgen-shared", ] @@ -5774,9 +5934,9 @@ checksum = "5f20c57d8d7db6d3b86154206ae5d8fba62dd39573114de97c2cb0578251f8e1" [[package]] name = "webpki-roots" -version = "0.26.1" +version = "0.26.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b3de34ae270483955a94f4b21bdaaeb83d508bb84a01435f393818edb0012009" +checksum = "bd7c23921eeb1713a4e851530e9b9756e4fb0e89978582942612524cf09f01cd" dependencies = [ "rustls-pki-types", ] @@ -5824,6 +5984,16 @@ version = "0.4.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "712e227841d057c1ee1cd2fb22fa7e5a5461ae8e48fa2ca79ec42cfc1931183f" +[[package]] +name = "windows" +version = "0.52.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e48a53791691ab099e5e2ad123536d0fff50652600abaf43bbf952894110d0be" +dependencies = [ + "windows-core", + "windows-targets 0.52.5", +] + [[package]] name = "windows-core" version = "0.52.0" @@ -5983,9 +6153,9 @@ dependencies = [ [[package]] name = "winnow" -version = "0.6.9" +version = "0.6.13" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "86c949fede1d13936a99f14fafd3e76fd642b556dd2ce96287fbe2e0151bfac6" +checksum = "59b5e5f6c299a3c7890b876a2a587f3115162487e704907d9b6cd29473052ba1" dependencies = [ "memchr", ] @@ -6061,7 +6231,7 @@ checksum = "15e934569e47891f7d9411f1a451d947a60e000ab3bd24fbb970f000387d1b3b" dependencies = [ "proc-macro2", "quote", - "syn 2.0.66", + "syn 2.0.67", ] [[package]] @@ -6081,13 +6251,14 @@ checksum = "ce36e65b0d2999d2aafac989fb249189a141aee1f53c612c1f37d72631959f69" dependencies = [ "proc-macro2", "quote", - "syn 2.0.66", + "syn 2.0.67", ] [[package]] name = "zkhash" version = "0.2.0" -source = "git+https://github.com/HorizenLabs/poseidon2#bb476b9ca38198cf5092487283c8b8c5d4317c4e" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4352d1081da6922701401cdd4cbf29a2723feb4cfabb5771f6fee8e9276da1c7" dependencies = [ "ark-ff 0.4.2", "ark-std 0.4.0", diff --git a/Cargo.toml b/Cargo.toml index 063a57c60a..ec25c75786 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,5 +1,6 @@ [workspace] members = [ + "build", "cli", "core", "derive", @@ -10,6 +11,8 @@ members = [ "recursion/circuit", "recursion/compiler", "recursion/core", + "recursion/derive", + "recursion/gnark-cli", "recursion/gnark-ffi", "recursion/program", "sdk", @@ -18,6 +21,14 @@ members = [ exclude = ["examples/target"] resolver = "2" +[workspace.package] +version = "1.0.0-rc.1" +edition = "2021" +license = "MIT OR Apache-2.0" +repository = "https://github.com/succinctlabs/sp1" +keywords = ["sp1", "succinct", "zero-knowledge", "zkvm"] +categories = ["cryptography"] + [profile.release] opt-level = 3 @@ -30,26 +41,43 @@ debug = true debug-assertions = true [workspace.dependencies] -p3-air = { git = "https://github.com/Plonky3/Plonky3.git", rev = "88ea2b866e41329817e4761429b4a5a2a9751c07" } -p3-field = { git = "https://github.com/Plonky3/Plonky3.git", rev = "88ea2b866e41329817e4761429b4a5a2a9751c07" } -p3-commit = { git = "https://github.com/Plonky3/Plonky3.git", rev = "88ea2b866e41329817e4761429b4a5a2a9751c07" } -p3-matrix = { git = "https://github.com/Plonky3/Plonky3.git", rev = "88ea2b866e41329817e4761429b4a5a2a9751c07" } -p3-baby-bear = { git = "https://github.com/Plonky3/Plonky3.git", features = [ - "nightly-features", -], rev = "88ea2b866e41329817e4761429b4a5a2a9751c07" } -p3-util = { git = "https://github.com/Plonky3/Plonky3.git", rev = "88ea2b866e41329817e4761429b4a5a2a9751c07" } -p3-challenger = { git = "https://github.com/Plonky3/Plonky3.git", rev = "88ea2b866e41329817e4761429b4a5a2a9751c07" } -p3-dft = { git = "https://github.com/Plonky3/Plonky3.git", rev = "88ea2b866e41329817e4761429b4a5a2a9751c07" } -p3-fri = { git = "https://github.com/Plonky3/Plonky3.git", rev = "88ea2b866e41329817e4761429b4a5a2a9751c07" } -p3-keccak = { git = "https://github.com/Plonky3/Plonky3.git", rev = "88ea2b866e41329817e4761429b4a5a2a9751c07" } -p3-keccak-air = { git = "https://github.com/Plonky3/Plonky3.git", rev = "88ea2b866e41329817e4761429b4a5a2a9751c07" } -p3-blake3 = { git = "https://github.com/Plonky3/Plonky3.git", rev = "88ea2b866e41329817e4761429b4a5a2a9751c07" } -p3-merkle-tree = { git = "https://github.com/Plonky3/Plonky3.git", rev = "88ea2b866e41329817e4761429b4a5a2a9751c07" } -p3-poseidon2 = { git = "https://github.com/Plonky3/Plonky3.git", rev = "88ea2b866e41329817e4761429b4a5a2a9751c07" } -p3-symmetric = { git = "https://github.com/Plonky3/Plonky3.git", rev = "88ea2b866e41329817e4761429b4a5a2a9751c07" } -p3-uni-stark = { git = "https://github.com/Plonky3/Plonky3.git", rev = "88ea2b866e41329817e4761429b4a5a2a9751c07" } -p3-maybe-rayon = { git = "https://github.com/Plonky3/Plonky3.git", rev = "88ea2b866e41329817e4761429b4a5a2a9751c07" } -p3-bn254-fr = { git = "https://github.com/Plonky3/Plonky3.git", rev = "88ea2b866e41329817e4761429b4a5a2a9751c07" } +sp1-build = { path = "build", version = "1.0.0-rc.1" } +sp1-derive = { path = "derive", version = "1.0.0-rc.1" } +sp1-core = { path = "core", version = "1.0.0-rc.1" } +sp1-cli = { path = "cli", version = "1.0.0-rc.1", default-features = false } +sp1-eval = { path = "eval", version = "1.0.0-rc.1", default-features = false } +sp1-helper = { path = "helper", version = "1.0.0-rc.1", default-features = false } +sp1-primitives = { path = "primitives", version = "1.0.0-rc.1" } +sp1-prover = { path = "prover", version = "1.0.0-rc.1" } +sp1-recursion-compiler = { path = "recursion/compiler", version = "1.0.0-rc.1" } +sp1-recursion-core = { path = "recursion/core", version = "1.0.0-rc.1", default-features = false } +sp1-recursion-derive = { path = "recursion/derive", version = "1.0.0-rc.1", default-features = false } +sp1-recursion-gnark-ffi = { path = "recursion/gnark-ffi", version = "1.0.0-rc.1", default-features = false } +sp1-recursion-program = { path = "recursion/program", version = "1.0.0-rc.1", default-features = false } +sp1-recursion-circuit = { path = "recursion/circuit", version = "1.0.0-rc.1", default-features = false } +sp1-sdk = { path = "sdk", version = "1.0.0-rc.1" } +sp1-lib = { path = "zkvm/lib", version = "1.0.0-rc.1", default-features = false } +sp1-zkvm = { path = "zkvm/entrypoint", version = "1.0.0-rc.1", default-features = false } +p3-air = "0.1.3-succinct" +p3-field = "0.1.3-succinct" +p3-commit = "0.1.3-succinct" +p3-matrix = "0.1.3-succinct" +p3-baby-bear = { version = "0.1.3-succinct", features = ["nightly-features"] } +p3-util = "0.1.3-succinct" +p3-challenger = "0.1.3-succinct" +p3-dft = "0.1.3-succinct" +p3-fri = "0.1.3-succinct" +p3-goldilocks = "0.1.3-succinct" +p3-keccak = "0.1.3-succinct" +p3-keccak-air = "0.1.3-succinct" +p3-blake3 = "0.1.3-succinct" +p3-mds = "0.1.3-succinct" +p3-merkle-tree = "0.1.3-succinct" +p3-poseidon2 = "0.1.3-succinct" +p3-symmetric = "0.1.3-succinct" +p3-uni-stark = "0.1.3-succinct" +p3-maybe-rayon = "0.1.3-succinct" +p3-bn254-fr = "0.1.3-succinct" # For local development. diff --git a/DEVELOPMENT.md b/DEVELOPMENT.md index b2afd19d91..b94340addd 100644 --- a/DEVELOPMENT.md +++ b/DEVELOPMENT.md @@ -27,3 +27,31 @@ To build docs locally, run the following commands in the top-level directory: cargo install mdbook # Installs mdbook locally mdbook serve # Serves the docs locally ``` + +## Publishing + +SP1 crates are hosted on [crates.io](https://crates.io/search?q=sp1). We use +[release-plz](https://release-plz.ieni.dev/) to automate the publication process, and it is configured +with [release-plz.toml](./release-plz.toml) and [.github/workflows/release-plz.yml](./.github/workflows/release-plz.yml). + +With this configuration, when the `dev` branch is pushed to, the following should happen: + +1. `release-plz` creates a pull request with the new version. +2. When we are ready to create a release, we merge the pull request. +3. After merging the pull request, `release-plz` publishes the packages. + +After the release pull request has been merged to `dev`, only then should we merge `dev` into `main` +and create a GitHub release for the new version. + +In the case that the automated publish does not work, you can manually do this by [installing +release-plz](https://release-plz.ieni.dev/docs/usage/installation) and preparing the crates with: + +```bash +release-plz update +``` + +and then publishing the crates with: + +```bash +release-plz release --git-token $GITHUB_TOKEN +``` diff --git a/Dockerfile.gnark-ffi b/Dockerfile.gnark-ffi index 3e0624d794..6d7ab65ce0 100644 --- a/Dockerfile.gnark-ffi +++ b/Dockerfile.gnark-ffi @@ -23,7 +23,7 @@ WORKDIR /sp1/recursion/gnark-cli RUN \ --mount=type=cache,target=target \ - cargo build --release && cp target/release/sp1-recursion-gnark-cli /gnark-cli + cargo build --release && cp ../../target/release/sp1-recursion-gnark-cli /gnark-cli FROM rustlang/rust:nightly-bullseye-slim COPY --from=rust-builder /gnark-cli /gnark-cli diff --git a/book.toml b/book.toml index e30b6057d5..aec81dc099 100644 --- a/book.toml +++ b/book.toml @@ -4,7 +4,7 @@ language = "en" multilingual = false src = "book" title = "SP1 Book" -description = "A book on all things Reth" +description = "A book on all things SP1" [output.html] theme = "book/theme" diff --git a/book/SUMMARY.md b/book/SUMMARY.md index 7e41b5b30b..fd8cf06fa7 100644 --- a/book/SUMMARY.md +++ b/book/SUMMARY.md @@ -2,6 +2,10 @@ [Introduction](./introduction.md) +[Why use SP1?](./why-use-sp1.md) + +[What is a zkVM?](./what-is-a-zkvm.md) + # Getting Started - [Install](./getting-started/install.md) @@ -10,6 +14,8 @@ - [Project Template](./getting-started/project-template.md) +- [Hardware Requirements](./getting-started/hardware-requirements.md) + # Writing Programs - [Setup](./writing-programs/setup.md) @@ -24,13 +30,29 @@ - [Cycle Tracking](./writing-programs/cycle-tracking.md) +- [Proof Aggregation](./writing-programs/proof-aggregation.md) + +- [Build Script](./writing-programs/build-script.md) + # Generating Proofs - [Setup](./generating-proofs/setup.md) - [Basics](./generating-proofs/basics.md) -- [Advanced](./generating-proofs/advanced.md) +- [Prover Options](./generating-proofs/prover-options.md) + +- [Development Options](./generating-proofs/development-options.md) + +- [Optimizing Performance](./generating-proofs/optimizing-performance.md) + +# Onchain Verification + +- [Setup](./onchain-verification/getting-started.md) + +- [Solidity SDK](./onchain-verification/solidity-sdk.md) + +- [Contract Addresses](./onchain-verification/contract-addresses.md) # Prover Network @@ -38,12 +60,10 @@ - [Usage](./prover-network/usage.md) -# Verifying Proofs - -- [Solidity & EVM](./verifying-proofs/solidity-and-evm.md) +- [Supported Versions](./prover-network/versions.md) # Developers -- [Building Plonk Bn254 Artifacts](./developers/building-plonk-artifacts.md) +- [Building PLONK Artifacts](./developers/building-plonk-artifacts.md) - [Common Issues](./developers/common-issues.md) diff --git a/book/developers/building-plonk-artifacts.md b/book/developers/building-plonk-artifacts.md index 9efd9127d0..fd0ba2a68b 100644 --- a/book/developers/building-plonk-artifacts.md +++ b/book/developers/building-plonk-artifacts.md @@ -1,7 +1,8 @@ -# Building Plonk BN254 Artifacts +# Building PLONK Artifacts -To build the Plonk Bn254 artifacts from scratch, you can use the `Makefile` inside the `prover` directory. +To build the production Plonk Bn254 artifacts from scratch, you can use the `Makefile` inside the `prover` directory. ```shell,noplayground -RUST_LOG=info make plonk-bn254 +cd prover +RUST_LOG=info make build-plonk-bn254 ``` \ No newline at end of file diff --git a/book/developers/common-issues.md b/book/developers/common-issues.md index 285f461a36..b5c5f7be79 100644 --- a/book/developers/common-issues.md +++ b/book/developers/common-issues.md @@ -1,4 +1,6 @@ -# Alloy Errors +# Common Issues + +## Alloy Errors If you are using a library that depends on `alloy_sol_types`, and encounter an error like this: @@ -16,3 +18,43 @@ sp1-sdk = { version = "0.1.0", default-features = false } This will configure out the `network` feature which will remove the dependency on `alloy_sol_types` and configure out the `NetworkProver`. + +## Rust Version Errors + +If you are using `alloy` or another library that has an MSRV (minimum support rust version) of 1.76.0 +or higher, you may encounter an error like this when building your program. + +``` +package `alloy v0.1.1 cannot be built because it requires rustc 1.76 or newer, while the currently active rustc version is 1.75.0-nightly` +``` + +This is due to the fact that the Succinct Rust toolchain is built with version 1.75, which is older +than the MSRV of the `alloy` crate. Note: Once the Succinct Rust toolchain is updated, this error will +go away. + +To fix this, you can: + +- If using `cargo prove build` directly, pass the `--ignore-rust-version` flag: + ``` + cargo prove build --ignore-rust-version + ``` +- If using `build_program`, set `ignore_rust_version` to true inside the `BuildArgs` struct and use `build_program_with_args`: + ```rust + let args = BuildArgs { + ignore_rust_version: true, + ..Default::default() + }; + build_program_with_args("path/to/program", args); + ``` + +## Stack Overflow Errors +If you encounter the following in a script using `sp1-sdk`: + +``` +thread 'main' has overflowed its stack +fatal runtime error: stack overflow +``` +``` +Segmentation fault (core dumped) +``` +Re-run your script with `--release`. \ No newline at end of file diff --git a/book/generating-proofs/advanced.md b/book/generating-proofs/advanced.md index 3b4caa25ee..b550215fe6 100644 --- a/book/generating-proofs/advanced.md +++ b/book/generating-proofs/advanced.md @@ -2,14 +2,14 @@ ## Execution Only -We recommend that during development of large programs (> 1 million cycles) that you do not generate proofs each time. +We recommend that during the development of large programs (> 1 million cycles) you do not generate proofs each time. Instead, you should have your script only execute the program with the RISC-V runtime and read `public_values`. Here is an example: ```rust,noplayground {{#include ../../examples/fibonacci/script/bin/execute.rs}} ``` -If execution of your program succeeds, then proof generation should succeed as well! (Unless there is a bug in our zkVM implementation.) +If the execution of your program succeeds, then proof generation should succeed as well! (Unless there is a bug in our zkVM implementation.) ## Compressed Proofs @@ -61,7 +61,7 @@ SHARD_SIZE=4194304 RUST_LOG=info RUSTFLAGS='-C target-cpu=native' cargo run --re ## Memory Usage -To reduce memory usage, set the `SHARD_BATCH_SIZE` enviroment variable depending on how much RAM +To reduce memory usage, set the `SHARD_BATCH_SIZE` environment variable depending on how much RAM your machine has. A higher number will use more memory, but will be faster. ```rust,noplayground diff --git a/book/generating-proofs/basics.md b/book/generating-proofs/basics.md index 3c24a2ee1c..ebae7128dd 100644 --- a/book/generating-proofs/basics.md +++ b/book/generating-proofs/basics.md @@ -1,45 +1,13 @@ # Generating Proofs: Basics -An end-to-end flow of proving `f(x) = y` with the SP1 zkVM involves the following steps: - -- Define `f` using normal Rust code and compile it to an ELF (covered in the [writing programs](../writing-programs/basics.md) section). -- Setup a proving key (`pk`) and verifying key (`vk`) for the program given the ELF. The proving key contains all the information needed to generate a proof and includes some post-processing on top of the ELF, while the verifying key is a compact representation of the ELF that contains all the information needed to verify a proof and is much smaller than the ELF itself. -- Generate a proof `π` using the SP1 zkVM that `f(x) = y` with `prove(pk, x)`. -- Verify the proof `π` using `verify(vk, x, y, π)`. +All the methods you'll need for generating proofs are included in the `sp1_sdk` crate. Most importantly, you'll need to use the `ProverClient` to setup a proving key and verifying key for your program and then use the `prove` and `verify` methods to generate and verify proofs. To make this more concrete, let's walk through a simple example of generating a proof for a Fiboancci program inside the zkVM. -## Fibonacci +## Example: Fibonacci ```rust,noplayground {{#include ../../examples/fibonacci/script/src/main.rs}} ``` -You can run the above script in the `script` directory with `RUST_LOG=info cargo run --release`. - -## Build Script - -If you want your program crate to be built automatically whenever you build/run your script crate, you can add a `build.rs` file inside of `script/` (at the same level as `Cargo.toml`): - -```rust,noplayground -{{#include ../../examples/fibonacci/script/build.rs}} -``` - -Make sure to also add `sp1-helper` as a build dependency in `script/Cargo.toml`: - -```toml -[build-dependencies] -sp1-helper = { git = "https://github.com/succinctlabs/sp1.git" } -``` - -If you run `RUST_LOG=info cargo run --release -vv`, you will see the following output from the build script if the program has changed, indicating that the program was rebuilt: - -```` -[fibonacci-script 0.1.0] cargo:rerun-if-changed=../program/src -[fibonacci-script 0.1.0] cargo:rerun-if-changed=../program/Cargo.toml -[fibonacci-script 0.1.0] cargo:rerun-if-changed=../program/Cargo.lock -[fibonacci-script 0.1.0] cargo:warning=fibonacci-program built at 2024-03-02 22:01:26 -[fibonacci-script 0.1.0] [sp1] Compiling fibonacci-program v0.1.0 (/Users/umaroy/Documents/fibonacci/program) -[fibonacci-script 0.1.0] [sp1] Finished release [optimized] target(s) in 0.15s -warning: fibonacci-script@0.1.0: fibonacci-program built at 2024-03-02 22:01:26``` -```` +You can run the above script in the `script` directory with `RUST_LOG=info cargo run --release`. \ No newline at end of file diff --git a/book/generating-proofs/development-options.md b/book/generating-proofs/development-options.md new file mode 100644 index 0000000000..e16fec2def --- /dev/null +++ b/book/generating-proofs/development-options.md @@ -0,0 +1,26 @@ +# Development Options + +## Execution Only + +We recommend that during the development of large programs (> 1 million cycles) you do not generate proofs each time. +Instead, you should have your script only execute the program with the RISC-V runtime and read `public_values`. Here is an example: + +```rust,noplayground +{{#include ../../examples/fibonacci/script/bin/execute.rs}} +``` + +If the execution of your program succeeds, then proof generation should succeed as well! (Unless there is a bug in our zkVM implementation.) + +## Logging and Tracing Information + +You can use `sp1_sdk::utils::setup_logger()` to enable logging information respectively. You can set the logging level with the `RUST_LOG` environment variable. + +```rust,noplayground +sp1_sdk::utils::setup_logger(); +``` + +Example of setting the logging level to `info` (other options are `debug`, `trace`, and `warn`): + +```bash +RUST_LOG=info cargo run --release +``` \ No newline at end of file diff --git a/book/generating-proofs/optimizing-performance.md b/book/generating-proofs/optimizing-performance.md new file mode 100644 index 0000000000..aa3d986923 --- /dev/null +++ b/book/generating-proofs/optimizing-performance.md @@ -0,0 +1,23 @@ +# Optimizing Performance + +## CPU Acceleration + +SP1 supports CPU hardware acceleration using AVX256/512 and NEON SIMD instructions. To enable the acceleration, you can use the `RUSTFLAGS` environment variable to generate code that is optimized for your CPU. + +**AVX256 / NEON**: +```bash +RUSTFLAGS='-C target-cpu=native' cargo run --release +``` + +**AVX512**: +```bash +RUSTFLAGS='-C target-cpu=native -C target_feature=+avx512ifma,+avx512vl' cargo run --release +``` + +## Enviroment Variables (Advanced) + +`SHARD_SIZE`: The number of cycles that will be proven in each "shard" in the SP1 zkVM. This value +must be set to a power of two. + +`SHARD_BATCH_SIZE`: The number of shards that will be proven in parallel. This value can be tuned +depending on how much memory your machine has to improve performance. \ No newline at end of file diff --git a/book/generating-proofs/prover-options.md b/book/generating-proofs/prover-options.md new file mode 100644 index 0000000000..bae82bdd4b --- /dev/null +++ b/book/generating-proofs/prover-options.md @@ -0,0 +1,38 @@ +# Prover Options + +The prover options can be configured using a "builder" pattern after creating a `ProverClient` and +calling `prove` on it. + +For a full list of options, see the [SP1 SDK](https://github.com/succinctlabs/sp1/blob/dev/sdk/src/action.rs). + +## Core (Default) + +The default prover mode generates a list of STARK proofs that in aggregate have size proportional to + the size of the execution. Use this in settings where you don't care about **verification cost / proof size**. + +```rust,noplayground +let client = ProverClient::new(); +client.prove(&pk, stdin).run().unwrap(); +``` + +## Compressed + +The compressed prover mode generates STARK proofs that have constant size. Use this in settings where you +care about **verification cost / proof size**. + +```rust,noplayground +let client = ProverClient::new(); +client.prove(&pk, stdin).compressed().run().unwrap(); +``` + +## PLONK + +> WARNING: The PLONK prover requires around 128GB of RAM and is only guaranteed to work on official releases of SP1. + +The PLONK prover mode generates a SNARK proof with extremely small proof size and low verification cost. +This mode is necessary for generating proofs that can be verified onchain for around ~300k gas. + +```rust,noplayground +let client = ProverClient::new(); +client.prove(&pk, stdin).plonk().run().unwrap(); +``` diff --git a/book/generating-proofs/setup.md b/book/generating-proofs/setup.md index fc7c68aeb4..4b2252d26e 100644 --- a/book/generating-proofs/setup.md +++ b/book/generating-proofs/setup.md @@ -36,4 +36,4 @@ edition = "2021" sp1-sdk = { git = "https://github.com/succinctlabs/sp1.git" } ``` -The `sp1-sdk` crate includes necessary utilities to generate, save, and verify proofs. +The `sp1-sdk` crate includes the necessary utilities to generate, save, and verify proofs. diff --git a/book/getting-started/hardware-requirements.md b/book/getting-started/hardware-requirements.md new file mode 100644 index 0000000000..dc6edd3289 --- /dev/null +++ b/book/getting-started/hardware-requirements.md @@ -0,0 +1,34 @@ +# Hardware Requirements + +The hardware requirements for SP1 depend on what features you want to use. These requirements can also +change over time as the design of the zKVM evolves. + +**The most important requirement is CPU for performance/latency and RAM to prevent running out of memory.** + +| | Mock / Network | Core / Compress | PLONK (EVM) | +|----------------|------------------------------|------------------------------------|----------------------------| +| CPU | 1+, single-core perf matters | 16+, more is better | 32+, more is better | +| Memory | 8GB+, more is better | 32GB+, more if you have more cores | 128GB+ (for PLONK) | +| Disk | 20GB+ | 20GB+ | 100GB+ (for trusted setup) | +| EVM Compatible | ✅ | ❌ | ✅ | + +### CPU + +The execution & trace generation of the zkVM is mostly CPU bound, having a high single-core +performance is recommended to accelerate these steps. The rest of the prover is mostly bound by hashing/field operations +which can be parallelized with multiple cores. + +### Memory + +Our prover requires keeping large matrices (i.e., traces) in memory to generate the proofs. Certain steps of the prover +have a minimum memory requirement, meaning that if you have less than this amount of memory, the process will OOM. + +This effect is most noticeable when using the PLONK prover, which requires around 128GB of RAM to generate a proof. We use PLONK to avoid +having to perform a trusted setup, which other SNARK provers like Groth16 require. We have future optimizations planned to reduce +the memory requirements of the PLONK prover substantially. + +### Disk + +Disk is required to install the SP1 zkVM toolchain and to install the trused setup artifacts, if you plan to locally build the PLONK prover. + +Furthermore, disk is used to checkpoint the state of the program execution, which is required to generate the proofs. \ No newline at end of file diff --git a/book/getting-started/install.md b/book/getting-started/install.md index f555f422bc..0b91a464e6 100644 --- a/book/getting-started/install.md +++ b/book/getting-started/install.md @@ -5,9 +5,9 @@ build the toolchain and CLI from source. ## Requirements +- [Git](https://git-scm.com/book/en/v2/Getting-Started-Installing-Git) - [Rust (Nightly)](https://www.rust-lang.org/tools/install) - [Docker](https://docs.docker.com/get-docker/) -- [Go >1.22.1 (Optional)](https://go.dev/doc/install) ## Option 1: Prebuilt Binaries (Recommended) @@ -42,7 +42,9 @@ If this works, go to the [next section](./quickstart.md) to compile and prove a ### Troubleshooting -If you have installed `cargo-prove` from source, it may conflict with sp1up's `cargo-prove` installation or vice versa. You can remove the `cargo-prove` that was installed from source with the following command: +If you experience [rate-limiting](https://docs.github.com/en/rest/using-the-rest-api/getting-started-with-the-rest-api?apiVersion=2022-11-28#rate-limiting) when using the `sp1up` command, you can resolve this by using the `--token` flag and providing your GitHub token. + +If you have installed `cargo-prove` from source, it may conflict with `sp1up`'s `cargo-prove` installation or vice versa. You can remove the `cargo-prove` that was installed from source with the following command: ```bash rm ~/.cargo/bin/cargo-prove @@ -75,7 +77,7 @@ Building the toolchain can take a while, ranging from 30 mins to an hour dependi cargo prove install-toolchain ``` -To verify the installation of the tooolchain, run and make sure you see `succinct`: +To verify the installation of the toolchain, run and make sure you see `succinct`: ```bash rustup toolchain list @@ -86,28 +88,3 @@ You can delete your existing installation of the toolchain with: ```bash rustup toolchain remove succinct ``` - -## Option 3: Using Docker - -SP1 can also be used entirely within a Docker container. If you don't have it, Docker can be -installed directly from [Docker's website](https://docs.docker.com/get-docker/). - -Then you can use: - -```bash -cargo prove --docker -``` - -to automatically use the latest image of SP1 in a container. - -Alternatively, it is possible to build the docker image locally by running: - -```bash -docker build -t succinctlabs/sp1:latest ./cli/docker -``` - -You can then run the `cargo prove` command by mounting your program directory into the container: - -```bash -docker run -v "$(pwd):/root/program" -it succinctlabs/sp1:latest prove build -``` diff --git a/book/onchain-verification/contract-addresses.md b/book/onchain-verification/contract-addresses.md new file mode 100644 index 0000000000..70fd26b07a --- /dev/null +++ b/book/onchain-verification/contract-addresses.md @@ -0,0 +1,43 @@ +# Contract Addresses + +When using SP1, we recommend using our deployed verifiers. Each contract is a [SP1VerifierGateway](https://github.com/succinctlabs/sp1-contracts/blob/main/contracts/src/ISP1VerifierGateway.sol) which can automatically routes your SP1 proof to the correct verifier based on the prover version. + + +| Chain ID | Chain | Gateway | +|----------|------------------|---------------------------------------------------------------------------------------------------------------------------------| +| 11155111 | Sepolia | [0x3B6041173B80E77f038f3F2C0f9744f04837185e](https://sepolia.etherscan.io/address/0x3B6041173B80E77f038f3F2C0f9744f04837185e) | +| 17000 | Holesky | [0x3B6041173B80E77f038f3F2C0f9744f04837185e](https://holesky.etherscan.io/address/0x3B6041173B80E77f038f3F2C0f9744f04837185e) | +| 42161 | Arbitrum One | [0x3B6041173B80E77f038f3F2C0f9744f04837185e](https://arbiscan.io/address/0x3B6041173B80E77f038f3F2C0f9744f04837185e) | +| 421614 | Arbitrum Sepolia | [0x3B6041173B80E77f038f3F2C0f9744f04837185e](https://sepolia.arbiscan.io/address/0x3B6041173B80E77f038f3F2C0f9744f04837185e) | +| 534351 | Scroll Sepolia | [0x3B6041173B80E77f038f3F2C0f9744f04837185e](https://sepolia.scrollscan.com/address/0x3B6041173B80E77f038f3F2C0f9744f04837185e) | +| 534352 | Scroll | [0x3B6041173B80E77f038f3F2C0f9744f04837185e](https://scrollscan.com/address/0x3B6041173B80E77f038f3F2C0f9744f04837185e) | +| 8453 | Base | [0x3B6041173B80E77f038f3F2C0f9744f04837185e](https://basescan.org/address/0x3B6041173B80E77f038f3F2C0f9744f04837185e) | +| 84532 | Base Sepolia | [0x3B6041173B80E77f038f3F2C0f9744f04837185e](https://sepolia.basescan.org/address/0x3B6041173B80E77f038f3F2C0f9744f04837185e) | + +**Currently officially supported versions of SP1 are v1.0.7 and v1.0.8.** If you'd like official support for a verifier on a different chain, please ask in the [SP1 Telegram](https://t.me/succinct_sp1). + +## ISP1Verifier Interface + +All verifiers implement the [ISP1Verifier](https://github.com/succinctlabs/sp1-contracts/blob/main/contracts/src/ISP1Verifier.sol) interface. + +```c++ +// SPDX-License-Identifier: MIT +pragma solidity ^0.8.20; + +/// @title SP1 Verifier Interface +/// @author Succinct Labs +/// @notice This contract is the interface for the SP1 Verifier. +interface ISP1Verifier { + /// @notice Verifies a proof with given public values and vkey. + /// @dev It is expected that the first 4 bytes of proofBytes must match the first 4 bytes of + /// target verifier's VERIFIER_HASH. + /// @param programVKey The verification key for the RISC-V program. + /// @param publicValues The public values encoded as bytes. + /// @param proofBytes The proof of the program execution the SP1 zkVM encoded as bytes. + function verifyProof( + bytes32 programVKey, + bytes calldata publicValues, + bytes calldata proofBytes + ) external view; +} +``` \ No newline at end of file diff --git a/book/onchain-verification/getting-started.md b/book/onchain-verification/getting-started.md new file mode 100644 index 0000000000..f9eb36b1a1 --- /dev/null +++ b/book/onchain-verification/getting-started.md @@ -0,0 +1,33 @@ +# Onchain Verification: Setup + +The best way to get started with verifying SP1 proofs on-chain is to refer to the [SP1 Project Template](https://github.com/succinctlabs/sp1-project-template/tree/main). + +- The template [program](https://github.com/succinctlabs/sp1-project-template/blob/main/program/src/main.rs) shows how to write outputs that can be decoded in Solidity. +- The template [script](https://github.com/succinctlabs/sp1-project-template/blob/main/script/src/bin/prove.rs) shows how to generate the proof using the SDK and save it to a file. +- The template [contract](https://github.com/succinctlabs/sp1-project-template/blob/main/contracts/src/Fibonacci.sol) shows how to verify the proof onchain using Solidity. + +Refer to the section on [Contract Addresses](./contract-addresses.md) for the addresses of the deployed verifiers. + +## Generating SP1 Proofs for Onchain Verification + +By default, the proofs generated by SP1 are not verifiable onchain, as they are non-constant size and STARK verification on Ethereum is very expensive. To generate a proof that can be verified onchain, we use performant STARK recursion to combine SP1 shard proofs into a single STARK proof and then wrap that in a SNARK proof. Our `ProverClient` has a prover option for this called `plonk`. Behind the scenes, this function will first generate a normal SP1 proof, then recursively combine all of them into a single proof using the STARK recursion protocol. Finally, the proof is wrapped in a SNARK proof using PLONK. + +> WARNING: The PLONK prover is only guaranteed to work on official releases of SP1. To use PLONK proving & verification locally, ensure that you have Docker installed and have at least 128GB of RAM. + +### Example + +```rust,noplayground +{{#include ../../examples/fibonacci/script/bin/plonk_bn254.rs}} +``` + +You can run the above script with `RUST_LOG=info cargo run --bin plonk_bn254 --release` in `examples/fibonacci/script`. + +#### Using PLONK without Docker (Advanced) + +If you would like to run the PLONK prover directly without Docker, you must have Go 1.22 installed and enable the `native-plonk` feature in `sp1-sdk`. This path is not recommended and may require additional native dependencies. + +```toml +sp1-sdk = { features = ["native-plonk"] } +``` + + diff --git a/book/onchain-verification/solidity-sdk.md b/book/onchain-verification/solidity-sdk.md new file mode 100644 index 0000000000..48f033e73a --- /dev/null +++ b/book/onchain-verification/solidity-sdk.md @@ -0,0 +1,70 @@ +# Solidity SDK + +We maintain a suite of [contracts](https://github.com/succinctlabs/sp1-contracts/tree/main) used for verifying SP1 proofs onchain. We highly recommend using [Foundry](https://book.getfoundry.sh/). + +## Installation + +To install the latest release version: + +```bash +forge install succinctlabs/sp1-contracts +``` + +To install a specific version: + +```bash +forge install succinctlabs/sp1-contracts@ +``` + +Finally, add `@sp1-contracts/=lib/sp1-contracts/contracts/src/` in `remappings.txt.` + +### Usage + +Once installed, you can use the contracts in the library by importing them: + +```c++ +// SPDX-License-Identifier: MIT +pragma solidity ^0.8.20; + +import {ISP1Verifier} from "@sp1-contracts/ISP1Verifier.sol"; + +/// @title Fibonacci. +/// @author Succinct Labs +/// @notice This contract implements a simple example of verifying the proof of a computing a +/// fibonacci number. +contract Fibonacci { + /// @notice The address of the SP1 verifier contract. + /// @dev This can either be a specific SP1Verifier for a specific version, or the + /// SP1VerifierGateway which can be used to verify proofs for any version of SP1. + /// For the list of supported verifiers on each chain, see: + /// https://github.com/succinctlabs/sp1-contracts/tree/main/contracts/deployments + address public verifier; + + /// @notice The verification key for the fibonacci program. + bytes32 public fibonacciProgramVkey; + + constructor(address _verifier, bytes32 _fibonacciProgramVkey) { + verifier = _verifier; + fibonacciProgramVkey = _fibonacciProgramVkey; + } + + /// @notice The entrypoint for verifying the proof of a fibonacci number. + /// @param proof The encoded proof. + /// @param publicValues The encoded public values. + function verifyFibonacciProof(bytes calldata proof, bytes calldata publicValues) + public + view + returns (uint32, uint32, uint32) + { + ISP1Verifier(verifier).verifyProof(fibonacciProgramVkey, publicValues, proof); + (uint32 n, uint32 a, uint32 b) = abi.decode(publicValues, (uint32, uint32, uint32)); + return (n, a, b); + } +} +``` + +For more details on the contracts, refer to the [sp1-contracts](https://github.com/succinctlabs/sp1-contracts) repo. + +### Testing + +To test the contract, we recommend setting up [Foundry Tests](https://book.getfoundry.sh/forge/tests). We have an example of such a test in the [SP1 Project Template](https://github.com/succinctlabs/sp1-project-template/blob/dev/contracts/test/Fibonacci.t.sol). \ No newline at end of file diff --git a/book/prover-network/key.png b/book/prover-network/key.png new file mode 100644 index 0000000000..ccbb4b8974 Binary files /dev/null and b/book/prover-network/key.png differ diff --git a/book/prover-network/setup.md b/book/prover-network/setup.md index 44544cf689..1417885c29 100644 --- a/book/prover-network/setup.md +++ b/book/prover-network/setup.md @@ -1,35 +1,50 @@ # Prover Network: Setup +> **Currently, the supported version of SP1 on the prover network is `v1.0.5-testnet`.** + So far we've explored how to generate proofs locally, but this can actually be inconvenient on local machines due to high memory / CPU requirements, especially for very large programs. -Succinct [has been building](https://blog.succinct.xyz/succinct-network/) the Succinct Network, a distributed network of provers that can generate proofs of any size quickly and reliably. It's currently in private beta, but you can get access by following the steps below. +Succinct [has been building](https://blog.succinct.xyz/succinct-network/) the Succinct Prover Network, a distributed network of provers that can generate proofs of any size quickly and reliably. It's currently in private beta, but you can get access by following the steps below. -## Get access +## Get your key whitelisted -Currently the network is permissioned, so you need to gain access through Succinct. After you have completed the key setup below, you can submit your address in this [form](https://docs.google.com/forms/d/e/1FAIpQLSd-X9uH7G0bvXH_kjptnQtNil8L4dumrVPpFE4t8Ci1XT1GaQ/viewform) and we'll contact you shortly. +**[FILL OUT THIS FORM](https://forms.gle/rTUvhstS8PFfv9B3A)** to gain access to the Succinct +Network. Completing this form requires you to complete the [key setup](#key-setup) steps below. -### Key Setup +## Key Setup -The prover network uses secp256k1 keypairs for authentication, like Ethereum wallets. You may generate a new keypair explicitly for use with the prover network, or use an existing keypair. Currently you do not need to hold any funds in this account, it is used solely for access control. +The prover network uses Secp256k1 keypairs for authentication, similar to Ethereum wallets. You may generate a new keypair explicitly for use with the prover network, or use an existing keypair. **You do not need to hold any funds in this account, it is used solely for access control.** -Prover network keypair credentials can be generated using the [cast](https://book.getfoundry.sh/cast/) CLI tool: +### Generate a new keypair with `cast` +Prover network keypair credentials can be generated using the +[cast](https://book.getfoundry.sh/cast/) CLI tool. -[Install](https://book.getfoundry.sh/getting-started/installation#using-foundryup): +First install [Foundry](https://book.getfoundry.sh/getting-started/installation#using-foundryup): ```sh curl -L https://foundry.paradigm.xyz | bash ``` -Generate a new keypair: +Upon running this command, you will be prompted to source your shell profile and run `foundryup`. Afterwards you should have access to the `cast` command. + +Use `cast` to generate a new keypair: ```sh cast wallet new ``` -Or, retrieve your address from an existing key: +which will give you an output similar to this: + +![Screenshot from running 'cast wallet new' to generate an SP1_PRIVATE_KEY.](key.png) + +The "Address" what you should submit in the [form](https://forms.gle/rTUvhstS8PFfv9B3A), in the example above this is `0x552f0FC6D736ed965CE07a3D71aA639De15B627b`. The "Private key" should be kept safe and +secure. When interacting with the network, you will set your `SP1_PRIVATE_KEY` environment variable +to this value. + +### Retrieve an existing key + +If you already have an existing key you would like to use, you can also use `cast` retrieve your address: ```sh cast wallet address --private-key $PRIVATE_KEY ``` - -Make sure to keep your private key somewhere safe and secure, you'll need it to interact with the prover network. diff --git a/book/prover-network/usage.md b/book/prover-network/usage.md index edaf114944..4b695d25f2 100644 --- a/book/prover-network/usage.md +++ b/book/prover-network/usage.md @@ -1,5 +1,7 @@ # Prover Network: Usage +> **Currently, the supported version of SP1 on the prover network is `v1.0.5-testnet`.** + ## Sending a proof request To use the prover network to generate a proof, you can run your script that uses `sp1_sdk::ProverClient` as you would normally but with additional environment variables set: @@ -8,7 +10,7 @@ To use the prover network to generate a proof, you can run your script that uses // Generate the proof for the given program. let client = ProverClient::new(); let (pk, vk) = client.setup(ELF); -let mut proof = client.prove(&pk, stdin).unwrap(); +let mut proof = client.prove(&pk, stdin).run().unwrap(); ``` ```sh @@ -17,8 +19,8 @@ SP1_PROVER=network SP1_PRIVATE_KEY=... RUST_LOG=info cargo run --release - `SP1_PROVER` should be set to `network` when using the prover network. -- `SP1_PRIVATE_KEY` should be set to your [private key](#key-setup). You will need - to be using a [permissioned](#get-access) key to use the network. +- `SP1_PRIVATE_KEY` should be set to your [private key](./setup.md#key-setup). You will need + to be using a [permissioned](./setup.md#get-access) key to use the network. When you call any of the prove functions in ProverClient now, it will first simulate your program, then wait for it to be proven through the network and finally return the proof. diff --git a/book/prover-network/versions.md b/book/prover-network/versions.md new file mode 100644 index 0000000000..a6dfc1b6f3 --- /dev/null +++ b/book/prover-network/versions.md @@ -0,0 +1,27 @@ +# Supported Versions + +The prover network currently only supports specific versions of SP1: + +| Environment | RPC URL | Supported Version | +| ----------- | -------------------------- | ----------------- | +| Prod | `https://rpc.succinct.xyz` | v1.0.5-testnet | + +If you submit a proof request to the prover network and your are not using the supported version, you will receive an error message. + +## Changing versions + +You must switch to a supported version before submitting a proof. To do so, replace the `sp1-zkvm` version in your progam's `Cargo.toml`: + +```toml +[dependencies] +sp1-zkvm = { git = "https://github.com/succinctlabs/sp1.git", tag = "v1.0.5-testnet" } +``` + +replace the `sp1-sdk` version in your script's `Cargo.toml`: + +```toml +[dependencies] +sp1-sdk = { git = "https://github.com/succinctlabs/sp1.git", tag = "v1.0.5-testnet" } +``` + +Re-build your program and script, and then try again. diff --git a/book/verifying-proofs/solidity-and-evm.md b/book/verifying-proofs/solidity-and-evm.md deleted file mode 100644 index e282a73cff..0000000000 --- a/book/verifying-proofs/solidity-and-evm.md +++ /dev/null @@ -1,65 +0,0 @@ -# Verifying Proofs: Solidity & EVM - -SP1 recently added support for verifying proofs for onchain usecases. To see an end-to-end example -of using SP1 for on-chain usecases, refer to the [SP1 Project Template](https://github.com/succinctlabs/sp1-project-template/tree/main). - -## Generating a Plonk Bn254 Proof - -By default, the proofs generated by SP1 are not verifiable onchain, as they are non-constant size and STARK verification on Ethereum is very expensive. To generate a proof that can be verified onchain, we use performant STARK recursion to combine SP1 shard proofs into a single STARK proof and then wrap that in a SNARK proof. Our `ProverClient` has a function for this called `prove_plonk`. Behind the scenes, this function will first generate a normal SP1 proof, then recursively combine all of them into a single proof using the STARK recursion protocol. Finally, the proof is wrapped in a SNARK proof using PLONK. - -**The PLONK Bn254 prover is only guaranteed to work on official releases of SP1. To use PLONK proving & verification locally, ensure that you have Docker installed.** - -### Example - -```rust,noplayground -{{#include ../../examples/fibonacci/script/bin/plonk_bn254.rs}} -``` - -You can run the above script with `RUST_LOG=info cargo run --bin plonk_bn254 --release` in `examples/fibonacci/script`. - -### Advanced: PLONK without Docker - -If you would like to run the PLONK prover directly without Docker, you must have Go 1.22 installed and enable the `native-plonk` feature in `sp1-sdk`. This path is not recommended and may require additional native dependencies. - -```toml -sp1-sdk = { features = ["native-plonk"] } -``` - -# Install SP1 Contracts - -## SP1 Contracts - -This repository contains the smart contracts for verifying [SP1](https://github.com/succinctlabs/sp1) EVM proofs. - -## Installation - -> [!WARNING] > [Foundry](https://github.com/foundry-rs/foundry) installs the latest release version initially, but subsequent `forge update` commands will use the `main` branch. This branch is the development branch and should be avoided in favor of tagged releases. The release process matches a specific SP1 version. - -To install the latest release version: - -```bash -forge install succinctlabs/sp1-contracts -``` - -To install a specific version: - -```bash -forge install succinctlabs/sp1-contracts@ -``` - -Add `@sp1-contracts/=lib/sp1-contracts/contracts/src/` in `remappings.txt.` - -### Usage - -Once installed, you can use the contracts in the library by importing them: - -```solidity -pragma solidity ^0.8.19; - -import {SP1Verifier} from "@sp1-contracts/SP1Verifier.sol"; - -contract MyContract is SP1Verifier { -} -``` - -For more details on the contracts, refer to the [sp1-contracts](https://github.com/succinctlabs/sp1-contracts) repo. diff --git a/book/what-is-a-zkvm.md b/book/what-is-a-zkvm.md new file mode 100644 index 0000000000..f58d3240dc --- /dev/null +++ b/book/what-is-a-zkvm.md @@ -0,0 +1,14 @@ +# What is a zkVM? + +A zero-knowledge virtual machine (zkVM) is zero-knowledge proof system that allows developers to prove the execution of arbitrary Rust (or other LLVM-compiled language) programs. + +Conceptually, you can think of the SP1 zkVM as proving the evaluation of a function `f(x) = y` by following the steps below: + +- Define `f` using normal Rust code and compile it to an ELF (covered in the [writing programs](./writing-programs/setup.md) section). +- Setup a proving key (`pk`) and verifying key (`vk`) for the program given the ELF. +- Generate a proof `π` using the SP1 zkVM that `f(x) = y` with `prove(pk, x)`. +- Verify the proof `π` using `verify(vk, x, y, π)`. + +As a practical example, `f` could be a simple Fibonacci [program](https://github.com/succinctlabs/sp1/blob/main/examples/fibonacci/program/src/main.rs). The process of generating a proof and verifying it can be seen [here](https://github.com/succinctlabs/sp1/blob/main/examples/fibonacci/script/src/main.rs). + +For blockchain applications, the verification usually happens inside of a [smart contract](https://github.com/succinctlabs/sp1-project-template/blob/main/contracts/src/Fibonacci.sol). diff --git a/book/why-use-sp1.md b/book/why-use-sp1.md new file mode 100644 index 0000000000..d76551e936 --- /dev/null +++ b/book/why-use-sp1.md @@ -0,0 +1,17 @@ +# Why use SP1? + +Zero-knowledge proofs (ZKPs) are a powerful primitive that enable developers to outsource verifiable computation to provers. But ZKP adoption has been held back because it is “moon math”, requiring specialized knowledge in obscure ZKP frameworks and hard to maintain one-off deployments. + +Performant, general-purpose zkVMs, like SP1, will obsolete the current paradigm of specialized teams hand rolling their own custom ZK stack and create a future where all blockchain infrastructure, including rollups, bridges, coprocessors, and more, utilize ZKPs **via maintainable software written in Rust (or other LLVM-compiled languages)**. + +SP1 is especially powerful in blockchain contexts which rely on verifiable computation. Example applications include: +- [Rollups](https://ethereum.org/en/developers/docs/scaling/zk-rollups/): SP1 can be used in combination with existing node infrastructure like [Reth](https://github.com/paradigmxyz/reth) to build rollups with fraud proofs based on zero-knowledge proofs. +- [Coprocessors](https://crypto.mirror.xyz/BFqUfBNVZrqYau3Vz9WJ-BACw5FT3W30iUX3mPlKxtA): SP1 can be used to outsource onchain computation to offchain provers to enable use cases such as accessing historical state and onchain machine learning, dramatically reducing gas costs. +- [Light Clients](https://ethereum.org/en/developers/docs/nodes-and-clients/light-clients/): SP1 can be used to build light clients that can verify the state of other chains, facilitating interoperability between different blockchains without relying on any trusted third parties. + +SP1 has already been integrated in many of these applications, including but not limited to: + +- [SP1 Reth](https://github.com/succinctlabs/sp1-reth): A performant, type-1 zkEVM written in Rust & SP1. +- [SP1 Tendermint](https://github.com/succinctlabs/sp1-tendermint-example): An example of a ZK Tendermint light client on Ethereum powered by SP1. +- and many more! + diff --git a/book/writing-programs/basics.md b/book/writing-programs/basics.md index 514cc049ee..552a48a37f 100644 --- a/book/writing-programs/basics.md +++ b/book/writing-programs/basics.md @@ -1,15 +1,8 @@ # Writing Programs: Basics -A zero-knowledge proof generally proves that some function `f` when applied to some input `x` produces some output `y` (i.e. `f(x) = y`). -In the context of the SP1 zkVM: +The easiest way to understand how to write programs for the SP1 zkVM is to look at some examples. -- `f` is written in normal Rust code. -- `x` are bytes that can be serialized / deserialized into objects -- `y` are bytes that can be serialized / deserialized into objects - -To make this more concrete, let's walk through a simple example of writing a Fibonacci program inside the zkVM. - -## Fibonacci +## Example: Fibonacci This program is from the `examples` [directory](https://github.com/succinctlabs/sp1/tree/main/examples) in the SP1 repo which contains several example programs of varying complexity. diff --git a/book/writing-programs/build-script.md b/book/writing-programs/build-script.md new file mode 100644 index 0000000000..fa673ad806 --- /dev/null +++ b/book/writing-programs/build-script.md @@ -0,0 +1,30 @@ +# Build Script + +> WARNING: This may not generate a reproducible ELF which is necessary for verifying that your binary corresponds to given source code. +> +> When building a ELF that will be used in production, make sure to use the [reproduction build system](../writing-programs/setup.md#build-with-docker-production). + +If you want your program crate to be built automatically whenever you build/run your script crate, you can add a `build.rs` file inside of `script/` (at the same level as `Cargo.toml`): + +```rust,noplayground +{{#include ../../examples/fibonacci/script/build.rs}} +``` + +Make sure to also add `sp1-helper` as a build dependency in `script/Cargo.toml`: + +```toml +[build-dependencies] +sp1-helper = { git = "https://github.com/succinctlabs/sp1.git" } +``` + +If you run `RUST_LOG=info cargo run --release -vv`, you will see the following output from the build script if the program has changed, indicating that the program was rebuilt: + +```` +[fibonacci-script 0.1.0] cargo:rerun-if-changed=../program/src +[fibonacci-script 0.1.0] cargo:rerun-if-changed=../program/Cargo.toml +[fibonacci-script 0.1.0] cargo:rerun-if-changed=../program/Cargo.lock +[fibonacci-script 0.1.0] cargo:warning=fibonacci-program built at 2024-03-02 22:01:26 +[fibonacci-script 0.1.0] [sp1] Compiling fibonacci-program v0.1.0 (/Users/umaroy/Documents/fibonacci/program) +[fibonacci-script 0.1.0] [sp1] Finished release [optimized] target(s) in 0.15s +warning: fibonacci-script@0.1.0: fibonacci-program built at 2024-03-02 22:01:26``` +```` diff --git a/book/writing-programs/inputs-and-outputs.md b/book/writing-programs/inputs-and-outputs.md index 4615ea64fd..9f819d6763 100644 --- a/book/writing-programs/inputs-and-outputs.md +++ b/book/writing-programs/inputs-and-outputs.md @@ -24,7 +24,7 @@ Note that `T` must implement the `serde::Serialize` and `serde::Deserialize` tra let my_vec = sp1_zkvm::io::read_vec(); ``` -## Commiting Data +## Committing Data Committing to data makes the data public to the verifier. Use the `sp1_zkvm::io::commit::` method: diff --git a/book/writing-programs/patched-crates.md b/book/writing-programs/patched-crates.md index 06468237b0..bceae2b10d 100644 --- a/book/writing-programs/patched-crates.md +++ b/book/writing-programs/patched-crates.md @@ -1,7 +1,7 @@ # Patched Crates We maintain forks of commonly used libraries in blockchain infrastructure to significantly accelerate the execution of certain operations. -Under the hood, we use [precompiles](./precompiles.md) to acheive tremendous performance improvements in proof generation time. +Under the hood, we use [precompiles](./precompiles.md) to achieve tremendous performance improvements in proof generation time. **If you know of a library or library version that you think should be patched, please open an issue or a pull request!** @@ -10,6 +10,8 @@ Under the hood, we use [precompiles](./precompiles.md) to acheive tremendous per | Crate Name | Repository | Notes | | ------------------- | ------------------------------------------------------------------------------------- | ---------------------- | | sha2 | [sp1-patches/RustCrypto-hashes](https://github.com/sp1-patches/RustCrypto-hashes) | sha256 | +| sha3 | [sp1-patches/RustCrypto-hashes](https://github.com/sp1-patches/RustCrypto-hashes) | keccak256 | +| bigint | [sp1-patches/RustCrypto-bigint](https://github.com/sp1-patches/RustCrypto-bigint) | bigint | | tiny-keccak | [sp1-patches/tiny-keccak](https://github.com/sp1-patches/tiny-keccak) | keccak256 | | ed25519-consensus | [sp1-patches/ed25519-consensus](http://github.com/sp1-patches/ed25519-consensus) | ed25519 verify | | curve25519-dalek-ng | [sp1-patches/curve25519-dalek-ng](https://github.com/sp1-patches/curve25519-dalek-ng) | ed25519 verify | @@ -23,9 +25,13 @@ To use the patched libraries, you can use corresponding patch entries in your pr ```toml [patch.crates-io] -sha2-v0-9-8 = { git = "https://github.com/sp1-patches/RustCrypto-hashes", package = "sha2", branch = "patch-v0.9.8" } -sha2-v0-10-6 = { git = "https://github.com/sp1-patches/RustCrypto-hashes", package = "sha2", branch = "patch-v0.10.6" } -sha2-v0-10-8 = { git = "https://github.com/sp1-patches/RustCrypto-hashes", package = "sha2", branch = "patch-v0.10.8" } +sha2-v0-9-8 = { git = "https://github.com/sp1-patches/RustCrypto-hashes", package = "sha2", branch = "patch-sha2-v0.9.8" } +sha2-v0-10-6 = { git = "https://github.com/sp1-patches/RustCrypto-hashes", package = "sha2", branch = "patch-sha2-v0.10.6" } +sha2-v0-10-8 = { git = "https://github.com/sp1-patches/RustCrypto-hashes", package = "sha2", branch = "patch-sha2-v0.10.8" } +sha3-v0-9-8 = { git = "https://github.com/sp1-patches/RustCrypto-hashes", package = "sha3", branch = "patch-sha3-v0.9.8" } +sha3-v0-10-6 = { git = "https://github.com/sp1-patches/RustCrypto-hashes", package = "sha3", branch = "patch-sha3-v0.10.6" } +sha3-v0-10-8 = { git = "https://github.com/sp1-patches/RustCrypto-hashes", package = "sha3", branch = "patch-sha3-v0.10.8" } +crypto-bigint = { git = "https://github.com/sp1-patches/RustCrypto-bigint", branch = "patch-v0.5.5" } curve25519-dalek = { git = "https://github.com/sp1-patches/curve25519-dalek", branch = "patch-v4.1.1" } curve25519-dalek-ng = { git = "https://github.com/sp1-patches/curve25519-dalek-ng", branch = "patch-v4.1.1" } ed25519-consensus = { git = "https://github.com/sp1-patches/ed25519-consensus", branch = "patch-v2.1.0" } @@ -34,67 +40,59 @@ revm = { git = "https://github.com/sp1-patches/revm", branch = "patch-v5.0.0" } reth-primitives = { git = "https://github.com/sp1-patches/reth", default-features = false, branch = "sp1-reth" } ``` -You may also need to update your `Cargo.lock` file. For example: +If you are patching a crate from Github instead of from crates.io, you need to specify the +repository in the patch section. For example: -```bash -cargo update -p ed25519-consensus +```toml +[patch."https://github.com/RustCrypto/hashes"] +sha3 = { git = "https://github.com/sp1-patches/RustCrypto-hashes", package = "sha3", branch = "patch-sha3-v0.10.8" } ``` -If you encounter issues relating to cargo / git, you can try setting `CARGO_NET_GIT_FETCH_WITH_CLI`: +An example of using patched crates is available in our [Tendermint Example](https://github.com/succinctlabs/sp1/blob/main/examples/tendermint/program/Cargo.toml#L22-L25). -``` -CARGO_NET_GIT_FETCH_WITH_CLI=true cargo update -p ed25519-consensus -``` +### Verifying Patch Usage: Cargo -You can permanently set this value in `~/.cargo/config`: +You can check if the patch was applied by using cargo's tree command to print the dependencies of the crate you patched. -```toml -[net] -git-fetch-with-cli = true +```bash +cargo tree -p sha2 +cargo tree -p sha2@0.9.8 ``` -### Sanity Checks +Next to the package name, it should have a link to the Github repository that you patched with. + +### Verifying Patch Usage: SP1 -**You must make sure your patch is in the workspace root, otherwise it will not be applied.** +To check if a precompile is used by your program, you can observe SP1's log output. Make sure to setup the logger with `sp1_sdk::utils::setup_logger()` and run your program with `RUST_LOG=info`. -You can check if the patch was applied by running a command like the following: +In the example below, note how the `sha256_extend` precompile was reported as being used eight times. ```bash -cargo tree -p sha2 -cargo tree -p sha2@0.9.8 +2024-07-03T04:46:33.753527Z INFO prove_core: execution report (syscall counts): +2024-07-03T04:46:33.753550Z INFO prove_core: 8 sha256_extend +2024-07-03T04:46:33.753550Z INFO prove_core: 8 commit +2024-07-03T04:46:33.753553Z INFO prove_core: 8 commit_deferred_proofs +2024-07-03T04:46:33.753554Z INFO prove_core: 4 write +2024-07-03T04:46:33.753555Z INFO prove_core: 1 halt ``` -Next to the package name, it should have a link to the Github repository that you patched with. +### Troubleshooting + +You may also need to update your `Cargo.lock` file. For example: -**Checking whether a precompile is used** +```bash +cargo update -p ed25519-consensus +``` -To check if a precompile is used by your program, when running the script to generate a proof, make sure to use the `RUST_LOG=info` environment variable and set up `utils::setup_logger()` in your script. Then, when you run the script, you should see a log message like the following: +If you encounter issues relating to cargo / git, you can try setting `CARGO_NET_GIT_FETCH_WITH_CLI`: ```bash -2024-03-02T19:10:39.570244Z INFO runtime.run(...): ... -2024-03-02T19:10:39.570244Z INFO runtime.run(...): ... -2024-03-02T19:10:40.003907Z INFO runtime.prove(...): Sharding the execution record. -2024-03-02T19:10:40.003916Z INFO runtime.prove(...): Generating trace for each chip. -2024-03-02T19:10:40.003918Z INFO runtime.prove(...): Record stats before generate_trace (incomplete): ShardStats { - nb_cpu_events: 7476561, - nb_add_events: 2126546, - nb_mul_events: 11116, - nb_sub_events: 54075, - nb_bitwise_events: 646940, - nb_shift_left_events: 142595, - nb_shift_right_events: 274016, - nb_divrem_events: 0, - nb_lt_events: 81862, - nb_field_events: 0, - nb_sha_extend_events: 0, - nb_sha_compress_events: 0, - nb_keccak_permute_events: 2916, - nb_ed_add_events: 0, - nb_ed_decompress_events: 0, - nb_weierstrass_add_events: 0, - nb_weierstrass_double_events: 0, - nb_k256_decompress_events: 0, -} +CARGO_NET_GIT_FETCH_WITH_CLI=true cargo update -p ed25519-consensus ``` -The `ShardStats` struct contains the number of events for each "table" from the execution of the program, including precompile tables. In the example above, the `nb_keccak_permute_events` field is `2916`, indicating that the precompile for the Keccak permutation was used. \ No newline at end of file +You can permanently set this value in `~/.cargo/config`: + +```toml +[net] +git-fetch-with-cli = true +``` diff --git a/book/writing-programs/precompiles.md b/book/writing-programs/precompiles.md index c48b7c6bfa..c65d20ae0b 100644 --- a/book/writing-programs/precompiles.md +++ b/book/writing-programs/precompiles.md @@ -2,7 +2,7 @@ Precompiles are built into the SP1 zkVM and accelerate commonly used operations such as elliptic curve arithmetic and hashing. Under the hood, precompiles are implemented as custom tables dedicated to proving one or few operations. **They typically improve the performance -of executing expensive operations by a few order of magnitudes.** +of executing expensive operations by a few orders of magnitude.** Inside the zkVM, precompiles are exposed as system calls executed through the `ecall` RISC-V instruction. Each precompile has a unique system call number and implements an interface for the computation. @@ -10,113 +10,15 @@ Each precompile has a unique system call number and implements an interface for SP1 also has been designed specifically to make it easy for external contributors to create and extend the zkVM with their own precompiles. To learn more about this, you can look at implementations of existing precompiles in the [precompiles](https://github.com/succinctlabs/sp1/tree/main/core/src/syscall/precompiles) folder. More documentation on this will be coming soon. -## Supported Precompiles +**To use precompiles, we typically recommend you interact with them through [patches](./patched-crates.md), which are crates modified +to use these precompiles under the hood.** -Typically, we recommend you interact with precompiles through [patches](./patched-crates.md), which are crates patched -to use these precompiles under the hood. However, if you are an advanced user you can interact -with the precompiles directly using extern system calls. +## Specification -Here is a list of extern system calls that use precompiles. +If you are an advanced user you can interact with the precompiles directly using external system calls. -### SHA256 Extend - -Executes the SHA256 extend operation on a word array. - -```rust,noplayground -pub extern "C" fn syscall_sha256_extend(w: *mut u32); -``` - -### SHA256 Compress - -Executes the SHA256 compress operation on a word array and a given state. - -```rust,noplayground -pub extern "C" fn syscall_sha256_compress(w: *mut u32, state: *mut u32); -``` - -### Keccak256 Permute - -Executes the Keccak256 permutation function on the given state. - -```rust,noplayground -pub extern "C" fn syscall_keccak_permute(state: *mut u64); -``` - -#### Ed25519 Add - -Adds two points on the ed25519 curve. The result is stored in the first point. - -```rust,noplayground -pub extern "C" fn syscall_ed_add(p: *mut u32, q: *mut u32); -``` - -#### Ed25519 Decompress. - -Decompresses a compressed Ed25519 point. - -The second half of the input array should contain the compressed Y point with the final bit as -the sign bit. The first half of the input array will be overwritten with the decompressed point, -and the sign bit will be removed. - -```rust,noplayground -pub extern "C" fn syscall_ed_decompress(point: &mut [u8; 64]) -``` - -#### Secp256k1 Add - -Adds two Secp256k1 points. The result is stored in the first point. - -```rust,noplayground -pub extern "C" fn syscall_secp256k1_add(p: *mut u32, q: *mut u32) -``` - -#### Secp256k1 Double - -Doubles a Secp256k1 point in place. - -```rust,noplayground -pub extern "C" fn syscall_secp256k1_double(p: *mut u32) -``` - -#### Secp256k1 Decompress - -Decompess a Secp256k1 point. - -The input array should be 32 bytes long, with the first 16 bytes containing the X coordinate in -big-endian format. The second half of the input will be overwritten with the decompressed point. - -```rust,noplayground -pub extern "C" fn syscall_secp256k1_decompress(point: &mut [u8; 64], is_odd: bool); -``` - -#### Bn254 Add - -Adds two Bn254 points. The result is stored in the first point. - -```rust,noplayground -pub extern "C" fn syscall_bn254_add(p: *mut u32, q: *mut u32) -``` - -#### Bn254 Double - -Doubles a Bn254 point in place. - -```rust,noplayground -pub extern "C" fn syscall_bn254_double(p: *mut u32) -``` - -#### Bls12-381 Add - -Adds two Bls12-381 points. The result is stored in the first point. - -```rust,noplayground -pub extern "C" fn syscall_bls12381_add(p: *mut u32, q: *mut u32) -``` - -#### Bls12-381 Double - -Doubles a Bls12-381 point in place. +Here is a list of all available system calls & precompiles. ```rust,noplayground -pub extern "C" fn syscall_bls12381_double(p: *mut u32) +{{#include ../../zkvm/lib/src/lib.rs}} ``` \ No newline at end of file diff --git a/book/writing-programs/proof-aggregation.md b/book/writing-programs/proof-aggregation.md new file mode 100644 index 0000000000..38806019c0 --- /dev/null +++ b/book/writing-programs/proof-aggregation.md @@ -0,0 +1,50 @@ +# Proof Aggregation + +SP1 supports proof aggregation and recursion, which allows you to verify proofs within a proof. Use cases include: + +- Reducing on-chain verification costs by aggregating multiple proofs into a single proof. +- Proving logic that is split into multiple proofs, such as proving a statement about a rollup's state transition function. + +**For an example of how to use proof aggregation and recursion in SP1, refer to the [aggregation example](https://github.com/succinctlabs/sp1/blob/main/examples/aggregation/script/src/main.rs).** + +## Verifying Proofs inside the zkVM + +To verify a proof inside the zkVM, you can use the `sp1_zkvm::lib::verify_proof` function. + +```rust,noplayground +sp1_zkvm::lib::verify_proof(vkey, public_values_digest); +``` + +**You do not need to pass in the proof as input into the syscall, as the proof will automatically be read for the proof input stream by the prover.** + +## Generating Proofs with Aggregation + +To provide an existing proof as input to the SP1 zkVM, you can use the existing `SP1Stdin` object +which is already used for all inputs to the zkVM. + +```rust,noplayground +# Generating proving key and verifying key. +let (input_pk, input_vk) = client.setup(PROOF_INPUT_ELF); +let (aggregation_pk, aggregation_vk) = client.setup(AGGREGATION_ELF); + +// Generate a proof that will be recursively verified / aggregated. +let mut stdin = SP1Stdin::new(); +let input_proof = client + .prove(&input_pk, stdin) + .compressed() + .run() + .expect("proving failed"); + +// Create a new stdin object to write the proof and the corresponding verifying key to. +let mut stdin = SP1Stdin::new(); +stdin.write_proof(proof, input_vk); + +// Generate a proof that will recusively verify / aggregate the input proof. +let aggregation_proof = client + .prove(&aggregation_pk, stdin) + .compressed() + .run() + .expect("proving failed"); + +``` + diff --git a/book/writing-programs/setup.md b/book/writing-programs/setup.md index 6cca74e9db..ca0dac1aa2 100644 --- a/book/writing-programs/setup.md +++ b/book/writing-programs/setup.md @@ -1,8 +1,8 @@ # Writing Programs: Setup -In this section, we will teach you how to setup a self-contained crate which can be compiled as an program that can be executed inside the zkVM. +In this section, we will teach you how to setup a self-contained crate which can be compiled as a program that can be executed inside the zkVM. -## CLI (Recommended) +## Create Project with CLI (Recommended) The recommended way to setup your first program to prove inside the zkVM is using the method described in [Quickstart](../getting-started/quickstart.md) which will create a program folder. @@ -11,25 +11,36 @@ cargo prove new cd program ``` -### Build +## Build with CLI (Development) -To build the program, simply run: +> WARNING: This may not generate a reproducible ELF which is necessary for verifying that your binary corresponds to given source code. +> +> Use the [reproducible build system](#build-with-docker-production) for production builds. -``` +To build the program while in development, simply run: + +```bash cargo prove build ``` This will compile the ELF that can be executed in the zkVM and put the executable in `elf/riscv32im-succinct-zkvm-elf`. -### Build with Docker +## Build with Docker (Production) -Another option is to build your program in a Docker container. This is useful if you are on a platform that does not have prebuilt binaries for the succinct toolchain, or if you are looking to get a reproducible ELF output. To do so, just use the `--docker` flag. +For production builds of programs, you can build your program inside a Docker container which will generate a **reproducible ELF** on all platforms. To do so, just use the `--docker` flag and the `--tag` flag with the release version you want to use. For example: +```bash +cargo prove build --docker --tag v1.0.5-testnet ``` -cargo prove build --docker + +To verify that your build is reproducible, you can compute the SHA-512 hash of the ELF on different platforms and systems with: + +```bash +$ shasum -a 512 elf/riscv32im-succinct-zkvm-elf +f9afb8caaef10de9a8aad484c4dd3bfa54ba7218f3fc245a20e8a03ed40b38c617e175328515968aecbd3c38c47b2ca034a99e6dbc928512894f20105b03a203 ``` -## Manual +## Manual Project Setup You can also manually setup a project. First create a new cargo project: @@ -67,13 +78,3 @@ sp1_zkvm::entrypoint!(main); ``` These two lines of code wrap your main function with some additional logic to ensure that your program compiles correctly with the RISCV target. - -### Build - -To build the program, simply run: - -``` -cargo prove build -``` - -This will compile the ELF (RISCV binary) that can be executed in the zkVM and put the executable in `elf/riscv32im-succinct-zkvm-elf`. diff --git a/build/CHANGELOG.md b/build/CHANGELOG.md new file mode 100644 index 0000000000..e9ccbee6ab --- /dev/null +++ b/build/CHANGELOG.md @@ -0,0 +1,19 @@ +# Changelog + +All notable changes to this project will be documented in this file. + +The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/), +and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html). + +## [Unreleased] + +## [1.0.0-rc.1](https://github.com/succinctlabs/sp1/compare/sp1-build-v1.0.0-rc.1...sp1-build-v1.0.0-rc.1) - 2024-07-19 + +### Fixed + +- `sp1-helper` workspace build ([#1119](https://github.com/succinctlabs/sp1/pull/1119)) + +### Other + +- _(deps)_ bump clap from 4.5.8 to 4.5.9 ([#1107](https://github.com/succinctlabs/sp1/pull/1107)) +- use global workspace version ([#1102](https://github.com/succinctlabs/sp1/pull/1102)) diff --git a/build/Cargo.toml b/build/Cargo.toml new file mode 100644 index 0000000000..87a17b2b5d --- /dev/null +++ b/build/Cargo.toml @@ -0,0 +1,14 @@ +[package] +name = "sp1-build" +description = "Build an SP1 program." +version = { workspace = true } +edition = { workspace = true } +license = { workspace = true } +repository = { workspace = true } +keywords = { workspace = true } +categories = { workspace = true } + +[dependencies] +cargo_metadata = "0.18.1" +anyhow = { version = "1.0.83" } +clap = { version = "4.5.9", features = ["derive", "env"] } diff --git a/build/README.md b/build/README.md new file mode 100644 index 0000000000..cc7620417c --- /dev/null +++ b/build/README.md @@ -0,0 +1,25 @@ +# sp1-build +Lightweight crate used to build SP1 programs. Internal crate that is exposed to users via `sp1-cli` and `sp1-helper`. + +Exposes `build_program`, which builds an SP1 program in the local environment or in a docker container with the specified parameters from `BuildArgs`. + +## Usage + +```rust +use sp1_build::build_program; + +build_program(&BuildArgs::default(), Some(program_dir)); +``` + +## Potential Issues + +If you attempt to build a program with Docker that depends on a local crate, and the crate is not in +the current workspace, you may run into issues with the docker build not being able to find the crate, as only the workspace root is mounted. + +``` +error: failed to load manifest for dependency `...` +``` + +To fix this, you can either: +1. Move the program into the workspace that contains the crate. +2. Build the crate locally instead. diff --git a/build/src/docker.rs b/build/src/docker.rs new file mode 100644 index 0000000000..2047bf9f8c --- /dev/null +++ b/build/src/docker.rs @@ -0,0 +1,71 @@ +use std::process::{exit, Command, Stdio}; + +use anyhow::{Context, Result}; +use cargo_metadata::camino::Utf8PathBuf; + +use crate::{get_program_build_args, get_rust_compiler_flags, BuildArgs}; + +/// Uses SP1_DOCKER_IMAGE environment variable if set, otherwise constructs the image to use based +/// on the provided tag. +fn get_docker_image(tag: &str) -> String { + std::env::var("SP1_DOCKER_IMAGE").unwrap_or_else(|_| { + let image_base = "ghcr.io/succinctlabs/sp1"; + format!("{}:{}", image_base, tag) + }) +} + +/// Creates a Docker command to build the program. +pub fn create_docker_command( + args: &BuildArgs, + program_dir: &Utf8PathBuf, + workspace_root: &Utf8PathBuf, +) -> Result { + let image = get_docker_image(&args.tag); + + // Check if docker is installed and running. + let docker_check = Command::new("docker") + .args(["info"]) + .stdout(Stdio::null()) + .stderr(Stdio::null()) + .status() + .context("failed to run docker command")?; + if !docker_check.success() { + eprintln!("docker is not installed or not running: https://docs.docker.com/get-docker/"); + exit(1); + } + + // Mount the entire workspace, and set the working directory to the program dir. Note: If the + // program dir has local dependencies outside of the workspace, building with Docker will fail. + let workspace_root_path = format!("{}:/root/program", workspace_root); + let program_dir_path = format!( + "/root/program/{}", + program_dir.strip_prefix(workspace_root).unwrap() + ); + + // Add docker-specific arguments. + let mut docker_args = vec![ + "run".to_string(), + "--rm".to_string(), + "--platform".to_string(), + "linux/amd64".to_string(), + "-v".to_string(), + workspace_root_path, + "-w".to_string(), + program_dir_path, + "-e".to_string(), + "RUSTUP_TOOLCHAIN=succinct".to_string(), + "-e".to_string(), + format!("CARGO_ENCODED_RUSTFLAGS={}", get_rust_compiler_flags()), + "--entrypoint".to_string(), + "".to_string(), + image, + "cargo".to_string(), + ]; + + // Add the SP1 program build arguments. + docker_args.extend_from_slice(&get_program_build_args(args)); + + let mut command = Command::new("docker"); + command.current_dir(program_dir.clone()).args(&docker_args); + Ok(command) +} diff --git a/build/src/lib.rs b/build/src/lib.rs new file mode 100644 index 0000000000..735f7edbf1 --- /dev/null +++ b/build/src/lib.rs @@ -0,0 +1,281 @@ +mod docker; + +use clap::Parser; +use std::{ + fs, + io::{BufRead, BufReader}, + path::PathBuf, + process::{exit, Command, Stdio}, + thread, +}; + +use anyhow::{Context, Result}; +use cargo_metadata::camino::Utf8PathBuf; + +const BUILD_TARGET: &str = "riscv32im-succinct-zkvm-elf"; +const DEFAULT_TAG: &str = "latest"; +const DEFAULT_OUTPUT_DIR: &str = "elf"; +const HELPER_TARGET_SUBDIR: &str = "elf-compilation"; + +/// [`BuildArgs`] is a struct that holds various arguments used for building a program. +/// +/// This struct can be used to configure the build process, including options for using Docker, +/// specifying binary and ELF names, ignoring Rust version checks, and enabling specific features. +#[derive(Clone, Parser, Debug)] +pub struct BuildArgs { + #[clap(long, action, help = "Build using Docker for reproducible builds.")] + pub docker: bool, + #[clap( + long, + help = "The ghcr.io/succinctlabs/sp1 image tag to use when building with docker.", + default_value = DEFAULT_TAG + )] + pub tag: String, + #[clap(long, action, value_delimiter = ',', help = "Build with features.")] + pub features: Vec, + #[clap(long, action, help = "Ignore Rust version check.")] + pub ignore_rust_version: bool, + #[clap( + alias = "bin", + long, + action, + help = "If building a binary, specify the name.", + default_value = "" + )] + pub binary: String, + #[clap(long, action, help = "ELF binary name.", default_value = "")] + pub elf_name: String, + #[clap( + long, + action, + help = "The output directory for the built program.", + default_value = DEFAULT_OUTPUT_DIR + )] + pub output_directory: String, + #[clap( + long, + action, + help = "Lock the dependencies, ensures that Cargo.lock doesn't update." + )] + pub locked: bool, + #[clap(long, action, help = "Build without default features.")] + pub no_default_features: bool, +} + +// Implement default args to match clap defaults. +impl Default for BuildArgs { + fn default() -> Self { + Self { + docker: false, + tag: DEFAULT_TAG.to_string(), + features: vec![], + ignore_rust_version: false, + binary: "".to_string(), + elf_name: "".to_string(), + output_directory: DEFAULT_OUTPUT_DIR.to_string(), + locked: false, + no_default_features: false, + } + } +} + +/// Get the arguments to build the program with the arguments from the [`BuildArgs`] struct. +fn get_program_build_args(args: &BuildArgs) -> Vec { + let mut build_args = vec![ + "build".to_string(), + "--release".to_string(), + "--target".to_string(), + BUILD_TARGET.to_string(), + ]; + + if args.ignore_rust_version { + build_args.push("--ignore-rust-version".to_string()); + } + + if !args.binary.is_empty() { + build_args.push("--bin".to_string()); + build_args.push(args.binary.clone()); + } + + if !args.features.is_empty() { + build_args.push("--features".to_string()); + build_args.push(args.features.join(",")); + } + + if args.no_default_features { + build_args.push("--no-default-features".to_string()); + } + + if args.locked { + build_args.push("--locked".to_string()); + } + + build_args +} + +/// Rust flags for compilation of C libraries. +fn get_rust_compiler_flags() -> String { + let rust_flags = [ + "-C".to_string(), + "passes=loweratomic".to_string(), + "-C".to_string(), + "link-arg=-Ttext=0x00200800".to_string(), + "-C".to_string(), + "panic=abort".to_string(), + ]; + rust_flags.join("\x1f") +} + +/// Get the command to build the program locally. +fn create_local_command(args: &BuildArgs, program_dir: &Utf8PathBuf) -> Command { + let mut command = Command::new("cargo"); + let canonicalized_program_dir = program_dir + .canonicalize() + .expect("Failed to canonicalize program directory"); + command + .current_dir(canonicalized_program_dir) + .env("RUSTUP_TOOLCHAIN", "succinct") + .env("CARGO_ENCODED_RUSTFLAGS", get_rust_compiler_flags()) + .args(&get_program_build_args(args)); + command +} + +/// Execute the command and handle the output depending on the context. +fn execute_command( + mut command: Command, + docker: bool, + program_metadata: &cargo_metadata::Metadata, +) -> Result<()> { + // Strip the rustc configuration, otherwise in the helper it will attempt to compile the SP1 + // program with the toolchain of the normal build process, rather than the Succinct toolchain. + command.env_remove("RUSTC"); + + // Set the target directory to a subdirectory of the program's target directory to avoid + // build conflicts with the parent process. If removed, programs that share the same target + // directory (i.e. same workspace) as the script will hang indefinitely due to a file lock + // when building in the helper. + // Source: https://github.com/rust-lang/cargo/issues/6412 + command.env( + "CARGO_TARGET_DIR", + program_metadata.target_directory.join(HELPER_TARGET_SUBDIR), + ); + + // Add necessary tags for stdout and stderr from the command. + let mut child = command + .stdout(Stdio::piped()) + .stderr(Stdio::piped()) + .spawn() + .context("failed to spawn command")?; + let stdout = BufReader::new(child.stdout.take().unwrap()); + let stderr = BufReader::new(child.stderr.take().unwrap()); + + // Add prefix to the output of the process depending on the context. + let msg = match docker { + true => "[sp1] [docker] ", + false => "[sp1] ", + }; + + // Pipe stdout and stderr to the parent process with [docker] prefix + let stdout_handle = thread::spawn(move || { + stdout.lines().for_each(|line| { + println!("{} {}", msg, line.unwrap()); + }); + }); + stderr.lines().for_each(|line| { + eprintln!("{} {}", msg, line.unwrap()); + }); + stdout_handle.join().unwrap(); + + // Wait for the child process to finish and check the result. + let result = child.wait()?; + if !result.success() { + // Error message is already printed by cargo. + exit(result.code().unwrap_or(1)) + } + Ok(()) +} + +/// Copy the ELF to the specified output directory. +fn copy_elf_to_output_dir( + args: &BuildArgs, + program_metadata: &cargo_metadata::Metadata, +) -> Result { + let root_package = program_metadata.root_package(); + let root_package_name = root_package.as_ref().map(|p| &p.name); + + // The ELF is written to a target folder specified by the program's package. + let original_elf_path = program_metadata + .target_directory + .join(HELPER_TARGET_SUBDIR) + .join(BUILD_TARGET) + .join("release") + .join(root_package_name.unwrap()); + + // The order of precedence for the ELF name is: + // 1. --elf_name flag + // 2. --binary flag + -elf suffix (defaults to riscv32im-succinct-zkvm-elf) + let elf_name = if !args.elf_name.is_empty() { + args.elf_name.clone() + } else if !args.binary.is_empty() { + // TODO: In the future, change this to default to the package name. Will require updating + // docs and examples. + args.binary.clone() + } else { + BUILD_TARGET.to_string() + }; + + let elf_dir = program_metadata + .target_directory + .parent() + .unwrap() + .join(&args.output_directory); + fs::create_dir_all(&elf_dir)?; + let result_elf_path = elf_dir.join(elf_name); + + // Copy the ELF to the specified output directory. + fs::copy(original_elf_path, &result_elf_path)?; + + Ok(result_elf_path) +} + +/// Build a program with the specified [`BuildArgs`]. The `program_dir` is specified as an argument when +/// the program is built via `build_program` in sp1-helper. +/// +/// # Arguments +/// +/// * `args` - A reference to a `BuildArgs` struct that holds various arguments used for building the program. +/// * `program_dir` - An optional `PathBuf` specifying the directory of the program to be built. +/// +/// # Returns +/// +/// * `Result` - The path to the built program as a `Utf8PathBuf` on success, or an error on failure. +pub fn build_program(args: &BuildArgs, program_dir: Option) -> Result { + // If the program directory is not specified, use the current directory. + let program_dir = program_dir + .unwrap_or_else(|| std::env::current_dir().expect("Failed to get current directory.")); + let program_dir: Utf8PathBuf = program_dir + .try_into() + .expect("Failed to convert PathBuf to Utf8PathBuf"); + + // The root package name corresponds to the package name of the current directory. + let metadata_cmd = cargo_metadata::MetadataCommand::new(); + let metadata = metadata_cmd.exec().unwrap(); + + // Get the command corresponding to Docker or local build. + let cmd = if args.docker { + docker::create_docker_command(args, &program_dir, &metadata.workspace_root)? + } else { + create_local_command(args, &program_dir) + }; + + let program_metadata_file = program_dir.join("Cargo.toml"); + let mut program_metadata_cmd = cargo_metadata::MetadataCommand::new(); + let program_metadata = program_metadata_cmd + .manifest_path(program_metadata_file) + .exec() + .unwrap(); + + execute_command(cmd, args.docker, &program_metadata)?; + + copy_elf_to_output_dir(args, &program_metadata) +} diff --git a/cli/CHANGELOG.md b/cli/CHANGELOG.md new file mode 100644 index 0000000000..56fce9e191 --- /dev/null +++ b/cli/CHANGELOG.md @@ -0,0 +1,109 @@ +# Changelog + +All notable changes to this project will be documented in this file. + +The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/), +and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html). + +## [Unreleased] + +## [1.0.0-rc.1](https://github.com/succinctlabs/sp1/compare/sp1-cli-v1.0.0-rc.1...sp1-cli-v1.0.0-rc.1) - 2024-07-19 + +### Added + +- Add `BuildArgs` to `build_program` ([#995](https://github.com/succinctlabs/sp1/pull/995)) +- publish sp1 to crates.io ([#1052](https://github.com/succinctlabs/sp1/pull/1052)) +- _(cli)_ use GH token during installation to avoid rate limiting ([#1031](https://github.com/succinctlabs/sp1/pull/1031)) +- _(cli)_ build --docker accepts an optional image tag ([#1022](https://github.com/succinctlabs/sp1/pull/1022)) +- _(cli)_ allow template version and fix CI ([#1012](https://github.com/succinctlabs/sp1/pull/1012)) +- _(cli)_ check for rust usage during installation ([#1006](https://github.com/succinctlabs/sp1/pull/1006)) +- _(cli)_ only template contracts when --evm is used ([#1004](https://github.com/succinctlabs/sp1/pull/1004)) +- (breaking changes to SDK API) use builder pattern for SDK execute/prove/verify ([#940](https://github.com/succinctlabs/sp1/pull/940)) +- cargo prove new from sp1-project-template ([#922](https://github.com/succinctlabs/sp1/pull/922)) +- update docs + add some tests around solidity contract export ([#693](https://github.com/succinctlabs/sp1/pull/693)) +- e2e groth16 with contract verifier ([#671](https://github.com/succinctlabs/sp1/pull/671)) +- aggregation fixes ([#649](https://github.com/succinctlabs/sp1/pull/649)) +- _(sdk)_ auto setup circuit ([#635](https://github.com/succinctlabs/sp1/pull/635)) +- fix cargo prove new issues ([#542](https://github.com/succinctlabs/sp1/pull/542)) +- added `--ignore-rust-version` to `cargo prove build` ([#462](https://github.com/succinctlabs/sp1/pull/462)) +- sdk using secp256k1 auth ([#483](https://github.com/succinctlabs/sp1/pull/483)) +- sp1-sdk, remote prover ([#370](https://github.com/succinctlabs/sp1/pull/370)) +- Many small features and chores ([#347](https://github.com/succinctlabs/sp1/pull/347)) +- add instructions for docker usage and setup CI ([#346](https://github.com/succinctlabs/sp1/pull/346)) +- _(cli)_ static toolchain + install from releases ([#300](https://github.com/succinctlabs/sp1/pull/300)) +- add gitignore in project creation ([#266](https://github.com/succinctlabs/sp1/pull/266)) +- _(cli)_ reproducible docker builds ([#254](https://github.com/succinctlabs/sp1/pull/254)) +- new README img ([#226](https://github.com/succinctlabs/sp1/pull/226)) +- _(cli)_ binary file or hex string input ([#210](https://github.com/succinctlabs/sp1/pull/210)) +- readme updates ([#205](https://github.com/succinctlabs/sp1/pull/205)) +- release v0.0.1-alpha ([#200](https://github.com/succinctlabs/sp1/pull/200)) +- upgrade toolchain to rust 1.75 ([#193](https://github.com/succinctlabs/sp1/pull/193)) +- more final touches ([#194](https://github.com/succinctlabs/sp1/pull/194)) +- hash function config in prover and verifier ([#186](https://github.com/succinctlabs/sp1/pull/186)) +- curtaup + release system + cargo prove CLI updates ([#178](https://github.com/succinctlabs/sp1/pull/178)) +- dynamic prover / verifier chips + proof size benchmarking ([#176](https://github.com/succinctlabs/sp1/pull/176)) +- (perf) updates from Plonky3 and verifier refactor ([#156](https://github.com/succinctlabs/sp1/pull/156)) +- developer experience improvements ([#145](https://github.com/succinctlabs/sp1/pull/145)) +- toolchain build from source & install ([#113](https://github.com/succinctlabs/sp1/pull/113)) +- io::read io::write ([#126](https://github.com/succinctlabs/sp1/pull/126)) +- tracing, profiling, benchmarking ([#99](https://github.com/succinctlabs/sp1/pull/99)) +- fix all cargo tests + add ci + rename curta to succinct ([#97](https://github.com/succinctlabs/sp1/pull/97)) +- tendermint example + runtime optimizations ([#93](https://github.com/succinctlabs/sp1/pull/93)) +- ssz withdrawals example ([#81](https://github.com/succinctlabs/sp1/pull/81)) +- simple benchmarks ([#72](https://github.com/succinctlabs/sp1/pull/72)) +- cargo prove + examples ([#67](https://github.com/succinctlabs/sp1/pull/67)) + +### Fixed + +- assets branch ([#752](https://github.com/succinctlabs/sp1/pull/752)) +- _(ci)_ downgrade `getrandom` ([#751](https://github.com/succinctlabs/sp1/pull/751)) +- install toolchain ([#650](https://github.com/succinctlabs/sp1/pull/650)) +- moving into toolchain dir ([#646](https://github.com/succinctlabs/sp1/pull/646)) +- sp1up ([#643](https://github.com/succinctlabs/sp1/pull/643)) +- outdated templates ([#473](https://github.com/succinctlabs/sp1/pull/473)) +- _(cli)_ get-target ([#270](https://github.com/succinctlabs/sp1/pull/270)) +- edit fibonacci example to use `u128` and note overflow case in quickstart ([#245](https://github.com/succinctlabs/sp1/pull/245)) + +### Other + +- _(deps)_ bump clap from 4.5.8 to 4.5.9 ([#1107](https://github.com/succinctlabs/sp1/pull/1107)) +- use global workspace version ([#1102](https://github.com/succinctlabs/sp1/pull/1102)) +- fix release-plz ([#1088](https://github.com/succinctlabs/sp1/pull/1088)) +- add release-plz ([#1086](https://github.com/succinctlabs/sp1/pull/1086)) +- _(deps)_ bump target-lexicon from 0.12.14 to 0.12.15 ([#1067](https://github.com/succinctlabs/sp1/pull/1067)) +- get docker url +- hm +- better build +- small fixes +- _(cli)_ informative logging ([#947](https://github.com/succinctlabs/sp1/pull/947)) +- Merge branch 'dev' into dependabot/cargo/dev/clap-4.5.8 +- _(deps)_ bump serde_json from 1.0.117 to 1.0.120 +- get rid of json convert to bin + add proof roundtrip to examples ([#924](https://github.com/succinctlabs/sp1/pull/924)) +- x86 mac also works +- failure on sp1 on unsupported target +- _(deps)_ bump clap from 4.5.4 to 4.5.7 ([#908](https://github.com/succinctlabs/sp1/pull/908)) +- _(deps)_ bump ubuntu from `3f85b7c` to `e3f92ab` in /cli/docker +- simplify quickstart ([#819](https://github.com/succinctlabs/sp1/pull/819)) +- remove unused deps ([#794](https://github.com/succinctlabs/sp1/pull/794)) +- Clean up TOML files ([#796](https://github.com/succinctlabs/sp1/pull/796)) +- update dev with latest main ([#728](https://github.com/succinctlabs/sp1/pull/728)) +- _(deps)_ bump dirs from 4.0.0 to 5.0.1 +- update all dependencies ([#689](https://github.com/succinctlabs/sp1/pull/689)) +- sdk improvements ([#580](https://github.com/succinctlabs/sp1/pull/580)) +- fixing dep tree for `prover`, `recursion`, `core` and `sdk` ([#545](https://github.com/succinctlabs/sp1/pull/545)) +- re-organise cpu air constraints ([#538](https://github.com/succinctlabs/sp1/pull/538)) +- better error messages on build-toolchain failure ([#490](https://github.com/succinctlabs/sp1/pull/490)) +- Typo in 'successfully' corrected across all instances ([#396](https://github.com/succinctlabs/sp1/pull/396)) +- remove manual openSSL installation in Dockerfile ([#352](https://github.com/succinctlabs/sp1/pull/352)) +- introduce a union type for `opcode_specific_columns` ([#310](https://github.com/succinctlabs/sp1/pull/310)) +- refactor air in keccak to not use `offset_of` ([#308](https://github.com/succinctlabs/sp1/pull/308)) +- mul trace gen ([#306](https://github.com/succinctlabs/sp1/pull/306)) +- clippy ([#255](https://github.com/succinctlabs/sp1/pull/255)) +- final touches for public release ([#239](https://github.com/succinctlabs/sp1/pull/239)) +- update docs with slight nits ([#224](https://github.com/succinctlabs/sp1/pull/224)) +- sp1 rename ([#212](https://github.com/succinctlabs/sp1/pull/212)) +- enshrine AlignedBorrow macro ([#209](https://github.com/succinctlabs/sp1/pull/209)) +- readme cleanup ([#196](https://github.com/succinctlabs/sp1/pull/196)) +- rename succinct to curta ([#192](https://github.com/succinctlabs/sp1/pull/192)) +- better curta graphic ([#184](https://github.com/succinctlabs/sp1/pull/184)) +- Initial commit diff --git a/cli/Cargo.toml b/cli/Cargo.toml index 12583a5141..6068e0a1bd 100644 --- a/cli/Cargo.toml +++ b/cli/Cargo.toml @@ -1,7 +1,13 @@ [package] name = "sp1-cli" -version = "0.1.0" -edition = "2021" +description = "SP1 is a performant, 100% open-source, contributor-friendly zkVM." +readme = "../README.md" +version = { workspace = true } +edition = { workspace = true } +license = { workspace = true } +repository = { workspace = true } +keywords = { workspace = true } +categories = { workspace = true } [build-dependencies] vergen = { version = "8", default-features = false, features = [ @@ -11,12 +17,14 @@ vergen = { version = "8", default-features = false, features = [ ] } [dependencies] + anyhow = { version = "1.0.83", features = ["backtrace"] } cargo_metadata = "0.18.1" -clap = { version = "4.5.7", features = ["derive", "env"] } -sp1-prover = { path = "../prover" } -sp1-sdk = { path = "../sdk" } -sp1-core = { path = "../core" } +clap = { version = "4.5.9", features = ["derive", "env"] } +sp1-build = { workspace = true } +sp1-prover = { workspace = true } +sp1-sdk = { workspace = true } +sp1-core = { workspace = true } reqwest = { version = "0.12.4", features = [ "stream", "json", @@ -31,9 +39,9 @@ rand = "0.8" downloader = { version = "0.2", default-features = false, features = [ "rustls-tls", ] } -serde_json = "1.0.117" +serde_json = "1.0.120" yansi = "1.0.1" hex = "0.4.3" anstyle = "1.0.7" -target-lexicon = "0.12.14" +target-lexicon = "0.12.15" tempfile = "3.10.1" diff --git a/cli/src/build.rs b/cli/src/build.rs deleted file mode 100644 index 499a0b3b8a..0000000000 --- a/cli/src/build.rs +++ /dev/null @@ -1,127 +0,0 @@ -use anyhow::{Context, Result}; -use cargo_metadata::camino::Utf8PathBuf; -use clap::Parser; -use std::{ - fs, - io::{BufRead, BufReader}, - process::{exit, Command, Stdio}, - thread, -}; - -fn get_docker_image() -> String { - // Get the docker image name from the environment variable - std::env::var("SP1_DOCKER_IMAGE") - .unwrap_or_else(|_| "ghcr.io/succinctlabs/sp1:latest".to_string()) -} - -#[derive(Parser)] -pub(crate) struct BuildArgs { - #[clap(long, action, help = "Ignore Rust version check.")] - pub(crate) docker: bool, - #[clap(long, action, help = "Ignore Rust version check.")] - pub(crate) ignore_rust_version: bool, -} - -pub fn build_program(args: &BuildArgs) -> Result { - let metadata_cmd = cargo_metadata::MetadataCommand::new(); - let metadata = metadata_cmd.exec().unwrap(); - let root_package = metadata.root_package(); - let root_package_name = root_package.as_ref().map(|p| &p.name); - - let build_target = "riscv32im-succinct-zkvm-elf"; - if args.docker { - let image = get_docker_image(); - - let docker_check = Command::new("docker") - .args(["info"]) - .stdout(Stdio::null()) - .stderr(Stdio::null()) - .status() - .context("failed to run docker command")?; - - if !docker_check.success() { - eprintln!("Docker is not installed or not running."); - exit(1); - } - - let workspace_root_path = format!("{}:/root/program", metadata.workspace_root); - let mut child_args = vec![ - "run", - "--rm", - "-v", - workspace_root_path.as_str(), - image.as_str(), - "prove", - "build", - ]; - if args.ignore_rust_version { - child_args.push("--ignore-rust-version"); - } - - let mut child = Command::new("docker") - .args(&child_args) - .stdout(Stdio::piped()) - .stderr(Stdio::piped()) - .spawn() - .context("failed to spawn command")?; - - let stdout = BufReader::new(child.stdout.take().unwrap()); - let stderr = BufReader::new(child.stderr.take().unwrap()); - - // Pipe stdout and stderr to the parent process with [docker] prefix - let stdout_handle = thread::spawn(move || { - stdout.lines().for_each(|line| { - println!("[docker] {}", line.unwrap()); - }); - }); - stderr.lines().for_each(|line| { - eprintln!("[docker] {}", line.unwrap()); - }); - - stdout_handle.join().unwrap(); - - let result = child.wait()?; - if !result.success() { - // Error message is already printed by cargo - exit(result.code().unwrap_or(1)) - } - } else { - let rust_flags = [ - "-C", - "passes=loweratomic", - "-C", - "link-arg=-Ttext=0x00200800", - "-C", - "panic=abort", - ]; - - let mut cargo_args = vec!["build", "--release", "--target", build_target, "--locked"]; - if args.ignore_rust_version { - cargo_args.push("--ignore-rust-version"); - } - - let result = Command::new("cargo") - .env("RUSTUP_TOOLCHAIN", "succinct") - .env("CARGO_ENCODED_RUSTFLAGS", rust_flags.join("\x1f")) - .args(&cargo_args) - .status() - .context("Failed to run cargo command.")?; - - if !result.success() { - // Error message is already printed by cargo - exit(result.code().unwrap_or(1)) - } - } - - let elf_path = metadata - .target_directory - .join(build_target) - .join("release") - .join(root_package_name.unwrap()); - let elf_dir = metadata.target_directory.parent().unwrap().join("elf"); - fs::create_dir_all(&elf_dir)?; - let result_elf_path = elf_dir.join("riscv32im-succinct-zkvm-elf"); - fs::copy(elf_path, &result_elf_path)?; - - Ok(result_elf_path) -} diff --git a/cli/src/commands/build.rs b/cli/src/commands/build.rs index 72e62693b1..51d8d1b64b 100644 --- a/cli/src/commands/build.rs +++ b/cli/src/commands/build.rs @@ -1,6 +1,6 @@ -use crate::build::{build_program, BuildArgs}; use anyhow::Result; use clap::Parser; +use sp1_build::{build_program, BuildArgs}; #[derive(Parser)] #[command(name = "build", about = "Build a program")] @@ -14,7 +14,7 @@ pub struct BuildCmd { impl BuildCmd { pub fn run(&self) -> Result<()> { - build_program(&self.build_args)?; + build_program(&self.build_args, None)?; Ok(()) } diff --git a/cli/src/commands/install_toolchain.rs b/cli/src/commands/install_toolchain.rs index b795e33ab1..6daaab5500 100644 --- a/cli/src/commands/install_toolchain.rs +++ b/cli/src/commands/install_toolchain.rs @@ -20,12 +20,43 @@ use crate::{ name = "install-toolchain", about = "Install the cargo-prove toolchain." )] -pub struct InstallToolchainCmd {} +pub struct InstallToolchainCmd { + #[arg(short, long, env = "GITHUB_TOKEN")] + pub token: Option, +} impl InstallToolchainCmd { pub fn run(&self) -> Result<()> { - // Setup client. - let client = Client::builder().user_agent("Mozilla/5.0").build()?; + // Check if rust is installed. + if Command::new("rustup") + .arg("--version") + .stdout(std::process::Stdio::null()) + .stderr(std::process::Stdio::null()) + .status() + .is_err() + { + return Err(anyhow::anyhow!( + "Rust is not installed. Please install Rust from https://rustup.rs/ and try again." + )); + } + + // Setup client with optional token. + let client_builder = Client::builder().user_agent("Mozilla/5.0"); + let client = if let Some(ref token) = self.token { + client_builder + .default_headers({ + let mut headers = reqwest::header::HeaderMap::new(); + headers.insert( + reqwest::header::AUTHORIZATION, + reqwest::header::HeaderValue::from_str(&format!("token {}", token)) + .unwrap(), + ); + headers + }) + .build()? + } else { + client_builder.build()? + }; // Setup variables. let root_dir = home_dir().unwrap().join(".sp1"); diff --git a/cli/src/commands/new.rs b/cli/src/commands/new.rs index ae61d55866..86798be083 100644 --- a/cli/src/commands/new.rs +++ b/cli/src/commands/new.rs @@ -6,7 +6,16 @@ use yansi::Paint; #[derive(Parser)] #[command(name = "new", about = "Setup a new project that runs inside the SP1.")] pub struct NewCmd { + /// The name of the project. name: String, + + /// Whether to create the project with template EVM contracts. + #[arg(long, action)] + evm: bool, + + /// Version of sp1-project-template to use (branch or tag). + #[arg(long, default_value = "main")] + version: String, } const TEMPLATE_REPOSITORY_URL: &str = "https://github.com/succinctlabs/sp1-project-template"; @@ -20,9 +29,11 @@ impl NewCmd { fs::create_dir(&self.name)?; } - // Clone the repository. + // Clone the repository with the specified version. let output = Command::new("git") .arg("clone") + .arg("--branch") + .arg(&self.version) .arg(TEMPLATE_REPOSITORY_URL) .arg(root.as_os_str()) .arg("--recurse-submodules") @@ -37,12 +48,20 @@ impl NewCmd { // Remove the .git directory. fs::remove_dir_all(root.join(".git"))?; - // Check if the user has `foundry` installed. - if Command::new("foundry").arg("--version").output().is_err() { - println!( - " \x1b[1m{}\x1b[0m Make sure to install Foundry to use contracts: https://book.getfoundry.sh/getting-started/installation.", + if self.evm { + // Check if the user has `foundry` installed. + if Command::new("foundry").arg("--version").output().is_err() { + println!( + " \x1b[1m{}\x1b[0m Make sure to install Foundry to use contracts: https://book.getfoundry.sh/getting-started/installation", Paint::yellow("Warning:"), ); + } + } else { + // Remove the `contracts` directory. + fs::remove_dir_all(root.join("contracts"))?; + + // Remove the `.gitmodules` file. + fs::remove_file(root.join(".gitmodules"))?; } println!( diff --git a/cli/src/commands/prove.rs b/cli/src/commands/prove.rs index aedc7284f9..72eea0b5ee 100644 --- a/cli/src/commands/prove.rs +++ b/cli/src/commands/prove.rs @@ -1,16 +1,14 @@ use anstyle::*; use anyhow::Result; use clap::Parser; +use sp1_build::{build_program, BuildArgs}; use sp1_core::utils::{setup_logger, setup_tracer}; use sp1_prover::SP1Stdin; use sp1_sdk::ProverClient; use std::time::Instant; use std::{env, fs::File, io::Read, path::PathBuf, str::FromStr}; -use crate::{ - build::{build_program, BuildArgs}, - util::{elapsed, write_status}, -}; +use crate::util::{elapsed, write_status}; #[derive(Debug, Clone)] enum Input { @@ -75,7 +73,7 @@ pub struct ProveCmd { impl ProveCmd { pub fn run(&self) -> Result<()> { - let elf_path = build_program(&self.build_args)?; + let elf_path = build_program(&self.build_args, None)?; if !self.profile { match env::var("RUST_LOG") { @@ -115,7 +113,7 @@ impl ProveCmd { let start_time = Instant::now(); let client = ProverClient::new(); let (pk, _) = client.setup(&elf); - let proof = client.prove(&pk, stdin).unwrap(); + let proof = client.prove(&pk, stdin).run().unwrap(); if let Some(ref path) = self.output { proof diff --git a/cli/src/lib.rs b/cli/src/lib.rs index 1ad6fbacee..654f7fab93 100644 --- a/cli/src/lib.rs +++ b/cli/src/lib.rs @@ -1,4 +1,3 @@ -mod build; pub mod commands; mod util; @@ -69,7 +68,7 @@ pub async fn get_toolchain_download_url(client: &Client, target: String) -> Stri .json::() .await .unwrap(); - let tag = json["tag_name"].as_str().unwrap(); + let tag = json["tag_name"].as_str().expect("Failed to download Succinct toolchain. Likely caused by GitHub rate limiting. Please try again using the --token flag. Docs: https://docs.succinct.xyz/getting-started/install.html#troubleshooting"); let url = format!( "https://github.com/succinctlabs/rust/releases/download/{}/rust-toolchain-{}.tar.gz", diff --git a/core/CHANGELOG.md b/core/CHANGELOG.md new file mode 100644 index 0000000000..327e04d5ff --- /dev/null +++ b/core/CHANGELOG.md @@ -0,0 +1,445 @@ +# Changelog + +All notable changes to this project will be documented in this file. + +The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/), +and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html). + +## [Unreleased] + +## [1.0.0-rc.1](https://github.com/succinctlabs/sp1/compare/sp1-core-v1.0.0-rc.1...sp1-core-v1.0.0-rc.1) - 2024-07-19 + +### Added + +- 1.0.0-rc.1 ([#1126](https://github.com/succinctlabs/sp1/pull/1126)) +- multi-threaded tracing ([#1124](https://github.com/succinctlabs/sp1/pull/1124)) +- parallel recursion tracegen ([#1095](https://github.com/succinctlabs/sp1/pull/1095)) +- publish sp1 to crates.io ([#1052](https://github.com/succinctlabs/sp1/pull/1052)) +- critical constraint changes ([#1046](https://github.com/succinctlabs/sp1/pull/1046)) +- cycle limit ([#1027](https://github.com/succinctlabs/sp1/pull/1027)) +- suggest prover network if high cycles ([#1019](https://github.com/succinctlabs/sp1/pull/1019)) +- put hook results in the front of the input stream ([#973](https://github.com/succinctlabs/sp1/pull/973)) +- poseidon2 hash ([#885](https://github.com/succinctlabs/sp1/pull/885)) +- optimize byte trace gen +- optimize cpu tracegen ([#949](https://github.com/succinctlabs/sp1/pull/949)) +- (breaking changes to SDK API) use builder pattern for SDK execute/prove/verify ([#940](https://github.com/succinctlabs/sp1/pull/940)) +- circuit version in proof ([#926](https://github.com/succinctlabs/sp1/pull/926)) +- verify subproof in runtime ([#911](https://github.com/succinctlabs/sp1/pull/911)) +- sp1 circuit version ([#899](https://github.com/succinctlabs/sp1/pull/899)) +- log info from `ExecutionReport` in `prove` ([#896](https://github.com/succinctlabs/sp1/pull/896)) +- use docker by default for gnark ([#890](https://github.com/succinctlabs/sp1/pull/890)) +- info spans for prover execute instances ([#893](https://github.com/succinctlabs/sp1/pull/893)) +- generic const expr ([#854](https://github.com/succinctlabs/sp1/pull/854)) +- execute() exposes ExecutionReport ([#847](https://github.com/succinctlabs/sp1/pull/847)) +- runtime instruction/syscall report ([#839](https://github.com/succinctlabs/sp1/pull/839)) +- sp1 core prover opts +- plonk prover ([#795](https://github.com/succinctlabs/sp1/pull/795)) +- byte multiplicity channel ([#800](https://github.com/succinctlabs/sp1/pull/800)) +- exit code ([#750](https://github.com/succinctlabs/sp1/pull/750)) +- _(recursion)_ public values constraints ([#748](https://github.com/succinctlabs/sp1/pull/748)) +- add proof verification ([#729](https://github.com/succinctlabs/sp1/pull/729)) +- add `hash_public_values` ([#730](https://github.com/succinctlabs/sp1/pull/730)) +- reduce network prover ([#687](https://github.com/succinctlabs/sp1/pull/687)) +- fix execution + proving errors ([#715](https://github.com/succinctlabs/sp1/pull/715)) +- activate `cycle-tracker` with `RUST_LOG=info` ([#707](https://github.com/succinctlabs/sp1/pull/707)) +- ci refactor ([#684](https://github.com/succinctlabs/sp1/pull/684)) +- program refactor ([#651](https://github.com/succinctlabs/sp1/pull/651)) +- e2e groth16 with contract verifier ([#671](https://github.com/succinctlabs/sp1/pull/671)) +- `mulmod` uint256 precompile ([#642](https://github.com/succinctlabs/sp1/pull/642)) +- nextgen ci for sp1-prover ([#663](https://github.com/succinctlabs/sp1/pull/663)) +- Adding docs for new `ProverClient` and `groth16` and `compressed` mode ([#627](https://github.com/succinctlabs/sp1/pull/627)) +- aggregation fixes ([#649](https://github.com/succinctlabs/sp1/pull/649)) +- improve circuit by 3-4x ([#648](https://github.com/succinctlabs/sp1/pull/648)) +- _(recursion)_ poseidon2 max constraint degree const generic ([#634](https://github.com/succinctlabs/sp1/pull/634)) +- regularize proof shape ([#641](https://github.com/succinctlabs/sp1/pull/641)) +- shard chunking multiplier ([#633](https://github.com/succinctlabs/sp1/pull/633)) +- prover tweaks pt4 ([#632](https://github.com/succinctlabs/sp1/pull/632)) +- _(recursion)_ cpu branch constraints ([#578](https://github.com/succinctlabs/sp1/pull/578)) +- prover tweaks ([#603](https://github.com/succinctlabs/sp1/pull/603)) +- _(recursion)_ memory access timestamp constraints ([#589](https://github.com/succinctlabs/sp1/pull/589)) +- enable arbitrary constraint degree ([#593](https://github.com/succinctlabs/sp1/pull/593)) +- recursion compress layer + RecursionAirWideDeg3 + RecursionAirSkinnyDeg7 + optimized groth16 ([#590](https://github.com/succinctlabs/sp1/pull/590)) +- fixing memory interactions ([#587](https://github.com/succinctlabs/sp1/pull/587)) +- _(Recursion)_ evaluate constraints in a single expression ([#592](https://github.com/succinctlabs/sp1/pull/592)) +- _(recursion)_ memory builder + fri-fold precompile ([#581](https://github.com/succinctlabs/sp1/pull/581)) +- complete reduce program ([#565](https://github.com/succinctlabs/sp1/pull/565)) +- public inputs in gnark circuit ([#576](https://github.com/succinctlabs/sp1/pull/576)) +- _(recursion)_ cpu alu constraints ([#570](https://github.com/succinctlabs/sp1/pull/570)) +- _(recursion)_ recursion air builder ([#574](https://github.com/succinctlabs/sp1/pull/574)) +- a few simplifications to the Keccak AIR ([#568](https://github.com/succinctlabs/sp1/pull/568)) +- alu cpu columns ([#562](https://github.com/succinctlabs/sp1/pull/562)) +- stark cleanup and verification ([#556](https://github.com/succinctlabs/sp1/pull/556)) +- add range checks to field and new LT table ([#529](https://github.com/succinctlabs/sp1/pull/529)) +- fix cargo prove new issues ([#542](https://github.com/succinctlabs/sp1/pull/542)) +- feat(precompile) bls12-381 add and double precompile ([#448](https://github.com/succinctlabs/sp1/pull/448)) +- _(precompile)_ add biguint arithmetic precompiles ([#378](https://github.com/succinctlabs/sp1/pull/378)) +- verify shard transitions + fixes ([#482](https://github.com/succinctlabs/sp1/pull/482)) +- weierstrass decompress precompile ([#440](https://github.com/succinctlabs/sp1/pull/440)) +- preprocess memory program chip ([#480](https://github.com/succinctlabs/sp1/pull/480)) +- nested sp1 proof verification ([#494](https://github.com/succinctlabs/sp1/pull/494)) +- verify pc and shard transition in recursive proofs ([#514](https://github.com/succinctlabs/sp1/pull/514)) +- recursion profiling ([#521](https://github.com/succinctlabs/sp1/pull/521)) +- small permutation trace gen perf opt ([#517](https://github.com/succinctlabs/sp1/pull/517)) +- update to latest p3 ([#515](https://github.com/succinctlabs/sp1/pull/515)) +- reduce with different configs ([#508](https://github.com/succinctlabs/sp1/pull/508)) +- sdk using secp256k1 auth ([#483](https://github.com/succinctlabs/sp1/pull/483)) +- logup batching ([#487](https://github.com/succinctlabs/sp1/pull/487)) +- recursion vm public values ([#495](https://github.com/succinctlabs/sp1/pull/495)) +- shard transition public values ([#466](https://github.com/succinctlabs/sp1/pull/466)) +- recursion permutation challenges as variables ([#486](https://github.com/succinctlabs/sp1/pull/486)) +- add support for witness in programs ([#476](https://github.com/succinctlabs/sp1/pull/476)) +- setup recursion prover crate ([#475](https://github.com/succinctlabs/sp1/pull/475)) +- gnark recursive verifier ([#457](https://github.com/succinctlabs/sp1/pull/457)) +- add shard to byte and program table ([#463](https://github.com/succinctlabs/sp1/pull/463)) +- recursion cpu constraints ([#464](https://github.com/succinctlabs/sp1/pull/464)) +- public values ([#455](https://github.com/succinctlabs/sp1/pull/455)) +- Preprocessing + recursion ([#450](https://github.com/succinctlabs/sp1/pull/450)) +- one cycle input ([#451](https://github.com/succinctlabs/sp1/pull/451)) +- sp1-sdk, remote prover ([#370](https://github.com/succinctlabs/sp1/pull/370)) +- _(precompile)_ add bn254 precompile ([#384](https://github.com/succinctlabs/sp1/pull/384)) +- constrain EnterUnconstrained syscall ([#449](https://github.com/succinctlabs/sp1/pull/449)) +- verify shard ([#444](https://github.com/succinctlabs/sp1/pull/444)) +- working two adic pcs verifier in recursive zkvm ([#434](https://github.com/succinctlabs/sp1/pull/434)) +- plonky3 update ([#428](https://github.com/succinctlabs/sp1/pull/428)) +- poseidon2 permute ([#423](https://github.com/succinctlabs/sp1/pull/423)) +- cpu chip clk constraints ([#420](https://github.com/succinctlabs/sp1/pull/420)) +- verify constraints ([#409](https://github.com/succinctlabs/sp1/pull/409)) +- Connect CPU to ECALL tables ([#364](https://github.com/succinctlabs/sp1/pull/364)) +- poseidon2 air ([#397](https://github.com/succinctlabs/sp1/pull/397)) +- checkpoint runtime for constant memory usage ([#389](https://github.com/succinctlabs/sp1/pull/389)) +- update to the latest plonky3 version ([#398](https://github.com/succinctlabs/sp1/pull/398)) +- verify constraints in DSL + basic verifier setup ([#395](https://github.com/succinctlabs/sp1/pull/395)) +- array and symbolic evaluation ([#390](https://github.com/succinctlabs/sp1/pull/390)) +- core recursion air constraints ([#359](https://github.com/succinctlabs/sp1/pull/359)) +- initial recursion core ([#354](https://github.com/succinctlabs/sp1/pull/354)) +- serializable execution record ([#328](https://github.com/succinctlabs/sp1/pull/328)) +- Many small features and chores ([#347](https://github.com/succinctlabs/sp1/pull/347)) +- keccak + weierstrass trace gen opt ([#335](https://github.com/succinctlabs/sp1/pull/335)) +- use u32 based hasher for BabybearBlake3 ([#327](https://github.com/succinctlabs/sp1/pull/327)) +- update to new Merkle tree API ([#301](https://github.com/succinctlabs/sp1/pull/301)) +- prover memory optimizations ([#294](https://github.com/succinctlabs/sp1/pull/294)) +- trace for cycle tracker ([#163](https://github.com/succinctlabs/sp1/pull/163)) +- derive `MachineAir`, chip and machine cleanup ([#278](https://github.com/succinctlabs/sp1/pull/278)) +- new README img ([#226](https://github.com/succinctlabs/sp1/pull/226)) +- Allow deserialization of `StarkGenericConfig`s ([#218](https://github.com/succinctlabs/sp1/pull/218)) +- new trace generation api ([#208](https://github.com/succinctlabs/sp1/pull/208)) +- Make proof types deserializable ([#211](https://github.com/succinctlabs/sp1/pull/211)) +- readme updates ([#205](https://github.com/succinctlabs/sp1/pull/205)) +- preprocessing api, cleanup, and testing ([#195](https://github.com/succinctlabs/sp1/pull/195)) +- release v0.0.1-alpha ([#200](https://github.com/succinctlabs/sp1/pull/200)) +- upgrade toolchain to rust 1.75 ([#193](https://github.com/succinctlabs/sp1/pull/193)) +- more final touches ([#194](https://github.com/succinctlabs/sp1/pull/194)) +- Blake3 compress precompile ([#180](https://github.com/succinctlabs/sp1/pull/180)) +- tendermint optimizations ([#188](https://github.com/succinctlabs/sp1/pull/188)) +- hash function config in prover and verifier ([#186](https://github.com/succinctlabs/sp1/pull/186)) +- Stark cleanup ([#179](https://github.com/succinctlabs/sp1/pull/179)) +- curtaup + release system + cargo prove CLI updates ([#178](https://github.com/succinctlabs/sp1/pull/178)) +- dynamic prover / verifier chips + proof size benchmarking ([#176](https://github.com/succinctlabs/sp1/pull/176)) +- (perf) k12 config ([#160](https://github.com/succinctlabs/sp1/pull/160)) +- unconstrained macro + ecrecover fn ([#153](https://github.com/succinctlabs/sp1/pull/153)) +- (perf) updates from Plonky3 and verifier refactor ([#156](https://github.com/succinctlabs/sp1/pull/156)) +- zeth program ([#147](https://github.com/succinctlabs/sp1/pull/147)) +- developer experience improvements ([#145](https://github.com/succinctlabs/sp1/pull/145)) +- k256_decompress precompile ([#143](https://github.com/succinctlabs/sp1/pull/143)) +- Secp256k1 double precompile ([#142](https://github.com/succinctlabs/sp1/pull/142)) +- Secp251k addition precompile ([#137](https://github.com/succinctlabs/sp1/pull/137)) +- Verifier ([#123](https://github.com/succinctlabs/sp1/pull/123)) +- keccak precompile ([#108](https://github.com/succinctlabs/sp1/pull/108)) +- _(perf)_ use poseidon fri ([#132](https://github.com/succinctlabs/sp1/pull/132)) +- enable debug assertions in ci ([#130](https://github.com/succinctlabs/sp1/pull/130)) +- toolchain build from source & install ([#113](https://github.com/succinctlabs/sp1/pull/113)) +- use actions cache for perf regress [perf] ([#128](https://github.com/succinctlabs/sp1/pull/128)) +- ed_decompress precompile ([#114](https://github.com/succinctlabs/sp1/pull/114)) +- io::read io::write ([#126](https://github.com/succinctlabs/sp1/pull/126)) +- performance regression check ([#125](https://github.com/succinctlabs/sp1/pull/125)) +- Ed25519 base field sqrt operation (WIP) ([#122](https://github.com/succinctlabs/sp1/pull/122)) +- ed_add precompile ([#95](https://github.com/succinctlabs/sp1/pull/95)) +- Implement `F_p` division [WIP/Draft] ([#115](https://github.com/succinctlabs/sp1/pull/115)) +- serialize MainData ([#116](https://github.com/succinctlabs/sp1/pull/116)) +- implement `add5` and `or` operations ([#111](https://github.com/succinctlabs/sp1/pull/111)) +- cycle tracker macro and print ([#109](https://github.com/succinctlabs/sp1/pull/109)) +- fix prover work and update plonky3 upstream changes ([#110](https://github.com/succinctlabs/sp1/pull/110)) +- get_cycles helper ([#104](https://github.com/succinctlabs/sp1/pull/104)) +- implement `isEqualWordOperation` and use it in `DivRemChip` ([#103](https://github.com/succinctlabs/sp1/pull/103)) +- Implement `MSB` byte lookup op and use it in ALU tables ([#100](https://github.com/succinctlabs/sp1/pull/100)) +- `IsZero` Operation ([#92](https://github.com/succinctlabs/sp1/pull/92)) +- sha256 compress contraints ([#94](https://github.com/succinctlabs/sp1/pull/94)) +- add4 operations ([#91](https://github.com/succinctlabs/sp1/pull/91)) +- tracing, profiling, benchmarking ([#99](https://github.com/succinctlabs/sp1/pull/99)) +- fix all cargo tests + add ci + rename curta to succinct ([#97](https://github.com/succinctlabs/sp1/pull/97)) +- Implement `and` `not` `xor` operations ([#98](https://github.com/succinctlabs/sp1/pull/98)) +- Fp add, mul, sub, inner_product and den operations, and Edwards add operation ([#68](https://github.com/succinctlabs/sp1/pull/68)) +- Constrain memory related ts/segment values ([#84](https://github.com/succinctlabs/sp1/pull/84)) +- tendermint example + runtime optimizations ([#93](https://github.com/succinctlabs/sp1/pull/93)) +- working prover ([#90](https://github.com/succinctlabs/sp1/pull/90)) +- ssz withdrawals example ([#81](https://github.com/succinctlabs/sp1/pull/81)) +- implement add operations ([#88](https://github.com/succinctlabs/sp1/pull/88)) +- rustcrypto sha256 example ([#82](https://github.com/succinctlabs/sp1/pull/82)) +- cpu memory value constraints ([#74](https://github.com/succinctlabs/sp1/pull/74)) +- print syscall + start of ssz example ([#76](https://github.com/succinctlabs/sp1/pull/76)) +- sha256 syscalls + fix for mul events being in add events ([#75](https://github.com/succinctlabs/sp1/pull/75)) +- simple benchmarks ([#72](https://github.com/succinctlabs/sp1/pull/72)) +- move runtime execution to precompile module ([#71](https://github.com/succinctlabs/sp1/pull/71)) +- Arithmetic & logical right shift (`SRA`, `SRL`) ([#70](https://github.com/succinctlabs/sp1/pull/70)) +- CPU constraints for jump instructions and AIUPC ([#69](https://github.com/succinctlabs/sp1/pull/69)) +- sha compress ([#66](https://github.com/succinctlabs/sp1/pull/66)) +- cpu constraints for branching related op codes ([#58](https://github.com/succinctlabs/sp1/pull/58)) +- sha extend ([#61](https://github.com/succinctlabs/sp1/pull/61)) +- `DIV`, `REM`, `DIVU` and `REMU` ALU table ([#49](https://github.com/succinctlabs/sp1/pull/49)) +- proving with global challenges ([#64](https://github.com/succinctlabs/sp1/pull/64)) +- memory constraints on CPU table ([#56](https://github.com/succinctlabs/sp1/pull/56)) +- bus constraint between cpu and program table ([#50](https://github.com/succinctlabs/sp1/pull/50)) +- `lt` ALU table ([#44](https://github.com/succinctlabs/sp1/pull/44)) +- left shift `SLL` ALU table ([#60](https://github.com/succinctlabs/sp1/pull/60)) +- working malloc, syscalls, elf/program refactor ([#53](https://github.com/succinctlabs/sp1/pull/53)) +- small nits ([#47](https://github.com/succinctlabs/sp1/pull/47)) +- Add all `MUL*` ALU tables ([#45](https://github.com/succinctlabs/sp1/pull/45)) +- disassemble + opcode + instruction refactor ([#43](https://github.com/succinctlabs/sp1/pull/43)) +- `MUL` ALU table ([#41](https://github.com/succinctlabs/sp1/pull/41)) +- Byte lookup table ([#35](https://github.com/succinctlabs/sp1/pull/35)) +- CPU and Memory interactions match ([#29](https://github.com/succinctlabs/sp1/pull/29)) +- cleanup prove method + traits ([#37](https://github.com/succinctlabs/sp1/pull/37)) +- shift table + less table + interactions for all existing tables ([#28](https://github.com/succinctlabs/sp1/pull/28)) +- builder interactions ([#33](https://github.com/succinctlabs/sp1/pull/33)) +- shift/less ([#31](https://github.com/succinctlabs/sp1/pull/31)) +- v3 prover ([#24](https://github.com/succinctlabs/sp1/pull/24)) +- chip interactions ([#26](https://github.com/succinctlabs/sp1/pull/26)) +- end-to-end testing setup including AIR / interaction constraints ([#17](https://github.com/succinctlabs/sp1/pull/17)) +- memory table with proof generation ([#18](https://github.com/succinctlabs/sp1/pull/18)) +- CPU trace pads and proves ([#19](https://github.com/succinctlabs/sp1/pull/19)) +- Parse ELF files ([#7](https://github.com/succinctlabs/sp1/pull/7)) +- v1 prove method + program table ([#15](https://github.com/succinctlabs/sp1/pull/15)) +- working ALU tables for ADD + SUB + AND + XOR + OR minus interactions ([#10](https://github.com/succinctlabs/sp1/pull/10)) +- memory air ([#9](https://github.com/succinctlabs/sp1/pull/9)) +- basic runtime for add +- basic runtime for add +- basic runtime for add +- make imm i32 +- make imm i32 +- v1 of encoding +- v1 of encoding +- v1 of encoding + +### Fixed + +- BLS381 decompress ([#1121](https://github.com/succinctlabs/sp1/pull/1121)) +- global memory assertions ([#1083](https://github.com/succinctlabs/sp1/pull/1083)) +- lookup id collisions ([#1114](https://github.com/succinctlabs/sp1/pull/1114)) +- correct permutation column counts in debug_constraints ([#1080](https://github.com/succinctlabs/sp1/pull/1080)) +- execution shard ([#1070](https://github.com/succinctlabs/sp1/pull/1070)) +- optimize serde for ExecutionState ([#1068](https://github.com/succinctlabs/sp1/pull/1068)) +- uint256 fixes ([#990](https://github.com/succinctlabs/sp1/pull/990)) +- range check halt/commit_deferred_proof operands ([#986](https://github.com/succinctlabs/sp1/pull/986)) +- verifier dos ([#1017](https://github.com/succinctlabs/sp1/pull/1017)) +- verifier dos +- apply plonky3's keccak air fix ([#984](https://github.com/succinctlabs/sp1/pull/984)) +- close unclosed file streams ([#954](https://github.com/succinctlabs/sp1/pull/954)) +- p3 audit change ([#964](https://github.com/succinctlabs/sp1/pull/964)) +- fix crhsi comments +- uint256 div ([#915](https://github.com/succinctlabs/sp1/pull/915)) +- remove mutable requirement ([#892](https://github.com/succinctlabs/sp1/pull/892)) +- set core opts from SHARD\* env vars ([#889](https://github.com/succinctlabs/sp1/pull/889)) +- unit tests to test nonces ([#875](https://github.com/succinctlabs/sp1/pull/875)) +- nonce in ed decompress ([#874](https://github.com/succinctlabs/sp1/pull/874)) +- install for `verify_plonk_bn254` ([#798](https://github.com/succinctlabs/sp1/pull/798)) +- _(core)_ Remove dummy constraint ([#783](https://github.com/succinctlabs/sp1/pull/783)) +- _(core)_ Fix benches warning for unstable features ([#763](https://github.com/succinctlabs/sp1/pull/763)) +- SHA_COMPRESS syscall added to syscall map twice ([#740](https://github.com/succinctlabs/sp1/pull/740)) +- multiply logged permutation column counts by extension field degree. ([#668](https://github.com/succinctlabs/sp1/pull/668)) +- proof aggregation issue ([#683](https://github.com/succinctlabs/sp1/pull/683)) +- verify reduced proofs ([#655](https://github.com/succinctlabs/sp1/pull/655)) +- shard_batch_size prover ([#659](https://github.com/succinctlabs/sp1/pull/659)) +- _(recursion)_ fixes for fri fold and poseidon2 ([#654](https://github.com/succinctlabs/sp1/pull/654)) +- _(core)_ assert_is_base_element fix for highest degree element ([#644](https://github.com/succinctlabs/sp1/pull/644)) +- some SubBuilder tweaks ([#622](https://github.com/succinctlabs/sp1/pull/622)) +- high degree constraints in recursion ([#619](https://github.com/succinctlabs/sp1/pull/619)) +- deferred proofs + cleanup hash_vkey ([#615](https://github.com/succinctlabs/sp1/pull/615)) +- posedion2 config bug ([#612](https://github.com/succinctlabs/sp1/pull/612)) +- update Poseidon2 air to match plonky3 ([#600](https://github.com/succinctlabs/sp1/pull/600)) +- downgrade `strum` ([#585](https://github.com/succinctlabs/sp1/pull/585)) +- verify read access for MemoryReadWriteCols cols in keccak precompile ([#531](https://github.com/succinctlabs/sp1/pull/531)) +- unaccessed hint input + small fixes ([#461](https://github.com/succinctlabs/sp1/pull/461)) +- observe only non-padded public values ([#523](https://github.com/succinctlabs/sp1/pull/523)) +- broken e2e recursion +- don't observe padded public values ([#520](https://github.com/succinctlabs/sp1/pull/520)) +- public inputs in recursion program ([#467](https://github.com/succinctlabs/sp1/pull/467)) +- few regression fixes ([#441](https://github.com/succinctlabs/sp1/pull/441)) +- only use tempfile if necessary ([#436](https://github.com/succinctlabs/sp1/pull/436)) +- don't use tempfile if unneeded ([#419](https://github.com/succinctlabs/sp1/pull/419)) +- silent lwa error ([#385](https://github.com/succinctlabs/sp1/pull/385)) +- non-default feature errors and check during ci ([#345](https://github.com/succinctlabs/sp1/pull/345)) +- BLAKE3 AIR constraint fix for handling multiple invocations ([#336](https://github.com/succinctlabs/sp1/pull/336)) +- S-box in Poseidon2 config ([#329](https://github.com/succinctlabs/sp1/pull/329)) +- ltu bug ([#284](https://github.com/succinctlabs/sp1/pull/284)) +- keccak memory bug ([#283](https://github.com/succinctlabs/sp1/pull/283)) +- verify proof in tests ([#280](https://github.com/succinctlabs/sp1/pull/280)) +- debug deserialization for SP1ProofWithIO. Test. ([#249](https://github.com/succinctlabs/sp1/pull/249)) +- Merkle tree config ([#251](https://github.com/succinctlabs/sp1/pull/251)) +- sha compress ([#252](https://github.com/succinctlabs/sp1/pull/252)) +- perf main bench ci ([#223](https://github.com/succinctlabs/sp1/pull/223)) +- k256 decompress ([#202](https://github.com/succinctlabs/sp1/pull/202)) +- blake3 interaction bug ([#199](https://github.com/succinctlabs/sp1/pull/199)) +- make SSZ work again ([#190](https://github.com/succinctlabs/sp1/pull/190)) +- remove verification checks from prove_core ([#185](https://github.com/succinctlabs/sp1/pull/185)) +- runtime sharding ([#181](https://github.com/succinctlabs/sp1/pull/181)) +- main ci ([#177](https://github.com/succinctlabs/sp1/pull/177)) +- proofs with dynamic jump clocks ([#172](https://github.com/succinctlabs/sp1/pull/172)) +- debug feature ([#171](https://github.com/succinctlabs/sp1/pull/171)) +- Interaction bug caused by carry arrays ([#131](https://github.com/succinctlabs/sp1/pull/131)) +- make memory argument safer ([#117](https://github.com/succinctlabs/sp1/pull/117)) +- bgeu ([#87](https://github.com/succinctlabs/sp1/pull/87)) +- revert to old fib program in tests ([#80](https://github.com/succinctlabs/sp1/pull/80)) +- sr byte lookup and memory events emitted during Syscall:PRINT ([#77](https://github.com/succinctlabs/sp1/pull/77)) +- support underflow case for sub chip ([#63](https://github.com/succinctlabs/sp1/pull/63)) +- use try_init() for env_logger ([#57](https://github.com/succinctlabs/sp1/pull/57)) +- bug ([#51](https://github.com/succinctlabs/sp1/pull/51)) +- `DIV`, `DIVU`, `REM`, `REMU` and add tests ([#42](https://github.com/succinctlabs/sp1/pull/42)) +- prover issue ([#32](https://github.com/succinctlabs/sp1/pull/32)) +- Fix the jump instructions, Fibonacci working now ([#27](https://github.com/succinctlabs/sp1/pull/27)) +- fix JALR and do not write to X0 ([#22](https://github.com/succinctlabs/sp1/pull/22)) +- jump bugs/jump decoding bugs ([#21](https://github.com/succinctlabs/sp1/pull/21)) + +### Other + +- poseidon2 parallel tracegen ([#1118](https://github.com/succinctlabs/sp1/pull/1118)) +- prover utilization ([#1100](https://github.com/succinctlabs/sp1/pull/1100)) +- _(deps)_ bump serde_with from 3.8.3 to 3.9.0 ([#1103](https://github.com/succinctlabs/sp1/pull/1103)) +- use global workspace version ([#1102](https://github.com/succinctlabs/sp1/pull/1102)) +- add more context to input stream panic ([#1091](https://github.com/succinctlabs/sp1/pull/1091)) +- fix release-plz ([#1088](https://github.com/succinctlabs/sp1/pull/1088)) +- add release-plz ([#1086](https://github.com/succinctlabs/sp1/pull/1086)) +- generate dependencies optimizations for CPU and ALU chips ([#1048](https://github.com/succinctlabs/sp1/pull/1048)) +- _(deps)_ bump serde_with from 3.8.1 to 3.8.3 ([#1064](https://github.com/succinctlabs/sp1/pull/1064)) +- _(deps)_ bump generic-array from 1.0.0 to 1.1.0 ([#1066](https://github.com/succinctlabs/sp1/pull/1066)) +- cycle limit +- Merge branch 'dev' into dependabot/cargo/dev/log-0.4.22 +- _(deps)_ bump num-bigint from 0.4.5 to 0.4.6 +- merge main -> dev ([#969](https://github.com/succinctlabs/sp1/pull/969)) +- cleanup +- v1.0.7-testnet ([#930](https://github.com/succinctlabs/sp1/pull/930)) +- remove u256 +- _(deps)_ bump itertools from 0.12.1 to 0.13.0 ([#817](https://github.com/succinctlabs/sp1/pull/817)) +- logging cleanup + non-compressed fibonacci ([#903](https://github.com/succinctlabs/sp1/pull/903)) +- Merge branch 'dev' into john/fix-main-regression +- fix program and permutation trace exports ([#887](https://github.com/succinctlabs/sp1/pull/887)) +- refactor derive, serialize bounds ([#869](https://github.com/succinctlabs/sp1/pull/869)) +- increase byte lookup channes ([#876](https://github.com/succinctlabs/sp1/pull/876)) +- constraint selectors when is_real zero ([#873](https://github.com/succinctlabs/sp1/pull/873)) +- state_mem validity ([#871](https://github.com/succinctlabs/sp1/pull/871)) +- fixes ([#821](https://github.com/succinctlabs/sp1/pull/821)) +- program doc and remove unnecessary clones ([#857](https://github.com/succinctlabs/sp1/pull/857)) +- default reconstruct commitments = true ([#846](https://github.com/succinctlabs/sp1/pull/846)) +- fmt +- hm +- change challenger rate from 16 to 8 ([#807](https://github.com/succinctlabs/sp1/pull/807)) +- hm +- no remainder range checks if division by 0 ([#764](https://github.com/succinctlabs/sp1/pull/764)) +- Make some functions const ([#774](https://github.com/succinctlabs/sp1/pull/774)) +- remove unused deps ([#794](https://github.com/succinctlabs/sp1/pull/794)) +- Clean up TOML files ([#796](https://github.com/succinctlabs/sp1/pull/796)) +- logup format ([#788](https://github.com/succinctlabs/sp1/pull/788)) +- pk/vk serde/clone ([#770](https://github.com/succinctlabs/sp1/pull/770)) +- get_cycles don't need emit events ([#697](https://github.com/succinctlabs/sp1/pull/697)) +- update all dependencies ([#689](https://github.com/succinctlabs/sp1/pull/689)) +- sdk tweaks ([#653](https://github.com/succinctlabs/sp1/pull/653)) +- avoid a few allocations in constraint code ([#567](https://github.com/succinctlabs/sp1/pull/567)) +- improve tracing log readability ([#616](https://github.com/succinctlabs/sp1/pull/616)) +- sdk improvements ([#580](https://github.com/succinctlabs/sp1/pull/580)) +- poseidon2 config change ([#609](https://github.com/succinctlabs/sp1/pull/609)) +- prover tweaks ([#610](https://github.com/succinctlabs/sp1/pull/610)) +- `get_cycles` ([#595](https://github.com/succinctlabs/sp1/pull/595)) +- fixing dep tree for `prover`, `recursion`, `core` and `sdk` ([#545](https://github.com/succinctlabs/sp1/pull/545)) +- cleanup prover ([#551](https://github.com/succinctlabs/sp1/pull/551)) +- re-organise cpu air constraints ([#538](https://github.com/succinctlabs/sp1/pull/538)) +- replace std::time with drop-in web-time for wasm compat ([#437](https://github.com/succinctlabs/sp1/pull/437)) +- make ci faster ([#536](https://github.com/succinctlabs/sp1/pull/536)) +- cleanup for allen ([#518](https://github.com/succinctlabs/sp1/pull/518)) +- _(recursion)_ reduce program ([#497](https://github.com/succinctlabs/sp1/pull/497)) +- _(simd)_ avx512 by dyxushuai ([#492](https://github.com/succinctlabs/sp1/pull/492)) +- update to latest plonky3 main ([#491](https://github.com/succinctlabs/sp1/pull/491)) +- clear semantics of variables ([#452](https://github.com/succinctlabs/sp1/pull/452)) +- constrain halt, is_real, and pc ([#424](https://github.com/succinctlabs/sp1/pull/424)) +- Clean up the `MUL` ALU table code ([#189](https://github.com/succinctlabs/sp1/pull/189)) +- cleanup keccak + more constraints ([#447](https://github.com/succinctlabs/sp1/pull/447)) +- sha cleanup + constraints ([#425](https://github.com/succinctlabs/sp1/pull/425)) +- generic size limbs for curve precompiles ([#417](https://github.com/succinctlabs/sp1/pull/417)) +- Merge sub chip into add chip ([#410](https://github.com/succinctlabs/sp1/pull/410)) +- styling and comment fixes ([#414](https://github.com/succinctlabs/sp1/pull/414)) +- Move memory access timestamp check inline ([#404](https://github.com/succinctlabs/sp1/pull/404)) +- set clk = 0 in initialize ([#406](https://github.com/succinctlabs/sp1/pull/406)) +- remove repetitive words ([#391](https://github.com/succinctlabs/sp1/pull/391)) +- sunday cleanup ([#363](https://github.com/succinctlabs/sp1/pull/363)) +- recursion core cleanup ([#355](https://github.com/succinctlabs/sp1/pull/355)) +- split `validate_memory_access` to avoid warnings in the release profile ([#353](https://github.com/succinctlabs/sp1/pull/353)) +- introduce a union type for `opcode_specific_columns` ([#310](https://github.com/succinctlabs/sp1/pull/310)) +- rename to upper camel case ([#325](https://github.com/succinctlabs/sp1/pull/325)) +- enable reconstruct trace/commit by default instead of using disk + lower memory usage ([#323](https://github.com/succinctlabs/sp1/pull/323)) +- various AIR tweaks ([#311](https://github.com/succinctlabs/sp1/pull/311)) +- refactor air in keccak to not use `offset_of` ([#308](https://github.com/succinctlabs/sp1/pull/308)) +- mul trace gen ([#306](https://github.com/succinctlabs/sp1/pull/306)) +- small verifier cleanup ([#288](https://github.com/succinctlabs/sp1/pull/288)) +- decrease default shard size ([#246](https://github.com/succinctlabs/sp1/pull/246)) +- update for compatibility with recent Plonky3 ([#277](https://github.com/succinctlabs/sp1/pull/277)) +- final touches for public release ([#239](https://github.com/succinctlabs/sp1/pull/239)) +- update ssh dependencies to https ([#235](https://github.com/succinctlabs/sp1/pull/235)) +- Range check misc fixes ([#216](https://github.com/succinctlabs/sp1/pull/216)) +- examples/tests folder refactor ([#234](https://github.com/succinctlabs/sp1/pull/234)) +- update docs with slight nits ([#224](https://github.com/succinctlabs/sp1/pull/224)) +- sp1 rename ([#212](https://github.com/succinctlabs/sp1/pull/212)) +- enshrine AlignedBorrow macro ([#209](https://github.com/succinctlabs/sp1/pull/209)) +- make `FpOperations` use `PrimeField32` to clean up type inconsistency hacks ([#203](https://github.com/succinctlabs/sp1/pull/203)) +- clean up the ed25519 test ([#207](https://github.com/succinctlabs/sp1/pull/207)) +- readme cleanup ([#196](https://github.com/succinctlabs/sp1/pull/196)) +- rename succinct to curta ([#192](https://github.com/succinctlabs/sp1/pull/192)) +- better curta graphic ([#184](https://github.com/succinctlabs/sp1/pull/184)) +- Move random related packages to dev dependency and constant poseidon2 RCs ([#182](https://github.com/succinctlabs/sp1/pull/182)) +- cleanup double generics + runtime ([#175](https://github.com/succinctlabs/sp1/pull/175)) +- cleanup runtime ([#170](https://github.com/succinctlabs/sp1/pull/170)) +- make demo and test in programs ([#167](https://github.com/succinctlabs/sp1/pull/167)) +- add config for SEGMENT_SIZE ([#166](https://github.com/succinctlabs/sp1/pull/166)) +- cleanup chip to it's own module ([#165](https://github.com/succinctlabs/sp1/pull/165)) +- use parallelization in Blake3 ([#164](https://github.com/succinctlabs/sp1/pull/164)) +- stark cleanup ([#162](https://github.com/succinctlabs/sp1/pull/162)) +- cpu cleanup ([#161](https://github.com/succinctlabs/sp1/pull/161)) +- prover cleanup pt 1 ([#159](https://github.com/succinctlabs/sp1/pull/159)) +- global prover imp v1 + blake3 ([#152](https://github.com/succinctlabs/sp1/pull/152)) +- parallelize segment proving ([#148](https://github.com/succinctlabs/sp1/pull/148)) +- split memory access by type ([#140](https://github.com/succinctlabs/sp1/pull/140)) +- air/alu/bytes/cpu ([#133](https://github.com/succinctlabs/sp1/pull/133)) +- cleanup patches + patch tendermint sha ([#135](https://github.com/succinctlabs/sp1/pull/135)) +- get rid of unneeded cpu cols and fix quotient values profile ([#118](https://github.com/succinctlabs/sp1/pull/118)) +- more efficient field ltu table ([#119](https://github.com/succinctlabs/sp1/pull/119)) +- generate permutation trace optimizations ([#121](https://github.com/succinctlabs/sp1/pull/121)) +- range check all appropriate values in ALU chips ([#107](https://github.com/succinctlabs/sp1/pull/107)) +- precompile runtime refactor ([#112](https://github.com/succinctlabs/sp1/pull/112)) +- minor improvements in `debug_interactions_with_all_chips` ([#106](https://github.com/succinctlabs/sp1/pull/106)) +- ALU table interaction tests + Shift clean up ([#89](https://github.com/succinctlabs/sp1/pull/89)) +- DIV/REM interaction fix ([#83](https://github.com/succinctlabs/sp1/pull/83)) +- Uncomment `debug_constraints` inside `prove` ([#86](https://github.com/succinctlabs/sp1/pull/86)) +- Fix MUL ALU table interactions ([#78](https://github.com/succinctlabs/sp1/pull/78)) +- air folder ([#73](https://github.com/succinctlabs/sp1/pull/73)) +- small changes to add chip ([#65](https://github.com/succinctlabs/sp1/pull/65)) +- Split the shift ALU table into left and right ([#62](https://github.com/succinctlabs/sp1/pull/62)) +- New memory argument ([#55](https://github.com/succinctlabs/sp1/pull/55)) +- update the implementation of MULH, MULHU, MULHSU ([#39](https://github.com/succinctlabs/sp1/pull/39)) +- implement ecall & panic at UNIMP ([#34](https://github.com/succinctlabs/sp1/pull/34)) +- CPU trace works ([#25](https://github.com/succinctlabs/sp1/pull/25)) +- minor fixes in the opcode/instruction ([#20](https://github.com/succinctlabs/sp1/pull/20)) +- CPU column cleanup ([#16](https://github.com/succinctlabs/sp1/pull/16)) +- Better structure cpu cols ([#14](https://github.com/succinctlabs/sp1/pull/14)) +- Uma/cpu lookups ([#12](https://github.com/succinctlabs/sp1/pull/12)) +- (feat) CPU Table ([#11](https://github.com/succinctlabs/sp1/pull/11)) +- tests for all ALU instructions +- tests for all ALU instructions +- tests for all ALU instructions +- tests for all ALU instructions +- resolve merge conflicts +- resolve merge conflicts +- resolve merge conflicts +- resolve merge conflicts +- interpreter +- interpreter +- runtime v.0.0.1 +- wip +- initial rought +- Initial commit diff --git a/core/Cargo.toml b/core/Cargo.toml index 85ad856103..4aeaccb3d7 100644 --- a/core/Cargo.toml +++ b/core/Cargo.toml @@ -1,14 +1,20 @@ [package] -edition = "2021" name = "sp1-core" -version = "0.1.0" +description = "SP1 is a performant, 100% open-source, contributor-friendly zkVM." +readme = "../README.md" +version = { workspace = true } +edition = { workspace = true } +license = { workspace = true } +repository = { workspace = true } +keywords = { workspace = true } +categories = { workspace = true } [dependencies] bincode = "1.3.3" serde = { version = "1.0", features = ["derive", "rc"] } elf = "0.7.4" itertools = "0.13.0" -log = "0.4.21" +log = "0.4.22" nohash-hasher = "0.2.0" num = { version = "0.4.3" } p3-air = { workspace = true } @@ -28,9 +34,9 @@ p3-poseidon2 = { workspace = true } p3-symmetric = { workspace = true } p3-uni-stark = { workspace = true } p3-util = { workspace = true } -rrs-lib = { git = "https://github.com/GregAC/rrs.git" } -sp1-derive = { path = "../derive" } -sp1-primitives = { path = "../primitives" } +rrs_lib = { package = "rrs-succinct", version = "0.1.0" } +sp1-derive = { workspace = true } +sp1-primitives = { workspace = true } anyhow = "1.0.83" amcl = { package = "snowbridge-amcl", version = "1.0.2", default-features = false, features = [ @@ -39,14 +45,14 @@ amcl = { package = "snowbridge-amcl", version = "1.0.2", default-features = fals arrayref = "0.3.7" blake3 = "1.5" cfg-if = "1.0.0" -generic-array = { version = "1.0.0", features = ["alloc", "serde"] } +generic-array = { version = "1.1.0", features = ["alloc", "serde"] } typenum = "1.17.0" curve25519-dalek = { version = "4.1.2" } elliptic-curve = "0.13.8" hex = "0.4.3" k256 = { version = "0.13.3", features = ["expose-field"] } num_cpus = "1.16.0" -serde_with = "3.8.1" +serde_with = "3.9.0" size = "0.4.1" tempfile = "3.10.1" tracing = "0.1.40" @@ -57,16 +63,17 @@ strum = "0.26" web-time = "1.1.0" rayon-scan = "0.1.1" thiserror = "1.0.60" -num-bigint = { version = "0.4.3", default-features = false } +num-bigint = { version = "0.4.6", default-features = false } rand = "0.8.5" bytemuck = "1.16.0" +hashbrown = { version = "0.14.5", features = ["serde", "inline-more"] } [dev-dependencies] tiny-keccak = { version = "2.0.2", features = ["keccak"] } criterion = "0.5.1" num = { version = "0.4.3", features = ["rand"] } rand = "0.8.5" -sp1-zkvm = { path = "../zkvm/entrypoint" } +sp1-zkvm = { workspace = true } [features] neon = ["p3-blake3/neon"] diff --git a/core/benches/main.rs b/core/benches/main.rs index 88c2db0874..1d9eb54ba6 100644 --- a/core/benches/main.rs +++ b/core/benches/main.rs @@ -1,6 +1,7 @@ use criterion::{black_box, criterion_group, criterion_main, Criterion}; use sp1_core::io::SP1Stdin; use sp1_core::runtime::{Program, Runtime}; +use sp1_core::stark::DefaultProver; use sp1_core::utils::{prove, BabyBearPoseidon2, SP1CoreOpts}; #[allow(unreachable_code)] @@ -20,7 +21,7 @@ pub fn criterion_benchmark(c: &mut Criterion) { format!("main:{}:{}", p.split('/').last().unwrap(), cycles), |b| { b.iter(|| { - prove( + prove::<_, DefaultProver<_, _>>( black_box(program.clone()), &SP1Stdin::new(), BabyBearPoseidon2::new(), diff --git a/core/src/air/builder.rs b/core/src/air/builder.rs index d957f43cd9..d5d87b2b23 100644 --- a/core/src/air/builder.rs +++ b/core/src/air/builder.rs @@ -52,6 +52,11 @@ pub trait BaseAirBuilder: AirBuilder + MessageBuilder } } + /// Asserts that an iterator of expressions are all zero. + fn assert_all_zero>(&mut self, iter: impl IntoIterator) { + iter.into_iter().for_each(|expr| self.assert_zero(expr)); + } + /// Will return `a` if `condition` is 1, else `b`. This assumes that `condition` is already /// checked to be a boolean. #[inline] diff --git a/core/src/air/machine.rs b/core/src/air/machine.rs index 55e8ac8627..a897ef5b5b 100644 --- a/core/src/air/machine.rs +++ b/core/src/air/machine.rs @@ -7,7 +7,7 @@ use crate::{runtime::Program, stark::MachineRecord}; pub use sp1_derive::MachineAir; /// An AIR that is part of a multi table AIR arithmetization. -pub trait MachineAir: BaseAir { +pub trait MachineAir: BaseAir + 'static + Send + Sync { /// The execution record containing events for producing the air trace. type Record: MachineRecord; diff --git a/core/src/air/public_values.rs b/core/src/air/public_values.rs index 0211e2e137..85fc554e1c 100644 --- a/core/src/air/public_values.rs +++ b/core/src/air/public_values.rs @@ -1,7 +1,7 @@ use core::fmt::Debug; use core::mem::size_of; -use std::array; -use std::iter::once; +use std::borrow::Borrow; +use std::borrow::BorrowMut; use itertools::Itertools; use p3_field::{AbstractField, PrimeField32}; @@ -20,6 +20,7 @@ pub const POSEIDON_NUM_WORDS: usize = 8; /// The PublicValues struct is used to store all of a shard proof's public values. #[derive(Serialize, Deserialize, Clone, Copy, Default, Debug)] +#[repr(C)] pub struct PublicValues { /// The hash of all the bytes that the guest program has written to public values. pub committed_value_digest: [W; PV_DIGEST_NUM_WORDS], @@ -40,74 +41,46 @@ pub struct PublicValues { /// The shard number. pub shard: T, + + /// The execution shard number. + pub execution_shard: T, + + /// The bits of the largest address that is witnessed for initialization in the previous shard. + pub previous_init_addr_bits: [T; 32], + + /// The largest address that is witnessed for initialization in the current shard. + pub last_init_addr_bits: [T; 32], + + /// The bits of the largest address that is witnessed for finalization in the previous shard. + pub previous_finalize_addr_bits: [T; 32], + + /// The bits of the largest address that is witnessed for finalization in the current shard. + pub last_finalize_addr_bits: [T; 32], } impl PublicValues { /// Convert the public values into a vector of field elements. This function will pad the vector /// to the maximum number of public values. pub fn to_vec(&self) -> Vec { - let mut ret = self - .committed_value_digest - .iter() - .flat_map(|w| Word::::from(*w).into_iter()) - .chain( - self.deferred_proofs_digest - .iter() - .cloned() - .map(F::from_canonical_u32), - ) - .chain(once(F::from_canonical_u32(self.start_pc))) - .chain(once(F::from_canonical_u32(self.next_pc))) - .chain(once(F::from_canonical_u32(self.exit_code))) - .chain(once(F::from_canonical_u32(self.shard))) - .collect_vec(); - - assert!( - ret.len() <= PROOF_MAX_NUM_PVS, - "Too many public values: {}", - ret.len() - ); - - ret.resize(PROOF_MAX_NUM_PVS, F::zero()); + let mut ret = vec![F::zero(); PROOF_MAX_NUM_PVS]; + let field_values = PublicValues::, F>::from(*self); + let ret_ref_mut: &mut PublicValues, F> = ret.as_mut_slice().borrow_mut(); + *ret_ref_mut = field_values; ret } -} -impl PublicValues, T> { - /// Convert a vector of field elements into a PublicValues struct. - pub fn from_vec(data: Vec) -> Self { - let mut iter = data.iter().cloned(); - - let committed_value_digest = array::from_fn(|_| Word::from_iter(&mut iter)); - - let deferred_proofs_digest = iter - .by_ref() - .take(POSEIDON_NUM_WORDS) - .collect_vec() - .try_into() - .unwrap(); - - // Collecting the remaining items into a tuple. Note that it is only getting the first - // four items, as the rest would be padded values. - let remaining_items = iter.collect_vec(); - if remaining_items.len() < 4 { - panic!("Invalid number of items in the serialized vector."); - } - - let [start_pc, next_pc, exit_code, shard] = match &remaining_items.as_slice()[0..4] { - [start_pc, next_pc, exit_code, shard] => [start_pc, next_pc, exit_code, shard], - _ => unreachable!(), - }; - - Self { - committed_value_digest, - deferred_proofs_digest, - start_pc: start_pc.to_owned(), - next_pc: next_pc.to_owned(), - exit_code: exit_code.to_owned(), - shard: shard.to_owned(), - } + pub fn reset(&self) -> Self { + let mut copy = *self; + copy.shard = 0; + copy.execution_shard = 0; + copy.start_pc = 0; + copy.next_pc = 0; + copy.previous_init_addr_bits = [0; 32]; + copy.last_init_addr_bits = [0; 32]; + copy.previous_finalize_addr_bits = [0; 32]; + copy.last_finalize_addr_bits = [0; 32]; + copy } } @@ -121,6 +94,78 @@ impl PublicValues, F> { } } +impl Borrow, T>> for [T] { + fn borrow(&self) -> &PublicValues, T> { + let size = std::mem::size_of::, u8>>(); + debug_assert!(self.len() >= size); + let slice = &self[0..size]; + let (prefix, shorts, _suffix) = unsafe { slice.align_to::, T>>() }; + debug_assert!(prefix.is_empty(), "Alignment should match"); + debug_assert_eq!(shorts.len(), 1); + &shorts[0] + } +} + +impl BorrowMut, T>> for [T] { + fn borrow_mut(&mut self) -> &mut PublicValues, T> { + let size = std::mem::size_of::, u8>>(); + debug_assert!(self.len() >= size); + let slice = &mut self[0..size]; + let (prefix, shorts, _suffix) = unsafe { slice.align_to_mut::, T>>() }; + debug_assert!(prefix.is_empty(), "Alignment should match"); + debug_assert_eq!(shorts.len(), 1); + &mut shorts[0] + } +} + +impl From> for PublicValues, F> { + fn from(value: PublicValues) -> Self { + let PublicValues { + committed_value_digest, + deferred_proofs_digest, + start_pc, + next_pc, + exit_code, + shard, + execution_shard, + previous_init_addr_bits, + last_init_addr_bits, + previous_finalize_addr_bits, + last_finalize_addr_bits, + } = value; + + let committed_value_digest: [_; PV_DIGEST_NUM_WORDS] = + core::array::from_fn(|i| Word::from(committed_value_digest[i])); + + let deferred_proofs_digest: [_; POSEIDON_NUM_WORDS] = + core::array::from_fn(|i| F::from_canonical_u32(deferred_proofs_digest[i])); + + let start_pc = F::from_canonical_u32(start_pc); + let next_pc = F::from_canonical_u32(next_pc); + let exit_code = F::from_canonical_u32(exit_code); + let shard = F::from_canonical_u32(shard); + let execution_shard = F::from_canonical_u32(execution_shard); + let previous_init_addr_bits = previous_init_addr_bits.map(F::from_canonical_u32); + let last_init_addr_bits = last_init_addr_bits.map(F::from_canonical_u32); + let previous_finalize_addr_bits = previous_finalize_addr_bits.map(F::from_canonical_u32); + let last_finalize_addr_bits = last_finalize_addr_bits.map(F::from_canonical_u32); + + Self { + committed_value_digest, + deferred_proofs_digest, + start_pc, + next_pc, + exit_code, + shard, + execution_shard, + previous_init_addr_bits, + last_init_addr_bits, + previous_finalize_addr_bits, + last_finalize_addr_bits, + } + } +} + #[cfg(test)] mod tests { use crate::air::public_values; diff --git a/core/src/alu/add_sub/mod.rs b/core/src/alu/add_sub/mod.rs index 3179d4d775..4765385576 100644 --- a/core/src/alu/add_sub/mod.rs +++ b/core/src/alu/add_sub/mod.rs @@ -1,22 +1,26 @@ use core::borrow::{Borrow, BorrowMut}; use core::mem::size_of; +use hashbrown::HashMap; +use itertools::Itertools; use p3_air::{Air, AirBuilder, BaseAir}; -use p3_field::AbstractField; -use p3_field::PrimeField; +use p3_field::{AbstractField, PrimeField}; use p3_matrix::dense::RowMajorMatrix; use p3_matrix::Matrix; -use p3_maybe_rayon::prelude::ParallelIterator; use p3_maybe_rayon::prelude::ParallelSlice; +use p3_maybe_rayon::prelude::{ParallelBridge, ParallelIterator}; use sp1_derive::AlignedBorrow; use crate::air::MachineAir; use crate::air::{SP1AirBuilder, Word}; +use crate::bytes::event::ByteRecord; +use crate::bytes::ByteLookupEvent; use crate::operations::AddOperation; use crate::runtime::{ExecutionRecord, Opcode, Program}; -use crate::stark::MachineRecord; use crate::utils::pad_to_power_of_two; +use super::AluEvent; + /// The number of main trace columns for `AddSubChip`. pub const NUM_ADD_SUB_COLS: usize = size_of::>(); @@ -71,7 +75,7 @@ impl MachineAir for AddSubChip { fn generate_trace( &self, input: &ExecutionRecord, - output: &mut ExecutionRecord, + _: &mut ExecutionRecord, ) -> RowMajorMatrix { // Generate the rows for the trace. let chunk_size = std::cmp::max( @@ -84,44 +88,26 @@ impl MachineAir for AddSubChip { .chain(input.sub_events.iter()) .collect::>(); - let rows_and_records = merged_events + let row_batches = merged_events .par_chunks(chunk_size) .map(|events| { - let mut record = ExecutionRecord::default(); let rows = events .iter() .map(|event| { let mut row = [F::zero(); NUM_ADD_SUB_COLS]; let cols: &mut AddSubCols = row.as_mut_slice().borrow_mut(); - let is_add = event.opcode == Opcode::ADD; - cols.shard = F::from_canonical_u32(event.shard); - cols.channel = F::from_canonical_u32(event.channel); - cols.is_add = F::from_bool(is_add); - cols.is_sub = F::from_bool(!is_add); - - let operand_1 = if is_add { event.b } else { event.a }; - let operand_2 = event.c; - - cols.add_operation.populate( - &mut record, - event.shard, - event.channel, - operand_1, - operand_2, - ); - cols.operand_1 = Word::from(operand_1); - cols.operand_2 = Word::from(operand_2); + let mut blu = Vec::new(); + self.event_to_row(event, cols, &mut blu); row }) .collect::>(); - (rows, record) + rows }) .collect::>(); let mut rows: Vec<[F; NUM_ADD_SUB_COLS]> = vec![]; - for mut row_and_record in rows_and_records { - rows.extend(row_and_record.0); - output.append(&mut row_and_record.1); + for row_batch in row_batches { + rows.extend(row_batch); } // Convert the trace to a row major matrix. @@ -143,11 +129,62 @@ impl MachineAir for AddSubChip { trace } + fn generate_dependencies(&self, input: &Self::Record, output: &mut Self::Record) { + let chunk_size = std::cmp::max( + (input.add_events.len() + input.sub_events.len()) / num_cpus::get(), + 1, + ); + + let event_iter = input + .add_events + .chunks(chunk_size) + .chain(input.sub_events.chunks(chunk_size)); + + let blu_batches = event_iter + .par_bridge() + .map(|events| { + let mut blu: HashMap> = HashMap::new(); + events.iter().for_each(|event| { + let mut row = [F::zero(); NUM_ADD_SUB_COLS]; + let cols: &mut AddSubCols = row.as_mut_slice().borrow_mut(); + self.event_to_row(event, cols, &mut blu); + }); + blu + }) + .collect::>(); + + output.add_sharded_byte_lookup_events(blu_batches.iter().collect_vec()); + } + fn included(&self, shard: &Self::Record) -> bool { !shard.add_events.is_empty() || !shard.sub_events.is_empty() } } +impl AddSubChip { + /// Create a row from an event. + fn event_to_row( + &self, + event: &AluEvent, + cols: &mut AddSubCols, + blu: &mut impl ByteRecord, + ) { + let is_add = event.opcode == Opcode::ADD; + cols.shard = F::from_canonical_u32(event.shard); + cols.channel = F::from_canonical_u32(event.channel); + cols.is_add = F::from_bool(is_add); + cols.is_sub = F::from_bool(!is_add); + + let operand_1 = if is_add { event.b } else { event.a }; + let operand_2 = event.c; + + cols.add_operation + .populate(blu, event.shard, event.channel, operand_1, operand_2); + cols.operand_1 = Word::from(operand_1); + cols.operand_2 = Word::from(operand_2); + } +} + impl BaseAir for AddSubChip { fn width(&self) -> usize { NUM_ADD_SUB_COLS diff --git a/core/src/alu/bitwise/mod.rs b/core/src/alu/bitwise/mod.rs index 81163b11e1..7a1cae7b21 100644 --- a/core/src/alu/bitwise/mod.rs +++ b/core/src/alu/bitwise/mod.rs @@ -1,12 +1,14 @@ use core::borrow::{Borrow, BorrowMut}; use core::mem::size_of; +use hashbrown::HashMap; +use itertools::Itertools; use p3_air::AirBuilder; use p3_air::{Air, BaseAir}; -use p3_field::AbstractField; -use p3_field::PrimeField; +use p3_field::{AbstractField, PrimeField}; use p3_matrix::dense::RowMajorMatrix; use p3_matrix::Matrix; +use p3_maybe_rayon::prelude::{IntoParallelRefIterator, ParallelIterator, ParallelSlice}; use sp1_derive::AlignedBorrow; use crate::air::MachineAir; @@ -16,6 +18,8 @@ use crate::bytes::{ByteLookupEvent, ByteOpcode}; use crate::runtime::{ExecutionRecord, Opcode, Program}; use crate::utils::pad_to_power_of_two; +use super::AluEvent; + /// The number of main trace columns for `BitwiseChip`. pub const NUM_BITWISE_COLS: usize = size_of::>(); @@ -67,42 +71,16 @@ impl MachineAir for BitwiseChip { fn generate_trace( &self, input: &ExecutionRecord, - output: &mut ExecutionRecord, + _: &mut ExecutionRecord, ) -> RowMajorMatrix { - // Generate the trace rows for each event. let rows = input .bitwise_events - .iter() + .par_iter() .map(|event| { let mut row = [F::zero(); NUM_BITWISE_COLS]; let cols: &mut BitwiseCols = row.as_mut_slice().borrow_mut(); - let a = event.a.to_le_bytes(); - let b = event.b.to_le_bytes(); - let c = event.c.to_le_bytes(); - - cols.shard = F::from_canonical_u32(event.shard); - cols.channel = F::from_canonical_u32(event.channel); - cols.a = Word::from(event.a); - cols.b = Word::from(event.b); - cols.c = Word::from(event.c); - - cols.is_xor = F::from_bool(event.opcode == Opcode::XOR); - cols.is_or = F::from_bool(event.opcode == Opcode::OR); - cols.is_and = F::from_bool(event.opcode == Opcode::AND); - - for ((b_a, b_b), b_c) in a.into_iter().zip(b).zip(c) { - let byte_event = ByteLookupEvent { - shard: event.shard, - channel: event.channel, - opcode: ByteOpcode::from(event.opcode), - a1: b_a as u32, - a2: 0, - b: b_b as u32, - c: b_c as u32, - }; - output.add_byte_lookup_event(byte_event); - } - + let mut blu = Vec::new(); + self.event_to_row(event, cols, &mut blu); row }) .collect::>(); @@ -125,11 +103,68 @@ impl MachineAir for BitwiseChip { trace } + fn generate_dependencies(&self, input: &Self::Record, output: &mut Self::Record) { + let chunk_size = std::cmp::max(input.bitwise_events.len() / num_cpus::get(), 1); + + let blu_batches = input + .bitwise_events + .par_chunks(chunk_size) + .map(|events| { + let mut blu: HashMap> = HashMap::new(); + events.iter().for_each(|event| { + let mut row = [F::zero(); NUM_BITWISE_COLS]; + let cols: &mut BitwiseCols = row.as_mut_slice().borrow_mut(); + self.event_to_row(event, cols, &mut blu); + }); + blu + }) + .collect::>(); + + output.add_sharded_byte_lookup_events(blu_batches.iter().collect_vec()); + } + fn included(&self, shard: &Self::Record) -> bool { !shard.bitwise_events.is_empty() } } +impl BitwiseChip { + /// Create a row from an event. + fn event_to_row( + &self, + event: &AluEvent, + cols: &mut BitwiseCols, + blu: &mut impl ByteRecord, + ) { + let a = event.a.to_le_bytes(); + let b = event.b.to_le_bytes(); + let c = event.c.to_le_bytes(); + + cols.shard = F::from_canonical_u32(event.shard); + cols.channel = F::from_canonical_u32(event.channel); + cols.a = Word::from(event.a); + cols.b = Word::from(event.b); + cols.c = Word::from(event.c); + + cols.is_xor = F::from_bool(event.opcode == Opcode::XOR); + cols.is_or = F::from_bool(event.opcode == Opcode::OR); + cols.is_and = F::from_bool(event.opcode == Opcode::AND); + + for ((b_a, b_b), b_c) in a.into_iter().zip(b).zip(c) { + let byte_event = ByteLookupEvent { + shard: event.shard, + channel: event.channel, + opcode: ByteOpcode::from(event.opcode), + a1: b_a as u32, + a2: 0, + b: b_b as u32, + c: b_c as u32, + }; + blu.add_byte_lookup_event(byte_event); + } + } +} + impl BaseAir for BitwiseChip { fn width(&self) -> usize { NUM_BITWISE_COLS diff --git a/core/src/alu/divrem/mod.rs b/core/src/alu/divrem/mod.rs index 84198b16bb..6779b44f22 100644 --- a/core/src/alu/divrem/mod.rs +++ b/core/src/alu/divrem/mod.rs @@ -64,7 +64,7 @@ mod utils; use core::borrow::{Borrow, BorrowMut}; use core::mem::size_of; -use std::collections::HashMap; +use hashbrown::HashMap; use p3_air::{Air, AirBuilder, BaseAir}; use p3_field::AbstractField; diff --git a/core/src/alu/lt/mod.rs b/core/src/alu/lt/mod.rs index 54d5768c2c..2e5af527da 100644 --- a/core/src/alu/lt/mod.rs +++ b/core/src/alu/lt/mod.rs @@ -1,7 +1,8 @@ use core::borrow::{Borrow, BorrowMut}; use core::mem::size_of; -use itertools::izip; +use hashbrown::HashMap; +use itertools::{izip, Itertools}; use p3_air::{Air, AirBuilder, BaseAir}; use p3_field::Field; use p3_field::{AbstractField, PrimeField32}; @@ -17,6 +18,8 @@ use crate::bytes::{ByteLookupEvent, ByteOpcode}; use crate::runtime::{ExecutionRecord, Opcode, Program}; use crate::utils::pad_to_power_of_two; +use super::AluEvent; + /// The number of main trace columns for `LtChip`. pub const NUM_LT_COLS: usize = size_of::>(); @@ -107,114 +110,21 @@ impl MachineAir for LtChip { fn generate_trace( &self, input: &ExecutionRecord, - output: &mut ExecutionRecord, + _: &mut ExecutionRecord, ) -> RowMajorMatrix { // Generate the trace rows for each event. - let (rows, new_byte_lookup_events): (Vec<_>, Vec<_>) = input + let rows = input .lt_events .par_iter() .map(|event| { let mut row = [F::zero(); NUM_LT_COLS]; let mut new_byte_lookup_events: Vec = Vec::new(); let cols: &mut LtCols = row.as_mut_slice().borrow_mut(); - let a = event.a.to_le_bytes(); - let b = event.b.to_le_bytes(); - let c = event.c.to_le_bytes(); - - cols.shard = F::from_canonical_u32(event.shard); - cols.channel = F::from_canonical_u32(event.channel); - cols.a = Word(a.map(F::from_canonical_u8)); - cols.b = Word(b.map(F::from_canonical_u8)); - cols.c = Word(c.map(F::from_canonical_u8)); - - // If this is SLT, mask the MSB of b & c before computing cols.bits. - let masked_b = b[3] & 0x7f; - let masked_c = c[3] & 0x7f; - cols.b_masked = F::from_canonical_u8(masked_b); - cols.c_masked = F::from_canonical_u8(masked_c); - - // Send the masked interaction. - new_byte_lookup_events.add_byte_lookup_event(ByteLookupEvent { - shard: event.shard, - channel: event.channel, - opcode: ByteOpcode::AND, - a1: masked_b as u32, - a2: 0, - b: b[3] as u32, - c: 0x7f as u32, - }); - new_byte_lookup_events.add_byte_lookup_event(ByteLookupEvent { - shard: event.shard, - channel: event.channel, - opcode: ByteOpcode::AND, - a1: masked_c as u32, - a2: 0, - b: c[3] as u32, - c: 0x7f as u32, - }); + self.event_to_row(event, cols, &mut new_byte_lookup_events); - let mut b_comp = b; - let mut c_comp = c; - if event.opcode == Opcode::SLT { - b_comp[3] = masked_b; - c_comp[3] = masked_c; - } - cols.sltu = F::from_bool(b_comp < c_comp); - cols.is_comp_eq = F::from_bool(b_comp == c_comp); - - // Set the byte equality flags. - for (b_byte, c_byte, flag) in izip!( - b_comp.iter().rev(), - c_comp.iter().rev(), - cols.byte_flags.iter_mut().rev() - ) { - if c_byte != b_byte { - *flag = F::one(); - cols.sltu = F::from_bool(b_byte < c_byte); - let b_byte = F::from_canonical_u8(*b_byte); - let c_byte = F::from_canonical_u8(*c_byte); - cols.not_eq_inv = (b_byte - c_byte).inverse(); - cols.comparison_bytes = [b_byte, c_byte]; - break; - } - } - - cols.msb_b = F::from_canonical_u8((b[3] >> 7) & 1); - cols.msb_c = F::from_canonical_u8((c[3] >> 7) & 1); - cols.is_sign_eq = if event.opcode == Opcode::SLT { - F::from_bool((b[3] >> 7) == (c[3] >> 7)) - } else { - F::one() - }; - - cols.is_slt = F::from_bool(event.opcode == Opcode::SLT); - cols.is_sltu = F::from_bool(event.opcode == Opcode::SLTU); - - cols.bit_b = cols.msb_b * cols.is_slt; - cols.bit_c = cols.msb_c * cols.is_slt; - - assert_eq!( - cols.a[0], - cols.bit_b * (F::one() - cols.bit_c) + cols.is_sign_eq * cols.sltu - ); - - new_byte_lookup_events.add_byte_lookup_event(ByteLookupEvent { - shard: event.shard, - channel: event.channel, - opcode: ByteOpcode::LTU, - a1: cols.sltu.as_canonical_u32(), - a2: 0, - b: cols.comparison_bytes[0].as_canonical_u32(), - c: cols.comparison_bytes[1].as_canonical_u32(), - }); - - (row, new_byte_lookup_events) + row }) - .unzip(); - - for byte_lookup_events in new_byte_lookup_events { - output.add_byte_lookup_events(byte_lookup_events); - } + .collect::>(); // Convert the trace to a row major matrix. let mut trace = @@ -233,11 +143,132 @@ impl MachineAir for LtChip { trace } + fn generate_dependencies(&self, input: &Self::Record, output: &mut Self::Record) { + let chunk_size = std::cmp::max(input.lt_events.len() / num_cpus::get(), 1); + + let blu_batches = input + .lt_events + .par_chunks(chunk_size) + .map(|events| { + let mut blu: HashMap> = HashMap::new(); + events.iter().for_each(|event| { + let mut row = [F::zero(); NUM_LT_COLS]; + let cols: &mut LtCols = row.as_mut_slice().borrow_mut(); + self.event_to_row(event, cols, &mut blu); + }); + blu + }) + .collect::>(); + + output.add_sharded_byte_lookup_events(blu_batches.iter().collect_vec()); + } + fn included(&self, shard: &Self::Record) -> bool { !shard.lt_events.is_empty() } } +impl LtChip { + /// Create a row from an event. + fn event_to_row( + &self, + event: &AluEvent, + cols: &mut LtCols, + blu: &mut impl ByteRecord, + ) { + let a = event.a.to_le_bytes(); + let b = event.b.to_le_bytes(); + let c = event.c.to_le_bytes(); + + cols.shard = F::from_canonical_u32(event.shard); + cols.channel = F::from_canonical_u32(event.channel); + cols.a = Word(a.map(F::from_canonical_u8)); + cols.b = Word(b.map(F::from_canonical_u8)); + cols.c = Word(c.map(F::from_canonical_u8)); + + // If this is SLT, mask the MSB of b & c before computing cols.bits. + let masked_b = b[3] & 0x7f; + let masked_c = c[3] & 0x7f; + cols.b_masked = F::from_canonical_u8(masked_b); + cols.c_masked = F::from_canonical_u8(masked_c); + + // Send the masked interaction. + blu.add_byte_lookup_event(ByteLookupEvent { + shard: event.shard, + channel: event.channel, + opcode: ByteOpcode::AND, + a1: masked_b as u32, + a2: 0, + b: b[3] as u32, + c: 0x7f as u32, + }); + blu.add_byte_lookup_event(ByteLookupEvent { + shard: event.shard, + channel: event.channel, + opcode: ByteOpcode::AND, + a1: masked_c as u32, + a2: 0, + b: c[3] as u32, + c: 0x7f as u32, + }); + + let mut b_comp = b; + let mut c_comp = c; + if event.opcode == Opcode::SLT { + b_comp[3] = masked_b; + c_comp[3] = masked_c; + } + cols.sltu = F::from_bool(b_comp < c_comp); + cols.is_comp_eq = F::from_bool(b_comp == c_comp); + + // Set the byte equality flags. + for (b_byte, c_byte, flag) in izip!( + b_comp.iter().rev(), + c_comp.iter().rev(), + cols.byte_flags.iter_mut().rev() + ) { + if c_byte != b_byte { + *flag = F::one(); + cols.sltu = F::from_bool(b_byte < c_byte); + let b_byte = F::from_canonical_u8(*b_byte); + let c_byte = F::from_canonical_u8(*c_byte); + cols.not_eq_inv = (b_byte - c_byte).inverse(); + cols.comparison_bytes = [b_byte, c_byte]; + break; + } + } + + cols.msb_b = F::from_canonical_u8((b[3] >> 7) & 1); + cols.msb_c = F::from_canonical_u8((c[3] >> 7) & 1); + cols.is_sign_eq = if event.opcode == Opcode::SLT { + F::from_bool((b[3] >> 7) == (c[3] >> 7)) + } else { + F::one() + }; + + cols.is_slt = F::from_bool(event.opcode == Opcode::SLT); + cols.is_sltu = F::from_bool(event.opcode == Opcode::SLTU); + + cols.bit_b = cols.msb_b * cols.is_slt; + cols.bit_c = cols.msb_c * cols.is_slt; + + assert_eq!( + cols.a[0], + cols.bit_b * (F::one() - cols.bit_c) + cols.is_sign_eq * cols.sltu + ); + + blu.add_byte_lookup_event(ByteLookupEvent { + shard: event.shard, + channel: event.channel, + opcode: ByteOpcode::LTU, + a1: cols.sltu.as_canonical_u32(), + a2: 0, + b: cols.comparison_bytes[0].as_canonical_u32(), + c: cols.comparison_bytes[1].as_canonical_u32(), + }); + } +} + impl BaseAir for LtChip { fn width(&self) -> usize { NUM_LT_COLS diff --git a/core/src/alu/mod.rs b/core/src/alu/mod.rs index a67d1ff909..535b6bee08 100644 --- a/core/src/alu/mod.rs +++ b/core/src/alu/mod.rs @@ -23,7 +23,7 @@ use crate::runtime::Opcode; #[derive(Debug, Clone, Copy, Serialize, Deserialize)] pub struct AluEvent { /// The lookup id of the event. - pub lookup_id: usize, + pub lookup_id: u128, /// The shard number, used for byte lookup table. pub shard: u32, @@ -46,7 +46,7 @@ pub struct AluEvent { // The second input operand. pub c: u32, - pub sub_lookups: [usize; 6], + pub sub_lookups: [u128; 6], } impl AluEvent { @@ -66,12 +66,12 @@ impl AluEvent { } } -pub fn create_alu_lookup_id() -> usize { +pub fn create_alu_lookup_id() -> u128 { let mut rng = rand::thread_rng(); rng.gen() } -pub fn create_alu_lookups() -> [usize; 6] { +pub fn create_alu_lookups() -> [u128; 6] { let mut rng = rand::thread_rng(); [ rng.gen(), diff --git a/core/src/alu/sll/mod.rs b/core/src/alu/sll/mod.rs index b5a711542b..a3caadbcad 100644 --- a/core/src/alu/sll/mod.rs +++ b/core/src/alu/sll/mod.rs @@ -33,20 +33,25 @@ use core::borrow::{Borrow, BorrowMut}; use core::mem::size_of; +use hashbrown::HashMap; +use itertools::Itertools; use p3_air::{Air, AirBuilder, BaseAir}; -use p3_field::AbstractField; -use p3_field::PrimeField; +use p3_field::{AbstractField, PrimeField}; use p3_matrix::dense::RowMajorMatrix; use p3_matrix::Matrix; +use p3_maybe_rayon::prelude::{ParallelIterator, ParallelSlice}; use sp1_derive::AlignedBorrow; use crate::air::MachineAir; use crate::air::{SP1AirBuilder, Word}; use crate::bytes::event::ByteRecord; +use crate::bytes::ByteLookupEvent; use crate::disassembler::WORD_SIZE; use crate::runtime::{ExecutionRecord, Opcode, Program}; use crate::utils::pad_to_power_of_two; +use super::AluEvent; + /// The number of main trace columns for `ShiftLeft`. pub const NUM_SHIFT_LEFT_COLS: usize = size_of::>(); @@ -112,7 +117,7 @@ impl MachineAir for ShiftLeft { fn generate_trace( &self, input: &ExecutionRecord, - output: &mut ExecutionRecord, + _: &mut ExecutionRecord, ) -> RowMajorMatrix { // Generate the trace rows for each event. let mut rows: Vec<[F; NUM_SHIFT_LEFT_COLS]> = vec![]; @@ -120,61 +125,8 @@ impl MachineAir for ShiftLeft { for event in shift_left_events.iter() { let mut row = [F::zero(); NUM_SHIFT_LEFT_COLS]; let cols: &mut ShiftLeftCols = row.as_mut_slice().borrow_mut(); - let a = event.a.to_le_bytes(); - let b = event.b.to_le_bytes(); - let c = event.c.to_le_bytes(); - cols.shard = F::from_canonical_u32(event.shard); - cols.channel = F::from_canonical_u32(event.channel); - cols.a = Word(a.map(F::from_canonical_u8)); - cols.b = Word(b.map(F::from_canonical_u8)); - cols.c = Word(c.map(F::from_canonical_u8)); - cols.is_real = F::one(); - for i in 0..BYTE_SIZE { - cols.c_least_sig_byte[i] = F::from_canonical_u32((event.c >> i) & 1); - } - - // Variables for bit shifting. - let num_bits_to_shift = event.c as usize % BYTE_SIZE; - for i in 0..BYTE_SIZE { - cols.shift_by_n_bits[i] = F::from_bool(num_bits_to_shift == i); - } - - let bit_shift_multiplier = 1u32 << num_bits_to_shift; - cols.bit_shift_multiplier = F::from_canonical_u32(bit_shift_multiplier); - - let mut carry = 0u32; - let base = 1u32 << BYTE_SIZE; - let mut bit_shift_result = [0u8; WORD_SIZE]; - let mut bit_shift_result_carry = [0u8; WORD_SIZE]; - for i in 0..WORD_SIZE { - let v = b[i] as u32 * bit_shift_multiplier + carry; - carry = v / base; - bit_shift_result[i] = (v % base) as u8; - bit_shift_result_carry[i] = carry as u8; - } - cols.bit_shift_result = bit_shift_result.map(F::from_canonical_u8); - cols.bit_shift_result_carry = bit_shift_result_carry.map(F::from_canonical_u8); - - // Variables for byte shifting. - let num_bytes_to_shift = (event.c & 0b11111) as usize / BYTE_SIZE; - for i in 0..WORD_SIZE { - cols.shift_by_n_bytes[i] = F::from_bool(num_bytes_to_shift == i); - } - - // Range checks. - { - output.add_u8_range_checks(event.shard, event.channel, &bit_shift_result); - output.add_u8_range_checks(event.shard, event.channel, &bit_shift_result_carry); - } - - // Sanity check. - for i in num_bytes_to_shift..WORD_SIZE { - debug_assert_eq!( - cols.bit_shift_result[i - num_bytes_to_shift], - F::from_canonical_u8(a[i]) - ); - } - + let mut blu = Vec::new(); + self.event_to_row(event, cols, &mut blu); rows.push(row); } @@ -211,11 +163,96 @@ impl MachineAir for ShiftLeft { trace } + fn generate_dependencies(&self, input: &Self::Record, output: &mut Self::Record) { + let chunk_size = std::cmp::max(input.shift_left_events.len() / num_cpus::get(), 1); + + let blu_batches = input + .shift_left_events + .par_chunks(chunk_size) + .map(|events| { + let mut blu: HashMap> = HashMap::new(); + events.iter().for_each(|event| { + let mut row = [F::zero(); NUM_SHIFT_LEFT_COLS]; + let cols: &mut ShiftLeftCols = row.as_mut_slice().borrow_mut(); + self.event_to_row(event, cols, &mut blu); + }); + blu + }) + .collect::>(); + + output.add_sharded_byte_lookup_events(blu_batches.iter().collect_vec()); + } + fn included(&self, shard: &Self::Record) -> bool { !shard.shift_left_events.is_empty() } } +impl ShiftLeft { + /// Create a row from an event. + fn event_to_row( + &self, + event: &AluEvent, + cols: &mut ShiftLeftCols, + blu: &mut impl ByteRecord, + ) { + let a = event.a.to_le_bytes(); + let b = event.b.to_le_bytes(); + let c = event.c.to_le_bytes(); + cols.shard = F::from_canonical_u32(event.shard); + cols.channel = F::from_canonical_u32(event.channel); + cols.a = Word(a.map(F::from_canonical_u8)); + cols.b = Word(b.map(F::from_canonical_u8)); + cols.c = Word(c.map(F::from_canonical_u8)); + cols.is_real = F::one(); + for i in 0..BYTE_SIZE { + cols.c_least_sig_byte[i] = F::from_canonical_u32((event.c >> i) & 1); + } + + // Variables for bit shifting. + let num_bits_to_shift = event.c as usize % BYTE_SIZE; + for i in 0..BYTE_SIZE { + cols.shift_by_n_bits[i] = F::from_bool(num_bits_to_shift == i); + } + + let bit_shift_multiplier = 1u32 << num_bits_to_shift; + cols.bit_shift_multiplier = F::from_canonical_u32(bit_shift_multiplier); + + let mut carry = 0u32; + let base = 1u32 << BYTE_SIZE; + let mut bit_shift_result = [0u8; WORD_SIZE]; + let mut bit_shift_result_carry = [0u8; WORD_SIZE]; + for i in 0..WORD_SIZE { + let v = b[i] as u32 * bit_shift_multiplier + carry; + carry = v / base; + bit_shift_result[i] = (v % base) as u8; + bit_shift_result_carry[i] = carry as u8; + } + cols.bit_shift_result = bit_shift_result.map(F::from_canonical_u8); + cols.bit_shift_result_carry = bit_shift_result_carry.map(F::from_canonical_u8); + + // Variables for byte shifting. + let num_bytes_to_shift = (event.c & 0b11111) as usize / BYTE_SIZE; + for i in 0..WORD_SIZE { + cols.shift_by_n_bytes[i] = F::from_bool(num_bytes_to_shift == i); + } + + // Range checks. + { + blu.add_u8_range_checks(event.shard, event.channel, &bit_shift_result); + blu.add_u8_range_checks(event.shard, event.channel, &bit_shift_result_carry); + } + + // Sanity check. + for i in num_bytes_to_shift..WORD_SIZE { + debug_assert_eq!( + cols.bit_shift_result[i - num_bytes_to_shift], + F::from_canonical_u8(a[i]) + ); + } + } +} + impl BaseAir for ShiftLeft { fn width(&self) -> usize { NUM_SHIFT_LEFT_COLS diff --git a/core/src/alu/sr/mod.rs b/core/src/alu/sr/mod.rs index bd7a91d52e..db093cf109 100644 --- a/core/src/alu/sr/mod.rs +++ b/core/src/alu/sr/mod.rs @@ -45,11 +45,14 @@ mod utils; use core::borrow::{Borrow, BorrowMut}; use core::mem::size_of; +use hashbrown::HashMap; +use itertools::Itertools; use p3_air::{Air, AirBuilder, BaseAir}; use p3_field::AbstractField; use p3_field::PrimeField; use p3_matrix::dense::RowMajorMatrix; use p3_matrix::Matrix; +use p3_maybe_rayon::prelude::{ParallelIterator, ParallelSlice}; use sp1_derive::AlignedBorrow; use crate::air::MachineAir; @@ -62,6 +65,8 @@ use crate::disassembler::WORD_SIZE; use crate::runtime::{ExecutionRecord, Opcode, Program}; use crate::utils::pad_to_power_of_two; +use super::AluEvent; + /// The number of main trace columns for `ShiftRightChip`. pub const NUM_SHIFT_RIGHT_COLS: usize = size_of::>(); @@ -143,7 +148,7 @@ impl MachineAir for ShiftRightChip { fn generate_trace( &self, input: &ExecutionRecord, - output: &mut ExecutionRecord, + _: &mut ExecutionRecord, ) -> RowMajorMatrix { // Generate the trace rows for each event. let mut rows: Vec<[F; NUM_SHIFT_RIGHT_COLS]> = Vec::new(); @@ -152,112 +157,8 @@ impl MachineAir for ShiftRightChip { assert!(event.opcode == Opcode::SRL || event.opcode == Opcode::SRA); let mut row = [F::zero(); NUM_SHIFT_RIGHT_COLS]; let cols: &mut ShiftRightCols = row.as_mut_slice().borrow_mut(); - // Initialize cols with basic operands and flags derived from the current event. - { - cols.shard = F::from_canonical_u32(event.shard); - cols.channel = F::from_canonical_u32(event.channel); - cols.a = Word::from(event.a); - cols.b = Word::from(event.b); - cols.c = Word::from(event.c); - - cols.b_msb = F::from_canonical_u32((event.b >> 31) & 1); - - cols.is_srl = F::from_bool(event.opcode == Opcode::SRL); - cols.is_sra = F::from_bool(event.opcode == Opcode::SRA); - - cols.is_real = F::one(); - - for i in 0..BYTE_SIZE { - cols.c_least_sig_byte[i] = F::from_canonical_u32((event.c >> i) & 1); - } - - // Insert the MSB lookup event. - let most_significant_byte = event.b.to_le_bytes()[WORD_SIZE - 1]; - output.add_byte_lookup_events(vec![ByteLookupEvent { - shard: event.shard, - channel: event.channel, - opcode: ByteOpcode::MSB, - a1: ((most_significant_byte >> 7) & 1) as u32, - a2: 0, - b: most_significant_byte as u32, - c: 0, - }]); - } - - let num_bytes_to_shift = nb_bytes_to_shift(event.c); - let num_bits_to_shift = nb_bits_to_shift(event.c); - - // Byte shifting. - let mut byte_shift_result = [0u8; LONG_WORD_SIZE]; - { - for i in 0..WORD_SIZE { - cols.shift_by_n_bytes[i] = F::from_bool(num_bytes_to_shift == i); - } - let sign_extended_b = { - if event.opcode == Opcode::SRA { - // Sign extension is necessary only for arithmetic right shift. - ((event.b as i32) as i64).to_le_bytes() - } else { - (event.b as u64).to_le_bytes() - } - }; - - for i in 0..LONG_WORD_SIZE { - if i + num_bytes_to_shift < LONG_WORD_SIZE { - byte_shift_result[i] = sign_extended_b[i + num_bytes_to_shift]; - } - } - cols.byte_shift_result = byte_shift_result.map(F::from_canonical_u8); - } - - // Bit shifting. - { - for i in 0..BYTE_SIZE { - cols.shift_by_n_bits[i] = F::from_bool(num_bits_to_shift == i); - } - let carry_multiplier = 1 << (8 - num_bits_to_shift); - let mut last_carry = 0u32; - let mut bit_shift_result = [0u8; LONG_WORD_SIZE]; - let mut shr_carry_output_carry = [0u8; LONG_WORD_SIZE]; - let mut shr_carry_output_shifted_byte = [0u8; LONG_WORD_SIZE]; - for i in (0..LONG_WORD_SIZE).rev() { - let (shift, carry) = shr_carry(byte_shift_result[i], num_bits_to_shift as u8); - - let byte_event = ByteLookupEvent { - shard: event.shard, - channel: event.channel, - opcode: ByteOpcode::ShrCarry, - a1: shift as u32, - a2: carry as u32, - b: byte_shift_result[i] as u32, - c: num_bits_to_shift as u32, - }; - output.add_byte_lookup_event(byte_event); - - shr_carry_output_carry[i] = carry; - shr_carry_output_shifted_byte[i] = shift; - bit_shift_result[i] = - ((shift as u32 + last_carry * carry_multiplier) & 0xff) as u8; - last_carry = carry as u32; - } - cols.bit_shift_result = bit_shift_result.map(F::from_canonical_u8); - cols.shr_carry_output_carry = shr_carry_output_carry.map(F::from_canonical_u8); - cols.shr_carry_output_shifted_byte = - shr_carry_output_shifted_byte.map(F::from_canonical_u8); - for i in 0..WORD_SIZE { - debug_assert_eq!(cols.a[i], cols.bit_shift_result[i].clone()); - } - // Range checks. - output.add_u8_range_checks(event.shard, event.channel, &byte_shift_result); - output.add_u8_range_checks(event.shard, event.channel, &bit_shift_result); - output.add_u8_range_checks(event.shard, event.channel, &shr_carry_output_carry); - output.add_u8_range_checks( - event.shard, - event.channel, - &shr_carry_output_shifted_byte, - ); - } - + let mut blu = Vec::new(); + self.event_to_row(event, cols, &mut blu); rows.push(row); } @@ -296,11 +197,142 @@ impl MachineAir for ShiftRightChip { trace } + fn generate_dependencies(&self, input: &Self::Record, output: &mut Self::Record) { + let chunk_size = std::cmp::max(input.shift_right_events.len() / num_cpus::get(), 1); + + let blu_batches = input + .shift_right_events + .par_chunks(chunk_size) + .map(|events| { + let mut blu: HashMap> = HashMap::new(); + events.iter().for_each(|event| { + let mut row = [F::zero(); NUM_SHIFT_RIGHT_COLS]; + let cols: &mut ShiftRightCols = row.as_mut_slice().borrow_mut(); + self.event_to_row(event, cols, &mut blu); + }); + blu + }) + .collect::>(); + + output.add_sharded_byte_lookup_events(blu_batches.iter().collect_vec()); + } + fn included(&self, shard: &Self::Record) -> bool { !shard.shift_right_events.is_empty() } } +impl ShiftRightChip { + /// Create a row from an event. + fn event_to_row( + &self, + event: &AluEvent, + cols: &mut ShiftRightCols, + blu: &mut impl ByteRecord, + ) { + // Initialize cols with basic operands and flags derived from the current event. + { + cols.shard = F::from_canonical_u32(event.shard); + cols.channel = F::from_canonical_u32(event.channel); + cols.a = Word::from(event.a); + cols.b = Word::from(event.b); + cols.c = Word::from(event.c); + + cols.b_msb = F::from_canonical_u32((event.b >> 31) & 1); + + cols.is_srl = F::from_bool(event.opcode == Opcode::SRL); + cols.is_sra = F::from_bool(event.opcode == Opcode::SRA); + + cols.is_real = F::one(); + + for i in 0..BYTE_SIZE { + cols.c_least_sig_byte[i] = F::from_canonical_u32((event.c >> i) & 1); + } + + // Insert the MSB lookup event. + let most_significant_byte = event.b.to_le_bytes()[WORD_SIZE - 1]; + blu.add_byte_lookup_events(vec![ByteLookupEvent { + shard: event.shard, + channel: event.channel, + opcode: ByteOpcode::MSB, + a1: ((most_significant_byte >> 7) & 1) as u32, + a2: 0, + b: most_significant_byte as u32, + c: 0, + }]); + } + + let num_bytes_to_shift = nb_bytes_to_shift(event.c); + let num_bits_to_shift = nb_bits_to_shift(event.c); + + // Byte shifting. + let mut byte_shift_result = [0u8; LONG_WORD_SIZE]; + { + for i in 0..WORD_SIZE { + cols.shift_by_n_bytes[i] = F::from_bool(num_bytes_to_shift == i); + } + let sign_extended_b = { + if event.opcode == Opcode::SRA { + // Sign extension is necessary only for arithmetic right shift. + ((event.b as i32) as i64).to_le_bytes() + } else { + (event.b as u64).to_le_bytes() + } + }; + + for i in 0..LONG_WORD_SIZE { + if i + num_bytes_to_shift < LONG_WORD_SIZE { + byte_shift_result[i] = sign_extended_b[i + num_bytes_to_shift]; + } + } + cols.byte_shift_result = byte_shift_result.map(F::from_canonical_u8); + } + + // Bit shifting. + { + for i in 0..BYTE_SIZE { + cols.shift_by_n_bits[i] = F::from_bool(num_bits_to_shift == i); + } + let carry_multiplier = 1 << (8 - num_bits_to_shift); + let mut last_carry = 0u32; + let mut bit_shift_result = [0u8; LONG_WORD_SIZE]; + let mut shr_carry_output_carry = [0u8; LONG_WORD_SIZE]; + let mut shr_carry_output_shifted_byte = [0u8; LONG_WORD_SIZE]; + for i in (0..LONG_WORD_SIZE).rev() { + let (shift, carry) = shr_carry(byte_shift_result[i], num_bits_to_shift as u8); + + let byte_event = ByteLookupEvent { + shard: event.shard, + channel: event.channel, + opcode: ByteOpcode::ShrCarry, + a1: shift as u32, + a2: carry as u32, + b: byte_shift_result[i] as u32, + c: num_bits_to_shift as u32, + }; + blu.add_byte_lookup_event(byte_event); + + shr_carry_output_carry[i] = carry; + shr_carry_output_shifted_byte[i] = shift; + bit_shift_result[i] = ((shift as u32 + last_carry * carry_multiplier) & 0xff) as u8; + last_carry = carry as u32; + } + cols.bit_shift_result = bit_shift_result.map(F::from_canonical_u8); + cols.shr_carry_output_carry = shr_carry_output_carry.map(F::from_canonical_u8); + cols.shr_carry_output_shifted_byte = + shr_carry_output_shifted_byte.map(F::from_canonical_u8); + for i in 0..WORD_SIZE { + debug_assert_eq!(cols.a[i], cols.bit_shift_result[i].clone()); + } + // Range checks. + blu.add_u8_range_checks(event.shard, event.channel, &byte_shift_result); + blu.add_u8_range_checks(event.shard, event.channel, &bit_shift_result); + blu.add_u8_range_checks(event.shard, event.channel, &shr_carry_output_carry); + blu.add_u8_range_checks(event.shard, event.channel, &shr_carry_output_shifted_byte); + } + } +} + impl BaseAir for ShiftRightChip { fn width(&self) -> usize { NUM_SHIFT_RIGHT_COLS diff --git a/core/src/bytes/event.rs b/core/src/bytes/event.rs index f45c80cfe8..874db6586b 100644 --- a/core/src/bytes/event.rs +++ b/core/src/bytes/event.rs @@ -1,6 +1,9 @@ -use std::collections::BTreeMap; - +use hashbrown::HashMap; +use itertools::Itertools; use p3_field::PrimeField32; +use p3_maybe_rayon::prelude::{ + IndexedParallelIterator, IntoParallelRefIterator, IntoParallelRefMutIterator, ParallelIterator, +}; use serde::{Deserialize, Serialize}; use super::ByteOpcode; @@ -35,10 +38,16 @@ pub trait ByteRecord { /// Adds a new `ByteLookupEvent` to the record. fn add_byte_lookup_event(&mut self, blu_event: ByteLookupEvent); + fn add_sharded_byte_lookup_events( + &mut self, + sharded_blu_events_vec: Vec<&HashMap>>, + ); + /// Adds a list of `ByteLookupEvent`s to the record. + #[inline] fn add_byte_lookup_events(&mut self, blu_events: Vec) { - for blu_event in blu_events.iter() { - self.add_byte_lookup_event(*blu_event); + for blu_event in blu_events.into_iter() { + self.add_byte_lookup_event(blu_event); } } @@ -121,6 +130,7 @@ pub trait ByteRecord { impl ByteLookupEvent { /// Creates a new `ByteLookupEvent`. + #[inline(always)] pub fn new( shard: u32, channel: u32, @@ -146,14 +156,85 @@ impl ByteRecord for Vec { fn add_byte_lookup_event(&mut self, blu_event: ByteLookupEvent) { self.push(blu_event); } + + fn add_sharded_byte_lookup_events( + &mut self, + _: Vec<&HashMap>>, + ) { + todo!() + } } -impl ByteRecord for BTreeMap> { +impl ByteRecord for HashMap> { + #[inline] fn add_byte_lookup_event(&mut self, blu_event: ByteLookupEvent) { - *self - .entry(blu_event.shard) + self.entry(blu_event.shard) .or_default() .entry(blu_event) - .or_insert(0) += 1 + .and_modify(|e| *e += 1) + .or_insert(1); + } + + fn add_sharded_byte_lookup_events( + &mut self, + new_events: Vec<&HashMap>>, + ) { + add_sharded_byte_lookup_events(self, new_events); + } +} + +pub(crate) fn add_sharded_byte_lookup_events( + sharded_blu_events: &mut HashMap>, + new_events: Vec<&HashMap>>, +) { + // new_sharded_blu_map is a map of shard -> Vec multiplicities>. + // We want to collect the new events in this format so that we can do parallel aggregation + // per shard. + let mut new_sharded_blu_map: HashMap>> = + HashMap::new(); + for new_sharded_blu_events in new_events.into_iter() { + for (shard, new_blu_map) in new_sharded_blu_events.into_iter() { + new_sharded_blu_map + .entry(*shard) + .or_insert(Vec::new()) + .push(new_blu_map); + } + } + + // Collect all the shard numbers. + let shards: Vec = new_sharded_blu_map.keys().copied().collect_vec(); + + // Move ownership of self's per shard blu maps into a vec. This is so that we + // can do parallel aggregation per shard. + let mut self_blu_maps: Vec> = Vec::new(); + shards.iter().for_each(|shard| { + let blu = sharded_blu_events.remove(shard); + + match blu { + Some(blu) => { + self_blu_maps.push(blu); + } + None => { + self_blu_maps.push(HashMap::new()); + } + } + }); + + // Increment self's byte lookup events multiplicity. + shards + .par_iter() + .zip_eq(self_blu_maps.par_iter_mut()) + .for_each(|(shard, self_blu_map)| { + let blu_map_vec = new_sharded_blu_map.get(shard).unwrap(); + for blu_map in blu_map_vec.iter() { + for (blu_event, count) in blu_map.iter() { + *self_blu_map.entry(*blu_event).or_insert(0) += count; + } + } + }); + + // Move ownership of the blu maps back to self. + for (shard, blu) in shards.into_iter().zip(self_blu_maps.into_iter()) { + sharded_blu_events.insert(shard, blu); } } diff --git a/core/src/bytes/mod.rs b/core/src/bytes/mod.rs index 2cf8c8fb1c..e751bb6cb0 100644 --- a/core/src/bytes/mod.rs +++ b/core/src/bytes/mod.rs @@ -8,7 +8,6 @@ pub mod utils; pub use event::ByteLookupEvent; pub use opcode::*; -use alloc::collections::BTreeMap; use core::borrow::BorrowMut; use std::marker::PhantomData; @@ -34,19 +33,10 @@ pub const NUM_BYTE_LOOKUP_CHANNELS: u32 = 16; pub struct ByteChip(PhantomData); impl ByteChip { - /// Creates the preprocessed byte trace and event map. + /// Creates the preprocessed byte trace. /// - /// This function returns a pair `(trace, map)`, where: - /// - `trace` is a matrix containing all possible byte operations. - /// - `map` is a map from a byte lookup to the corresponding row it appears in the table and - /// the index of the result in the array of multiplicities. - pub fn trace_and_map( - shard: u32, - ) -> (RowMajorMatrix, BTreeMap) { - // A map from a byte lookup to its corresponding row in the table and index in the array of - // multiplicities. - let mut event_map = BTreeMap::new(); - + /// This function returns a `trace` which is a matrix containing all possible byte operations. + pub fn trace() -> RowMajorMatrix { // The trace containing all values, with all multiplicities set to zero. let mut initial_trace = RowMajorMatrix::new( vec![F::zero(); NUM_ROWS * NUM_BYTE_PREPROCESSED_COLS], @@ -67,9 +57,10 @@ impl ByteChip { col.c = F::from_canonical_u8(c); // Iterate over all operations for results and updating the table map. + let shard = 0; for channel in 0..NUM_BYTE_LOOKUP_CHANNELS { - for (i, opcode) in opcodes.iter().enumerate() { - let event = match opcode { + for opcode in opcodes.iter() { + match opcode { ByteOpcode::AND => { let and = b & c; col.and = F::from_canonical_u8(and); @@ -135,11 +126,25 @@ impl ByteChip { ByteLookupEvent::new(shard, channel, *opcode, v, 0, 0, 0) } }; - event_map.insert(event, (row_index, i)); } } } - (initial_trace, event_map) + initial_trace + } +} + +#[cfg(test)] +mod tests { + use p3_baby_bear::BabyBear; + use std::time::Instant; + + use super::*; + + #[test] + pub fn test_trace_and_map() { + let start = Instant::now(); + ByteChip::::trace(); + println!("trace and map: {:?}", start.elapsed()); } } diff --git a/core/src/bytes/trace.rs b/core/src/bytes/trace.rs index d6ba3921b6..abbdacdf2c 100644 --- a/core/src/bytes/trace.rs +++ b/core/src/bytes/trace.rs @@ -1,5 +1,6 @@ use std::borrow::BorrowMut; +use hashbrown::HashMap; use p3_field::Field; use p3_matrix::dense::RowMajorMatrix; @@ -9,6 +10,7 @@ use super::{ }; use crate::{ air::MachineAir, + bytes::ByteOpcode, runtime::{ExecutionRecord, Program}, }; @@ -28,10 +30,7 @@ impl MachineAir for ByteChip { } fn generate_preprocessed_trace(&self, _program: &Self::Program) -> Option> { - // OPT: We should be able to make this a constant. Also, trace / map should be separate. - // Since we only need the trace and not the map, we can just pass 0 as the shard. - let (trace, _) = Self::trace_and_map(0); - + let trace = Self::trace(); Some(trace) } @@ -44,23 +43,28 @@ impl MachineAir for ByteChip { input: &ExecutionRecord, _output: &mut ExecutionRecord, ) -> RowMajorMatrix { - let shard = input.index; - let (_, event_map) = Self::trace_and_map(shard); - let mut trace = RowMajorMatrix::new( vec![F::zero(); NUM_BYTE_MULT_COLS * NUM_ROWS], NUM_BYTE_MULT_COLS, ); - for (lookup, mult) in input.byte_lookups[&shard].iter() { - let (row, index) = event_map[lookup]; + let shard = input.public_values.execution_shard; + for (lookup, mult) in input + .byte_lookups + .get(&shard) + .unwrap_or(&HashMap::new()) + .iter() + { + let row = if lookup.opcode != ByteOpcode::U16Range { + ((lookup.b << 8) + lookup.c) as usize + } else { + lookup.a1 as usize + }; + let index = lookup.opcode as usize; let channel = lookup.channel as usize; - let cols: &mut ByteMultCols = trace.row_mut(row).borrow_mut(); - // Update the trace multiplicity + let cols: &mut ByteMultCols = trace.row_mut(row).borrow_mut(); cols.mult_channels[channel].multiplicities[index] += F::from_canonical_usize(*mult); - - // Set the shard column as the current shard. cols.shard = F::from_canonical_u32(shard); } diff --git a/core/src/cpu/air/ecall.rs b/core/src/cpu/air/ecall.rs index 870513b83e..ff7cda017f 100644 --- a/core/src/cpu/air/ecall.rs +++ b/core/src/cpu/air/ecall.rs @@ -5,7 +5,7 @@ use crate::air::{BaseAirBuilder, PublicValues, WordAirBuilder}; use crate::cpu::air::{Word, POSEIDON_NUM_WORDS, PV_DIGEST_NUM_WORDS}; use crate::cpu::columns::{CpuCols, OpcodeSelectorCols}; use crate::memory::MemoryCols; -use crate::operations::IsZeroOperation; +use crate::operations::{BabyBearWordRangeChecker, IsZeroOperation}; use crate::runtime::SyscallCode; use crate::stark::{CpuChip, SP1AirBuilder}; @@ -88,6 +88,21 @@ impl CpuChip { .when(is_ecall_instruction.clone()) .when_not(is_enter_unconstrained + is_hint_len) .assert_word_eq(local.op_a_val(), local.op_a_access.prev_value); + + // Verify value of ecall_range_check_operand column. + builder.assert_eq( + local.ecall_range_check_operand, + is_ecall_instruction + * (ecall_cols.is_halt.result + ecall_cols.is_commit_deferred_proofs.result), + ); + + // Babybear range check the operand_to_check word. + BabyBearWordRangeChecker::::range_check::( + builder, + ecall_cols.operand_to_check, + ecall_cols.operand_range_check_cols, + local.ecall_range_check_operand.into(), + ); } /// Constraints related to the COMMIT and COMMIT_DEFERRED_PROOFS instructions. @@ -160,13 +175,18 @@ impl CpuChip { .when(local.selectors.is_ecall * is_commit) .assert_word_eq(expected_pv_digest_word, *digest_word); - let expected_deferred_proofs_digest_word = + let expected_deferred_proofs_digest_element = builder.index_array(&deferred_proofs_digest, &ecall_columns.index_bitmap); + // Verify that the operand that was range checked is digest_word. + builder + .when(local.selectors.is_ecall * is_commit_deferred_proofs.clone()) + .assert_word_eq(*digest_word, ecall_columns.operand_to_check); + builder .when(local.selectors.is_ecall * is_commit_deferred_proofs) .assert_eq( - expected_deferred_proofs_digest_word, + expected_deferred_proofs_digest_element, digest_word.reduce::(), ); } @@ -189,6 +209,12 @@ impl CpuChip { builder.when(is_halt.clone()).assert_zero(local.next_pc); + // Verify that the operand that was range checked is op_b. + let ecall_columns = local.opcode_specific_columns.ecall(); + builder + .when(is_halt.clone()) + .assert_word_eq(local.op_b_val(), ecall_columns.operand_to_check); + builder.when(is_halt.clone()).assert_eq( local.op_b_access.value().reduce::(), public_values.exit_code.clone(), diff --git a/core/src/cpu/air/mod.rs b/core/src/cpu/air/mod.rs index 4caebbbf73..05d6a3fdc3 100644 --- a/core/src/cpu/air/mod.rs +++ b/core/src/cpu/air/mod.rs @@ -4,7 +4,6 @@ pub mod memory; pub mod register; use core::borrow::Borrow; -use itertools::Itertools; use p3_air::Air; use p3_air::AirBuilder; use p3_air::AirBuilderWithPublicValues; @@ -18,6 +17,7 @@ use crate::air::SP1AirBuilder; use crate::air::Word; use crate::air::POSEIDON_NUM_WORDS; use crate::air::PV_DIGEST_NUM_WORDS; +use crate::air::SP1_PROOF_NUM_PV_ELTS; use crate::bytes::ByteOpcode; use crate::cpu::columns::OpcodeSelectorCols; use crate::cpu::columns::{CpuCols, NUM_CPU_COLS}; @@ -39,13 +39,10 @@ where let (local, next) = (main.row_slice(0), main.row_slice(1)); let local: &CpuCols = (*local).borrow(); let next: &CpuCols = (*next).borrow(); - let public_values = PublicValues::, AB::Expr>::from_vec( - builder - .public_values() - .iter() - .map(|elm| (*elm).into()) - .collect_vec(), - ); + let public_values_slice: [AB::Expr; SP1_PROOF_NUM_PV_ELTS] = + core::array::from_fn(|i| builder.public_values()[i].into()); + let public_values: &PublicValues, AB::Expr> = + public_values_slice.as_slice().borrow(); // Program constraints. builder.send_program( @@ -112,7 +109,7 @@ where ); // HALT ecall and UNIMPL instruction. - self.eval_halt_unimpl(builder, local, next, &public_values); + self.eval_halt_unimpl(builder, local, next, public_values); // Check that the shard and clk is updated correctly. self.eval_shard_clk(builder, local, next); @@ -121,7 +118,7 @@ where self.eval_pc(builder, local, next, is_branch_instruction.clone()); // Check public values constraints. - self.eval_public_values(builder, local, next, &public_values); + self.eval_public_values(builder, local, next, public_values); // Check that the is_real flag is correct. self.eval_is_real(builder, local, next); @@ -382,7 +379,7 @@ impl CpuChip { // Verify the public value's shard. builder .when(local.is_real) - .assert_eq(public_values.shard.clone(), local.shard); + .assert_eq(public_values.execution_shard.clone(), local.shard); // Verify the public value's start pc. builder diff --git a/core/src/cpu/columns/channel.rs b/core/src/cpu/columns/channel.rs index 9bd6a4ef78..ba6f763eea 100644 --- a/core/src/cpu/columns/channel.rs +++ b/core/src/cpu/columns/channel.rs @@ -12,6 +12,7 @@ pub struct ChannelSelectorCols { } impl ChannelSelectorCols { + #[inline(always)] pub fn populate(&mut self, channel: u32) { self.channel_selectors = [F::zero(); NUM_BYTE_LOOKUP_CHANNELS as usize]; self.channel_selectors[channel as usize] = F::one(); diff --git a/core/src/cpu/columns/ecall.rs b/core/src/cpu/columns/ecall.rs index 5d91622c36..649708f19f 100644 --- a/core/src/cpu/columns/ecall.rs +++ b/core/src/cpu/columns/ecall.rs @@ -1,7 +1,10 @@ use sp1_derive::AlignedBorrow; use std::mem::size_of; -use crate::{air::PV_DIGEST_NUM_WORDS, operations::IsZeroOperation}; +use crate::{ + air::{Word, PV_DIGEST_NUM_WORDS}, + operations::{BabyBearWordRangeChecker, IsZeroOperation}, +}; pub const NUM_ECALL_COLS: usize = size_of::>(); @@ -29,4 +32,10 @@ pub struct EcallCols { /// The nonce of the syscall operation. pub syscall_nonce: T, + + /// Columns to babybear range check the halt/commit_deferred_proofs operand. + pub operand_range_check_cols: BabyBearWordRangeChecker, + + /// The operand value to babybear range check. + pub operand_to_check: Word, } diff --git a/core/src/cpu/columns/mod.rs b/core/src/cpu/columns/mod.rs index 968c58362f..e0ceec7aa2 100644 --- a/core/src/cpu/columns/mod.rs +++ b/core/src/cpu/columns/mod.rs @@ -104,6 +104,9 @@ pub struct CpuCols { /// The result of selectors.is_ecall * the send_to_table column for the ECALL opcode. pub ecall_mul_send_to_table: T, + /// The result of selectors.is_ecall * (is_halt || is_commit_deferred_proofs) + pub ecall_range_check_operand: T, + /// This is true for all instructions that are not jumps, branches, and halt. Those instructions /// may move the program counter to a non sequential instruction. pub is_sequential_instr: T, diff --git a/core/src/cpu/event.rs b/core/src/cpu/event.rs index cdd38f4765..2e68eddbf7 100644 --- a/core/src/cpu/event.rs +++ b/core/src/cpu/event.rs @@ -52,14 +52,14 @@ pub struct CpuEvent { /// Exit code called with halt. pub exit_code: u32, - pub alu_lookup_id: usize, - pub syscall_lookup_id: usize, - pub memory_add_lookup_id: usize, - pub memory_sub_lookup_id: usize, - pub branch_gt_lookup_id: usize, - pub branch_lt_lookup_id: usize, - pub branch_add_lookup_id: usize, - pub jump_jal_lookup_id: usize, - pub jump_jalr_lookup_id: usize, - pub auipc_lookup_id: usize, + pub alu_lookup_id: u128, + pub syscall_lookup_id: u128, + pub memory_add_lookup_id: u128, + pub memory_sub_lookup_id: u128, + pub branch_gt_lookup_id: u128, + pub branch_lt_lookup_id: u128, + pub branch_add_lookup_id: u128, + pub jump_jal_lookup_id: u128, + pub jump_jalr_lookup_id: u128, + pub auipc_lookup_id: u128, } diff --git a/core/src/cpu/mod.rs b/core/src/cpu/mod.rs index fbb3914879..c9c513ab64 100644 --- a/core/src/cpu/mod.rs +++ b/core/src/cpu/mod.rs @@ -5,6 +5,9 @@ pub mod trace; pub use event::*; +/// The maximum log degree of the CPU chip to avoid lookup multiplicity overflow. +pub const MAX_CPU_LOG_DEGREE: usize = 22; + /// A chip that implements the CPU. #[derive(Default)] pub struct CpuChip; diff --git a/core/src/cpu/trace.rs b/core/src/cpu/trace.rs index 893faa385e..2029629774 100644 --- a/core/src/cpu/trace.rs +++ b/core/src/cpu/trace.rs @@ -1,10 +1,12 @@ +use hashbrown::HashMap; +use itertools::Itertools; use std::array; use std::borrow::BorrowMut; -use std::collections::HashMap; use p3_field::{PrimeField, PrimeField32}; use p3_matrix::dense::RowMajorMatrix; -use p3_maybe_rayon::prelude::IntoParallelRefIterator; +use p3_maybe_rayon::prelude::IntoParallelRefMutIterator; +use p3_maybe_rayon::prelude::ParallelBridge; use p3_maybe_rayon::prelude::ParallelIterator; use p3_maybe_rayon::prelude::ParallelSlice; use tracing::instrument; @@ -36,46 +38,33 @@ impl MachineAir for CpuChip { fn generate_trace( &self, input: &ExecutionRecord, - output: &mut ExecutionRecord, + _: &mut ExecutionRecord, ) -> RowMajorMatrix { - let mut new_alu_events = HashMap::new(); - let mut new_blu_events = Vec::new(); - - // Generate the trace rows for each event. - let mut rows_with_events = input - .cpu_events - .par_iter() - .map(|op: &CpuEvent| self.event_to_row::(*op, &input.nonce_lookup)) - .collect::>(); - - // No need to sort by the shard, since the cpu events are already partitioned by that. - rows_with_events.sort_unstable_by_key(|(event, _, _)| event[CPU_COL_MAP.clk]); - - let mut rows = Vec::::new(); - rows_with_events.into_iter().for_each(|row_with_events| { - let (row, alu_events, blu_events) = row_with_events; - rows.extend(row); - for (key, value) in alu_events { - new_alu_events - .entry(key) - .and_modify(|op_new_events: &mut Vec| { - op_new_events.extend(value.clone()) - }) - .or_insert(value); - } - new_blu_events.extend(blu_events); - }); + let mut values = vec![F::zero(); input.cpu_events.len() * NUM_CPU_COLS]; - // Add the dependency events to the shard. - for (_, value) in new_alu_events.iter_mut() { - value.sort_unstable_by_key(|event| event.clk); - } - new_blu_events.sort_unstable_by_key(|event| event.a1); - output.add_alu_events(new_alu_events); - output.add_byte_lookup_events(new_blu_events); + let chunk_size = std::cmp::max(input.cpu_events.len() / num_cpus::get(), 1); + values + .chunks_mut(chunk_size * NUM_CPU_COLS) + .enumerate() + .par_bridge() + .for_each(|(i, rows)| { + rows.chunks_mut(NUM_CPU_COLS) + .enumerate() + .for_each(|(j, row)| { + let idx = i * chunk_size + j; + let cols: &mut CpuCols = row.borrow_mut(); + let mut byte_lookup_events = Vec::new(); + self.event_to_row( + &input.cpu_events[idx], + &input.nonce_lookup, + cols, + &mut byte_lookup_events, + ); + }); + }); // Convert the trace to a row major matrix. - let mut trace = RowMajorMatrix::new(rows, NUM_CPU_COLS); + let mut trace = RowMajorMatrix::new(values, NUM_CPU_COLS); // Pad the trace to a power of two. Self::pad_to_power_of_two::(&mut trace.values); @@ -87,38 +76,35 @@ impl MachineAir for CpuChip { fn generate_dependencies(&self, input: &ExecutionRecord, output: &mut ExecutionRecord) { // Generate the trace rows for each event. let chunk_size = std::cmp::max(input.cpu_events.len() / num_cpus::get(), 1); - let events = input + + let (alu_events, blu_events): (Vec<_>, Vec<_>) = input .cpu_events .par_chunks(chunk_size) .map(|ops: &[CpuEvent]| { let mut alu = HashMap::new(); - let mut blu: Vec<_> = Vec::default(); + // The blu map stores shard -> map(byte lookup event -> multiplicity). + let mut blu: HashMap> = HashMap::new(); ops.iter().for_each(|op| { - let (_, alu_events, blu_events) = self.event_to_row::(*op, &HashMap::new()); + let mut row = [F::zero(); NUM_CPU_COLS]; + let cols: &mut CpuCols = row.as_mut_slice().borrow_mut(); + let alu_events = self.event_to_row::(op, &HashMap::new(), cols, &mut blu); alu_events.into_iter().for_each(|(key, value)| { alu.entry(key).or_insert(Vec::default()).extend(value); }); - blu.extend(blu_events); }); (alu, blu) }) - .collect::>(); + .unzip(); - events - .into_iter() - .for_each(|(mut alu_events, mut blu_events)| { - for (_, value) in alu_events.iter_mut() { - value.sort_unstable_by_key(|event| event.clk); - } - // Add the dependency events to the shard. - output.add_alu_events(alu_events); - blu_events.sort_unstable_by_key(|event| event.a1); - output.add_byte_lookup_events(blu_events); - }); + for alu_events_chunk in alu_events.into_iter() { + output.add_alu_events(alu_events_chunk); + } + + output.add_sharded_byte_lookup_events(blu_events.iter().collect_vec()); } - fn included(&self, _: &Self::Record) -> bool { - true + fn included(&self, input: &Self::Record) -> bool { + !input.cpu_events.is_empty() } } @@ -126,21 +112,15 @@ impl CpuChip { /// Create a row from an event. fn event_to_row( &self, - event: CpuEvent, - nonce_lookup: &HashMap, - ) -> ( - [F; NUM_CPU_COLS], - HashMap>, - Vec, - ) { + event: &CpuEvent, + nonce_lookup: &HashMap, + cols: &mut CpuCols, + blu_events: &mut impl ByteRecord, + ) -> HashMap> { let mut new_alu_events = HashMap::new(); - let mut new_blu_events = Vec::new(); - - let mut row = [F::zero(); NUM_CPU_COLS]; - let cols: &mut CpuCols = row.as_mut_slice().borrow_mut(); // Populate shard and clk columns. - self.populate_shard_clk(cols, event, &mut new_blu_events); + self.populate_shard_clk(cols, event, blu_events); // Populate the nonce. cols.nonce = F::from_canonical_u32( @@ -161,16 +141,13 @@ impl CpuChip { // Populate memory accesses for a, b, and c. if let Some(record) = event.a_record { - cols.op_a_access - .populate(event.channel, record, &mut new_blu_events); + cols.op_a_access.populate(event.channel, record, blu_events); } if let Some(MemoryRecordEnum::Read(record)) = event.b_record { - cols.op_b_access - .populate(event.channel, record, &mut new_blu_events); + cols.op_b_access.populate(event.channel, record, blu_events); } if let Some(MemoryRecordEnum::Read(record)) = event.c_record { - cols.op_c_access - .populate(event.channel, record, &mut new_blu_events); + cols.op_c_access.populate(event.channel, record, blu_events); } // Populate range checks for a. @@ -182,7 +159,7 @@ impl CpuChip { .iter() .map(|x| x.as_canonical_u32()) .collect::>(); - new_blu_events.push(ByteLookupEvent { + blu_events.add_byte_lookup_event(ByteLookupEvent { shard: event.shard, channel: event.channel, opcode: ByteOpcode::U8Range, @@ -191,7 +168,7 @@ impl CpuChip { b: a_bytes[0], c: a_bytes[1], }); - new_blu_events.push(ByteLookupEvent { + blu_events.add_byte_lookup_event(ByteLookupEvent { shard: event.shard, channel: event.channel, opcode: ByteOpcode::U8Range, @@ -207,17 +184,11 @@ impl CpuChip { if let Some(record) = event.memory_record { memory_columns .memory_access - .populate(event.channel, record, &mut new_blu_events) + .populate(event.channel, record, blu_events) } // Populate memory, branch, jump, and auipc specific fields. - self.populate_memory( - cols, - event, - &mut new_alu_events, - &mut new_blu_events, - nonce_lookup, - ); + self.populate_memory(cols, event, &mut new_alu_events, blu_events, nonce_lookup); self.populate_branch(cols, event, &mut new_alu_events, nonce_lookup); self.populate_jump(cols, event, &mut new_alu_events, nonce_lookup); self.populate_auipc(cols, event, &mut new_alu_events, nonce_lookup); @@ -232,20 +203,28 @@ impl CpuChip { // Assert that the instruction is not a no-op. cols.is_real = F::one(); - (row, new_alu_events, new_blu_events) + new_alu_events } /// Populates the shard, channel, and clk related rows. fn populate_shard_clk( &self, cols: &mut CpuCols, - event: CpuEvent, - new_blu_events: &mut Vec, + event: &CpuEvent, + blu_events: &mut impl ByteRecord, ) { cols.shard = F::from_canonical_u32(event.shard); cols.channel = F::from_canonical_u32(event.channel); + cols.clk = F::from_canonical_u32(event.clk); + + let clk_16bit_limb = event.clk & 0xffff; + let clk_8bit_limb = (event.clk >> 16) & 0xff; + cols.clk_16bit_limb = F::from_canonical_u32(clk_16bit_limb); + cols.clk_8bit_limb = F::from_canonical_u32(clk_8bit_limb); + cols.channel_selectors.populate(event.channel); - new_blu_events.push(ByteLookupEvent::new( + + blu_events.add_byte_lookup_event(ByteLookupEvent::new( event.shard, event.channel, U16Range, @@ -254,13 +233,7 @@ impl CpuChip { 0, 0, )); - - cols.clk = F::from_canonical_u32(event.clk); - let clk_16bit_limb = event.clk & 0xffff; - cols.clk_16bit_limb = F::from_canonical_u32(clk_16bit_limb); - let clk_8bit_limb = (event.clk >> 16) & 0xff; - cols.clk_8bit_limb = F::from_canonical_u32(clk_8bit_limb); - new_blu_events.push(ByteLookupEvent::new( + blu_events.add_byte_lookup_event(ByteLookupEvent::new( event.shard, event.channel, U16Range, @@ -269,7 +242,7 @@ impl CpuChip { 0, 0, )); - new_blu_events.push(ByteLookupEvent::new( + blu_events.add_byte_lookup_event(ByteLookupEvent::new( event.shard, event.channel, U8Range, @@ -284,10 +257,10 @@ impl CpuChip { fn populate_memory( &self, cols: &mut CpuCols, - event: CpuEvent, + event: &CpuEvent, new_alu_events: &mut HashMap>, - new_blu_events: &mut Vec, - nonce_lookup: &HashMap, + blu_events: &mut impl ByteRecord, + nonce_lookup: &HashMap, ) { if !matches!( event.instruction.opcode, @@ -420,7 +393,7 @@ impl CpuChip { // Add event to byte lookup for byte range checking each byte in the memory addr let addr_bytes = memory_addr.to_le_bytes(); for byte_pair in addr_bytes.chunks_exact(2) { - new_blu_events.push(ByteLookupEvent { + blu_events.add_byte_lookup_event(ByteLookupEvent { shard: event.shard, channel: event.channel, opcode: ByteOpcode::U8Range, @@ -436,9 +409,9 @@ impl CpuChip { fn populate_branch( &self, cols: &mut CpuCols, - event: CpuEvent, + event: &CpuEvent, alu_events: &mut HashMap>, - nonce_lookup: &HashMap, + nonce_lookup: &HashMap, ) { if event.instruction.is_branch_instruction() { let branch_columns = cols.opcode_specific_columns.branch_mut(); @@ -565,9 +538,9 @@ impl CpuChip { fn populate_jump( &self, cols: &mut CpuCols, - event: CpuEvent, + event: &CpuEvent, alu_events: &mut HashMap>, - nonce_lookup: &HashMap, + nonce_lookup: &HashMap, ) { if event.instruction.is_jump_instruction() { let jump_columns = cols.opcode_specific_columns.jump_mut(); @@ -642,9 +615,9 @@ impl CpuChip { fn populate_auipc( &self, cols: &mut CpuCols, - event: CpuEvent, + event: &CpuEvent, alu_events: &mut HashMap>, - nonce_lookup: &HashMap, + nonce_lookup: &HashMap, ) { if matches!(event.instruction.opcode, Opcode::AUIPC) { let auipc_columns = cols.opcode_specific_columns.auipc_mut(); @@ -681,8 +654,8 @@ impl CpuChip { fn populate_ecall( &self, cols: &mut CpuCols, - event: CpuEvent, - nonce_lookup: &HashMap, + event: &CpuEvent, + nonce_lookup: &HashMap, ) -> bool { let mut is_halt = false; @@ -746,6 +719,21 @@ impl CpuChip { ); is_halt = syscall_id == F::from_canonical_u32(SyscallCode::HALT.syscall_id()); + + // For halt and commit deferred proofs syscalls, we need to baby bear range check one of + // it's operands. + if is_halt { + ecall_cols.operand_to_check = event.b.into(); + ecall_cols.operand_range_check_cols.populate(event.b); + cols.ecall_range_check_operand = F::one(); + } + + if syscall_id == F::from_canonical_u32(SyscallCode::COMMIT_DEFERRED_PROOFS.syscall_id()) + { + ecall_cols.operand_to_check = event.c.into(); + ecall_cols.operand_range_check_cols.populate(event.c); + cols.ecall_range_check_operand = F::one(); + } } is_halt @@ -768,7 +756,7 @@ impl CpuChip { ) }; - rows[n_real_rows..].iter_mut().for_each(|padded_row| { + rows[n_real_rows..].par_iter_mut().for_each(|padded_row| { padded_row[CPU_COL_MAP.selectors.imm_b] = F::one(); padded_row[CPU_COL_MAP.selectors.imm_c] = F::one(); }); @@ -779,9 +767,13 @@ impl CpuChip { mod tests { use p3_baby_bear::BabyBear; + use std::time::Instant; + use super::*; + use crate::runtime::tests::ssz_withdrawals_program; use crate::runtime::{tests::simple_program, Runtime}; + use crate::stark::DefaultProver; use crate::utils::{run_test, setup_logger, SP1CoreOpts}; // #[test] @@ -819,22 +811,30 @@ mod tests { #[test] fn generate_trace_simple_program() { - let program = simple_program(); + let program = ssz_withdrawals_program(); let mut runtime = Runtime::new(program, SP1CoreOpts::default()); runtime.run().unwrap(); + println!("runtime: {:?}", runtime.state.global_clk); let chip = CpuChip::default(); - let trace: RowMajorMatrix = + + let start = Instant::now(); + >::generate_dependencies( + &chip, + &runtime.record, + &mut ExecutionRecord::default(), + ); + println!("generate dependencies: {:?}", start.elapsed()); + + let start = Instant::now(); + let _: RowMajorMatrix = chip.generate_trace(&runtime.record, &mut ExecutionRecord::default()); - for cpu_event in runtime.record.cpu_events { - println!("{:?}", cpu_event); - } - println!("{:?}", trace.values) + println!("generate trace: {:?}", start.elapsed()); } #[test] fn prove_trace() { setup_logger(); let program = simple_program(); - run_test(program).unwrap(); + run_test::>(program).unwrap(); } } diff --git a/core/src/io.rs b/core/src/io.rs index 2c4a87953c..98d8ad5154 100644 --- a/core/src/io.rs +++ b/core/src/io.rs @@ -91,7 +91,7 @@ impl SP1PublicValues { } } - pub fn bytes(&self) -> String { + pub fn raw(&self) -> String { format!("0x{}", hex::encode(self.buffer.data.clone())) } diff --git a/core/src/lib.rs b/core/src/lib.rs index ac8524027d..2e9fecd64d 100644 --- a/core/src/lib.rs +++ b/core/src/lib.rs @@ -13,8 +13,6 @@ )] #![warn(unused_extern_crates)] -extern crate alloc; - pub mod air; pub mod alu; pub mod bytes; @@ -39,4 +37,4 @@ use stark::StarkGenericConfig; /// This string should be updated whenever any step in verifying an SP1 proof changes, including /// core, recursion, and plonk-bn254. This string is used to download SP1 artifacts and the gnark /// docker image. -pub const SP1_CIRCUIT_VERSION: &str = "v1.0.8-testnet"; +pub const SP1_CIRCUIT_VERSION: &str = "v1.0.0-rc.1"; diff --git a/core/src/lookup/debug.rs b/core/src/lookup/debug.rs index f8962c5769..546ec25147 100644 --- a/core/src/lookup/debug.rs +++ b/core/src/lookup/debug.rs @@ -206,9 +206,10 @@ where #[cfg(test)] mod test { + use crate::{ lookup::InteractionKind, - runtime::{Program, Runtime, ShardingConfig}, + runtime::{Program, Runtime}, stark::RiscvAir, utils::{setup_logger, tests::UINT256_MUL_ELF, BabyBearPoseidon2, SP1CoreOpts}, }; @@ -224,7 +225,13 @@ mod test { let (pk, _) = machine.setup(&program); let mut runtime = Runtime::new(program, SP1CoreOpts::default()); runtime.run().unwrap(); - let shards = machine.shard(runtime.record, &ShardingConfig::default()); + let opts = SP1CoreOpts::default(); + machine.generate_dependencies(&mut runtime.records, &opts); + + let mut shards = runtime.records; + shards.iter_mut().enumerate().for_each(|(i, shard)| { + shard.public_values.shard = (i + 1) as u32; + }); let ok = debug_interactions_with_all_chips(&machine, &pk, &shards, InteractionKind::all_kinds()); assert!(ok); diff --git a/core/src/memory/global.rs b/core/src/memory/global.rs index a6cf49d02a..afa97c844f 100644 --- a/core/src/memory/global.rs +++ b/core/src/memory/global.rs @@ -4,21 +4,20 @@ use std::array; use p3_air::BaseAir; use p3_air::{Air, AirBuilder}; -use p3_field::AbstractField; -use p3_field::PrimeField; +use p3_field::{AbstractField, PrimeField32}; use p3_matrix::dense::RowMajorMatrix; use p3_matrix::Matrix; use sp1_derive::AlignedBorrow; use super::MemoryInitializeFinalizeEvent; -use crate::air::MachineAir; -use crate::air::{AirInteraction, BaseAirBuilder, SP1AirBuilder}; -use crate::operations::BabyBearBitDecomposition; +use crate::air::{AirInteraction, BaseAirBuilder, PublicValues, SP1AirBuilder, Word}; +use crate::air::{MachineAir, SP1_PROOF_NUM_PV_ELTS}; +use crate::operations::{AssertLtColsBits, BabyBearBitDecomposition, IsZeroOperation}; use crate::runtime::{ExecutionRecord, Program}; use crate::utils::pad_to_power_of_two; /// The type of memory chip that is being initialized. -#[derive(PartialEq)] +#[derive(Debug, Clone, Copy, PartialEq, Eq)] pub enum MemoryChipType { Initialize, Finalize, @@ -42,7 +41,7 @@ impl BaseAir for MemoryChip { } } -impl MachineAir for MemoryChip { +impl MachineAir for MemoryChip { type Record = ExecutionRecord; type Program = Program; @@ -63,6 +62,12 @@ impl MachineAir for MemoryChip { MemoryChipType::Initialize => input.memory_initialize_events.clone(), MemoryChipType::Finalize => input.memory_finalize_events.clone(), }; + + let previous_addr_bits = match self.kind { + MemoryChipType::Initialize => input.public_values.previous_init_addr_bits, + MemoryChipType::Finalize => input.public_values.previous_finalize_addr_bits, + }; + memory_events.sort_by_key(|event| event.addr); let rows: Vec<[F; NUM_MEMORY_INIT_COLS]> = (0..memory_events.len()) // OPT: change this to par_iter .map(|i| { @@ -83,25 +88,34 @@ impl MachineAir for MemoryChip { cols.value = array::from_fn(|i| F::from_canonical_u32((value >> i) & 1)); cols.is_real = F::from_canonical_u32(used); - if i != memory_events.len() - 1 { - let next_addr = memory_events[i + 1].addr; - assert_ne!(next_addr, addr); - - cols.addr_bits.populate(addr); - - cols.seen_diff_bits[0] = F::zero(); - for j in 0..32 { - let rev_j = 32 - j - 1; - let next_bit = ((next_addr >> rev_j) & 1) == 1; - let local_bit = ((addr >> rev_j) & 1) == 1; - cols.match_bits[j] = - F::from_bool((local_bit && next_bit) || (!local_bit && !next_bit)); - cols.seen_diff_bits[j + 1] = cols.seen_diff_bits[j] - + (F::one() - cols.seen_diff_bits[j]) * (F::one() - cols.match_bits[j]); - cols.not_match_and_not_seen_diff_bits[j] = - (F::one() - cols.match_bits[j]) * (F::one() - cols.seen_diff_bits[j]); + if i == 0 { + let prev_addr = previous_addr_bits + .iter() + .enumerate() + .map(|(j, bit)| bit * (1 << j)) + .sum::(); + cols.is_prev_addr_zero.populate(prev_addr); + cols.is_first_comp = F::from_bool(prev_addr != 0); + if prev_addr != 0 { + debug_assert!(prev_addr < addr, "prev_addr {} < addr {}", prev_addr, addr); + let addr_bits: [_; 32] = array::from_fn(|i| (addr >> i) & 1); + cols.lt_cols.populate(&previous_addr_bits, &addr_bits); } - assert_eq!(cols.seen_diff_bits[cols.seen_diff_bits.len() - 1], F::one()); + } + + if i != 0 { + let prev_is_real = memory_events[i - 1].used; + cols.is_next_comp = F::from_canonical_u32(prev_is_real); + let previous_addr = memory_events[i - 1].addr; + assert_ne!(previous_addr, addr); + + let addr_bits: [_; 32] = array::from_fn(|i| (addr >> i) & 1); + let prev_addr_bits: [_; 32] = array::from_fn(|i| (previous_addr >> i) & 1); + cols.lt_cols.populate(&prev_addr_bits, &addr_bits); + } + + if i == memory_events.len() - 1 { + cols.is_last_addr = F::one(); } row @@ -138,23 +152,29 @@ pub struct MemoryInitCols { /// The address of the memory access. pub addr: T, + /// Comparison assertions for address to be strictly increasing. + pub lt_cols: AssertLtColsBits, + /// A bit decomposition of `addr`. pub addr_bits: BabyBearBitDecomposition, - // Whether the i'th bit matches the next addr's bit. - pub match_bits: [T; 32], - - // Whether we've seen a different bit in the comparison. - pub seen_diff_bits: [T; 33], - - // Whether the i'th bit doesn't match the next addr's bit and we haven't seen a diff bitn yet. - pub not_match_and_not_seen_diff_bits: [T; 32], - /// The value of the memory access. pub value: [T; 32], /// Whether the memory access is a real access. pub is_real: T, + + /// Whether or not we are making the assertion `addr < addr_next`. + pub is_next_comp: T, + + /// A witness to assert whether or not we the previous address is zero. + pub is_prev_addr_zero: IsZeroOperation, + + /// Auxilary column, equal to `(1 - is_prev_addr_zero.result) * is_first_row`. + pub is_first_comp: T, + + /// A flag to inidicate the last non-padded address. An auxiliary column needed for degree 3. + pub is_last_addr: T, } pub(crate) const NUM_MEMORY_INIT_COLS: usize = size_of::>(); @@ -209,76 +229,6 @@ where )); } - // We want to assert addr < addr'. Assume seen_diff_0 = 0. - // - // match_i = (addr_i & addr'_i) || (!addr_i & !addr'_i) - // => - // match_i == addr_i * addr_i + (1 - addr_i) * (1 - addr'_i) - // - // when !match_i and !seen_diff_i, then enforce (addr_i == 0) and (addr'_i == 1). - // if seen_diff_i: - // seen_diff_{i+1} = 1 - // else: - // seen_diff_{i+1} = !match_i - // => - // builder.when(!match_i * !seen_diff_i).assert_zero(addr_i) - // builder.when(!match_i * !seen_diff_i).assert_one(addr'_i) - // seen_diff_bit_{i+1} == seen_diff_i + (1-seen_diff_i) * (1 - match_i) - // - // at the end of the algorithm, assert that we've seen a diff bit. - // => - // seen_diff_bit_{last} == 1 - - // Assert that we start with assuming that we haven't seen a diff bit. - builder.assert_zero(local.seen_diff_bits[0]); - - for i in 0..local.addr_bits.bits.len() { - // Compute the i'th msb bit's index. - let rev_i = local.addr_bits.bits.len() - i - 1; - - // Compute whether the i'th msb bit matches. - let match_i = local.addr_bits.bits[rev_i] * next.addr_bits.bits[rev_i] - + (AB::Expr::one() - local.addr_bits.bits[rev_i]) - * (AB::Expr::one() - next.addr_bits.bits[rev_i]); - builder - .when_transition() - .when(next.is_real) - .assert_eq(match_i.clone(), local.match_bits[i]); - - // Compute whether it's not a match and we haven't seen a diff bit. - let not_match_and_not_seen_diff_i = (AB::Expr::one() - local.match_bits[i]) - * (AB::Expr::one() - local.seen_diff_bits[i]); - builder.when_transition().when(next.is_real).assert_eq( - local.not_match_and_not_seen_diff_bits[i], - not_match_and_not_seen_diff_i, - ); - - // If the i'th msb bit doesn't match and it's the first time we've seen a diff bit, - // then enforce that the next bit is one and the current bit is zero. - builder - .when_transition() - .when(local.not_match_and_not_seen_diff_bits[i]) - .when(next.is_real) - .assert_zero(local.addr_bits.bits[rev_i]); - builder - .when_transition() - .when(local.not_match_and_not_seen_diff_bits[i]) - .when(next.is_real) - .assert_one(next.addr_bits.bits[rev_i]); - - // Update the seen diff bits. - builder.when_transition().assert_eq( - local.seen_diff_bits[i + 1], - local.seen_diff_bits[i] + local.not_match_and_not_seen_diff_bits[i], - ); - } - - // Assert that on rows where the next row is real, we've seen a diff bit. - builder - .when_transition() - .when(next.is_real) - .assert_one(local.seen_diff_bits[local.addr_bits.bits.len()]); - // Canonically decompose the address into bits so we can do comparisons. BabyBearBitDecomposition::::range_check( builder, @@ -287,28 +237,156 @@ where local.is_real.into(), ); + // Assertion for increasing address. We need to make two types of less-than assertions, + // first we ned to assert that the addr < addr' when the next row is real. Then we need to + // make assertions with regards to public values. + // + // If the chip is a `MemoryInit`: + // - In the first row, we need to assert that previous_init_addr < addr. + // - In the last real row, we need to assert that addr = last_init_addr. + // + // If the chip is a `MemoryFinalize`: + // - In the first row, we need to assert that previous_finalize_addr < addr. + // - In the last real row, we need to assert that addr = last_finalize_addr. + + // Assert that addr < addr' when the next row is real. + builder + .when_transition() + .assert_eq(next.is_next_comp, next.is_real); + next.lt_cols.eval( + builder, + &local.addr_bits.bits, + &next.addr_bits.bits, + next.is_next_comp, + ); + // Assert that the real rows are all padded to the top. builder .when_transition() .when_not(local.is_real) .assert_zero(next.is_real); + // Make assertions for the initial comparison. + + // We want to constrain that the `adrr` in the first row is larger than the previous + // initialized/finalized address, unless the previous address is zero. Since the previous + // address is either zero or constrained by a different shard, we know it's an element of + // the field, so we can get an element from the bit decomposition with no concern for + // overflow. + + let local_addr_bits = local.addr_bits.bits; + + let public_values_array: [AB::Expr; SP1_PROOF_NUM_PV_ELTS] = + array::from_fn(|i| builder.public_values()[i].into()); + let public_values: &PublicValues, AB::Expr> = + public_values_array.as_slice().borrow(); + + let prev_addr_bits = match self.kind { + MemoryChipType::Initialize => &public_values.previous_init_addr_bits, + MemoryChipType::Finalize => &public_values.previous_finalize_addr_bits, + }; + + // Since the previous address is either zero or constrained by a different shard, we know + // it's an element of the field, so we can get an element from the bit decomposition with + // no concern for overflow. + let prev_addr = prev_addr_bits + .iter() + .enumerate() + .map(|(i, bit)| bit.clone() * AB::F::from_wrapped_u32(1 << i)) + .sum::(); + + // Constrain the is_prev_addr_zero operation only in the first row. + let is_first_row = builder.is_first_row(); + IsZeroOperation::::eval(builder, prev_addr, local.is_prev_addr_zero, is_first_row); + + // Constrain the is_first_comp column. + builder.assert_bool(local.is_first_comp); + builder.when_first_row().assert_eq( + local.is_first_comp, + AB::Expr::one() - local.is_prev_addr_zero.result, + ); + + // Ensure at least one real row. + builder.when_first_row().assert_one(local.is_real); + + // Constrain the inequality assertion in the first row. + local.lt_cols.eval( + builder, + prev_addr_bits, + &local_addr_bits, + local.is_first_comp, + ); + + // Insure that there are no duplicate initializations by assuring there is exactly one + // initialization event of the zero address. This is done by assuring that when the previous + // address is zero, then the first row address is also zero, and that the second row is also + // real, and the less than comparison is being made. + builder + .when_first_row() + .when(local.is_prev_addr_zero.result) + .assert_zero(local.addr); + builder + .when_first_row() + .when(local.is_prev_addr_zero.result) + .assert_one(next.is_real); + // Ensure that in the address zero case the comparison is being made so that there is an + // address bigger than zero being committed to. + builder + .when_first_row() + .when(local.is_prev_addr_zero.result) + .assert_one(next.is_next_comp); + + // Make assertions for specific types of memory chips. + if self.kind == MemoryChipType::Initialize { builder .when(local.is_real) .assert_eq(local.timestamp, AB::F::one()); } + // Constraints related to register %x0. + // Register %x0 should always be 0. See 2.6 Load and Store Instruction on - // P.18 of the RISC-V spec. To ensure that, we expect that the first row of the Initialize - // and Finalize global memory chip is for register %x0 (i.e. addr = 0x0), and that those rows - // have a value of 0. Additionally, in the CPU air, we ensure that whenever op_a is set to - // %x0, its value is 0. - if self.kind == MemoryChipType::Initialize || self.kind == MemoryChipType::Finalize { - builder.when_first_row().assert_zero(local.addr); - for i in 0..32 { - builder.when_first_row().assert_zero(local.value[i]); - } + // P.18 of the RISC-V spec. To ensure that, we will constain that the value is zero + // whenever the `is_first_comp` flag is set to to zero as well. This guarantees that the + // presence of this flag asserts the initialization/finalization of %x0 to zero. + // + // **Remark**: it is up to the verifier to ensure that this flag is set to zero exactly + // once, this can be constrained by the public values setting `previous_init_addr_bits` or + // `previous_finalize_addr_bits` to zero. + for i in 0..32 { + builder + .when_first_row() + .when_not(local.is_first_comp) + .assert_zero(local.value[i]); + } + + // Make assertions for the final value. We need to connect the final valid address to the + // correspinding `last_addr` value. + let last_addr_bits = match self.kind { + MemoryChipType::Initialize => &public_values.last_init_addr_bits, + MemoryChipType::Finalize => &public_values.last_finalize_addr_bits, + }; + // The last address is either: + // - It's the last row and `is_real` is set to one. + // - The flag `is_real` is set to one and the next `is_real` is set to zero. + + // Constrain the `is_last_addr` flag. + builder.when_transition().assert_eq( + local.is_last_addr, + local.is_real * (AB::Expr::one() - next.is_real), + ); + + // Constrain the last address bits to be equal to the corresponding `last_addr_bits` value. + for (local_bit, pub_bit) in local.addr_bits.bits.iter().zip(last_addr_bits.iter()) { + builder + .when_last_row() + .when(local.is_real) + .assert_eq(*local_bit, pub_bit.clone()); + builder + .when_transition() + .when(local.is_last_addr) + .assert_eq(*local_bit, pub_bit.clone()); } } } @@ -320,11 +398,9 @@ mod tests { use crate::lookup::{debug_interactions_with_all_chips, InteractionKind}; use crate::runtime::tests::simple_program; use crate::runtime::Runtime; - use crate::stark::MachineRecord; - use crate::stark::{RiscvAir, StarkGenericConfig}; + use crate::stark::RiscvAir; use crate::syscall::precompiles::sha256::extend_tests::sha_extend_program; use crate::utils::{setup_logger, BabyBearPoseidon2, SP1CoreOpts}; - use crate::utils::{uni_stark_prove as prove, uni_stark_verify as verify}; use p3_baby_bear::BabyBear; #[test] @@ -350,25 +426,6 @@ mod tests { } } - #[test] - fn test_memory_prove_babybear() { - let config = BabyBearPoseidon2::new(); - let mut challenger = config.challenger(); - - let program = simple_program(); - let mut runtime = Runtime::new(program, SP1CoreOpts::default()); - runtime.run().unwrap(); - - let chip = MemoryChip::new(MemoryChipType::Initialize); - - let trace: RowMajorMatrix = - chip.generate_trace(&runtime.record, &mut ExecutionRecord::default()); - let proof = prove::(&config, &chip, &mut challenger, trace); - - let mut challenger = config.challenger(); - verify(&config, &chip, &mut challenger, &proof).unwrap(); - } - #[test] fn test_memory_lookup_interactions() { setup_logger(); @@ -379,11 +436,11 @@ mod tests { let machine: crate::stark::StarkMachine> = RiscvAir::machine(BabyBearPoseidon2::new()); let (pkey, _) = machine.setup(&program_clone); - let shards = machine.shard( - runtime.record, - &::Config::default(), - ); - assert_eq!(shards.len(), 1); + let opts = SP1CoreOpts::default(); + machine.generate_dependencies(&mut runtime.records, &opts); + + let shards = runtime.records; + assert_eq!(shards.len(), 2); debug_interactions_with_all_chips::>( &machine, &pkey, @@ -401,11 +458,11 @@ mod tests { runtime.run().unwrap(); let machine = RiscvAir::machine(BabyBearPoseidon2::new()); let (pkey, _) = machine.setup(&program_clone); - let shards = machine.shard( - runtime.record, - &::Config::default(), - ); - assert_eq!(shards.len(), 1); + let opts = SP1CoreOpts::default(); + machine.generate_dependencies(&mut runtime.records, &opts); + + let shards = runtime.records; + assert_eq!(shards.len(), 2); debug_interactions_with_all_chips::>( &machine, &pkey, diff --git a/core/src/memory/mod.rs b/core/src/memory/mod.rs index 4246db14c8..90198d541e 100644 --- a/core/src/memory/mod.rs +++ b/core/src/memory/mod.rs @@ -26,7 +26,7 @@ impl MemoryInitializeFinalizeEvent { Self { addr, value, - shard: 0, + shard: 1, timestamp: 1, used: if used { 1 } else { 0 }, } diff --git a/core/src/memory/program.rs b/core/src/memory/program.rs index ace3a6c219..3adf5aec1f 100644 --- a/core/src/memory/program.rs +++ b/core/src/memory/program.rs @@ -8,7 +8,7 @@ use p3_matrix::Matrix; use sp1_derive::AlignedBorrow; -use crate::air::{AirInteraction, PublicValues, SP1AirBuilder}; +use crate::air::{AirInteraction, PublicValues, SP1AirBuilder, SP1_PROOF_NUM_PV_ELTS}; use crate::air::{MachineAir, Word}; use crate::operations::IsZeroOperation; use crate::runtime::{ExecutionRecord, Program}; @@ -109,7 +109,7 @@ impl MachineAir for MemoryProgramChip { .copied() .collect::>(); - let mult = if input.index == 1 { + let mult = if input.public_values.shard == 1 { F::one() } else { F::zero() @@ -122,7 +122,7 @@ impl MachineAir for MemoryProgramChip { let mut row = [F::zero(); NUM_MEMORY_PROGRAM_MULT_COLS]; let cols: &mut MemoryProgramMultCols = row.as_mut_slice().borrow_mut(); cols.multiplicity = mult; - cols.is_first_shard.populate(input.index - 1); + cols.is_first_shard.populate(input.public_values.shard - 1); row }) .collect::>(); @@ -165,18 +165,15 @@ where let mult_local: &MemoryProgramMultCols = (*mult_local).borrow(); // Get shard from public values and evaluate whether it is the first shard. - let public_values = PublicValues::, AB::Expr>::from_vec( - builder - .public_values() - .iter() - .map(|elm| (*elm).into()) - .collect::>(), - ); + let public_values_slice: [AB::Expr; SP1_PROOF_NUM_PV_ELTS] = + core::array::from_fn(|i| builder.public_values()[i].into()); + let public_values: &PublicValues, AB::Expr> = + public_values_slice.as_slice().borrow(); // Constrain `is_first_shard` to be 1 if and only if the shard is the first shard. IsZeroOperation::::eval( builder, - public_values.shard - AB::F::one(), + public_values.shard.clone() - AB::F::one(), mult_local.is_first_shard, prep_local.is_real.into(), ); diff --git a/core/src/operations/add.rs b/core/src/operations/add.rs index 27f002db3f..0ede31dd93 100644 --- a/core/src/operations/add.rs +++ b/core/src/operations/add.rs @@ -1,7 +1,6 @@ use crate::air::SP1AirBuilder; use crate::air::Word; use crate::bytes::event::ByteRecord; -use crate::runtime::ExecutionRecord; use p3_air::AirBuilder; use p3_field::AbstractField; @@ -22,7 +21,7 @@ pub struct AddOperation { impl AddOperation { pub fn populate( &mut self, - record: &mut ExecutionRecord, + record: &mut impl ByteRecord, shard: u32, channel: u32, a_u32: u32, diff --git a/core/src/operations/add4.rs b/core/src/operations/add4.rs index f3066a3851..39449571b7 100644 --- a/core/src/operations/add4.rs +++ b/core/src/operations/add4.rs @@ -7,7 +7,6 @@ use crate::air::SP1AirBuilder; use crate::air::Word; use crate::air::WORD_SIZE; use crate::bytes::event::ByteRecord; -use crate::runtime::ExecutionRecord; /// A set of columns needed to compute the add of four words. #[derive(AlignedBorrow, Default, Debug, Clone, Copy)] @@ -36,7 +35,7 @@ impl Add4Operation { #[allow(clippy::too_many_arguments)] pub fn populate( &mut self, - record: &mut ExecutionRecord, + record: &mut impl ByteRecord, shard: u32, channel: u32, a_u32: u32, diff --git a/core/src/operations/add5.rs b/core/src/operations/add5.rs index 00da26bf84..b25c41243b 100644 --- a/core/src/operations/add5.rs +++ b/core/src/operations/add5.rs @@ -7,7 +7,6 @@ use crate::air::SP1AirBuilder; use crate::air::Word; use crate::air::WORD_SIZE; use crate::bytes::event::ByteRecord; -use crate::runtime::ExecutionRecord; /// A set of columns needed to compute the sum of five words. #[derive(AlignedBorrow, Default, Debug, Clone, Copy)] @@ -39,7 +38,7 @@ impl Add5Operation { #[allow(clippy::too_many_arguments)] pub fn populate( &mut self, - record: &mut ExecutionRecord, + record: &mut impl ByteRecord, shard: u32, channel: u32, a_u32: u32, diff --git a/core/src/operations/and.rs b/core/src/operations/and.rs index adeade4190..947c2d1384 100644 --- a/core/src/operations/and.rs +++ b/core/src/operations/and.rs @@ -8,7 +8,6 @@ use crate::bytes::event::ByteRecord; use crate::bytes::ByteLookupEvent; use crate::bytes::ByteOpcode; use crate::disassembler::WORD_SIZE; -use crate::runtime::ExecutionRecord; /// A set of columns needed to compute the and of two words. #[derive(AlignedBorrow, Default, Debug, Clone, Copy)] @@ -21,7 +20,7 @@ pub struct AndOperation { impl AndOperation { pub fn populate( &mut self, - record: &mut ExecutionRecord, + record: &mut impl ByteRecord, shard: u32, channel: u32, x: u32, diff --git a/core/src/operations/field/field_sqrt.rs b/core/src/operations/field/field_sqrt.rs index e16de147bd..802cb395a5 100644 --- a/core/src/operations/field/field_sqrt.rs +++ b/core/src/operations/field/field_sqrt.rs @@ -6,8 +6,8 @@ use p3_field::PrimeField32; use sp1_derive::AlignedBorrow; use super::field_op::FieldOpCols; -use super::params::Limbs; -use super::range::FieldRangeCols; +use super::params::{limbs_from_vec, Limbs}; +use super::range::FieldLtCols; use crate::air::SP1AirBuilder; use crate::bytes::event::ByteRecord; use crate::bytes::{ByteLookupEvent, ByteOpcode}; @@ -27,7 +27,7 @@ pub struct FieldSqrtCols { /// since we'll receive the input again in the `eval` function. pub multiplication: FieldOpCols, - pub range: FieldRangeCols, + pub range: FieldLtCols, // The least significant bit of the square root. pub lsb: T, @@ -67,7 +67,7 @@ impl FieldSqrtCols { self.multiplication.result = P::to_limbs_field::(&sqrt); // Populate the range columns. - self.range.populate(record, shard, channel, &sqrt); + self.range.populate(record, shard, channel, &sqrt, &modulus); let sqrt_bytes = P::to_limbs(&sqrt); self.lsb = F::from_canonical_u8(sqrt_bytes[0] & 1); @@ -135,9 +135,11 @@ where is_real.clone(), ); + let modulus_limbs = P::to_limbs_field_vec(&P::modulus()); self.range.eval( builder, &sqrt, + &limbs_from_vec::(modulus_limbs), shard.clone(), channel.clone(), is_real.clone(), diff --git a/core/src/operations/field/params.rs b/core/src/operations/field/params.rs index 923c0557de..3a34764e18 100644 --- a/core/src/operations/field/params.rs +++ b/core/src/operations/field/params.rs @@ -74,12 +74,12 @@ pub trait FieldParameters: } } -/// Convert a vec of u8 limbs to a Limbs of N length. -pub fn limbs_from_vec, N: ArrayLength, F: Field>(limbs: Vec) -> Limbs { +/// Convert a vec of F limbs to a Limbs of N length. +pub fn limbs_from_vec, N: ArrayLength, F: Field>(limbs: Vec) -> Limbs { debug_assert_eq!(limbs.len(), N::USIZE); let mut result = GenericArray::::generate(|_i| F::zero().into()); for (i, limb) in limbs.into_iter().enumerate() { - result[i] = limb; + result[i] = limb.into(); } Limbs(result) } diff --git a/core/src/operations/field/range.rs b/core/src/operations/field/range.rs index da2a2de4e8..04c7699ad7 100644 --- a/core/src/operations/field/range.rs +++ b/core/src/operations/field/range.rs @@ -1,4 +1,5 @@ use itertools::izip; +use std::fmt::Debug; use num::BigUint; @@ -8,6 +9,7 @@ use p3_field::PrimeField32; use sp1_derive::AlignedBorrow; +use crate::air::BaseAirBuilder; use crate::{ air::Polynomial, bytes::{event::ByteRecord, ByteLookupEvent, ByteOpcode}, @@ -17,38 +19,44 @@ use crate::{ use super::params::FieldParameters; use super::params::Limbs; -/// Operation columns for verifying that an element is within the range `[0, modulus)`. +/// Operation columns for verifying that `lhs < rhs`. #[derive(Debug, Clone, AlignedBorrow)] #[repr(C)] -pub struct FieldRangeCols { +pub struct FieldLtCols { /// Boolean flags to indicate the first byte in which the element is smaller than the modulus. pub(crate) byte_flags: Limbs, - pub(crate) comparison_byte: T, + pub(crate) lhs_comparison_byte: T, + + pub(crate) rhs_comparison_byte: T, } -impl FieldRangeCols { +impl FieldLtCols { pub fn populate( &mut self, record: &mut impl ByteRecord, shard: u32, channel: u32, - value: &BigUint, + lhs: &BigUint, + rhs: &BigUint, ) { - let value_limbs = P::to_limbs(value); - let modulus_limbs = P::to_limbs(&P::modulus()); + assert!(lhs < rhs); + + let value_limbs = P::to_limbs(lhs); + let modulus = P::to_limbs(rhs); let mut byte_flags = vec![0u8; P::NB_LIMBS]; for (byte, modulus_byte, flag) in izip!( value_limbs.iter().rev(), - modulus_limbs.iter().rev(), + modulus.iter().rev(), byte_flags.iter_mut().rev() ) { assert!(byte <= modulus_byte); if byte < modulus_byte { *flag = 1; - self.comparison_byte = F::from_canonical_u8(*byte); + self.lhs_comparison_byte = F::from_canonical_u8(*byte); + self.rhs_comparison_byte = F::from_canonical_u8(*modulus_byte); record.add_byte_lookup_event(ByteLookupEvent { opcode: ByteOpcode::LTU, shard, @@ -68,11 +76,16 @@ impl FieldRangeCols { } } -impl FieldRangeCols { - pub fn eval, E: Into> + Clone>( +impl FieldLtCols { + pub fn eval< + AB: SP1AirBuilder, + E1: Into> + Clone, + E2: Into> + Clone, + >( &self, builder: &mut AB, - element: &E, + lhs: &E1, + rhs: &E2, shard: impl Into + Clone, channel: impl Into + Clone, is_real: impl Into + Clone, @@ -81,25 +94,25 @@ impl FieldRangeCols { Limbs: Copy, { // The byte flags give a specification of which byte is `first_eq`, i,e, the first most - // significant byte for which the element is smaller than the modulus. To verify the + // significant byte for which the lhs is smaller than the modulus. To verify the // less-than claim we need to check that: - // * For all bytes until `first_eq` the element byte is equal to the modulus byte. - // * For the `first_eq` byte the element byte is smaller than the modulus byte. + // * For all bytes until `first_eq` the lhs byte is equal to the modulus byte. + // * For the `first_eq` byte the lhs byte is smaller than the modulus byte. // * all byte flags are boolean. // * only one byte flag is set to one, and the rest are set to zero. // Check the flags are of valid form. - // Verrify that only one flag is set to one. + // Verify that only one flag is set to one. let mut sum_flags: AB::Expr = AB::Expr::zero(); for &flag in self.byte_flags.0.iter() { // Assert that the flag is boolean. - builder.assert_bool(flag); + builder.when(is_real.clone()).assert_bool(flag); // Add the flag to the sum. sum_flags += flag.into(); } // Assert that the sum is equal to one. - builder.assert_one(sum_flags); + builder.when(is_real.clone()).assert_one(sum_flags); // Check the less-than condition. @@ -107,38 +120,42 @@ impl FieldRangeCols { // most significant until the first inequality. let mut is_inequality_visited = AB::Expr::zero(); - // The bytes of the modulus. - let modulus_bytes = P::MODULUS.to_vec(); - - let element: Polynomial<_> = element.clone().into(); + let rhs: Polynomial<_> = rhs.clone().into(); + let lhs: Polynomial<_> = lhs.clone().into(); - let mut first_lt_byte = AB::Expr::zero(); - let mut modulus_comparison_byte = AB::Expr::zero(); - for (byte, modulus_byte, &flag) in izip!( - element.coefficients().iter().rev(), - modulus_bytes.into_iter().rev(), + let mut lhs_comparison_byte = AB::Expr::zero(); + let mut rhs_comparison_byte = AB::Expr::zero(); + for (lhs_byte, rhs_byte, &flag) in izip!( + lhs.coefficients().iter().rev(), + rhs.coefficients().iter().rev(), self.byte_flags.0.iter().rev() ) { // Once the byte flag was set to one, we turn off the quality check flag. // We can do this by calculating the sum of the flags since only `1` is set to `1`. is_inequality_visited += flag.into(); - first_lt_byte += byte.clone() * flag; - modulus_comparison_byte += flag.into() * AB::F::from_canonical_u8(modulus_byte); + lhs_comparison_byte += lhs_byte.clone() * flag; + rhs_comparison_byte += flag.into() * rhs_byte.clone(); builder + .when(is_real.clone()) .when_not(is_inequality_visited.clone()) - .assert_eq(byte.clone(), AB::F::from_canonical_u8(modulus_byte)); + .assert_eq(lhs_byte.clone(), rhs_byte.clone()); } - builder.assert_eq(self.comparison_byte, first_lt_byte); + builder + .when(is_real.clone()) + .assert_eq(self.lhs_comparison_byte, lhs_comparison_byte); + builder + .when(is_real.clone()) + .assert_eq(self.rhs_comparison_byte, rhs_comparison_byte); // Send the comparison interaction. builder.send_byte( ByteOpcode::LTU.as_field::(), AB::F::one(), - self.comparison_byte, - modulus_comparison_byte, + self.lhs_comparison_byte, + self.rhs_comparison_byte, shard, channel, is_real, diff --git a/core/src/operations/fixed_rotate_right.rs b/core/src/operations/fixed_rotate_right.rs index 5172465b39..4de8eee4aa 100644 --- a/core/src/operations/fixed_rotate_right.rs +++ b/core/src/operations/fixed_rotate_right.rs @@ -9,7 +9,6 @@ use crate::bytes::utils::shr_carry; use crate::bytes::ByteLookupEvent; use crate::bytes::ByteOpcode; use crate::disassembler::WORD_SIZE; -use crate::runtime::ExecutionRecord; /// A set of columns needed to compute `rotateright` of a word with a fixed offset R. /// @@ -43,7 +42,7 @@ impl FixedRotateRightOperation { pub fn populate( &mut self, - record: &mut ExecutionRecord, + record: &mut impl ByteRecord, shard: u32, channel: u32, input: u32, diff --git a/core/src/operations/fixed_shift_right.rs b/core/src/operations/fixed_shift_right.rs index 305f573d4b..42fdc637d9 100644 --- a/core/src/operations/fixed_shift_right.rs +++ b/core/src/operations/fixed_shift_right.rs @@ -9,7 +9,6 @@ use crate::bytes::utils::shr_carry; use crate::bytes::ByteLookupEvent; use crate::bytes::ByteOpcode; use crate::disassembler::WORD_SIZE; -use crate::runtime::ExecutionRecord; /// A set of columns needed to compute `>>` of a word with a fixed offset R. /// @@ -43,7 +42,7 @@ impl FixedShiftRightOperation { pub fn populate( &mut self, - record: &mut ExecutionRecord, + record: &mut impl ByteRecord, shard: u32, channel: u32, input: u32, diff --git a/core/src/operations/is_zero.rs b/core/src/operations/is_zero.rs index 819a2d1cd1..67f183bb66 100644 --- a/core/src/operations/is_zero.rs +++ b/core/src/operations/is_zero.rs @@ -46,7 +46,6 @@ impl IsZeroOperation { cols: IsZeroOperation, is_real: AB::Expr, ) { - builder.assert_bool(is_real.clone()); let one: AB::Expr = AB::F::one().into(); // 1. Input == 0 => is_zero = 1 regardless of the inverse. diff --git a/core/src/operations/lt.rs b/core/src/operations/lt.rs new file mode 100644 index 0000000000..fcc344db24 --- /dev/null +++ b/core/src/operations/lt.rs @@ -0,0 +1,251 @@ +use itertools::izip; + +use p3_air::AirBuilder; +use p3_field::AbstractField; +use p3_field::PrimeField32; + +use sp1_derive::AlignedBorrow; + +use crate::air::BaseAirBuilder; +use crate::{ + bytes::{event::ByteRecord, ByteLookupEvent, ByteOpcode}, + stark::SP1AirBuilder, +}; + +/// Operation columns for verifying that an element is within the range `[0, modulus)`. +#[derive(Debug, Clone, Copy, AlignedBorrow)] +#[repr(C)] +pub struct AssertLtColsBytes { + /// Boolean flags to indicate the first byte in which the element is smaller than the modulus. + pub(crate) byte_flags: [T; N], + + pub(crate) a_comparison_byte: T, + pub(crate) b_comparison_byte: T, +} + +impl AssertLtColsBytes { + pub fn populate( + &mut self, + record: &mut impl ByteRecord, + shard: u32, + channel: u32, + a: &[u8], + b: &[u8], + ) { + let mut byte_flags = vec![0u8; N]; + + for (a_byte, b_byte, flag) in + izip!(a.iter().rev(), b.iter().rev(), byte_flags.iter_mut().rev()) + { + assert!(a_byte <= b_byte); + if a_byte < b_byte { + *flag = 1; + self.a_comparison_byte = F::from_canonical_u8(*a_byte); + self.b_comparison_byte = F::from_canonical_u8(*b_byte); + record.add_byte_lookup_event(ByteLookupEvent { + opcode: ByteOpcode::LTU, + shard, + channel, + a1: 1, + a2: 0, + b: *a_byte as u32, + c: *b_byte as u32, + }); + break; + } + } + + for (byte, flag) in izip!(byte_flags.iter(), self.byte_flags.iter_mut()) { + *flag = F::from_canonical_u8(*byte); + } + } +} + +impl AssertLtColsBytes { + pub fn eval< + AB: SP1AirBuilder, + Ea: Into + Clone, + Eb: Into + Clone, + >( + &self, + builder: &mut AB, + a: &[Ea], + b: &[Eb], + shard: impl Into + Clone, + channel: impl Into + Clone, + is_real: impl Into + Clone, + ) where + V: Into, + { + // The byte flags give a specification of which byte is `first_eq`, i,e, the first most + // significant byte for which the element `a` is smaller than `b`. To verify the + // less-than claim we need to check that: + // * For all bytes until `first_eq` the element `a` byte is equal to the `b` byte. + // * For the `first_eq` byte the `a`` byte is smaller than the `b`byte. + // * all byte flags are boolean. + // * only one byte flag is set to one, and the rest are set to zero. + + // Check the flags are of valid form. + + // Verrify that only one flag is set to one. + let mut sum_flags: AB::Expr = AB::Expr::zero(); + for &flag in self.byte_flags.iter() { + // Assert that the flag is boolean. + builder.assert_bool(flag); + // Add the flag to the sum. + sum_flags += flag.into(); + } + // Assert that the sum is equal to one. + builder.when(is_real.clone()).assert_one(sum_flags); + + // Check the less-than condition. + + // A flag to indicate whether an equality check is necessary (this is for all bytes from + // most significant until the first inequality. + let mut is_inequality_visited = AB::Expr::zero(); + + // The bytes of the modulus. + + let a: [AB::Expr; N] = core::array::from_fn(|i| a[i].clone().into()); + let b: [AB::Expr; N] = core::array::from_fn(|i| b[i].clone().into()); + + let mut first_lt_byte = AB::Expr::zero(); + let mut b_comparison_byte = AB::Expr::zero(); + for (a_byte, b_byte, &flag) in + izip!(a.iter().rev(), b.iter().rev(), self.byte_flags.iter().rev()) + { + // Once the byte flag was set to one, we turn off the quality check flag. + // We can do this by calculating the sum of the flags since only `1` is set to `1`. + is_inequality_visited += flag.into(); + + first_lt_byte += a_byte.clone() * flag; + b_comparison_byte += b_byte.clone() * flag; + + builder + .when_not(is_inequality_visited.clone()) + .when(is_real.clone()) + .assert_eq(a_byte.clone(), b_byte.clone()); + } + + builder + .when(is_real.clone()) + .assert_eq(self.a_comparison_byte, first_lt_byte); + builder + .when(is_real.clone()) + .assert_eq(self.b_comparison_byte, b_comparison_byte); + + // Send the comparison interaction. + builder.send_byte( + ByteOpcode::LTU.as_field::(), + AB::F::one(), + self.a_comparison_byte, + self.b_comparison_byte, + shard, + channel, + is_real, + ) + } +} + +/// Operation columns for verifying that an element is within the range `[0, modulus)`. +#[derive(Debug, Clone, Copy, AlignedBorrow)] +#[repr(C)] +pub struct AssertLtColsBits { + /// Boolean flags to indicate the first byte in which the element is smaller than the modulus. + pub(crate) bit_flags: [T; N], +} + +impl AssertLtColsBits { + pub fn populate(&mut self, a: &[u32], b: &[u32]) { + let mut bit_flags = vec![0u8; N]; + + for (a_bit, b_bit, flag) in + izip!(a.iter().rev(), b.iter().rev(), bit_flags.iter_mut().rev()) + { + assert!(a_bit <= b_bit); + debug_assert!(*a_bit == 0 || *a_bit == 1); + debug_assert!(*b_bit == 0 || *b_bit == 1); + if a_bit < b_bit { + *flag = 1; + break; + } + } + + for (bit, flag) in izip!(bit_flags.iter(), self.bit_flags.iter_mut()) { + *flag = F::from_canonical_u8(*bit); + } + } +} + +impl AssertLtColsBits { + pub fn eval< + AB: SP1AirBuilder, + Ea: Into + Clone, + Eb: Into + Clone, + >( + &self, + builder: &mut AB, + a: &[Ea], + b: &[Eb], + is_real: impl Into + Clone, + ) where + V: Into, + { + // The bit flags give a specification of which bit is `first_lt`, i,e, the first most + // significant bit for which the element `a` is smaller than `b`. To verify the + // less-than claim we need to check that: + // * For all bytes until `first_lt` the element `a` byte is equal to the `b` byte. + // * For the `first_lt` bit the `a`` bit is smaller than the `b` bit. + // * all bit flags are boolean. + // * only one bit flag is set to one, and the rest are set to zero. + + // Check the flags are of valid form. + + // Verrify that only one flag is set to one. + let mut sum_flags: AB::Expr = AB::Expr::zero(); + for &flag in self.bit_flags.iter() { + // Assert that the flag is boolean. + builder.assert_bool(flag); + // Add the flag to the sum. + sum_flags += flag.into(); + } + // Assert that the sum is equal to one. + builder.when(is_real.clone()).assert_one(sum_flags); + + // Check the less-than condition. + + // A flag to indicate whether an equality check is necessary (this is for all bits from + // most significant until the first inequality. + let mut is_inequality_visited = AB::Expr::zero(); + + // The bits of the elements. + let a: [AB::Expr; N] = core::array::from_fn(|i| a[i].clone().into()); + let b: [AB::Expr; N] = core::array::from_fn(|i| b[i].clone().into()); + + // Calculate the bit which is the first inequality. + let mut a_comparison_bit = AB::Expr::zero(); + let mut b_comparison_bit = AB::Expr::zero(); + for (a_bit, b_bit, &flag) in + izip!(a.iter().rev(), b.iter().rev(), self.bit_flags.iter().rev()) + { + // Once the bit flag was set to one, we turn off the quality check flag. + // We can do this by calculating the sum of the flags since only `1` is set to `1`. + is_inequality_visited += flag.into(); + + a_comparison_bit += a_bit.clone() * flag; + b_comparison_bit += b_bit.clone() * flag; + + builder + .when(is_real.clone()) + .when_not(is_inequality_visited.clone()) + .assert_eq(a_bit.clone(), b_bit.clone()); + } + + builder + .when(is_real.clone()) + .assert_eq(a_comparison_bit, AB::F::zero()); + builder + .when(is_real.clone()) + .assert_eq(b_comparison_bit, AB::F::one()); + } +} diff --git a/core/src/operations/mod.rs b/core/src/operations/mod.rs index e3fbcc78b1..394daf906b 100644 --- a/core/src/operations/mod.rs +++ b/core/src/operations/mod.rs @@ -16,6 +16,7 @@ mod fixed_shift_right; mod is_equal_word; mod is_zero; mod is_zero_word; +mod lt; mod not; mod or; mod xor; @@ -31,6 +32,7 @@ pub use fixed_shift_right::*; pub use is_equal_word::*; pub use is_zero::*; pub use is_zero_word::*; +pub use lt::*; pub use not::*; pub use or::*; pub use xor::*; diff --git a/core/src/operations/not.rs b/core/src/operations/not.rs index 309c630610..769d255030 100644 --- a/core/src/operations/not.rs +++ b/core/src/operations/not.rs @@ -8,7 +8,6 @@ use crate::air::Word; use crate::bytes::event::ByteRecord; use crate::bytes::ByteOpcode; use crate::disassembler::WORD_SIZE; -use crate::runtime::ExecutionRecord; /// A set of columns needed to compute the not of a word. #[derive(AlignedBorrow, Default, Debug, Clone, Copy)] @@ -21,7 +20,7 @@ pub struct NotOperation { impl NotOperation { pub fn populate( &mut self, - record: &mut ExecutionRecord, + record: &mut impl ByteRecord, shard: u32, channel: u32, x: u32, diff --git a/core/src/operations/xor.rs b/core/src/operations/xor.rs index ffb70f6847..fe0cadf966 100644 --- a/core/src/operations/xor.rs +++ b/core/src/operations/xor.rs @@ -8,7 +8,6 @@ use crate::bytes::event::ByteRecord; use crate::bytes::ByteLookupEvent; use crate::bytes::ByteOpcode; use crate::disassembler::WORD_SIZE; -use crate::runtime::ExecutionRecord; /// A set of columns needed to compute the xor of two words. #[derive(AlignedBorrow, Default, Debug, Clone, Copy)] @@ -21,7 +20,7 @@ pub struct XorOperation { impl XorOperation { pub fn populate( &mut self, - record: &mut ExecutionRecord, + record: &mut impl ByteRecord, shard: u32, channel: u32, x: u32, diff --git a/core/src/program/mod.rs b/core/src/program/mod.rs index 5b075db1cb..a54f8e0ad1 100644 --- a/core/src/program/mod.rs +++ b/core/src/program/mod.rs @@ -62,6 +62,7 @@ impl MachineAir for ProgramChip { } fn generate_preprocessed_trace(&self, program: &Self::Program) -> Option> { + debug_assert!(!program.instructions.is_empty(), "empty program"); let rows = program .instructions .clone() @@ -123,7 +124,7 @@ impl MachineAir for ProgramChip { let pc = input.program.pc_base + (i as u32 * 4); let mut row = [F::zero(); NUM_PROGRAM_MULT_COLS]; let cols: &mut ProgramMultiplicityCols = row.as_mut_slice().borrow_mut(); - cols.shard = F::from_canonical_u32(input.index); + cols.shard = F::from_canonical_u32(input.public_values.execution_shard); cols.multiplicity = F::from_canonical_usize(*instruction_counts.get(&pc).unwrap_or(&0)); row diff --git a/core/src/runtime/context.rs b/core/src/runtime/context.rs new file mode 100644 index 0000000000..d2642f4228 --- /dev/null +++ b/core/src/runtime/context.rs @@ -0,0 +1,164 @@ +use core::mem::take; +use std::sync::Arc; + +use super::{hookify, BoxedHook, HookEnv, HookRegistry, SubproofVerifier}; + +/// Context to run a program inside SP1. +#[derive(Clone, Default)] +pub struct SP1Context<'a> { + /// The registry of hooks invokable from inside SP1. + /// + /// Note: `None` denotes the default list of hooks. + pub hook_registry: Option>, + + /// The verifier for verifying subproofs. + pub subproof_verifier: Option>, + + /// The maximum number of cpu cycles to use for execution. + pub max_cycles: Option, +} + +#[derive(Clone, Default)] +pub struct SP1ContextBuilder<'a> { + no_default_hooks: bool, + hook_registry_entries: Vec<(u32, BoxedHook<'a>)>, + subproof_verifier: Option>, + max_cycles: Option, +} + +impl<'a> SP1Context<'a> { + /// Create a new context builder. See [SP1ContextBuilder] for more details. + pub fn builder() -> SP1ContextBuilder<'a> { + SP1ContextBuilder::new() + } +} + +impl<'a> SP1ContextBuilder<'a> { + /// Create a new [`SP1ContextBuilder`]. + /// + /// Prefer using [`SP1Context::builder`]. + pub fn new() -> Self { + Default::default() + } + + /// Build and return the [SP1Context]. + /// + /// Clears and resets the builder, allowing it to be reused. + pub fn build(&mut self) -> SP1Context<'a> { + // If hook_registry_entries is nonempty or no_default_hooks true, + // indicating a non-default value of hook_registry. + let hook_registry = + (!self.hook_registry_entries.is_empty() || self.no_default_hooks).then(|| { + let mut table = if take(&mut self.no_default_hooks) { + Default::default() + } else { + HookRegistry::default().table + }; + // Allows overwriting default hooks. + table.extend(take(&mut self.hook_registry_entries)); + HookRegistry { table } + }); + let subproof_verifier = take(&mut self.subproof_verifier); + let cycle_limit = take(&mut self.max_cycles); + SP1Context { + hook_registry, + subproof_verifier, + max_cycles: cycle_limit, + } + } + + /// Add a runtime [Hook](super::Hook) into the context. + /// + /// Hooks may be invoked from within SP1 by writing to the specified file descriptor `fd` + /// with [`sp1_zkvm::io::write`], returning a list of arbitrary data that may be read + /// with successive calls to [`sp1_zkvm::io::read`]. + pub fn hook( + &mut self, + fd: u32, + f: impl FnMut(HookEnv, &[u8]) -> Vec> + Send + Sync + 'a, + ) -> &mut Self { + self.hook_registry_entries.push((fd, hookify(f))); + self + } + + /// Avoid registering the default hooks in the runtime. + /// + /// It is not necessary to call this to override hooks --- instead, simply + /// register a hook with the same value of `fd` by calling [`Self::hook`]. + pub fn without_default_hooks(&mut self) -> &mut Self { + self.no_default_hooks = true; + self + } + + /// Add a subproof verifier. + /// + /// The verifier is used to sanity check `verify_sp1_proof` during runtime. + pub fn subproof_verifier( + &mut self, + subproof_verifier: Arc, + ) -> &mut Self { + self.subproof_verifier = Some(subproof_verifier); + self + } + + /// Set the maximum number of cpu cycles to use for execution. + pub fn max_cycles(&mut self, max_cycles: u64) -> &mut Self { + self.max_cycles = Some(max_cycles); + self + } +} + +#[cfg(test)] +mod tests { + use std::sync::Arc; + + use crate::runtime::{DefaultSubproofVerifier, SP1Context}; + + #[test] + fn defaults() { + let SP1Context { + hook_registry, + subproof_verifier, + max_cycles: cycle_limit, + } = SP1Context::builder().build(); + assert!(hook_registry.is_none()); + assert!(subproof_verifier.is_none()); + assert!(cycle_limit.is_none()); + } + + #[test] + fn without_default_hooks() { + let SP1Context { hook_registry, .. } = + SP1Context::builder().without_default_hooks().build(); + assert!(hook_registry.unwrap().table.is_empty()); + } + + #[test] + fn with_custom_hook() { + let SP1Context { hook_registry, .. } = + SP1Context::builder().hook(30, |_, _| vec![]).build(); + assert!(hook_registry.unwrap().table.contains_key(&30)); + } + + #[test] + fn without_default_hooks_with_custom_hook() { + let SP1Context { hook_registry, .. } = SP1Context::builder() + .without_default_hooks() + .hook(30, |_, _| vec![]) + .build(); + assert_eq!( + &hook_registry.unwrap().table.into_keys().collect::>(), + &[30] + ); + } + + #[test] + fn subproof_verifier() { + let SP1Context { + subproof_verifier, .. + } = SP1Context::builder() + .subproof_verifier(Arc::new(DefaultSubproofVerifier::new())) + .build(); + assert!(subproof_verifier.is_some()); + } +} diff --git a/core/src/runtime/hooks.rs b/core/src/runtime/hooks.rs index e9f503076f..ff93af248b 100644 --- a/core/src/runtime/hooks.rs +++ b/core/src/runtime/hooks.rs @@ -1,24 +1,49 @@ +use core::fmt::Debug; + use std::collections::HashMap; +use std::sync::{Arc, RwLock, RwLockWriteGuard}; use k256::ecdsa::{RecoveryId, Signature, VerifyingKey}; use k256::elliptic_curve::ops::Invert; use super::Runtime; -pub trait Hook: Fn(HookEnv, &[u8]) -> Vec> + Send {} - -impl Vec> + Send> Hook for F {} - -pub type BoxedHook<'a> = Box; +/// A runtime hook, wrapped in a smart pointer. +pub type BoxedHook<'a> = Arc>; /// The file descriptor through which to access `hook_ecrecover`. pub const FD_ECRECOVER_HOOK: u32 = 5; +/// A runtime hook. May be called during execution by writing to a specified file descriptor, +/// accepting and returning arbitrary data. +pub trait Hook { + /// Invoke the runtime hook with a standard environment and arbitrary data. + /// Returns the computed data. + fn invoke_hook(&mut self, env: HookEnv, buf: &[u8]) -> Vec>; +} + +impl Vec>> Hook for F { + /// Invokes the function `self` as a hook. + fn invoke_hook(&mut self, env: HookEnv, buf: &[u8]) -> Vec> { + self(env, buf) + } +} + +/// Wrap a function in a smart pointer so it may be placed in a `HookRegistry`. +/// +/// Note: the Send + Sync requirement may be logically extraneous. Requires further investigation. +pub fn hookify<'a>( + f: impl FnMut(HookEnv, &[u8]) -> Vec> + Send + Sync + 'a, +) -> BoxedHook<'a> { + Arc::new(RwLock::new(f)) +} + /// A registry of hooks to call, indexed by the file descriptors through which they are accessed. +#[derive(Clone)] pub struct HookRegistry<'a> { - /// Table of registered hooks. Prefer using `Runtime::invoke_hook` and - /// `HookRegistry::register` over interacting with this field directly. - pub table: HashMap>, + /// Table of registered hooks. Prefer using `Runtime::hook`, ` Runtime::hook_env`, + /// and `HookRegistry::get` over interacting with this field directly. + pub(crate) table: HashMap>, } impl<'a> HookRegistry<'a> { @@ -34,28 +59,40 @@ impl<'a> HookRegistry<'a> { } } - /// Register a hook under a given name. - pub fn register(&mut self, name: u32, hook: BoxedHook<'a>) { - self.table.insert(name, hook); + /// Get a hook with exclusive write access, if it exists. + /// Should not be called in async contexts, unless you know what you are doing. + pub fn get(&self, fd: &u32) -> Option> { + // Calling `.unwrap()` panics on a poisoned lock. Should never happen normally. + self.table.get(fd).map(|x| x.write().unwrap()) } } impl<'a> Default for HookRegistry<'a> { fn default() -> Self { // When `LazyCell` gets stabilized (1.81.0), we can use it to avoid unnecessary allocations. - let table = { - let entries: Vec<(u32, BoxedHook)> = vec![ - // Note: To ensure any `fd` value is synced with `zkvm/precompiles/src/io.rs`, - // add an assertion to the test `hook_fds_match` below. - (FD_ECRECOVER_HOOK, Box::new(hook_ecrecover)), - ]; - HashMap::from_iter(entries) - }; + let table = HashMap::from([ + // Note: To ensure any `fd` value is synced with `zkvm/precompiles/src/io.rs`, + // add an assertion to the test `hook_fds_match` below. + (FD_ECRECOVER_HOOK, hookify(hook_ecrecover)), + ]); Self { table } } } +impl<'a> Debug for HookRegistry<'a> { + fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { + let mut keys = self.table.keys().collect::>(); + keys.sort_unstable(); + f.debug_struct("HookRegistry") + .field( + "table", + &format_args!("{{{} hooks registered at {:?}}}", self.table.len(), keys), + ) + .finish() + } +} + /// Environment that a hook may read from. pub struct HookEnv<'a, 'b: 'a> { pub runtime: &'a Runtime<'b>, @@ -93,6 +130,7 @@ pub fn hook_ecrecover(_env: HookEnv, buf: &[u8]) -> Vec> { pub mod tests { use crate::{ runtime::Program, + stark::DefaultProver, utils::{self, tests::ECRECOVER_ELF}, }; @@ -100,13 +138,14 @@ pub mod tests { #[test] pub fn hook_fds_match() { - use sp1_zkvm::precompiles::io; + use sp1_zkvm::lib::io; assert_eq!(FD_ECRECOVER_HOOK, io::FD_ECRECOVER_HOOK) } #[test] pub fn registry_new_is_inhabited() { assert_ne!(HookRegistry::new().table.len(), 0); + println!("{:?}", HookRegistry::new()); } #[test] @@ -118,6 +157,6 @@ pub mod tests { fn test_ecrecover_program_prove() { utils::setup_logger(); let program = Program::from(ECRECOVER_ELF); - utils::run_test(program).unwrap(); + utils::run_test::>(program).unwrap(); } } diff --git a/core/src/runtime/io.rs b/core/src/runtime/io.rs index a0bb76508f..6eebbb4bd2 100644 --- a/core/src/runtime/io.rs +++ b/core/src/runtime/io.rs @@ -59,6 +59,7 @@ impl<'a> Runtime<'a> { pub mod tests { use super::*; use crate::runtime::Program; + use crate::stark::DefaultProver; use crate::utils::tests::IO_ELF; use crate::utils::{self, prove_simple, BabyBearBlake3, SP1CoreOpts}; use serde::Deserialize; @@ -115,6 +116,6 @@ pub mod tests { runtime.write_stdin(&points.1); runtime.run().unwrap(); let config = BabyBearBlake3::new(); - prove_simple(config, runtime).unwrap(); + prove_simple::<_, DefaultProver<_, _>>(config, runtime).unwrap(); } } diff --git a/core/src/runtime/mod.rs b/core/src/runtime/mod.rs index b223e1503e..beded5eb66 100644 --- a/core/src/runtime/mod.rs +++ b/core/src/runtime/mod.rs @@ -1,3 +1,4 @@ +mod context; mod hooks; mod instruction; mod io; @@ -13,6 +14,7 @@ mod syscall; mod utils; mod subproof; +pub use context::*; pub use hooks::*; pub use instruction::*; pub use memory::*; @@ -56,9 +58,12 @@ pub struct Runtime<'a> { /// The state of the execution. pub state: ExecutionState, - /// The trace of the execution. + /// The current trace of the execution that is being collected. pub record: ExecutionRecord, + /// The collected records, split by cpu cycles. + pub records: Vec, + /// The memory accesses for the current cycle. pub memory_accesses: MemoryAccessRecord, @@ -82,12 +87,16 @@ pub struct Runtime<'a> { /// the unconstrained block. The only thing preserved is writes to the input stream. pub unconstrained: bool, + /// The state of the runtime when in unconstrained mode. pub(crate) unconstrained_state: ForkState, + /// The mapping between syscall codes and their implementations. pub syscall_map: HashMap>, + /// The maximum number of cycles for a syscall. pub max_syscall_cycles: u32, + /// Whether to emit events during execution. pub emit_events: bool, /// Report of the program execution. @@ -101,6 +110,12 @@ pub struct Runtime<'a> { /// Registry of hooks, to be invoked by writing to certain file descriptors. pub hook_registry: HookRegistry<'a>, + + // The options for the runtime. + pub opts: SP1CoreOpts, + + /// The maximum number of cpu cycles to use for execution. + pub max_cycles: Option, } #[derive(Error, Debug)] @@ -113,13 +128,20 @@ pub enum ExecutionError { UnsupportedSyscall(u32), #[error("breakpoint encountered")] Breakpoint(), + #[error("exceeded cycle limit of {0}")] + ExceededCycleLimit(u64), #[error("got unimplemented as opcode")] Unimplemented(), } impl<'a> Runtime<'a> { - // Create a new runtime from a program. + // Create a new runtime from a program and options. pub fn new(program: Program, opts: SP1CoreOpts) -> Self { + Self::with_context(program, opts, Default::default()) + } + + /// Create a new runtime from a program, options, and a context. + pub fn with_context(program: Program, opts: SP1CoreOpts, context: SP1Context<'a>) -> Self { // Create a shared reference to the program. let program = Arc::new(program); @@ -145,8 +167,14 @@ impl<'a> Runtime<'a> { .max() .unwrap_or(0); + let subproof_verifier = context + .subproof_verifier + .unwrap_or_else(|| Arc::new(DefaultSubproofVerifier::new())); + let hook_registry = context.hook_registry.unwrap_or_default(); + Self { record, + records: vec![], state: ExecutionState::new(program.pc_start), program, memory_accesses: MemoryAccessRecord::default(), @@ -162,30 +190,31 @@ impl<'a> Runtime<'a> { max_syscall_cycles, report: ExecutionReport::default(), print_report: false, - subproof_verifier: Arc::new(DefaultSubproofVerifier::new()), - hook_registry: HookRegistry::default(), + subproof_verifier, + hook_registry, + opts, + max_cycles: context.max_cycles, } } /// Invokes the hook corresponding to the given file descriptor `fd` with the data `buf`, /// returning the resulting data. pub fn hook(&self, fd: u32, buf: &[u8]) -> Vec> { - self.hook_registry.table[&fd](self.hook_env(), buf) + self.hook_registry + .get(&fd) + .unwrap() + .invoke_hook(self.hook_env(), buf) } /// Prepare a `HookEnv` for use by hooks. - pub fn hook_env(&self) -> HookEnv { + pub fn hook_env<'b>(&'b self) -> HookEnv<'b, 'a> { HookEnv { runtime: self } } /// Recover runtime state from a program and existing execution state. pub fn recover(program: Program, state: ExecutionState, opts: SP1CoreOpts) -> Self { - let mut runtime = Self::new(program, opts); + let mut runtime = Self::new(program.clone(), opts); runtime.state = state; - let index: u32 = (runtime.state.global_clk / (runtime.shard_size / 4) as u64) - .try_into() - .unwrap(); - runtime.record.index = index + 1; runtime } @@ -416,8 +445,8 @@ impl<'a> Runtime<'a> { memory_store_value: Option, record: MemoryAccessRecord, exit_code: u32, - lookup_id: usize, - syscall_lookup_id: usize, + lookup_id: u128, + syscall_lookup_id: u128, ) { let cpu_event = CpuEvent { shard, @@ -451,7 +480,7 @@ impl<'a> Runtime<'a> { } /// Emit an ALU event. - fn emit_alu(&mut self, clk: u32, opcode: Opcode, a: u32, b: u32, c: u32, lookup_id: usize) { + fn emit_alu(&mut self, clk: u32, opcode: Opcode, a: u32, b: u32, c: u32, lookup_id: u128) { let event = AluEvent { lookup_id, shard: self.shard(), @@ -522,7 +551,7 @@ impl<'a> Runtime<'a> { a: u32, b: u32, c: u32, - lookup_id: usize, + lookup_id: u128, ) { self.rw(rd, a); if self.emit_events { @@ -850,6 +879,24 @@ impl<'a> Runtime<'a> { next_pc = precompile_next_pc; self.state.clk += precompile_cycles; exit_code = returned_exit_code; + + // Update the syscall counts. + let syscall_count = self.state.syscall_counts.entry(syscall).or_insert(0); + let (threshold, multiplier) = match syscall { + SyscallCode::KECCAK_PERMUTE => { + (self.opts.split_opts.keccak_split_threshold, 24) + } + SyscallCode::SHA_EXTEND => { + (self.opts.split_opts.sha_extend_split_threshold, 48) + } + SyscallCode::SHA_COMPRESS => { + (self.opts.split_opts.sha_compress_split_threshold, 80) + } + _ => (self.opts.split_opts.deferred_shift_threshold, 1), + }; + let nonce = (((*syscall_count as usize) % threshold) * multiplier) as u32; + self.record.nonce_lookup.insert(syscall_lookup_id, nonce); + *syscall_count += 1; } Opcode::EBREAK => { return Err(ExecutionError::Breakpoint()); @@ -975,18 +1022,35 @@ impl<'a> Runtime<'a> { self.state.current_shard += 1; self.state.clk = 0; self.state.channel = 0; + + self.bump_record(); + } + + // If the cycle limit is exceeded, return an error. + if let Some(max_cycles) = self.max_cycles { + if self.state.global_clk >= max_cycles { + return Err(ExecutionError::ExceededCycleLimit(max_cycles)); + } } Ok(self.state.pc.wrapping_sub(self.program.pc_base) >= (self.program.instructions.len() * 4) as u32) } + pub fn bump_record(&mut self) { + let removed_record = + std::mem::replace(&mut self.record, ExecutionRecord::new(self.program.clone())); + let public_values = removed_record.public_values; + self.record.public_values = public_values; + self.records.push(removed_record); + } + /// Execute up to `self.shard_batch_size` cycles, returning the events emitted and whether the program ended. - pub fn execute_record(&mut self) -> Result<(ExecutionRecord, bool), ExecutionError> { + pub fn execute_record(&mut self) -> Result<(Vec, bool), ExecutionError> { self.emit_events = true; self.print_report = true; let done = self.execute()?; - Ok((std::mem::take(&mut self.record), done)) + Ok((std::mem::take(&mut self.records), done)) } /// Execute up to `self.shard_batch_size` cycles, returning a copy of the prestate and whether the program ended. @@ -1036,6 +1100,12 @@ impl<'a> Runtime<'a> { /// Executes up to `self.shard_batch_size` cycles of the program, returning whether the program has finished. fn execute(&mut self) -> Result { + // Get the program. + let program = self.program.clone(); + + // Get the current shard. + let start_shard = self.state.current_shard; + // If it's the first cycle, initialize the program. if self.state.global_clk == 0 { self.initialize(); @@ -1060,8 +1130,41 @@ impl<'a> Runtime<'a> { } } + // Get the final public values. + let public_values = self.record.public_values; + + // Push the remaining execution record, if there are any CPU events. + if !self.record.cpu_events.is_empty() { + self.bump_record(); + } + if done { self.postprocess(); + + // Push the remaining execution record with memory initialize & finalize events. + self.bump_record(); + } + + // Set the global public values for all shards. + let mut last_next_pc = 0; + let mut last_exit_code = 0; + for (i, record) in self.records.iter_mut().enumerate() { + record.program = program.clone(); + record.public_values = public_values; + record.public_values.committed_value_digest = public_values.committed_value_digest; + record.public_values.deferred_proofs_digest = public_values.deferred_proofs_digest; + record.public_values.execution_shard = start_shard + i as u32; + if !record.cpu_events.is_empty() { + record.public_values.start_pc = record.cpu_events[0].pc; + record.public_values.next_pc = record.cpu_events.last().unwrap().next_pc; + record.public_values.exit_code = record.cpu_events.last().unwrap().exit_code; + last_next_pc = record.public_values.next_pc; + last_exit_code = record.public_values.exit_code; + } else { + record.public_values.start_pc = last_next_pc; + record.public_values.next_pc = last_next_pc; + record.public_values.exit_code = last_exit_code; + } } Ok(done) @@ -1090,7 +1193,9 @@ impl<'a> Runtime<'a> { // Ensure that all proofs and input bytes were read, otherwise warn the user. if self.state.proof_stream_ptr != self.state.proof_stream.len() { - panic!("Not all proofs were read. Proving will fail during recursion. Did you pass too many proofs in or forget to call verify_sp1_proof?"); + panic!( + "Not all proofs were read. Proving will fail during recursion. Did you pass too many proofs in or forget to call verify_sp1_proof?" + ); } if self.state.input_stream_ptr != self.state.input_stream.len() { log::warn!("Not all input bytes were read."); @@ -1156,7 +1261,7 @@ pub mod tests { use crate::{ runtime::Register, utils::{ - tests::{FIBONACCI_ELF, PANIC_ELF, SSZ_WITHDRAWALS_ELF}, + tests::{FIBONACCI_ELF, KECCAK_PERMUTE_ELF, PANIC_ELF}, SP1CoreOpts, }, }; @@ -1177,7 +1282,7 @@ pub mod tests { } pub fn ssz_withdrawals_program() -> Program { - Program::from(SSZ_WITHDRAWALS_ELF) + Program::from(KECCAK_PERMUTE_ELF) } pub fn panic_program() -> Program { diff --git a/core/src/runtime/record.rs b/core/src/runtime/record.rs index 0e80a40841..c989c3be05 100644 --- a/core/src/runtime/record.rs +++ b/core/src/runtime/record.rs @@ -1,9 +1,8 @@ -use std::collections::BTreeMap; -use std::collections::HashMap; -use std::mem::take; +use hashbrown::HashMap; +use itertools::EitherOrBoth; +use itertools::Itertools; use std::sync::Arc; -use itertools::Itertools; use p3_field::AbstractField; use serde::{Deserialize, Serialize}; @@ -11,6 +10,7 @@ use super::program::Program; use super::Opcode; use crate::air::PublicValues; use crate::alu::AluEvent; +use crate::bytes::event::add_sharded_byte_lookup_events; use crate::bytes::event::ByteRecord; use crate::bytes::ByteLookupEvent; use crate::cpu::CpuEvent; @@ -25,13 +25,11 @@ use crate::syscall::precompiles::ECDecompressEvent; use crate::syscall::precompiles::{ECAddEvent, ECDoubleEvent}; use crate::utils::SP1CoreOpts; -/// A record of the execution of a program. Contains event data for everything that happened during -/// the execution of the shard. +/// A record of the execution of a program. +/// +/// The trace of the execution is represented as a list of "events" that occur every cycle. #[derive(Default, Clone, Debug, Serialize, Deserialize)] pub struct ExecutionRecord { - /// The index of the shard. - pub index: u32, - /// The program. pub program: Arc, @@ -62,9 +60,11 @@ pub struct ExecutionRecord { /// A trace of the SLT, SLTI, SLTU, and SLTIU events. pub lt_events: Vec, - /// All byte lookups that are needed. The layout is shard -> (event -> count). Byte lookups are - /// sharded to prevent the multiplicities from overflowing. - pub byte_lookups: BTreeMap>, + /// All byte lookups that are needed. + /// + /// The layout is shard -> (event -> count). Byte lookups are sharded to prevent the + /// multiplicities from overflowing. + pub byte_lookups: HashMap>, pub sha_extend_events: Vec, @@ -101,72 +101,32 @@ pub struct ExecutionRecord { /// The public values. pub public_values: PublicValues, - pub nonce_lookup: HashMap, -} - -pub struct ShardingConfig { - pub shard_size: usize, - pub add_len: usize, - pub mul_len: usize, - pub sub_len: usize, - pub bitwise_len: usize, - pub shift_left_len: usize, - pub shift_right_len: usize, - pub divrem_len: usize, - pub lt_len: usize, - pub field_len: usize, - pub keccak_len: usize, - pub secp256k1_add_len: usize, - pub secp256k1_double_len: usize, - pub bn254_add_len: usize, - pub bn254_double_len: usize, - pub bls12381_add_len: usize, - pub bls12381_double_len: usize, - pub uint256_mul_len: usize, + pub nonce_lookup: HashMap, } -impl ShardingConfig { - pub const fn shard_size(&self) -> usize { - self.shard_size - } +#[derive(Clone, Copy, Debug, PartialEq, Eq)] +pub struct SplitOpts { + pub deferred_shift_threshold: usize, + pub keccak_split_threshold: usize, + pub sha_extend_split_threshold: usize, + pub sha_compress_split_threshold: usize, + pub memory_split_threshold: usize, } -impl Default for ShardingConfig { - fn default() -> Self { - let shard_size = SP1CoreOpts::default().shard_size; +impl SplitOpts { + pub fn new(deferred_shift_threshold: usize) -> Self { Self { - shard_size, - add_len: shard_size, - sub_len: shard_size, - bitwise_len: shard_size, - shift_left_len: shard_size, - divrem_len: shard_size, - lt_len: shard_size, - mul_len: shard_size, - shift_right_len: shard_size, - field_len: shard_size * 4, - keccak_len: shard_size, - secp256k1_add_len: shard_size, - secp256k1_double_len: shard_size, - bn254_add_len: shard_size, - bn254_double_len: shard_size, - bls12381_add_len: shard_size, - bls12381_double_len: shard_size, - uint256_mul_len: shard_size, + deferred_shift_threshold, + keccak_split_threshold: deferred_shift_threshold / 24, + sha_extend_split_threshold: deferred_shift_threshold / 48, + sha_compress_split_threshold: deferred_shift_threshold / 80, + memory_split_threshold: deferred_shift_threshold, } } } impl MachineRecord for ExecutionRecord { - type Config = ShardingConfig; - - fn index(&self) -> u32 { - self.index - } - - fn set_index(&mut self, index: u32) { - self.index = index; - } + type Config = SP1CoreOpts; fn stats(&self) -> HashMap { let mut stats = HashMap::new(); @@ -231,11 +191,27 @@ impl MachineRecord for ExecutionRecord { "uint256_mul_events".to_string(), self.uint256_mul_events.len(), ); - stats.insert( "bls12381_decompress_events".to_string(), self.bls12381_decompress_events.len(), ); + stats.insert( + "memory_initialize_events".to_string(), + self.memory_initialize_events.len(), + ); + stats.insert( + "memory_finalize_events".to_string(), + self.memory_finalize_events.len(), + ); + if !self.cpu_events.is_empty() { + let shard = self.cpu_events[0].shard; + stats.insert( + "byte_lookups".to_string(), + self.byte_lookups.get(&shard).map_or(0, |v| v.len()), + ); + } + // Filter out the empty events. + stats.retain(|_, v| *v != 0); stats } @@ -276,20 +252,10 @@ impl MachineRecord for ExecutionRecord { self.bls12381_decompress_events .append(&mut other.bls12381_decompress_events); - // Merge the byte lookups. - for (shard, events_map) in std::mem::take(&mut other.byte_lookups).into_iter() { - match self.byte_lookups.get_mut(&shard) { - Some(existing) => { - // If there's already a map for this shard, update counts for each event. - for (event, count) in events_map.iter() { - *existing.entry(*event).or_insert(0) += count; - } - } - None => { - // If there isn't a map for this shard, insert the whole map. - self.byte_lookups.insert(shard, events_map); - } - } + if self.byte_lookups.is_empty() { + self.byte_lookups = std::mem::take(&mut other.byte_lookups); + } else { + self.add_sharded_byte_lookup_events(vec![&other.byte_lookups]); } self.memory_initialize_events @@ -298,306 +264,62 @@ impl MachineRecord for ExecutionRecord { .append(&mut other.memory_finalize_events); } - fn shard(mut self, config: &ShardingConfig) -> Vec { - // Get the number of CPU events. - let num_cpu_events = self.cpu_events.len(); - - // Create empty shards that we will fill in. - let mut shards: Vec = Vec::new(); - - // Iterate throught he CPU events and fill in the shards. - let mut start_idx = 0; - let mut current_shard = self.cpu_events[0].shard; - for (i, cpu_event) in self.cpu_events.iter().enumerate() { - let at_last_event = i == num_cpu_events - 1; - if cpu_event.shard != current_shard || at_last_event { - let last_idx = if at_last_event { i + 1 } else { i }; - - // Fill in the shard. - let mut shard = ExecutionRecord::default(); - shard.index = current_shard; - shard.cpu_events = self.cpu_events[start_idx..last_idx].to_vec(); - shard.program = self.program.clone(); - - // Byte lookups are already sharded, so put this shard's lookups in. - let current_byte_lookups = - self.byte_lookups.remove(¤t_shard).unwrap_or_default(); - shard - .byte_lookups - .insert(current_shard, current_byte_lookups); - let last_shard_cpu_event = shard.cpu_events.last().unwrap(); - - // Set the public_values_digest for all shards. For the vast majority of the time, only the last shard - // will read the public values. But in some very rare edge cases, the last two shards will - // read it (e.g. when the halt instruction is the only instruction in the last shard). - // It seems overly complex to set the public_values_digest for the last two shards, so we just set it - // for all of the shards. - shard.public_values.committed_value_digest = - self.public_values.committed_value_digest; - shard.public_values.deferred_proofs_digest = - self.public_values.deferred_proofs_digest; - shard.public_values.shard = current_shard; - shard.public_values.start_pc = shard.cpu_events[0].pc; - shard.public_values.next_pc = last_shard_cpu_event.next_pc; - shard.public_values.exit_code = last_shard_cpu_event.exit_code; - shards.push(shard); - - if !(at_last_event) { - start_idx = i; - current_shard += 1; - } - } - } - - // Shard the ADD events. - for (add_chunk, shard) in take(&mut self.add_events) - .chunks_mut(config.add_len) - .zip(shards.iter_mut()) - { - shard.add_events.extend_from_slice(add_chunk); - for (i, event) in add_chunk.iter().enumerate() { - self.nonce_lookup.insert(event.lookup_id, i as u32); - } - } - - // Shard the SUB events. - for (sub_chunk, shard) in take(&mut self.sub_events) - .chunks_mut(config.sub_len) - .zip(shards.iter_mut()) - { - shard.sub_events.extend_from_slice(sub_chunk); - for (i, event) in sub_chunk.iter().enumerate() { - self.nonce_lookup - .insert(event.lookup_id, shard.add_events.len() as u32 + i as u32); - } - } - - // Shard the MUL events. - for (mul_chunk, shard) in take(&mut self.mul_events) - .chunks_mut(config.mul_len) - .zip(shards.iter_mut()) - { - shard.mul_events.extend_from_slice(mul_chunk); - for (i, event) in mul_chunk.iter().enumerate() { - self.nonce_lookup.insert(event.lookup_id, i as u32); - } - } - - // Shard the bitwise events. - for (bitwise_chunk, shard) in take(&mut self.bitwise_events) - .chunks_mut(config.bitwise_len) - .zip(shards.iter_mut()) - { - shard.bitwise_events.extend_from_slice(bitwise_chunk); - for (i, event) in bitwise_chunk.iter().enumerate() { - self.nonce_lookup.insert(event.lookup_id, i as u32); - } - } - - // Shard the shift left events. - for (shift_left_chunk, shard) in take(&mut self.shift_left_events) - .chunks_mut(config.shift_left_len) - .zip(shards.iter_mut()) - { - shard.shift_left_events.extend_from_slice(shift_left_chunk); - for (i, event) in shift_left_chunk.iter().enumerate() { - self.nonce_lookup.insert(event.lookup_id, i as u32); - } - } - - // Shard the shift right events. - for (shift_right_chunk, shard) in take(&mut self.shift_right_events) - .chunks_mut(config.shift_right_len) - .zip(shards.iter_mut()) - { - shard - .shift_right_events - .extend_from_slice(shift_right_chunk); - for (i, event) in shift_right_chunk.iter().enumerate() { - self.nonce_lookup.insert(event.lookup_id, i as u32); - } - } - - // Shard the divrem events. - for (divrem_chunk, shard) in take(&mut self.divrem_events) - .chunks_mut(config.divrem_len) - .zip(shards.iter_mut()) - { - shard.divrem_events.extend_from_slice(divrem_chunk); - for (i, event) in divrem_chunk.iter().enumerate() { - self.nonce_lookup.insert(event.lookup_id, i as u32); - } - } - - // Shard the LT events. - for (lt_chunk, shard) in take(&mut self.lt_events) - .chunks_mut(config.lt_len) - .zip(shards.iter_mut()) - { - shard.lt_events.extend_from_slice(lt_chunk); - for (i, event) in lt_chunk.iter().enumerate() { - self.nonce_lookup.insert(event.lookup_id, i as u32); - } - } - - // Keccak-256 permute events. - for (keccak_chunk, shard) in take(&mut self.keccak_permute_events) - .chunks_mut(config.keccak_len) - .zip(shards.iter_mut()) - { - shard.keccak_permute_events.extend_from_slice(keccak_chunk); - for (i, event) in keccak_chunk.iter().enumerate() { - self.nonce_lookup.insert(event.lookup_id, (i * 24) as u32); - } - } + fn register_nonces(&mut self, _opts: &Self::Config) { + self.add_events.iter().enumerate().for_each(|(i, event)| { + self.nonce_lookup.insert(event.lookup_id, i as u32); + }); - // secp256k1 curve add events. - for (secp256k1_add_chunk, shard) in take(&mut self.secp256k1_add_events) - .chunks_mut(config.secp256k1_add_len) - .zip(shards.iter_mut()) - { - shard - .secp256k1_add_events - .extend_from_slice(secp256k1_add_chunk); - for (i, event) in secp256k1_add_chunk.iter().enumerate() { - self.nonce_lookup.insert(event.lookup_id, i as u32); - } - } + self.sub_events.iter().enumerate().for_each(|(i, event)| { + self.nonce_lookup + .insert(event.lookup_id, (self.add_events.len() + i) as u32); + }); - // secp256k1 curve double events. - for (secp256k1_double_chunk, shard) in take(&mut self.secp256k1_double_events) - .chunks_mut(config.secp256k1_double_len) - .zip(shards.iter_mut()) - { - shard - .secp256k1_double_events - .extend_from_slice(secp256k1_double_chunk); - for (i, event) in secp256k1_double_chunk.iter().enumerate() { - self.nonce_lookup.insert(event.lookup_id, i as u32); - } - } + self.mul_events.iter().enumerate().for_each(|(i, event)| { + self.nonce_lookup.insert(event.lookup_id, i as u32); + }); - // bn254 curve add events. - for (bn254_add_chunk, shard) in take(&mut self.bn254_add_events) - .chunks_mut(config.bn254_add_len) - .zip(shards.iter_mut()) - { - shard.bn254_add_events.extend_from_slice(bn254_add_chunk); - for (i, event) in bn254_add_chunk.iter().enumerate() { + self.bitwise_events + .iter() + .enumerate() + .for_each(|(i, event)| { self.nonce_lookup.insert(event.lookup_id, i as u32); - } - } + }); - // bn254 curve double events. - for (bn254_double_chunk, shard) in take(&mut self.bn254_double_events) - .chunks_mut(config.bn254_double_len) - .zip(shards.iter_mut()) - { - shard - .bn254_double_events - .extend_from_slice(bn254_double_chunk); - for (i, event) in bn254_double_chunk.iter().enumerate() { + self.shift_left_events + .iter() + .enumerate() + .for_each(|(i, event)| { self.nonce_lookup.insert(event.lookup_id, i as u32); - } - } + }); - // BLS12-381 curve add events. - for (bls12381_add_chunk, shard) in take(&mut self.bls12381_add_events) - .chunks_mut(config.bls12381_add_len) - .zip(shards.iter_mut()) - { - shard - .bls12381_add_events - .extend_from_slice(bls12381_add_chunk); - for (i, event) in bls12381_add_chunk.iter().enumerate() { + self.shift_right_events + .iter() + .enumerate() + .for_each(|(i, event)| { self.nonce_lookup.insert(event.lookup_id, i as u32); - } - } + }); - // BLS12-381 curve double events. - for (bls12381_double_chunk, shard) in take(&mut self.bls12381_double_events) - .chunks_mut(config.bls12381_double_len) - .zip(shards.iter_mut()) - { - shard - .bls12381_double_events - .extend_from_slice(bls12381_double_chunk); - for (i, event) in bls12381_double_chunk.iter().enumerate() { + self.divrem_events + .iter() + .enumerate() + .for_each(|(i, event)| { self.nonce_lookup.insert(event.lookup_id, i as u32); - } - } - - // Put the precompile events in the first shard. - let first = shards.first_mut().unwrap(); + }); - // SHA-256 extend events. - first.sha_extend_events = std::mem::take(&mut self.sha_extend_events); - for (i, event) in first.sha_extend_events.iter().enumerate() { - self.nonce_lookup.insert(event.lookup_id, (i * 48) as u32); - } - - // SHA-256 compress events. - first.sha_compress_events = std::mem::take(&mut self.sha_compress_events); - for (i, event) in first.sha_compress_events.iter().enumerate() { - self.nonce_lookup.insert(event.lookup_id, (i * 80) as u32); - } - - // Edwards curve add events. - first.ed_add_events = std::mem::take(&mut self.ed_add_events); - for (i, event) in first.ed_add_events.iter().enumerate() { + self.lt_events.iter().enumerate().for_each(|(i, event)| { self.nonce_lookup.insert(event.lookup_id, i as u32); - } - - // Edwards curve decompress events. - first.ed_decompress_events = std::mem::take(&mut self.ed_decompress_events); - for (i, event) in first.ed_decompress_events.iter().enumerate() { - self.nonce_lookup.insert(event.lookup_id, i as u32); - } - - // K256 curve decompress events. - first.k256_decompress_events = std::mem::take(&mut self.k256_decompress_events); - for (i, event) in first.k256_decompress_events.iter().enumerate() { - self.nonce_lookup.insert(event.lookup_id, i as u32); - } - - // Uint256 mul arithmetic events. - first.uint256_mul_events = std::mem::take(&mut self.uint256_mul_events); - for (i, event) in first.uint256_mul_events.iter().enumerate() { - self.nonce_lookup.insert(event.lookup_id, i as u32); - } - - // Bls12-381 decompress events . - first.bls12381_decompress_events = std::mem::take(&mut self.bls12381_decompress_events); - for (i, event) in first.bls12381_decompress_events.iter().enumerate() { - self.nonce_lookup.insert(event.lookup_id, i as u32); - } - - // Put MemoryInit / MemoryFinalize events in the last shard. - let last = shards.last_mut().unwrap(); - last.memory_initialize_events - .extend_from_slice(&self.memory_initialize_events); - last.memory_finalize_events - .extend_from_slice(&self.memory_finalize_events); - - // Copy the nonce lookup to all shards. - for shard in shards.iter_mut() { - shard.nonce_lookup.clone_from(&self.nonce_lookup); - } - - shards + }); } /// Retrieves the public values. This method is needed for the `MachineRecord` trait, since - /// the public values digest is used by the prover. fn public_values(&self) -> Vec { self.public_values.to_vec() } } impl ExecutionRecord { - pub fn new(index: u32, program: Arc) -> Self { + pub fn new(program: Arc) -> Self { Self { - index, program, ..Default::default() } @@ -611,32 +333,29 @@ impl ExecutionRecord { self.lt_events.push(lt_event); } - pub fn add_alu_events(&mut self, alu_events: HashMap>) { - let keys = alu_events.keys().sorted(); - for opcode in keys { + pub fn add_alu_events(&mut self, mut alu_events: HashMap>) { + for (opcode, value) in alu_events.iter_mut() { match opcode { Opcode::ADD => { - self.add_events.extend_from_slice(&alu_events[opcode]); + self.add_events.append(value); } Opcode::MUL | Opcode::MULH | Opcode::MULHU | Opcode::MULHSU => { - self.mul_events.extend_from_slice(&alu_events[opcode]); + self.mul_events.append(value); } Opcode::SUB => { - self.sub_events.extend_from_slice(&alu_events[opcode]); + self.sub_events.append(value); } Opcode::XOR | Opcode::OR | Opcode::AND => { - self.bitwise_events.extend_from_slice(&alu_events[opcode]); + self.bitwise_events.append(value); } Opcode::SLL => { - self.shift_left_events - .extend_from_slice(&alu_events[opcode]); + self.shift_left_events.append(value); } Opcode::SRL | Opcode::SRA => { - self.shift_right_events - .extend_from_slice(&alu_events[opcode]); + self.shift_right_events.append(value); } Opcode::SLT | Opcode::SLTU => { - self.lt_events.extend_from_slice(&alu_events[opcode]); + self.lt_events.append(value); } _ => { panic!("Invalid opcode: {:?}", opcode); @@ -644,6 +363,215 @@ impl ExecutionRecord { } } } + + /// Take out events from the [ExecutionRecord] that should be deferred to a separate shard. + /// + /// Note: we usually defer events that would increase the recursion cost significantly if + /// included in every shard. + pub fn defer(&mut self) -> ExecutionRecord { + ExecutionRecord { + keccak_permute_events: std::mem::take(&mut self.keccak_permute_events), + secp256k1_add_events: std::mem::take(&mut self.secp256k1_add_events), + secp256k1_double_events: std::mem::take(&mut self.secp256k1_double_events), + bn254_add_events: std::mem::take(&mut self.bn254_add_events), + bn254_double_events: std::mem::take(&mut self.bn254_double_events), + bls12381_add_events: std::mem::take(&mut self.bls12381_add_events), + bls12381_double_events: std::mem::take(&mut self.bls12381_double_events), + sha_extend_events: std::mem::take(&mut self.sha_extend_events), + sha_compress_events: std::mem::take(&mut self.sha_compress_events), + ed_add_events: std::mem::take(&mut self.ed_add_events), + ed_decompress_events: std::mem::take(&mut self.ed_decompress_events), + k256_decompress_events: std::mem::take(&mut self.k256_decompress_events), + uint256_mul_events: std::mem::take(&mut self.uint256_mul_events), + bls12381_decompress_events: std::mem::take(&mut self.bls12381_decompress_events), + memory_initialize_events: std::mem::take(&mut self.memory_initialize_events), + memory_finalize_events: std::mem::take(&mut self.memory_finalize_events), + ..Default::default() + } + } + + /// Splits the deferred [ExecutionRecord] into multiple [ExecutionRecord]s, each which contain + /// a "reasonable" number of deferred events. + pub fn split(&mut self, last: bool, opts: SplitOpts) -> Vec { + let mut shards = Vec::new(); + + macro_rules! split_events { + ($self:ident, $events:ident, $shards:ident, $threshold:expr, $exact:expr) => { + let events = std::mem::take(&mut $self.$events); + let chunks = events.chunks_exact($threshold); + if !$exact { + $self.$events = chunks.remainder().to_vec(); + } else { + let remainder = chunks.remainder().to_vec(); + if !remainder.is_empty() { + $shards.push(ExecutionRecord { + $events: chunks.remainder().to_vec(), + program: self.program.clone(), + ..Default::default() + }); + } + } + let mut event_shards = chunks + .map(|chunk| ExecutionRecord { + $events: chunk.to_vec(), + program: self.program.clone(), + ..Default::default() + }) + .collect::>(); + $shards.append(&mut event_shards); + }; + } + + split_events!( + self, + keccak_permute_events, + shards, + opts.keccak_split_threshold, + last + ); + split_events!( + self, + secp256k1_add_events, + shards, + opts.deferred_shift_threshold, + last + ); + split_events!( + self, + secp256k1_double_events, + shards, + opts.deferred_shift_threshold, + last + ); + split_events!( + self, + bn254_add_events, + shards, + opts.deferred_shift_threshold, + last + ); + split_events!( + self, + bn254_double_events, + shards, + opts.deferred_shift_threshold, + last + ); + split_events!( + self, + bls12381_add_events, + shards, + opts.deferred_shift_threshold, + last + ); + split_events!( + self, + bls12381_double_events, + shards, + opts.deferred_shift_threshold, + last + ); + split_events!( + self, + sha_extend_events, + shards, + opts.sha_extend_split_threshold, + last + ); + split_events!( + self, + sha_compress_events, + shards, + opts.sha_compress_split_threshold, + last + ); + split_events!( + self, + ed_add_events, + shards, + opts.deferred_shift_threshold, + last + ); + split_events!( + self, + ed_decompress_events, + shards, + opts.deferred_shift_threshold, + last + ); + split_events!( + self, + k256_decompress_events, + shards, + opts.deferred_shift_threshold, + last + ); + split_events!( + self, + uint256_mul_events, + shards, + opts.deferred_shift_threshold, + last + ); + split_events!( + self, + bls12381_decompress_events, + shards, + opts.deferred_shift_threshold, + last + ); + + if last { + self.memory_initialize_events + .sort_by_key(|event| event.addr); + self.memory_finalize_events.sort_by_key(|event| event.addr); + + let mut init_addr_bits = [0; 32]; + let mut finalize_addr_bits = [0; 32]; + for mem_chunks in self + .memory_initialize_events + .chunks(opts.memory_split_threshold) + .zip_longest( + self.memory_finalize_events + .chunks(opts.memory_split_threshold), + ) + { + let (mem_init_chunk, mem_finalize_chunk) = match mem_chunks { + EitherOrBoth::Both(mem_init_chunk, mem_finalize_chunk) => { + (mem_init_chunk, mem_finalize_chunk) + } + EitherOrBoth::Left(mem_init_chunk) => (mem_init_chunk, [].as_slice()), + EitherOrBoth::Right(mem_finalize_chunk) => ([].as_slice(), mem_finalize_chunk), + }; + let mut shard = ExecutionRecord::default(); + shard.program = self.program.clone(); + shard + .memory_initialize_events + .extend_from_slice(mem_init_chunk); + shard.public_values.previous_init_addr_bits = init_addr_bits; + if let Some(last_event) = mem_init_chunk.last() { + let last_init_addr_bits = core::array::from_fn(|i| (last_event.addr >> i) & 1); + init_addr_bits = last_init_addr_bits; + } + shard.public_values.last_init_addr_bits = init_addr_bits; + + shard + .memory_finalize_events + .extend_from_slice(mem_finalize_chunk); + shard.public_values.previous_finalize_addr_bits = finalize_addr_bits; + if let Some(last_event) = mem_finalize_chunk.last() { + let last_finalize_addr_bits = + core::array::from_fn(|i| (last_event.addr >> i) & 1); + finalize_addr_bits = last_finalize_addr_bits; + } + shard.public_values.last_finalize_addr_bits = finalize_addr_bits; + + shards.push(shard); + } + } + + shards + } } impl ByteRecord for ExecutionRecord { @@ -655,6 +583,14 @@ impl ByteRecord for ExecutionRecord { .entry(blu_event) .or_insert(0) += 1 } + + #[inline] + fn add_sharded_byte_lookup_events( + &mut self, + new_events: Vec<&HashMap>>, + ) { + add_sharded_byte_lookup_events(&mut self.byte_lookups, new_events); + } } #[derive(Debug, Copy, Clone, Default)] @@ -664,3 +600,6 @@ pub struct MemoryAccessRecord { pub c: Option, pub memory: Option, } + +/// The threshold for splitting deferred events. +pub const DEFERRED_SPLIT_THRESHOLD: usize = 1 << 19; diff --git a/core/src/runtime/state.rs b/core/src/runtime/state.rs index 8b1c289ee9..d5a1f3bdf1 100644 --- a/core/src/runtime/state.rs +++ b/core/src/runtime/state.rs @@ -1,16 +1,20 @@ -use std::collections::HashMap; +use std::{ + collections::HashMap, + fs::File, + io::{Seek, Write}, +}; use nohash_hasher::BuildNoHashHasher; use serde::{Deserialize, Serialize}; use serde_with::serde_as; +use super::{ExecutionRecord, MemoryAccessRecord, MemoryRecord, SyscallCode}; +use crate::utils::{deserialize_hashmap_as_vec, serialize_hashmap_as_vec}; use crate::{ stark::{ShardProof, StarkVerifyingKey}, utils::BabyBearPoseidon2, }; -use super::{ExecutionRecord, MemoryAccessRecord, MemoryRecord}; - /// Holds data describing the current state of a program's execution. #[serde_as] #[derive(Debug, Clone, Default, Serialize, Deserialize)] @@ -34,10 +38,18 @@ pub struct ExecutionState { /// The memory which instructions operate over. Values contain the memory value and last shard /// + timestamp that each memory address was accessed. + #[serde( + serialize_with = "serialize_hashmap_as_vec", + deserialize_with = "deserialize_hashmap_as_vec" + )] pub memory: HashMap>, /// Uninitialized memory addresses that have a specific value they should be initialized with. /// SyscallHintRead uses this to write hint data into uninitialized memory. + #[serde( + serialize_with = "serialize_hashmap_as_vec", + deserialize_with = "deserialize_hashmap_as_vec" + )] pub uninitialized_memory: HashMap>, /// A stream of input values (global to the entire program). @@ -60,6 +72,9 @@ pub struct ExecutionState { /// A ptr to the current position in the public values stream, incremented when reading from public_values_stream. pub public_values_stream_ptr: usize, + + /// Keeps track of how many times a certain syscall has been called. + pub syscall_counts: HashMap, } impl ExecutionState { @@ -79,6 +94,7 @@ impl ExecutionState { public_values_stream_ptr: 0, proof_stream: Vec::new(), proof_stream_ptr: 0, + syscall_counts: HashMap::new(), } } } @@ -107,3 +123,13 @@ pub(crate) struct ForkState { // Emit events from original state pub(crate) emit_events: bool, } + +impl ExecutionState { + pub fn save(&self, file: &mut File) -> std::io::Result<()> { + let mut writer = std::io::BufWriter::new(file); + bincode::serialize_into(&mut writer, self).unwrap(); + writer.flush()?; + writer.seek(std::io::SeekFrom::Start(0))?; + Ok(()) + } +} diff --git a/core/src/runtime/syscall.rs b/core/src/runtime/syscall.rs index 7fd4909534..2cf3299219 100644 --- a/core/src/runtime/syscall.rs +++ b/core/src/runtime/syscall.rs @@ -2,6 +2,7 @@ use std::collections::HashMap; use std::fmt; use std::sync::Arc; +use serde::{Deserialize, Serialize}; use strum_macros::EnumIter; use crate::runtime::{Register, Runtime}; @@ -28,7 +29,9 @@ use crate::{runtime::ExecutionRecord, runtime::MemoryReadRecord, runtime::Memory /// - The second byte is 0/1 depending on whether the syscall has a separate table. This is used /// in the CPU table to determine whether to lookup the syscall using the syscall interaction. /// - The third byte is the number of additional cycles the syscall uses. -#[derive(Debug, Copy, Clone, PartialEq, Eq, Hash, EnumIter, Ord, PartialOrd)] +#[derive( + Debug, Copy, Clone, PartialEq, Eq, Hash, EnumIter, Ord, PartialOrd, Serialize, Deserialize, +)] #[allow(non_camel_case_types)] pub enum SyscallCode { /// Halts the program. @@ -92,7 +95,7 @@ pub enum SyscallCode { HINT_READ = 0x00_00_00_F1, /// Executes the `UINT256_MUL` precompile. - UINT256_MUL = 0x00_00_01_1D, + UINT256_MUL = 0x00_01_01_1D, /// Executes the `BLS12381_ADD` precompile. BLS12381_ADD = 0x00_01_01_1E, @@ -126,7 +129,7 @@ impl SyscallCode { 0x00_00_00_1B => SyscallCode::VERIFY_SP1_PROOF, 0x00_00_00_F0 => SyscallCode::HINT_LEN, 0x00_00_00_F1 => SyscallCode::HINT_READ, - 0x00_00_01_1D => SyscallCode::UINT256_MUL, + 0x00_01_01_1D => SyscallCode::UINT256_MUL, 0x00_00_01_1C => SyscallCode::BLS12381_DECOMPRESS, _ => panic!("invalid syscall number: {}", value), } @@ -175,7 +178,7 @@ pub struct SyscallContext<'a, 'b: 'a> { /// This is the exit_code used for the HALT syscall pub(crate) exit_code: u32, pub(crate) rt: &'a mut Runtime<'b>, - pub syscall_lookup_id: usize, + pub syscall_lookup_id: u128, } impl<'a, 'b> SyscallContext<'a, 'b> { @@ -291,7 +294,7 @@ pub fn default_syscall_map() -> HashMap> { ); syscall_map.insert( SyscallCode::SECP256K1_DECOMPRESS, - Arc::new(WeierstrassDecompressChip::::new()), + Arc::new(WeierstrassDecompressChip::::with_lsb_rule()), ); syscall_map.insert( SyscallCode::BN254_ADD, @@ -332,7 +335,7 @@ pub fn default_syscall_map() -> HashMap> { syscall_map.insert(SyscallCode::HINT_READ, Arc::new(SyscallHintRead::new())); syscall_map.insert( SyscallCode::BLS12381_DECOMPRESS, - Arc::new(WeierstrassDecompressChip::::new()), + Arc::new(WeierstrassDecompressChip::::with_lexicographic_rule()), ); syscall_map.insert(SyscallCode::UINT256_MUL, Arc::new(Uint256MulChip::new())); diff --git a/core/src/stark/air.rs b/core/src/stark/air.rs index 558ccec5ab..433fcdcc10 100644 --- a/core/src/stark/air.rs +++ b/core/src/stark/air.rs @@ -128,7 +128,8 @@ impl RiscvAir { chips.push(RiscvAir::Ed25519Add(ed_add_assign)); let ed_decompress = EdDecompressChip::::default(); chips.push(RiscvAir::Ed25519Decompress(ed_decompress)); - let k256_decompress = WeierstrassDecompressChip::>::new(); + let k256_decompress = + WeierstrassDecompressChip::>::with_lsb_rule(); chips.push(RiscvAir::K256Decompress(k256_decompress)); let secp256k1_add_assign = WeierstrassAddAssignChip::>::new(); chips.push(RiscvAir::Secp256k1Add(secp256k1_add_assign)); @@ -147,7 +148,8 @@ impl RiscvAir { chips.push(RiscvAir::Bls12381Double(bls12381_double)); let uint256_mul = Uint256MulChip::default(); chips.push(RiscvAir::Uint256Mul(uint256_mul)); - let bls12381_decompress = WeierstrassDecompressChip::>::new(); + let bls12381_decompress = + WeierstrassDecompressChip::>::with_lexicographic_rule(); chips.push(RiscvAir::Bls12381Decompress(bls12381_decompress)); let div_rem = DivRemChip::default(); chips.push(RiscvAir::DivRem(div_rem)); diff --git a/core/src/stark/config.rs b/core/src/stark/config.rs index 2caf8c2e7f..b944fbfe80 100644 --- a/core/src/stark/config.rs +++ b/core/src/stark/config.rs @@ -46,7 +46,7 @@ pub type PcsProverData = <::Pcs as Pcs< pub type Challenge = ::Challenge; pub type Challenger = ::Challenger; -pub trait StarkGenericConfig: Send + Sync + Serialize + DeserializeOwned + Clone { +pub trait StarkGenericConfig: 'static + Send + Sync + Serialize + DeserializeOwned + Clone { type Val: PrimeField; type Domain: PolynomialSpace + Sync; diff --git a/core/src/stark/machine.rs b/core/src/stark/machine.rs index 3c80832343..54edf46229 100644 --- a/core/src/stark/machine.rs +++ b/core/src/stark/machine.rs @@ -1,8 +1,10 @@ +use hashbrown::HashMap; use itertools::Itertools; use p3_air::Air; use p3_challenger::CanObserve; use p3_challenger::FieldChallenger; use p3_commit::Pcs; +use p3_field::AbstractExtensionField; use p3_field::AbstractField; use p3_field::Field; use p3_field::PrimeField32; @@ -14,7 +16,6 @@ use serde::de::DeserializeOwned; use serde::Deserialize; use serde::Serialize; use std::cmp::Reverse; -use std::collections::HashMap; use std::fmt::Debug; use tracing::instrument; @@ -23,20 +24,16 @@ use super::Dom; use crate::air::MachineAir; use crate::air::MachineProgram; use crate::lookup::debug_interactions_with_all_chips; -use crate::lookup::InteractionBuilder; use crate::lookup::InteractionKind; use crate::stark::record::MachineRecord; use crate::stark::DebugConstraintBuilder; -use crate::stark::ProverConstraintFolder; use crate::stark::ShardProof; use crate::stark::VerifierConstraintFolder; -use crate::utils::SP1CoreOpts; use super::Chip; use super::Com; use super::MachineProof; use super::PcsProverData; -use super::Prover; use super::StarkGenericConfig; use super::Val; use super::VerificationError; @@ -239,54 +236,22 @@ impl>> StarkMachine { ) } - pub fn shard( + pub fn generate_dependencies( &self, - mut record: A::Record, - config: &::Config, - ) -> Vec { - // Get the local and global chips. + records: &mut [A::Record], + opts: &::Config, + ) { let chips = self.chips(); - - // Generate the trace for each chip to collect events emitted from chips with dependencies. - tracing::debug_span!("collect record events from chips").in_scope(|| { + records.iter_mut().for_each(|record| { chips.iter().for_each(|chip| { - let mut output = A::Record::default(); - output.set_index(record.index()); - chip.generate_dependencies(&record, &mut output); - record.append(&mut output); - }) - }); - - // Display some statistics about the workload. - let stats = record.stats(); - log::debug!("shard: {:?}", stats); - - // For each chip, shard the events into segments. - record.shard(config) - } - - /// Prove the execution record is valid. - /// - /// Given a proving key `pk` and a matching execution record `record`, this function generates - /// a STARK proof that the execution record is valid. - pub fn prove>( - &self, - pk: &StarkProvingKey, - record: A::Record, - challenger: &mut SC::Challenger, - opts: SP1CoreOpts, - ) -> MachineProof - where - A: for<'a> Air> - + Air>> - + for<'a> Air> - + for<'a> Air, SC::Challenge>>, - { - let shards = tracing::info_span!("shard_record") - .in_scope(|| self.shard(record, &::Config::default())); - - tracing::info_span!("prove_shards") - .in_scope(|| P::prove_shards(self, pk, shards, challenger, opts)) + tracing::debug_span!("chip dependencies", chip = chip.name()).in_scope(|| { + let mut output = A::Record::default(); + chip.generate_dependencies(record, &mut output); + record.append(&mut output); + }); + }); + tracing::debug_span!("register nonces").in_scope(|| record.register_nonces(opts)); + }) } pub const fn config(&self) -> &SC { @@ -321,7 +286,7 @@ impl>> StarkMachine { tracing::debug_span!("verify shard proofs").in_scope(|| { for (i, shard_proof) in proof.shard_proofs.iter().enumerate() { - tracing::debug_span!("verifying shard", segment = i).in_scope(|| { + tracing::debug_span!("verifying shard", shard = i).in_scope(|| { let chips = self .shard_chips_ordered(&shard_proof.chip_ordering) .collect::>(); @@ -332,7 +297,7 @@ impl>> StarkMachine { &mut challenger.clone(), shard_proof, ) - .map_err(MachineVerificationError::InvalidSegmentProof) + .map_err(MachineVerificationError::InvalidShardProof) })?; } @@ -356,19 +321,22 @@ impl>> StarkMachine { pub fn debug_constraints( &self, pk: &StarkProvingKey, - record: A::Record, + records: Vec, challenger: &mut SC::Challenger, ) where SC::Val: PrimeField32, A: for<'a> Air, SC::Challenge>>, { - tracing::debug!("sharding the execution record"); - let shards = self.shard(record, &::Config::default()); - tracing::debug!("checking constraints for each shard"); + // Obtain the challenges used for the permutation argument. + let mut permutation_challenges: Vec = Vec::new(); + for _ in 0..2 { + permutation_challenges.push(challenger.sample_ext_element()); + } + let mut cumulative_sum = SC::Challenge::zero(); - for shard in shards.iter() { + for shard in records.iter() { // Filter the chips based on what is used. let chips = self.shard_chips(shard).collect::>(); @@ -387,13 +355,6 @@ impl>> StarkMachine { .zip(pre_traces) .collect::>(); - // Get a permutation challenge. - // Obtain the challenges used for the permutation argument. - let mut permutation_challenges: Vec = Vec::new(); - for _ in 0..2 { - permutation_challenges.push(challenger.sample_ext_element()); - } - // Generate the permutation traces. let mut permutation_traces = Vec::with_capacity(chips.len()); let mut cumulative_sums = Vec::with_capacity(chips.len()); @@ -422,7 +383,8 @@ impl>> StarkMachine { // Compute some statistics. for i in 0..chips.len() { let trace_width = traces[i].0.width(); - let permutation_width = permutation_traces[i].width(); + let permutation_width = permutation_traces[i].width() + * >::D; let total_width = trace_width + permutation_width; tracing::debug!( "{:<11} | Main Cols = {:<5} | Perm Cols = {:<5} | Rows = {:<10} | Cells = {:<10}", @@ -457,7 +419,7 @@ impl>> StarkMachine { debug_interactions_with_all_chips::( self, pk, - &shards, + &records, InteractionKind::all_kinds(), ); panic!("Cumulative sum is not zero"); @@ -466,7 +428,7 @@ impl>> StarkMachine { } pub enum MachineVerificationError { - InvalidSegmentProof(VerificationError), + InvalidShardProof(VerificationError), InvalidGlobalProof(VerificationError), NonZeroCumulativeSum, InvalidPublicValuesDigest, @@ -475,13 +437,15 @@ pub enum MachineVerificationError { InvalidPublicValues(&'static str), TooManyShards, InvalidChipOccurence(String), + MissingCpuInFirstShard, + CpuLogDegreeTooLarge(usize), } impl Debug for MachineVerificationError { fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { match self { - MachineVerificationError::InvalidSegmentProof(e) => { - write!(f, "Invalid segment proof: {:?}", e) + MachineVerificationError::InvalidShardProof(e) => { + write!(f, "Invalid shard proof: {:?}", e) } MachineVerificationError::InvalidGlobalProof(e) => { write!(f, "Invalid global proof: {:?}", e) @@ -507,6 +471,12 @@ impl Debug for MachineVerificationError { MachineVerificationError::InvalidChipOccurence(s) => { write!(f, "Invalid chip occurence: {}", s) } + MachineVerificationError::MissingCpuInFirstShard => { + write!(f, "Missing CPU in first shard") + } + MachineVerificationError::CpuLogDegreeTooLarge(log_degree) => { + write!(f, "CPU log degree too large: {}", log_degree) + } } } } @@ -531,6 +501,7 @@ pub mod tests { use crate::runtime::Instruction; use crate::runtime::Opcode; use crate::runtime::Program; + use crate::stark::DefaultProver; use crate::stark::RiscvAir; use crate::stark::StarkProvingKey; use crate::stark::StarkVerifyingKey; @@ -545,7 +516,7 @@ pub mod tests { fn test_simple_prove() { utils::setup_logger(); let program = simple_program(); - run_test(program).unwrap(); + run_test::>(program).unwrap(); } #[test] @@ -567,7 +538,7 @@ pub mod tests { Instruction::new(*shift_op, 31, 29, 3, false, false), ]; let program = Program::new(instructions, 0, 0); - run_test(program).unwrap(); + run_test::>(program).unwrap(); } } } @@ -581,7 +552,7 @@ pub mod tests { Instruction::new(Opcode::SUB, 31, 30, 29, false, false), ]; let program = Program::new(instructions, 0, 0); - run_test(program).unwrap(); + run_test::>(program).unwrap(); } #[test] @@ -593,7 +564,7 @@ pub mod tests { Instruction::new(Opcode::ADD, 31, 30, 29, false, false), ]; let program = Program::new(instructions, 0, 0); - run_test(program).unwrap(); + run_test::>(program).unwrap(); } #[test] @@ -615,7 +586,7 @@ pub mod tests { Instruction::new(*mul_op, 31, 30, 29, false, false), ]; let program = Program::new(instructions, 0, 0); - run_test(program).unwrap(); + run_test::>(program).unwrap(); } } } @@ -631,7 +602,7 @@ pub mod tests { Instruction::new(*lt_op, 31, 30, 29, false, false), ]; let program = Program::new(instructions, 0, 0); - run_test(program).unwrap(); + run_test::>(program).unwrap(); } } @@ -647,7 +618,7 @@ pub mod tests { Instruction::new(*bitwise_op, 31, 30, 29, false, false), ]; let program = Program::new(instructions, 0, 0); - run_test(program).unwrap(); + run_test::>(program).unwrap(); } } @@ -670,16 +641,16 @@ pub mod tests { Instruction::new(*div_rem_op, 31, 29, 30, false, false), ]; let program = Program::new(instructions, 0, 0); - run_test(program).unwrap(); + run_test::>(program).unwrap(); } } } #[test] - fn test_fibonacci_prove() { + fn test_fibonacci_prove_simple() { setup_logger(); let program = fibonacci_program(); - run_test(program).unwrap(); + run_test::>(program).unwrap(); } #[test] @@ -691,7 +662,7 @@ pub mod tests { let mut opts = SP1CoreOpts::default(); opts.shard_size = 1024; opts.shard_batch_size = 2; - prove(program, &stdin, BabyBearPoseidon2::new(), opts).unwrap(); + prove::<_, DefaultProver<_, _>>(program, &stdin, BabyBearPoseidon2::new(), opts).unwrap(); } #[test] @@ -699,7 +670,7 @@ pub mod tests { setup_logger(); let program = fibonacci_program(); let stdin = SP1Stdin::new(); - prove( + prove::<_, DefaultProver<_, _>>( program, &stdin, BabyBearPoseidon2::new(), @@ -710,15 +681,16 @@ pub mod tests { #[test] fn test_simple_memory_program_prove() { + setup_logger(); let program = simple_memory_program(); - run_test(program).unwrap(); + run_test::>(program).unwrap(); } #[test] - #[ignore] fn test_ssz_withdrawal() { + setup_logger(); let program = ssz_withdrawals_program(); - run_test(program).unwrap(); + run_test::>(program).unwrap(); } #[test] diff --git a/core/src/stark/prover.rs b/core/src/stark/prover.rs index 7c22161e1f..7cf1123b29 100644 --- a/core/src/stark/prover.rs +++ b/core/src/stark/prover.rs @@ -1,15 +1,13 @@ use serde::de::DeserializeOwned; use serde::Serialize; use std::cmp::Reverse; -use std::marker::PhantomData; -use std::sync::atomic::{AtomicU32, Ordering}; +use std::error::Error; use itertools::Itertools; use p3_air::Air; use p3_challenger::{CanObserve, FieldChallenger}; use p3_commit::Pcs; use p3_commit::PolynomialSpace; -use p3_field::ExtensionField; use p3_field::PrimeField32; use p3_field::{AbstractExtensionField, AbstractField}; use p3_matrix::dense::RowMajorMatrix; @@ -17,19 +15,106 @@ use p3_matrix::Matrix; use p3_maybe_rayon::prelude::*; use p3_util::log2_strict_usize; -use super::{quotient_values, PcsProverData, StarkMachine, Val}; +use super::{quotient_values, StarkMachine, Val}; use super::{types::*, StarkGenericConfig}; use super::{Com, OpeningProof}; use super::{StarkProvingKey, VerifierConstraintFolder}; use crate::air::MachineAir; use crate::lookup::InteractionBuilder; use crate::stark::record::MachineRecord; +use crate::stark::DebugConstraintBuilder; use crate::stark::MachineChip; use crate::stark::PackedChallenge; +use crate::stark::PcsProverData; use crate::stark::ProverConstraintFolder; +use crate::stark::StarkVerifyingKey; use crate::utils::SP1CoreOpts; -fn chunk_vec(mut vec: Vec, chunk_size: usize) -> Vec> { +pub trait MachineProver>: + 'static + Send + Sync +{ + type Error: Error + Send + Sync; + + /// Create a new prover from a given machine. + fn new(machine: StarkMachine) -> Self; + + /// A reference to the machine that this prover is using. + fn machine(&self) -> &StarkMachine; + + /// Calculate the main commitment for a given record. + fn commit(&self, record: &A::Record) -> Com; + + /// Commit and generate a proof for a given record, using the given challenger. + fn commit_and_open( + &self, + pk: &StarkProvingKey, + record: A::Record, + challenger: &mut SC::Challenger, + ) -> Result, Self::Error>; + + /// Generate a proof for the given records. + fn prove( + &self, + pk: &StarkProvingKey, + records: Vec, + challenger: &mut SC::Challenger, + opts: ::Config, + ) -> Result, Self::Error> + where + A: for<'a> Air, SC::Challenge>>; + + /// The stark config for the machine. + fn config(&self) -> &SC { + self.machine().config() + } + + fn num_pv_elts(&self) -> usize { + self.machine().num_pv_elts() + } + + fn shard_chips<'a, 'b>( + &'a self, + shard: &'b A::Record, + ) -> impl Iterator> + where + 'a: 'b, + SC: 'b, + { + self.machine().shard_chips(shard) + } + + fn setup(&self, program: &A::Program) -> (StarkProvingKey, StarkVerifyingKey) { + self.machine().setup(program) + } + + /// Update the challenger with the given shard data + fn update( + &self, + challenger: &mut SC::Challenger, + commitment: Com, + public_values: &[SC::Val], + ) { + // Observe the commitment. + challenger.observe(commitment); + // Observe the public values. + challenger.observe_slice(public_values); + } + + fn debug_constraints( + &self, + pk: &StarkProvingKey, + records: Vec, + challenger: &mut SC::Challenger, + ) where + SC::Val: PrimeField32, + A: for<'a> Air, SC::Challenge>>, + { + self.machine().debug_constraints(pk, records, challenger) + } +} + +#[allow(dead_code)] +pub fn chunk_vec(mut vec: Vec, chunk_size: usize) -> Vec> { let mut result = Vec::new(); while !vec.is_empty() { let current_chunk_size = std::cmp::min(chunk_size, vec.len()); @@ -39,156 +124,155 @@ fn chunk_vec(mut vec: Vec, chunk_size: usize) -> Vec> { result } -pub trait Prover>> { - fn prove_shards( - machine: &StarkMachine, - pk: &StarkProvingKey, - shards: Vec, - challenger: &mut SC::Challenger, - opts: SP1CoreOpts, - ) -> MachineProof - where - A: for<'a> Air> - + Air>> - + for<'a> Air>; +pub struct DefaultProver { + machine: StarkMachine, } -impl Prover for LocalProver +#[derive(Debug, Clone, Copy)] +pub struct DefaultProverError; + +impl std::fmt::Display for DefaultProverError { + fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { + write!(f, "DefaultProverError") + } +} + +impl Error for DefaultProverError {} + +impl MachineProver for DefaultProver where + SC: 'static + StarkGenericConfig + Send + Sync, + A: MachineAir + + for<'a> Air> + + Air>> + + for<'a> Air>, + A::Record: MachineRecord, SC::Val: PrimeField32, - SC: StarkGenericConfig + Send + Sync, - SC::Challenger: Clone, Com: Send + Sync, PcsProverData: Send + Sync, OpeningProof: Send + Sync, ShardMainData: Serialize + DeserializeOwned, - A: MachineAir>, + SC::Challenger: Clone, { - fn prove_shards( - machine: &StarkMachine, + type Error = DefaultProverError; + + fn new(machine: StarkMachine) -> Self { + Self { machine } + } + + fn machine(&self) -> &StarkMachine { + &self.machine + } + + fn commit(&self, record: &A::Record) -> Com { + self.commit_main(record).main_commit + } + + /// Prove the execution record is valid. + /// + /// Given a proving key `pk` and a matching execution record `record`, this function generates + /// a STARK proof that the execution record is valid. + fn prove( + &self, pk: &StarkProvingKey, - shards: Vec, + mut records: Vec, challenger: &mut SC::Challenger, - opts: SP1CoreOpts, - ) -> MachineProof + opts: ::Config, + ) -> Result, Self::Error> where - A: for<'a> Air> - + Air>> - + for<'a> Air>, + A: for<'a> Air, SC::Challenge>>, { + let chips = self.machine().chips(); + records.iter_mut().for_each(|record| { + chips.iter().for_each(|chip| { + let mut output = A::Record::default(); + chip.generate_dependencies(record, &mut output); + record.append(&mut output); + }); + record.register_nonces(&opts); + }); + // Observe the preprocessed commitment. pk.observe_into(challenger); - // Generate and commit the traces for each segment. - let (shard_commits, shard_data) = Self::commit_shards(machine, &shards, opts); + + // Generate and commit the traces for each shard. + let shard_data = records + .into_par_iter() + .map(|record| self.commit_main(&record)) + .collect::>(); // Observe the challenges for each segment. tracing::debug_span!("observing all challenges").in_scope(|| { - shard_commits - .into_iter() - .zip(shards.iter()) - .for_each(|(commitment, shard)| { - challenger.observe(commitment); - challenger - .observe_slice(&shard.public_values::()[0..machine.num_pv_elts()]); - }); + shard_data.iter().for_each(|data| { + challenger.observe(data.main_commit.clone()); + challenger.observe_slice(&data.public_values[0..self.num_pv_elts()]); + }); }); - let finished = AtomicU32::new(0); - - // Generate a proof for each segment. Note that we clone the challenger so we can observe - // identical global challenges across the segments. - let chunking_multiplier = opts.shard_chunking_multiplier; - let chunk_size = std::cmp::max(chunking_multiplier * shards.len() / num_cpus::get(), 1); - let config = machine.config(); - let reconstruct_commitments = opts.reconstruct_commitments; - let shard_data_chunks = chunk_vec(shard_data, chunk_size); - let shard_chunks = chunk_vec(shards, chunk_size); - let parent_span = tracing::debug_span!("open_shards"); - let shard_proofs = parent_span.in_scope(|| { - shard_data_chunks + let shard_proofs = tracing::info_span!("prove_shards").in_scope(|| { + shard_data .into_par_iter() - .zip(shard_chunks.into_par_iter()) - .map(|(datas, shards)| { - datas - .into_iter() - .zip(shards) - .map(|(data, shard)| { - tracing::debug_span!(parent: &parent_span, "prove shard opening") - .in_scope(|| { - let idx = shard.index() as usize; - let data = if reconstruct_commitments { - Self::commit_main(config, machine, &shard, idx) - } else { - data.materialize() - .expect("failed to materialize shard main data") - }; - let ordering = data.chip_ordering.clone(); - let chips = - machine.shard_chips_ordered(&ordering).collect::>(); - let proof = Self::prove_shard( - config, - pk, - &chips, - data, - &mut challenger.clone(), - ); - finished.fetch_add(1, Ordering::Relaxed); - proof - }) - }) - .collect::>() - }) - .flatten() - .collect::>() - }); + .map(|data| self.prove_shard(pk, data, &mut challenger.clone())) + .collect::, _>>() + })?; - MachineProof { shard_proofs } + Ok(MachineProof { shard_proofs }) } -} -pub struct LocalProver(PhantomData, PhantomData); + /// Prove the program for the given shard and given a commitment to the main data. + fn commit_and_open( + &self, + pk: &StarkProvingKey, + record: A::Record, + challenger: &mut ::Challenger, + ) -> Result, Self::Error> { + let shard_data = self.commit_main(&record); + self.prove_shard(pk, shard_data, challenger) + } +} -impl LocalProver +impl DefaultProver where - SC: StarkGenericConfig, - SC::Challenger: Clone, - A: MachineAir, + SC: 'static + StarkGenericConfig + Send + Sync, + A: MachineAir + + for<'a> Air> + + Air>> + + for<'a> Air>, + A::Record: MachineRecord, + SC::Val: PrimeField32, Com: Send + Sync, PcsProverData: Send + Sync, + OpeningProof: Send + Sync, ShardMainData: Serialize + DeserializeOwned, + SC::Challenger: Clone, { - pub fn commit_main( - config: &SC, - machine: &StarkMachine, - shard: &A::Record, - index: usize, - ) -> ShardMainData { + fn commit_main(&self, shard: &A::Record) -> ShardMainData { // Filter the chips based on what is used. - let shard_chips = machine.shard_chips(shard).collect::>(); + let shard_chips = self.shard_chips(shard).collect::>(); // For each chip, generate the trace. let parent_span = tracing::debug_span!("generate traces for shard"); let mut named_traces = parent_span.in_scope(|| { - shard_chips - .par_iter() - .map(|chip| { - let chip_name = chip.name(); - - // We need to create an outer span here because, for some reason, - // the #[instrument] macro on the chip impl isn't attaching its span to `parent_span` - // to avoid the unnecessary span, remove the #[instrument] macro. - let trace = - tracing::debug_span!(parent: &parent_span, "generate trace for chip", %chip_name) - .in_scope(|| chip.generate_trace(shard, &mut A::Record::default())); - (chip_name, trace) - }) - .collect::>() - }); + shard_chips + .par_iter() + .map(|chip| { + let chip_name = chip.name(); + + // We need to create an outer span here because, for some reason, + // the #[instrument] macro on the chip impl isn't attaching its span to `parent_span` + // to avoid the unnecessary span, remove the #[instrument] macro. + let trace = + tracing::debug_span!(parent: &parent_span, "generate trace for chip", %chip_name) + .in_scope(|| chip.generate_trace(shard, &mut A::Record::default())); + (chip_name, trace) + }) + .collect::>() + }); // Order the chips and traces by trace size (biggest first), and get the ordering map. named_traces.sort_by_key(|(_, trace)| Reverse(trace.height())); - let pcs = config.pcs(); + let pcs = self.config().pcs(); let domains_and_traces = named_traces .iter() @@ -218,27 +302,21 @@ where main_commit, main_data, chip_ordering, - index, public_values: shard.public_values(), } } - /// Prove the program for the given shard and given a commitment to the main data. - pub fn prove_shard( - config: &SC, + fn prove_shard( + &self, pk: &StarkProvingKey, - chips: &[&MachineChip], mut shard_data: ShardMainData, challenger: &mut SC::Challenger, - ) -> ShardProof - where - Val: PrimeField32, - SC: Send + Sync, - ShardMainData: DeserializeOwned, - A: for<'a> Air> - + Air>> - + for<'a> Air>, - { + ) -> Result, DefaultProverError> { + let chips = self + .machine() + .shard_chips_ordered(&shard_data.chip_ordering) + .collect::>(); + let config = self.machine().config(); // Get the traces. let traces = &mut shard_data.traces; @@ -527,7 +605,7 @@ where ) .collect::>(); - ShardProof:: { + Ok(ShardProof:: { commitment: ShardCommitment { main_commit: shard_data.main_commit.clone(), permutation_commit, @@ -539,61 +617,6 @@ where opening_proof, chip_ordering: shard_data.chip_ordering, public_values: shard_data.public_values, - } - } - - pub fn commit_shards( - machine: &StarkMachine, - shards: &[A::Record], - opts: SP1CoreOpts, - ) -> (Vec>, Vec>) - where - F: PrimeField32, - EF: ExtensionField, - SC: StarkGenericConfig + Send + Sync, - SC::Challenger: Clone, - PcsProverData: Send + Sync, - ShardMainData: Serialize + DeserializeOwned, - { - let config = machine.config(); - - // Get the number of shards that is the threshold for saving shards to disk instead of - // keeping all the shards in memory. - let reconstruct_commitments = opts.reconstruct_commitments; - let finished = AtomicU32::new(0); - let chunk_size = std::cmp::max(shards.len() / num_cpus::get(), 1); - let parent_span = tracing::debug_span!("commit to all shards"); - let (commitments, shard_main_data): (Vec<_>, Vec<_>) = parent_span.in_scope(|| { - shards - .par_chunks(chunk_size) - .map(|shard_batch| { - shard_batch - .iter() - .map(|shard| { - tracing::debug_span!(parent: &parent_span, "commit to shard").in_scope( - || { - let index = shard.index(); - let data = - Self::commit_main(config, machine, shard, index as usize); - finished.fetch_add(1, Ordering::Relaxed); - let commitment = data.main_commit.clone(); - let data = if reconstruct_commitments { - ShardMainDataWrapper::Empty() - } else { - data.to_in_memory() - }; - (commitment, data) - }, - ) - }) - .collect::>() - }) - .flatten() - .collect::>() - .into_iter() - .unzip() - }); - - (commitments, shard_main_data) + }) } } diff --git a/core/src/stark/record.rs b/core/src/stark/record.rs index 2261885140..a82a77ce6b 100644 --- a/core/src/stark/record.rs +++ b/core/src/stark/record.rs @@ -1,19 +1,15 @@ -use std::collections::HashMap; +use hashbrown::HashMap; use p3_field::AbstractField; pub trait MachineRecord: Default + Sized + Send + Sync + Clone { - type Config: Default; - - fn index(&self) -> u32; - - fn set_index(&mut self, index: u32); + type Config: 'static + Copy + Send + Sync; fn stats(&self) -> HashMap; fn append(&mut self, other: &mut Self); - fn shard(self, config: &Self::Config) -> Vec; + fn register_nonces(&mut self, _opts: &Self::Config) {} fn public_values(&self) -> Vec; } diff --git a/core/src/stark/types.rs b/core/src/stark/types.rs index e3eede2874..f0b6fb49b9 100644 --- a/core/src/stark/types.rs +++ b/core/src/stark/types.rs @@ -1,17 +1,10 @@ -use std::{ - collections::HashMap, - fmt::Debug, - fs::File, - io::{BufReader, BufWriter, Seek}, -}; - -use bincode::{deserialize_from, Error}; +use std::fmt::Debug; + +use hashbrown::HashMap; use p3_matrix::dense::RowMajorMatrix; use p3_matrix::dense::RowMajorMatrixView; use p3_matrix::stack::VerticalPair; -use serde::{de::DeserializeOwned, Deserialize, Serialize}; -use size::Size; -use tracing::trace; +use serde::{Deserialize, Serialize}; use super::{Challenge, Com, OpeningProof, PcsProverData, StarkGenericConfig, Val}; @@ -25,7 +18,6 @@ pub struct ShardMainData { pub main_commit: Com, pub main_data: PcsProverData, pub chip_ordering: HashMap, - pub index: usize, pub public_values: Vec, } @@ -35,7 +27,6 @@ impl ShardMainData { main_commit: Com, main_data: PcsProverData, chip_ordering: HashMap, - index: usize, public_values: Vec>, ) -> Self { Self { @@ -43,54 +34,9 @@ impl ShardMainData { main_commit, main_data, chip_ordering, - index, public_values, } } - - pub fn save(&self, file: File) -> Result, Error> - where - ShardMainData: Serialize, - { - let mut writer = BufWriter::new(&file); - bincode::serialize_into(&mut writer, self)?; - drop(writer); - let metadata = file.metadata()?; - let bytes_written = metadata.len(); - trace!( - "wrote {} while saving ShardMainData", - Size::from_bytes(bytes_written) - ); - Ok(ShardMainDataWrapper::TempFile(file, bytes_written)) - } - - pub const fn to_in_memory(self) -> ShardMainDataWrapper { - ShardMainDataWrapper::InMemory(self) - } -} - -pub enum ShardMainDataWrapper { - InMemory(ShardMainData), - TempFile(File, u64), - Empty(), -} - -impl ShardMainDataWrapper { - pub fn materialize(self) -> Result, Error> - where - ShardMainData: DeserializeOwned, - { - match self { - Self::InMemory(data) => Ok(data), - Self::TempFile(file, _) => { - let mut buffer = BufReader::new(&file); - buffer.seek(std::io::SeekFrom::Start(0))?; - let data = deserialize_from(&mut buffer)?; - Ok(data) - } - Self::Empty() => unreachable!(), - } - } } #[derive(Debug, Clone, Serialize, Deserialize)] @@ -124,7 +70,7 @@ pub struct ShardOpenedValues { /// The maximum number of elements that can be stored in the public values vec. Both SP1 and recursive /// proofs need to pad their public_values vec to this length. This is required since the recursion /// verification program expects the public values vec to be fixed length. -pub const PROOF_MAX_NUM_PVS: usize = 241; +pub const PROOF_MAX_NUM_PVS: usize = 370; #[derive(Serialize, Deserialize, Clone)] #[serde(bound = "")] @@ -158,6 +104,23 @@ impl ShardProof { .map(|c| c.cumulative_sum) .sum() } + + pub fn log_degree_cpu(&self) -> usize { + let idx = self.chip_ordering.get("CPU").expect("CPU chip not found"); + self.opened_values.chips[*idx].log_degree + } + + pub fn contains_cpu(&self) -> bool { + self.chip_ordering.contains_key("CPU") + } + + pub fn contains_memory_init(&self) -> bool { + self.chip_ordering.contains_key("MemoryInit") + } + + pub fn contains_memory_finalize(&self) -> bool { + self.chip_ordering.contains_key("MemoryFinalize") + } } #[derive(Serialize, Deserialize, Clone)] diff --git a/core/src/stark/verifier.rs b/core/src/stark/verifier.rs index 17e3753336..f1b51aaba8 100644 --- a/core/src/stark/verifier.rs +++ b/core/src/stark/verifier.rs @@ -51,7 +51,9 @@ impl>> Verifier { let pcs = config.pcs(); - assert_eq!(chips.len(), opened_values.chips.len()); + if chips.len() != opened_values.chips.len() { + return Err(VerificationError::ChipOpeningLengthMismatch); + } let log_degrees = opened_values .chips @@ -199,11 +201,6 @@ impl>> Verifier { .map_err(|_| VerificationError::OodEvaluationMismatch(chip.name()))?; } - let nb_cpu_chips = chips.iter().filter(|chip| chip.name() == "CPU").count(); - if nb_cpu_chips != 1 { - return Err(VerificationError::MissingCpuChip); - } - Ok(()) } @@ -417,6 +414,7 @@ pub enum VerificationError { /// The shape of the opening arguments is invalid. OpeningShapeError(String, OpeningShapeError), MissingCpuChip, + ChipOpeningLengthMismatch, } impl Debug for OpeningShapeError { @@ -483,6 +481,9 @@ impl Debug for VerificationError { VerificationError::MissingCpuChip => { write!(f, "Missing CPU chip") } + VerificationError::ChipOpeningLengthMismatch => { + write!(f, "Chip opening length mismatch") + } } } } @@ -502,6 +503,9 @@ impl Display for VerificationError { VerificationError::MissingCpuChip => { write!(f, "Missing CPU chip in shard") } + VerificationError::ChipOpeningLengthMismatch => { + write!(f, "Chip opening length mismatch") + } } } } diff --git a/core/src/syscall/hint.rs b/core/src/syscall/hint.rs index 8cf8a2d614..d0fb51d8be 100644 --- a/core/src/syscall/hint.rs +++ b/core/src/syscall/hint.rs @@ -12,7 +12,11 @@ impl SyscallHintLen { impl Syscall for SyscallHintLen { fn execute(&self, ctx: &mut SyscallContext, _arg1: u32, _arg2: u32) -> Option { if ctx.rt.state.input_stream_ptr >= ctx.rt.state.input_stream.len() { - panic!("not enough vecs in hint input stream"); + panic!( + "failed reading stdin due to insufficient input data: input_stream_ptr={}, input_stream_len={}", + ctx.rt.state.input_stream_ptr, + ctx.rt.state.input_stream.len() + ); } Some(ctx.rt.state.input_stream[ctx.rt.state.input_stream_ptr].len() as u32) } @@ -30,7 +34,11 @@ impl SyscallHintRead { impl Syscall for SyscallHintRead { fn execute(&self, ctx: &mut SyscallContext, ptr: u32, len: u32) -> Option { if ctx.rt.state.input_stream_ptr >= ctx.rt.state.input_stream.len() { - panic!("not enough vecs in hint input stream"); + panic!( + "failed reading stdin due to insufficient input data: input_stream_ptr={}, input_stream_len={}", + ctx.rt.state.input_stream_ptr, + ctx.rt.state.input_stream.len() + ); } let vec = &ctx.rt.state.input_stream[ctx.rt.state.input_stream_ptr]; ctx.rt.state.input_stream_ptr += 1; @@ -75,6 +83,7 @@ mod tests { use crate::{ io::SP1Stdin, runtime::Program, + stark::DefaultProver, utils::{prove, setup_logger, BabyBearPoseidon2, SP1CoreOpts}, }; @@ -96,6 +105,6 @@ mod tests { let program = Program::from(HINT_IO_ELF); let config = BabyBearPoseidon2::new(); - prove(program, &stdin, config, SP1CoreOpts::default()).unwrap(); + prove::<_, DefaultProver<_, _>>(program, &stdin, config, SP1CoreOpts::default()).unwrap(); } } diff --git a/core/src/syscall/precompiles/edwards/ed_add.rs b/core/src/syscall/precompiles/edwards/ed_add.rs index 44d29edb83..a51956a388 100644 --- a/core/src/syscall/precompiles/edwards/ed_add.rs +++ b/core/src/syscall/precompiles/edwards/ed_add.rs @@ -3,6 +3,8 @@ use core::mem::size_of; use std::fmt::Debug; use std::marker::PhantomData; +use hashbrown::HashMap; +use itertools::Itertools; use num::BigUint; use num::Zero; @@ -14,6 +16,7 @@ use p3_matrix::dense::RowMajorMatrix; use p3_matrix::Matrix; use p3_maybe_rayon::prelude::IntoParallelRefIterator; use p3_maybe_rayon::prelude::ParallelIterator; +use p3_maybe_rayon::prelude::ParallelSlice; use sp1_derive::AlignedBorrow; use super::{NUM_LIMBS, WORDS_CURVE_POINT}; @@ -34,8 +37,8 @@ use crate::runtime::ExecutionRecord; use crate::runtime::Program; use crate::runtime::Syscall; use crate::runtime::SyscallCode; -use crate::syscall::precompiles::create_ec_add_event; use crate::syscall::precompiles::SyscallContext; +use crate::syscall::precompiles::{create_ec_add_event, ECAddEvent}; use crate::utils::ec::edwards::ed25519::Ed25519BaseField; use crate::utils::ec::edwards::EdwardsParameters; use crate::utils::ec::AffinePoint; @@ -158,69 +161,19 @@ impl MachineAir for Ed fn generate_trace( &self, input: &ExecutionRecord, - output: &mut ExecutionRecord, + _: &mut ExecutionRecord, ) -> RowMajorMatrix { - let (mut rows, new_byte_lookup_events): ( - Vec<[F; NUM_ED_ADD_COLS]>, - Vec>, - ) = input + let mut rows = input .ed_add_events .par_iter() .map(|event| { let mut row = [F::zero(); NUM_ED_ADD_COLS]; let cols: &mut EdAddAssignCols = row.as_mut_slice().borrow_mut(); - - // Decode affine points. - let p = &event.p; - let q = &event.q; - let p = AffinePoint::::from_words_le(p); - let (p_x, p_y) = (p.x, p.y); - let q = AffinePoint::::from_words_le(q); - let (q_x, q_y) = (q.x, q.y); - - // Populate basic columns. - cols.is_real = F::one(); - cols.shard = F::from_canonical_u32(event.shard); - cols.channel = F::from_canonical_u32(event.channel); - cols.clk = F::from_canonical_u32(event.clk); - cols.p_ptr = F::from_canonical_u32(event.p_ptr); - cols.q_ptr = F::from_canonical_u32(event.q_ptr); - - let mut new_byte_lookup_events = Vec::new(); - Self::populate_field_ops( - &mut new_byte_lookup_events, - event.shard, - event.channel, - cols, - p_x, - p_y, - q_x, - q_y, - ); - - // Populate the memory access columns. - for i in 0..WORDS_CURVE_POINT { - cols.q_access[i].populate( - event.channel, - event.q_memory_records[i], - &mut new_byte_lookup_events, - ); - } - for i in 0..WORDS_CURVE_POINT { - cols.p_access[i].populate( - event.channel, - event.p_memory_records[i], - &mut new_byte_lookup_events, - ); - } - - (row, new_byte_lookup_events) + let mut blu = Vec::new(); + self.event_to_row(event, cols, &mut blu); + row }) - .unzip(); - - for byte_lookup_events in new_byte_lookup_events { - output.add_byte_lookup_events(byte_lookup_events); - } + .collect::>(); pad_rows(&mut rows, || { let mut row = [F::zero(); NUM_ED_ADD_COLS]; @@ -255,11 +208,67 @@ impl MachineAir for Ed trace } + fn generate_dependencies(&self, input: &Self::Record, output: &mut Self::Record) { + let chunk_size = std::cmp::max(input.ed_add_events.len() / num_cpus::get(), 1); + + let blu_batches = input + .ed_add_events + .par_chunks(chunk_size) + .map(|events| { + let mut blu: HashMap> = HashMap::new(); + events.iter().for_each(|event| { + let mut row = [F::zero(); NUM_ED_ADD_COLS]; + let cols: &mut EdAddAssignCols = row.as_mut_slice().borrow_mut(); + self.event_to_row(event, cols, &mut blu); + }); + blu + }) + .collect::>(); + + output.add_sharded_byte_lookup_events(blu_batches.iter().collect_vec()); + } + fn included(&self, shard: &Self::Record) -> bool { !shard.ed_add_events.is_empty() } } +impl EdAddAssignChip { + /// Create a row from an event. + fn event_to_row( + &self, + event: &ECAddEvent, + cols: &mut EdAddAssignCols, + blu: &mut impl ByteRecord, + ) { + // Decode affine points. + let p = &event.p; + let q = &event.q; + let p = AffinePoint::::from_words_le(p); + let (p_x, p_y) = (p.x, p.y); + let q = AffinePoint::::from_words_le(q); + let (q_x, q_y) = (q.x, q.y); + + // Populate basic columns. + cols.is_real = F::one(); + cols.shard = F::from_canonical_u32(event.shard); + cols.channel = F::from_canonical_u32(event.channel); + cols.clk = F::from_canonical_u32(event.clk); + cols.p_ptr = F::from_canonical_u32(event.p_ptr); + cols.q_ptr = F::from_canonical_u32(event.q_ptr); + + Self::populate_field_ops(blu, event.shard, event.channel, cols, p_x, p_y, q_x, q_y); + + // Populate the memory access columns. + for i in 0..WORDS_CURVE_POINT { + cols.q_access[i].populate(event.channel, event.q_memory_records[i], blu); + } + for i in 0..WORDS_CURVE_POINT { + cols.p_access[i].populate(event.channel, event.p_memory_records[i], blu); + } + } +} + impl BaseAir for EdAddAssignChip { fn width(&self) -> usize { NUM_ED_ADD_COLS @@ -422,6 +431,7 @@ where #[cfg(test)] mod tests { + use crate::stark::DefaultProver; use crate::utils; use crate::utils::tests::{ED25519_ELF, ED_ADD_ELF}; use crate::Program; @@ -430,13 +440,13 @@ mod tests { fn test_ed_add_simple() { utils::setup_logger(); let program = Program::from(ED_ADD_ELF); - utils::run_test(program).unwrap(); + utils::run_test::>(program).unwrap(); } #[test] fn test_ed25519_program() { utils::setup_logger(); let program = Program::from(ED25519_ELF); - utils::run_test(program).unwrap(); + utils::run_test::>(program).unwrap(); } } diff --git a/core/src/syscall/precompiles/edwards/ed_decompress.rs b/core/src/syscall/precompiles/edwards/ed_decompress.rs index a0618137ce..2fdd7071d5 100644 --- a/core/src/syscall/precompiles/edwards/ed_decompress.rs +++ b/core/src/syscall/precompiles/edwards/ed_decompress.rs @@ -27,9 +27,9 @@ use crate::memory::MemoryWriteCols; use crate::operations::field::field_op::FieldOpCols; use crate::operations::field::field_op::FieldOperation; use crate::operations::field::field_sqrt::FieldSqrtCols; -use crate::operations::field::params::FieldParameters; use crate::operations::field::params::Limbs; -use crate::operations::field::range::FieldRangeCols; +use crate::operations::field::params::{limbs_from_vec, FieldParameters}; +use crate::operations::field::range::FieldLtCols; use crate::runtime::ExecutionRecord; use crate::runtime::MemoryReadRecord; use crate::runtime::MemoryWriteRecord; @@ -53,7 +53,7 @@ use super::{WordsFieldElement, WORDS_FIELD_ELEMENT}; #[derive(Debug, Clone, Serialize, Deserialize)] pub struct EdDecompressEvent { - pub lookup_id: usize, + pub lookup_id: u128, pub shard: u32, pub channel: u32, pub clk: u32, @@ -84,7 +84,7 @@ pub struct EdDecompressCols { pub sign: T, pub x_access: GenericArray, WordsFieldElement>, pub y_access: GenericArray, WordsFieldElement>, - pub(crate) y_range: FieldRangeCols, + pub(crate) y_range: FieldLtCols, pub(crate) yy: FieldOpCols, pub(crate) u: FieldOpCols, pub(crate) dyy: FieldOpCols, @@ -141,7 +141,8 @@ impl EdDecompressCols { y: &BigUint, ) { let one = BigUint::one(); - self.y_range.populate(blu_events, shard, channel, y); + self.y_range + .populate(blu_events, shard, channel, y, &Ed25519BaseField::modulus()); let yy = self .yy .populate(blu_events, shard, channel, y, y, FieldOperation::Mul); @@ -186,8 +187,15 @@ impl EdDecompressCols { builder.assert_bool(self.sign); let y: Limbs = limbs_from_prev_access(&self.y_access); - self.y_range - .eval(builder, &y, self.shard, self.channel, self.is_real); + let max_num_limbs = P::to_limbs_field_vec(&Ed25519BaseField::modulus()); + self.y_range.eval( + builder, + &y, + &limbs_from_vec::(max_num_limbs), + self.shard, + self.channel, + self.is_real, + ); self.yy.eval( builder, &y, @@ -454,6 +462,7 @@ where pub mod tests { use crate::{ runtime::Program, + stark::DefaultProver, utils::{self, tests::ED_DECOMPRESS_ELF}, }; @@ -461,6 +470,6 @@ pub mod tests { fn test_ed_decompress() { utils::setup_logger(); let program = Program::from(ED_DECOMPRESS_ELF); - utils::run_test(program).unwrap(); + utils::run_test::>(program).unwrap(); } } diff --git a/core/src/syscall/precompiles/keccak256/air.rs b/core/src/syscall/precompiles/keccak256/air.rs index 1647616798..3d4acbdf95 100644 --- a/core/src/syscall/precompiles/keccak256/air.rs +++ b/core/src/syscall/precompiles/keccak256/air.rs @@ -126,7 +126,7 @@ where memory_limbs[i].clone(), local .keccak - .a_prime_prime_prime(x_idx as usize, y_idx as usize, i), + .a_prime_prime_prime(y_idx as usize, x_idx as usize, i), ) } } @@ -153,7 +153,7 @@ where mod test { use crate::io::{SP1PublicValues, SP1Stdin}; use crate::runtime::Program; - use crate::stark::{RiscvAir, StarkGenericConfig}; + use crate::stark::{DefaultProver, RiscvAir, StarkGenericConfig}; use crate::utils::SP1CoreOpts; use crate::utils::{prove, setup_logger, tests::KECCAK256_ELF, BabyBearPoseidon2}; @@ -190,8 +190,9 @@ mod test { let config = BabyBearPoseidon2::new(); let program = Program::from(KECCAK256_ELF); - let (proof, public_values) = - prove(program, &stdin, config, SP1CoreOpts::default()).unwrap(); + let (proof, public_values, _) = + prove::<_, DefaultProver<_, _>>(program, &stdin, config, SP1CoreOpts::default()) + .unwrap(); let mut public_values = SP1PublicValues::from(&public_values); let config = BabyBearPoseidon2::new(); diff --git a/core/src/syscall/precompiles/keccak256/mod.rs b/core/src/syscall/precompiles/keccak256/mod.rs index 2b95b8b400..d5e1d01190 100644 --- a/core/src/syscall/precompiles/keccak256/mod.rs +++ b/core/src/syscall/precompiles/keccak256/mod.rs @@ -15,7 +15,7 @@ const STATE_NUM_WORDS: usize = STATE_SIZE * 2; #[derive(Debug, Clone, Serialize, Deserialize)] pub struct KeccakPermuteEvent { - pub lookup_id: usize, + pub lookup_id: u128, pub shard: u32, pub channel: u32, pub clk: u32, @@ -41,6 +41,7 @@ impl KeccakPermuteChip { #[cfg(test)] pub mod permute_tests { use crate::runtime::SyscallCode; + use crate::stark::DefaultProver; use crate::utils::{run_test, SP1CoreOpts}; use crate::{ runtime::{Instruction, Opcode, Program, Runtime}, @@ -85,13 +86,13 @@ pub mod permute_tests { utils::setup_logger(); let program = keccak_permute_program(); - run_test(program).unwrap(); + run_test::>(program).unwrap(); } #[test] fn test_keccak_permute_program_prove() { utils::setup_logger(); let program = Program::from(KECCAK_PERMUTE_ELF); - run_test(program).unwrap(); + run_test::>(program).unwrap(); } } diff --git a/core/src/syscall/precompiles/keccak256/trace.rs b/core/src/syscall/precompiles/keccak256/trace.rs index e4700fe97a..9ca3839535 100644 --- a/core/src/syscall/precompiles/keccak256/trace.rs +++ b/core/src/syscall/precompiles/keccak256/trace.rs @@ -126,7 +126,6 @@ impl MachineAir for KeccakPermuteChip { let mut rows: Vec<[F; NUM_KECCAK_MEM_COLS]> = vec![]; for (mut row, mut record) in rows_and_records { rows.append(&mut row); - record.index = output.index; output.append(&mut record); } diff --git a/core/src/syscall/precompiles/mod.rs b/core/src/syscall/precompiles/mod.rs index 5f1bc43e60..43aab6f7fc 100644 --- a/core/src/syscall/precompiles/mod.rs +++ b/core/src/syscall/precompiles/mod.rs @@ -19,7 +19,7 @@ use serde::{Deserialize, Serialize}; /// Elliptic curve add event. #[derive(Debug, Clone, Serialize, Deserialize)] pub struct ECAddEvent { - pub lookup_id: usize, + pub lookup_id: u128, pub shard: u32, pub channel: u32, pub clk: u32, @@ -84,7 +84,7 @@ pub fn create_ec_add_event( /// Elliptic curve double event. #[derive(Debug, Clone, Serialize, Deserialize)] pub struct ECDoubleEvent { - pub lookup_id: usize, + pub lookup_id: u128, pub shard: u32, pub channel: u32, pub clk: u32, @@ -134,12 +134,12 @@ pub fn create_ec_double_event( /// Elliptic curve point decompress event. #[derive(Debug, Clone, Serialize, Deserialize)] pub struct ECDecompressEvent { - pub lookup_id: usize, + pub lookup_id: u128, pub shard: u32, pub channel: u32, pub clk: u32, pub ptr: u32, - pub is_odd: bool, + pub sign_bit: bool, pub x_bytes: Vec, pub decompressed_y_bytes: Vec, pub x_memory_records: Vec, @@ -149,11 +149,11 @@ pub struct ECDecompressEvent { pub fn create_ec_decompress_event( rt: &mut SyscallContext, slice_ptr: u32, - is_odd: u32, + sign_bit: u32, ) -> ECDecompressEvent { let start_clk = rt.clk; assert!(slice_ptr % 4 == 0, "slice_ptr must be 4-byte aligned"); - assert!(is_odd <= 1, "is_odd must be 0 or 1"); + assert!(sign_bit <= 1, "is_odd must be 0 or 1"); let num_limbs = ::Limbs::USIZE; let num_words_field_element = num_limbs / 4; @@ -171,7 +171,7 @@ pub fn create_ec_decompress_event( _ => panic!("Unsupported curve"), }; - let computed_point: AffinePoint = decompress_fn(&x_bytes_be, is_odd); + let computed_point: AffinePoint = decompress_fn(&x_bytes_be, sign_bit); let mut decompressed_y_bytes = computed_point.y.to_bytes_le(); decompressed_y_bytes.resize(num_limbs, 0u8); @@ -185,7 +185,7 @@ pub fn create_ec_decompress_event( channel: rt.current_channel(), clk: start_clk, ptr: slice_ptr, - is_odd: is_odd != 0, + sign_bit: sign_bit != 0, x_bytes: x_bytes.to_vec(), decompressed_y_bytes, x_memory_records, diff --git a/core/src/syscall/precompiles/sha256/compress/mod.rs b/core/src/syscall/precompiles/sha256/compress/mod.rs index 47401a25bc..dcf3749b3a 100644 --- a/core/src/syscall/precompiles/sha256/compress/mod.rs +++ b/core/src/syscall/precompiles/sha256/compress/mod.rs @@ -20,7 +20,7 @@ pub const SHA_COMPRESS_K: [u32; 64] = [ #[derive(Debug, Clone, Serialize, Deserialize)] pub struct ShaCompressEvent { - pub lookup_id: usize, + pub lookup_id: u128, pub shard: u32, pub channel: u32, pub clk: u32, @@ -54,6 +54,7 @@ pub mod compress_tests { use crate::{ runtime::{Instruction, Opcode, Program, SyscallCode}, + stark::DefaultProver, utils::{run_test, setup_logger, tests::SHA_COMPRESS_ELF}, }; @@ -93,13 +94,13 @@ pub mod compress_tests { fn prove_babybear() { setup_logger(); let program = sha_compress_program(); - run_test(program).unwrap(); + run_test::>(program).unwrap(); } #[test] fn test_sha_compress_program() { setup_logger(); let program = Program::from(SHA_COMPRESS_ELF); - run_test(program).unwrap(); + run_test::>(program).unwrap(); } } diff --git a/core/src/syscall/precompiles/sha256/compress/trace.rs b/core/src/syscall/precompiles/sha256/compress/trace.rs index 6cd524fbd6..9a1eaad76b 100644 --- a/core/src/syscall/precompiles/sha256/compress/trace.rs +++ b/core/src/syscall/precompiles/sha256/compress/trace.rs @@ -1,16 +1,19 @@ use std::borrow::BorrowMut; +use hashbrown::HashMap; +use itertools::Itertools; use p3_field::PrimeField32; use p3_matrix::dense::RowMajorMatrix; use p3_matrix::Matrix; +use p3_maybe_rayon::prelude::{ParallelIterator, ParallelSlice}; use super::{ columns::{ShaCompressCols, NUM_SHA_COMPRESS_COLS}, - ShaCompressChip, SHA_COMPRESS_K, + ShaCompressChip, ShaCompressEvent, SHA_COMPRESS_K, }; use crate::{ air::{MachineAir, Word}, - bytes::event::ByteRecord, + bytes::{event::ByteRecord, ByteLookupEvent}, runtime::{ExecutionRecord, Program}, utils::pad_rows, }; @@ -27,230 +30,16 @@ impl MachineAir for ShaCompressChip { fn generate_trace( &self, input: &ExecutionRecord, - output: &mut ExecutionRecord, + _: &mut ExecutionRecord, ) -> RowMajorMatrix { - let mut rows = Vec::new(); + let rows = Vec::new(); - let mut new_byte_lookup_events = Vec::new(); + let mut wrapped_rows = Some(rows); for i in 0..input.sha_compress_events.len() { - let mut event = input.sha_compress_events[i].clone(); - let shard = event.shard; - let channel = event.channel; - - let og_h = event.h; - - let mut octet_num_idx = 0; - - // Load a, b, c, d, e, f, g, h. - for j in 0..8usize { - let mut row = [F::zero(); NUM_SHA_COMPRESS_COLS]; - let cols: &mut ShaCompressCols = row.as_mut_slice().borrow_mut(); - - cols.shard = F::from_canonical_u32(event.shard); - cols.channel = F::from_canonical_u32(event.channel); - cols.clk = F::from_canonical_u32(event.clk); - cols.w_ptr = F::from_canonical_u32(event.w_ptr); - cols.h_ptr = F::from_canonical_u32(event.h_ptr); - - cols.octet[j] = F::one(); - cols.octet_num[octet_num_idx] = F::one(); - cols.is_initialize = F::one(); - - cols.mem.populate_read( - channel, - event.h_read_records[j], - &mut new_byte_lookup_events, - ); - cols.mem_addr = F::from_canonical_u32(event.h_ptr + (j * 4) as u32); - - cols.a = Word::from(event.h_read_records[0].value); - cols.b = Word::from(event.h_read_records[1].value); - cols.c = Word::from(event.h_read_records[2].value); - cols.d = Word::from(event.h_read_records[3].value); - cols.e = Word::from(event.h_read_records[4].value); - cols.f = Word::from(event.h_read_records[5].value); - cols.g = Word::from(event.h_read_records[6].value); - cols.h = Word::from(event.h_read_records[7].value); - - cols.is_real = F::one(); - cols.start = cols.is_real * cols.octet_num[0] * cols.octet[0]; - rows.push(row); - } - - // Performs the compress operation. - for j in 0..64 { - if j % 8 == 0 { - octet_num_idx += 1; - } - let mut row = [F::zero(); NUM_SHA_COMPRESS_COLS]; - let cols: &mut ShaCompressCols = row.as_mut_slice().borrow_mut(); - - cols.k = Word::from(SHA_COMPRESS_K[j]); - cols.is_compression = F::one(); - cols.octet[j % 8] = F::one(); - cols.octet_num[octet_num_idx] = F::one(); - - cols.shard = F::from_canonical_u32(event.shard); - cols.channel = F::from_canonical_u32(event.channel); - cols.clk = F::from_canonical_u32(event.clk); - cols.w_ptr = F::from_canonical_u32(event.w_ptr); - cols.h_ptr = F::from_canonical_u32(event.h_ptr); - cols.mem.populate_read( - channel, - event.w_i_read_records[j], - &mut new_byte_lookup_events, - ); - cols.mem_addr = F::from_canonical_u32(event.w_ptr + (j * 4) as u32); - - let a = event.h[0]; - let b = event.h[1]; - let c = event.h[2]; - let d = event.h[3]; - let e = event.h[4]; - let f = event.h[5]; - let g = event.h[6]; - let h = event.h[7]; - cols.a = Word::from(a); - cols.b = Word::from(b); - cols.c = Word::from(c); - cols.d = Word::from(d); - cols.e = Word::from(e); - cols.f = Word::from(f); - cols.g = Word::from(g); - cols.h = Word::from(h); - - let e_rr_6 = cols.e_rr_6.populate(output, shard, channel, e, 6); - let e_rr_11 = cols.e_rr_11.populate(output, shard, channel, e, 11); - let e_rr_25 = cols.e_rr_25.populate(output, shard, channel, e, 25); - let s1_intermediate = cols - .s1_intermediate - .populate(output, shard, channel, e_rr_6, e_rr_11); - let s1 = cols - .s1 - .populate(output, shard, channel, s1_intermediate, e_rr_25); - - let e_and_f = cols.e_and_f.populate(output, shard, channel, e, f); - let e_not = cols.e_not.populate(output, shard, channel, e); - let e_not_and_g = cols.e_not_and_g.populate(output, shard, channel, e_not, g); - let ch = cols - .ch - .populate(output, shard, channel, e_and_f, e_not_and_g); - - let temp1 = cols.temp1.populate( - output, - shard, - channel, - h, - s1, - ch, - event.w[j], - SHA_COMPRESS_K[j], - ); - - let a_rr_2 = cols.a_rr_2.populate(output, shard, channel, a, 2); - let a_rr_13 = cols.a_rr_13.populate(output, shard, channel, a, 13); - let a_rr_22 = cols.a_rr_22.populate(output, shard, channel, a, 22); - let s0_intermediate = cols - .s0_intermediate - .populate(output, shard, channel, a_rr_2, a_rr_13); - let s0 = cols - .s0 - .populate(output, shard, channel, s0_intermediate, a_rr_22); - - let a_and_b = cols.a_and_b.populate(output, shard, channel, a, b); - let a_and_c = cols.a_and_c.populate(output, shard, channel, a, c); - let b_and_c = cols.b_and_c.populate(output, shard, channel, b, c); - let maj_intermediate = cols - .maj_intermediate - .populate(output, shard, channel, a_and_b, a_and_c); - let maj = cols - .maj - .populate(output, shard, channel, maj_intermediate, b_and_c); - - let temp2 = cols.temp2.populate(output, shard, channel, s0, maj); - - let d_add_temp1 = cols.d_add_temp1.populate(output, shard, channel, d, temp1); - let temp1_add_temp2 = cols - .temp1_add_temp2 - .populate(output, shard, channel, temp1, temp2); - - event.h[7] = g; - event.h[6] = f; - event.h[5] = e; - event.h[4] = d_add_temp1; - event.h[3] = c; - event.h[2] = b; - event.h[1] = a; - event.h[0] = temp1_add_temp2; - - cols.is_real = F::one(); - cols.start = cols.is_real * cols.octet_num[0] * cols.octet[0]; - - rows.push(row); - } - - let mut v: [u32; 8] = (0..8) - .map(|i| event.h[i]) - .collect::>() - .try_into() - .unwrap(); - - octet_num_idx += 1; - // Store a, b, c, d, e, f, g, h. - for j in 0..8usize { - let mut row = [F::zero(); NUM_SHA_COMPRESS_COLS]; - let cols: &mut ShaCompressCols = row.as_mut_slice().borrow_mut(); - - cols.shard = F::from_canonical_u32(event.shard); - cols.channel = F::from_canonical_u32(event.channel); - cols.clk = F::from_canonical_u32(event.clk); - cols.w_ptr = F::from_canonical_u32(event.w_ptr); - cols.h_ptr = F::from_canonical_u32(event.h_ptr); - - cols.octet[j] = F::one(); - cols.octet_num[octet_num_idx] = F::one(); - cols.is_finalize = F::one(); - - cols.finalize_add - .populate(output, shard, channel, og_h[j], event.h[j]); - cols.mem.populate_write( - channel, - event.h_write_records[j], - &mut new_byte_lookup_events, - ); - cols.mem_addr = F::from_canonical_u32(event.h_ptr + (j * 4) as u32); - - v[j] = event.h[j]; - cols.a = Word::from(v[0]); - cols.b = Word::from(v[1]); - cols.c = Word::from(v[2]); - cols.d = Word::from(v[3]); - cols.e = Word::from(v[4]); - cols.f = Word::from(v[5]); - cols.g = Word::from(v[6]); - cols.h = Word::from(v[7]); - - match j { - 0 => cols.finalized_operand = cols.a, - 1 => cols.finalized_operand = cols.b, - 2 => cols.finalized_operand = cols.c, - 3 => cols.finalized_operand = cols.d, - 4 => cols.finalized_operand = cols.e, - 5 => cols.finalized_operand = cols.f, - 6 => cols.finalized_operand = cols.g, - 7 => cols.finalized_operand = cols.h, - _ => panic!("unsupported j"), - }; - - cols.is_real = F::one(); - cols.is_last_row = cols.octet[7] * cols.octet_num[9]; - cols.start = cols.is_real * cols.octet_num[0] * cols.octet[0]; - - rows.push(row); - } + let event = input.sha_compress_events[i].clone(); + self.event_to_rows(&event, &mut wrapped_rows, &mut Vec::new()); } - - output.add_byte_lookup_events(new_byte_lookup_events); + let mut rows = wrapped_rows.unwrap(); let num_real_rows = rows.len(); @@ -296,7 +85,245 @@ impl MachineAir for ShaCompressChip { trace } + fn generate_dependencies(&self, input: &Self::Record, output: &mut Self::Record) { + let chunk_size = std::cmp::max(input.sha_compress_events.len() / num_cpus::get(), 1); + + let blu_batches = input + .sha_compress_events + .par_chunks(chunk_size) + .map(|events| { + let mut blu: HashMap> = HashMap::new(); + events.iter().for_each(|event| { + self.event_to_rows::(event, &mut None, &mut blu); + }); + blu + }) + .collect::>(); + + output.add_sharded_byte_lookup_events(blu_batches.iter().collect_vec()); + } + fn included(&self, shard: &Self::Record) -> bool { !shard.sha_compress_events.is_empty() } } + +impl ShaCompressChip { + fn event_to_rows( + &self, + event: &ShaCompressEvent, + rows: &mut Option>, + blu: &mut impl ByteRecord, + ) { + let shard = event.shard; + let channel = event.channel; + + let og_h = event.h; + + let mut octet_num_idx = 0; + + // Load a, b, c, d, e, f, g, h. + for j in 0..8usize { + let mut row = [F::zero(); NUM_SHA_COMPRESS_COLS]; + let cols: &mut ShaCompressCols = row.as_mut_slice().borrow_mut(); + + cols.shard = F::from_canonical_u32(event.shard); + cols.channel = F::from_canonical_u32(event.channel); + cols.clk = F::from_canonical_u32(event.clk); + cols.w_ptr = F::from_canonical_u32(event.w_ptr); + cols.h_ptr = F::from_canonical_u32(event.h_ptr); + + cols.octet[j] = F::one(); + cols.octet_num[octet_num_idx] = F::one(); + cols.is_initialize = F::one(); + + cols.mem + .populate_read(channel, event.h_read_records[j], blu); + cols.mem_addr = F::from_canonical_u32(event.h_ptr + (j * 4) as u32); + + cols.a = Word::from(event.h_read_records[0].value); + cols.b = Word::from(event.h_read_records[1].value); + cols.c = Word::from(event.h_read_records[2].value); + cols.d = Word::from(event.h_read_records[3].value); + cols.e = Word::from(event.h_read_records[4].value); + cols.f = Word::from(event.h_read_records[5].value); + cols.g = Word::from(event.h_read_records[6].value); + cols.h = Word::from(event.h_read_records[7].value); + + cols.is_real = F::one(); + cols.start = cols.is_real * cols.octet_num[0] * cols.octet[0]; + if rows.as_ref().is_some() { + rows.as_mut().unwrap().push(row); + } + } + + // Performs the compress operation. + let mut h_array = event.h; + for j in 0..64 { + if j % 8 == 0 { + octet_num_idx += 1; + } + let mut row = [F::zero(); NUM_SHA_COMPRESS_COLS]; + let cols: &mut ShaCompressCols = row.as_mut_slice().borrow_mut(); + + cols.k = Word::from(SHA_COMPRESS_K[j]); + cols.is_compression = F::one(); + cols.octet[j % 8] = F::one(); + cols.octet_num[octet_num_idx] = F::one(); + + cols.shard = F::from_canonical_u32(event.shard); + cols.channel = F::from_canonical_u32(event.channel); + cols.clk = F::from_canonical_u32(event.clk); + cols.w_ptr = F::from_canonical_u32(event.w_ptr); + cols.h_ptr = F::from_canonical_u32(event.h_ptr); + cols.mem + .populate_read(channel, event.w_i_read_records[j], blu); + cols.mem_addr = F::from_canonical_u32(event.w_ptr + (j * 4) as u32); + + let a = h_array[0]; + let b = h_array[1]; + let c = h_array[2]; + let d = h_array[3]; + let e = h_array[4]; + let f = h_array[5]; + let g = h_array[6]; + let h = h_array[7]; + cols.a = Word::from(a); + cols.b = Word::from(b); + cols.c = Word::from(c); + cols.d = Word::from(d); + cols.e = Word::from(e); + cols.f = Word::from(f); + cols.g = Word::from(g); + cols.h = Word::from(h); + + let e_rr_6 = cols.e_rr_6.populate(blu, shard, channel, e, 6); + let e_rr_11 = cols.e_rr_11.populate(blu, shard, channel, e, 11); + let e_rr_25 = cols.e_rr_25.populate(blu, shard, channel, e, 25); + let s1_intermediate = cols + .s1_intermediate + .populate(blu, shard, channel, e_rr_6, e_rr_11); + let s1 = cols + .s1 + .populate(blu, shard, channel, s1_intermediate, e_rr_25); + + let e_and_f = cols.e_and_f.populate(blu, shard, channel, e, f); + let e_not = cols.e_not.populate(blu, shard, channel, e); + let e_not_and_g = cols.e_not_and_g.populate(blu, shard, channel, e_not, g); + let ch = cols.ch.populate(blu, shard, channel, e_and_f, e_not_and_g); + + let temp1 = cols.temp1.populate( + blu, + shard, + channel, + h, + s1, + ch, + event.w[j], + SHA_COMPRESS_K[j], + ); + + let a_rr_2 = cols.a_rr_2.populate(blu, shard, channel, a, 2); + let a_rr_13 = cols.a_rr_13.populate(blu, shard, channel, a, 13); + let a_rr_22 = cols.a_rr_22.populate(blu, shard, channel, a, 22); + let s0_intermediate = cols + .s0_intermediate + .populate(blu, shard, channel, a_rr_2, a_rr_13); + let s0 = cols + .s0 + .populate(blu, shard, channel, s0_intermediate, a_rr_22); + + let a_and_b = cols.a_and_b.populate(blu, shard, channel, a, b); + let a_and_c = cols.a_and_c.populate(blu, shard, channel, a, c); + let b_and_c = cols.b_and_c.populate(blu, shard, channel, b, c); + let maj_intermediate = cols + .maj_intermediate + .populate(blu, shard, channel, a_and_b, a_and_c); + let maj = cols + .maj + .populate(blu, shard, channel, maj_intermediate, b_and_c); + + let temp2 = cols.temp2.populate(blu, shard, channel, s0, maj); + + let d_add_temp1 = cols.d_add_temp1.populate(blu, shard, channel, d, temp1); + let temp1_add_temp2 = cols + .temp1_add_temp2 + .populate(blu, shard, channel, temp1, temp2); + + h_array[7] = g; + h_array[6] = f; + h_array[5] = e; + h_array[4] = d_add_temp1; + h_array[3] = c; + h_array[2] = b; + h_array[1] = a; + h_array[0] = temp1_add_temp2; + + cols.is_real = F::one(); + cols.start = cols.is_real * cols.octet_num[0] * cols.octet[0]; + + if rows.as_ref().is_some() { + rows.as_mut().unwrap().push(row); + } + } + + let mut v: [u32; 8] = (0..8) + .map(|i| h_array[i]) + .collect::>() + .try_into() + .unwrap(); + + octet_num_idx += 1; + // Store a, b, c, d, e, f, g, h. + for j in 0..8usize { + let mut row = [F::zero(); NUM_SHA_COMPRESS_COLS]; + let cols: &mut ShaCompressCols = row.as_mut_slice().borrow_mut(); + + cols.shard = F::from_canonical_u32(event.shard); + cols.channel = F::from_canonical_u32(event.channel); + cols.clk = F::from_canonical_u32(event.clk); + cols.w_ptr = F::from_canonical_u32(event.w_ptr); + cols.h_ptr = F::from_canonical_u32(event.h_ptr); + + cols.octet[j] = F::one(); + cols.octet_num[octet_num_idx] = F::one(); + cols.is_finalize = F::one(); + + cols.finalize_add + .populate(blu, shard, channel, og_h[j], h_array[j]); + cols.mem + .populate_write(channel, event.h_write_records[j], blu); + cols.mem_addr = F::from_canonical_u32(event.h_ptr + (j * 4) as u32); + + v[j] = h_array[j]; + cols.a = Word::from(v[0]); + cols.b = Word::from(v[1]); + cols.c = Word::from(v[2]); + cols.d = Word::from(v[3]); + cols.e = Word::from(v[4]); + cols.f = Word::from(v[5]); + cols.g = Word::from(v[6]); + cols.h = Word::from(v[7]); + + match j { + 0 => cols.finalized_operand = cols.a, + 1 => cols.finalized_operand = cols.b, + 2 => cols.finalized_operand = cols.c, + 3 => cols.finalized_operand = cols.d, + 4 => cols.finalized_operand = cols.e, + 5 => cols.finalized_operand = cols.f, + 6 => cols.finalized_operand = cols.g, + 7 => cols.finalized_operand = cols.h, + _ => panic!("unsupported j"), + }; + + cols.is_real = F::one(); + cols.is_last_row = cols.octet[7] * cols.octet_num[9]; + cols.start = cols.is_real * cols.octet_num[0] * cols.octet[0]; + + if rows.as_ref().is_some() { + rows.as_mut().unwrap().push(row); + } + } + } +} diff --git a/core/src/syscall/precompiles/sha256/extend/mod.rs b/core/src/syscall/precompiles/sha256/extend/mod.rs index 7868cabd88..a28da0045c 100644 --- a/core/src/syscall/precompiles/sha256/extend/mod.rs +++ b/core/src/syscall/precompiles/sha256/extend/mod.rs @@ -11,7 +11,7 @@ use serde::{Deserialize, Serialize}; #[derive(Debug, Clone, Serialize, Deserialize)] pub struct ShaExtendEvent { - pub lookup_id: usize, + pub lookup_id: u128, pub shard: u32, pub channel: u32, pub clk: u32, @@ -56,6 +56,7 @@ pub mod extend_tests { air::MachineAir, alu::AluEvent, runtime::{ExecutionRecord, Instruction, Opcode, Program, SyscallCode}, + stark::DefaultProver, utils::{ self, run_test, tests::{SHA2_ELF, SHA_EXTEND_ELF}, @@ -103,20 +104,20 @@ pub mod extend_tests { fn test_sha_prove() { utils::setup_logger(); let program = sha_extend_program(); - run_test(program).unwrap(); + run_test::>(program).unwrap(); } #[test] fn test_sha256_program() { utils::setup_logger(); let program = Program::from(SHA2_ELF); - run_test(program).unwrap(); + run_test::>(program).unwrap(); } #[test] fn test_sha_extend_program() { utils::setup_logger(); let program = Program::from(SHA_EXTEND_ELF); - run_test(program).unwrap(); + run_test::>(program).unwrap(); } } diff --git a/core/src/syscall/precompiles/sha256/extend/trace.rs b/core/src/syscall/precompiles/sha256/extend/trace.rs index 2dcf882260..d3784e7355 100644 --- a/core/src/syscall/precompiles/sha256/extend/trace.rs +++ b/core/src/syscall/precompiles/sha256/extend/trace.rs @@ -1,15 +1,18 @@ +use hashbrown::HashMap; +use itertools::Itertools; use p3_field::PrimeField32; use p3_matrix::dense::RowMajorMatrix; use p3_matrix::Matrix; +use p3_maybe_rayon::prelude::{ParallelIterator, ParallelSlice}; use std::borrow::BorrowMut; use crate::{ air::MachineAir, - bytes::event::ByteRecord, + bytes::{event::ByteRecord, ByteLookupEvent}, runtime::{ExecutionRecord, Program}, }; -use super::{ShaExtendChip, ShaExtendCols, NUM_SHA_EXTEND_COLS}; +use super::{ShaExtendChip, ShaExtendCols, ShaExtendEvent, NUM_SHA_EXTEND_COLS}; impl MachineAir for ShaExtendChip { type Record = ExecutionRecord; @@ -23,126 +26,21 @@ impl MachineAir for ShaExtendChip { fn generate_trace( &self, input: &ExecutionRecord, - output: &mut ExecutionRecord, + _: &mut ExecutionRecord, ) -> RowMajorMatrix { - let mut rows = Vec::new(); + let rows = Vec::new(); let mut new_byte_lookup_events = Vec::new(); + let mut wrapped_rows = Some(rows); for i in 0..input.sha_extend_events.len() { - let event = input.sha_extend_events[i].clone(); - let shard = event.shard; - for j in 0..48usize { - let mut row = [F::zero(); NUM_SHA_EXTEND_COLS]; - let cols: &mut ShaExtendCols = row.as_mut_slice().borrow_mut(); - cols.is_real = F::one(); - cols.populate_flags(j); - cols.shard = F::from_canonical_u32(event.shard); - cols.channel = F::from_canonical_u32(event.channel); - cols.clk = F::from_canonical_u32(event.clk); - cols.w_ptr = F::from_canonical_u32(event.w_ptr); - - cols.w_i_minus_15.populate( - event.channel, - event.w_i_minus_15_reads[j], - &mut new_byte_lookup_events, - ); - cols.w_i_minus_2.populate( - event.channel, - event.w_i_minus_2_reads[j], - &mut new_byte_lookup_events, - ); - cols.w_i_minus_16.populate( - event.channel, - event.w_i_minus_16_reads[j], - &mut new_byte_lookup_events, - ); - cols.w_i_minus_7.populate( - event.channel, - event.w_i_minus_7_reads[j], - &mut new_byte_lookup_events, - ); - - // `s0 := (w[i-15] rightrotate 7) xor (w[i-15] rightrotate 18) xor (w[i-15] rightshift 3)`. - let w_i_minus_15 = event.w_i_minus_15_reads[j].value; - let w_i_minus_15_rr_7 = - cols.w_i_minus_15_rr_7 - .populate(output, shard, event.channel, w_i_minus_15, 7); - let w_i_minus_15_rr_18 = cols.w_i_minus_15_rr_18.populate( - output, - shard, - event.channel, - w_i_minus_15, - 18, - ); - let w_i_minus_15_rs_3 = - cols.w_i_minus_15_rs_3 - .populate(output, shard, event.channel, w_i_minus_15, 3); - let s0_intermediate = cols.s0_intermediate.populate( - output, - shard, - event.channel, - w_i_minus_15_rr_7, - w_i_minus_15_rr_18, - ); - let s0 = cols.s0.populate( - output, - shard, - event.channel, - s0_intermediate, - w_i_minus_15_rs_3, - ); - - // `s1 := (w[i-2] rightrotate 17) xor (w[i-2] rightrotate 19) xor (w[i-2] rightshift 10)`. - let w_i_minus_2 = event.w_i_minus_2_reads[j].value; - let w_i_minus_2_rr_17 = - cols.w_i_minus_2_rr_17 - .populate(output, shard, event.channel, w_i_minus_2, 17); - let w_i_minus_2_rr_19 = - cols.w_i_minus_2_rr_19 - .populate(output, shard, event.channel, w_i_minus_2, 19); - let w_i_minus_2_rs_10 = - cols.w_i_minus_2_rs_10 - .populate(output, shard, event.channel, w_i_minus_2, 10); - let s1_intermediate = cols.s1_intermediate.populate( - output, - shard, - event.channel, - w_i_minus_2_rr_17, - w_i_minus_2_rr_19, - ); - let s1 = cols.s1.populate( - output, - shard, - event.channel, - s1_intermediate, - w_i_minus_2_rs_10, - ); - - // Compute `s2`. - let w_i_minus_7 = event.w_i_minus_7_reads[j].value; - let w_i_minus_16 = event.w_i_minus_16_reads[j].value; - cols.s2.populate( - output, - shard, - event.channel, - w_i_minus_16, - s0, - w_i_minus_7, - s1, - ); - - cols.w_i.populate( - event.channel, - event.w_i_writes[j], - &mut new_byte_lookup_events, - ); - - rows.push(row); - } + self.event_to_rows( + &input.sha_extend_events[i], + &mut wrapped_rows, + &mut new_byte_lookup_events, + ); } - output.add_byte_lookup_events(new_byte_lookup_events); - + let mut rows = wrapped_rows.unwrap(); let nb_rows = rows.len(); let mut padded_nb_rows = nb_rows.next_power_of_two(); if padded_nb_rows == 2 || padded_nb_rows == 1 { @@ -171,7 +69,119 @@ impl MachineAir for ShaExtendChip { trace } + fn generate_dependencies(&self, input: &Self::Record, output: &mut Self::Record) { + let chunk_size = std::cmp::max(input.sha_extend_events.len() / num_cpus::get(), 1); + + let blu_batches = input + .sha_extend_events + .par_chunks(chunk_size) + .map(|events| { + let mut blu: HashMap> = HashMap::new(); + events.iter().for_each(|event| { + self.event_to_rows::(event, &mut None, &mut blu); + }); + blu + }) + .collect::>(); + + output.add_sharded_byte_lookup_events(blu_batches.iter().collect_vec()); + } + fn included(&self, shard: &Self::Record) -> bool { !shard.sha_extend_events.is_empty() } } + +impl ShaExtendChip { + fn event_to_rows( + &self, + event: &ShaExtendEvent, + rows: &mut Option>, + blu: &mut impl ByteRecord, + ) { + let shard = event.shard; + for j in 0..48usize { + let mut row = [F::zero(); NUM_SHA_EXTEND_COLS]; + let cols: &mut ShaExtendCols = row.as_mut_slice().borrow_mut(); + cols.is_real = F::one(); + cols.populate_flags(j); + cols.shard = F::from_canonical_u32(event.shard); + cols.channel = F::from_canonical_u32(event.channel); + cols.clk = F::from_canonical_u32(event.clk); + cols.w_ptr = F::from_canonical_u32(event.w_ptr); + + cols.w_i_minus_15 + .populate(event.channel, event.w_i_minus_15_reads[j], blu); + cols.w_i_minus_2 + .populate(event.channel, event.w_i_minus_2_reads[j], blu); + cols.w_i_minus_16 + .populate(event.channel, event.w_i_minus_16_reads[j], blu); + cols.w_i_minus_7 + .populate(event.channel, event.w_i_minus_7_reads[j], blu); + + // `s0 := (w[i-15] rightrotate 7) xor (w[i-15] rightrotate 18) xor (w[i-15] rightshift 3)`. + let w_i_minus_15 = event.w_i_minus_15_reads[j].value; + let w_i_minus_15_rr_7 = + cols.w_i_minus_15_rr_7 + .populate(blu, shard, event.channel, w_i_minus_15, 7); + let w_i_minus_15_rr_18 = + cols.w_i_minus_15_rr_18 + .populate(blu, shard, event.channel, w_i_minus_15, 18); + let w_i_minus_15_rs_3 = + cols.w_i_minus_15_rs_3 + .populate(blu, shard, event.channel, w_i_minus_15, 3); + let s0_intermediate = cols.s0_intermediate.populate( + blu, + shard, + event.channel, + w_i_minus_15_rr_7, + w_i_minus_15_rr_18, + ); + let s0 = cols.s0.populate( + blu, + shard, + event.channel, + s0_intermediate, + w_i_minus_15_rs_3, + ); + + // `s1 := (w[i-2] rightrotate 17) xor (w[i-2] rightrotate 19) xor (w[i-2] rightshift 10)`. + let w_i_minus_2 = event.w_i_minus_2_reads[j].value; + let w_i_minus_2_rr_17 = + cols.w_i_minus_2_rr_17 + .populate(blu, shard, event.channel, w_i_minus_2, 17); + let w_i_minus_2_rr_19 = + cols.w_i_minus_2_rr_19 + .populate(blu, shard, event.channel, w_i_minus_2, 19); + let w_i_minus_2_rs_10 = + cols.w_i_minus_2_rs_10 + .populate(blu, shard, event.channel, w_i_minus_2, 10); + let s1_intermediate = cols.s1_intermediate.populate( + blu, + shard, + event.channel, + w_i_minus_2_rr_17, + w_i_minus_2_rr_19, + ); + let s1 = cols.s1.populate( + blu, + shard, + event.channel, + s1_intermediate, + w_i_minus_2_rs_10, + ); + + // Compute `s2`. + let w_i_minus_7 = event.w_i_minus_7_reads[j].value; + let w_i_minus_16 = event.w_i_minus_16_reads[j].value; + cols.s2 + .populate(blu, shard, event.channel, w_i_minus_16, s0, w_i_minus_7, s1); + + cols.w_i.populate(event.channel, event.w_i_writes[j], blu); + + if rows.as_ref().is_some() { + rows.as_mut().unwrap().push(row); + } + } + } +} diff --git a/core/src/syscall/precompiles/uint256/air.rs b/core/src/syscall/precompiles/uint256/air.rs index dd8cce29e4..9e723646f6 100644 --- a/core/src/syscall/precompiles/uint256/air.rs +++ b/core/src/syscall/precompiles/uint256/air.rs @@ -4,6 +4,7 @@ use crate::memory::{value_as_limbs, MemoryReadCols, MemoryWriteCols}; use crate::operations::field::field_op::{FieldOpCols, FieldOperation}; use crate::operations::field::params::NumWords; use crate::operations::field::params::{Limbs, NumLimbs}; +use crate::operations::field::range::FieldLtCols; use crate::operations::IsZeroOperation; use crate::runtime::{ExecutionRecord, Program, Syscall, SyscallCode}; use crate::runtime::{MemoryReadRecord, MemoryWriteRecord}; @@ -15,8 +16,7 @@ use crate::utils::{ words_to_bytes_le_vec, }; use generic_array::GenericArray; -use num::Zero; -use num::{BigUint, One}; +use num::{BigUint, One, Zero}; use p3_air::AirBuilder; use p3_air::{Air, BaseAir}; use p3_field::AbstractField; @@ -34,7 +34,7 @@ const NUM_COLS: usize = size_of::>(); #[derive(Debug, Clone, Serialize, Deserialize)] pub struct Uint256MulEvent { - pub lookup_id: usize, + pub lookup_id: u128, pub shard: u32, pub channel: u32, pub clk: u32, @@ -73,7 +73,7 @@ pub struct Uint256MulCols { /// The clock cycle of the syscall. pub clk: T, - /// The none of the operation. + /// The nonce of the operation. pub nonce: T, /// The pointer to the first input. @@ -88,12 +88,17 @@ pub struct Uint256MulCols { pub y_memory: GenericArray, WordsFieldElement>, pub modulus_memory: GenericArray, WordsFieldElement>, - // Columns for checking if modulus is zero. If it's zero, then use 2^256 as the effective modulus. + /// Columns for checking if modulus is zero. If it's zero, then use 2^256 as the effective modulus. pub modulus_is_zero: IsZeroOperation, + /// Column that is equal to is_real * (1 - modulus_is_zero.result). + pub modulus_is_not_zero: T, + // Output values. We compute (x * y) % modulus. pub output: FieldOpCols, + pub output_range_check: FieldLtCols, + pub is_real: T, } @@ -167,7 +172,7 @@ impl MachineAir for Uint256MulChip { } else { modulus.clone() }; - cols.output.populate_with_modulus( + let result = cols.output.populate_with_modulus( &mut new_byte_lookup_events, event.shard, event.channel, @@ -178,6 +183,17 @@ impl MachineAir for Uint256MulChip { FieldOperation::Mul, ); + cols.modulus_is_not_zero = F::one() - cols.modulus_is_zero.result; + if cols.modulus_is_not_zero == F::one() { + cols.output_range_check.populate( + &mut new_byte_lookup_events, + event.shard, + event.channel, + &result, + &effective_modulus, + ); + } + row }) .collect::>(); @@ -226,10 +242,12 @@ impl MachineAir for Uint256MulChip { impl Syscall for Uint256MulChip { fn num_extra_cycles(&self) -> u32 { - 0 + 1 } fn execute(&self, rt: &mut SyscallContext, arg1: u32, arg2: u32) -> Option { + let clk = rt.clk; + let x_ptr = arg1; if x_ptr % 4 != 0 { panic!(); @@ -269,13 +287,14 @@ impl Syscall for Uint256MulChip { // Convert the result to little endian u32 words. let result = bytes_to_words_le::<8>(&result_bytes); + // Increment clk so that the write is not at the same cycle as the read. + rt.clk += 1; // Write the result to x and keep track of the memory records. let x_memory_records = rt.mw_slice(x_ptr, &result); let lookup_id = rt.syscall_lookup_id; let shard = rt.current_shard(); let channel = rt.current_channel(); - let clk = rt.clk; rt.record_mut().uint256_mul_events.push(Uint256MulEvent { lookup_id, shard, @@ -362,6 +381,21 @@ where local.is_real, ); + // Verify the range of the output if the moduls is not zero. Also, check the value of + // modulus_is_not_zero. + local.output_range_check.eval( + builder, + &local.output.result, + &modulus_limbs, + local.shard, + local.channel, + local.modulus_is_not_zero, + ); + builder.assert_eq( + local.modulus_is_not_zero, + local.is_real * (AB::Expr::one() - modulus_is_zero.into()), + ); + // Assert that the correct result is being written to x_memory. builder .when(local.is_real) @@ -371,7 +405,7 @@ where builder.eval_memory_access_slice( local.shard, local.channel, - local.clk.into(), + local.clk.into() + AB::Expr::one(), local.x_ptr, &local.x_memory, local.is_real, diff --git a/core/src/syscall/precompiles/uint256/mod.rs b/core/src/syscall/precompiles/uint256/mod.rs index 0b35b0056f..e7b6b49213 100644 --- a/core/src/syscall/precompiles/uint256/mod.rs +++ b/core/src/syscall/precompiles/uint256/mod.rs @@ -6,6 +6,7 @@ pub use air::*; mod tests { use crate::operations::field::params::FieldParameters; + use crate::stark::DefaultProver; use crate::{ io::SP1Stdin, runtime::Program, @@ -21,7 +22,7 @@ mod tests { fn test_uint256_mul() { utils::setup_logger(); let program = Program::from(UINT256_MUL_ELF); - run_test_io(program, SP1Stdin::new()).unwrap(); + run_test_io::>(program, SP1Stdin::new()).unwrap(); } #[test] diff --git a/core/src/syscall/precompiles/weierstrass/weierstrass_add.rs b/core/src/syscall/precompiles/weierstrass/weierstrass_add.rs index 2eef29c6c7..7a25bd57e6 100644 --- a/core/src/syscall/precompiles/weierstrass/weierstrass_add.rs +++ b/core/src/syscall/precompiles/weierstrass/weierstrass_add.rs @@ -524,6 +524,7 @@ mod tests { use crate::{ runtime::Program, + stark::DefaultProver, utils::{ run_test, setup_logger, tests::{ @@ -537,48 +538,48 @@ mod tests { fn test_secp256k1_add_simple() { setup_logger(); let program = Program::from(SECP256K1_ADD_ELF); - run_test(program).unwrap(); + run_test::>(program).unwrap(); } #[test] fn test_bn254_add_simple() { setup_logger(); let program = Program::from(BN254_ADD_ELF); - run_test(program).unwrap(); + run_test::>(program).unwrap(); } #[test] fn test_bn254_mul_simple() { setup_logger(); let program = Program::from(BN254_MUL_ELF); - run_test(program).unwrap(); + run_test::>(program).unwrap(); } #[test] fn test_secp256k1_mul_simple() { setup_logger(); let program = Program::from(SECP256K1_MUL_ELF); - run_test(program).unwrap(); + run_test::>(program).unwrap(); } #[test] fn test_bls12381_add_simple() { setup_logger(); let program = Program::from(BLS12381_ADD_ELF); - run_test(program).unwrap(); + run_test::>(program).unwrap(); } #[test] fn test_bls12381_double_simple() { setup_logger(); let program = Program::from(BLS12381_DOUBLE_ELF); - run_test(program).unwrap(); + run_test::>(program).unwrap(); } #[test] fn test_bls12381_mul_simple() { setup_logger(); let program = Program::from(BLS12381_MUL_ELF); - run_test(program).unwrap(); + run_test::>(program).unwrap(); } } diff --git a/core/src/syscall/precompiles/weierstrass/weierstrass_decompress.rs b/core/src/syscall/precompiles/weierstrass/weierstrass_decompress.rs index 62958e86ca..495bf9781c 100644 --- a/core/src/syscall/precompiles/weierstrass/weierstrass_decompress.rs +++ b/core/src/syscall/precompiles/weierstrass/weierstrass_decompress.rs @@ -3,8 +3,7 @@ use core::mem::size_of; use std::fmt::Debug; use generic_array::GenericArray; -use num::BigUint; -use num::Zero; +use num::{BigUint, Zero}; use p3_air::{Air, AirBuilder, BaseAir}; use p3_field::AbstractField; use p3_field::PrimeField32; @@ -14,18 +13,16 @@ use sp1_derive::AlignedBorrow; use std::marker::PhantomData; use typenum::Unsigned; -use crate::air::BaseAirBuilder; -use crate::air::MachineAir; -use crate::air::SP1AirBuilder; +use crate::air::{BaseAirBuilder, MachineAir, SP1AirBuilder}; use crate::bytes::event::ByteRecord; use crate::memory::MemoryReadCols; use crate::memory::MemoryReadWriteCols; use crate::operations::field::field_op::FieldOpCols; use crate::operations::field::field_op::FieldOperation; use crate::operations::field::field_sqrt::FieldSqrtCols; -use crate::operations::field::params::{FieldParameters, NumWords}; +use crate::operations::field::params::{limbs_from_vec, FieldParameters, NumWords}; use crate::operations::field::params::{Limbs, NumLimbs}; -use crate::operations::field::range::FieldRangeCols; +use crate::operations::field::range::FieldLtCols; use crate::runtime::ExecutionRecord; use crate::runtime::Program; use crate::runtime::Syscall; @@ -56,10 +53,10 @@ pub struct WeierstrassDecompressCols { pub clk: T, pub nonce: T, pub ptr: T, - pub is_odd: T, + pub sign_bit: T, pub x_access: GenericArray, P::WordsFieldElement>, pub y_access: GenericArray, P::WordsFieldElement>, - pub(crate) range_x: FieldRangeCols, + pub(crate) range_x: FieldLtCols, pub(crate) x_2: FieldOpCols, pub(crate) x_3: FieldOpCols, pub(crate) x_3_plus_b: FieldOpCols, @@ -67,8 +64,35 @@ pub struct WeierstrassDecompressCols { pub(crate) neg_y: FieldOpCols, } -#[derive(Default)] +/// A set of columns to compute `WeierstrassDecompress` that decompresses a point on a Weierstrass +/// curve. +#[derive(Debug, Clone, AlignedBorrow)] +#[repr(C)] +pub struct LexicographicChoiceCols { + pub comparison_lt_cols: FieldLtCols, + pub neg_y_range_check: FieldLtCols, + pub is_y_eq_sqrt_y_result: T, + pub when_sqrt_y_res_is_lt: T, + pub when_neg_y_res_is_lt: T, +} + +/// The convention for choosing the decompressed `y` value given a sign bit. +pub enum SignChoiceRule { + /// Lease significant bit convention. + /// + /// In this convention, the `sign_bit` matches the pairty of the `y` value. This is the + /// convention used in the ECDSA signature scheme, for example, in the secp256k1 curve. + LeastSignificantBit, + /// Lexicographic convention. + /// + /// In this convention, the `sign_bit` corresponds to whether the `y` value is larger than its + /// negative counterpart with respect to the embedding of ptime field elements as integers. + /// This onvention used in the BLS signature scheme, for example, in the BLS12-381 curve. + Lexicographic, +} + pub struct WeierstrassDecompressChip { + sign_rule: SignChoiceRule, _marker: PhantomData, } @@ -89,8 +113,23 @@ impl Syscall for WeierstrassDecompressChip { } impl WeierstrassDecompressChip { - pub const fn new() -> Self { + pub const fn new(sign_rule: SignChoiceRule) -> Self { Self { + sign_rule, + _marker: PhantomData::, + } + } + + pub const fn with_lsb_rule() -> Self { + Self { + sign_rule: SignChoiceRule::LeastSignificantBit, + _marker: PhantomData::, + } + } + + pub const fn with_lexicographic_rule() -> Self { + Self { + sign_rule: SignChoiceRule::Lexicographic, _marker: PhantomData::, } } @@ -103,7 +142,8 @@ impl WeierstrassDecompressChip { x: BigUint, ) { // Y = sqrt(x^3 + b) - cols.range_x.populate(record, shard, channel, &x); + cols.range_x + .populate(record, shard, channel, &x, &E::BaseField::modulus()); let x_2 = cols.x_2.populate( record, shard, @@ -161,14 +201,18 @@ impl MachineAir }; let mut rows = Vec::new(); + let weierstrass_width = num_weierstrass_decompress_cols::(); + let width = BaseAir::::width(self); let mut new_byte_lookup_events = Vec::new(); + let modulus = E::BaseField::modulus(); + for i in 0..events.len() { let event = events[i].clone(); - let mut row = vec![F::zero(); num_weierstrass_decompress_cols::()]; + let mut row = vec![F::zero(); width]; let cols: &mut WeierstrassDecompressCols = - row.as_mut_slice().borrow_mut(); + row[0..weierstrass_width].borrow_mut(); cols.is_real = F::from_bool(true); cols.shard = F::from_canonical_u32(event.shard); @@ -176,7 +220,7 @@ impl MachineAir cols.channel = F::from_canonical_u32(event.channel); cols.clk = F::from_canonical_u32(event.clk); cols.ptr = F::from_canonical_u32(event.ptr); - cols.is_odd = F::from_canonical_u32(event.is_odd as u32); + cols.sign_bit = F::from_bool(event.sign_bit); let x = BigUint::from_bytes_le(&event.x_bytes); Self::populate_field_ops( @@ -202,14 +246,68 @@ impl MachineAir ); } + if matches!(self.sign_rule, SignChoiceRule::Lexicographic) { + let lsb = cols.y.lsb; + let choice_cols: &mut LexicographicChoiceCols = + row[weierstrass_width..width].borrow_mut(); + + let decompressed_y = BigUint::from_bytes_le(&event.decompressed_y_bytes); + let neg_y = &modulus - &decompressed_y; + + let is_y_eq_sqrt_y_result = + F::from_canonical_u8(event.decompressed_y_bytes[0] % 2) == lsb; + choice_cols.is_y_eq_sqrt_y_result = F::from_bool(is_y_eq_sqrt_y_result); + + if is_y_eq_sqrt_y_result { + choice_cols.neg_y_range_check.populate( + &mut new_byte_lookup_events, + event.shard, + event.channel, + &neg_y, + &modulus, + ); + } else { + choice_cols.neg_y_range_check.populate( + &mut new_byte_lookup_events, + event.shard, + event.channel, + &decompressed_y, + &modulus, + ); + } + if event.sign_bit { + assert!(neg_y < decompressed_y); + choice_cols.when_sqrt_y_res_is_lt = F::from_bool(!is_y_eq_sqrt_y_result); + choice_cols.when_neg_y_res_is_lt = F::from_bool(is_y_eq_sqrt_y_result); + choice_cols.comparison_lt_cols.populate( + &mut new_byte_lookup_events, + event.shard, + event.channel, + &neg_y, + &decompressed_y, + ); + } else { + assert!(neg_y > decompressed_y); + choice_cols.when_sqrt_y_res_is_lt = F::from_bool(is_y_eq_sqrt_y_result); + choice_cols.when_neg_y_res_is_lt = F::from_bool(!is_y_eq_sqrt_y_result); + choice_cols.comparison_lt_cols.populate( + &mut new_byte_lookup_events, + event.shard, + event.channel, + &decompressed_y, + &neg_y, + ); + } + } + rows.push(row); } output.add_byte_lookup_events(new_byte_lookup_events); pad_rows(&mut rows, || { - let mut row = vec![F::zero(); num_weierstrass_decompress_cols::()]; + let mut row = vec![F::zero(); width]; let cols: &mut WeierstrassDecompressCols = - row.as_mut_slice().borrow_mut(); + row.as_mut_slice()[0..weierstrass_width].borrow_mut(); // take X of the generator as a dummy value to make sure Y^2 = X^3 + b holds let dummy_value = E::generator().0; @@ -223,17 +321,12 @@ impl MachineAir row }); - let mut trace = RowMajorMatrix::new( - rows.into_iter().flatten().collect::>(), - num_weierstrass_decompress_cols::(), - ); + let mut trace = RowMajorMatrix::new(rows.into_iter().flatten().collect::>(), width); // Write the nonces to the trace. for i in 0..trace.height() { - let cols: &mut WeierstrassDecompressCols = trace.values[i - * num_weierstrass_decompress_cols::() - ..(i + 1) * num_weierstrass_decompress_cols::()] - .borrow_mut(); + let cols: &mut WeierstrassDecompressCols = + trace.values[i * width..i * width + weierstrass_width].borrow_mut(); cols.nonce = F::from_canonical_usize(i); } @@ -252,6 +345,12 @@ impl MachineAir impl BaseAir for WeierstrassDecompressChip { fn width(&self) -> usize { num_weierstrass_decompress_cols::() + + match self.sign_rule { + SignChoiceRule::LeastSignificantBit => 0, + SignChoiceRule::Lexicographic => { + size_of::>() + } + } } } @@ -262,10 +361,14 @@ where { fn eval(&self, builder: &mut AB) { let main = builder.main(); - let local = main.row_slice(0); - let local: &WeierstrassDecompressCols = (*local).borrow(); + + let weierstrass_cols = num_weierstrass_decompress_cols::(); + let local_slice = main.row_slice(0); + let local: &WeierstrassDecompressCols = + (*local_slice)[0..weierstrass_cols].borrow(); let next = main.row_slice(1); - let next: &WeierstrassDecompressCols = (*next).borrow(); + let next: &WeierstrassDecompressCols = + (*next)[0..weierstrass_cols].borrow(); // Constrain the incrementing nonce. builder.when_first_row().assert_zero(local.nonce); @@ -276,13 +379,19 @@ where let num_limbs = ::Limbs::USIZE; let num_words_field_element = num_limbs / 4; - builder.assert_bool(local.is_odd); + builder.assert_bool(local.sign_bit); let x: Limbs::Limbs> = limbs_from_prev_access(&local.x_access); - local - .range_x - .eval(builder, &x, local.shard, local.channel, local.is_real); + let max_num_limbs = E::BaseField::to_limbs_field_vec(&E::BaseField::modulus()); + local.range_x.eval( + builder, + &x, + &limbs_from_vec::::Limbs, AB::F>(max_num_limbs), + local.shard, + local.channel, + local.is_real, + ); local.x_2.eval( builder, &x, @@ -323,9 +432,6 @@ where local.is_real, ); - // Interpret the lowest bit of Y as whether it is odd or not. - let y_is_odd = local.y.lsb; - local.y.eval( builder, &local.x_3_plus_b.result, @@ -337,14 +443,126 @@ where let y_limbs: Limbs::Limbs> = limbs_from_access(&local.y_access); - builder - .when(local.is_real) - .when_ne(y_is_odd, AB::Expr::one() - local.is_odd) - .assert_all_eq(local.y.multiplication.result, y_limbs); - builder - .when(local.is_real) - .when_ne(y_is_odd, local.is_odd) - .assert_all_eq(local.neg_y.result, y_limbs); + + // Constrain the y value according the sign rule convention. + match self.sign_rule { + SignChoiceRule::LeastSignificantBit => { + // When the sign rule is LeastSignificantBit, the sign_bit should match the parity + // of the result. The parity of the square root result is given by the local.y.lsb + // value. Thus, if the sign_bit matches the local.y.lsb value, then the result + // should be the square root of the y value. Otherwise, the result should be the + // negative square root of the y value. + builder + .when(local.is_real) + .when_ne(local.y.lsb, AB::Expr::one() - local.sign_bit) + .assert_all_eq(local.y.multiplication.result, y_limbs); + builder + .when(local.is_real) + .when_ne(local.y.lsb, local.sign_bit) + .assert_all_eq(local.neg_y.result, y_limbs); + } + SignChoiceRule::Lexicographic => { + // When the sign rule is Lexicographic, the sign_bit corresponds to whether + // the result is greater than or less its negative with respect to the lexicographic + // ordering, embedding prime field values as integers. + // + // In order to endorce these constraints, we will use the auxillary choice columns. + + // Get the choice columns from the row slice + let choice_cols: &LexicographicChoiceCols = (*local_slice) + [weierstrass_cols + ..weierstrass_cols + + size_of::>()] + .borrow(); + + // Range check the neg_y value since we are now using a lexicographic comparison. + let modulus_limbs = E::BaseField::to_limbs_field_vec(&E::BaseField::modulus()); + let modulus_limbs = + limbs_from_vec::::Limbs, AB::F>( + modulus_limbs, + ); + choice_cols.neg_y_range_check.eval( + builder, + &local.neg_y.result, + &modulus_limbs, + local.shard, + local.channel, + local.is_real, + ); + + // Assert that the flags are booleans. + builder.assert_bool(choice_cols.is_y_eq_sqrt_y_result); + builder.assert_bool(choice_cols.when_sqrt_y_res_is_lt); + builder.assert_bool(choice_cols.when_neg_y_res_is_lt); + + // Assert that the `when` flags are disjoint: + builder.when(local.is_real).assert_one( + choice_cols.when_sqrt_y_res_is_lt + choice_cols.when_neg_y_res_is_lt, + ); + + // Assert that the value of `y` matches the claimed value by the flags. + + builder + .when(local.is_real) + .when(choice_cols.is_y_eq_sqrt_y_result) + .assert_all_eq(local.y.multiplication.result, y_limbs); + + builder + .when(local.is_real) + .when_not(choice_cols.is_y_eq_sqrt_y_result) + .assert_all_eq(local.neg_y.result, y_limbs); + + // Assert that the comparison only turns on when `is_real` is true. + builder + .when_not(local.is_real) + .assert_zero(choice_cols.when_sqrt_y_res_is_lt); + builder + .when_not(local.is_real) + .assert_zero(choice_cols.when_neg_y_res_is_lt); + + // Assert that the flags are set correctly. When the sign_bit is true, we want that + // `neg_y < y`, and vice versa when the sign_bit is false. Hence, when should have: + // - When `sign_bit` is true , then when_sqrt_y_res_is_lt = (y != sqrt(y)). + // - When `sign_bit` is false, then when_neg_y_res_is_lt = (y == sqrt(y)). + // - When `sign_bit` is true , then when_sqrt_y_res_is_lt = (y != sqrt(y)). + // - When `sign_bit` is false, then when_neg_y_res_is_lt = (y == sqrt(y)). + // + // Since the when less-than flags are disjoint, we can assert that: + // - When `sign_bit` is true , then is_y_eq_sqrt_y_result == when_neg_y_res_is_lt. + // - When `sign_bit` is false, then is_y_eq_sqrt_y_result == when_sqrt_y_res_is_lt. + builder.when(local.is_real).when(local.sign_bit).assert_eq( + choice_cols.is_y_eq_sqrt_y_result, + choice_cols.when_neg_y_res_is_lt, + ); + builder + .when(local.is_real) + .when_not(local.sign_bit) + .assert_eq( + choice_cols.is_y_eq_sqrt_y_result, + choice_cols.when_sqrt_y_res_is_lt, + ); + + // Assert the less-than comparisons according to the flags. + + choice_cols.comparison_lt_cols.eval( + builder, + &local.y.multiplication.result, + &local.neg_y.result, + local.shard, + local.channel, + choice_cols.when_sqrt_y_res_is_lt, + ); + + choice_cols.comparison_lt_cols.eval( + builder, + &local.neg_y.result, + &local.y.multiplication.result, + local.shard, + local.channel, + choice_cols.when_neg_y_res_is_lt, + ); + } + } for i in 0..num_words_field_element { builder.eval_memory_access( @@ -384,7 +602,7 @@ where local.nonce, syscall_id, local.ptr, - local.is_odd, + local.sign_bit, local.is_real, ); } @@ -393,6 +611,7 @@ where #[cfg(test)] mod tests { use crate::io::SP1Stdin; + use crate::stark::DefaultProver; use crate::utils::{self, tests::BLS12381_DECOMPRESS_ELF}; use crate::Program; use amcl::bls381::bls381::basic::key_pair_generate_g2; @@ -411,21 +630,27 @@ mod tests { let mut rand = RAND::new(); let len = 100; + let num_tests = 10; let random_slice = (0..len).map(|_| rng.gen::()).collect::>(); rand.seed(len, &random_slice); - let (_, compressed) = key_pair_generate_g2(&mut RAND::new()); - let stdin = SP1Stdin::from(&compressed); - let mut public_values = run_test_io(Program::from(BLS12381_DECOMPRESS_ELF), stdin).unwrap(); + for _ in 0..num_tests { + let (_, compressed) = key_pair_generate_g2(&mut rand); + + let stdin = SP1Stdin::from(&compressed); + let mut public_values = + run_test_io::>(Program::from(BLS12381_DECOMPRESS_ELF), stdin) + .unwrap(); - let mut result = [0; 96]; - public_values.read_slice(&mut result); + let mut result = [0; 96]; + public_values.read_slice(&mut result); - let point = deserialize_g1(&compressed).unwrap(); - let x = point.getx().to_string(); - let y = point.gety().to_string(); - let decompressed = hex::decode(format!("{x}{y}")).unwrap(); - assert_eq!(result, decompressed.as_slice()); + let point = deserialize_g1(&compressed).unwrap(); + let x = point.getx().to_string(); + let y = point.gety().to_string(); + let decompressed = hex::decode(format!("{x}{y}")).unwrap(); + assert_eq!(result, decompressed.as_slice()); + } } #[test] @@ -446,7 +671,8 @@ mod tests { let inputs = SP1Stdin::from(&compressed); let mut public_values = - run_test_io(Program::from(SECP256K1_DECOMPRESS_ELF), inputs).unwrap(); + run_test_io::>(Program::from(SECP256K1_DECOMPRESS_ELF), inputs) + .unwrap(); let mut result = [0; 65]; public_values.read_slice(&mut result); assert_eq!(result, decompressed); diff --git a/core/src/syscall/precompiles/weierstrass/weierstrass_double.rs b/core/src/syscall/precompiles/weierstrass/weierstrass_double.rs index 9221d680f1..4a480f6c94 100644 --- a/core/src/syscall/precompiles/weierstrass/weierstrass_double.rs +++ b/core/src/syscall/precompiles/weierstrass/weierstrass_double.rs @@ -549,6 +549,7 @@ pub mod tests { use crate::{ runtime::Program, + stark::DefaultProver, utils::{ run_test, setup_logger, tests::{BLS12381_DOUBLE_ELF, BN254_DOUBLE_ELF, SECP256K1_DOUBLE_ELF}, @@ -559,20 +560,20 @@ pub mod tests { fn test_secp256k1_double_simple() { setup_logger(); let program = Program::from(SECP256K1_DOUBLE_ELF); - run_test(program).unwrap(); + run_test::>(program).unwrap(); } #[test] fn test_bn254_double_simple() { setup_logger(); let program = Program::from(BN254_DOUBLE_ELF); - run_test(program).unwrap(); + run_test::>(program).unwrap(); } #[test] fn test_bls12381_double_simple() { setup_logger(); let program = Program::from(BLS12381_DOUBLE_ELF); - run_test(program).unwrap(); + run_test::>(program).unwrap(); } } diff --git a/core/src/syscall/write.rs b/core/src/syscall/write.rs index d8956844d8..fc159c0719 100644 --- a/core/src/syscall/write.rs +++ b/core/src/syscall/write.rs @@ -72,8 +72,11 @@ impl Syscall for SyscallWrite { rt.state.public_values_stream.extend_from_slice(slice); } else if fd == 4 { rt.state.input_stream.push(slice.to_vec()); - } else if let Some(hook) = rt.hook_registry.table.get(&fd) { - rt.state.input_stream.extend(hook(rt.hook_env(), slice)); + } else if let Some(mut hook) = rt.hook_registry.get(&fd) { + let res = hook.invoke_hook(rt.hook_env(), slice); + // Add result vectors to the beginning of the stream. + let ptr = rt.state.input_stream_ptr; + rt.state.input_stream.splice(ptr..ptr, res); } else { log::warn!("tried to write to unknown file descriptor {fd}"); } diff --git a/core/src/utils/ec/weierstrass/bls12_381.rs b/core/src/utils/ec/weierstrass/bls12_381.rs index 2cd8f80ac8..1234024224 100644 --- a/core/src/utils/ec/weierstrass/bls12_381.rs +++ b/core/src/utils/ec/weierstrass/bls12_381.rs @@ -109,10 +109,10 @@ impl WeierstrassParameters for Bls12381Parameters { } } -pub fn bls12381_decompress(bytes_be: &[u8], is_odd: u32) -> AffinePoint { +pub fn bls12381_decompress(bytes_be: &[u8], sign_bit: u32) -> AffinePoint { let mut g1_bytes_be: [u8; 48] = bytes_be.try_into().unwrap(); let mut flags = COMPRESION_FLAG; - if is_odd == 0 { + if sign_bit == 1 { flags |= Y_IS_ODD_FLAG; }; @@ -177,10 +177,10 @@ mod tests { let y_neg = Bls12381BaseField::modulus() - y.clone(); // Set flags - let mut is_odd = 1; + let mut is_odd = 0; if y > y_neg { result[0] += Y_IS_ODD_FLAG; - is_odd = 0; + is_odd = 1; } result[0] += COMPRESION_FLAG; diff --git a/core/src/utils/mod.rs b/core/src/utils/mod.rs index e768f999a7..d0f9206d3e 100644 --- a/core/src/utils/mod.rs +++ b/core/src/utils/mod.rs @@ -6,6 +6,7 @@ mod options; #[cfg(any(test, feature = "programs"))] mod programs; mod prove; +mod serde; mod tracer; pub use buffer::*; @@ -13,6 +14,7 @@ pub use config::*; pub use logger::*; pub use options::*; pub use prove::*; +pub use serde::*; pub use tracer::*; #[cfg(any(test, feature = "programs"))] @@ -20,6 +22,7 @@ pub use programs::*; use crate::{memory::MemoryCols, operations::field::params::Limbs}; use generic_array::ArrayLength; +use p3_maybe_rayon::prelude::{ParallelBridge, ParallelIterator}; pub const fn indices_arr() -> [usize; N] { let mut indices_arr = [0; N]; @@ -86,30 +89,36 @@ pub fn pad_rows_fixed( ) { let nb_rows = rows.len(); let dummy_row = row_fn(); - match size_log2 { - Some(size_log2) => { - let padded_nb_rows = 1 << size_log2; - if nb_rows * 2 < padded_nb_rows { + rows.resize(next_power_of_two(nb_rows, size_log2), dummy_row); +} + +/// Returns the next power of two that is >= `n` and >= 16. If `fixed_power` is set, it will return +/// `2^fixed_power` after checking that `n <= 2^fixed_power`. +pub fn next_power_of_two(n: usize, fixed_power: Option) -> usize { + match fixed_power { + Some(power) => { + let padded_nb_rows = 1 << power; + if n * 2 < padded_nb_rows { tracing::warn!( "fixed log2 rows can be potentially reduced: got {}, expected {}", - nb_rows, + n, padded_nb_rows ); } - if nb_rows > padded_nb_rows { + if n > padded_nb_rows { panic!( "fixed log2 rows is too small: got {}, expected {}", - nb_rows, padded_nb_rows + n, padded_nb_rows ); } - rows.resize(padded_nb_rows, dummy_row); + padded_nb_rows } None => { - let mut padded_nb_rows = nb_rows.next_power_of_two(); + let mut padded_nb_rows = n.next_power_of_two(); if padded_nb_rows < 16 { padded_nb_rows = 16; } - rows.resize(padded_nb_rows, dummy_row); + padded_nb_rows } } } @@ -184,3 +193,29 @@ pub fn log2_strict_usize(n: usize) -> usize { assert_eq!(n.wrapping_shr(res), 1, "Not a power of two: {n}"); res as usize } + +pub fn par_for_each_row(vec: &mut [F], num_elements_per_event: usize, processor: P) +where + F: Send, + P: Fn(usize, &mut [F]) + Send + Sync, +{ + // Split the vector into `num_cpus` chunks, but at least `num_cpus` rows per chunk. + assert!(vec.len() % num_elements_per_event == 0); + let len = vec.len() / num_elements_per_event; + let cpus = num_cpus::get(); + let ceil_div = (len + cpus - 1) / cpus; + let chunk_size = std::cmp::max(ceil_div, cpus); + + vec.chunks_mut(chunk_size * num_elements_per_event) + .enumerate() + .par_bridge() + .for_each(|(i, chunk)| { + chunk + .chunks_mut(num_elements_per_event) + .enumerate() + .for_each(|(j, row)| { + assert!(row.len() == num_elements_per_event); + processor(i * chunk_size + j, row); + }); + }); +} diff --git a/core/src/utils/options.rs b/core/src/utils/options.rs index 8ef087e3ac..c092dac136 100644 --- a/core/src/utils/options.rs +++ b/core/src/utils/options.rs @@ -1,18 +1,42 @@ use std::env; +use crate::runtime::{SplitOpts, DEFERRED_SPLIT_THRESHOLD}; + const DEFAULT_SHARD_SIZE: usize = 1 << 22; const DEFAULT_SHARD_BATCH_SIZE: usize = 16; +const DEFAULT_COMMIT_STREAM_CAPACITY: usize = 1; +const DEFAULT_PROVE_STREAM_CAPACITY: usize = 1; + +#[derive(Debug, Clone, Copy, PartialEq, Eq)] +pub struct SP1ProverOpts { + pub core_opts: SP1CoreOpts, + pub recursion_opts: SP1CoreOpts, +} -#[derive(Debug, Clone, Copy)] +impl Default for SP1ProverOpts { + fn default() -> Self { + Self { + core_opts: SP1CoreOpts::default(), + recursion_opts: SP1CoreOpts::recursion(), + } + } +} + +#[derive(Debug, Clone, Copy, PartialEq, Eq)] pub struct SP1CoreOpts { pub shard_size: usize, pub shard_batch_size: usize, - pub shard_chunking_multiplier: usize, + pub commit_stream_capacity: usize, + pub prove_stream_capacity: usize, + pub split_opts: SplitOpts, pub reconstruct_commitments: bool, } impl Default for SP1CoreOpts { fn default() -> Self { + let split_threshold = env::var("SPLIT_THRESHOLD") + .map(|s| s.parse::().unwrap_or(DEFERRED_SPLIT_THRESHOLD)) + .unwrap_or(DEFERRED_SPLIT_THRESHOLD); Self { shard_size: env::var("SHARD_SIZE").map_or_else( |_| DEFAULT_SHARD_SIZE, @@ -22,7 +46,15 @@ impl Default for SP1CoreOpts { |_| DEFAULT_SHARD_BATCH_SIZE, |s| s.parse::().unwrap_or(DEFAULT_SHARD_BATCH_SIZE), ), - shard_chunking_multiplier: 1, + commit_stream_capacity: env::var("COMMIT_STREAM_CAPACITY").map_or_else( + |_| DEFAULT_COMMIT_STREAM_CAPACITY, + |s| s.parse::().unwrap_or(DEFAULT_COMMIT_STREAM_CAPACITY), + ), + prove_stream_capacity: env::var("PROVE_STREAM_CAPACITY").map_or_else( + |_| DEFAULT_PROVE_STREAM_CAPACITY, + |s| s.parse::().unwrap_or(DEFAULT_PROVE_STREAM_CAPACITY), + ), + split_opts: SplitOpts::new(split_threshold), reconstruct_commitments: true, } } diff --git a/core/src/utils/prove.rs b/core/src/utils/prove.rs index 8afe5f55b0..867798b35b 100644 --- a/core/src/utils/prove.rs +++ b/core/src/utils/prove.rs @@ -1,37 +1,40 @@ use std::fs::File; -use std::io; -use std::io::{Seek, Write}; +use std::io::Seek; +use std::io::{self}; +use std::sync::mpsc::sync_channel; use std::sync::Arc; use web_time::Instant; -pub use baby_bear_blake3::BabyBearBlake3; -use p3_challenger::CanObserve; -use p3_field::PrimeField32; +use p3_maybe_rayon::prelude::*; + use serde::de::DeserializeOwned; use serde::Serialize; use size::Size; use thiserror::Error; +pub use baby_bear_blake3::BabyBearBlake3; +use p3_baby_bear::BabyBear; +use p3_field::PrimeField32; + use crate::air::MachineAir; use crate::io::{SP1PublicValues, SP1Stdin}; use crate::lookup::InteractionBuilder; -use crate::runtime::{ - DefaultSubproofVerifier, ExecutionError, NoOpSubproofVerifier, SubproofVerifier, -}; -use crate::runtime::{ExecutionRecord, ExecutionReport, ShardingConfig}; +use crate::runtime::{ExecutionError, NoOpSubproofVerifier, SP1Context}; +use crate::runtime::{ExecutionRecord, ExecutionReport}; use crate::stark::DebugConstraintBuilder; use crate::stark::MachineProof; +use crate::stark::MachineProver; use crate::stark::ProverConstraintFolder; use crate::stark::StarkVerifyingKey; use crate::stark::Val; use crate::stark::VerifierConstraintFolder; -use crate::stark::{Com, PcsProverData, RiscvAir, ShardProof, StarkProvingKey, UniConfig}; +use crate::stark::{Com, PcsProverData, RiscvAir, StarkProvingKey, UniConfig}; use crate::stark::{MachineRecord, StarkMachine}; use crate::utils::SP1CoreOpts; use crate::{ runtime::{Program, Runtime}, stark::StarkGenericConfig, - stark::{LocalProver, OpeningProof, ShardMainData}, + stark::{DefaultProver, OpeningProof, ShardMainData}, }; const LOG_DEGREE_BOUND: usize = 31; @@ -46,10 +49,10 @@ pub enum SP1CoreProverError { SerializationError(bincode::Error), } -pub fn prove_simple( +pub fn prove_simple>>( config: SC, - runtime: Runtime, -) -> Result, SP1CoreProverError> + mut runtime: Runtime, +) -> Result<(MachineProof, u64), SP1CoreProverError> where SC::Challenger: Clone, OpeningProof: Send + Sync, @@ -60,17 +63,29 @@ where { // Setup the machine. let machine = RiscvAir::machine(config); - let (pk, _) = machine.setup(runtime.program.as_ref()); + let prover = P::new(machine); + let (pk, _) = prover.setup(runtime.program.as_ref()); + + // Set the shard numbers. + runtime + .records + .iter_mut() + .enumerate() + .for_each(|(i, shard)| { + shard.public_values.shard = (i + 1) as u32; + }); // Prove the program. - let mut challenger = machine.config().challenger(); + let mut challenger = prover.config().challenger(); let proving_start = Instant::now(); - let proof = machine.prove::>( - &pk, - runtime.record, - &mut challenger, - SP1CoreOpts::default(), - ); + let proof = prover + .prove( + &pk, + runtime.records, + &mut challenger, + SP1CoreOpts::default(), + ) + .unwrap(); let proving_duration = proving_start.elapsed().as_millis(); let nb_bytes = bincode::serialize(&proof).unwrap().len(); @@ -83,246 +98,372 @@ where Size::from_bytes(nb_bytes), ); - Ok(proof) + Ok((proof, runtime.state.global_clk)) } -pub fn prove( +pub fn prove>>( program: Program, stdin: &SP1Stdin, config: SC, opts: SP1CoreOpts, -) -> Result<(MachineProof, Vec), SP1CoreProverError> +) -> Result<(MachineProof, Vec, u64), SP1CoreProverError> where - SC::Challenger: Clone, - OpeningProof: Send + Sync, + SC::Challenger: 'static + Clone + Send, + ::Val: PrimeField32, + OpeningProof: Send, Com: Send + Sync, PcsProverData: Send + Sync, - ShardMainData: Serialize + DeserializeOwned, - ::Val: PrimeField32, { - prove_with_subproof_verifier::(program, stdin, config, opts, None) + let machine = RiscvAir::machine(config); + let prover = P::new(machine); + prove_with_context::(&prover, program, stdin, opts, Default::default()) } -pub fn prove_with_subproof_verifier( +pub fn prove_with_context>>( + prover: &P, program: Program, stdin: &SP1Stdin, - config: SC, opts: SP1CoreOpts, - subproof_verifier: Option>, -) -> Result<(MachineProof, Vec), SP1CoreProverError> + context: SP1Context, +) -> Result<(MachineProof, Vec, u64), SP1CoreProverError> where - SC::Challenger: Clone, - OpeningProof: Send + Sync, + SC::Val: PrimeField32, + SC::Challenger: 'static + Clone + Send, + OpeningProof: Send, Com: Send + Sync, PcsProverData: Send + Sync, - ShardMainData: Serialize + DeserializeOwned, - ::Val: PrimeField32, { + // Record the start of the process. let proving_start = Instant::now(); // Execute the program. - let mut runtime = Runtime::new(program.clone(), opts); + let mut runtime = Runtime::with_context(program.clone(), opts, context); runtime.write_vecs(&stdin.buffer); for proof in stdin.proofs.iter() { runtime.write_proof(proof.0.clone(), proof.1.clone()); } - if let Some(deferred_fn) = subproof_verifier.clone() { - runtime.subproof_verifier = deferred_fn; - } // Setup the machine. - let machine = RiscvAir::machine(config); - let (pk, vk) = machine.setup(runtime.program.as_ref()); - - // If we don't need to batch, we can just run the program normally and prove it. - if opts.shard_batch_size == 0 { - // Execute the runtime and collect all the events.. - runtime.run().map_err(SP1CoreProverError::ExecutionError)?; - - // If debugging is enabled, we will also debug the constraints. - #[cfg(feature = "debug")] - { - let mut challenger = machine.config().challenger(); - machine.debug_constraints(&pk, runtime.record.clone(), &mut challenger); - } - - // Generate the proof and return the proof and public values. - let public_values = std::mem::take(&mut runtime.state.public_values_stream); - let proof = prove_simple(machine.config().clone(), runtime)?; - return Ok((proof, public_values)); - } + let (pk, vk) = prover.setup(runtime.program.as_ref()); // Execute the program, saving checkpoints at the start of every `shard_batch_size` cycle range. + let create_checkpoints_span = tracing::debug_span!("create checkpoints").entered(); let mut checkpoints = Vec::new(); let (public_values_stream, public_values) = loop { // Execute the runtime until we reach a checkpoint. - let (checkpoint, done) = tracing::info_span!("collect_checkpoints") - .in_scope(|| runtime.execute_state()) + let (checkpoint, done) = runtime + .execute_state() .map_err(SP1CoreProverError::ExecutionError)?; // Save the checkpoint to a temp file. - let mut tempfile = tempfile::tempfile().map_err(SP1CoreProverError::IoError)?; - let mut writer = std::io::BufWriter::new(&mut tempfile); - bincode::serialize_into(&mut writer, &checkpoint) - .map_err(SP1CoreProverError::SerializationError)?; - writer.flush().map_err(SP1CoreProverError::IoError)?; - drop(writer); - tempfile - .seek(std::io::SeekFrom::Start(0)) + let mut checkpoint_file = tempfile::tempfile().map_err(SP1CoreProverError::IoError)?; + checkpoint + .save(&mut checkpoint_file) .map_err(SP1CoreProverError::IoError)?; - checkpoints.push(tempfile); + checkpoints.push(checkpoint_file); // If we've reached the final checkpoint, break out of the loop. if done { break ( - std::mem::take(&mut runtime.state.public_values_stream), - runtime.record.public_values, + runtime.state.public_values_stream, + runtime + .records + .last() + .expect("at least one record") + .public_values, ); } }; + create_checkpoints_span.exit(); - // For each checkpoint, generate events, shard them, commit shards, and observe in challenger. - let sharding_config = ShardingConfig::default(); - let mut shard_main_datas = Vec::new(); - let mut challenger = machine.config().challenger(); + // Commit to the shards. + #[cfg(debug_assertions)] + let mut debug_records: Vec = Vec::new(); + + let mut deferred = ExecutionRecord::new(program.clone().into()); + let mut state = public_values.reset(); + let nb_checkpoints = checkpoints.len(); + let mut challenger = prover.config().challenger(); vk.observe_into(&mut challenger); - for (num, checkpoint_file) in checkpoints.iter_mut().enumerate() { - let (mut record, _) = tracing::info_span!("commit_checkpoint", num) - .in_scope(|| trace_checkpoint(program.clone(), checkpoint_file, opts)); - record.public_values = public_values; - reset_seek(&mut *checkpoint_file); - - // Shard the record into shards. - let checkpoint_shards = - tracing::info_span!("shard").in_scope(|| machine.shard(record, &sharding_config)); - - // Commit to each shard. - let (commitments, commit_data) = tracing::info_span!("commit") - .in_scope(|| LocalProver::commit_shards(&machine, &checkpoint_shards, opts)); - shard_main_datas.push(commit_data); - - // Observe the commitments. - for (commitment, shard) in commitments.into_iter().zip(checkpoint_shards.iter()) { - challenger.observe(commitment); - challenger.observe_slice(&shard.public_values::()[0..machine.num_pv_elts()]); - } - } - // For each checkpoint, generate events and shard again, then prove the shards. - let mut shard_proofs = Vec::>::new(); - let mut report_aggregate = ExecutionReport::default(); - for (num, mut checkpoint_file) in checkpoints.into_iter().enumerate() { - let checkpoint_shards = { - let (mut events, report) = tracing::info_span!("prove_checkpoint", num) - .in_scope(|| trace_checkpoint(program.clone(), &checkpoint_file, opts)); - report_aggregate += report; - events.public_values = public_values; - reset_seek(&mut checkpoint_file); - tracing::debug_span!("shard").in_scope(|| machine.shard(events, &sharding_config)) - }; - let mut checkpoint_proofs = checkpoint_shards - .into_iter() - .map(|shard| { - let config = machine.config(); - let shard_data = - LocalProver::commit_main(config, &machine, &shard, shard.index() as usize); - - let chip_ordering = shard_data.chip_ordering.clone(); - let ordered_chips = machine - .shard_chips_ordered(&chip_ordering) - .collect::>() - .to_vec(); - LocalProver::prove_shard( - config, - &pk, - &ordered_chips, - shard_data, - &mut challenger.clone(), - ) - }) - .collect::>(); - shard_proofs.append(&mut checkpoint_proofs); - } - // Log some of the `ExecutionReport` information. - tracing::info!( - "execution report (totals): total_cycles={}, total_syscall_cycles={}", - report_aggregate.total_instruction_count(), - report_aggregate.total_syscall_count() - ); - // Print the opcode and syscall count tables like `du`: - // sorted by count (descending) and with the count in the first column. - tracing::info!("execution report (opcode counts):"); - for line in ExecutionReport::sorted_table_lines(&report_aggregate.opcode_counts) { - tracing::info!(" {line}"); - } - tracing::info!("execution report (syscall counts):"); - for line in ExecutionReport::sorted_table_lines(&report_aggregate.syscall_counts) { - tracing::info!(" {line}"); - } + let scope_span = tracing::Span::current().clone(); + std::thread::scope(move |s| { + let _span = scope_span.enter(); + + // Spawn a thread for commiting to the shards. + let span = tracing::Span::current().clone(); + let (records_tx, records_rx) = + sync_channel::>(opts.commit_stream_capacity); + let challenger_handle = s.spawn(move || { + let _span = span.enter(); + tracing::debug_span!("phase 1 commiter").in_scope(|| { + for records in records_rx.iter() { + let commitments = tracing::debug_span!("batch").in_scope(|| { + let span = tracing::Span::current().clone(); + records + .par_iter() + .map(|record| { + let _span = span.enter(); + prover.commit(record) + }) + .collect::>() + }); + for (commit, record) in commitments.into_iter().zip(records) { + prover.update( + &mut challenger, + commit, + &record.public_values::()[0..prover.machine().num_pv_elts()], + ); + } + } + }); + + challenger + }); + + tracing::debug_span!("phase 1 record generator").in_scope(|| { + for (checkpoint_idx, checkpoint_file) in checkpoints.iter_mut().enumerate() { + // Trace the checkpoint and reconstruct the execution records. + let (mut records, _) = tracing::debug_span!("trace checkpoint") + .in_scope(|| trace_checkpoint(program.clone(), checkpoint_file, opts)); + reset_seek(&mut *checkpoint_file); + + // Update the public values & prover state for the shards which contain "cpu events". + for record in records.iter_mut() { + state.shard += 1; + state.execution_shard = record.public_values.execution_shard; + state.start_pc = record.public_values.start_pc; + state.next_pc = record.public_values.next_pc; + record.public_values = state; + } + + // Generate the dependencies. + tracing::debug_span!("generate dependencies") + .in_scope(|| prover.machine().generate_dependencies(&mut records, &opts)); + + // Defer events that are too expensive to include in every shard. + for record in records.iter_mut() { + deferred.append(&mut record.defer()); + } + + // See if any deferred shards are ready to be commited to. + let is_last_checkpoint = checkpoint_idx == nb_checkpoints - 1; + let mut deferred = deferred.split(is_last_checkpoint, opts.split_opts); + + // Update the public values & prover state for the shards which do not contain "cpu events" + // before committing to them. + if !is_last_checkpoint { + state.execution_shard += 1; + } + for record in deferred.iter_mut() { + state.shard += 1; + state.previous_init_addr_bits = record.public_values.previous_init_addr_bits; + state.last_init_addr_bits = record.public_values.last_init_addr_bits; + state.previous_finalize_addr_bits = + record.public_values.previous_finalize_addr_bits; + state.last_finalize_addr_bits = record.public_values.last_finalize_addr_bits; + state.start_pc = state.next_pc; + record.public_values = state; + } + records.append(&mut deferred); + + #[cfg(debug_assertions)] + { + debug_records.extend(records.clone()); + } + + records_tx.send(records).unwrap(); + } + }); + drop(records_tx); + let challenger = challenger_handle.join().unwrap(); - let proof = MachineProof:: { shard_proofs }; + // Debug the constraints if debug assertions are enabled. + #[cfg(debug_assertions)] + { + let mut challenger = prover.config().challenger(); + prover.debug_constraints(&pk, debug_records, &mut challenger); + } - // Print the summary. - let proving_time = proving_start.elapsed().as_secs_f64(); - tracing::info!( - "summary: cycles={}, e2e={}, khz={:.2}, proofSize={}", - runtime.state.global_clk, - proving_time, - (runtime.state.global_clk as f64 / proving_time as f64), - bincode::serialize(&proof).unwrap().len(), - ); + // Prove the shards. + let mut deferred = ExecutionRecord::new(program.clone().into()); + let mut state = public_values.reset(); + let mut report_aggregate = ExecutionReport::default(); + + // Spawn a thread for proving the shards. + let (records_tx, records_rx) = + sync_channel::>(opts.prove_stream_capacity); + + let commit_and_open = tracing::Span::current().clone(); + let shard_proofs = s.spawn(move || { + let _span = commit_and_open.enter(); + let mut shard_proofs = Vec::new(); + tracing::debug_span!("phase 2 prover").in_scope(|| { + for records in records_rx.iter() { + tracing::debug_span!("batch").in_scope(|| { + let span = tracing::Span::current().clone(); + shard_proofs.par_extend(records.into_par_iter().map(|record| { + let _span = span.enter(); + prover + .commit_and_open(&pk, record, &mut challenger.clone()) + .unwrap() + })); + }); + } + }); + shard_proofs + }); + + tracing::debug_span!("phase 2 record generator").in_scope(|| { + for (checkpoint_idx, mut checkpoint_file) in checkpoints.into_iter().enumerate() { + // Trace the checkpoint and reconstruct the execution records. + let (mut records, report) = tracing::debug_span!("trace checkpoint") + .in_scope(|| trace_checkpoint(program.clone(), &checkpoint_file, opts)); + report_aggregate += report; + reset_seek(&mut checkpoint_file); + + // Update the public values & prover state for the shards which contain "cpu events". + for record in records.iter_mut() { + state.shard += 1; + state.execution_shard = record.public_values.execution_shard; + state.start_pc = record.public_values.start_pc; + state.next_pc = record.public_values.next_pc; + record.public_values = state; + } + + // Generate the dependencies. + tracing::debug_span!("generate dependencies") + .in_scope(|| prover.machine().generate_dependencies(&mut records, &opts)); + + // Defer events that are too expensive to include in every shard. + for record in records.iter_mut() { + deferred.append(&mut record.defer()); + } + + // See if any deferred shards are ready to be commited to. + let is_last_checkpoint = checkpoint_idx == nb_checkpoints - 1; + let mut deferred = deferred.split(is_last_checkpoint, opts.split_opts); + + // Update the public values & prover state for the shards which do not contain "cpu events" + // before committing to them. + if !is_last_checkpoint { + state.execution_shard += 1; + } + for record in deferred.iter_mut() { + state.shard += 1; + state.previous_init_addr_bits = record.public_values.previous_init_addr_bits; + state.last_init_addr_bits = record.public_values.last_init_addr_bits; + state.previous_finalize_addr_bits = + record.public_values.previous_finalize_addr_bits; + state.last_finalize_addr_bits = record.public_values.last_finalize_addr_bits; + state.start_pc = state.next_pc; + record.public_values = state; + } + records.append(&mut deferred); + + records_tx.send(records).unwrap(); + } + }); + drop(records_tx); + let shard_proofs = shard_proofs.join().unwrap(); + + // Log some of the `ExecutionReport` information. + tracing::info!( + "execution report (totals): total_cycles={}, total_syscall_cycles={}", + report_aggregate.total_instruction_count(), + report_aggregate.total_syscall_count() + ); + + // Print the opcode and syscall count tables like `du`: sorted by count (descending) and with + // the count in the first column. + tracing::info!("execution report (opcode counts):"); + for line in ExecutionReport::sorted_table_lines(&report_aggregate.opcode_counts) { + tracing::info!(" {line}"); + } + tracing::info!("execution report (syscall counts):"); + for line in ExecutionReport::sorted_table_lines(&report_aggregate.syscall_counts) { + tracing::info!(" {line}"); + } - Ok((proof, public_values_stream)) + let proof = MachineProof:: { shard_proofs }; + let cycles = runtime.state.global_clk; + + // Print the summary. + let proving_time = proving_start.elapsed().as_secs_f64(); + tracing::info!( + "summary: cycles={}, e2e={}s, khz={:.2}, proofSize={}", + cycles, + proving_time, + (runtime.state.global_clk as f64 / (proving_time * 1000.0) as f64), + bincode::serialize(&proof).unwrap().len(), + ); + + Ok((proof, public_values_stream, cycles)) + }) } /// Runs a program and returns the public values stream. -pub fn run_test_io( +pub fn run_test_io>>( program: Program, inputs: SP1Stdin, ) -> Result> { - let runtime = tracing::info_span!("runtime.run(...)").in_scope(|| { + let runtime = tracing::debug_span!("runtime.run(...)").in_scope(|| { let mut runtime = Runtime::new(program, SP1CoreOpts::default()); runtime.write_vecs(&inputs.buffer); runtime.run().unwrap(); runtime }); let public_values = SP1PublicValues::from(&runtime.state.public_values_stream); - let _ = run_test_core(runtime)?; + let _ = run_test_core::

(runtime, inputs)?; Ok(public_values) } -pub fn run_test( +pub fn run_test>>( program: Program, ) -> Result< crate::stark::MachineProof, crate::stark::MachineVerificationError, > { - let runtime = tracing::info_span!("runtime.run(...)").in_scope(|| { + let runtime = tracing::debug_span!("runtime.run(...)").in_scope(|| { let mut runtime = Runtime::new(program, SP1CoreOpts::default()); runtime.run().unwrap(); runtime }); - run_test_core(runtime) + run_test_core::

(runtime, SP1Stdin::new()) } #[allow(unused_variables)] -pub fn run_test_core( +pub fn run_test_core>>( runtime: Runtime, + inputs: SP1Stdin, ) -> Result< crate::stark::MachineProof, crate::stark::MachineVerificationError, > { + let config = BabyBearPoseidon2::new(); + let machine = RiscvAir::machine(config); + let prover = P::new(machine); + let (proof, output, _) = prove_with_context( + &prover, + Program::clone(&runtime.program), + &inputs, + SP1CoreOpts::default(), + SP1Context::default(), + ) + .unwrap(); + let config = BabyBearPoseidon2::new(); let machine = RiscvAir::machine(config); let (pk, vk) = machine.setup(runtime.program.as_ref()); + let mut challenger = machine.config().challenger(); + machine.verify(&vk, &proof, &mut challenger).unwrap(); - let record = runtime.record; - run_test_machine(record, machine, pk, vk) + Ok(proof) } #[allow(unused_variables)] pub fn run_test_machine( - record: A::Record, + records: Vec, machine: StarkMachine, pk: StarkProvingKey, vk: StarkVerifyingKey, @@ -333,6 +474,7 @@ where + Air>> + for<'a> Air> + for<'a> Air, SC::Challenge>>, + A::Record: MachineRecord, SC: StarkGenericConfig, SC::Val: p3_field::PrimeField32, SC::Challenger: Clone, @@ -341,32 +483,17 @@ where OpeningProof: Send + Sync, ShardMainData: Serialize + DeserializeOwned, { - #[cfg(feature = "debug")] - { - let mut challenger_clone = machine.config().challenger(); - let record_clone = record.clone(); - machine.debug_constraints(&pk, record_clone, &mut challenger_clone); - } - let stats = record.stats().clone(); - let cycles = stats.get("cpu_events").unwrap(); - let start = Instant::now(); - let mut challenger = machine.config().challenger(); - let proof = - machine.prove::>(&pk, record, &mut challenger, SP1CoreOpts::default()); + let prover = DefaultProver::new(machine); + let mut challenger = prover.config().challenger(); + let proof = prover + .prove(&pk, records, &mut challenger, SP1CoreOpts::default()) + .unwrap(); let time = start.elapsed().as_millis(); let nb_bytes = bincode::serialize(&proof).unwrap().len(); - let mut challenger = machine.config().challenger(); - machine.verify(&vk, &proof, &mut challenger)?; - - tracing::info!( - "summary: cycles={}, e2e={}, khz={:.2}, proofSize={}", - cycles, - time, - (*cycles as f64 / time as f64), - Size::from_bytes(nb_bytes), - ); + let mut challenger = prover.config().challenger(); + prover.machine().verify(&vk, &proof, &mut challenger)?; Ok(proof) } @@ -375,15 +502,14 @@ fn trace_checkpoint( program: Program, file: &File, opts: SP1CoreOpts, -) -> (ExecutionRecord, ExecutionReport) { +) -> (Vec, ExecutionReport) { let mut reader = std::io::BufReader::new(file); let state = bincode::deserialize_from(&mut reader).expect("failed to deserialize state"); let mut runtime = Runtime::recover(program.clone(), state, opts); // We already passed the deferred proof verifier when creating checkpoints, so the proofs were // already verified. So here we use a noop verifier to not print any warnings. runtime.subproof_verifier = Arc::new(NoOpSubproofVerifier); - let (events, _) = - tracing::debug_span!("runtime.trace").in_scope(|| runtime.execute_record().unwrap()); + let (events, _) = runtime.execute_record().unwrap(); (events, runtime.report) } diff --git a/core/src/utils/serde.rs b/core/src/utils/serde.rs new file mode 100644 index 0000000000..fa7fdcef98 --- /dev/null +++ b/core/src/utils/serde.rs @@ -0,0 +1,18 @@ +use std::collections::HashMap; + +use nohash_hasher::BuildNoHashHasher; +use serde::{Deserialize, Deserializer, Serialize, Serializer}; + +pub fn serialize_hashmap_as_vec( + map: &HashMap>, + serializer: S, +) -> Result { + Serialize::serialize(&map.iter().collect::>(), serializer) +} + +pub fn deserialize_hashmap_as_vec<'de, V: Deserialize<'de>, D: Deserializer<'de>>( + deserializer: D, +) -> Result>, D::Error> { + let seq: Vec<(u32, V)> = Deserialize::deserialize(deserializer)?; + Ok(seq.into_iter().collect()) +} diff --git a/derive/CHANGELOG.md b/derive/CHANGELOG.md new file mode 100644 index 0000000000..67ba1999ef --- /dev/null +++ b/derive/CHANGELOG.md @@ -0,0 +1,14 @@ +# Changelog + +All notable changes to this project will be documented in this file. + +The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/), +and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html). + +## [Unreleased] + +## [1.0.0-rc.1](https://github.com/succinctlabs/sp1/compare/sp1-derive-v1.0.0-rc.1...sp1-derive-v1.0.0-rc.1) - 2024-07-19 + +### Other + +- use global workspace version ([#1102](https://github.com/succinctlabs/sp1/pull/1102)) diff --git a/derive/Cargo.toml b/derive/Cargo.toml index cd09114d95..88e1f95211 100644 --- a/derive/Cargo.toml +++ b/derive/Cargo.toml @@ -1,7 +1,13 @@ [package] name = "sp1-derive" -version = "0.1.0" -edition = "2021" +description = "SP1 is a performant, 100% open-source, contributor-friendly zkVM." +readme = "../README.md" +version = { workspace = true } +edition = { workspace = true } +license = { workspace = true } +repository = { workspace = true } +keywords = { workspace = true } +categories = { workspace = true } [lib] proc-macro = true diff --git a/derive/src/lib.rs b/derive/src/lib.rs index 552c3fc348..a621e0ac1e 100644 --- a/derive/src/lib.rs +++ b/derive/src/lib.rs @@ -32,6 +32,7 @@ use syn::Data; use syn::DeriveInput; use syn::GenericParam; use syn::ItemFn; +use syn::WherePredicate; #[proc_macro_derive(AlignedBorrow)] pub fn aligned_borrow_derive(input: TokenStream) -> TokenStream { @@ -94,7 +95,13 @@ pub fn aligned_borrow_derive(input: TokenStream) -> TokenStream { #[proc_macro_derive( MachineAir, - attributes(sp1_core_path, execution_record_path, program_path, builder_path) + attributes( + sp1_core_path, + execution_record_path, + program_path, + builder_path, + eval_trait_bound + ) )] pub fn machine_air_derive(input: TokenStream) -> TokenStream { let ast: syn::DeriveInput = syn::parse(input).unwrap(); @@ -105,6 +112,7 @@ pub fn machine_air_derive(input: TokenStream) -> TokenStream { let execution_record_path = find_execution_record_path(&ast.attrs); let program_path = find_program_path(&ast.attrs); let builder_path = find_builder_path(&ast.attrs); + let eval_trait_bound = find_eval_trait_bound(&ast.attrs); let (impl_generics, ty_generics, where_clause) = generics.split_for_impl(); match &ast.data { @@ -257,6 +265,13 @@ pub fn machine_air_derive(input: TokenStream) -> TokenStream { let (air_impl_generics, _, _) = new_generics.split_for_impl(); + let mut new_generics = generics.clone(); + let where_clause = new_generics.make_where_clause(); + if eval_trait_bound.is_some() { + let predicate: WherePredicate = syn::parse_str(&eval_trait_bound.unwrap()).unwrap(); + where_clause.predicates.push(predicate); + } + let air = quote! { impl #air_impl_generics p3_air::Air for #name #ty_generics #where_clause { fn eval(&self, builder: &mut AB) { @@ -360,3 +375,17 @@ fn find_builder_path(attrs: &[syn::Attribute]) -> syn::Path { } parse_quote!(crate::air::SP1AirBuilder) } + +fn find_eval_trait_bound(attrs: &[syn::Attribute]) -> Option { + for attr in attrs { + if attr.path.is_ident("eval_trait_bound") { + if let Ok(syn::Meta::NameValue(meta)) = attr.parse_meta() { + if let syn::Lit::Str(lit_str) = &meta.lit { + return Some(lit_str.value()); + } + } + } + } + + None +} diff --git a/eval/Cargo.toml b/eval/Cargo.toml index a9d8207870..3cf9b539f9 100644 --- a/eval/Cargo.toml +++ b/eval/Cargo.toml @@ -1,12 +1,17 @@ [package] name = "sp1-eval" -version = "0.1.0" -edition = "2021" +version = { workspace = true } +edition = { workspace = true } +license = { workspace = true } +repository = { workspace = true } +keywords = { workspace = true } +categories = { workspace = true } +publish = false [dependencies] -sp1-core = { path = "../core" } -sp1-prover = { path = "../prover" } +sp1-core = { workspace = true } +sp1-prover = { workspace = true } -clap = { version = "4.5.7", features = ["derive"] } +clap = { version = "4.5.9", features = ["derive"] } csv = "1.3.0" -serde = "1.0.201" +serde = "1.0.204" diff --git a/eval/src/main.rs b/eval/src/main.rs index 3ed7a9d3af..9ee05886ad 100644 --- a/eval/src/main.rs +++ b/eval/src/main.rs @@ -2,6 +2,7 @@ use clap::{command, Parser}; use csv::WriterBuilder; use serde::Serialize; use sp1_core::runtime::{Program, Runtime}; +use sp1_core::stark::DefaultProver; use sp1_core::utils::{ prove_simple, BabyBearBlake3, BabyBearKeccak, BabyBearPoseidon2, SP1CoreOpts, }; @@ -144,7 +145,7 @@ fn run_evaluation(hashfn: &HashFnId, program: &Program, _elf: &[u8]) -> (f64, f6 let config = BabyBearBlake3::new(); let prove_start = Instant::now(); - let _proof = prove_simple(config.clone(), runtime); + let _proof = prove_simple::<_, DefaultProver<_, _>>(config.clone(), runtime); let prove_duration = prove_start.elapsed().as_secs_f64(); let verify_start = Instant::now(); @@ -162,7 +163,7 @@ fn run_evaluation(hashfn: &HashFnId, program: &Program, _elf: &[u8]) -> (f64, f6 let config = BabyBearPoseidon2::new(); let prove_start = Instant::now(); - let _proof = prove_simple(config.clone(), runtime); + let _proof = prove_simple::<_, DefaultProver<_, _>>(config.clone(), runtime); let prove_duration = prove_start.elapsed().as_secs_f64(); let verify_start = Instant::now(); @@ -180,7 +181,7 @@ fn run_evaluation(hashfn: &HashFnId, program: &Program, _elf: &[u8]) -> (f64, f6 let config = BabyBearKeccak::new(); let prove_start = Instant::now(); - let _proof = prove_simple(config.clone(), runtime); + let _proof = prove_simple::<_, DefaultProver<_, _>>(config.clone(), runtime); let prove_duration = prove_start.elapsed().as_secs_f64(); let verify_start = Instant::now(); diff --git a/examples/Cargo.lock b/examples/Cargo.lock index cb3302af4d..1644e2759e 100644 --- a/examples/Cargo.lock +++ b/examples/Cargo.lock @@ -51,7 +51,7 @@ dependencies = [ [[package]] name = "aggregation-script" -version = "0.1.0" +version = "1.0.0-rc.1" dependencies = [ "hex", "sp1-helper", @@ -233,9 +233,9 @@ dependencies = [ [[package]] name = "anstyle-query" -version = "1.0.3" +version = "1.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a64c907d4e79225ac72e2a354c9ce84d50ebb4586dee56c82b3ee73004f537f5" +checksum = "ad186efb764318d35165f1758e7dcef3b10628e26d41a44bc5550652e6804391" dependencies = [ "windows-sys 0.52.0", ] @@ -267,7 +267,7 @@ dependencies = [ "ark-serialize 0.3.0", "ark-std 0.3.0", "derivative", - "num-bigint 0.4.5", + "num-bigint 0.4.6", "num-traits", "paste", "rustc_version 0.3.3", @@ -287,7 +287,7 @@ dependencies = [ "derivative", "digest 0.10.7", "itertools 0.10.5", - "num-bigint 0.4.5", + "num-bigint 0.4.6", "num-traits", "paste", "rustc_version 0.4.0", @@ -320,7 +320,7 @@ version = "0.3.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "db2fd794a08ccb318058009eefdf15bcaaaaf6f8161eb3345f907222bac38b20" dependencies = [ - "num-bigint 0.4.5", + "num-bigint 0.4.6", "num-traits", "quote", "syn 1.0.109", @@ -332,7 +332,7 @@ version = "0.4.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "7abe79b0e4288889c4574159ab790824d0033b9fdcb2a112a3182fac2e514565" dependencies = [ - "num-bigint 0.4.5", + "num-bigint 0.4.6", "num-traits", "proc-macro2", "quote", @@ -357,7 +357,7 @@ checksum = "adb7b85a02b83d2f22f89bd5cac66c9c89474240cb6207cb1efc16d098e822a5" dependencies = [ "ark-std 0.4.0", "digest 0.10.7", - "num-bigint 0.4.5", + "num-bigint 0.4.6", ] [[package]] @@ -394,9 +394,9 @@ checksum = "96d30a06541fbafbc7f82ed10c06164cfbd2c401138f6addd8404629c4b16711" [[package]] name = "async-trait" -version = "0.1.80" +version = "0.1.81" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c6fa2087f2753a7da8cc1c0dbfcf89579dd57458e36769de5ac750b4671737ca" +checksum = "6e0c28dcc82d7c8ead5cb13beb15405b57b8546e93215673ff8ca0349a028107" dependencies = [ "proc-macro2", "quote", @@ -439,9 +439,9 @@ checksum = "0c4b4d0bd25bd0b74681c0ad21497610ce1b7c91b1022cd21c80c6fbdd9476b0" [[package]] name = "axum" -version = "0.7.5" +version = "0.7.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3a6c9af12842a67734c9a2e355436e5d03b22383ed60cf13cd0c18fbfe3dcbcf" +checksum = "1236b4b292f6c4d6dc34604bb5120d85c3fe1d1aa596bd5cc52ca054d13e7b9e" dependencies = [ "async-trait", "axum-core", @@ -463,7 +463,7 @@ dependencies = [ "serde_json", "serde_path_to_error", "serde_urlencoded", - "sync_wrapper 1.0.1", + "sync_wrapper 0.1.2", "tokio", "tower", "tower-layer", @@ -494,9 +494,9 @@ dependencies = [ [[package]] name = "backtrace" -version = "0.3.72" +version = "0.3.73" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "17c6a35df3749d2e8bb1b7b21a976d82b15548788d2735b9d82f329268f71a11" +checksum = "5cc23269a4f8976d0a4d2e7109211a419fe30e8d88d677cd60b6bc79c5732e0a" dependencies = [ "addr2line", "cc", @@ -757,13 +757,12 @@ dependencies = [ [[package]] name = "cc" -version = "1.0.98" +version = "1.1.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "41c270e7540d725e65ac7f1b212ac8ce349719624d7bcff99f8e2e488e8cf03f" +checksum = "2aba8f4e9906c7ce3c73463f62a7f0c65183ada1a2d47e397cc8810827f9694f" dependencies = [ "jobserver", "libc", - "once_cell", ] [[package]] @@ -783,7 +782,7 @@ checksum = "baf1de4339761588bc0619e3cbc0120ee582ebb74b53b4efbf79117bd2da40fd" [[package]] name = "chess-script" -version = "0.1.0" +version = "1.0.0-rc.1" dependencies = [ "sp1-helper", "sp1-sdk", @@ -825,9 +824,9 @@ dependencies = [ [[package]] name = "clap" -version = "4.5.7" +version = "4.5.9" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5db83dced34638ad474f39f250d7fea9598bdd239eaced1bdf45d597da0f433f" +checksum = "64acc1846d54c1fe936a78dc189c34e28d3f5afc348403f28ecf53660b9b8462" dependencies = [ "clap_builder", "clap_derive", @@ -835,9 +834,9 @@ dependencies = [ [[package]] name = "clap_builder" -version = "4.5.7" +version = "4.5.9" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f7e204572485eb3fbf28f871612191521df159bc3e15a9f5064c66dba3a8c05f" +checksum = "6fb8393d67ba2e7bfaf28a23458e4e2b543cc73a99595511eb207fdb8aede942" dependencies = [ "anstream", "anstyle", @@ -847,9 +846,9 @@ dependencies = [ [[package]] name = "clap_derive" -version = "4.5.5" +version = "4.5.8" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c780290ccf4fb26629baa7a1081e68ced113f1d3ec302fa5948f1c381ebf06c6" +checksum = "2bac35c6dafb060fd4d275d9a4ffae97917c13a6327903a8be2153cd964f7085" dependencies = [ "heck", "proc-macro2", @@ -859,9 +858,15 @@ dependencies = [ [[package]] name = "clap_lex" -version = "0.7.0" +version = "0.7.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4b82cf0babdbd58558212896d1a4272303a57bdb245c2bf1147185fb45640e70" + +[[package]] +name = "cobs" +version = "0.2.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "98cc8fbded0c607b7ba9dd60cd98df59af97e84d24e49c8557331cfc26d301ce" +checksum = "67ba02a97a2bd10f4b59b25c7973101c79642302776489e030cd13cdab09ed15" [[package]] name = "coins-bip32" @@ -1070,15 +1075,14 @@ dependencies = [ [[package]] name = "curve25519-dalek" -version = "4.1.2" +version = "4.1.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0a677b8922c94e01bdbb12126b0bc852f00447528dee1782229af9c720c3f348" +checksum = "97fb8b7c4503de7d6ae7b42ab72a5a59857b4c937ec27a3d4539dba95b5ab2be" dependencies = [ "cfg-if", "cpufeatures", "curve25519-dalek-derive", "fiat-crypto", - "platforms", "rustc_version 0.4.0", "subtle", "zeroize", @@ -1110,7 +1114,7 @@ dependencies = [ [[package]] name = "cycle-tracking-script" -version = "0.1.0" +version = "1.0.0-rc.1" dependencies = [ "sp1-helper", "sp1-sdk", @@ -1195,15 +1199,15 @@ dependencies = [ [[package]] name = "derive_more" -version = "0.99.17" +version = "0.99.18" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4fb810d30a7c1953f91334de7244731fc3f3c10d7fe163338a35b9f640960321" +checksum = "5f33878137e4dafd7fa914ad4e259e18a4e8e532b9617a2d0150262bf53abfce" dependencies = [ "convert_case", "proc-macro2", "quote", "rustc_version 0.4.0", - "syn 1.0.109", + "syn 2.0.66", ] [[package]] @@ -1293,7 +1297,9 @@ dependencies = [ "curve25519-dalek-ng", "hex", "rand_core", + "serde", "sha2 0.9.9", + "thiserror", "zeroize", ] @@ -1328,6 +1334,12 @@ dependencies = [ "zeroize", ] +[[package]] +name = "embedded-io" +version = "0.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ef1a6892d9eef45c8fa6b9e0086428a2cca8491aca8f787c534a3d6d0bcb3ced" + [[package]] name = "encode_unicode" version = "0.3.6" @@ -1716,7 +1728,7 @@ checksum = "28dea519a9695b9977216879a3ebfddf92f1c08c05d984f8996aecd6ecdc811d" [[package]] name = "fibonacci-script" -version = "0.1.0" +version = "1.0.0-rc.1" dependencies = [ "itertools 0.12.1", "sha2 0.10.8", @@ -1918,9 +1930,9 @@ dependencies = [ [[package]] name = "generic-array" -version = "1.0.0" +version = "1.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "fe739944a5406424e080edccb6add95685130b9f160d5407c639c7df0c5836b0" +checksum = "96512db27971c2c3eece70a1e106fbe6c87760234e31e8f7e5634912fe52794a" dependencies = [ "serde", "typenum", @@ -2078,6 +2090,7 @@ checksum = "e5274423e17b7c9fc20b6e7e208532f9b19825d82dfd615708b70edd83df41f1" dependencies = [ "ahash", "allocator-api2", + "serde", ] [[package]] @@ -2176,12 +2189,12 @@ dependencies = [ [[package]] name = "http-body-util" -version = "0.1.1" +version = "0.1.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0475f8b2ac86659c21b64320d5d653f9efe42acd2a4e560073ec61a155a34f1d" +checksum = "793429d76616a256bcb62c2a2ec2bed781c8307e797e2598c50010f2bee2544f" dependencies = [ "bytes", - "futures-core", + "futures-util", "http 1.1.0", "http-body 1.0.0", "pin-project-lite", @@ -2189,9 +2202,9 @@ dependencies = [ [[package]] name = "httparse" -version = "1.8.0" +version = "1.9.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d897f394bad6a705d5f4104762e116a75639e470d80901eed05a860a95cb1904" +checksum = "0fcc0b4a115bf80b728eb8ea024ad5bd707b615bfed49e0665b6e0f86fd082d9" [[package]] name = "httpdate" @@ -2201,9 +2214,9 @@ checksum = "df3b46402a9d5adb4c86a0cf463f42e19994e3ee891101b1841f30a545cb49a9" [[package]] name = "hyper" -version = "0.14.28" +version = "0.14.29" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bf96e135eb83a2a8ddf766e426a841d8ddd7449d5f00d34ea02b41d2f19eef80" +checksum = "f361cde2f109281a220d4307746cdfd5ee3f410da58a70377762396775634b33" dependencies = [ "bytes", "futures-channel", @@ -2246,9 +2259,9 @@ dependencies = [ [[package]] name = "hyper-rustls" -version = "0.26.0" +version = "0.27.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a0bea761b46ae2b24eb4aef630d8d1c398157b6fc29e6350ecf090a0b70c952c" +checksum = "5ee4be2c948921a1a5320b629c4193916ed787a7f7f293fd3f7f5a6c9de74155" dependencies = [ "futures-util", "http 1.1.0", @@ -2259,6 +2272,7 @@ dependencies = [ "tokio", "tokio-rustls", "tower-service", + "webpki-roots", ] [[package]] @@ -2268,7 +2282,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "d6183ddfa99b85da61a140bea0efc93fdf56ceaa041b37d553518030827f9905" dependencies = [ "bytes", - "hyper 0.14.28", + "hyper 0.14.29", "native-tls", "tokio", "tokio-native-tls", @@ -2448,7 +2462,7 @@ dependencies = [ [[package]] name = "io-script" -version = "0.1.0" +version = "1.0.0-rc.1" dependencies = [ "serde", "sp1-helper", @@ -2463,7 +2477,7 @@ checksum = "8f518f335dce6725a761382244631d86cf0ccb2863413590b31338feb467f9c3" [[package]] name = "is-prime-script" -version = "0.1.0" +version = "1.0.0-rc.1" dependencies = [ "sp1-sdk", ] @@ -2527,7 +2541,7 @@ dependencies = [ [[package]] name = "json-script" -version = "0.1.0" +version = "1.0.0-rc.1" dependencies = [ "lib", "serde", @@ -2599,11 +2613,11 @@ dependencies = [ [[package]] name = "lazy_static" -version = "1.4.0" +version = "1.5.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e2abad23fbc42b3700f2f279844dc832adb2b2eb069b2df918f455c4e18cc646" +checksum = "bbd2bcb4c963f2ddae06a2efc7e9f3591312473c50c6685e1f298068316e66fe" dependencies = [ - "spin 0.5.2", + "spin 0.9.8", ] [[package]] @@ -2614,7 +2628,7 @@ checksum = "830d08ce1d1d941e6b30645f1a0eb5643013d835ce3779a5fc208261dbe10f55" [[package]] name = "lib" -version = "0.1.0" +version = "1.0.0-rc.1" dependencies = [ "serde", ] @@ -2693,9 +2707,9 @@ dependencies = [ [[package]] name = "log" -version = "0.4.21" +version = "0.4.22" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "90ed8c1e510134f979dbc4f070f87d4313098b704861a105fe34231c70a3901c" +checksum = "a7a70ba024b9dc04c27ea2f0c0548feb474ec5c54bba33a7f72f873a39d07b24" [[package]] name = "matchers" @@ -2714,9 +2728,9 @@ checksum = "0e7465ac9959cc2b1404e8e2367b43684a6d13790fe23056cc8c6c5a6b7bcb94" [[package]] name = "memchr" -version = "2.7.2" +version = "2.7.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6c8640c5d730cb13ebd907d8d04b52f55ac9a2eec55b440c8892f40d56c76c1d" +checksum = "78ca9ab1a0babb1e7d5695e3530886289c18cf2f87ec19a575a0abdce112e3a3" [[package]] name = "memuse" @@ -2738,9 +2752,9 @@ checksum = "68354c5c6bd36d73ff3feceb05efa59b6acb7626617f4962be322a825e61f79a" [[package]] name = "miniz_oxide" -version = "0.7.3" +version = "0.7.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "87dfd01fe195c66b572b37921ad8803d010623c0aca821bea2302239d155cdae" +checksum = "b8a240ddb74feaf34a79a7add65a741f3167852fba007066dcac1ca548d89c08" dependencies = [ "adler", ] @@ -2789,6 +2803,15 @@ dependencies = [ "minimal-lexical", ] +[[package]] +name = "ntapi" +version = "0.4.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e8a3895c6391c39d7fe7ebc444a87eb2991b2a0bc718fdabd071eec617fc68e4" +dependencies = [ + "winapi", +] + [[package]] name = "nu-ansi-term" version = "0.46.0" @@ -2805,7 +2828,7 @@ version = "0.4.3" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "35bd024e8b2ff75562e5f34e7f4905839deb4b22955ef5e73d2fea1b9813cb23" dependencies = [ - "num-bigint 0.4.5", + "num-bigint 0.4.6", "num-complex", "num-integer", "num-iter", @@ -2826,9 +2849,9 @@ dependencies = [ [[package]] name = "num-bigint" -version = "0.4.5" +version = "0.4.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c165a9ab64cf766f73521c0dd2cfdff64f488b8f0b3e621face3462d3db536d7" +checksum = "a5e44f723f1133c9deac646763579fdb3ac745e418f2a7af9cd0c431da1f20b9" dependencies = [ "num-integer", "num-traits", @@ -2868,13 +2891,13 @@ checksum = "51d515d32fb182ee37cda2ccdcb92950d6a3c2893aa280e540671c2cd0f3b1d9" [[package]] name = "num-derive" -version = "0.3.3" +version = "0.4.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "876a53fff98e03a936a674b29568b0e605f06b29372c2489ff4de23f1949743d" +checksum = "ed3955f1a9c7c0c15e092f9c887db08b1fc683305fdf6eb6684f22555355e202" dependencies = [ "proc-macro2", "quote", - "syn 1.0.109", + "syn 2.0.66", ] [[package]] @@ -2903,7 +2926,7 @@ version = "0.4.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "f83d14da390562dca69fc84082e73e548e1ad308d24accdedd2720017cb37824" dependencies = [ - "num-bigint 0.4.5", + "num-bigint 0.4.6", "num-integer", "num-traits", ] @@ -2987,9 +3010,9 @@ checksum = "830b246a0e5f20af87141b25c173cd1b609bd7779a4617d6ec582abaf90870f3" [[package]] name = "object" -version = "0.35.0" +version = "0.36.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b8ec7ab813848ba4522158d5517a6093db1ded27575b070f4177b8d12b41db5e" +checksum = "576dfe1fc8f9df304abb159d767a29d0476f7750fbf8aa7ad07816004a207434" dependencies = [ "memchr", ] @@ -3000,6 +3023,12 @@ version = "1.19.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "3fdb12b2476b595f9358c5161aa467c2438859caa136dec86c26fdd2efe17b92" +[[package]] +name = "oneshot" +version = "0.1.8" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e296cf87e61c9cfc1a61c3c63a0f7f286ed4554e0e22be84e8a38e1d264a2a29" + [[package]] name = "opaque-debug" version = "0.3.1" @@ -3089,8 +3118,9 @@ checksum = "b15813163c1d831bf4a13c3610c05c0d03b39feb07f7e09fa234dac9b15aaf39" [[package]] name = "p3-air" -version = "0.1.0" -source = "git+https://github.com/Plonky3/Plonky3.git?rev=3b5265f9d5af36534a46caebf0617595cfb42c5a#3b5265f9d5af36534a46caebf0617595cfb42c5a" +version = "0.1.3-succinct" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "45e909ef66fa5d77ff0fd3cb5af4b33b27fa6fb68d02b9b1e70edbc29383e565" dependencies = [ "p3-field", "p3-matrix", @@ -3098,10 +3128,11 @@ dependencies = [ [[package]] name = "p3-baby-bear" -version = "0.1.0" -source = "git+https://github.com/Plonky3/Plonky3.git?rev=3b5265f9d5af36534a46caebf0617595cfb42c5a#3b5265f9d5af36534a46caebf0617595cfb42c5a" +version = "0.1.3-succinct" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "46965470aac1cddfe52f535424b59d52f2fffef0fdeb9dbed19da39b1d8f048a" dependencies = [ - "num-bigint 0.4.5", + "num-bigint 0.4.6", "p3-field", "p3-mds", "p3-poseidon2", @@ -3112,8 +3143,9 @@ dependencies = [ [[package]] name = "p3-blake3" -version = "0.1.0" -source = "git+https://github.com/Plonky3/Plonky3.git?rev=3b5265f9d5af36534a46caebf0617595cfb42c5a#3b5265f9d5af36534a46caebf0617595cfb42c5a" +version = "0.1.3-succinct" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "36ef32d6ea21dd5cf9fec8a31bf0c64e6ceee8901dbf50966b83a443093c2aba" dependencies = [ "blake3", "p3-symmetric", @@ -3121,11 +3153,12 @@ dependencies = [ [[package]] name = "p3-bn254-fr" -version = "0.1.0" -source = "git+https://github.com/Plonky3/Plonky3.git?rev=3b5265f9d5af36534a46caebf0617595cfb42c5a#3b5265f9d5af36534a46caebf0617595cfb42c5a" +version = "0.1.3-succinct" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7e3edfca6be3b3109adf8e3330baec30c3fc5f9f4d63d27aaec1b471ca51ed67" dependencies = [ "ff 0.13.0", - "num-bigint 0.4.5", + "num-bigint 0.4.6", "p3-field", "p3-poseidon2", "p3-symmetric", @@ -3135,8 +3168,9 @@ dependencies = [ [[package]] name = "p3-challenger" -version = "0.1.0" -source = "git+https://github.com/Plonky3/Plonky3.git?rev=3b5265f9d5af36534a46caebf0617595cfb42c5a#3b5265f9d5af36534a46caebf0617595cfb42c5a" +version = "0.1.3-succinct" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a6662ea899a5d848b60c699944491d72757873b5e1fd46798e4712f90a03a4e9" dependencies = [ "p3-field", "p3-maybe-rayon", @@ -3147,8 +3181,9 @@ dependencies = [ [[package]] name = "p3-commit" -version = "0.1.0" -source = "git+https://github.com/Plonky3/Plonky3.git?rev=3b5265f9d5af36534a46caebf0617595cfb42c5a#3b5265f9d5af36534a46caebf0617595cfb42c5a" +version = "0.1.3-succinct" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "fc3563918b5cc44ef5280bf9b51753e70dc78802de25e3fb81ed6c94617ccb6e" dependencies = [ "itertools 0.12.1", "p3-challenger", @@ -3160,8 +3195,9 @@ dependencies = [ [[package]] name = "p3-dft" -version = "0.1.0" -source = "git+https://github.com/Plonky3/Plonky3.git?rev=3b5265f9d5af36534a46caebf0617595cfb42c5a#3b5265f9d5af36534a46caebf0617595cfb42c5a" +version = "0.1.3-succinct" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "510095701819d83c9509fe825bbf1ebfe50426ae75149df5fe1dcfd18261323a" dependencies = [ "p3-field", "p3-matrix", @@ -3172,11 +3208,12 @@ dependencies = [ [[package]] name = "p3-field" -version = "0.1.0" -source = "git+https://github.com/Plonky3/Plonky3.git?rev=3b5265f9d5af36534a46caebf0617595cfb42c5a#3b5265f9d5af36534a46caebf0617595cfb42c5a" +version = "0.1.3-succinct" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "61f1977a0a65789f719aa824119c332c4676b000bdbfe94d312fb6244a70d601" dependencies = [ "itertools 0.12.1", - "num-bigint 0.4.5", + "num-bigint 0.4.6", "num-traits", "p3-util", "rand", @@ -3185,8 +3222,9 @@ dependencies = [ [[package]] name = "p3-fri" -version = "0.1.0" -source = "git+https://github.com/Plonky3/Plonky3.git?rev=3b5265f9d5af36534a46caebf0617595cfb42c5a#3b5265f9d5af36534a46caebf0617595cfb42c5a" +version = "0.1.3-succinct" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c22ddb958f200d9289cc73ff68847b0167ca0c14557b791dd9e318f98c2d1b28" dependencies = [ "itertools 0.12.1", "p3-challenger", @@ -3203,8 +3241,9 @@ dependencies = [ [[package]] name = "p3-interpolation" -version = "0.1.0" -source = "git+https://github.com/Plonky3/Plonky3.git?rev=3b5265f9d5af36534a46caebf0617595cfb42c5a#3b5265f9d5af36534a46caebf0617595cfb42c5a" +version = "0.1.3-succinct" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d032cda212f6b408d7d5b0b9a8270a9455acb93742fe55a0880d82be8e90e500" dependencies = [ "p3-field", "p3-matrix", @@ -3213,8 +3252,9 @@ dependencies = [ [[package]] name = "p3-keccak" -version = "0.1.0" -source = "git+https://github.com/Plonky3/Plonky3.git?rev=3b5265f9d5af36534a46caebf0617595cfb42c5a#3b5265f9d5af36534a46caebf0617595cfb42c5a" +version = "0.1.3-succinct" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7c56abdd5a8a780049d2f8e92cea1df57b55a2ef50a40d1103f2732f7a00e4b1" dependencies = [ "p3-symmetric", "tiny-keccak", @@ -3222,8 +3262,9 @@ dependencies = [ [[package]] name = "p3-keccak-air" -version = "0.1.0" -source = "git+https://github.com/Plonky3/Plonky3.git?rev=3b5265f9d5af36534a46caebf0617595cfb42c5a#3b5265f9d5af36534a46caebf0617595cfb42c5a" +version = "0.1.3-succinct" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e8398f1694ccc38513df0b8cab5f9ef7325423f27cd9e4fa20bdc77d5079cf1b" dependencies = [ "p3-air", "p3-field", @@ -3231,12 +3272,15 @@ dependencies = [ "p3-maybe-rayon", "p3-util", "tracing", + "tracing-forest", + "tracing-subscriber", ] [[package]] name = "p3-matrix" -version = "0.1.0" -source = "git+https://github.com/Plonky3/Plonky3.git?rev=3b5265f9d5af36534a46caebf0617595cfb42c5a#3b5265f9d5af36534a46caebf0617595cfb42c5a" +version = "0.1.3-succinct" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d548ee0b834f8e2ebc5037073acd101a3b0ca41a2d1d28a15ba0ccd9059495b0" dependencies = [ "itertools 0.12.1", "p3-field", @@ -3249,16 +3293,18 @@ dependencies = [ [[package]] name = "p3-maybe-rayon" -version = "0.1.0" -source = "git+https://github.com/Plonky3/Plonky3.git?rev=3b5265f9d5af36534a46caebf0617595cfb42c5a#3b5265f9d5af36534a46caebf0617595cfb42c5a" +version = "0.1.3-succinct" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "55f5575d3d61bedb3e05681abb0f36b8bb339d65aa395d50756bfa64e9cd3f46" dependencies = [ "rayon", ] [[package]] name = "p3-mds" -version = "0.1.0" -source = "git+https://github.com/Plonky3/Plonky3.git?rev=3b5265f9d5af36534a46caebf0617595cfb42c5a#3b5265f9d5af36534a46caebf0617595cfb42c5a" +version = "0.1.3-succinct" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6a6e57ed310d59245f93e24ee805ea7aa16fc9c505551b76a15f5e50f29d177e" dependencies = [ "itertools 0.12.1", "p3-dft", @@ -3271,8 +3317,9 @@ dependencies = [ [[package]] name = "p3-merkle-tree" -version = "0.1.0" -source = "git+https://github.com/Plonky3/Plonky3.git?rev=3b5265f9d5af36534a46caebf0617595cfb42c5a#3b5265f9d5af36534a46caebf0617595cfb42c5a" +version = "0.1.3-succinct" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "af46b41cba75d483ec8a553cbab1d2d794935ae3403d75394acfa4fb2c977cce" dependencies = [ "itertools 0.12.1", "p3-commit", @@ -3287,8 +3334,9 @@ dependencies = [ [[package]] name = "p3-poseidon2" -version = "0.1.0" -source = "git+https://github.com/Plonky3/Plonky3.git?rev=3b5265f9d5af36534a46caebf0617595cfb42c5a#3b5265f9d5af36534a46caebf0617595cfb42c5a" +version = "0.1.3-succinct" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "adaba6f14c197203530e233badce0ca1126ba3bf3c9ff766505b497bdad0bee1" dependencies = [ "gcd", "p3-field", @@ -3299,8 +3347,9 @@ dependencies = [ [[package]] name = "p3-symmetric" -version = "0.1.0" -source = "git+https://github.com/Plonky3/Plonky3.git?rev=3b5265f9d5af36534a46caebf0617595cfb42c5a#3b5265f9d5af36534a46caebf0617595cfb42c5a" +version = "0.1.3-succinct" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "57ecc4282566eb14f48be7707f6745c4dff6be664984d59ec0fb1849cd82b5c2" dependencies = [ "itertools 0.12.1", "p3-field", @@ -3309,8 +3358,9 @@ dependencies = [ [[package]] name = "p3-uni-stark" -version = "0.1.0" -source = "git+https://github.com/Plonky3/Plonky3.git?rev=3b5265f9d5af36534a46caebf0617595cfb42c5a#3b5265f9d5af36534a46caebf0617595cfb42c5a" +version = "0.1.3-succinct" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1af5c038b22b058bf1d49fb1ea3dd6c240a3e46c3278fde5c444e0034f7ffe37" dependencies = [ "itertools 0.12.1", "p3-air", @@ -3321,14 +3371,18 @@ dependencies = [ "p3-matrix", "p3-maybe-rayon", "p3-util", + "postcard", "serde", "tracing", + "tracing-forest", + "tracing-subscriber", ] [[package]] name = "p3-util" -version = "0.1.0" -source = "git+https://github.com/Plonky3/Plonky3.git?rev=3b5265f9d5af36534a46caebf0617595cfb42c5a#3b5265f9d5af36534a46caebf0617595cfb42c5a" +version = "0.1.3-succinct" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "79f3fef0e00d9d7246385e758c4cd39b4efcbbcea31752471491ab502631385e" dependencies = [ "serde", ] @@ -3427,6 +3481,18 @@ version = "1.0.15" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "57c0d7b74b563b49d38dae00a0c37d4d6de9b432382b2892f0574ddcae73fd0a" +[[package]] +name = "patch-testing-script" +version = "1.0.0-rc.1" +dependencies = [ + "ed25519-consensus", + "rand", + "sp1-core", + "sp1-helper", + "sp1-sdk", + "tiny-keccak", +] + [[package]] name = "pbkdf2" version = "0.11.0" @@ -3561,18 +3627,23 @@ version = "0.3.30" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "d231b230927b5e4ad203db57bbcbee2802f6bce620b1e4a9024a07d94e2907ec" -[[package]] -name = "platforms" -version = "3.4.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "db23d408679286588f4d4644f965003d056e3dd5abcaaa938116871d7ce2fee7" - [[package]] name = "portable-atomic" version = "1.6.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "7170ef9988bc169ba16dd36a7fa041e5c4cbeb6a35b76d4c03daded371eae7c0" +[[package]] +name = "postcard" +version = "1.0.8" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a55c51ee6c0db07e68448e336cf8ea4131a620edefebf9893e759b2d793420f8" +dependencies = [ + "cobs", + "embedded-io", + "serde", +] + [[package]] name = "powerfmt" version = "0.2.0" @@ -3654,9 +3725,9 @@ dependencies = [ [[package]] name = "proc-macro2" -version = "1.0.84" +version = "1.0.85" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ec96c6a92621310b51366f1e28d05ef11489516e93be030060e5fc12024a49d6" +checksum = "22244ce15aa966053a896d1accb3a6e68469b97c7f33f284b99f0d576879fc23" dependencies = [ "unicode-ident", ] @@ -3675,7 +3746,7 @@ dependencies = [ "rand", "rand_chacha", "rand_xorshift", - "regex-syntax 0.8.3", + "regex-syntax 0.8.4", "rusty-fork", "tempfile", "unarray", @@ -3713,12 +3784,68 @@ dependencies = [ "prost", ] +[[package]] +name = "psm" +version = "0.1.21" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5787f7cda34e3033a72192c018bc5883100330f362ef279a8cbccfce8bb4e874" +dependencies = [ + "cc", +] + [[package]] name = "quick-error" version = "1.2.3" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "a1d01941d82fa2ab50be1e79e6714289dd7cde78eba4c074bc5a4374f650dfe0" +[[package]] +name = "quinn" +version = "0.11.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e4ceeeeabace7857413798eb1ffa1e9c905a9946a57d81fb69b4b71c4d8eb3ad" +dependencies = [ + "bytes", + "pin-project-lite", + "quinn-proto", + "quinn-udp", + "rustc-hash", + "rustls", + "thiserror", + "tokio", + "tracing", +] + +[[package]] +name = "quinn-proto" +version = "0.11.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ddf517c03a109db8100448a4be38d498df8a210a99fe0e1b9eaf39e78c640efe" +dependencies = [ + "bytes", + "rand", + "ring 0.17.8", + "rustc-hash", + "rustls", + "slab", + "thiserror", + "tinyvec", + "tracing", +] + +[[package]] +name = "quinn-udp" +version = "0.5.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9096629c45860fc7fb143e125eb826b5e721e10be3263160c7d60ca832cf8c46" +dependencies = [ + "libc", + "once_cell", + "socket2", + "tracing", + "windows-sys 0.52.0", +] + [[package]] name = "quote" version = "1.0.36" @@ -3804,9 +3931,9 @@ dependencies = [ [[package]] name = "redox_syscall" -version = "0.5.1" +version = "0.5.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "469052894dcb553421e483e4209ee581a45100d31b4018de03e5a7ad86374a7e" +checksum = "c82cf8cff14456045f55ec4241383baeff27af886adb72ffb2162f99911de0fd" dependencies = [ "bitflags 2.5.0", ] @@ -3824,14 +3951,14 @@ dependencies = [ [[package]] name = "regex" -version = "1.10.4" +version = "1.10.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c117dbdfde9c8308975b6a18d71f3f385c89461f7b3fb054288ecf2a2058ba4c" +checksum = "b91213439dad192326a0d7c6ee3955910425f441d7038e0d6933b0aec5c4517f" dependencies = [ "aho-corasick", "memchr", - "regex-automata 0.4.6", - "regex-syntax 0.8.3", + "regex-automata 0.4.7", + "regex-syntax 0.8.4", ] [[package]] @@ -3845,18 +3972,18 @@ dependencies = [ [[package]] name = "regex-automata" -version = "0.4.6" +version = "0.4.7" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "86b83b8b9847f9bf95ef68afb0b8e6cdb80f498442f5179a29fad448fcc1eaea" +checksum = "38caf58cc5ef2fed281f89292ef23f6365465ed9a41b7a7754eb4e26496c92df" dependencies = [ "aho-corasick", "memchr", - "regex-syntax 0.8.3", + "regex-syntax 0.8.4", ] [[package]] name = "regex-script" -version = "0.1.0" +version = "1.0.0-rc.1" dependencies = [ "sp1-helper", "sp1-sdk", @@ -3870,9 +3997,9 @@ checksum = "f162c6dd7b008981e4d40210aca20b4bd0f9b60ca9271061b07f78537722f2e1" [[package]] name = "regex-syntax" -version = "0.8.3" +version = "0.8.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "adad44e29e4c806119491a7f06f03de4d1af22c3a680dd47f1e6e179439d1f56" +checksum = "7a66a03ae7c801facd77a29370b4faec201768915ac14a721ba36f20bc9c209b" [[package]] name = "reqwest" @@ -3888,7 +4015,7 @@ dependencies = [ "h2 0.3.26", "http 0.2.12", "http-body 0.4.6", - "hyper 0.14.28", + "hyper 0.14.29", "hyper-tls 0.5.0", "ipnet", "js-sys", @@ -3916,9 +4043,9 @@ dependencies = [ [[package]] name = "reqwest" -version = "0.12.4" +version = "0.12.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "566cafdd92868e0939d3fb961bd0dc25fcfaaed179291093b3d43e6b3150ea10" +checksum = "c7d6d2a27d57148378eb5e111173f4276ad26340ecc5c49a4a2152167a2d6a37" dependencies = [ "base64 0.22.1", "bytes", @@ -3941,13 +4068,14 @@ dependencies = [ "once_cell", "percent-encoding", "pin-project-lite", + "quinn", "rustls", "rustls-pemfile 2.1.2", "rustls-pki-types", "serde", "serde_json", "serde_urlencoded", - "sync_wrapper 0.1.2", + "sync_wrapper 1.0.1", "system-configuration", "tokio", "tokio-native-tls", @@ -3965,14 +4093,14 @@ dependencies = [ [[package]] name = "reqwest-middleware" -version = "0.3.1" +version = "0.3.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a45d100244a467870f6cb763c4484d010a6bed6bd610b3676e3825d93fb4cfbd" +checksum = "39346a33ddfe6be00cbc17a34ce996818b97b230b87229f10114693becca1268" dependencies = [ "anyhow", "async-trait", "http 1.1.0", - "reqwest 0.12.4", + "reqwest 0.12.5", "serde", "thiserror", "tower-service", @@ -4050,9 +4178,10 @@ dependencies = [ ] [[package]] -name = "rrs-lib" +name = "rrs-succinct" version = "0.1.0" -source = "git+https://github.com/GregAC/rrs.git#b23afc16b4e6a1fb5c4a73eb1e337e9400816507" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3372685893a9f67d18e98e792d690017287fd17379a83d798d958e517d380fa9" dependencies = [ "downcast-rs", "num_enum 0.5.11", @@ -4081,7 +4210,7 @@ dependencies = [ [[package]] name = "rsa-script" -version = "0.1.0" +version = "1.0.0-rc.1" dependencies = [ "rsa", "sp1-helper", @@ -4099,7 +4228,7 @@ dependencies = [ "ark-ff 0.4.2", "bytes", "fastrlp", - "num-bigint 0.4.5", + "num-bigint 0.4.6", "num-traits", "parity-scale-codec", "primitive-types", @@ -4169,11 +4298,11 @@ dependencies = [ [[package]] name = "rustls" -version = "0.22.4" +version = "0.23.10" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bf4ef73721ac7bcd79b2b315da7779d8fc09718c6b3d2d1b2d94850eb8c18432" +checksum = "05cff451f60db80f490f3c182b77c35260baace73209e9cdbbe526bfe3a4d402" dependencies = [ - "log", + "once_cell", "ring 0.17.8", "rustls-pki-types", "rustls-webpki", @@ -4403,9 +4532,9 @@ checksum = "cd0b0ec5f1c1ca621c432a25813d8d60c88abe6d3e08a3eb9cf37d97a0fe3d73" [[package]] name = "serde" -version = "1.0.203" +version = "1.0.204" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7253ab4de971e72fb7be983802300c30b5a7f0c2e56fab8abfc6a214307c0094" +checksum = "bc76f558e0cbb2a839d37354c575f1dc3fdc6546b5be373ba43d95f231bf7c12" dependencies = [ "serde_derive", ] @@ -4431,9 +4560,9 @@ dependencies = [ [[package]] name = "serde_derive" -version = "1.0.203" +version = "1.0.204" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "500cbc0ebeb6f46627f50f3f5811ccf6bf00643be300b4c3eabc0ef55dc5b5ba" +checksum = "e0cd7e117be63d3c3678776753929474f3b04a43a080c744d6b0ae2a8c28e222" dependencies = [ "proc-macro2", "quote", @@ -4442,9 +4571,9 @@ dependencies = [ [[package]] name = "serde_json" -version = "1.0.117" +version = "1.0.120" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "455182ea6142b14f93f4bc5320a2b31c1f266b66a4a5c858b013302a5d8cbfc3" +checksum = "4e0d21c9a8cae1235ad58a00c11cb40d4b1e5c784f1ef2c537876ed6ffd8b7c5" dependencies = [ "itoa", "ryu", @@ -4495,9 +4624,9 @@ dependencies = [ [[package]] name = "serde_with" -version = "3.8.1" +version = "3.9.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0ad483d2ab0149d5a5ebcd9972a3852711e0153d863bf5a5d0391d28883c4a20" +checksum = "69cecfa94848272156ea67b2b1a53f20fc7bc638c4a46d2f8abde08f05f4b857" dependencies = [ "base64 0.22.1", "chrono", @@ -4513,9 +4642,9 @@ dependencies = [ [[package]] name = "serde_with_macros" -version = "3.8.1" +version = "3.9.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "65569b702f41443e8bc8bbb1c5779bd0450bbe723b56198980e80ec45780bce2" +checksum = "a8fee4991ef4f274617a51ad4af30519438dacb2f56ac773b08a1922ff743350" dependencies = [ "darling", "proc-macro2", @@ -4632,7 +4761,7 @@ version = "0.6.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "adc4e5204eb1910f40f9cfa375f6f05b68c3abac4b6fd879c8ff5e7ae8a0a085" dependencies = [ - "num-bigint 0.4.5", + "num-bigint 0.4.6", "num-traits", "thiserror", "time", @@ -4679,9 +4808,18 @@ dependencies = [ "windows-sys 0.52.0", ] +[[package]] +name = "sp1-build" +version = "1.0.0-rc.1" +dependencies = [ + "anyhow", + "cargo_metadata", + "clap", +] + [[package]] name = "sp1-core" -version = "0.1.0" +version = "1.0.0-rc.1" dependencies = [ "anyhow", "arrayref", @@ -4692,14 +4830,15 @@ dependencies = [ "curve25519-dalek", "elf", "elliptic-curve", - "generic-array 1.0.0", + "generic-array 1.1.0", + "hashbrown 0.14.5", "hex", "itertools 0.13.0", "k256", "log", "nohash-hasher", "num", - "num-bigint 0.4.5", + "num-bigint 0.4.6", "num_cpus", "p3-air", "p3-baby-bear", @@ -4720,7 +4859,7 @@ dependencies = [ "p3-util", "rand", "rayon-scan", - "rrs-lib", + "rrs-succinct", "serde", "serde_with", "size", @@ -4740,7 +4879,7 @@ dependencies = [ [[package]] name = "sp1-derive" -version = "0.1.0" +version = "1.0.0-rc.1" dependencies = [ "proc-macro2", "quote", @@ -4749,15 +4888,16 @@ dependencies = [ [[package]] name = "sp1-helper" -version = "0.1.0" +version = "1.0.0-rc.1" dependencies = [ "cargo_metadata", "chrono", + "sp1-build", ] [[package]] name = "sp1-primitives" -version = "0.1.0" +version = "1.0.0-rc.1" dependencies = [ "itertools 0.13.0", "lazy_static", @@ -4769,33 +4909,25 @@ dependencies = [ [[package]] name = "sp1-prover" -version = "0.1.0" +version = "1.0.0-rc.1" dependencies = [ "anyhow", - "backtrace", "bincode", - "bytemuck", "clap", "dirs", - "futures", "hex", - "indicatif", "itertools 0.13.0", - "num-bigint 0.4.5", + "num-bigint 0.4.6", + "oneshot", "p3-baby-bear", "p3-bn254-fr", "p3-challenger", "p3-commit", "p3-field", - "p3-util", - "rand", "rayon", - "reqwest 0.12.4", "serde", "serde_json", "serial_test", - "sha2 0.10.8", - "size", "sp1-core", "sp1-primitives", "sp1-recursion-circuit", @@ -4806,14 +4938,13 @@ dependencies = [ "subtle-encoding", "tempfile", "thiserror", - "tokio", "tracing", "tracing-subscriber", ] [[package]] name = "sp1-recursion-circuit" -version = "0.1.0" +version = "1.0.0-rc.1" dependencies = [ "bincode", "itertools 0.13.0", @@ -4835,7 +4966,7 @@ dependencies = [ [[package]] name = "sp1-recursion-compiler" -version = "0.1.0" +version = "1.0.0-rc.1" dependencies = [ "backtrace", "itertools 0.13.0", @@ -4851,6 +4982,7 @@ dependencies = [ "p3-util", "serde", "sp1-core", + "sp1-primitives", "sp1-recursion-core", "sp1-recursion-derive", "tracing", @@ -4858,13 +4990,14 @@ dependencies = [ [[package]] name = "sp1-recursion-core" -version = "0.1.0" +version = "1.0.0-rc.1" dependencies = [ "arrayref", "backtrace", "ff 0.13.0", "hashbrown 0.14.5", "itertools 0.13.0", + "num_cpus", "p3-air", "p3-baby-bear", "p3-bn254-fr", @@ -4891,7 +5024,7 @@ dependencies = [ [[package]] name = "sp1-recursion-derive" -version = "0.1.0" +version = "1.0.0-rc.1" dependencies = [ "proc-macro2", "quote", @@ -4900,7 +5033,7 @@ dependencies = [ [[package]] name = "sp1-recursion-gnark-ffi" -version = "0.1.0" +version = "1.0.0-rc.1" dependencies = [ "anyhow", "bincode", @@ -4909,7 +5042,7 @@ dependencies = [ "cfg-if", "hex", "log", - "num-bigint 0.4.5", + "num-bigint 0.4.6", "p3-baby-bear", "p3-field", "p3-symmetric", @@ -4924,7 +5057,7 @@ dependencies = [ [[package]] name = "sp1-recursion-program" -version = "0.1.0" +version = "1.0.0-rc.1" dependencies = [ "itertools 0.13.0", "p3-air", @@ -4943,14 +5076,16 @@ dependencies = [ "rand", "serde", "sp1-core", + "sp1-primitives", "sp1-recursion-compiler", "sp1-recursion-core", + "stacker", "tracing", ] [[package]] name = "sp1-sdk" -version = "0.1.0" +version = "1.0.0-rc.1" dependencies = [ "alloy-sol-types", "anyhow", @@ -4961,15 +5096,18 @@ dependencies = [ "dirs", "ethers", "futures", + "hashbrown 0.14.5", "hex", "indicatif", "log", - "num-bigint 0.4.5", + "num-bigint 0.4.6", + "p3-baby-bear", "p3-commit", "p3-field", + "p3-fri", "p3-matrix", "prost", - "reqwest 0.12.4", + "reqwest 0.12.5", "reqwest-middleware", "serde", "serde_json", @@ -4978,11 +5116,12 @@ dependencies = [ "sp1-prover", "strum", "strum_macros", + "sysinfo", "tempfile", "thiserror", "tokio", "tracing", - "twirp", + "twirp-rs", "vergen", ] @@ -5020,12 +5159,25 @@ dependencies = [ [[package]] name = "ssz-withdrawals-script" -version = "0.1.0" +version = "1.0.0-rc.1" dependencies = [ "sp1-helper", "sp1-sdk", ] +[[package]] +name = "stacker" +version = "0.1.15" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c886bd4480155fd3ef527d45e9ac8dd7118a898a46530b7b94c3e21866259fce" +dependencies = [ + "cc", + "cfg-if", + "libc", + "psm", + "winapi", +] + [[package]] name = "static_assertions" version = "1.1.0" @@ -5040,9 +5192,9 @@ checksum = "7da8b5736845d9f2fcb837ea5d9e2628564b3b043a70948a3f0b778838c5fb4f" [[package]] name = "strum" -version = "0.26.2" +version = "0.26.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5d8cec3501a5194c432b2b7976db6b7d10ec95c253208b45f83f7136aa985e29" +checksum = "8fec0f0aef304996cf250b31b5a10dee7980c85da9d759361292b8bca5a18f06" dependencies = [ "strum_macros", ] @@ -5127,6 +5279,21 @@ version = "1.0.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "a7065abeca94b6a8a577f9bd45aa0867a2238b74e8eb67cf10d492bc39351394" +[[package]] +name = "sysinfo" +version = "0.30.13" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0a5b4ddaee55fb2bea2bf0e5000747e5f5c0de765e5a5ff87f4cd106439f4bb3" +dependencies = [ + "cfg-if", + "core-foundation-sys", + "libc", + "ntapi", + "once_cell", + "rayon", + "windows", +] + [[package]] name = "system-configuration" version = "0.5.1" @@ -5168,9 +5335,9 @@ dependencies = [ [[package]] name = "tendermint" -version = "0.34.1" +version = "0.35.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "15ab8f0a25d0d2ad49ac615da054d6a76aa6603ff95f7d18bafdd34450a1a04b" +checksum = "43f8a10105d0a7c4af0a242e23ed5a12519afe5cc0e68419da441bb5981a6802" dependencies = [ "bytes", "digest 0.10.7", @@ -5197,9 +5364,9 @@ dependencies = [ [[package]] name = "tendermint-light-client-verifier" -version = "0.34.1" +version = "0.35.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9b8090d0eef9ad57b1b913b5e358e26145c86017e87338136509b94383a4af25" +checksum = "35678b66e819659617c2e83f9662b8544425694441990c07137904a07872d871" dependencies = [ "derive_more", "flex-error", @@ -5210,9 +5377,9 @@ dependencies = [ [[package]] name = "tendermint-proto" -version = "0.34.1" +version = "0.35.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b797dd3d2beaaee91d2f065e7bdf239dc8d80bba4a183a288bc1279dd5a69a1e" +checksum = "ff525d5540a9fc535c38dc0d92a98da3ee36fcdfbda99cecb9f3cce5cd4d41d7" dependencies = [ "bytes", "flex-error", @@ -5228,7 +5395,7 @@ dependencies = [ [[package]] name = "tendermint-script" -version = "0.1.0" +version = "1.0.0-rc.1" dependencies = [ "bincode", "itertools 0.12.1", @@ -5374,9 +5541,9 @@ dependencies = [ [[package]] name = "tokio-rustls" -version = "0.25.0" +version = "0.26.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "775e0c0f0adb3a2f22a00c4745d728b479985fc15ee7ca6a2608388c5569860f" +checksum = "0c7bc40d0e5a97695bb96e27995cd3a08538541b0a846f65bba7a359f36700d4" dependencies = [ "rustls", "rustls-pki-types", @@ -5398,14 +5565,14 @@ dependencies = [ [[package]] name = "toml" -version = "0.8.13" +version = "0.8.14" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a4e43f8cc456c9704c851ae29c67e17ef65d2c30017c17a9765b89c382dc8bba" +checksum = "6f49eb2ab21d2f26bd6db7bf383edc527a7ebaee412d17af4d40fdccd442f335" dependencies = [ "serde", "serde_spanned", "toml_datetime", - "toml_edit 0.22.13", + "toml_edit 0.22.14", ] [[package]] @@ -5441,15 +5608,15 @@ dependencies = [ [[package]] name = "toml_edit" -version = "0.22.13" +version = "0.22.14" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c127785850e8c20836d49732ae6abfa47616e60bf9d9f57c43c250361a9db96c" +checksum = "f21c7aaf97f1bd9ca9d4f9e73b0a6c74bd5afef56f2bc931943a6e1c37e04e38" dependencies = [ "indexmap 2.2.6", "serde", "serde_spanned", "toml_datetime", - "winnow 0.6.9", + "winnow 0.6.13", ] [[package]] @@ -5572,9 +5739,10 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "e421abadd41a4225275504ea4d6566923418b7f05506fbc9c0fe86ba7396114b" [[package]] -name = "twirp" +name = "twirp-rs" version = "0.3.0" -source = "git+https://github.com/github/twirp-rs.git?rev=c85f31f9c54957374e7dcb3534fc52cff0aa2dc5#c85f31f9c54957374e7dcb3534fc52cff0aa2dc5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "dfa3161d8eee0abcad4e762f4215381a430cc1281870d575b0f1e4fbfc74b8ce" dependencies = [ "async-trait", "axum", @@ -5584,7 +5752,7 @@ dependencies = [ "http-body-util", "hyper 1.3.1", "prost", - "reqwest 0.12.4", + "reqwest 0.12.5", "serde", "serde_json", "thiserror", @@ -5646,9 +5814,9 @@ dependencies = [ [[package]] name = "unicode-width" -version = "0.1.12" +version = "0.1.13" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "68f5e5f3158ecfd4b8ff6fe086db7c8467a2dfdac97fe420f2b7c4aa97af66d6" +checksum = "0336d538f7abc86d282a4189614dfaa90810dfc2c6f6427eaf88e16311dd225d" [[package]] name = "unicode-xid" @@ -5670,9 +5838,9 @@ checksum = "8ecb6da28b8a351d773b68d5825ac39017e680750f980f3a1a85cd8dd28a47c1" [[package]] name = "url" -version = "2.5.0" +version = "2.5.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "31e6302e3bb753d46e83516cae55ae196fc0c309407cf11ab35cc51a4c2a4633" +checksum = "22784dbdf76fdde8af1aeda5622b546b422b6fc585325248a2bf9f5e41e94d6c" dependencies = [ "form_urlencoded", "idna", @@ -5681,9 +5849,9 @@ dependencies = [ [[package]] name = "utf8parse" -version = "0.2.1" +version = "0.2.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "711b9620af191e0cdc7468a8d14e709c3dcdb115b36f838e601583af800a370a" +checksum = "06abde3611657adf66d383f00b093d7faecc7fa57071cce2578660c9f1010821" [[package]] name = "uuid" @@ -5861,9 +6029,9 @@ dependencies = [ [[package]] name = "webpki-roots" -version = "0.26.1" +version = "0.26.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b3de34ae270483955a94f4b21bdaaeb83d508bb84a01435f393818edb0012009" +checksum = "bd7c23921eeb1713a4e851530e9b9756e4fb0e89978582942612524cf09f01cd" dependencies = [ "rustls-pki-types", ] @@ -5911,6 +6079,16 @@ version = "0.4.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "712e227841d057c1ee1cd2fb22fa7e5a5461ae8e48fa2ca79ec42cfc1931183f" +[[package]] +name = "windows" +version = "0.52.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e48a53791691ab099e5e2ad123536d0fff50652600abaf43bbf952894110d0be" +dependencies = [ + "windows-core", + "windows-targets 0.52.5", +] + [[package]] name = "windows-core" version = "0.52.0" @@ -6070,9 +6248,9 @@ dependencies = [ [[package]] name = "winnow" -version = "0.6.9" +version = "0.6.13" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "86c949fede1d13936a99f14fafd3e76fd642b556dd2ce96287fbe2e0151bfac6" +checksum = "59b5e5f6c299a3c7890b876a2a587f3115162487e704907d9b6cd29473052ba1" dependencies = [ "memchr", ] @@ -6168,7 +6346,8 @@ dependencies = [ [[package]] name = "zkhash" version = "0.2.0" -source = "git+https://github.com/HorizenLabs/poseidon2#bb476b9ca38198cf5092487283c8b8c5d4317c4e" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4352d1081da6922701401cdd4cbf29a2723feb4cfabb5771f6fee8e9276da1c7" dependencies = [ "ark-ff 0.4.2", "ark-std 0.4.0", diff --git a/examples/Cargo.toml b/examples/Cargo.toml index 65d4cb5902..9aa472af29 100644 --- a/examples/Cargo.toml +++ b/examples/Cargo.toml @@ -12,5 +12,29 @@ members = [ "rsa/script", "ssz-withdrawals/script", "tendermint/script", + "patch-testing/script", ] -resolver = "2" \ No newline at end of file +resolver = "2" + +[workspace.package] +version = "1.0.0-rc.1" +edition = "2021" + +[workspace.dependencies] +sp1-build = { path = "../build" } +sp1-derive = { path = "../derive" } +sp1-core = { path = "../core" } +sp1-cli = { path = "../cli", default-features = false } +sp1-eval = { path = "../eval", default-features = false } +sp1-helper = { path = "../helper", default-features = false } +sp1-primitives = { path = "../primitives" } +sp1-prover = { path = "../prover" } +sp1-recursion-compiler = { path = "../recursion/compiler" } +sp1-recursion-core = { path = "../recursion/core", default-features = false } +sp1-recursion-derive = { path = "../recursion/derive", default-features = false } +sp1-recursion-gnark-ffi = { path = "../recursion/gnark-ffi", default-features = false } +sp1-recursion-program = { path = "../recursion/program", default-features = false } +sp1-recursion-circuit = { path = "../recursion/circuit", default-features = false } +sp1-sdk = { path = "../sdk" } +sp1-lib = { path = "../zkvm/lib", default-features = false } +sp1-zkvm = { path = "../zkvm/entrypoint", default-features = false } diff --git a/examples/aggregation/program/Cargo.lock b/examples/aggregation/program/Cargo.lock index 71a2d8afcd..32aa1d0e0c 100644 --- a/examples/aggregation/program/Cargo.lock +++ b/examples/aggregation/program/Cargo.lock @@ -4,7 +4,7 @@ version = 3 [[package]] name = "aggregation-program" -version = "0.1.0" +version = "1.0.0-rc.1" dependencies = [ "hex", "sha2", @@ -17,29 +17,11 @@ version = "1.0.86" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "b3d1d046238990b9cf5bcde22a3fb3584ee5cf65fb2765f454ed428c7a0063da" -[[package]] -name = "arrayvec" -version = "0.7.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "96d30a06541fbafbc7f82ed10c06164cfbd2c401138f6addd8404629c4b16711" - [[package]] name = "autocfg" -version = "1.2.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f1fdabc7756949593fe60f30ec81974b613357de856987752631dea1e3394c80" - -[[package]] -name = "base16ct" -version = "0.2.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4c7f02d4ea65f2c1853089ffd8d2787bdbc63de2f0d29dedbcf8ccdfa0ccd4cf" - -[[package]] -name = "base64ct" -version = "1.6.0" +version = "1.3.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8c3c1a368f70d6cf7302d78f8f7093da241fb8e8807c05cc9e51a125895a6d5b" +checksum = "0c4b4d0bd25bd0b74681c0ad21497610ce1b7c91b1022cd21c80c6fbdd9476b0" [[package]] name = "bincode" @@ -50,18 +32,6 @@ dependencies = [ "serde", ] -[[package]] -name = "bitvec" -version = "1.0.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1bc2832c24239b0141d5674bb9174f9d68a8b5b3f2753311927c172ca46f7e9c" -dependencies = [ - "funty", - "radium", - "tap", - "wyz", -] - [[package]] name = "block-buffer" version = "0.10.4" @@ -71,24 +41,12 @@ dependencies = [ "generic-array", ] -[[package]] -name = "byte-slice-cast" -version = "1.2.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c3ac9f8b63eca6fd385229b3675f6cc0dc5c8a5c8a54a59d4f52ffd670d87b0c" - [[package]] name = "cfg-if" version = "1.0.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "baf1de4339761588bc0619e3cbc0120ee582ebb74b53b4efbf79117bd2da40fd" -[[package]] -name = "const-oid" -version = "0.9.6" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c2459377285ad874054d797f3ccebf984978aa39129f6eafde5cdc8315b612f8" - [[package]] name = "cpufeatures" version = "0.2.12" @@ -98,18 +56,6 @@ dependencies = [ "libc", ] -[[package]] -name = "crypto-bigint" -version = "0.5.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0dc92fb57ca44df6db8059111ab3af99a63d5d0f8375d9972e319a379c6bab76" -dependencies = [ - "generic-array", - "rand_core", - "subtle", - "zeroize", -] - [[package]] name = "crypto-common" version = "0.1.6" @@ -120,27 +66,6 @@ dependencies = [ "typenum", ] -[[package]] -name = "der" -version = "0.7.9" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f55bf8e7b65898637379c1b74eb1551107c8294ed26d855ceb9fd1a09cfc9bc0" -dependencies = [ - "const-oid", - "zeroize", -] - -[[package]] -name = "derive_more" -version = "0.99.17" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4fb810d30a7c1953f91334de7244731fc3f3c10d7fe163338a35b9f640960321" -dependencies = [ - "proc-macro2", - "quote", - "syn 1.0.109", -] - [[package]] name = "digest" version = "0.10.7" @@ -148,73 +73,14 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "9ed9a281f7bc9b7576e61468ba615a66a5c8cfdff42420a70aa82701a3b1e292" dependencies = [ "block-buffer", - "const-oid", "crypto-common", - "subtle", -] - -[[package]] -name = "ecdsa" -version = "0.16.9" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ee27f32b5c5292967d2d4a9d7f1e0b0aed2c15daded5a60300e4abb9d8020bca" -dependencies = [ - "der", - "digest", - "elliptic-curve", - "rfc6979", - "signature", - "spki", ] [[package]] name = "either" -version = "1.11.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a47c1c47d2f5964e29c61246e81db715514cd532db6b5116a25ea3c03d6780a2" - -[[package]] -name = "elliptic-curve" -version = "0.13.8" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b5e6043086bf7973472e0c7dff2142ea0b680d30e18d9cc40f267efbf222bd47" -dependencies = [ - "base16ct", - "crypto-bigint", - "digest", - "ff", - "generic-array", - "group", - "pkcs8", - "rand_core", - "sec1", - "subtle", - "tap", - "zeroize", -] - -[[package]] -name = "equivalent" -version = "1.0.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5443807d6dff69373d433ab9ef5378ad8df50ca6298caf15de6e52e24aaf54d5" - -[[package]] -name = "ff" -version = "0.13.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ded41244b729663b1e574f1b4fb731469f69f79c17667b5d776b16cda0479449" -dependencies = [ - "bitvec", - "rand_core", - "subtle", -] - -[[package]] -name = "funty" -version = "2.0.0" +version = "1.12.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e6d5a32815ae3f33302d95fdcb2ce17862f8c65363dcfd29360480ba1001fc9c" +checksum = "3dca9240753cf90908d7e4aac30f630662b02aebaa1b58a3cadabdb23385b58b" [[package]] name = "gcd" @@ -230,73 +96,25 @@ checksum = "85649ca51fd72272d7821adaf274ad91c288277713d9c18820d8499a7ff69e9a" dependencies = [ "typenum", "version_check", - "zeroize", ] [[package]] name = "getrandom" -version = "0.2.14" +version = "0.2.15" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "94b22e06ecb0110981051723910cbf0b5f5e09a2062dd7663334ee79a9d1286c" +checksum = "c4567c8db10ae91089c99af84c68c38da3ec2f087c3f82960bcdbf3656b6f4d7" dependencies = [ "cfg-if", "libc", "wasi", ] -[[package]] -name = "group" -version = "0.13.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f0f9ef7462f7c099f518d754361858f86d8a07af53ba9af0fe635bbccb151a63" -dependencies = [ - "ff", - "rand_core", - "subtle", -] - -[[package]] -name = "hashbrown" -version = "0.14.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e5274423e17b7c9fc20b6e7e208532f9b19825d82dfd615708b70edd83df41f1" - [[package]] name = "hex" version = "0.4.3" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "7f24254aa9a54b5c858eaee2f5bccdb46aaf0e486a595ed5fd8f86ba55232a70" -[[package]] -name = "hmac" -version = "0.12.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6c49c37c09c17a53d937dfbb742eb3a961d65a994e6bcdcf37e7399d0cc8ab5e" -dependencies = [ - "digest", -] - -[[package]] -name = "impl-trait-for-tuples" -version = "0.2.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "11d7a9f6330b71fea57921c9b61c47ee6e84f72d394754eff6163ae67e7395eb" -dependencies = [ - "proc-macro2", - "quote", - "syn 1.0.109", -] - -[[package]] -name = "indexmap" -version = "2.2.6" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "168fb715dda47215e360912c096649d23d58bf392ac62f73919e831745e40f26" -dependencies = [ - "equivalent", - "hashbrown", -] - [[package]] name = "itertools" version = "0.12.1" @@ -315,31 +133,17 @@ dependencies = [ "either", ] -[[package]] -name = "k256" -version = "0.13.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "956ff9b67e26e1a6a866cb758f12c6f8746208489e3e4a4b5580802f2f0a587b" -dependencies = [ - "cfg-if", - "ecdsa", - "elliptic-curve", - "once_cell", - "sha2", - "signature", -] - [[package]] name = "lazy_static" -version = "1.4.0" +version = "1.5.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e2abad23fbc42b3700f2f279844dc832adb2b2eb069b2df918f455c4e18cc646" +checksum = "bbd2bcb4c963f2ddae06a2efc7e9f3591312473c50c6685e1f298068316e66fe" [[package]] name = "libc" -version = "0.2.154" +version = "0.2.155" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ae743338b92ff9146ce83992f766a31066a91a8c84a45e0e9f21e7cf6de6d346" +checksum = "97b3888a4aecf77e811145cadf6eef5901f4782c53886191b2f693f24761847c" [[package]] name = "libm" @@ -347,26 +151,6 @@ version = "0.2.8" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "4ec2a862134d2a7d32d7983ddcdd1c4923530833c9f2ea1a44fc5fa473989058" -[[package]] -name = "memchr" -version = "2.7.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6c8640c5d730cb13ebd907d8d04b52f55ac9a2eec55b440c8892f40d56c76c1d" - -[[package]] -name = "num" -version = "0.4.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "35bd024e8b2ff75562e5f34e7f4905839deb4b22955ef5e73d2fea1b9813cb23" -dependencies = [ - "num-bigint", - "num-complex", - "num-integer", - "num-iter", - "num-rational", - "num-traits", -] - [[package]] name = "num-bigint" version = "0.4.5" @@ -377,15 +161,6 @@ dependencies = [ "num-traits", ] -[[package]] -name = "num-complex" -version = "0.4.6" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "73f88a1307638156682bada9d7604135552957b7818057dcef22705b4d509495" -dependencies = [ - "num-traits", -] - [[package]] name = "num-integer" version = "0.1.46" @@ -395,28 +170,6 @@ dependencies = [ "num-traits", ] -[[package]] -name = "num-iter" -version = "0.1.45" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1429034a0490724d0075ebb2bc9e875d6503c3cf69e235a8941aa757d83ef5bf" -dependencies = [ - "autocfg", - "num-integer", - "num-traits", -] - -[[package]] -name = "num-rational" -version = "0.4.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f83d14da390562dca69fc84082e73e548e1ad308d24accdedd2720017cb37824" -dependencies = [ - "num-bigint", - "num-integer", - "num-traits", -] - [[package]] name = "num-traits" version = "0.2.19" @@ -434,8 +187,9 @@ checksum = "3fdb12b2476b595f9358c5161aa467c2438859caa136dec86c26fdd2efe17b92" [[package]] name = "p3-baby-bear" -version = "0.1.0" -source = "git+https://github.com/Plonky3/Plonky3.git?rev=3b5265f9d5af36534a46caebf0617595cfb42c5a#3b5265f9d5af36534a46caebf0617595cfb42c5a" +version = "0.1.3-succinct" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "46965470aac1cddfe52f535424b59d52f2fffef0fdeb9dbed19da39b1d8f048a" dependencies = [ "num-bigint", "p3-field", @@ -448,8 +202,9 @@ dependencies = [ [[package]] name = "p3-dft" -version = "0.1.0" -source = "git+https://github.com/Plonky3/Plonky3.git?rev=3b5265f9d5af36534a46caebf0617595cfb42c5a#3b5265f9d5af36534a46caebf0617595cfb42c5a" +version = "0.1.3-succinct" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "510095701819d83c9509fe825bbf1ebfe50426ae75149df5fe1dcfd18261323a" dependencies = [ "p3-field", "p3-matrix", @@ -460,8 +215,9 @@ dependencies = [ [[package]] name = "p3-field" -version = "0.1.0" -source = "git+https://github.com/Plonky3/Plonky3.git?rev=3b5265f9d5af36534a46caebf0617595cfb42c5a#3b5265f9d5af36534a46caebf0617595cfb42c5a" +version = "0.1.3-succinct" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "61f1977a0a65789f719aa824119c332c4676b000bdbfe94d312fb6244a70d601" dependencies = [ "itertools 0.12.1", "num-bigint", @@ -473,8 +229,9 @@ dependencies = [ [[package]] name = "p3-matrix" -version = "0.1.0" -source = "git+https://github.com/Plonky3/Plonky3.git?rev=3b5265f9d5af36534a46caebf0617595cfb42c5a#3b5265f9d5af36534a46caebf0617595cfb42c5a" +version = "0.1.3-succinct" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d548ee0b834f8e2ebc5037073acd101a3b0ca41a2d1d28a15ba0ccd9059495b0" dependencies = [ "itertools 0.12.1", "p3-field", @@ -487,13 +244,15 @@ dependencies = [ [[package]] name = "p3-maybe-rayon" -version = "0.1.0" -source = "git+https://github.com/Plonky3/Plonky3.git?rev=3b5265f9d5af36534a46caebf0617595cfb42c5a#3b5265f9d5af36534a46caebf0617595cfb42c5a" +version = "0.1.3-succinct" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "55f5575d3d61bedb3e05681abb0f36b8bb339d65aa395d50756bfa64e9cd3f46" [[package]] name = "p3-mds" -version = "0.1.0" -source = "git+https://github.com/Plonky3/Plonky3.git?rev=3b5265f9d5af36534a46caebf0617595cfb42c5a#3b5265f9d5af36534a46caebf0617595cfb42c5a" +version = "0.1.3-succinct" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6a6e57ed310d59245f93e24ee805ea7aa16fc9c505551b76a15f5e50f29d177e" dependencies = [ "itertools 0.12.1", "p3-dft", @@ -506,8 +265,9 @@ dependencies = [ [[package]] name = "p3-poseidon2" -version = "0.1.0" -source = "git+https://github.com/Plonky3/Plonky3.git?rev=3b5265f9d5af36534a46caebf0617595cfb42c5a#3b5265f9d5af36534a46caebf0617595cfb42c5a" +version = "0.1.3-succinct" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "adaba6f14c197203530e233badce0ca1126ba3bf3c9ff766505b497bdad0bee1" dependencies = [ "gcd", "p3-field", @@ -518,8 +278,9 @@ dependencies = [ [[package]] name = "p3-symmetric" -version = "0.1.0" -source = "git+https://github.com/Plonky3/Plonky3.git?rev=3b5265f9d5af36534a46caebf0617595cfb42c5a#3b5265f9d5af36534a46caebf0617595cfb42c5a" +version = "0.1.3-succinct" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "57ecc4282566eb14f48be7707f6745c4dff6be664984d59ec0fb1849cd82b5c2" dependencies = [ "itertools 0.12.1", "p3-field", @@ -528,34 +289,11 @@ dependencies = [ [[package]] name = "p3-util" -version = "0.1.0" -source = "git+https://github.com/Plonky3/Plonky3.git?rev=3b5265f9d5af36534a46caebf0617595cfb42c5a#3b5265f9d5af36534a46caebf0617595cfb42c5a" -dependencies = [ - "serde", -] - -[[package]] -name = "parity-scale-codec" -version = "3.6.9" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "881331e34fa842a2fb61cc2db9643a8fedc615e47cfcc52597d1af0db9a7e8fe" -dependencies = [ - "arrayvec", - "byte-slice-cast", - "impl-trait-for-tuples", - "parity-scale-codec-derive", -] - -[[package]] -name = "parity-scale-codec-derive" -version = "3.6.9" +version = "0.1.3-succinct" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "be30eaf4b0a9fba5336683b38de57bb86d179a35862ba6bfcf57625d006bde5b" +checksum = "79f3fef0e00d9d7246385e758c4cd39b4efcbbcea31752471491ab502631385e" dependencies = [ - "proc-macro-crate 2.0.2", - "proc-macro2", - "quote", - "syn 1.0.109", + "serde", ] [[package]] @@ -564,47 +302,17 @@ version = "0.2.14" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "bda66fc9667c18cb2758a2ac84d1167245054bcf85d5d1aaa6923f45801bdd02" -[[package]] -name = "pkcs8" -version = "0.10.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f950b2377845cebe5cf8b5165cb3cc1a5e0fa5cfa3e1f7f55707d8fd82e0a7b7" -dependencies = [ - "der", - "spki", -] - [[package]] name = "ppv-lite86" version = "0.2.17" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "5b40af805b3121feab8a3c29f04d8ad262fa8e0561883e7653e024ae4479e6de" -[[package]] -name = "proc-macro-crate" -version = "1.3.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7f4c021e1093a56626774e81216a4ce732a735e5bad4868a03f3ed65ca0c3919" -dependencies = [ - "once_cell", - "toml_edit 0.19.15", -] - -[[package]] -name = "proc-macro-crate" -version = "2.0.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b00f26d3400549137f92511a46ac1cd8ce37cb5598a96d382381458b992a5d24" -dependencies = [ - "toml_datetime", - "toml_edit 0.20.2", -] - [[package]] name = "proc-macro2" -version = "1.0.81" +version = "1.0.85" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3d1597b0c024618f09a9c3b8655b7e430397a36d23fdafec26d6965e9eec3eba" +checksum = "22244ce15aa966053a896d1accb3a6e68469b97c7f33f284b99f0d576879fc23" dependencies = [ "unicode-ident", ] @@ -618,12 +326,6 @@ dependencies = [ "proc-macro2", ] -[[package]] -name = "radium" -version = "0.7.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "dc33ff2d4973d518d823d61aa239014831e521c75da58e3df4840d3f47749d09" - [[package]] name = "rand" version = "0.8.5" @@ -654,72 +356,24 @@ dependencies = [ "getrandom", ] -[[package]] -name = "rfc6979" -version = "0.4.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f8dd2a808d456c4a54e300a23e9f5a67e122c3024119acbfd73e3bf664491cb2" -dependencies = [ - "hmac", - "subtle", -] - -[[package]] -name = "scale-info" -version = "2.11.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7c453e59a955f81fb62ee5d596b450383d699f152d350e9d23a0db2adb78e4c0" -dependencies = [ - "cfg-if", - "derive_more", - "parity-scale-codec", - "scale-info-derive", -] - -[[package]] -name = "scale-info-derive" -version = "2.11.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "18cf6c6447f813ef19eb450e985bcce6705f9ce7660db221b59093d15c79c4b7" -dependencies = [ - "proc-macro-crate 1.3.1", - "proc-macro2", - "quote", - "syn 1.0.109", -] - -[[package]] -name = "sec1" -version = "0.7.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d3e97a565f76233a6003f9f5c54be1d9c5bdfa3eccfb189469f11ec4901c47dc" -dependencies = [ - "base16ct", - "der", - "generic-array", - "pkcs8", - "subtle", - "zeroize", -] - [[package]] name = "serde" -version = "1.0.202" +version = "1.0.204" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "226b61a0d411b2ba5ff6d7f73a476ac4f8bb900373459cd00fab8512828ba395" +checksum = "bc76f558e0cbb2a839d37354c575f1dc3fdc6546b5be373ba43d95f231bf7c12" dependencies = [ "serde_derive", ] [[package]] name = "serde_derive" -version = "1.0.202" +version = "1.0.204" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6048858004bcff69094cd972ed40a32500f153bd3be9f716b2eed2e8217c4838" +checksum = "e0cd7e117be63d3c3678776753929474f3b04a43a080c744d6b0ae2a8c28e222" dependencies = [ "proc-macro2", "quote", - "syn 2.0.60", + "syn", ] [[package]] @@ -733,44 +387,18 @@ dependencies = [ ] [[package]] -name = "signature" -version = "2.2.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "77549399552de45a898a580c1b41d445bf730df867cc44e6c0233bbc4b8329de" -dependencies = [ - "digest", - "rand_core", -] - -[[package]] -name = "snowbridge-amcl" -version = "1.0.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "460a9ed63cdf03c1b9847e8a12a5f5ba19c4efd5869e4a737e05be25d7c427e5" -dependencies = [ - "parity-scale-codec", - "scale-info", -] - -[[package]] -name = "sp1-precompiles" -version = "0.1.0" +name = "sp1-lib" +version = "1.0.0-rc.1" dependencies = [ "anyhow", "bincode", "cfg-if", - "getrandom", - "hex", - "k256", - "num", - "rand", "serde", - "snowbridge-amcl", ] [[package]] name = "sp1-primitives" -version = "0.1.0" +version = "1.0.0-rc.1" dependencies = [ "itertools 0.13.0", "lazy_static", @@ -782,12 +410,11 @@ dependencies = [ [[package]] name = "sp1-zkvm" -version = "0.1.0" +version = "1.0.0-rc.1" dependencies = [ "bincode", "cfg-if", "getrandom", - "k256", "lazy_static", "libm", "once_cell", @@ -796,82 +423,21 @@ dependencies = [ "rand", "serde", "sha2", - "sp1-precompiles", + "sp1-lib", "sp1-primitives", ] -[[package]] -name = "spki" -version = "0.7.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d91ed6c858b01f942cd56b37a94b3e0a1798290327d1236e4d9cf4eaca44d29d" -dependencies = [ - "base64ct", - "der", -] - -[[package]] -name = "subtle" -version = "2.5.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "81cdd64d312baedb58e21336b31bc043b77e01cc99033ce76ef539f78e965ebc" - [[package]] name = "syn" -version = "1.0.109" +version = "2.0.66" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "72b64191b275b66ffe2469e8af2c1cfe3bafa67b529ead792a6d0160888b4237" +checksum = "c42f3f41a2de00b01c0aaad383c5a45241efc8b2d1eda5661812fda5f3cdcff5" dependencies = [ "proc-macro2", "quote", "unicode-ident", ] -[[package]] -name = "syn" -version = "2.0.60" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "909518bc7b1c9b779f1bbf07f2929d35af9f0f37e47c6e9ef7f9dddc1e1821f3" -dependencies = [ - "proc-macro2", - "quote", - "unicode-ident", -] - -[[package]] -name = "tap" -version = "1.0.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "55937e1799185b12863d447f42597ed69d9928686b8d88a1df17376a097d8369" - -[[package]] -name = "toml_datetime" -version = "0.6.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7cda73e2f1397b1262d6dfdcef8aafae14d1de7748d66822d3bfeeb6d03e5e4b" - -[[package]] -name = "toml_edit" -version = "0.19.15" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1b5bb770da30e5cbfde35a2d7b9b8a2c4b8ef89548a7a6aeab5c9a576e3e7421" -dependencies = [ - "indexmap", - "toml_datetime", - "winnow", -] - -[[package]] -name = "toml_edit" -version = "0.20.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "396e4d48bbb2b7554c944bde63101b5ae446cff6ec4a24227428f15eb72ef338" -dependencies = [ - "indexmap", - "toml_datetime", - "winnow", -] - [[package]] name = "tracing" version = "0.1.40" @@ -891,7 +457,7 @@ checksum = "34704c8d6ebcbc939824180af020566b01a7c01f80641264eba0999f6c2b6be7" dependencies = [ "proc-macro2", "quote", - "syn 2.0.60", + "syn", ] [[package]] @@ -926,27 +492,3 @@ name = "wasi" version = "0.11.0+wasi-snapshot-preview1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "9c8d87e72b64a3b4db28d11ce29237c246188f4f51057d65a7eab63b7987e423" - -[[package]] -name = "winnow" -version = "0.5.40" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f593a95398737aeed53e489c785df13f3618e41dbcd6718c6addbf1395aa6876" -dependencies = [ - "memchr", -] - -[[package]] -name = "wyz" -version = "0.5.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "05f360fc0b24296329c78fda852a1e9ae82de9cf7b27dae4b7f62f118f77b9ed" -dependencies = [ - "tap", -] - -[[package]] -name = "zeroize" -version = "1.7.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "525b4ec142c6b68a2d10f01f7bbf6755599ca3f81ea53b8431b7dd348f5fdb2d" diff --git a/examples/aggregation/program/Cargo.toml b/examples/aggregation/program/Cargo.toml index ee70949a70..8b9ae99e28 100644 --- a/examples/aggregation/program/Cargo.toml +++ b/examples/aggregation/program/Cargo.toml @@ -1,8 +1,9 @@ [workspace] [package] -version = "0.1.0" name = "aggregation-program" +version = "1.0.0-rc.1" edition = "2021" +publish = false [dependencies] hex = "0.4.3" diff --git a/examples/aggregation/program/elf/riscv32im-succinct-zkvm-elf b/examples/aggregation/program/elf/riscv32im-succinct-zkvm-elf index d256639d5f..5ad0fa1fe7 100755 Binary files a/examples/aggregation/program/elf/riscv32im-succinct-zkvm-elf and b/examples/aggregation/program/elf/riscv32im-succinct-zkvm-elf differ diff --git a/examples/aggregation/program/src/main.rs b/examples/aggregation/program/src/main.rs index c09b97b470..0d31146023 100644 --- a/examples/aggregation/program/src/main.rs +++ b/examples/aggregation/program/src/main.rs @@ -56,7 +56,7 @@ pub fn main() { let vkey = &vkeys[i]; let public_values = &public_values[i]; let public_values_digest = Sha256::digest(public_values); - sp1_zkvm::precompiles::verify::verify_sp1_proof(vkey, &public_values_digest.into()); + sp1_zkvm::lib::verify::verify_sp1_proof(vkey, &public_values_digest.into()); } // TODO: Do something interesting with the proofs here. diff --git a/examples/aggregation/script/Cargo.toml b/examples/aggregation/script/Cargo.toml index b8c50fea51..4df959459c 100644 --- a/examples/aggregation/script/Cargo.toml +++ b/examples/aggregation/script/Cargo.toml @@ -1,12 +1,13 @@ [package] -version = "0.1.0" name = "aggregation-script" -edition = "2021" +version = { workspace = true } +edition = { workspace = true } +publish = false [dependencies] hex = "0.4.3" -sp1-sdk = { path = "../../../sdk" } +sp1-sdk = { workspace = true } tracing = "0.1.40" [build-dependencies] -sp1-helper = { path = "../../../helper" } +sp1-helper = { workspace = true } diff --git a/examples/aggregation/script/src/main.rs b/examples/aggregation/script/src/main.rs index b22a10d1a3..37b4e8b570 100644 --- a/examples/aggregation/script/src/main.rs +++ b/examples/aggregation/script/src/main.rs @@ -1,6 +1,8 @@ //! A simple example showing how to aggregate proofs of multiple programs with SP1. -use sp1_sdk::{HashableKey, ProverClient, SP1CompressedProof, SP1Stdin, SP1VerifyingKey}; +use sp1_sdk::{ + HashableKey, ProverClient, SP1Proof, SP1ProofWithPublicValues, SP1Stdin, SP1VerifyingKey, +}; /// A program that aggregates the proofs of the simple program. const AGGREGATION_ELF: &[u8] = include_bytes!("../../program/elf/riscv32im-succinct-zkvm-elf"); @@ -13,7 +15,7 @@ const FIBONACCI_ELF: &[u8] = /// /// Consists of a proof and a verification key. struct AggregationInput { - pub proof: SP1CompressedProof, + pub proof: SP1ProofWithPublicValues, pub vk: SP1VerifyingKey, } @@ -33,21 +35,27 @@ fn main() { let mut stdin = SP1Stdin::new(); stdin.write(&10); client - .prove_compressed(&fibonacci_pk, stdin) + .prove(&fibonacci_pk, stdin) + .compressed() + .run() .expect("proving failed") }); let proof_2 = tracing::info_span!("generate fibonacci proof n=20").in_scope(|| { let mut stdin = SP1Stdin::new(); stdin.write(&20); client - .prove_compressed(&fibonacci_pk, stdin) + .prove(&fibonacci_pk, stdin) + .compressed() + .run() .expect("proving failed") }); let proof_3 = tracing::info_span!("generate fibonacci proof n=30").in_scope(|| { let mut stdin = SP1Stdin::new(); stdin.write(&30); client - .prove_compressed(&fibonacci_pk, stdin) + .prove(&fibonacci_pk, stdin) + .compressed() + .run() .expect("proving failed") }); @@ -89,12 +97,17 @@ fn main() { // Note: this data will not actually be read by the aggregation program, instead it will be // witnessed by the prover during the recursive aggregation process inside SP1 itself. for input in inputs { - stdin.write_proof(input.proof.proof, input.vk.vk); + let SP1Proof::Compressed(proof) = input.proof.proof else { + panic!() + }; + stdin.write_proof(proof, input.vk.vk); } // Generate the plonk bn254 proof. client - .prove_plonk(&aggregation_pk, stdin) + .prove(&aggregation_pk, stdin) + .plonk() + .run() .expect("proving failed"); }); } diff --git a/examples/chess/program/Cargo.lock b/examples/chess/program/Cargo.lock index 484054dd96..041ffce981 100644 --- a/examples/chess/program/Cargo.lock +++ b/examples/chess/program/Cargo.lock @@ -29,18 +29,6 @@ version = "0.5.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "23b62fc65de8e4e7f52534fb52b0f3ed04746ae267519eef2a83941e8085068b" -[[package]] -name = "arrayvec" -version = "0.7.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "96d30a06541fbafbc7f82ed10c06164cfbd2c401138f6addd8404629c4b16711" - -[[package]] -name = "autocfg" -version = "1.2.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f1fdabc7756949593fe60f30ec81974b613357de856987752631dea1e3394c80" - [[package]] name = "backtrace" version = "0.3.71" @@ -56,18 +44,6 @@ dependencies = [ "rustc-demangle", ] -[[package]] -name = "base16ct" -version = "0.2.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4c7f02d4ea65f2c1853089ffd8d2787bdbc63de2f0d29dedbcf8ccdfa0ccd4cf" - -[[package]] -name = "base64ct" -version = "1.6.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8c3c1a368f70d6cf7302d78f8f7093da241fb8e8807c05cc9e51a125895a6d5b" - [[package]] name = "bincode" version = "1.3.3" @@ -77,18 +53,6 @@ dependencies = [ "serde", ] -[[package]] -name = "bitvec" -version = "1.0.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1bc2832c24239b0141d5674bb9174f9d68a8b5b3f2753311927c172ca46f7e9c" -dependencies = [ - "funty", - "radium", - "tap", - "wyz", -] - [[package]] name = "block-buffer" version = "0.10.4" @@ -98,12 +62,6 @@ dependencies = [ "generic-array", ] -[[package]] -name = "byte-slice-cast" -version = "1.2.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c3ac9f8b63eca6fd385229b3675f6cc0dc5c8a5c8a54a59d4f52ffd670d87b0c" - [[package]] name = "cc" version = "1.0.95" @@ -122,7 +80,7 @@ version = "3.2.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "2ed299b171ec34f372945ad6726f7bc1d2afd5f59fb8380f64f48e2bab2f0ec8" dependencies = [ - "arrayvec 0.5.2", + "arrayvec", "failure", "nodrop", "rand 0.7.3", @@ -130,18 +88,12 @@ dependencies = [ [[package]] name = "chess-program" -version = "0.1.0" +version = "1.0.0-rc.1" dependencies = [ "chess", "sp1-zkvm", ] -[[package]] -name = "const-oid" -version = "0.9.6" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c2459377285ad874054d797f3ccebf984978aa39129f6eafde5cdc8315b612f8" - [[package]] name = "cpufeatures" version = "0.2.12" @@ -151,18 +103,6 @@ dependencies = [ "libc", ] -[[package]] -name = "crypto-bigint" -version = "0.5.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0dc92fb57ca44df6db8059111ab3af99a63d5d0f8375d9972e319a379c6bab76" -dependencies = [ - "generic-array", - "rand_core 0.6.4", - "subtle", - "zeroize", -] - [[package]] name = "crypto-common" version = "0.1.6" @@ -173,27 +113,6 @@ dependencies = [ "typenum", ] -[[package]] -name = "der" -version = "0.7.9" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f55bf8e7b65898637379c1b74eb1551107c8294ed26d855ceb9fd1a09cfc9bc0" -dependencies = [ - "const-oid", - "zeroize", -] - -[[package]] -name = "derive_more" -version = "0.99.17" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4fb810d30a7c1953f91334de7244731fc3f3c10d7fe163338a35b9f640960321" -dependencies = [ - "proc-macro2", - "quote", - "syn 1.0.109", -] - [[package]] name = "digest" version = "0.10.7" @@ -201,51 +120,9 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "9ed9a281f7bc9b7576e61468ba615a66a5c8cfdff42420a70aa82701a3b1e292" dependencies = [ "block-buffer", - "const-oid", "crypto-common", - "subtle", -] - -[[package]] -name = "ecdsa" -version = "0.16.9" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ee27f32b5c5292967d2d4a9d7f1e0b0aed2c15daded5a60300e4abb9d8020bca" -dependencies = [ - "der", - "digest", - "elliptic-curve", - "rfc6979", - "signature", - "spki", -] - -[[package]] -name = "elliptic-curve" -version = "0.13.8" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b5e6043086bf7973472e0c7dff2142ea0b680d30e18d9cc40f267efbf222bd47" -dependencies = [ - "base16ct", - "crypto-bigint", - "digest", - "ff", - "generic-array", - "group", - "pkcs8", - "rand_core 0.6.4", - "sec1", - "subtle", - "tap", - "zeroize", ] -[[package]] -name = "equivalent" -version = "1.0.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5443807d6dff69373d433ab9ef5378ad8df50ca6298caf15de6e52e24aaf54d5" - [[package]] name = "failure" version = "0.1.8" @@ -268,23 +145,6 @@ dependencies = [ "synstructure", ] -[[package]] -name = "ff" -version = "0.13.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ded41244b729663b1e574f1b4fb731469f69f79c17667b5d776b16cda0479449" -dependencies = [ - "bitvec", - "rand_core 0.6.4", - "subtle", -] - -[[package]] -name = "funty" -version = "2.0.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e6d5a32815ae3f33302d95fdcb2ce17862f8c65363dcfd29360480ba1001fc9c" - [[package]] name = "generic-array" version = "0.14.7" @@ -293,7 +153,6 @@ checksum = "85649ca51fd72272d7821adaf274ad91c288277713d9c18820d8499a7ff69e9a" dependencies = [ "typenum", "version_check", - "zeroize", ] [[package]] @@ -313,78 +172,11 @@ version = "0.28.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "4271d37baee1b8c7e4b708028c57d816cf9d2434acb33a549475f78c181f6253" -[[package]] -name = "group" -version = "0.13.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f0f9ef7462f7c099f518d754361858f86d8a07af53ba9af0fe635bbccb151a63" -dependencies = [ - "ff", - "rand_core 0.6.4", - "subtle", -] - -[[package]] -name = "hashbrown" -version = "0.14.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "290f1a1d9242c78d09ce40a5e87e7554ee637af1351968159f4952f028f75604" - -[[package]] -name = "hex" -version = "0.4.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7f24254aa9a54b5c858eaee2f5bccdb46aaf0e486a595ed5fd8f86ba55232a70" - -[[package]] -name = "hmac" -version = "0.12.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6c49c37c09c17a53d937dfbb742eb3a961d65a994e6bcdcf37e7399d0cc8ab5e" -dependencies = [ - "digest", -] - -[[package]] -name = "impl-trait-for-tuples" -version = "0.2.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "11d7a9f6330b71fea57921c9b61c47ee6e84f72d394754eff6163ae67e7395eb" -dependencies = [ - "proc-macro2", - "quote", - "syn 1.0.109", -] - -[[package]] -name = "indexmap" -version = "2.2.6" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "168fb715dda47215e360912c096649d23d58bf392ac62f73919e831745e40f26" -dependencies = [ - "equivalent", - "hashbrown", -] - -[[package]] -name = "k256" -version = "0.13.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "956ff9b67e26e1a6a866cb758f12c6f8746208489e3e4a4b5580802f2f0a587b" -dependencies = [ - "cfg-if", - "ecdsa", - "elliptic-curve", - "once_cell", - "sha2", - "signature", -] - [[package]] name = "lazy_static" -version = "1.4.0" +version = "1.5.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e2abad23fbc42b3700f2f279844dc832adb2b2eb069b2df918f455c4e18cc646" +checksum = "bbd2bcb4c963f2ddae06a2efc7e9f3591312473c50c6685e1f298068316e66fe" [[package]] name = "libc" @@ -419,79 +211,6 @@ version = "0.1.14" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "72ef4a56884ca558e5ddb05a1d1e7e1bfd9a68d9ed024c21704cc98872dae1bb" -[[package]] -name = "num" -version = "0.4.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "35bd024e8b2ff75562e5f34e7f4905839deb4b22955ef5e73d2fea1b9813cb23" -dependencies = [ - "num-bigint", - "num-complex", - "num-integer", - "num-iter", - "num-rational", - "num-traits", -] - -[[package]] -name = "num-bigint" -version = "0.4.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c165a9ab64cf766f73521c0dd2cfdff64f488b8f0b3e621face3462d3db536d7" -dependencies = [ - "num-integer", - "num-traits", -] - -[[package]] -name = "num-complex" -version = "0.4.6" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "73f88a1307638156682bada9d7604135552957b7818057dcef22705b4d509495" -dependencies = [ - "num-traits", -] - -[[package]] -name = "num-integer" -version = "0.1.46" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7969661fd2958a5cb096e56c8e1ad0444ac2bbcd0061bd28660485a44879858f" -dependencies = [ - "num-traits", -] - -[[package]] -name = "num-iter" -version = "0.1.45" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1429034a0490724d0075ebb2bc9e875d6503c3cf69e235a8941aa757d83ef5bf" -dependencies = [ - "autocfg", - "num-integer", - "num-traits", -] - -[[package]] -name = "num-rational" -version = "0.4.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f83d14da390562dca69fc84082e73e548e1ad308d24accdedd2720017cb37824" -dependencies = [ - "num-bigint", - "num-integer", - "num-traits", -] - -[[package]] -name = "num-traits" -version = "0.2.19" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "071dfc062690e90b734c0b2273ce72ad0ffa95f0c74596bc250dcfd960262841" -dependencies = [ - "autocfg", -] - [[package]] name = "object" version = "0.32.2" @@ -507,66 +226,12 @@ version = "1.19.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "3fdb12b2476b595f9358c5161aa467c2438859caa136dec86c26fdd2efe17b92" -[[package]] -name = "parity-scale-codec" -version = "3.6.9" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "881331e34fa842a2fb61cc2db9643a8fedc615e47cfcc52597d1af0db9a7e8fe" -dependencies = [ - "arrayvec 0.7.4", - "byte-slice-cast", - "impl-trait-for-tuples", - "parity-scale-codec-derive", -] - -[[package]] -name = "parity-scale-codec-derive" -version = "3.6.9" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "be30eaf4b0a9fba5336683b38de57bb86d179a35862ba6bfcf57625d006bde5b" -dependencies = [ - "proc-macro-crate 2.0.2", - "proc-macro2", - "quote", - "syn 1.0.109", -] - -[[package]] -name = "pkcs8" -version = "0.10.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f950b2377845cebe5cf8b5165cb3cc1a5e0fa5cfa3e1f7f55707d8fd82e0a7b7" -dependencies = [ - "der", - "spki", -] - [[package]] name = "ppv-lite86" version = "0.2.17" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "5b40af805b3121feab8a3c29f04d8ad262fa8e0561883e7653e024ae4479e6de" -[[package]] -name = "proc-macro-crate" -version = "1.3.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7f4c021e1093a56626774e81216a4ce732a735e5bad4868a03f3ed65ca0c3919" -dependencies = [ - "once_cell", - "toml_edit 0.19.15", -] - -[[package]] -name = "proc-macro-crate" -version = "2.0.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b00f26d3400549137f92511a46ac1cd8ce37cb5598a96d382381458b992a5d24" -dependencies = [ - "toml_datetime", - "toml_edit 0.20.2", -] - [[package]] name = "proc-macro2" version = "1.0.81" @@ -585,12 +250,6 @@ dependencies = [ "proc-macro2", ] -[[package]] -name = "radium" -version = "0.7.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "dc33ff2d4973d518d823d61aa239014831e521c75da58e3df4840d3f47749d09" - [[package]] name = "rand" version = "0.7.3" @@ -667,74 +326,26 @@ dependencies = [ "rand_core 0.5.1", ] -[[package]] -name = "rfc6979" -version = "0.4.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f8dd2a808d456c4a54e300a23e9f5a67e122c3024119acbfd73e3bf664491cb2" -dependencies = [ - "hmac", - "subtle", -] - [[package]] name = "rustc-demangle" version = "0.1.23" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "d626bb9dae77e28219937af045c257c28bfd3f69333c512553507f5f9798cb76" -[[package]] -name = "scale-info" -version = "2.11.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7c453e59a955f81fb62ee5d596b450383d699f152d350e9d23a0db2adb78e4c0" -dependencies = [ - "cfg-if", - "derive_more", - "parity-scale-codec", - "scale-info-derive", -] - -[[package]] -name = "scale-info-derive" -version = "2.11.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "18cf6c6447f813ef19eb450e985bcce6705f9ce7660db221b59093d15c79c4b7" -dependencies = [ - "proc-macro-crate 1.3.1", - "proc-macro2", - "quote", - "syn 1.0.109", -] - -[[package]] -name = "sec1" -version = "0.7.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d3e97a565f76233a6003f9f5c54be1d9c5bdfa3eccfb189469f11ec4901c47dc" -dependencies = [ - "base16ct", - "der", - "generic-array", - "pkcs8", - "subtle", - "zeroize", -] - [[package]] name = "serde" -version = "1.0.201" +version = "1.0.204" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "780f1cebed1629e4753a1a38a3c72d30b97ec044f0aef68cb26650a3c5cf363c" +checksum = "bc76f558e0cbb2a839d37354c575f1dc3fdc6546b5be373ba43d95f231bf7c12" dependencies = [ "serde_derive", ] [[package]] name = "serde_derive" -version = "1.0.201" +version = "1.0.204" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c5e405930b9796f1c00bee880d03fc7e0bb4b9a11afc776885ffe84320da2865" +checksum = "e0cd7e117be63d3c3678776753929474f3b04a43a080c744d6b0ae2a8c28e222" dependencies = [ "proc-macro2", "quote", @@ -753,74 +364,31 @@ dependencies = [ ] [[package]] -name = "signature" -version = "2.2.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "77549399552de45a898a580c1b41d445bf730df867cc44e6c0233bbc4b8329de" -dependencies = [ - "digest", - "rand_core 0.6.4", -] - -[[package]] -name = "snowbridge-amcl" -version = "1.0.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "460a9ed63cdf03c1b9847e8a12a5f5ba19c4efd5869e4a737e05be25d7c427e5" -dependencies = [ - "parity-scale-codec", - "scale-info", -] - -[[package]] -name = "sp1-precompiles" -version = "0.1.0" +name = "sp1-lib" +version = "1.0.0-rc.1" dependencies = [ "anyhow", "bincode", "cfg-if", - "getrandom", - "hex", - "k256", - "num", - "rand 0.8.5", "serde", - "snowbridge-amcl", ] [[package]] name = "sp1-zkvm" -version = "0.1.0" +version = "1.0.0-rc.1" dependencies = [ "bincode", "cfg-if", "getrandom", - "k256", "lazy_static", "libm", "once_cell", "rand 0.8.5", "serde", "sha2", - "sp1-precompiles", + "sp1-lib", ] -[[package]] -name = "spki" -version = "0.7.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d91ed6c858b01f942cd56b37a94b3e0a1798290327d1236e4d9cf4eaca44d29d" -dependencies = [ - "base64ct", - "der", -] - -[[package]] -name = "subtle" -version = "2.5.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "81cdd64d312baedb58e21336b31bc043b77e01cc99033ce76ef539f78e965ebc" - [[package]] name = "syn" version = "1.0.109" @@ -855,40 +423,6 @@ dependencies = [ "unicode-xid", ] -[[package]] -name = "tap" -version = "1.0.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "55937e1799185b12863d447f42597ed69d9928686b8d88a1df17376a097d8369" - -[[package]] -name = "toml_datetime" -version = "0.6.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7cda73e2f1397b1262d6dfdcef8aafae14d1de7748d66822d3bfeeb6d03e5e4b" - -[[package]] -name = "toml_edit" -version = "0.19.15" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1b5bb770da30e5cbfde35a2d7b9b8a2c4b8ef89548a7a6aeab5c9a576e3e7421" -dependencies = [ - "indexmap", - "toml_datetime", - "winnow", -] - -[[package]] -name = "toml_edit" -version = "0.20.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "396e4d48bbb2b7554c944bde63101b5ae446cff6ec4a24227428f15eb72ef338" -dependencies = [ - "indexmap", - "toml_datetime", - "winnow", -] - [[package]] name = "typenum" version = "1.17.0" @@ -918,27 +452,3 @@ name = "wasi" version = "0.11.0+wasi-snapshot-preview1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "9c8d87e72b64a3b4db28d11ce29237c246188f4f51057d65a7eab63b7987e423" - -[[package]] -name = "winnow" -version = "0.5.40" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f593a95398737aeed53e489c785df13f3618e41dbcd6718c6addbf1395aa6876" -dependencies = [ - "memchr", -] - -[[package]] -name = "wyz" -version = "0.5.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "05f360fc0b24296329c78fda852a1e9ae82de9cf7b27dae4b7f62f118f77b9ed" -dependencies = [ - "tap", -] - -[[package]] -name = "zeroize" -version = "1.7.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "525b4ec142c6b68a2d10f01f7bbf6755599ca3f81ea53b8431b7dd348f5fdb2d" diff --git a/examples/chess/program/Cargo.toml b/examples/chess/program/Cargo.toml index fe588f0185..48126fcda7 100644 --- a/examples/chess/program/Cargo.toml +++ b/examples/chess/program/Cargo.toml @@ -1,9 +1,10 @@ [workspace] [package] -version = "0.1.0" name = "chess-program" +version = "1.0.0-rc.1" edition = "2021" +publish = false [dependencies] -chess = "3.2.0" sp1-zkvm = { path = "../../../zkvm/entrypoint" } +chess = "3.2.0" diff --git a/examples/chess/program/elf/riscv32im-succinct-zkvm-elf b/examples/chess/program/elf/riscv32im-succinct-zkvm-elf index 6a9bf30352..63fcb4124d 100755 Binary files a/examples/chess/program/elf/riscv32im-succinct-zkvm-elf and b/examples/chess/program/elf/riscv32im-succinct-zkvm-elf differ diff --git a/examples/chess/script/Cargo.toml b/examples/chess/script/Cargo.toml index 55b05bcdcd..cfa637b66f 100644 --- a/examples/chess/script/Cargo.toml +++ b/examples/chess/script/Cargo.toml @@ -1,10 +1,11 @@ [package] -version = "0.1.0" name = "chess-script" -edition = "2021" +version = { workspace = true } +edition = { workspace = true } +publish = false [dependencies] -sp1-sdk = { path = "../../../sdk" } +sp1-sdk = { workspace = true } [build-dependencies] -sp1-helper = { path = "../../../helper" } +sp1-helper = { workspace = true } diff --git a/examples/chess/script/src/main.rs b/examples/chess/script/src/main.rs index de8f8f9dcc..74861cab54 100644 --- a/examples/chess/script/src/main.rs +++ b/examples/chess/script/src/main.rs @@ -1,4 +1,4 @@ -use sp1_sdk::{ProverClient, SP1Proof, SP1Stdin}; +use sp1_sdk::{ProverClient, SP1ProofWithPublicValues, SP1Stdin}; const ELF: &[u8] = include_bytes!("../../program/elf/riscv32im-succinct-zkvm-elf"); @@ -15,7 +15,7 @@ fn main() { let client = ProverClient::new(); let (pk, vk) = client.setup(ELF); - let mut proof = client.prove(&pk, stdin).unwrap(); + let mut proof = client.prove(&pk, stdin).run().unwrap(); // Read output. let is_valid_move = proof.public_values.read::(); @@ -28,7 +28,8 @@ fn main() { proof .save("proof-with-io.bin") .expect("saving proof failed"); - let deserialized_proof = SP1Proof::load("proof-with-io.bin").expect("loading proof failed"); + let deserialized_proof = + SP1ProofWithPublicValues::load("proof-with-io.bin").expect("loading proof failed"); // Verify the deserialized proof. client diff --git a/examples/cycle-tracking/program/Cargo.lock b/examples/cycle-tracking/program/Cargo.lock index 7c539c31b4..e9c96087c2 100644 --- a/examples/cycle-tracking/program/Cargo.lock +++ b/examples/cycle-tracking/program/Cargo.lock @@ -8,30 +8,6 @@ version = "1.0.83" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "25bdb32cbbdce2b519a9cd7df3a678443100e265d5e25ca763b7572a5104f5f3" -[[package]] -name = "arrayvec" -version = "0.7.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "96d30a06541fbafbc7f82ed10c06164cfbd2c401138f6addd8404629c4b16711" - -[[package]] -name = "autocfg" -version = "1.2.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f1fdabc7756949593fe60f30ec81974b613357de856987752631dea1e3394c80" - -[[package]] -name = "base16ct" -version = "0.2.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4c7f02d4ea65f2c1853089ffd8d2787bdbc63de2f0d29dedbcf8ccdfa0ccd4cf" - -[[package]] -name = "base64ct" -version = "1.6.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8c3c1a368f70d6cf7302d78f8f7093da241fb8e8807c05cc9e51a125895a6d5b" - [[package]] name = "bincode" version = "1.3.3" @@ -41,18 +17,6 @@ dependencies = [ "serde", ] -[[package]] -name = "bitvec" -version = "1.0.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1bc2832c24239b0141d5674bb9174f9d68a8b5b3f2753311927c172ca46f7e9c" -dependencies = [ - "funty", - "radium", - "tap", - "wyz", -] - [[package]] name = "block-buffer" version = "0.10.4" @@ -62,24 +26,12 @@ dependencies = [ "generic-array", ] -[[package]] -name = "byte-slice-cast" -version = "1.2.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c3ac9f8b63eca6fd385229b3675f6cc0dc5c8a5c8a54a59d4f52ffd670d87b0c" - [[package]] name = "cfg-if" version = "1.0.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "baf1de4339761588bc0619e3cbc0120ee582ebb74b53b4efbf79117bd2da40fd" -[[package]] -name = "const-oid" -version = "0.9.6" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c2459377285ad874054d797f3ccebf984978aa39129f6eafde5cdc8315b612f8" - [[package]] name = "cpufeatures" version = "0.2.12" @@ -89,18 +41,6 @@ dependencies = [ "libc", ] -[[package]] -name = "crypto-bigint" -version = "0.5.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0dc92fb57ca44df6db8059111ab3af99a63d5d0f8375d9972e319a379c6bab76" -dependencies = [ - "generic-array", - "rand_core", - "subtle", - "zeroize", -] - [[package]] name = "crypto-common" version = "0.1.6" @@ -113,33 +53,12 @@ dependencies = [ [[package]] name = "cycle-tracking-program" -version = "0.1.0" +version = "1.0.0-rc.1" dependencies = [ "sp1-derive", "sp1-zkvm", ] -[[package]] -name = "der" -version = "0.7.9" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f55bf8e7b65898637379c1b74eb1551107c8294ed26d855ceb9fd1a09cfc9bc0" -dependencies = [ - "const-oid", - "zeroize", -] - -[[package]] -name = "derive_more" -version = "0.99.17" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4fb810d30a7c1953f91334de7244731fc3f3c10d7fe163338a35b9f640960321" -dependencies = [ - "proc-macro2", - "quote", - "syn 1.0.109", -] - [[package]] name = "digest" version = "0.10.7" @@ -147,68 +66,9 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "9ed9a281f7bc9b7576e61468ba615a66a5c8cfdff42420a70aa82701a3b1e292" dependencies = [ "block-buffer", - "const-oid", "crypto-common", - "subtle", -] - -[[package]] -name = "ecdsa" -version = "0.16.9" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ee27f32b5c5292967d2d4a9d7f1e0b0aed2c15daded5a60300e4abb9d8020bca" -dependencies = [ - "der", - "digest", - "elliptic-curve", - "rfc6979", - "signature", - "spki", -] - -[[package]] -name = "elliptic-curve" -version = "0.13.8" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b5e6043086bf7973472e0c7dff2142ea0b680d30e18d9cc40f267efbf222bd47" -dependencies = [ - "base16ct", - "crypto-bigint", - "digest", - "ff", - "generic-array", - "group", - "pkcs8", - "rand_core", - "sec1", - "subtle", - "tap", - "zeroize", ] -[[package]] -name = "equivalent" -version = "1.0.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5443807d6dff69373d433ab9ef5378ad8df50ca6298caf15de6e52e24aaf54d5" - -[[package]] -name = "ff" -version = "0.13.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ded41244b729663b1e574f1b4fb731469f69f79c17667b5d776b16cda0479449" -dependencies = [ - "bitvec", - "rand_core", - "subtle", -] - -[[package]] -name = "funty" -version = "2.0.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e6d5a32815ae3f33302d95fdcb2ce17862f8c65363dcfd29360480ba1001fc9c" - [[package]] name = "generic-array" version = "0.14.7" @@ -217,7 +77,6 @@ checksum = "85649ca51fd72272d7821adaf274ad91c288277713d9c18820d8499a7ff69e9a" dependencies = [ "typenum", "version_check", - "zeroize", ] [[package]] @@ -231,78 +90,11 @@ dependencies = [ "wasi", ] -[[package]] -name = "group" -version = "0.13.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f0f9ef7462f7c099f518d754361858f86d8a07af53ba9af0fe635bbccb151a63" -dependencies = [ - "ff", - "rand_core", - "subtle", -] - -[[package]] -name = "hashbrown" -version = "0.14.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "290f1a1d9242c78d09ce40a5e87e7554ee637af1351968159f4952f028f75604" - -[[package]] -name = "hex" -version = "0.4.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7f24254aa9a54b5c858eaee2f5bccdb46aaf0e486a595ed5fd8f86ba55232a70" - -[[package]] -name = "hmac" -version = "0.12.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6c49c37c09c17a53d937dfbb742eb3a961d65a994e6bcdcf37e7399d0cc8ab5e" -dependencies = [ - "digest", -] - -[[package]] -name = "impl-trait-for-tuples" -version = "0.2.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "11d7a9f6330b71fea57921c9b61c47ee6e84f72d394754eff6163ae67e7395eb" -dependencies = [ - "proc-macro2", - "quote", - "syn 1.0.109", -] - -[[package]] -name = "indexmap" -version = "2.2.6" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "168fb715dda47215e360912c096649d23d58bf392ac62f73919e831745e40f26" -dependencies = [ - "equivalent", - "hashbrown", -] - -[[package]] -name = "k256" -version = "0.13.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "956ff9b67e26e1a6a866cb758f12c6f8746208489e3e4a4b5580802f2f0a587b" -dependencies = [ - "cfg-if", - "ecdsa", - "elliptic-curve", - "once_cell", - "sha2", - "signature", -] - [[package]] name = "lazy_static" -version = "1.4.0" +version = "1.5.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e2abad23fbc42b3700f2f279844dc832adb2b2eb069b2df918f455c4e18cc646" +checksum = "bbd2bcb4c963f2ddae06a2efc7e9f3591312473c50c6685e1f298068316e66fe" [[package]] name = "libc" @@ -316,151 +108,18 @@ version = "0.2.8" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "4ec2a862134d2a7d32d7983ddcdd1c4923530833c9f2ea1a44fc5fa473989058" -[[package]] -name = "memchr" -version = "2.7.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6c8640c5d730cb13ebd907d8d04b52f55ac9a2eec55b440c8892f40d56c76c1d" - -[[package]] -name = "num" -version = "0.4.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "35bd024e8b2ff75562e5f34e7f4905839deb4b22955ef5e73d2fea1b9813cb23" -dependencies = [ - "num-bigint", - "num-complex", - "num-integer", - "num-iter", - "num-rational", - "num-traits", -] - -[[package]] -name = "num-bigint" -version = "0.4.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c165a9ab64cf766f73521c0dd2cfdff64f488b8f0b3e621face3462d3db536d7" -dependencies = [ - "num-integer", - "num-traits", -] - -[[package]] -name = "num-complex" -version = "0.4.6" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "73f88a1307638156682bada9d7604135552957b7818057dcef22705b4d509495" -dependencies = [ - "num-traits", -] - -[[package]] -name = "num-integer" -version = "0.1.46" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7969661fd2958a5cb096e56c8e1ad0444ac2bbcd0061bd28660485a44879858f" -dependencies = [ - "num-traits", -] - -[[package]] -name = "num-iter" -version = "0.1.45" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1429034a0490724d0075ebb2bc9e875d6503c3cf69e235a8941aa757d83ef5bf" -dependencies = [ - "autocfg", - "num-integer", - "num-traits", -] - -[[package]] -name = "num-rational" -version = "0.4.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f83d14da390562dca69fc84082e73e548e1ad308d24accdedd2720017cb37824" -dependencies = [ - "num-bigint", - "num-integer", - "num-traits", -] - -[[package]] -name = "num-traits" -version = "0.2.19" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "071dfc062690e90b734c0b2273ce72ad0ffa95f0c74596bc250dcfd960262841" -dependencies = [ - "autocfg", -] - [[package]] name = "once_cell" version = "1.19.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "3fdb12b2476b595f9358c5161aa467c2438859caa136dec86c26fdd2efe17b92" -[[package]] -name = "parity-scale-codec" -version = "3.6.9" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "881331e34fa842a2fb61cc2db9643a8fedc615e47cfcc52597d1af0db9a7e8fe" -dependencies = [ - "arrayvec", - "byte-slice-cast", - "impl-trait-for-tuples", - "parity-scale-codec-derive", -] - -[[package]] -name = "parity-scale-codec-derive" -version = "3.6.9" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "be30eaf4b0a9fba5336683b38de57bb86d179a35862ba6bfcf57625d006bde5b" -dependencies = [ - "proc-macro-crate 2.0.2", - "proc-macro2", - "quote", - "syn 1.0.109", -] - -[[package]] -name = "pkcs8" -version = "0.10.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f950b2377845cebe5cf8b5165cb3cc1a5e0fa5cfa3e1f7f55707d8fd82e0a7b7" -dependencies = [ - "der", - "spki", -] - [[package]] name = "ppv-lite86" version = "0.2.17" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "5b40af805b3121feab8a3c29f04d8ad262fa8e0561883e7653e024ae4479e6de" -[[package]] -name = "proc-macro-crate" -version = "1.3.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7f4c021e1093a56626774e81216a4ce732a735e5bad4868a03f3ed65ca0c3919" -dependencies = [ - "once_cell", - "toml_edit 0.19.15", -] - -[[package]] -name = "proc-macro-crate" -version = "2.0.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b00f26d3400549137f92511a46ac1cd8ce37cb5598a96d382381458b992a5d24" -dependencies = [ - "toml_datetime", - "toml_edit 0.20.2", -] - [[package]] name = "proc-macro2" version = "1.0.81" @@ -479,12 +138,6 @@ dependencies = [ "proc-macro2", ] -[[package]] -name = "radium" -version = "0.7.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "dc33ff2d4973d518d823d61aa239014831e521c75da58e3df4840d3f47749d09" - [[package]] name = "rand" version = "0.8.5" @@ -515,68 +168,20 @@ dependencies = [ "getrandom", ] -[[package]] -name = "rfc6979" -version = "0.4.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f8dd2a808d456c4a54e300a23e9f5a67e122c3024119acbfd73e3bf664491cb2" -dependencies = [ - "hmac", - "subtle", -] - -[[package]] -name = "scale-info" -version = "2.11.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7c453e59a955f81fb62ee5d596b450383d699f152d350e9d23a0db2adb78e4c0" -dependencies = [ - "cfg-if", - "derive_more", - "parity-scale-codec", - "scale-info-derive", -] - -[[package]] -name = "scale-info-derive" -version = "2.11.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "18cf6c6447f813ef19eb450e985bcce6705f9ce7660db221b59093d15c79c4b7" -dependencies = [ - "proc-macro-crate 1.3.1", - "proc-macro2", - "quote", - "syn 1.0.109", -] - -[[package]] -name = "sec1" -version = "0.7.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d3e97a565f76233a6003f9f5c54be1d9c5bdfa3eccfb189469f11ec4901c47dc" -dependencies = [ - "base16ct", - "der", - "generic-array", - "pkcs8", - "subtle", - "zeroize", -] - [[package]] name = "serde" -version = "1.0.201" +version = "1.0.204" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "780f1cebed1629e4753a1a38a3c72d30b97ec044f0aef68cb26650a3c5cf363c" +checksum = "bc76f558e0cbb2a839d37354c575f1dc3fdc6546b5be373ba43d95f231bf7c12" dependencies = [ "serde_derive", ] [[package]] name = "serde_derive" -version = "1.0.201" +version = "1.0.204" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c5e405930b9796f1c00bee880d03fc7e0bb4b9a11afc776885ffe84320da2865" +checksum = "e0cd7e117be63d3c3678776753929474f3b04a43a080c744d6b0ae2a8c28e222" dependencies = [ "proc-macro2", "quote", @@ -594,29 +199,9 @@ dependencies = [ "digest", ] -[[package]] -name = "signature" -version = "2.2.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "77549399552de45a898a580c1b41d445bf730df867cc44e6c0233bbc4b8329de" -dependencies = [ - "digest", - "rand_core", -] - -[[package]] -name = "snowbridge-amcl" -version = "1.0.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "460a9ed63cdf03c1b9847e8a12a5f5ba19c4efd5869e4a737e05be25d7c427e5" -dependencies = [ - "parity-scale-codec", - "scale-info", -] - [[package]] name = "sp1-derive" -version = "0.1.0" +version = "1.0.0-rc.1" dependencies = [ "proc-macro2", "quote", @@ -624,54 +209,31 @@ dependencies = [ ] [[package]] -name = "sp1-precompiles" -version = "0.1.0" +name = "sp1-lib" +version = "1.0.0-rc.1" dependencies = [ "anyhow", "bincode", "cfg-if", - "getrandom", - "hex", - "k256", - "num", - "rand", "serde", - "snowbridge-amcl", ] [[package]] name = "sp1-zkvm" -version = "0.1.0" +version = "1.0.0-rc.1" dependencies = [ "bincode", "cfg-if", "getrandom", - "k256", "lazy_static", "libm", "once_cell", "rand", "serde", "sha2", - "sp1-precompiles", -] - -[[package]] -name = "spki" -version = "0.7.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d91ed6c858b01f942cd56b37a94b3e0a1798290327d1236e4d9cf4eaca44d29d" -dependencies = [ - "base64ct", - "der", + "sp1-lib", ] -[[package]] -name = "subtle" -version = "2.5.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "81cdd64d312baedb58e21336b31bc043b77e01cc99033ce76ef539f78e965ebc" - [[package]] name = "syn" version = "1.0.109" @@ -694,40 +256,6 @@ dependencies = [ "unicode-ident", ] -[[package]] -name = "tap" -version = "1.0.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "55937e1799185b12863d447f42597ed69d9928686b8d88a1df17376a097d8369" - -[[package]] -name = "toml_datetime" -version = "0.6.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7cda73e2f1397b1262d6dfdcef8aafae14d1de7748d66822d3bfeeb6d03e5e4b" - -[[package]] -name = "toml_edit" -version = "0.19.15" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1b5bb770da30e5cbfde35a2d7b9b8a2c4b8ef89548a7a6aeab5c9a576e3e7421" -dependencies = [ - "indexmap", - "toml_datetime", - "winnow", -] - -[[package]] -name = "toml_edit" -version = "0.20.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "396e4d48bbb2b7554c944bde63101b5ae446cff6ec4a24227428f15eb72ef338" -dependencies = [ - "indexmap", - "toml_datetime", - "winnow", -] - [[package]] name = "typenum" version = "1.17.0" @@ -751,27 +279,3 @@ name = "wasi" version = "0.11.0+wasi-snapshot-preview1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "9c8d87e72b64a3b4db28d11ce29237c246188f4f51057d65a7eab63b7987e423" - -[[package]] -name = "winnow" -version = "0.5.40" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f593a95398737aeed53e489c785df13f3618e41dbcd6718c6addbf1395aa6876" -dependencies = [ - "memchr", -] - -[[package]] -name = "wyz" -version = "0.5.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "05f360fc0b24296329c78fda852a1e9ae82de9cf7b27dae4b7f62f118f77b9ed" -dependencies = [ - "tap", -] - -[[package]] -name = "zeroize" -version = "1.7.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "525b4ec142c6b68a2d10f01f7bbf6755599ca3f81ea53b8431b7dd348f5fdb2d" diff --git a/examples/cycle-tracking/program/Cargo.toml b/examples/cycle-tracking/program/Cargo.toml index d00b69640c..22958112a4 100644 --- a/examples/cycle-tracking/program/Cargo.toml +++ b/examples/cycle-tracking/program/Cargo.toml @@ -1,8 +1,9 @@ [workspace] [package] -version = "0.1.0" name = "cycle-tracking-program" +version = "1.0.0-rc.1" edition = "2021" +publish = false [dependencies] sp1-zkvm = { path = "../../../zkvm/entrypoint" } diff --git a/examples/cycle-tracking/program/elf/riscv32im-succinct-zkvm-elf b/examples/cycle-tracking/program/elf/riscv32im-succinct-zkvm-elf index c0c915cd22..7c3f10b487 100755 Binary files a/examples/cycle-tracking/program/elf/riscv32im-succinct-zkvm-elf and b/examples/cycle-tracking/program/elf/riscv32im-succinct-zkvm-elf differ diff --git a/examples/cycle-tracking/script/Cargo.toml b/examples/cycle-tracking/script/Cargo.toml index 2aac9c1e6b..fb8ef7774b 100644 --- a/examples/cycle-tracking/script/Cargo.toml +++ b/examples/cycle-tracking/script/Cargo.toml @@ -1,10 +1,11 @@ [package] -version = "0.1.0" name = "cycle-tracking-script" -edition = "2021" +version = { workspace = true } +edition = { workspace = true } +publish = false [dependencies] -sp1-sdk = { path = "../../../sdk" } +sp1-sdk = { workspace = true } [build-dependencies] -sp1-helper = { path = "../../../helper" } +sp1-helper = { workspace = true } diff --git a/examples/cycle-tracking/script/src/main.rs b/examples/cycle-tracking/script/src/main.rs index 81e534f997..fad0e8cf93 100644 --- a/examples/cycle-tracking/script/src/main.rs +++ b/examples/cycle-tracking/script/src/main.rs @@ -1,4 +1,4 @@ -use sp1_sdk::{utils, ProverClient, SP1Proof, SP1Stdin}; +use sp1_sdk::{utils, ProverClient, SP1ProofWithPublicValues, SP1Stdin}; /// The ELF we want to execute inside the zkVM. const ELF: &[u8] = include_bytes!("../../program/elf/riscv32im-succinct-zkvm-elf"); @@ -13,7 +13,7 @@ fn main() { // Generate the proof for the given program. let client = ProverClient::new(); let (pk, vk) = client.setup(ELF); - let proof = client.prove(&pk, stdin).expect("proving failed"); + let proof = client.prove(&pk, stdin).run().expect("proving failed"); // Verify proof. client.verify(&proof, &vk).expect("verification failed"); @@ -22,7 +22,8 @@ fn main() { proof .save("proof-with-pis.bin") .expect("saving proof failed"); - let deserialized_proof = SP1Proof::load("proof-with-pis.bin").expect("loading proof failed"); + let deserialized_proof = + SP1ProofWithPublicValues::load("proof-with-pis.bin").expect("loading proof failed"); // Verify the deserialized proof. client diff --git a/examples/fibonacci/program/Cargo.lock b/examples/fibonacci/program/Cargo.lock index 9a8dc81508..ad6e8ec61e 100644 --- a/examples/fibonacci/program/Cargo.lock +++ b/examples/fibonacci/program/Cargo.lock @@ -8,30 +8,6 @@ version = "1.0.83" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "25bdb32cbbdce2b519a9cd7df3a678443100e265d5e25ca763b7572a5104f5f3" -[[package]] -name = "arrayvec" -version = "0.7.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "96d30a06541fbafbc7f82ed10c06164cfbd2c401138f6addd8404629c4b16711" - -[[package]] -name = "autocfg" -version = "1.2.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f1fdabc7756949593fe60f30ec81974b613357de856987752631dea1e3394c80" - -[[package]] -name = "base16ct" -version = "0.2.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4c7f02d4ea65f2c1853089ffd8d2787bdbc63de2f0d29dedbcf8ccdfa0ccd4cf" - -[[package]] -name = "base64ct" -version = "1.6.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8c3c1a368f70d6cf7302d78f8f7093da241fb8e8807c05cc9e51a125895a6d5b" - [[package]] name = "bincode" version = "1.3.3" @@ -41,18 +17,6 @@ dependencies = [ "serde", ] -[[package]] -name = "bitvec" -version = "1.0.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1bc2832c24239b0141d5674bb9174f9d68a8b5b3f2753311927c172ca46f7e9c" -dependencies = [ - "funty", - "radium", - "tap", - "wyz", -] - [[package]] name = "block-buffer" version = "0.10.4" @@ -62,24 +26,12 @@ dependencies = [ "generic-array", ] -[[package]] -name = "byte-slice-cast" -version = "1.2.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c3ac9f8b63eca6fd385229b3675f6cc0dc5c8a5c8a54a59d4f52ffd670d87b0c" - [[package]] name = "cfg-if" version = "1.0.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "baf1de4339761588bc0619e3cbc0120ee582ebb74b53b4efbf79117bd2da40fd" -[[package]] -name = "const-oid" -version = "0.9.6" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c2459377285ad874054d797f3ccebf984978aa39129f6eafde5cdc8315b612f8" - [[package]] name = "cpufeatures" version = "0.2.12" @@ -89,18 +41,6 @@ dependencies = [ "libc", ] -[[package]] -name = "crypto-bigint" -version = "0.5.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0dc92fb57ca44df6db8059111ab3af99a63d5d0f8375d9972e319a379c6bab76" -dependencies = [ - "generic-array", - "rand_core", - "subtle", - "zeroize", -] - [[package]] name = "crypto-common" version = "0.1.6" @@ -111,27 +51,6 @@ dependencies = [ "typenum", ] -[[package]] -name = "der" -version = "0.7.9" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f55bf8e7b65898637379c1b74eb1551107c8294ed26d855ceb9fd1a09cfc9bc0" -dependencies = [ - "const-oid", - "zeroize", -] - -[[package]] -name = "derive_more" -version = "0.99.17" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4fb810d30a7c1953f91334de7244731fc3f3c10d7fe163338a35b9f640960321" -dependencies = [ - "proc-macro2", - "quote", - "syn 1.0.109", -] - [[package]] name = "digest" version = "0.10.7" @@ -139,75 +58,16 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "9ed9a281f7bc9b7576e61468ba615a66a5c8cfdff42420a70aa82701a3b1e292" dependencies = [ "block-buffer", - "const-oid", "crypto-common", - "subtle", -] - -[[package]] -name = "ecdsa" -version = "0.16.9" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ee27f32b5c5292967d2d4a9d7f1e0b0aed2c15daded5a60300e4abb9d8020bca" -dependencies = [ - "der", - "digest", - "elliptic-curve", - "rfc6979", - "signature", - "spki", -] - -[[package]] -name = "elliptic-curve" -version = "0.13.8" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b5e6043086bf7973472e0c7dff2142ea0b680d30e18d9cc40f267efbf222bd47" -dependencies = [ - "base16ct", - "crypto-bigint", - "digest", - "ff", - "generic-array", - "group", - "pkcs8", - "rand_core", - "sec1", - "subtle", - "tap", - "zeroize", -] - -[[package]] -name = "equivalent" -version = "1.0.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5443807d6dff69373d433ab9ef5378ad8df50ca6298caf15de6e52e24aaf54d5" - -[[package]] -name = "ff" -version = "0.13.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ded41244b729663b1e574f1b4fb731469f69f79c17667b5d776b16cda0479449" -dependencies = [ - "bitvec", - "rand_core", - "subtle", ] [[package]] name = "fibonacci-program" -version = "0.1.0" +version = "1.0.0-rc.1" dependencies = [ "sp1-zkvm", ] -[[package]] -name = "funty" -version = "2.0.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e6d5a32815ae3f33302d95fdcb2ce17862f8c65363dcfd29360480ba1001fc9c" - [[package]] name = "generic-array" version = "0.14.7" @@ -216,7 +76,6 @@ checksum = "85649ca51fd72272d7821adaf274ad91c288277713d9c18820d8499a7ff69e9a" dependencies = [ "typenum", "version_check", - "zeroize", ] [[package]] @@ -230,78 +89,11 @@ dependencies = [ "wasi", ] -[[package]] -name = "group" -version = "0.13.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f0f9ef7462f7c099f518d754361858f86d8a07af53ba9af0fe635bbccb151a63" -dependencies = [ - "ff", - "rand_core", - "subtle", -] - -[[package]] -name = "hashbrown" -version = "0.14.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "290f1a1d9242c78d09ce40a5e87e7554ee637af1351968159f4952f028f75604" - -[[package]] -name = "hex" -version = "0.4.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7f24254aa9a54b5c858eaee2f5bccdb46aaf0e486a595ed5fd8f86ba55232a70" - -[[package]] -name = "hmac" -version = "0.12.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6c49c37c09c17a53d937dfbb742eb3a961d65a994e6bcdcf37e7399d0cc8ab5e" -dependencies = [ - "digest", -] - -[[package]] -name = "impl-trait-for-tuples" -version = "0.2.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "11d7a9f6330b71fea57921c9b61c47ee6e84f72d394754eff6163ae67e7395eb" -dependencies = [ - "proc-macro2", - "quote", - "syn 1.0.109", -] - -[[package]] -name = "indexmap" -version = "2.2.6" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "168fb715dda47215e360912c096649d23d58bf392ac62f73919e831745e40f26" -dependencies = [ - "equivalent", - "hashbrown", -] - -[[package]] -name = "k256" -version = "0.13.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "956ff9b67e26e1a6a866cb758f12c6f8746208489e3e4a4b5580802f2f0a587b" -dependencies = [ - "cfg-if", - "ecdsa", - "elliptic-curve", - "once_cell", - "sha2", - "signature", -] - [[package]] name = "lazy_static" -version = "1.4.0" +version = "1.5.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e2abad23fbc42b3700f2f279844dc832adb2b2eb069b2df918f455c4e18cc646" +checksum = "bbd2bcb4c963f2ddae06a2efc7e9f3591312473c50c6685e1f298068316e66fe" [[package]] name = "libc" @@ -315,151 +107,18 @@ version = "0.2.8" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "4ec2a862134d2a7d32d7983ddcdd1c4923530833c9f2ea1a44fc5fa473989058" -[[package]] -name = "memchr" -version = "2.7.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6c8640c5d730cb13ebd907d8d04b52f55ac9a2eec55b440c8892f40d56c76c1d" - -[[package]] -name = "num" -version = "0.4.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "35bd024e8b2ff75562e5f34e7f4905839deb4b22955ef5e73d2fea1b9813cb23" -dependencies = [ - "num-bigint", - "num-complex", - "num-integer", - "num-iter", - "num-rational", - "num-traits", -] - -[[package]] -name = "num-bigint" -version = "0.4.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c165a9ab64cf766f73521c0dd2cfdff64f488b8f0b3e621face3462d3db536d7" -dependencies = [ - "num-integer", - "num-traits", -] - -[[package]] -name = "num-complex" -version = "0.4.6" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "73f88a1307638156682bada9d7604135552957b7818057dcef22705b4d509495" -dependencies = [ - "num-traits", -] - -[[package]] -name = "num-integer" -version = "0.1.46" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7969661fd2958a5cb096e56c8e1ad0444ac2bbcd0061bd28660485a44879858f" -dependencies = [ - "num-traits", -] - -[[package]] -name = "num-iter" -version = "0.1.45" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1429034a0490724d0075ebb2bc9e875d6503c3cf69e235a8941aa757d83ef5bf" -dependencies = [ - "autocfg", - "num-integer", - "num-traits", -] - -[[package]] -name = "num-rational" -version = "0.4.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f83d14da390562dca69fc84082e73e548e1ad308d24accdedd2720017cb37824" -dependencies = [ - "num-bigint", - "num-integer", - "num-traits", -] - -[[package]] -name = "num-traits" -version = "0.2.19" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "071dfc062690e90b734c0b2273ce72ad0ffa95f0c74596bc250dcfd960262841" -dependencies = [ - "autocfg", -] - [[package]] name = "once_cell" version = "1.19.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "3fdb12b2476b595f9358c5161aa467c2438859caa136dec86c26fdd2efe17b92" -[[package]] -name = "parity-scale-codec" -version = "3.6.9" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "881331e34fa842a2fb61cc2db9643a8fedc615e47cfcc52597d1af0db9a7e8fe" -dependencies = [ - "arrayvec", - "byte-slice-cast", - "impl-trait-for-tuples", - "parity-scale-codec-derive", -] - -[[package]] -name = "parity-scale-codec-derive" -version = "3.6.9" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "be30eaf4b0a9fba5336683b38de57bb86d179a35862ba6bfcf57625d006bde5b" -dependencies = [ - "proc-macro-crate 2.0.2", - "proc-macro2", - "quote", - "syn 1.0.109", -] - -[[package]] -name = "pkcs8" -version = "0.10.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f950b2377845cebe5cf8b5165cb3cc1a5e0fa5cfa3e1f7f55707d8fd82e0a7b7" -dependencies = [ - "der", - "spki", -] - [[package]] name = "ppv-lite86" version = "0.2.17" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "5b40af805b3121feab8a3c29f04d8ad262fa8e0561883e7653e024ae4479e6de" -[[package]] -name = "proc-macro-crate" -version = "1.3.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7f4c021e1093a56626774e81216a4ce732a735e5bad4868a03f3ed65ca0c3919" -dependencies = [ - "once_cell", - "toml_edit 0.19.15", -] - -[[package]] -name = "proc-macro-crate" -version = "2.0.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b00f26d3400549137f92511a46ac1cd8ce37cb5598a96d382381458b992a5d24" -dependencies = [ - "toml_datetime", - "toml_edit 0.20.2", -] - [[package]] name = "proc-macro2" version = "1.0.81" @@ -478,12 +137,6 @@ dependencies = [ "proc-macro2", ] -[[package]] -name = "radium" -version = "0.7.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "dc33ff2d4973d518d823d61aa239014831e521c75da58e3df4840d3f47749d09" - [[package]] name = "rand" version = "0.8.5" @@ -514,72 +167,24 @@ dependencies = [ "getrandom", ] -[[package]] -name = "rfc6979" -version = "0.4.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f8dd2a808d456c4a54e300a23e9f5a67e122c3024119acbfd73e3bf664491cb2" -dependencies = [ - "hmac", - "subtle", -] - -[[package]] -name = "scale-info" -version = "2.11.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7c453e59a955f81fb62ee5d596b450383d699f152d350e9d23a0db2adb78e4c0" -dependencies = [ - "cfg-if", - "derive_more", - "parity-scale-codec", - "scale-info-derive", -] - -[[package]] -name = "scale-info-derive" -version = "2.11.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "18cf6c6447f813ef19eb450e985bcce6705f9ce7660db221b59093d15c79c4b7" -dependencies = [ - "proc-macro-crate 1.3.1", - "proc-macro2", - "quote", - "syn 1.0.109", -] - -[[package]] -name = "sec1" -version = "0.7.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d3e97a565f76233a6003f9f5c54be1d9c5bdfa3eccfb189469f11ec4901c47dc" -dependencies = [ - "base16ct", - "der", - "generic-array", - "pkcs8", - "subtle", - "zeroize", -] - [[package]] name = "serde" -version = "1.0.201" +version = "1.0.204" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "780f1cebed1629e4753a1a38a3c72d30b97ec044f0aef68cb26650a3c5cf363c" +checksum = "bc76f558e0cbb2a839d37354c575f1dc3fdc6546b5be373ba43d95f231bf7c12" dependencies = [ "serde_derive", ] [[package]] name = "serde_derive" -version = "1.0.201" +version = "1.0.204" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c5e405930b9796f1c00bee880d03fc7e0bb4b9a11afc776885ffe84320da2865" +checksum = "e0cd7e117be63d3c3678776753929474f3b04a43a080c744d6b0ae2a8c28e222" dependencies = [ "proc-macro2", "quote", - "syn 2.0.60", + "syn", ] [[package]] @@ -594,83 +199,29 @@ dependencies = [ ] [[package]] -name = "signature" -version = "2.2.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "77549399552de45a898a580c1b41d445bf730df867cc44e6c0233bbc4b8329de" -dependencies = [ - "digest", - "rand_core", -] - -[[package]] -name = "snowbridge-amcl" -version = "1.0.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "460a9ed63cdf03c1b9847e8a12a5f5ba19c4efd5869e4a737e05be25d7c427e5" -dependencies = [ - "parity-scale-codec", - "scale-info", -] - -[[package]] -name = "sp1-precompiles" -version = "0.1.0" +name = "sp1-lib" +version = "1.0.0-rc.1" dependencies = [ "anyhow", "bincode", "cfg-if", - "getrandom", - "hex", - "k256", - "num", - "rand", "serde", - "snowbridge-amcl", ] [[package]] name = "sp1-zkvm" -version = "0.1.0" +version = "1.0.0-rc.1" dependencies = [ "bincode", "cfg-if", "getrandom", - "k256", "lazy_static", "libm", "once_cell", "rand", "serde", "sha2", - "sp1-precompiles", -] - -[[package]] -name = "spki" -version = "0.7.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d91ed6c858b01f942cd56b37a94b3e0a1798290327d1236e4d9cf4eaca44d29d" -dependencies = [ - "base64ct", - "der", -] - -[[package]] -name = "subtle" -version = "2.5.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "81cdd64d312baedb58e21336b31bc043b77e01cc99033ce76ef539f78e965ebc" - -[[package]] -name = "syn" -version = "1.0.109" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "72b64191b275b66ffe2469e8af2c1cfe3bafa67b529ead792a6d0160888b4237" -dependencies = [ - "proc-macro2", - "quote", - "unicode-ident", + "sp1-lib", ] [[package]] @@ -684,40 +235,6 @@ dependencies = [ "unicode-ident", ] -[[package]] -name = "tap" -version = "1.0.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "55937e1799185b12863d447f42597ed69d9928686b8d88a1df17376a097d8369" - -[[package]] -name = "toml_datetime" -version = "0.6.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7cda73e2f1397b1262d6dfdcef8aafae14d1de7748d66822d3bfeeb6d03e5e4b" - -[[package]] -name = "toml_edit" -version = "0.19.15" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1b5bb770da30e5cbfde35a2d7b9b8a2c4b8ef89548a7a6aeab5c9a576e3e7421" -dependencies = [ - "indexmap", - "toml_datetime", - "winnow", -] - -[[package]] -name = "toml_edit" -version = "0.20.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "396e4d48bbb2b7554c944bde63101b5ae446cff6ec4a24227428f15eb72ef338" -dependencies = [ - "indexmap", - "toml_datetime", - "winnow", -] - [[package]] name = "typenum" version = "1.17.0" @@ -741,27 +258,3 @@ name = "wasi" version = "0.11.0+wasi-snapshot-preview1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "9c8d87e72b64a3b4db28d11ce29237c246188f4f51057d65a7eab63b7987e423" - -[[package]] -name = "winnow" -version = "0.5.40" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f593a95398737aeed53e489c785df13f3618e41dbcd6718c6addbf1395aa6876" -dependencies = [ - "memchr", -] - -[[package]] -name = "wyz" -version = "0.5.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "05f360fc0b24296329c78fda852a1e9ae82de9cf7b27dae4b7f62f118f77b9ed" -dependencies = [ - "tap", -] - -[[package]] -name = "zeroize" -version = "1.7.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "525b4ec142c6b68a2d10f01f7bbf6755599ca3f81ea53b8431b7dd348f5fdb2d" diff --git a/examples/fibonacci/program/Cargo.toml b/examples/fibonacci/program/Cargo.toml index 7d92da05d9..c9e2debd4e 100644 --- a/examples/fibonacci/program/Cargo.toml +++ b/examples/fibonacci/program/Cargo.toml @@ -1,8 +1,9 @@ [workspace] [package] -version = "0.1.0" name = "fibonacci-program" +version = "1.0.0-rc.1" edition = "2021" +publish = false [dependencies] sp1-zkvm = { path = "../../../zkvm/entrypoint" } diff --git a/examples/fibonacci/program/elf/riscv32im-succinct-zkvm-elf b/examples/fibonacci/program/elf/riscv32im-succinct-zkvm-elf index cd36cd92d4..0b8be22e19 100755 Binary files a/examples/fibonacci/program/elf/riscv32im-succinct-zkvm-elf and b/examples/fibonacci/program/elf/riscv32im-succinct-zkvm-elf differ diff --git a/examples/fibonacci/script/Cargo.toml b/examples/fibonacci/script/Cargo.toml index 5d8bfb0c8b..6054ede538 100644 --- a/examples/fibonacci/script/Cargo.toml +++ b/examples/fibonacci/script/Cargo.toml @@ -1,16 +1,17 @@ [package] -version = "0.1.0" name = "fibonacci-script" -edition = "2021" +version = { workspace = true } +edition = { workspace = true } default-run = "fibonacci-script" +publish = false [dependencies] itertools = "0.12.1" -sp1-sdk = { path = "../../../sdk" } +sp1-sdk = { workspace = true } sha2 = "0.10.8" [build-dependencies] -sp1-helper = { path = "../../../helper" } +sp1-helper = { workspace = true } [[bin]] name = "plonk_bn254" diff --git a/examples/fibonacci/script/bin/compressed.rs b/examples/fibonacci/script/bin/compressed.rs index 9dd3f52690..04ae62bb29 100644 --- a/examples/fibonacci/script/bin/compressed.rs +++ b/examples/fibonacci/script/bin/compressed.rs @@ -15,7 +15,7 @@ fn main() { // Generate the constant-sized proof for the given program and input. let client = ProverClient::new(); let (pk, vk) = client.setup(ELF); - let mut proof = client.prove_compressed(&pk, stdin).unwrap(); + let mut proof = client.prove(&pk, stdin).compressed().run().unwrap(); println!("generated proof"); // Read and verify the output. @@ -24,9 +24,7 @@ fn main() { println!("a: {}, b: {}", a, b); // Verify proof and public values - client - .verify_compressed(&proof, &vk) - .expect("verification failed"); + client.verify(&proof, &vk).expect("verification failed"); // Save the proof. proof diff --git a/examples/fibonacci/script/bin/execute.rs b/examples/fibonacci/script/bin/execute.rs index 180da9ceea..9c519428fd 100644 --- a/examples/fibonacci/script/bin/execute.rs +++ b/examples/fibonacci/script/bin/execute.rs @@ -15,7 +15,7 @@ fn main() { // Only execute the program and get a `SP1PublicValues` object. let client = ProverClient::new(); - let (mut public_values, _) = client.execute(ELF, stdin).unwrap(); + let (mut public_values, _) = client.execute(ELF, stdin).run().unwrap(); println!("generated proof"); diff --git a/examples/fibonacci/script/bin/plonk_bn254.rs b/examples/fibonacci/script/bin/plonk_bn254.rs index 2bff4fb21c..ee09e43b1c 100644 --- a/examples/fibonacci/script/bin/plonk_bn254.rs +++ b/examples/fibonacci/script/bin/plonk_bn254.rs @@ -16,21 +16,20 @@ fn main() { // Generate the proof for the given program and input. let client = ProverClient::new(); let (pk, vk) = client.setup(ELF); - let mut proof = client.prove_plonk(&pk, stdin).unwrap(); + let proof = client.prove(&pk, stdin).plonk().run().unwrap(); println!("generated proof"); - // Read and verify the output. - let _ = proof.public_values.read::(); - let a = proof.public_values.read::(); - let b = proof.public_values.read::(); - println!("a: {}", a); - println!("b: {}", b); + // Get the public values as bytes. + let public_values = proof.public_values.raw(); + println!("public values: {:?}", public_values); + + // Get the proof as bytes. + let solidity_proof = proof.raw(); + println!("proof: {:?}", solidity_proof); // Verify proof and public values - client - .verify_plonk(&proof, &vk) - .expect("verification failed"); + client.verify(&proof, &vk).expect("verification failed"); // Save the proof. proof diff --git a/examples/fibonacci/script/src/main.rs b/examples/fibonacci/script/src/main.rs index d7de54e3ab..8c28bab03d 100644 --- a/examples/fibonacci/script/src/main.rs +++ b/examples/fibonacci/script/src/main.rs @@ -1,4 +1,4 @@ -use sp1_sdk::{utils, ProverClient, SP1Proof, SP1Stdin}; +use sp1_sdk::{utils, ProverClient, SP1ProofWithPublicValues, SP1Stdin}; /// The ELF we want to execute inside the zkVM. const ELF: &[u8] = include_bytes!("../../program/elf/riscv32im-succinct-zkvm-elf"); @@ -8,7 +8,7 @@ fn main() { utils::setup_logger(); // Create an input stream and write '500' to it. - let n = 500u32; + let n = 1u32; let mut stdin = SP1Stdin::new(); stdin.write(&n); @@ -16,7 +16,7 @@ fn main() { // Generate the proof for the given program and input. let client = ProverClient::new(); let (pk, vk) = client.setup(ELF); - let mut proof = client.prove(&pk, stdin).unwrap(); + let mut proof = client.prove(&pk, stdin).run().unwrap(); println!("generated proof"); @@ -35,7 +35,8 @@ fn main() { proof .save("proof-with-pis.bin") .expect("saving proof failed"); - let deserialized_proof = SP1Proof::load("proof-with-pis.bin").expect("loading proof failed"); + let deserialized_proof = + SP1ProofWithPublicValues::load("proof-with-pis.bin").expect("loading proof failed"); // Verify the deserialized proof. client diff --git a/examples/io/program/Cargo.lock b/examples/io/program/Cargo.lock index e3fcd779c5..cd9d99e33a 100644 --- a/examples/io/program/Cargo.lock +++ b/examples/io/program/Cargo.lock @@ -8,30 +8,6 @@ version = "1.0.83" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "25bdb32cbbdce2b519a9cd7df3a678443100e265d5e25ca763b7572a5104f5f3" -[[package]] -name = "arrayvec" -version = "0.7.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "96d30a06541fbafbc7f82ed10c06164cfbd2c401138f6addd8404629c4b16711" - -[[package]] -name = "autocfg" -version = "1.2.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f1fdabc7756949593fe60f30ec81974b613357de856987752631dea1e3394c80" - -[[package]] -name = "base16ct" -version = "0.2.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4c7f02d4ea65f2c1853089ffd8d2787bdbc63de2f0d29dedbcf8ccdfa0ccd4cf" - -[[package]] -name = "base64ct" -version = "1.6.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8c3c1a368f70d6cf7302d78f8f7093da241fb8e8807c05cc9e51a125895a6d5b" - [[package]] name = "bincode" version = "1.3.3" @@ -41,18 +17,6 @@ dependencies = [ "serde", ] -[[package]] -name = "bitvec" -version = "1.0.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1bc2832c24239b0141d5674bb9174f9d68a8b5b3f2753311927c172ca46f7e9c" -dependencies = [ - "funty", - "radium", - "tap", - "wyz", -] - [[package]] name = "block-buffer" version = "0.10.4" @@ -62,24 +26,12 @@ dependencies = [ "generic-array", ] -[[package]] -name = "byte-slice-cast" -version = "1.2.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c3ac9f8b63eca6fd385229b3675f6cc0dc5c8a5c8a54a59d4f52ffd670d87b0c" - [[package]] name = "cfg-if" version = "1.0.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "baf1de4339761588bc0619e3cbc0120ee582ebb74b53b4efbf79117bd2da40fd" -[[package]] -name = "const-oid" -version = "0.9.6" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c2459377285ad874054d797f3ccebf984978aa39129f6eafde5cdc8315b612f8" - [[package]] name = "cpufeatures" version = "0.2.12" @@ -89,18 +41,6 @@ dependencies = [ "libc", ] -[[package]] -name = "crypto-bigint" -version = "0.5.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0dc92fb57ca44df6db8059111ab3af99a63d5d0f8375d9972e319a379c6bab76" -dependencies = [ - "generic-array", - "rand_core", - "subtle", - "zeroize", -] - [[package]] name = "crypto-common" version = "0.1.6" @@ -111,27 +51,6 @@ dependencies = [ "typenum", ] -[[package]] -name = "der" -version = "0.7.9" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f55bf8e7b65898637379c1b74eb1551107c8294ed26d855ceb9fd1a09cfc9bc0" -dependencies = [ - "const-oid", - "zeroize", -] - -[[package]] -name = "derive_more" -version = "0.99.17" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4fb810d30a7c1953f91334de7244731fc3f3c10d7fe163338a35b9f640960321" -dependencies = [ - "proc-macro2", - "quote", - "syn 1.0.109", -] - [[package]] name = "digest" version = "0.10.7" @@ -139,68 +58,9 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "9ed9a281f7bc9b7576e61468ba615a66a5c8cfdff42420a70aa82701a3b1e292" dependencies = [ "block-buffer", - "const-oid", "crypto-common", - "subtle", -] - -[[package]] -name = "ecdsa" -version = "0.16.9" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ee27f32b5c5292967d2d4a9d7f1e0b0aed2c15daded5a60300e4abb9d8020bca" -dependencies = [ - "der", - "digest", - "elliptic-curve", - "rfc6979", - "signature", - "spki", -] - -[[package]] -name = "elliptic-curve" -version = "0.13.8" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b5e6043086bf7973472e0c7dff2142ea0b680d30e18d9cc40f267efbf222bd47" -dependencies = [ - "base16ct", - "crypto-bigint", - "digest", - "ff", - "generic-array", - "group", - "pkcs8", - "rand_core", - "sec1", - "subtle", - "tap", - "zeroize", -] - -[[package]] -name = "equivalent" -version = "1.0.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5443807d6dff69373d433ab9ef5378ad8df50ca6298caf15de6e52e24aaf54d5" - -[[package]] -name = "ff" -version = "0.13.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ded41244b729663b1e574f1b4fb731469f69f79c17667b5d776b16cda0479449" -dependencies = [ - "bitvec", - "rand_core", - "subtle", ] -[[package]] -name = "funty" -version = "2.0.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e6d5a32815ae3f33302d95fdcb2ce17862f8c65363dcfd29360480ba1001fc9c" - [[package]] name = "generic-array" version = "0.14.7" @@ -209,7 +69,6 @@ checksum = "85649ca51fd72272d7821adaf274ad91c288277713d9c18820d8499a7ff69e9a" dependencies = [ "typenum", "version_check", - "zeroize", ] [[package]] @@ -223,86 +82,19 @@ dependencies = [ "wasi", ] -[[package]] -name = "group" -version = "0.13.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f0f9ef7462f7c099f518d754361858f86d8a07af53ba9af0fe635bbccb151a63" -dependencies = [ - "ff", - "rand_core", - "subtle", -] - -[[package]] -name = "hashbrown" -version = "0.14.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "290f1a1d9242c78d09ce40a5e87e7554ee637af1351968159f4952f028f75604" - -[[package]] -name = "hex" -version = "0.4.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7f24254aa9a54b5c858eaee2f5bccdb46aaf0e486a595ed5fd8f86ba55232a70" - -[[package]] -name = "hmac" -version = "0.12.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6c49c37c09c17a53d937dfbb742eb3a961d65a994e6bcdcf37e7399d0cc8ab5e" -dependencies = [ - "digest", -] - -[[package]] -name = "impl-trait-for-tuples" -version = "0.2.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "11d7a9f6330b71fea57921c9b61c47ee6e84f72d394754eff6163ae67e7395eb" -dependencies = [ - "proc-macro2", - "quote", - "syn 1.0.109", -] - -[[package]] -name = "indexmap" -version = "2.2.6" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "168fb715dda47215e360912c096649d23d58bf392ac62f73919e831745e40f26" -dependencies = [ - "equivalent", - "hashbrown", -] - [[package]] name = "io-program" -version = "0.1.0" +version = "1.0.0-rc.1" dependencies = [ "serde", "sp1-zkvm", ] -[[package]] -name = "k256" -version = "0.13.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "956ff9b67e26e1a6a866cb758f12c6f8746208489e3e4a4b5580802f2f0a587b" -dependencies = [ - "cfg-if", - "ecdsa", - "elliptic-curve", - "once_cell", - "sha2", - "signature", -] - [[package]] name = "lazy_static" -version = "1.4.0" +version = "1.5.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e2abad23fbc42b3700f2f279844dc832adb2b2eb069b2df918f455c4e18cc646" +checksum = "bbd2bcb4c963f2ddae06a2efc7e9f3591312473c50c6685e1f298068316e66fe" [[package]] name = "libc" @@ -316,151 +108,18 @@ version = "0.2.8" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "4ec2a862134d2a7d32d7983ddcdd1c4923530833c9f2ea1a44fc5fa473989058" -[[package]] -name = "memchr" -version = "2.7.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6c8640c5d730cb13ebd907d8d04b52f55ac9a2eec55b440c8892f40d56c76c1d" - -[[package]] -name = "num" -version = "0.4.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "35bd024e8b2ff75562e5f34e7f4905839deb4b22955ef5e73d2fea1b9813cb23" -dependencies = [ - "num-bigint", - "num-complex", - "num-integer", - "num-iter", - "num-rational", - "num-traits", -] - -[[package]] -name = "num-bigint" -version = "0.4.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c165a9ab64cf766f73521c0dd2cfdff64f488b8f0b3e621face3462d3db536d7" -dependencies = [ - "num-integer", - "num-traits", -] - -[[package]] -name = "num-complex" -version = "0.4.6" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "73f88a1307638156682bada9d7604135552957b7818057dcef22705b4d509495" -dependencies = [ - "num-traits", -] - -[[package]] -name = "num-integer" -version = "0.1.46" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7969661fd2958a5cb096e56c8e1ad0444ac2bbcd0061bd28660485a44879858f" -dependencies = [ - "num-traits", -] - -[[package]] -name = "num-iter" -version = "0.1.45" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1429034a0490724d0075ebb2bc9e875d6503c3cf69e235a8941aa757d83ef5bf" -dependencies = [ - "autocfg", - "num-integer", - "num-traits", -] - -[[package]] -name = "num-rational" -version = "0.4.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f83d14da390562dca69fc84082e73e548e1ad308d24accdedd2720017cb37824" -dependencies = [ - "num-bigint", - "num-integer", - "num-traits", -] - -[[package]] -name = "num-traits" -version = "0.2.19" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "071dfc062690e90b734c0b2273ce72ad0ffa95f0c74596bc250dcfd960262841" -dependencies = [ - "autocfg", -] - [[package]] name = "once_cell" version = "1.19.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "3fdb12b2476b595f9358c5161aa467c2438859caa136dec86c26fdd2efe17b92" -[[package]] -name = "parity-scale-codec" -version = "3.6.9" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "881331e34fa842a2fb61cc2db9643a8fedc615e47cfcc52597d1af0db9a7e8fe" -dependencies = [ - "arrayvec", - "byte-slice-cast", - "impl-trait-for-tuples", - "parity-scale-codec-derive", -] - -[[package]] -name = "parity-scale-codec-derive" -version = "3.6.9" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "be30eaf4b0a9fba5336683b38de57bb86d179a35862ba6bfcf57625d006bde5b" -dependencies = [ - "proc-macro-crate 2.0.2", - "proc-macro2", - "quote", - "syn 1.0.109", -] - -[[package]] -name = "pkcs8" -version = "0.10.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f950b2377845cebe5cf8b5165cb3cc1a5e0fa5cfa3e1f7f55707d8fd82e0a7b7" -dependencies = [ - "der", - "spki", -] - [[package]] name = "ppv-lite86" version = "0.2.17" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "5b40af805b3121feab8a3c29f04d8ad262fa8e0561883e7653e024ae4479e6de" -[[package]] -name = "proc-macro-crate" -version = "1.3.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7f4c021e1093a56626774e81216a4ce732a735e5bad4868a03f3ed65ca0c3919" -dependencies = [ - "once_cell", - "toml_edit 0.19.15", -] - -[[package]] -name = "proc-macro-crate" -version = "2.0.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b00f26d3400549137f92511a46ac1cd8ce37cb5598a96d382381458b992a5d24" -dependencies = [ - "toml_datetime", - "toml_edit 0.20.2", -] - [[package]] name = "proc-macro2" version = "1.0.81" @@ -479,12 +138,6 @@ dependencies = [ "proc-macro2", ] -[[package]] -name = "radium" -version = "0.7.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "dc33ff2d4973d518d823d61aa239014831e521c75da58e3df4840d3f47749d09" - [[package]] name = "rand" version = "0.8.5" @@ -515,72 +168,24 @@ dependencies = [ "getrandom", ] -[[package]] -name = "rfc6979" -version = "0.4.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f8dd2a808d456c4a54e300a23e9f5a67e122c3024119acbfd73e3bf664491cb2" -dependencies = [ - "hmac", - "subtle", -] - -[[package]] -name = "scale-info" -version = "2.11.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7c453e59a955f81fb62ee5d596b450383d699f152d350e9d23a0db2adb78e4c0" -dependencies = [ - "cfg-if", - "derive_more", - "parity-scale-codec", - "scale-info-derive", -] - -[[package]] -name = "scale-info-derive" -version = "2.11.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "18cf6c6447f813ef19eb450e985bcce6705f9ce7660db221b59093d15c79c4b7" -dependencies = [ - "proc-macro-crate 1.3.1", - "proc-macro2", - "quote", - "syn 1.0.109", -] - -[[package]] -name = "sec1" -version = "0.7.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d3e97a565f76233a6003f9f5c54be1d9c5bdfa3eccfb189469f11ec4901c47dc" -dependencies = [ - "base16ct", - "der", - "generic-array", - "pkcs8", - "subtle", - "zeroize", -] - [[package]] name = "serde" -version = "1.0.201" +version = "1.0.204" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "780f1cebed1629e4753a1a38a3c72d30b97ec044f0aef68cb26650a3c5cf363c" +checksum = "bc76f558e0cbb2a839d37354c575f1dc3fdc6546b5be373ba43d95f231bf7c12" dependencies = [ "serde_derive", ] [[package]] name = "serde_derive" -version = "1.0.201" +version = "1.0.204" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c5e405930b9796f1c00bee880d03fc7e0bb4b9a11afc776885ffe84320da2865" +checksum = "e0cd7e117be63d3c3678776753929474f3b04a43a080c744d6b0ae2a8c28e222" dependencies = [ "proc-macro2", "quote", - "syn 2.0.60", + "syn", ] [[package]] @@ -595,83 +200,29 @@ dependencies = [ ] [[package]] -name = "signature" -version = "2.2.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "77549399552de45a898a580c1b41d445bf730df867cc44e6c0233bbc4b8329de" -dependencies = [ - "digest", - "rand_core", -] - -[[package]] -name = "snowbridge-amcl" -version = "1.0.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "460a9ed63cdf03c1b9847e8a12a5f5ba19c4efd5869e4a737e05be25d7c427e5" -dependencies = [ - "parity-scale-codec", - "scale-info", -] - -[[package]] -name = "sp1-precompiles" -version = "0.1.0" +name = "sp1-lib" +version = "1.0.0-rc.1" dependencies = [ "anyhow", "bincode", "cfg-if", - "getrandom", - "hex", - "k256", - "num", - "rand", "serde", - "snowbridge-amcl", ] [[package]] name = "sp1-zkvm" -version = "0.1.0" +version = "1.0.0-rc.1" dependencies = [ "bincode", "cfg-if", "getrandom", - "k256", "lazy_static", "libm", "once_cell", "rand", "serde", "sha2", - "sp1-precompiles", -] - -[[package]] -name = "spki" -version = "0.7.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d91ed6c858b01f942cd56b37a94b3e0a1798290327d1236e4d9cf4eaca44d29d" -dependencies = [ - "base64ct", - "der", -] - -[[package]] -name = "subtle" -version = "2.5.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "81cdd64d312baedb58e21336b31bc043b77e01cc99033ce76ef539f78e965ebc" - -[[package]] -name = "syn" -version = "1.0.109" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "72b64191b275b66ffe2469e8af2c1cfe3bafa67b529ead792a6d0160888b4237" -dependencies = [ - "proc-macro2", - "quote", - "unicode-ident", + "sp1-lib", ] [[package]] @@ -685,40 +236,6 @@ dependencies = [ "unicode-ident", ] -[[package]] -name = "tap" -version = "1.0.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "55937e1799185b12863d447f42597ed69d9928686b8d88a1df17376a097d8369" - -[[package]] -name = "toml_datetime" -version = "0.6.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7cda73e2f1397b1262d6dfdcef8aafae14d1de7748d66822d3bfeeb6d03e5e4b" - -[[package]] -name = "toml_edit" -version = "0.19.15" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1b5bb770da30e5cbfde35a2d7b9b8a2c4b8ef89548a7a6aeab5c9a576e3e7421" -dependencies = [ - "indexmap", - "toml_datetime", - "winnow", -] - -[[package]] -name = "toml_edit" -version = "0.20.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "396e4d48bbb2b7554c944bde63101b5ae446cff6ec4a24227428f15eb72ef338" -dependencies = [ - "indexmap", - "toml_datetime", - "winnow", -] - [[package]] name = "typenum" version = "1.17.0" @@ -742,27 +259,3 @@ name = "wasi" version = "0.11.0+wasi-snapshot-preview1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "9c8d87e72b64a3b4db28d11ce29237c246188f4f51057d65a7eab63b7987e423" - -[[package]] -name = "winnow" -version = "0.5.40" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f593a95398737aeed53e489c785df13f3618e41dbcd6718c6addbf1395aa6876" -dependencies = [ - "memchr", -] - -[[package]] -name = "wyz" -version = "0.5.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "05f360fc0b24296329c78fda852a1e9ae82de9cf7b27dae4b7f62f118f77b9ed" -dependencies = [ - "tap", -] - -[[package]] -name = "zeroize" -version = "1.7.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "525b4ec142c6b68a2d10f01f7bbf6755599ca3f81ea53b8431b7dd348f5fdb2d" diff --git a/examples/io/program/Cargo.toml b/examples/io/program/Cargo.toml index c85b94b968..64e066daa9 100644 --- a/examples/io/program/Cargo.toml +++ b/examples/io/program/Cargo.toml @@ -1,8 +1,9 @@ [workspace] [package] -version = "0.1.0" name = "io-program" +version = "1.0.0-rc.1" edition = "2021" +publish = false [dependencies] sp1-zkvm = { path = "../../../zkvm/entrypoint" } diff --git a/examples/io/program/elf/riscv32im-succinct-zkvm-elf b/examples/io/program/elf/riscv32im-succinct-zkvm-elf index 9c86e401ef..e1eb253a4e 100755 Binary files a/examples/io/program/elf/riscv32im-succinct-zkvm-elf and b/examples/io/program/elf/riscv32im-succinct-zkvm-elf differ diff --git a/examples/io/script/Cargo.toml b/examples/io/script/Cargo.toml index 18f02b7af8..fbda365c6c 100644 --- a/examples/io/script/Cargo.toml +++ b/examples/io/script/Cargo.toml @@ -1,11 +1,12 @@ [package] -version = "0.1.0" name = "io-script" -edition = "2021" +version = { workspace = true } +edition = { workspace = true } +publish = false [dependencies] serde = { version = "1.0.196", features = ["derive"] } -sp1-sdk = { path = "../../../sdk" } +sp1-sdk = { workspace = true } [build-dependencies] -sp1-helper = { path = "../../../helper" } +sp1-helper = { workspace = true } diff --git a/examples/io/script/src/main.rs b/examples/io/script/src/main.rs index b4aa20786d..826940603d 100644 --- a/examples/io/script/src/main.rs +++ b/examples/io/script/src/main.rs @@ -1,5 +1,5 @@ use serde::{Deserialize, Serialize}; -use sp1_sdk::{utils, ProverClient, SP1Proof, SP1Stdin}; +use sp1_sdk::{utils, ProverClient, SP1ProofWithPublicValues, SP1Stdin}; /// The ELF we want to execute inside the zkVM. const ELF: &[u8] = include_bytes!("../../program/elf/riscv32im-succinct-zkvm-elf"); @@ -33,7 +33,7 @@ fn main() { // Generate the proof for the given program. let client = ProverClient::new(); let (pk, vk) = client.setup(ELF); - let mut proof = client.prove(&pk, stdin).unwrap(); + let mut proof = client.prove(&pk, stdin).run().unwrap(); // Read the output. let r = proof.public_values.read::(); @@ -46,7 +46,8 @@ fn main() { proof .save("proof-with-pis.bin") .expect("saving proof failed"); - let deserialized_proof = SP1Proof::load("proof-with-pis.bin").expect("loading proof failed"); + let deserialized_proof = + SP1ProofWithPublicValues::load("proof-with-pis.bin").expect("loading proof failed"); // Verify the deserialized proof. client diff --git a/examples/is-prime/program/Cargo.toml b/examples/is-prime/program/Cargo.toml index e4a4d11a19..f30650ec1c 100644 --- a/examples/is-prime/program/Cargo.toml +++ b/examples/is-prime/program/Cargo.toml @@ -1,8 +1,9 @@ [workspace] [package] -version = "0.1.0" name = "is-prime-program" +version = "1.0.0-rc.1" edition = "2021" +publish = false [dependencies] -sp1-zkvm = { git = "https://github.com/succinctlabs/sp1.git" } +sp1-zkvm = { path = "../../../zkvm/entrypoint" } diff --git a/examples/is-prime/script/Cargo.toml b/examples/is-prime/script/Cargo.toml index b47b84cbb0..6e79ab53c3 100644 --- a/examples/is-prime/script/Cargo.toml +++ b/examples/is-prime/script/Cargo.toml @@ -1,7 +1,8 @@ [package] -version = "0.1.0" name = "is-prime-script" -edition = "2021" +version = { workspace = true } +edition = { workspace = true } +publish = false [dependencies] -sp1-sdk = { path = "../../../sdk" } +sp1-sdk = { workspace = true } diff --git a/examples/is-prime/script/src/main.rs b/examples/is-prime/script/src/main.rs index 281c361545..d998cba20f 100644 --- a/examples/is-prime/script/src/main.rs +++ b/examples/is-prime/script/src/main.rs @@ -1,5 +1,5 @@ //! A program that takes a number `n` as input, and writes if `n` is prime as an output. -use sp1_sdk::{utils, ProverClient, SP1Proof, SP1Stdin}; +use sp1_sdk::{utils, ProverClient, SP1ProofWithPublicValues, SP1Stdin}; const ELF: &[u8] = include_bytes!("../../program/elf/riscv32im-succinct-zkvm-elf"); @@ -16,7 +16,7 @@ fn main() { // Generate and verify the proof let client = ProverClient::new(); let (pk, vk) = client.setup(ELF); - let mut proof = client.prove(&pk, stdin).unwrap(); + let mut proof = client.prove(&pk, stdin).run().unwrap(); let is_prime = proof.public_values.read::(); println!("Is 29 prime? {}", is_prime); @@ -28,7 +28,7 @@ fn main() { .save("proof-with-is-prime.bin") .expect("saving proof failed"); let deserialized_proof = - SP1Proof::load("proof-with-is-prime.bin").expect("loading proof failed"); + SP1ProofWithPublicValues::load("proof-with-is-prime.bin").expect("loading proof failed"); // Verify the deserialized proof. client diff --git a/examples/json/lib/Cargo.toml b/examples/json/lib/Cargo.toml index 8ac755b6df..836a989153 100644 --- a/examples/json/lib/Cargo.toml +++ b/examples/json/lib/Cargo.toml @@ -1,7 +1,8 @@ [package] name = "lib" -version = "0.1.0" -edition = "2021" +version = { workspace = true } +edition = { workspace = true } +publish = false [dependencies] serde = "1.0.196" diff --git a/examples/json/program/Cargo.lock b/examples/json/program/Cargo.lock index 66b23ba7f8..6592725c22 100644 --- a/examples/json/program/Cargo.lock +++ b/examples/json/program/Cargo.lock @@ -8,30 +8,6 @@ version = "1.0.83" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "25bdb32cbbdce2b519a9cd7df3a678443100e265d5e25ca763b7572a5104f5f3" -[[package]] -name = "arrayvec" -version = "0.7.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "96d30a06541fbafbc7f82ed10c06164cfbd2c401138f6addd8404629c4b16711" - -[[package]] -name = "autocfg" -version = "1.2.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f1fdabc7756949593fe60f30ec81974b613357de856987752631dea1e3394c80" - -[[package]] -name = "base16ct" -version = "0.2.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4c7f02d4ea65f2c1853089ffd8d2787bdbc63de2f0d29dedbcf8ccdfa0ccd4cf" - -[[package]] -name = "base64ct" -version = "1.6.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8c3c1a368f70d6cf7302d78f8f7093da241fb8e8807c05cc9e51a125895a6d5b" - [[package]] name = "bincode" version = "1.3.3" @@ -41,18 +17,6 @@ dependencies = [ "serde", ] -[[package]] -name = "bitvec" -version = "1.0.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1bc2832c24239b0141d5674bb9174f9d68a8b5b3f2753311927c172ca46f7e9c" -dependencies = [ - "funty", - "radium", - "tap", - "wyz", -] - [[package]] name = "block-buffer" version = "0.10.4" @@ -62,24 +26,12 @@ dependencies = [ "generic-array", ] -[[package]] -name = "byte-slice-cast" -version = "1.2.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c3ac9f8b63eca6fd385229b3675f6cc0dc5c8a5c8a54a59d4f52ffd670d87b0c" - [[package]] name = "cfg-if" version = "1.0.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "baf1de4339761588bc0619e3cbc0120ee582ebb74b53b4efbf79117bd2da40fd" -[[package]] -name = "const-oid" -version = "0.9.6" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c2459377285ad874054d797f3ccebf984978aa39129f6eafde5cdc8315b612f8" - [[package]] name = "cpufeatures" version = "0.2.12" @@ -89,18 +41,6 @@ dependencies = [ "libc", ] -[[package]] -name = "crypto-bigint" -version = "0.5.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0dc92fb57ca44df6db8059111ab3af99a63d5d0f8375d9972e319a379c6bab76" -dependencies = [ - "generic-array", - "rand_core", - "subtle", - "zeroize", -] - [[package]] name = "crypto-common" version = "0.1.6" @@ -111,27 +51,6 @@ dependencies = [ "typenum", ] -[[package]] -name = "der" -version = "0.7.9" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f55bf8e7b65898637379c1b74eb1551107c8294ed26d855ceb9fd1a09cfc9bc0" -dependencies = [ - "const-oid", - "zeroize", -] - -[[package]] -name = "derive_more" -version = "0.99.17" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4fb810d30a7c1953f91334de7244731fc3f3c10d7fe163338a35b9f640960321" -dependencies = [ - "proc-macro2", - "quote", - "syn 1.0.109", -] - [[package]] name = "digest" version = "0.10.7" @@ -139,68 +58,9 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "9ed9a281f7bc9b7576e61468ba615a66a5c8cfdff42420a70aa82701a3b1e292" dependencies = [ "block-buffer", - "const-oid", "crypto-common", - "subtle", -] - -[[package]] -name = "ecdsa" -version = "0.16.9" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ee27f32b5c5292967d2d4a9d7f1e0b0aed2c15daded5a60300e4abb9d8020bca" -dependencies = [ - "der", - "digest", - "elliptic-curve", - "rfc6979", - "signature", - "spki", -] - -[[package]] -name = "elliptic-curve" -version = "0.13.8" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b5e6043086bf7973472e0c7dff2142ea0b680d30e18d9cc40f267efbf222bd47" -dependencies = [ - "base16ct", - "crypto-bigint", - "digest", - "ff", - "generic-array", - "group", - "pkcs8", - "rand_core", - "sec1", - "subtle", - "tap", - "zeroize", -] - -[[package]] -name = "equivalent" -version = "1.0.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5443807d6dff69373d433ab9ef5378ad8df50ca6298caf15de6e52e24aaf54d5" - -[[package]] -name = "ff" -version = "0.13.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ded41244b729663b1e574f1b4fb731469f69f79c17667b5d776b16cda0479449" -dependencies = [ - "bitvec", - "rand_core", - "subtle", ] -[[package]] -name = "funty" -version = "2.0.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e6d5a32815ae3f33302d95fdcb2ce17862f8c65363dcfd29360480ba1001fc9c" - [[package]] name = "generic-array" version = "0.14.7" @@ -209,7 +69,6 @@ checksum = "85649ca51fd72272d7821adaf274ad91c288277713d9c18820d8499a7ff69e9a" dependencies = [ "typenum", "version_check", - "zeroize", ] [[package]] @@ -223,59 +82,6 @@ dependencies = [ "wasi", ] -[[package]] -name = "group" -version = "0.13.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f0f9ef7462f7c099f518d754361858f86d8a07af53ba9af0fe635bbccb151a63" -dependencies = [ - "ff", - "rand_core", - "subtle", -] - -[[package]] -name = "hashbrown" -version = "0.14.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "290f1a1d9242c78d09ce40a5e87e7554ee637af1351968159f4952f028f75604" - -[[package]] -name = "hex" -version = "0.4.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7f24254aa9a54b5c858eaee2f5bccdb46aaf0e486a595ed5fd8f86ba55232a70" - -[[package]] -name = "hmac" -version = "0.12.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6c49c37c09c17a53d937dfbb742eb3a961d65a994e6bcdcf37e7399d0cc8ab5e" -dependencies = [ - "digest", -] - -[[package]] -name = "impl-trait-for-tuples" -version = "0.2.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "11d7a9f6330b71fea57921c9b61c47ee6e84f72d394754eff6163ae67e7395eb" -dependencies = [ - "proc-macro2", - "quote", - "syn 1.0.109", -] - -[[package]] -name = "indexmap" -version = "2.2.6" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "168fb715dda47215e360912c096649d23d58bf392ac62f73919e831745e40f26" -dependencies = [ - "equivalent", - "hashbrown", -] - [[package]] name = "itoa" version = "1.0.11" @@ -284,7 +90,7 @@ checksum = "49f1f14873335454500d59611f1cf4a4b0f786f9ac11f4312a78e4cf2566695b" [[package]] name = "json-program" -version = "0.1.0" +version = "1.0.0-rc.1" dependencies = [ "lib", "serde", @@ -292,29 +98,15 @@ dependencies = [ "sp1-zkvm", ] -[[package]] -name = "k256" -version = "0.13.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "956ff9b67e26e1a6a866cb758f12c6f8746208489e3e4a4b5580802f2f0a587b" -dependencies = [ - "cfg-if", - "ecdsa", - "elliptic-curve", - "once_cell", - "sha2", - "signature", -] - [[package]] name = "lazy_static" -version = "1.4.0" +version = "1.5.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e2abad23fbc42b3700f2f279844dc832adb2b2eb069b2df918f455c4e18cc646" +checksum = "bbd2bcb4c963f2ddae06a2efc7e9f3591312473c50c6685e1f298068316e66fe" [[package]] name = "lib" -version = "0.1.0" +version = "1.0.0-rc.1" dependencies = [ "serde", ] @@ -331,151 +123,18 @@ version = "0.2.8" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "4ec2a862134d2a7d32d7983ddcdd1c4923530833c9f2ea1a44fc5fa473989058" -[[package]] -name = "memchr" -version = "2.7.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6c8640c5d730cb13ebd907d8d04b52f55ac9a2eec55b440c8892f40d56c76c1d" - -[[package]] -name = "num" -version = "0.4.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "35bd024e8b2ff75562e5f34e7f4905839deb4b22955ef5e73d2fea1b9813cb23" -dependencies = [ - "num-bigint", - "num-complex", - "num-integer", - "num-iter", - "num-rational", - "num-traits", -] - -[[package]] -name = "num-bigint" -version = "0.4.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c165a9ab64cf766f73521c0dd2cfdff64f488b8f0b3e621face3462d3db536d7" -dependencies = [ - "num-integer", - "num-traits", -] - -[[package]] -name = "num-complex" -version = "0.4.6" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "73f88a1307638156682bada9d7604135552957b7818057dcef22705b4d509495" -dependencies = [ - "num-traits", -] - -[[package]] -name = "num-integer" -version = "0.1.46" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7969661fd2958a5cb096e56c8e1ad0444ac2bbcd0061bd28660485a44879858f" -dependencies = [ - "num-traits", -] - -[[package]] -name = "num-iter" -version = "0.1.45" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1429034a0490724d0075ebb2bc9e875d6503c3cf69e235a8941aa757d83ef5bf" -dependencies = [ - "autocfg", - "num-integer", - "num-traits", -] - -[[package]] -name = "num-rational" -version = "0.4.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f83d14da390562dca69fc84082e73e548e1ad308d24accdedd2720017cb37824" -dependencies = [ - "num-bigint", - "num-integer", - "num-traits", -] - -[[package]] -name = "num-traits" -version = "0.2.19" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "071dfc062690e90b734c0b2273ce72ad0ffa95f0c74596bc250dcfd960262841" -dependencies = [ - "autocfg", -] - [[package]] name = "once_cell" version = "1.19.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "3fdb12b2476b595f9358c5161aa467c2438859caa136dec86c26fdd2efe17b92" -[[package]] -name = "parity-scale-codec" -version = "3.6.9" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "881331e34fa842a2fb61cc2db9643a8fedc615e47cfcc52597d1af0db9a7e8fe" -dependencies = [ - "arrayvec", - "byte-slice-cast", - "impl-trait-for-tuples", - "parity-scale-codec-derive", -] - -[[package]] -name = "parity-scale-codec-derive" -version = "3.6.9" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "be30eaf4b0a9fba5336683b38de57bb86d179a35862ba6bfcf57625d006bde5b" -dependencies = [ - "proc-macro-crate 2.0.2", - "proc-macro2", - "quote", - "syn 1.0.109", -] - -[[package]] -name = "pkcs8" -version = "0.10.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f950b2377845cebe5cf8b5165cb3cc1a5e0fa5cfa3e1f7f55707d8fd82e0a7b7" -dependencies = [ - "der", - "spki", -] - [[package]] name = "ppv-lite86" version = "0.2.17" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "5b40af805b3121feab8a3c29f04d8ad262fa8e0561883e7653e024ae4479e6de" -[[package]] -name = "proc-macro-crate" -version = "1.3.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7f4c021e1093a56626774e81216a4ce732a735e5bad4868a03f3ed65ca0c3919" -dependencies = [ - "once_cell", - "toml_edit 0.19.15", -] - -[[package]] -name = "proc-macro-crate" -version = "2.0.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b00f26d3400549137f92511a46ac1cd8ce37cb5598a96d382381458b992a5d24" -dependencies = [ - "toml_datetime", - "toml_edit 0.20.2", -] - [[package]] name = "proc-macro2" version = "1.0.81" @@ -494,12 +153,6 @@ dependencies = [ "proc-macro2", ] -[[package]] -name = "radium" -version = "0.7.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "dc33ff2d4973d518d823d61aa239014831e521c75da58e3df4840d3f47749d09" - [[package]] name = "rand" version = "0.8.5" @@ -530,78 +183,30 @@ dependencies = [ "getrandom", ] -[[package]] -name = "rfc6979" -version = "0.4.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f8dd2a808d456c4a54e300a23e9f5a67e122c3024119acbfd73e3bf664491cb2" -dependencies = [ - "hmac", - "subtle", -] - [[package]] name = "ryu" version = "1.0.17" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "e86697c916019a8588c99b5fac3cead74ec0b4b819707a682fd4d23fa0ce1ba1" -[[package]] -name = "scale-info" -version = "2.11.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7c453e59a955f81fb62ee5d596b450383d699f152d350e9d23a0db2adb78e4c0" -dependencies = [ - "cfg-if", - "derive_more", - "parity-scale-codec", - "scale-info-derive", -] - -[[package]] -name = "scale-info-derive" -version = "2.11.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "18cf6c6447f813ef19eb450e985bcce6705f9ce7660db221b59093d15c79c4b7" -dependencies = [ - "proc-macro-crate 1.3.1", - "proc-macro2", - "quote", - "syn 1.0.109", -] - -[[package]] -name = "sec1" -version = "0.7.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d3e97a565f76233a6003f9f5c54be1d9c5bdfa3eccfb189469f11ec4901c47dc" -dependencies = [ - "base16ct", - "der", - "generic-array", - "pkcs8", - "subtle", - "zeroize", -] - [[package]] name = "serde" -version = "1.0.201" +version = "1.0.204" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "780f1cebed1629e4753a1a38a3c72d30b97ec044f0aef68cb26650a3c5cf363c" +checksum = "bc76f558e0cbb2a839d37354c575f1dc3fdc6546b5be373ba43d95f231bf7c12" dependencies = [ "serde_derive", ] [[package]] name = "serde_derive" -version = "1.0.201" +version = "1.0.204" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c5e405930b9796f1c00bee880d03fc7e0bb4b9a11afc776885ffe84320da2865" +checksum = "e0cd7e117be63d3c3678776753929474f3b04a43a080c744d6b0ae2a8c28e222" dependencies = [ "proc-macro2", "quote", - "syn 2.0.60", + "syn", ] [[package]] @@ -627,83 +232,29 @@ dependencies = [ ] [[package]] -name = "signature" -version = "2.2.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "77549399552de45a898a580c1b41d445bf730df867cc44e6c0233bbc4b8329de" -dependencies = [ - "digest", - "rand_core", -] - -[[package]] -name = "snowbridge-amcl" -version = "1.0.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "460a9ed63cdf03c1b9847e8a12a5f5ba19c4efd5869e4a737e05be25d7c427e5" -dependencies = [ - "parity-scale-codec", - "scale-info", -] - -[[package]] -name = "sp1-precompiles" -version = "0.1.0" +name = "sp1-lib" +version = "1.0.0-rc.1" dependencies = [ "anyhow", "bincode", "cfg-if", - "getrandom", - "hex", - "k256", - "num", - "rand", "serde", - "snowbridge-amcl", ] [[package]] name = "sp1-zkvm" -version = "0.1.0" +version = "1.0.0-rc.1" dependencies = [ "bincode", "cfg-if", "getrandom", - "k256", "lazy_static", "libm", "once_cell", "rand", "serde", "sha2", - "sp1-precompiles", -] - -[[package]] -name = "spki" -version = "0.7.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d91ed6c858b01f942cd56b37a94b3e0a1798290327d1236e4d9cf4eaca44d29d" -dependencies = [ - "base64ct", - "der", -] - -[[package]] -name = "subtle" -version = "2.5.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "81cdd64d312baedb58e21336b31bc043b77e01cc99033ce76ef539f78e965ebc" - -[[package]] -name = "syn" -version = "1.0.109" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "72b64191b275b66ffe2469e8af2c1cfe3bafa67b529ead792a6d0160888b4237" -dependencies = [ - "proc-macro2", - "quote", - "unicode-ident", + "sp1-lib", ] [[package]] @@ -717,40 +268,6 @@ dependencies = [ "unicode-ident", ] -[[package]] -name = "tap" -version = "1.0.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "55937e1799185b12863d447f42597ed69d9928686b8d88a1df17376a097d8369" - -[[package]] -name = "toml_datetime" -version = "0.6.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7cda73e2f1397b1262d6dfdcef8aafae14d1de7748d66822d3bfeeb6d03e5e4b" - -[[package]] -name = "toml_edit" -version = "0.19.15" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1b5bb770da30e5cbfde35a2d7b9b8a2c4b8ef89548a7a6aeab5c9a576e3e7421" -dependencies = [ - "indexmap", - "toml_datetime", - "winnow", -] - -[[package]] -name = "toml_edit" -version = "0.20.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "396e4d48bbb2b7554c944bde63101b5ae446cff6ec4a24227428f15eb72ef338" -dependencies = [ - "indexmap", - "toml_datetime", - "winnow", -] - [[package]] name = "typenum" version = "1.17.0" @@ -774,27 +291,3 @@ name = "wasi" version = "0.11.0+wasi-snapshot-preview1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "9c8d87e72b64a3b4db28d11ce29237c246188f4f51057d65a7eab63b7987e423" - -[[package]] -name = "winnow" -version = "0.5.40" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f593a95398737aeed53e489c785df13f3618e41dbcd6718c6addbf1395aa6876" -dependencies = [ - "memchr", -] - -[[package]] -name = "wyz" -version = "0.5.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "05f360fc0b24296329c78fda852a1e9ae82de9cf7b27dae4b7f62f118f77b9ed" -dependencies = [ - "tap", -] - -[[package]] -name = "zeroize" -version = "1.7.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "525b4ec142c6b68a2d10f01f7bbf6755599ca3f81ea53b8431b7dd348f5fdb2d" diff --git a/examples/json/program/Cargo.toml b/examples/json/program/Cargo.toml index 344491bec9..60c7a3d9a1 100644 --- a/examples/json/program/Cargo.toml +++ b/examples/json/program/Cargo.toml @@ -1,8 +1,9 @@ [workspace] [package] -version = "0.1.0" name = "json-program" +version = "1.0.0-rc.1" edition = "2021" +publish = false [dependencies] sp1-zkvm = { path = "../../../zkvm/entrypoint" } diff --git a/examples/json/program/elf/riscv32im-succinct-zkvm-elf b/examples/json/program/elf/riscv32im-succinct-zkvm-elf index ad80a3fbb4..3960bd24dc 100755 Binary files a/examples/json/program/elf/riscv32im-succinct-zkvm-elf and b/examples/json/program/elf/riscv32im-succinct-zkvm-elf differ diff --git a/examples/json/script/Cargo.toml b/examples/json/script/Cargo.toml index 9679f5dedb..796c53eff6 100644 --- a/examples/json/script/Cargo.toml +++ b/examples/json/script/Cargo.toml @@ -1,13 +1,14 @@ [package] -version = "0.1.0" name = "json-script" -edition = "2021" +version = { workspace = true } +edition = { workspace = true } +publish = false [dependencies] serde = "1.0.197" serde_json = "1.0.114" -sp1-sdk = { path = "../../../sdk" } +sp1-sdk = { workspace = true } lib = { path = "../lib" } [build-dependencies] -sp1-helper = { path = "../../../helper" } +sp1-helper = { workspace = true } diff --git a/examples/json/script/src/main.rs b/examples/json/script/src/main.rs index 2e3a015112..fdb7c3d44a 100644 --- a/examples/json/script/src/main.rs +++ b/examples/json/script/src/main.rs @@ -1,7 +1,7 @@ //! A simple script to generate and verify the proof of a given program. use lib::{Account, Transaction}; -use sp1_sdk::{utils, ProverClient, SP1Proof, SP1Stdin}; +use sp1_sdk::{utils, ProverClient, SP1ProofWithPublicValues, SP1Stdin}; const JSON_ELF: &[u8] = include_bytes!("../../program/elf/riscv32im-succinct-zkvm-elf"); @@ -47,7 +47,7 @@ fn main() { let client = ProverClient::new(); let (pk, vk) = client.setup(JSON_ELF); - let mut proof = client.prove(&pk, stdin).expect("proving failed"); + let mut proof = client.prove(&pk, stdin).run().expect("proving failed"); // Read output. let val = proof.public_values.read::(); @@ -66,7 +66,8 @@ fn main() { proof .save("proof-with-io.bin") .expect("saving proof failed"); - let deserialized_proof = SP1Proof::load("proof-with-io.bin").expect("loading proof failed"); + let deserialized_proof = + SP1ProofWithPublicValues::load("proof-with-io.bin").expect("loading proof failed"); // Verify the deserialized proof. client diff --git a/examples/patch-testing/program/Cargo.lock b/examples/patch-testing/program/Cargo.lock new file mode 100644 index 0000000000..16f907514f --- /dev/null +++ b/examples/patch-testing/program/Cargo.lock @@ -0,0 +1,391 @@ +# This file is automatically @generated by Cargo. +# It is not intended for manual editing. +version = 3 + +[[package]] +name = "anyhow" +version = "1.0.86" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b3d1d046238990b9cf5bcde22a3fb3584ee5cf65fb2765f454ed428c7a0063da" + +[[package]] +name = "bincode" +version = "1.3.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b1f45e9417d87227c7a56d22e471c6206462cba514c7590c09aff4cf6d1ddcad" +dependencies = [ + "serde", +] + +[[package]] +name = "block-buffer" +version = "0.9.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4152116fd6e9dadb291ae18fc1ec3575ed6d84c29642d97890f4b4a3417297e4" +dependencies = [ + "generic-array", +] + +[[package]] +name = "block-buffer" +version = "0.10.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3078c7629b62d3f0439517fa394996acacc5cbc91c5a20d8c658e77abd503a71" +dependencies = [ + "generic-array", +] + +[[package]] +name = "byteorder" +version = "1.5.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1fd0f2584146f6f2ef48085050886acf353beff7305ebd1ae69500e27c67f64b" + +[[package]] +name = "cfg-if" +version = "1.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "baf1de4339761588bc0619e3cbc0120ee582ebb74b53b4efbf79117bd2da40fd" + +[[package]] +name = "cpufeatures" +version = "0.2.12" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "53fe5e26ff1b7aef8bca9c6080520cfb8d9333c7568e1829cef191a9723e5504" +dependencies = [ + "libc", +] + +[[package]] +name = "crunchy" +version = "0.2.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7a81dae078cea95a014a339291cec439d2f232ebe854a9d672b796c6afafa9b7" + +[[package]] +name = "crypto-common" +version = "0.1.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1bfb12502f3fc46cca1bb51ac28df9d618d813cdc3d2f25b9fe775a34af26bb3" +dependencies = [ + "generic-array", + "typenum", +] + +[[package]] +name = "curve25519-dalek-ng" +version = "4.1.1" +source = "git+https://github.com/sp1-patches/curve25519-dalek-ng?branch=patch-v4.1.1#f5607edd61ad8e9d80c9be933cd119f4008044d9" +dependencies = [ + "byteorder", + "digest 0.9.0", + "rand_core", + "subtle-ng", + "zeroize", +] + +[[package]] +name = "digest" +version = "0.9.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d3dd60d1080a57a05ab032377049e0591415d2b31afd7028356dbf3cc6dcb066" +dependencies = [ + "generic-array", +] + +[[package]] +name = "digest" +version = "0.10.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9ed9a281f7bc9b7576e61468ba615a66a5c8cfdff42420a70aa82701a3b1e292" +dependencies = [ + "block-buffer 0.10.4", + "crypto-common", +] + +[[package]] +name = "ed25519-consensus" +version = "2.1.0" +source = "git+https://github.com/sp1-patches/ed25519-consensus?branch=patch-v2.1.0#4fba9b0acc9fcf7a87d00da84c340d5988e3d7cb" +dependencies = [ + "curve25519-dalek-ng", + "hex", + "rand_core", + "serde", + "sha2 0.9.8", + "thiserror", + "zeroize", +] + +[[package]] +name = "generic-array" +version = "0.14.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "85649ca51fd72272d7821adaf274ad91c288277713d9c18820d8499a7ff69e9a" +dependencies = [ + "typenum", + "version_check", +] + +[[package]] +name = "getrandom" +version = "0.2.15" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c4567c8db10ae91089c99af84c68c38da3ec2f087c3f82960bcdbf3656b6f4d7" +dependencies = [ + "cfg-if", + "libc", + "wasi", +] + +[[package]] +name = "hex" +version = "0.4.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7f24254aa9a54b5c858eaee2f5bccdb46aaf0e486a595ed5fd8f86ba55232a70" + +[[package]] +name = "lazy_static" +version = "1.5.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "bbd2bcb4c963f2ddae06a2efc7e9f3591312473c50c6685e1f298068316e66fe" + +[[package]] +name = "libc" +version = "0.2.155" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "97b3888a4aecf77e811145cadf6eef5901f4782c53886191b2f693f24761847c" + +[[package]] +name = "libm" +version = "0.2.8" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4ec2a862134d2a7d32d7983ddcdd1c4923530833c9f2ea1a44fc5fa473989058" + +[[package]] +name = "once_cell" +version = "1.19.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3fdb12b2476b595f9358c5161aa467c2438859caa136dec86c26fdd2efe17b92" + +[[package]] +name = "opaque-debug" +version = "0.3.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c08d65885ee38876c4f86fa503fb49d7b507c2b62552df7c70b2fce627e06381" + +[[package]] +name = "patch-testing-program" +version = "1.0.0-rc.1" +dependencies = [ + "curve25519-dalek-ng", + "ed25519-consensus", + "sha2 0.10.8", + "sha2 0.9.8", + "sp1-zkvm", + "tiny-keccak", +] + +[[package]] +name = "ppv-lite86" +version = "0.2.17" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5b40af805b3121feab8a3c29f04d8ad262fa8e0561883e7653e024ae4479e6de" + +[[package]] +name = "proc-macro2" +version = "1.0.85" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "22244ce15aa966053a896d1accb3a6e68469b97c7f33f284b99f0d576879fc23" +dependencies = [ + "unicode-ident", +] + +[[package]] +name = "quote" +version = "1.0.36" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0fa76aaf39101c457836aec0ce2316dbdc3ab723cdda1c6bd4e6ad4208acaca7" +dependencies = [ + "proc-macro2", +] + +[[package]] +name = "rand" +version = "0.8.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "34af8d1a0e25924bc5b7c43c079c942339d8f0a8b57c39049bef581b46327404" +dependencies = [ + "libc", + "rand_chacha", + "rand_core", +] + +[[package]] +name = "rand_chacha" +version = "0.3.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e6c10a63a0fa32252be49d21e7709d4d4baf8d231c2dbce1eaa8141b9b127d88" +dependencies = [ + "ppv-lite86", + "rand_core", +] + +[[package]] +name = "rand_core" +version = "0.6.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ec0be4795e2f6a28069bec0b5ff3e2ac9bafc99e6a9a7dc3547996c5c816922c" +dependencies = [ + "getrandom", +] + +[[package]] +name = "serde" +version = "1.0.204" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "bc76f558e0cbb2a839d37354c575f1dc3fdc6546b5be373ba43d95f231bf7c12" +dependencies = [ + "serde_derive", +] + +[[package]] +name = "serde_derive" +version = "1.0.204" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e0cd7e117be63d3c3678776753929474f3b04a43a080c744d6b0ae2a8c28e222" +dependencies = [ + "proc-macro2", + "quote", + "syn", +] + +[[package]] +name = "sha2" +version = "0.9.8" +source = "git+https://github.com/sp1-patches/RustCrypto-hashes?branch=patch-sha2-v0.9.8#afdbfb09c325f8a69c01d540ec9a261e3637725d" +dependencies = [ + "block-buffer 0.9.0", + "cfg-if", + "cpufeatures", + "digest 0.9.0", + "opaque-debug", +] + +[[package]] +name = "sha2" +version = "0.10.8" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "793db75ad2bcafc3ffa7c68b215fee268f537982cd901d132f89c6343f3a3dc8" +dependencies = [ + "cfg-if", + "cpufeatures", + "digest 0.10.7", +] + +[[package]] +name = "sp1-lib" +version = "1.0.0-rc.1" +dependencies = [ + "anyhow", + "bincode", + "cfg-if", + "serde", +] + +[[package]] +name = "sp1-zkvm" +version = "1.0.0-rc.1" +dependencies = [ + "bincode", + "cfg-if", + "getrandom", + "lazy_static", + "libm", + "once_cell", + "rand", + "serde", + "sha2 0.10.8", + "sp1-lib", +] + +[[package]] +name = "subtle-ng" +version = "2.5.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "734676eb262c623cec13c3155096e08d1f8f29adce39ba17948b18dad1e54142" + +[[package]] +name = "syn" +version = "2.0.66" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c42f3f41a2de00b01c0aaad383c5a45241efc8b2d1eda5661812fda5f3cdcff5" +dependencies = [ + "proc-macro2", + "quote", + "unicode-ident", +] + +[[package]] +name = "thiserror" +version = "1.0.61" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c546c80d6be4bc6a00c0f01730c08df82eaa7a7a61f11d656526506112cc1709" +dependencies = [ + "thiserror-impl", +] + +[[package]] +name = "thiserror-impl" +version = "1.0.61" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "46c3384250002a6d5af4d114f2845d37b57521033f30d5c3f46c4d70e1197533" +dependencies = [ + "proc-macro2", + "quote", + "syn", +] + +[[package]] +name = "tiny-keccak" +version = "2.0.2" +source = "git+https://github.com/sp1-patches/tiny-keccak?branch=patch-v2.0.2#bf0b28f63510a90c7b6c21ac6ff461c93ecd2331" +dependencies = [ + "cfg-if", + "crunchy", +] + +[[package]] +name = "typenum" +version = "1.17.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "42ff0bf0c66b8238c6f3b578df37d0b7848e55df8577b3f74f92a69acceeb825" + +[[package]] +name = "unicode-ident" +version = "1.0.12" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3354b9ac3fae1ff6755cb6db53683adb661634f67557942dea4facebec0fee4b" + +[[package]] +name = "version_check" +version = "0.9.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "49874b5167b65d7193b8aba1567f5c7d93d001cafc34600cee003eda787e483f" + +[[package]] +name = "wasi" +version = "0.11.0+wasi-snapshot-preview1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9c8d87e72b64a3b4db28d11ce29237c246188f4f51057d65a7eab63b7987e423" + +[[package]] +name = "zeroize" +version = "1.8.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ced3678a2879b30306d323f4542626697a464a97c0a07c9aebf7ebca65cd4dde" + +[[patch.unused]] +name = "sha2" +version = "0.10.6" +source = "git+https://github.com/sp1-patches/RustCrypto-hashes?branch=patch-sha2-v0.10.6#e5f8b7eaaa9801503bd998932a52b65848eee234" diff --git a/examples/patch-testing/program/Cargo.toml b/examples/patch-testing/program/Cargo.toml new file mode 100644 index 0000000000..34c289601f --- /dev/null +++ b/examples/patch-testing/program/Cargo.toml @@ -0,0 +1,26 @@ +[workspace] +[package] +name = "patch-testing-program" +version = "1.0.0-rc.1" +edition = "2021" +publish = false + +[dependencies] +sp1-zkvm = { path = "../../../zkvm/entrypoint" } + +sha2-v0-9-8 = { version = "0.9.8", package = "sha2" } +# Note: Can't have sha2-v0-10-6 and v0-10-8 at the same time due to crate resolution. +sha2-v0-10-6 = { version = "0.10.6", package = "sha2" } +# sha2-v0-10-8 = { version = "0.10.8", package = "sha2" } + +ed25519-consensus = "2.1.0" +tiny-keccak = { version = "2.0.2", features = ["keccak"] } +curve25519-dalek-ng = "4.1" + +[patch.crates-io] +tiny-keccak = { git = "https://github.com/sp1-patches/tiny-keccak", branch = "patch-v2.0.2" } +ed25519-consensus = { git = "https://github.com/sp1-patches/ed25519-consensus", branch = "patch-v2.1.0" } +sha2-v0-9-8 = { git = "https://github.com/sp1-patches/RustCrypto-hashes", package = "sha2", branch = "patch-sha2-v0.9.8" } +sha2-v0-10-6 = { git = "https://github.com/sp1-patches/RustCrypto-hashes", package = "sha2", branch = "patch-sha2-v0.10.6" } +# sha2-v0-10-8 = { git = "https://github.com/sp1-patches/RustCrypto-hashes", package = "sha2", branch = "patch-sha2-v0.10.8" } +curve25519-dalek-ng = { git = "https://github.com/sp1-patches/curve25519-dalek-ng", branch = "patch-v4.1.1" } diff --git a/examples/patch-testing/program/elf/riscv32im-succinct-zkvm-elf b/examples/patch-testing/program/elf/riscv32im-succinct-zkvm-elf new file mode 100755 index 0000000000..ac3d523f9d Binary files /dev/null and b/examples/patch-testing/program/elf/riscv32im-succinct-zkvm-elf differ diff --git a/examples/patch-testing/program/src/main.rs b/examples/patch-testing/program/src/main.rs new file mode 100644 index 0000000000..e3b964af07 --- /dev/null +++ b/examples/patch-testing/program/src/main.rs @@ -0,0 +1,44 @@ +#![no_main] +sp1_zkvm::entrypoint!(main); + +use curve25519_dalek_ng::edwards::CompressedEdwardsY; +use ed25519_consensus::{Signature, VerificationKey}; +use sha2_v0_10_6::{Digest as Digest_10_6, Sha256 as Sha256_10_6}; +// use sha2_v0_10_8::{Digest as Digest_10_8, Sha256 as Sha256_10_8}; +use sha2_v0_9_8::{Digest as Digest_9_8, Sha256 as Sha256_9_8}; +use tiny_keccak::{Hasher, Keccak}; + +/// To add testing for a new patch, add a new case to the function below. +fn main() { + let input = [1u8; 32]; + + let sig: Signature = sp1_zkvm::io::read(); + let vk: VerificationKey = sp1_zkvm::io::read(); + let msg: Vec = sp1_zkvm::io::read_vec(); + + // Test Keccak. + let mut hasher = Keccak::v256(); + hasher.update(&input); + let mut output = [0u8; 32]; + hasher.finalize(&mut output); + + // Test SHA256. + let mut sha256_9_8 = Sha256_9_8::new(); + sha256_9_8.update(input); + let _ = sha256_9_8.finalize(); + + let mut sha256_10_6 = Sha256_10_6::new(); + sha256_10_6.update(input); + let _ = sha256_10_6.finalize(); + + // let mut sha256_10_8 = Sha256_10_8::new(); + // sha256_10_8.update(input); + // let output_10_8 = sha256_10_8.finalize(); + + // Test curve25519-dalek-ng. + let y = CompressedEdwardsY(input); + let _ = y.decompress(); + + // Test ed25519-consensus. + assert_eq!(vk.verify(&sig, &msg[..]), Ok(())) +} diff --git a/examples/patch-testing/script/Cargo.lock b/examples/patch-testing/script/Cargo.lock new file mode 100644 index 0000000000..0aed140cf4 --- /dev/null +++ b/examples/patch-testing/script/Cargo.lock @@ -0,0 +1,5648 @@ +# This file is automatically @generated by Cargo. +# It is not intended for manual editing. +version = 3 + +[[package]] +name = "addchain" +version = "0.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3b2e69442aa5628ea6951fa33e24efe8313f4321a91bd729fc2f75bdfc858570" +dependencies = [ + "num-bigint 0.3.3", + "num-integer", + "num-traits", +] + +[[package]] +name = "addr2line" +version = "0.21.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8a30b2e23b9e17a9f90641c7ab1549cd9b44f296d3ccbf309d2863cfe398a0cb" +dependencies = [ + "gimli", +] + +[[package]] +name = "adler" +version = "1.0.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f26201604c87b1e01bd3d98f8d5d9a8fcbb815e8cedb41ffccbeb4bf593a35fe" + +[[package]] +name = "ahash" +version = "0.8.11" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e89da841a80418a9b391ebaea17f5c112ffaaa96f621d2c285b5174da76b9011" +dependencies = [ + "cfg-if", + "once_cell", + "version_check", + "zerocopy", +] + +[[package]] +name = "aho-corasick" +version = "1.1.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8e60d3430d3a69478ad0993f19238d2df97c507009a52b3c10addcd7f6bcb916" +dependencies = [ + "memchr", +] + +[[package]] +name = "allocator-api2" +version = "0.2.18" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5c6cb57a04249c6480766f7f7cef5467412af1490f8d1e243141daddada3264f" + +[[package]] +name = "alloy" +version = "0.1.0" +source = "git+https://github.com/alloy-rs/alloy?rev=bfd0fda#bfd0fda492e560c3463d521958793c81bbeadfc1" +dependencies = [ + "alloy-contract", + "alloy-core", + "alloy-eips", + "alloy-genesis", + "alloy-provider", + "alloy-rpc-client", + "alloy-serde", + "alloy-signer", + "alloy-signer-wallet", + "alloy-transport-http", + "reqwest 0.12.4", +] + +[[package]] +name = "alloy-consensus" +version = "0.1.0" +source = "git+https://github.com/alloy-rs/alloy?rev=bfd0fda#bfd0fda492e560c3463d521958793c81bbeadfc1" +dependencies = [ + "alloy-eips", + "alloy-primitives", + "alloy-rlp", + "alloy-serde", + "serde", + "sha2 0.10.8", +] + +[[package]] +name = "alloy-contract" +version = "0.1.0" +source = "git+https://github.com/alloy-rs/alloy?rev=bfd0fda#bfd0fda492e560c3463d521958793c81bbeadfc1" +dependencies = [ + "alloy-dyn-abi", + "alloy-json-abi", + "alloy-network", + "alloy-primitives", + "alloy-provider", + "alloy-rpc-types", + "alloy-sol-types", + "alloy-transport", + "futures", + "futures-util", + "thiserror", +] + +[[package]] +name = "alloy-core" +version = "0.7.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ba1c115a94254b998be1e0318f06af03b72f54c631669cbd7801056a1bbd5701" +dependencies = [ + "alloy-dyn-abi", + "alloy-json-abi", + "alloy-primitives", + "alloy-sol-types", +] + +[[package]] +name = "alloy-dyn-abi" +version = "0.7.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "22ab339ca7b4ea9115f0578c941abc80a171edf8e5eadd01e6c4237b68db8083" +dependencies = [ + "alloy-json-abi", + "alloy-primitives", + "alloy-sol-type-parser", + "alloy-sol-types", + "const-hex", + "itoa", + "serde", + "serde_json", + "winnow 0.6.6", +] + +[[package]] +name = "alloy-eips" +version = "0.1.0" +source = "git+https://github.com/alloy-rs/alloy?rev=bfd0fda#bfd0fda492e560c3463d521958793c81bbeadfc1" +dependencies = [ + "alloy-primitives", + "alloy-rlp", + "alloy-serde", + "c-kzg", + "once_cell", + "serde", +] + +[[package]] +name = "alloy-genesis" +version = "0.1.0" +source = "git+https://github.com/alloy-rs/alloy?rev=bfd0fda#bfd0fda492e560c3463d521958793c81bbeadfc1" +dependencies = [ + "alloy-primitives", + "alloy-serde", + "serde", +] + +[[package]] +name = "alloy-json-abi" +version = "0.7.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "44294729c145cf7ae65feab544b5b81fb2bb7e2fd060214842eb3989a1e9d882" +dependencies = [ + "alloy-primitives", + "alloy-sol-type-parser", + "serde", + "serde_json", +] + +[[package]] +name = "alloy-json-rpc" +version = "0.1.0" +source = "git+https://github.com/alloy-rs/alloy?rev=bfd0fda#bfd0fda492e560c3463d521958793c81bbeadfc1" +dependencies = [ + "alloy-primitives", + "serde", + "serde_json", + "thiserror", +] + +[[package]] +name = "alloy-network" +version = "0.1.0" +source = "git+https://github.com/alloy-rs/alloy?rev=bfd0fda#bfd0fda492e560c3463d521958793c81bbeadfc1" +dependencies = [ + "alloy-consensus", + "alloy-eips", + "alloy-json-rpc", + "alloy-primitives", + "alloy-rpc-types", + "alloy-signer", + "async-trait", + "futures-utils-wasm", + "serde", + "thiserror", +] + +[[package]] +name = "alloy-primitives" +version = "0.7.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "50c715249705afa1e32be79dabfd35e2ef0f1cc02ad2cf48c9d1e20026ee637b" +dependencies = [ + "alloy-rlp", + "bytes", + "cfg-if", + "const-hex", + "derive_more", + "hex-literal", + "itoa", + "k256", + "keccak-asm", + "proptest", + "rand", + "ruint", + "serde", + "tiny-keccak", +] + +[[package]] +name = "alloy-provider" +version = "0.1.0" +source = "git+https://github.com/alloy-rs/alloy?rev=bfd0fda#bfd0fda492e560c3463d521958793c81bbeadfc1" +dependencies = [ + "alloy-json-rpc", + "alloy-network", + "alloy-primitives", + "alloy-rpc-client", + "alloy-rpc-types", + "alloy-rpc-types-trace", + "alloy-transport", + "alloy-transport-http", + "async-stream", + "async-trait", + "auto_impl", + "dashmap", + "futures", + "lru", + "reqwest 0.12.4", + "serde_json", + "tokio", + "tracing", + "url", +] + +[[package]] +name = "alloy-rlp" +version = "0.3.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8d58d9f5da7b40e9bfff0b7e7816700be4019db97d4b6359fe7f94a9e22e42ac" +dependencies = [ + "alloy-rlp-derive", + "arrayvec", + "bytes", +] + +[[package]] +name = "alloy-rlp-derive" +version = "0.3.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1a047897373be4bbb0224c1afdabca92648dc57a9c9ef6e7b0be3aff7a859c83" +dependencies = [ + "proc-macro2", + "quote", + "syn 2.0.60", +] + +[[package]] +name = "alloy-rpc-client" +version = "0.1.0" +source = "git+https://github.com/alloy-rs/alloy?rev=bfd0fda#bfd0fda492e560c3463d521958793c81bbeadfc1" +dependencies = [ + "alloy-json-rpc", + "alloy-transport", + "alloy-transport-http", + "futures", + "pin-project", + "reqwest 0.12.4", + "serde", + "serde_json", + "tokio", + "tokio-stream", + "tower", + "tracing", + "url", +] + +[[package]] +name = "alloy-rpc-types" +version = "0.1.0" +source = "git+https://github.com/alloy-rs/alloy?rev=bfd0fda#bfd0fda492e560c3463d521958793c81bbeadfc1" +dependencies = [ + "alloy-consensus", + "alloy-eips", + "alloy-genesis", + "alloy-primitives", + "alloy-rlp", + "alloy-serde", + "alloy-sol-types", + "itertools 0.12.1", + "serde", + "serde_json", + "thiserror", +] + +[[package]] +name = "alloy-rpc-types-trace" +version = "0.1.0" +source = "git+https://github.com/alloy-rs/alloy?rev=bfd0fda#bfd0fda492e560c3463d521958793c81bbeadfc1" +dependencies = [ + "alloy-primitives", + "alloy-rpc-types", + "alloy-serde", + "serde", + "serde_json", +] + +[[package]] +name = "alloy-serde" +version = "0.1.0" +source = "git+https://github.com/alloy-rs/alloy?rev=bfd0fda#bfd0fda492e560c3463d521958793c81bbeadfc1" +dependencies = [ + "alloy-primitives", + "serde", + "serde_json", +] + +[[package]] +name = "alloy-signer" +version = "0.1.0" +source = "git+https://github.com/alloy-rs/alloy?rev=bfd0fda#bfd0fda492e560c3463d521958793c81bbeadfc1" +dependencies = [ + "alloy-primitives", + "async-trait", + "auto_impl", + "elliptic-curve", + "k256", + "thiserror", +] + +[[package]] +name = "alloy-signer-wallet" +version = "0.1.0" +source = "git+https://github.com/alloy-rs/alloy?rev=bfd0fda#bfd0fda492e560c3463d521958793c81bbeadfc1" +dependencies = [ + "alloy-consensus", + "alloy-network", + "alloy-primitives", + "alloy-signer", + "async-trait", + "k256", + "rand", + "thiserror", +] + +[[package]] +name = "alloy-sol-macro" +version = "0.7.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "bef9a94a27345fb31e3fcb5f5e9f592bb4847493b07fa1e47dd9fde2222f2e28" +dependencies = [ + "alloy-json-abi", + "alloy-sol-macro-input", + "const-hex", + "heck 0.4.1", + "indexmap 2.2.6", + "proc-macro-error", + "proc-macro2", + "quote", + "syn 2.0.60", + "syn-solidity", + "tiny-keccak", +] + +[[package]] +name = "alloy-sol-macro-input" +version = "0.7.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c31fe73cd259527e24dc2dbfe64bc95e5ddfcd2b2731f670a11ff72b2be2c25b" +dependencies = [ + "alloy-json-abi", + "const-hex", + "dunce", + "heck 0.5.0", + "proc-macro2", + "quote", + "serde_json", + "syn 2.0.60", + "syn-solidity", +] + +[[package]] +name = "alloy-sol-type-parser" +version = "0.7.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8c8d6e74e4feeaa2bcfdecfd3da247ab53c67bd654ba1907270c32e02b142331" +dependencies = [ + "winnow 0.6.6", +] + +[[package]] +name = "alloy-sol-types" +version = "0.7.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "afaffed78bfb17526375754931e045f96018aa810844b29c7aef823266dd4b4b" +dependencies = [ + "alloy-json-abi", + "alloy-primitives", + "alloy-sol-macro", + "const-hex", + "serde", +] + +[[package]] +name = "alloy-transport" +version = "0.1.0" +source = "git+https://github.com/alloy-rs/alloy?rev=bfd0fda#bfd0fda492e560c3463d521958793c81bbeadfc1" +dependencies = [ + "alloy-json-rpc", + "base64 0.22.0", + "futures-util", + "futures-utils-wasm", + "serde", + "serde_json", + "thiserror", + "tokio", + "tower", + "url", + "wasm-bindgen-futures", +] + +[[package]] +name = "alloy-transport-http" +version = "0.1.0" +source = "git+https://github.com/alloy-rs/alloy?rev=bfd0fda#bfd0fda492e560c3463d521958793c81bbeadfc1" +dependencies = [ + "alloy-json-rpc", + "alloy-transport", + "reqwest 0.12.4", + "serde_json", + "tower", + "url", +] + +[[package]] +name = "android-tzdata" +version = "0.1.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e999941b234f3131b00bc13c22d06e8c5ff726d1b6318ac7eb276997bbb4fef0" + +[[package]] +name = "android_system_properties" +version = "0.1.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "819e7219dbd41043ac279b19830f2efc897156490d7fd6ea916720117ee66311" +dependencies = [ + "libc", +] + +[[package]] +name = "ansi_term" +version = "0.12.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d52a9bb7ec0cf484c551830a7ce27bd20d67eac647e1befb56b0be4ee39a55d2" +dependencies = [ + "winapi", +] + +[[package]] +name = "anstream" +version = "0.6.13" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d96bd03f33fe50a863e394ee9718a706f988b9079b20c3784fb726e7678b62fb" +dependencies = [ + "anstyle", + "anstyle-parse", + "anstyle-query", + "anstyle-wincon", + "colorchoice", + "utf8parse", +] + +[[package]] +name = "anstyle" +version = "1.0.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8901269c6307e8d93993578286ac0edf7f195079ffff5ebdeea6a59ffb7e36bc" + +[[package]] +name = "anstyle-parse" +version = "0.2.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c75ac65da39e5fe5ab759307499ddad880d724eed2f6ce5b5e8a26f4f387928c" +dependencies = [ + "utf8parse", +] + +[[package]] +name = "anstyle-query" +version = "1.0.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e28923312444cdd728e4738b3f9c9cac739500909bb3d3c94b43551b16517648" +dependencies = [ + "windows-sys 0.52.0", +] + +[[package]] +name = "anstyle-wincon" +version = "3.0.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1cd54b81ec8d6180e24654d0b371ad22fc3dd083b6ff8ba325b72e00c87660a7" +dependencies = [ + "anstyle", + "windows-sys 0.52.0", +] + +[[package]] +name = "anyhow" +version = "1.0.82" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f538837af36e6f6a9be0faa67f9a314f8119e4e4b5867c6ab40ed60360142519" + +[[package]] +name = "ark-ff" +version = "0.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6b3235cc41ee7a12aaaf2c575a2ad7b46713a8a50bda2fc3b003a04845c05dd6" +dependencies = [ + "ark-ff-asm 0.3.0", + "ark-ff-macros 0.3.0", + "ark-serialize 0.3.0", + "ark-std 0.3.0", + "derivative", + "num-bigint 0.4.4", + "num-traits", + "paste", + "rustc_version 0.3.3", + "zeroize", +] + +[[package]] +name = "ark-ff" +version = "0.4.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ec847af850f44ad29048935519032c33da8aa03340876d351dfab5660d2966ba" +dependencies = [ + "ark-ff-asm 0.4.2", + "ark-ff-macros 0.4.2", + "ark-serialize 0.4.2", + "ark-std 0.4.0", + "derivative", + "digest 0.10.7", + "itertools 0.10.5", + "num-bigint 0.4.4", + "num-traits", + "paste", + "rustc_version 0.4.0", + "zeroize", +] + +[[package]] +name = "ark-ff-asm" +version = "0.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "db02d390bf6643fb404d3d22d31aee1c4bc4459600aef9113833d17e786c6e44" +dependencies = [ + "quote", + "syn 1.0.109", +] + +[[package]] +name = "ark-ff-asm" +version = "0.4.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3ed4aa4fe255d0bc6d79373f7e31d2ea147bcf486cba1be5ba7ea85abdb92348" +dependencies = [ + "quote", + "syn 1.0.109", +] + +[[package]] +name = "ark-ff-macros" +version = "0.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "db2fd794a08ccb318058009eefdf15bcaaaaf6f8161eb3345f907222bac38b20" +dependencies = [ + "num-bigint 0.4.4", + "num-traits", + "quote", + "syn 1.0.109", +] + +[[package]] +name = "ark-ff-macros" +version = "0.4.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7abe79b0e4288889c4574159ab790824d0033b9fdcb2a112a3182fac2e514565" +dependencies = [ + "num-bigint 0.4.4", + "num-traits", + "proc-macro2", + "quote", + "syn 1.0.109", +] + +[[package]] +name = "ark-serialize" +version = "0.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1d6c2b318ee6e10f8c2853e73a83adc0ccb88995aa978d8a3408d492ab2ee671" +dependencies = [ + "ark-std 0.3.0", + "digest 0.9.0", +] + +[[package]] +name = "ark-serialize" +version = "0.4.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "adb7b85a02b83d2f22f89bd5cac66c9c89474240cb6207cb1efc16d098e822a5" +dependencies = [ + "ark-std 0.4.0", + "digest 0.10.7", + "num-bigint 0.4.4", +] + +[[package]] +name = "ark-std" +version = "0.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1df2c09229cbc5a028b1d70e00fdb2acee28b1055dfb5ca73eea49c5a25c4e7c" +dependencies = [ + "num-traits", + "rand", +] + +[[package]] +name = "ark-std" +version = "0.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "94893f1e0c6eeab764ade8dc4c0db24caf4fe7cbbaafc0eba0a9030f447b5185" +dependencies = [ + "num-traits", + "rand", +] + +[[package]] +name = "array-macro" +version = "2.1.8" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "220a2c618ab466efe41d0eace94dfeff1c35e3aa47891bdb95e1c0fefffd3c99" + +[[package]] +name = "arrayref" +version = "0.3.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6b4930d2cb77ce62f89ee5d5289b4ac049559b1c45539271f5ed4fdc7db34545" + +[[package]] +name = "arrayvec" +version = "0.7.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "96d30a06541fbafbc7f82ed10c06164cfbd2c401138f6addd8404629c4b16711" + +[[package]] +name = "async-stream" +version = "0.3.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "cd56dd203fef61ac097dd65721a419ddccb106b2d2b70ba60a6b529f03961a51" +dependencies = [ + "async-stream-impl", + "futures-core", + "pin-project-lite", +] + +[[package]] +name = "async-stream-impl" +version = "0.3.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "16e62a023e7c117e27523144c5d2459f4397fcc3cab0085af8e2224f643a0193" +dependencies = [ + "proc-macro2", + "quote", + "syn 2.0.60", +] + +[[package]] +name = "async-trait" +version = "0.1.80" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c6fa2087f2753a7da8cc1c0dbfcf89579dd57458e36769de5ac750b4671737ca" +dependencies = [ + "proc-macro2", + "quote", + "syn 2.0.60", +] + +[[package]] +name = "auto_impl" +version = "1.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3c87f3f15e7794432337fc718554eaa4dc8f04c9677a950ffe366f20a162ae42" +dependencies = [ + "proc-macro2", + "quote", + "syn 2.0.60", +] + +[[package]] +name = "autocfg" +version = "1.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f1fdabc7756949593fe60f30ec81974b613357de856987752631dea1e3394c80" + +[[package]] +name = "axum" +version = "0.7.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1236b4b292f6c4d6dc34604bb5120d85c3fe1d1aa596bd5cc52ca054d13e7b9e" +dependencies = [ + "async-trait", + "axum-core", + "bytes", + "futures-util", + "http 1.1.0", + "http-body 1.0.0", + "http-body-util", + "hyper 1.3.1", + "hyper-util", + "itoa", + "matchit", + "memchr", + "mime", + "percent-encoding", + "pin-project-lite", + "rustversion", + "serde", + "serde_json", + "serde_path_to_error", + "serde_urlencoded", + "sync_wrapper", + "tokio", + "tower", + "tower-layer", + "tower-service", + "tracing", +] + +[[package]] +name = "axum-core" +version = "0.4.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a15c63fd72d41492dc4f497196f5da1fb04fb7529e631d73630d1b491e47a2e3" +dependencies = [ + "async-trait", + "bytes", + "futures-util", + "http 1.1.0", + "http-body 1.0.0", + "http-body-util", + "mime", + "pin-project-lite", + "rustversion", + "sync_wrapper", + "tower-layer", + "tower-service", + "tracing", +] + +[[package]] +name = "backtrace" +version = "0.3.71" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "26b05800d2e817c8b3b4b54abd461726265fa9789ae34330622f2db9ee696f9d" +dependencies = [ + "addr2line", + "cc", + "cfg-if", + "libc", + "miniz_oxide", + "object", + "rustc-demangle", + "serde", +] + +[[package]] +name = "base16ct" +version = "0.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4c7f02d4ea65f2c1853089ffd8d2787bdbc63de2f0d29dedbcf8ccdfa0ccd4cf" + +[[package]] +name = "base64" +version = "0.21.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9d297deb1925b89f2ccc13d7635fa0714f12c87adce1c75356b39ca9b7178567" + +[[package]] +name = "base64" +version = "0.22.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9475866fec1451be56a3c2400fd081ff546538961565ccb5b7142cbd22bc7a51" + +[[package]] +name = "base64ct" +version = "1.6.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8c3c1a368f70d6cf7302d78f8f7093da241fb8e8807c05cc9e51a125895a6d5b" + +[[package]] +name = "bincode" +version = "1.3.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b1f45e9417d87227c7a56d22e471c6206462cba514c7590c09aff4cf6d1ddcad" +dependencies = [ + "serde", +] + +[[package]] +name = "bit-set" +version = "0.5.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0700ddab506f33b20a03b13996eccd309a48e5ff77d0d95926aa0210fb4e95f1" +dependencies = [ + "bit-vec", +] + +[[package]] +name = "bit-vec" +version = "0.6.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "349f9b6a179ed607305526ca489b34ad0a41aed5f7980fa90eb03160b69598fb" + +[[package]] +name = "bitflags" +version = "1.3.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "bef38d45163c2f1dde094a7dfd33ccf595c92905c8f8f4fdc18d06fb1037718a" + +[[package]] +name = "bitflags" +version = "2.5.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "cf4b9d6a944f767f8e5e0db018570623c85f3d925ac718db4e06d0187adb21c1" + +[[package]] +name = "bitvec" +version = "1.0.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1bc2832c24239b0141d5674bb9174f9d68a8b5b3f2753311927c172ca46f7e9c" +dependencies = [ + "funty", + "radium", + "tap", + "wyz", +] + +[[package]] +name = "blake2" +version = "0.10.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "46502ad458c9a52b69d4d4d32775c788b7a1b85e8bc9d482d92250fc0e3f8efe" +dependencies = [ + "digest 0.10.7", +] + +[[package]] +name = "blake2b_simd" +version = "1.0.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "23285ad32269793932e830392f2fe2f83e26488fd3ec778883a93c8323735780" +dependencies = [ + "arrayref", + "arrayvec", + "constant_time_eq", +] + +[[package]] +name = "blake3" +version = "1.5.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "30cca6d3674597c30ddf2c587bf8d9d65c9a84d2326d941cc79c9842dfe0ef52" +dependencies = [ + "arrayref", + "arrayvec", + "cc", + "cfg-if", + "constant_time_eq", + "rayon", +] + +[[package]] +name = "blake3-zkvm" +version = "0.1.0" +source = "git+https://github.com/sp1-patches/BLAKE3.git?branch=patch-blake3_zkvm/v.1.0.0#bac2d59f9122b07a4d91475560b4c3214ae62444" + +[[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" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3078c7629b62d3f0439517fa394996acacc5cbc91c5a20d8c658e77abd503a71" +dependencies = [ + "generic-array 0.14.7", +] + +[[package]] +name = "bls12_381" +version = "0.7.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a3c196a77437e7cc2fb515ce413a6401291578b5afc8ecb29a3c7ab957f05941" +dependencies = [ + "ff 0.12.1", + "group 0.12.1", + "pairing", + "rand_core", + "subtle", +] + +[[package]] +name = "blst" +version = "0.3.11" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c94087b935a822949d3291a9989ad2b2051ea141eda0fd4e478a75f6aa3e604b" +dependencies = [ + "cc", + "glob", + "threadpool", + "zeroize", +] + +[[package]] +name = "bumpalo" +version = "3.16.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "79296716171880943b8470b5f8d03aa55eb2e645a4874bdbb28adb49162e012c" + +[[package]] +name = "byte-slice-cast" +version = "1.2.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c3ac9f8b63eca6fd385229b3675f6cc0dc5c8a5c8a54a59d4f52ffd670d87b0c" + +[[package]] +name = "byteorder" +version = "1.5.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1fd0f2584146f6f2ef48085050886acf353beff7305ebd1ae69500e27c67f64b" + +[[package]] +name = "bytes" +version = "1.6.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "514de17de45fdb8dc022b1a7975556c53c86f9f0aa5f534b98977b171857c2c9" +dependencies = [ + "serde", +] + +[[package]] +name = "c-kzg" +version = "1.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3130f3d8717cc02e668a896af24984d5d5d4e8bf12e278e982e0f1bd88a0f9af" +dependencies = [ + "blst", + "cc", + "glob", + "hex", + "libc", + "serde", +] + +[[package]] +name = "camino" +version = "1.1.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c59e92b5a388f549b863a7bea62612c09f24c8393560709a54558a9abdfb3b9c" +dependencies = [ + "serde", +] + +[[package]] +name = "cargo-platform" +version = "0.1.8" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "24b1f0365a6c6bb4020cd05806fd0d33c44d38046b8bd7f0e40814b9763cabfc" +dependencies = [ + "serde", +] + +[[package]] +name = "cargo_metadata" +version = "0.18.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2d886547e41f740c616ae73108f6eb70afe6d940c7bc697cb30f13daec073037" +dependencies = [ + "camino", + "cargo-platform", + "semver 1.0.22", + "serde", + "serde_json", + "thiserror", +] + +[[package]] +name = "cc" +version = "1.0.95" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d32a725bc159af97c3e629873bb9f88fb8cf8a4867175f76dc987815ea07c83b" +dependencies = [ + "jobserver", + "libc", + "once_cell", +] + +[[package]] +name = "cfg-if" +version = "1.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "baf1de4339761588bc0619e3cbc0120ee582ebb74b53b4efbf79117bd2da40fd" + +[[package]] +name = "chrono" +version = "0.4.38" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a21f936df1771bf62b77f047b726c4625ff2e8aa607c01ec06e5a05bd8463401" +dependencies = [ + "android-tzdata", + "iana-time-zone", + "num-traits", + "serde", + "windows-targets 0.52.5", +] + +[[package]] +name = "clap" +version = "4.5.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "90bc066a67923782aa8515dbaea16946c5bcc5addbd668bb80af688e53e548a0" +dependencies = [ + "clap_builder", + "clap_derive", +] + +[[package]] +name = "clap_builder" +version = "4.5.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ae129e2e766ae0ec03484e609954119f123cc1fe650337e155d03b022f24f7b4" +dependencies = [ + "anstream", + "anstyle", + "clap_lex", + "strsim 0.11.1", +] + +[[package]] +name = "clap_derive" +version = "4.5.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "528131438037fd55894f62d6e9f068b8f45ac57ffa77517819645d10aed04f64" +dependencies = [ + "heck 0.5.0", + "proc-macro2", + "quote", + "syn 2.0.60", +] + +[[package]] +name = "clap_lex" +version = "0.7.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "98cc8fbded0c607b7ba9dd60cd98df59af97e84d24e49c8557331cfc26d301ce" + +[[package]] +name = "colorchoice" +version = "1.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "acbf1af155f9b9ef647e42cdc158db4b64a1b61f743629225fde6f3e0be2a7c7" + +[[package]] +name = "console" +version = "0.15.8" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0e1f83fc076bd6dd27517eacdf25fef6c4dfe5f1d7448bafaaf3a26f13b5e4eb" +dependencies = [ + "encode_unicode", + "lazy_static", + "libc", + "unicode-width", + "windows-sys 0.52.0", +] + +[[package]] +name = "const-hex" +version = "1.11.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5ba00838774b4ab0233e355d26710fbfc8327a05c017f6dc4873f876d1f79f78" +dependencies = [ + "cfg-if", + "cpufeatures", + "hex", + "proptest", + "serde", +] + +[[package]] +name = "const-oid" +version = "0.9.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c2459377285ad874054d797f3ccebf984978aa39129f6eafde5cdc8315b612f8" + +[[package]] +name = "constant_time_eq" +version = "0.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f7144d30dcf0fafbce74250a3963025d8d52177934239851c917d29f1df280c2" + +[[package]] +name = "convert_case" +version = "0.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6245d59a3e82a7fc217c5828a6692dbc6dfb63a0c8c90495621f7b9d79704a0e" + +[[package]] +name = "core-foundation" +version = "0.9.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "91e195e091a93c46f7102ec7818a2aa394e1e1771c3ab4825963fa03e45afb8f" +dependencies = [ + "core-foundation-sys", + "libc", +] + +[[package]] +name = "core-foundation-sys" +version = "0.8.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "06ea2b9bc92be3c2baa9334a323ebca2d6f074ff852cd1d7b11064035cd3868f" + +[[package]] +name = "cpufeatures" +version = "0.2.12" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "53fe5e26ff1b7aef8bca9c6080520cfb8d9333c7568e1829cef191a9723e5504" +dependencies = [ + "libc", +] + +[[package]] +name = "crossbeam" +version = "0.8.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1137cd7e7fc0fb5d3c5a8678be38ec56e819125d8d7907411fe24ccb943faca8" +dependencies = [ + "crossbeam-channel", + "crossbeam-deque", + "crossbeam-epoch", + "crossbeam-queue", + "crossbeam-utils", +] + +[[package]] +name = "crossbeam-channel" +version = "0.5.12" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ab3db02a9c5b5121e1e42fbdb1aeb65f5e02624cc58c43f2884c6ccac0b82f95" +dependencies = [ + "crossbeam-utils", +] + +[[package]] +name = "crossbeam-deque" +version = "0.8.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "613f8cc01fe9cf1a3eb3d7f488fd2fa8388403e97039e2f73692932e291a770d" +dependencies = [ + "crossbeam-epoch", + "crossbeam-utils", +] + +[[package]] +name = "crossbeam-epoch" +version = "0.9.18" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5b82ac4a3c2ca9c3460964f020e1402edd5753411d7737aa39c3714ad1b5420e" +dependencies = [ + "crossbeam-utils", +] + +[[package]] +name = "crossbeam-queue" +version = "0.3.11" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "df0346b5d5e76ac2fe4e327c5fd1118d6be7c51dfb18f9b7922923f287471e35" +dependencies = [ + "crossbeam-utils", +] + +[[package]] +name = "crossbeam-utils" +version = "0.8.19" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "248e3bacc7dc6baa3b21e405ee045c3047101a49145e7e9eca583ab4c2ca5345" + +[[package]] +name = "crunchy" +version = "0.2.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7a81dae078cea95a014a339291cec439d2f232ebe854a9d672b796c6afafa9b7" + +[[package]] +name = "crypto-bigint" +version = "0.5.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0dc92fb57ca44df6db8059111ab3af99a63d5d0f8375d9972e319a379c6bab76" +dependencies = [ + "generic-array 0.14.7", + "rand_core", + "subtle", + "zeroize", +] + +[[package]] +name = "crypto-common" +version = "0.1.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1bfb12502f3fc46cca1bb51ac28df9d618d813cdc3d2f25b9fe775a34af26bb3" +dependencies = [ + "generic-array 0.14.7", + "typenum", +] + +[[package]] +name = "curve25519-dalek" +version = "4.1.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0a677b8922c94e01bdbb12126b0bc852f00447528dee1782229af9c720c3f348" +dependencies = [ + "cfg-if", + "cpufeatures", + "curve25519-dalek-derive", + "fiat-crypto", + "platforms", + "rustc_version 0.4.0", + "subtle", + "zeroize", +] + +[[package]] +name = "curve25519-dalek-derive" +version = "0.1.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f46882e17999c6cc590af592290432be3bce0428cb0d5f8b6715e4dc7b383eb3" +dependencies = [ + "proc-macro2", + "quote", + "syn 2.0.60", +] + +[[package]] +name = "curve25519-dalek-ng" +version = "4.1.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1c359b7249347e46fb28804470d071c921156ad62b3eef5d34e2ba867533dec8" +dependencies = [ + "byteorder", + "digest 0.9.0", + "rand_core", + "subtle-ng", + "zeroize", +] + +[[package]] +name = "darling" +version = "0.20.8" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "54e36fcd13ed84ffdfda6f5be89b31287cbb80c439841fe69e04841435464391" +dependencies = [ + "darling_core", + "darling_macro", +] + +[[package]] +name = "darling_core" +version = "0.20.8" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9c2cf1c23a687a1feeb728783b993c4e1ad83d99f351801977dd809b48d0a70f" +dependencies = [ + "fnv", + "ident_case", + "proc-macro2", + "quote", + "strsim 0.10.0", + "syn 2.0.60", +] + +[[package]] +name = "darling_macro" +version = "0.20.8" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a668eda54683121533a393014d8692171709ff57a7d61f187b6e782719f8933f" +dependencies = [ + "darling_core", + "quote", + "syn 2.0.60", +] + +[[package]] +name = "dashmap" +version = "5.5.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "978747c1d849a7d2ee5e8adc0159961c48fb7e5db2f06af6723b80123bb53856" +dependencies = [ + "cfg-if", + "hashbrown 0.14.3", + "lock_api", + "once_cell", + "parking_lot_core", +] + +[[package]] +name = "data-encoding" +version = "2.5.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7e962a19be5cfc3f3bf6dd8f61eb50107f356ad6270fbb3ed41476571db78be5" + +[[package]] +name = "der" +version = "0.7.9" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f55bf8e7b65898637379c1b74eb1551107c8294ed26d855ceb9fd1a09cfc9bc0" +dependencies = [ + "const-oid", + "zeroize", +] + +[[package]] +name = "deranged" +version = "0.3.11" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b42b6fa04a440b495c8b04d0e71b707c585f83cb9cb28cf8cd0d976c315e31b4" +dependencies = [ + "powerfmt", + "serde", +] + +[[package]] +name = "derivative" +version = "2.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "fcc3dd5e9e9c0b295d6e1e4d811fb6f157d5ffd784b8d202fc62eac8035a770b" +dependencies = [ + "proc-macro2", + "quote", + "syn 1.0.109", +] + +[[package]] +name = "derive_more" +version = "0.99.17" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4fb810d30a7c1953f91334de7244731fc3f3c10d7fe163338a35b9f640960321" +dependencies = [ + "convert_case", + "proc-macro2", + "quote", + "rustc_version 0.4.0", + "syn 1.0.109", +] + +[[package]] +name = "digest" +version = "0.9.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d3dd60d1080a57a05ab032377049e0591415d2b31afd7028356dbf3cc6dcb066" +dependencies = [ + "generic-array 0.14.7", +] + +[[package]] +name = "digest" +version = "0.10.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9ed9a281f7bc9b7576e61468ba615a66a5c8cfdff42420a70aa82701a3b1e292" +dependencies = [ + "block-buffer 0.10.4", + "const-oid", + "crypto-common", + "subtle", +] + +[[package]] +name = "dirs" +version = "5.0.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "44c45a9d03d6676652bcb5e724c7e988de1acad23a711b5217ab9cbecbec2225" +dependencies = [ + "dirs-sys", +] + +[[package]] +name = "dirs-sys" +version = "0.4.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "520f05a5cbd335fae5a99ff7a6ab8627577660ee5cfd6a94a6a929b52ff0321c" +dependencies = [ + "libc", + "option-ext", + "redox_users", + "windows-sys 0.48.0", +] + +[[package]] +name = "dotenv" +version = "0.15.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "77c90badedccf4105eca100756a0b1289e191f6fcbdadd3cee1d2f614f97da8f" + +[[package]] +name = "downcast-rs" +version = "1.2.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "75b325c5dbd37f80359721ad39aca5a29fb04c89279657cffdda8736d0c0b9d2" + +[[package]] +name = "dunce" +version = "1.0.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "56ce8c6da7551ec6c462cbaf3bfbc75131ebbfa1c944aeaa9dab51ca1c5f0c3b" + +[[package]] +name = "ecdsa" +version = "0.16.9" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ee27f32b5c5292967d2d4a9d7f1e0b0aed2c15daded5a60300e4abb9d8020bca" +dependencies = [ + "der", + "digest 0.10.7", + "elliptic-curve", + "rfc6979", + "signature", + "spki", +] + +[[package]] +name = "ed25519" +version = "2.2.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "115531babc129696a58c64a4fef0a8bf9e9698629fb97e9e40767d235cfbcd53" +dependencies = [ + "pkcs8", + "signature", +] + +[[package]] +name = "ed25519-consensus" +version = "2.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3c8465edc8ee7436ffea81d21a019b16676ee3db267aa8d5a8d729581ecf998b" +dependencies = [ + "curve25519-dalek-ng", + "hex", + "rand_core", + "sha2 0.9.9", + "zeroize", +] + +[[package]] +name = "either" +version = "1.11.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a47c1c47d2f5964e29c61246e81db715514cd532db6b5116a25ea3c03d6780a2" + +[[package]] +name = "elf" +version = "0.7.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4445909572dbd556c457c849c4ca58623d84b27c8fff1e74b0b4227d8b90d17b" + +[[package]] +name = "elliptic-curve" +version = "0.13.8" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b5e6043086bf7973472e0c7dff2142ea0b680d30e18d9cc40f267efbf222bd47" +dependencies = [ + "base16ct", + "crypto-bigint", + "digest 0.10.7", + "ff 0.13.0", + "generic-array 0.14.7", + "group 0.13.0", + "pkcs8", + "rand_core", + "sec1", + "subtle", + "zeroize", +] + +[[package]] +name = "encode_unicode" +version = "0.3.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a357d28ed41a50f9c765dbfe56cbc04a64e53e5fc58ba79fbc34c10ef3df831f" + +[[package]] +name = "encoding_rs" +version = "0.8.34" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b45de904aa0b010bce2ab45264d0631681847fa7b6f2eaa7dab7619943bc4f59" +dependencies = [ + "cfg-if", +] + +[[package]] +name = "enum-as-inner" +version = "0.6.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5ffccbb6966c05b32ef8fbac435df276c4ae4d3dc55a8cd0eb9745e6c12f546a" +dependencies = [ + "heck 0.4.1", + "proc-macro2", + "quote", + "syn 2.0.60", +] + +[[package]] +name = "equivalent" +version = "1.0.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5443807d6dff69373d433ab9ef5378ad8df50ca6298caf15de6e52e24aaf54d5" + +[[package]] +name = "errno" +version = "0.3.8" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a258e46cdc063eb8519c00b9fc845fc47bcfca4130e2f08e88665ceda8474245" +dependencies = [ + "libc", + "windows-sys 0.52.0", +] + +[[package]] +name = "fastrand" +version = "2.0.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "658bd65b1cf4c852a3cc96f18a8ce7b5640f6b703f905c7d74532294c2a63984" + +[[package]] +name = "fastrlp" +version = "0.3.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "139834ddba373bbdd213dffe02c8d110508dcf1726c2be27e8d1f7d7e1856418" +dependencies = [ + "arrayvec", + "auto_impl", + "bytes", +] + +[[package]] +name = "ff" +version = "0.12.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d013fc25338cc558c5c2cfbad646908fb23591e2404481826742b651c9af7160" +dependencies = [ + "bitvec", + "rand_core", + "subtle", +] + +[[package]] +name = "ff" +version = "0.13.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ded41244b729663b1e574f1b4fb731469f69f79c17667b5d776b16cda0479449" +dependencies = [ + "bitvec", + "byteorder", + "ff_derive", + "rand_core", + "subtle", +] + +[[package]] +name = "ff_derive" +version = "0.13.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e9f54704be45ed286151c5e11531316eaef5b8f5af7d597b806fdb8af108d84a" +dependencies = [ + "addchain", + "cfg-if", + "num-bigint 0.3.3", + "num-integer", + "num-traits", + "proc-macro2", + "quote", + "syn 1.0.109", +] + +[[package]] +name = "fiat-crypto" +version = "0.2.8" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "38793c55593b33412e3ae40c2c9781ffaa6f438f6f8c10f24e71846fbd7ae01e" + +[[package]] +name = "fixed-hash" +version = "0.8.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "835c052cb0c08c1acf6ffd71c022172e18723949c8282f2b9f27efbc51e64534" +dependencies = [ + "byteorder", + "rand", + "rustc-hex", + "static_assertions", +] + +[[package]] +name = "flex-error" +version = "0.4.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c606d892c9de11507fa0dcffc116434f94e105d0bbdc4e405b61519464c49d7b" +dependencies = [ + "paste", +] + +[[package]] +name = "fnv" +version = "1.0.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3f9eec918d3f24069decb9af1554cad7c880e2da24a9afd88aca000531ab82c1" + +[[package]] +name = "foreign-types" +version = "0.3.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f6f339eb8adc052cd2ca78910fda869aefa38d22d5cb648e6485e4d3fc06f3b1" +dependencies = [ + "foreign-types-shared", +] + +[[package]] +name = "foreign-types-shared" +version = "0.1.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "00b0228411908ca8685dba7fc2cdd70ec9990a6e753e89b6ac91a84c40fbaf4b" + +[[package]] +name = "form_urlencoded" +version = "1.2.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e13624c2627564efccf4934284bdd98cbaa14e79b0b5a141218e507b3a823456" +dependencies = [ + "percent-encoding", +] + +[[package]] +name = "funty" +version = "2.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e6d5a32815ae3f33302d95fdcb2ce17862f8c65363dcfd29360480ba1001fc9c" + +[[package]] +name = "futures" +version = "0.3.30" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "645c6916888f6cb6350d2550b80fb63e734897a8498abe35cfb732b6487804b0" +dependencies = [ + "futures-channel", + "futures-core", + "futures-executor", + "futures-io", + "futures-sink", + "futures-task", + "futures-util", +] + +[[package]] +name = "futures-channel" +version = "0.3.30" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "eac8f7d7865dcb88bd4373ab671c8cf4508703796caa2b1985a9ca867b3fcb78" +dependencies = [ + "futures-core", + "futures-sink", +] + +[[package]] +name = "futures-core" +version = "0.3.30" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "dfc6580bb841c5a68e9ef15c77ccc837b40a7504914d52e47b8b0e9bbda25a1d" + +[[package]] +name = "futures-executor" +version = "0.3.30" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a576fc72ae164fca6b9db127eaa9a9dda0d61316034f33a0a0d4eda41f02b01d" +dependencies = [ + "futures-core", + "futures-task", + "futures-util", +] + +[[package]] +name = "futures-io" +version = "0.3.30" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a44623e20b9681a318efdd71c299b6b222ed6f231972bfe2f224ebad6311f0c1" + +[[package]] +name = "futures-macro" +version = "0.3.30" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "87750cf4b7a4c0625b1529e4c543c2182106e4dedc60a2a6455e00d212c489ac" +dependencies = [ + "proc-macro2", + "quote", + "syn 2.0.60", +] + +[[package]] +name = "futures-sink" +version = "0.3.30" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9fb8e00e87438d937621c1c6269e53f536c14d3fbd6a042bb24879e57d474fb5" + +[[package]] +name = "futures-task" +version = "0.3.30" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "38d84fa142264698cdce1a9f9172cf383a0c82de1bddcf3092901442c4097004" + +[[package]] +name = "futures-util" +version = "0.3.30" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3d6401deb83407ab3da39eba7e33987a73c3df0c82b4bb5813ee871c19c41d48" +dependencies = [ + "futures-channel", + "futures-core", + "futures-io", + "futures-macro", + "futures-sink", + "futures-task", + "memchr", + "pin-project-lite", + "pin-utils", + "slab", +] + +[[package]] +name = "futures-utils-wasm" +version = "0.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "42012b0f064e01aa58b545fe3727f90f7dd4020f4a3ea735b50344965f5a57e9" + +[[package]] +name = "gcd" +version = "2.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1d758ba1b47b00caf47f24925c0074ecb20d6dfcffe7f6d53395c0465674841a" + +[[package]] +name = "generic-array" +version = "0.14.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "85649ca51fd72272d7821adaf274ad91c288277713d9c18820d8499a7ff69e9a" +dependencies = [ + "typenum", + "version_check", + "zeroize", +] + +[[package]] +name = "generic-array" +version = "1.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "fe739944a5406424e080edccb6add95685130b9f160d5407c639c7df0c5836b0" +dependencies = [ + "serde", + "typenum", +] + +[[package]] +name = "getrandom" +version = "0.2.14" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "94b22e06ecb0110981051723910cbf0b5f5e09a2062dd7663334ee79a9d1286c" +dependencies = [ + "cfg-if", + "libc", + "wasi", +] + +[[package]] +name = "gimli" +version = "0.28.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4271d37baee1b8c7e4b708028c57d816cf9d2434acb33a549475f78c181f6253" + +[[package]] +name = "git2" +version = "0.18.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "232e6a7bfe35766bf715e55a88b39a700596c0ccfd88cd3680b4cdb40d66ef70" +dependencies = [ + "bitflags 2.5.0", + "libc", + "libgit2-sys", + "log", + "url", +] + +[[package]] +name = "glob" +version = "0.3.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d2fabcfbdc87f4758337ca535fb41a6d701b65693ce38287d856d1674551ec9b" + +[[package]] +name = "group" +version = "0.12.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5dfbfb3a6cfbd390d5c9564ab283a0349b9b9fcd46a706c1eb10e0db70bfbac7" +dependencies = [ + "ff 0.12.1", + "memuse", + "rand_core", + "subtle", +] + +[[package]] +name = "group" +version = "0.13.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f0f9ef7462f7c099f518d754361858f86d8a07af53ba9af0fe635bbccb151a63" +dependencies = [ + "ff 0.13.0", + "rand_core", + "subtle", +] + +[[package]] +name = "h2" +version = "0.3.26" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "81fe527a889e1532da5c525686d96d4c2e74cdd345badf8dfef9f6b39dd5f5e8" +dependencies = [ + "bytes", + "fnv", + "futures-core", + "futures-sink", + "futures-util", + "http 0.2.12", + "indexmap 2.2.6", + "slab", + "tokio", + "tokio-util", + "tracing", +] + +[[package]] +name = "h2" +version = "0.4.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "816ec7294445779408f36fe57bc5b7fc1cf59664059096c65f905c1c61f58069" +dependencies = [ + "bytes", + "fnv", + "futures-core", + "futures-sink", + "futures-util", + "http 1.1.0", + "indexmap 2.2.6", + "slab", + "tokio", + "tokio-util", + "tracing", +] + +[[package]] +name = "half" +version = "1.8.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1b43ede17f21864e81be2fa654110bf1e793774238d86ef8555c37e6519c0403" + +[[package]] +name = "halo2" +version = "0.1.0-beta.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2a23c779b38253fe1538102da44ad5bd5378495a61d2c4ee18d64eaa61ae5995" +dependencies = [ + "halo2_proofs", +] + +[[package]] +name = "halo2_proofs" +version = "0.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e925780549adee8364c7f2b685c753f6f3df23bde520c67416e93bf615933760" +dependencies = [ + "blake2b_simd", + "ff 0.12.1", + "group 0.12.1", + "pasta_curves 0.4.1", + "rand_core", + "rayon", +] + +[[package]] +name = "hashbrown" +version = "0.12.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8a9ee70c43aaf417c914396645a0fa852624801b24ebb7ae78fe8272889ac888" + +[[package]] +name = "hashbrown" +version = "0.14.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "290f1a1d9242c78d09ce40a5e87e7554ee637af1351968159f4952f028f75604" +dependencies = [ + "ahash", + "allocator-api2", +] + +[[package]] +name = "heck" +version = "0.4.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "95505c38b4572b2d910cecb0281560f54b440a19336cbbcb27bf6ce6adc6f5a8" + +[[package]] +name = "heck" +version = "0.5.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2304e00983f87ffb38b55b444b5e3b60a884b5d30c0fca7d82fe33449bbe55ea" + +[[package]] +name = "hermit-abi" +version = "0.3.9" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d231dfb89cfffdbc30e7fc41579ed6066ad03abda9e567ccafae602b97ec5024" + +[[package]] +name = "hex" +version = "0.4.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7f24254aa9a54b5c858eaee2f5bccdb46aaf0e486a595ed5fd8f86ba55232a70" +dependencies = [ + "serde", +] + +[[package]] +name = "hex-literal" +version = "0.4.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6fe2267d4ed49bc07b63801559be28c718ea06c4738b7a03c94df7386d2cde46" + +[[package]] +name = "hickory-proto" +version = "0.24.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "07698b8420e2f0d6447a436ba999ec85d8fbf2a398bbd737b82cac4a2e96e512" +dependencies = [ + "async-trait", + "cfg-if", + "data-encoding", + "enum-as-inner", + "futures-channel", + "futures-io", + "futures-util", + "idna 0.4.0", + "ipnet", + "once_cell", + "rand", + "thiserror", + "tinyvec", + "tokio", + "tracing", + "url", +] + +[[package]] +name = "hickory-resolver" +version = "0.24.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "28757f23aa75c98f254cf0405e6d8c25b831b32921b050a66692427679b1f243" +dependencies = [ + "cfg-if", + "futures-util", + "hickory-proto", + "ipconfig", + "lru-cache", + "once_cell", + "parking_lot", + "rand", + "resolv-conf", + "smallvec", + "thiserror", + "tokio", + "tracing", +] + +[[package]] +name = "hmac" +version = "0.12.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6c49c37c09c17a53d937dfbb742eb3a961d65a994e6bcdcf37e7399d0cc8ab5e" +dependencies = [ + "digest 0.10.7", +] + +[[package]] +name = "hostname" +version = "0.3.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3c731c3e10504cc8ed35cfe2f1db4c9274c3d35fa486e3b31df46f068ef3e867" +dependencies = [ + "libc", + "match_cfg", + "winapi", +] + +[[package]] +name = "http" +version = "0.2.12" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "601cbb57e577e2f5ef5be8e7b83f0f63994f25aa94d673e54a92d5c516d101f1" +dependencies = [ + "bytes", + "fnv", + "itoa", +] + +[[package]] +name = "http" +version = "1.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "21b9ddb458710bc376481b842f5da65cdf31522de232c1ca8146abce2a358258" +dependencies = [ + "bytes", + "fnv", + "itoa", +] + +[[package]] +name = "http-body" +version = "0.4.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7ceab25649e9960c0311ea418d17bee82c0dcec1bd053b5f9a66e265a693bed2" +dependencies = [ + "bytes", + "http 0.2.12", + "pin-project-lite", +] + +[[package]] +name = "http-body" +version = "1.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1cac85db508abc24a2e48553ba12a996e87244a0395ce011e62b37158745d643" +dependencies = [ + "bytes", + "http 1.1.0", +] + +[[package]] +name = "http-body-util" +version = "0.1.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0475f8b2ac86659c21b64320d5d653f9efe42acd2a4e560073ec61a155a34f1d" +dependencies = [ + "bytes", + "futures-core", + "http 1.1.0", + "http-body 1.0.0", + "pin-project-lite", +] + +[[package]] +name = "httparse" +version = "1.8.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d897f394bad6a705d5f4104762e116a75639e470d80901eed05a860a95cb1904" + +[[package]] +name = "httpdate" +version = "1.0.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "df3b46402a9d5adb4c86a0cf463f42e19994e3ee891101b1841f30a545cb49a9" + +[[package]] +name = "hyper" +version = "0.14.28" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "bf96e135eb83a2a8ddf766e426a841d8ddd7449d5f00d34ea02b41d2f19eef80" +dependencies = [ + "bytes", + "futures-channel", + "futures-core", + "futures-util", + "h2 0.3.26", + "http 0.2.12", + "http-body 0.4.6", + "httparse", + "httpdate", + "itoa", + "pin-project-lite", + "socket2", + "tokio", + "tower-service", + "tracing", + "want", +] + +[[package]] +name = "hyper" +version = "1.3.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "fe575dd17d0862a9a33781c8c4696a55c320909004a67a00fb286ba8b1bc496d" +dependencies = [ + "bytes", + "futures-channel", + "futures-util", + "h2 0.4.4", + "http 1.1.0", + "http-body 1.0.0", + "httparse", + "httpdate", + "itoa", + "pin-project-lite", + "smallvec", + "tokio", + "want", +] + +[[package]] +name = "hyper-rustls" +version = "0.24.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ec3efd23720e2049821a693cbc7e65ea87c72f1c58ff2f9522ff332b1491e590" +dependencies = [ + "futures-util", + "http 0.2.12", + "hyper 0.14.28", + "rustls", + "tokio", + "tokio-rustls", +] + +[[package]] +name = "hyper-tls" +version = "0.5.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d6183ddfa99b85da61a140bea0efc93fdf56ceaa041b37d553518030827f9905" +dependencies = [ + "bytes", + "hyper 0.14.28", + "native-tls", + "tokio", + "tokio-native-tls", +] + +[[package]] +name = "hyper-tls" +version = "0.6.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "70206fc6890eaca9fde8a0bf71caa2ddfc9fe045ac9e5c70df101a7dbde866e0" +dependencies = [ + "bytes", + "http-body-util", + "hyper 1.3.1", + "hyper-util", + "native-tls", + "tokio", + "tokio-native-tls", + "tower-service", +] + +[[package]] +name = "hyper-util" +version = "0.1.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ca38ef113da30126bbff9cd1705f9273e15d45498615d138b0c20279ac7a76aa" +dependencies = [ + "bytes", + "futures-channel", + "futures-util", + "http 1.1.0", + "http-body 1.0.0", + "hyper 1.3.1", + "pin-project-lite", + "socket2", + "tokio", + "tower", + "tower-service", + "tracing", +] + +[[package]] +name = "iana-time-zone" +version = "0.1.60" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e7ffbb5a1b541ea2561f8c41c087286cc091e21e556a4f09a8f6cbf17b69b141" +dependencies = [ + "android_system_properties", + "core-foundation-sys", + "iana-time-zone-haiku", + "js-sys", + "wasm-bindgen", + "windows-core", +] + +[[package]] +name = "iana-time-zone-haiku" +version = "0.1.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f31827a206f56af32e590ba56d5d2d085f558508192593743f16b2306495269f" +dependencies = [ + "cc", +] + +[[package]] +name = "ident_case" +version = "1.0.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b9e0384b61958566e926dc50660321d12159025e767c18e043daf26b70104c39" + +[[package]] +name = "idna" +version = "0.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7d20d6b07bfbc108882d88ed8e37d39636dcc260e15e30c45e6ba089610b917c" +dependencies = [ + "unicode-bidi", + "unicode-normalization", +] + +[[package]] +name = "idna" +version = "0.5.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "634d9b1461af396cad843f47fdba5597a4f9e6ddd4bfb6ff5d85028c25cb12f6" +dependencies = [ + "unicode-bidi", + "unicode-normalization", +] + +[[package]] +name = "impl-codec" +version = "0.6.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ba6a270039626615617f3f36d15fc827041df3b78c439da2cadfa47455a77f2f" +dependencies = [ + "parity-scale-codec", +] + +[[package]] +name = "impl-trait-for-tuples" +version = "0.2.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "11d7a9f6330b71fea57921c9b61c47ee6e84f72d394754eff6163ae67e7395eb" +dependencies = [ + "proc-macro2", + "quote", + "syn 1.0.109", +] + +[[package]] +name = "indexmap" +version = "1.9.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "bd070e393353796e801d209ad339e89596eb4c8d430d18ede6a1cced8fafbd99" +dependencies = [ + "autocfg", + "hashbrown 0.12.3", + "serde", +] + +[[package]] +name = "indexmap" +version = "2.2.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "168fb715dda47215e360912c096649d23d58bf392ac62f73919e831745e40f26" +dependencies = [ + "equivalent", + "hashbrown 0.14.3", + "serde", +] + +[[package]] +name = "indicatif" +version = "0.17.8" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "763a5a8f45087d6bcea4222e7b72c291a054edf80e4ef6efd2a4979878c7bea3" +dependencies = [ + "console", + "instant", + "number_prefix", + "portable-atomic", + "unicode-width", +] + +[[package]] +name = "instant" +version = "0.1.12" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7a5bbe824c507c5da5956355e86a746d82e0e1464f65d862cc5e71da70e94b2c" +dependencies = [ + "cfg-if", +] + +[[package]] +name = "ipconfig" +version = "0.3.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b58db92f96b720de98181bbbe63c831e87005ab460c1bf306eb2622b4707997f" +dependencies = [ + "socket2", + "widestring", + "windows-sys 0.48.0", + "winreg 0.50.0", +] + +[[package]] +name = "ipnet" +version = "2.9.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8f518f335dce6725a761382244631d86cf0ccb2863413590b31338feb467f9c3" + +[[package]] +name = "itertools" +version = "0.10.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b0fd2260e829bddf4cb6ea802289de2f86d6a7a690192fbe91b3f46e0f2c8473" +dependencies = [ + "either", +] + +[[package]] +name = "itertools" +version = "0.12.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ba291022dbbd398a455acf126c1e341954079855bc60dfdda641363bd6922569" +dependencies = [ + "either", +] + +[[package]] +name = "itoa" +version = "1.0.11" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "49f1f14873335454500d59611f1cf4a4b0f786f9ac11f4312a78e4cf2566695b" + +[[package]] +name = "jobserver" +version = "0.1.31" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d2b099aaa34a9751c5bf0878add70444e1ed2dd73f347be99003d4577277de6e" +dependencies = [ + "libc", +] + +[[package]] +name = "js-sys" +version = "0.3.69" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "29c15563dc2726973df627357ce0c9ddddbea194836909d655df6a75d2cf296d" +dependencies = [ + "wasm-bindgen", +] + +[[package]] +name = "jubjub" +version = "0.9.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a575df5f985fe1cd5b2b05664ff6accfc46559032b954529fd225a2168d27b0f" +dependencies = [ + "bitvec", + "bls12_381", + "ff 0.12.1", + "group 0.12.1", + "rand_core", + "subtle", +] + +[[package]] +name = "k256" +version = "0.13.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "956ff9b67e26e1a6a866cb758f12c6f8746208489e3e4a4b5580802f2f0a587b" +dependencies = [ + "cfg-if", + "ecdsa", + "elliptic-curve", + "once_cell", + "sha2 0.10.8", + "signature", +] + +[[package]] +name = "keccak" +version = "0.1.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ecc2af9a1119c51f12a14607e783cb977bde58bc069ff0c3da1095e635d70654" +dependencies = [ + "cpufeatures", +] + +[[package]] +name = "keccak-asm" +version = "0.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "bb8515fff80ed850aea4a1595f2e519c003e2a00a82fe168ebf5269196caf444" +dependencies = [ + "digest 0.10.7", + "sha3-asm", +] + +[[package]] +name = "lazy_static" +version = "1.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e2abad23fbc42b3700f2f279844dc832adb2b2eb069b2df918f455c4e18cc646" +dependencies = [ + "spin 0.5.2", +] + +[[package]] +name = "libc" +version = "0.2.153" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9c198f91728a82281a64e1f4f9eeb25d82cb32a5de251c6bd1b5154d63a8e7bd" + +[[package]] +name = "libgit2-sys" +version = "0.16.2+1.7.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ee4126d8b4ee5c9d9ea891dd875cfdc1e9d0950437179104b183d7d8a74d24e8" +dependencies = [ + "cc", + "libc", + "libz-sys", + "pkg-config", +] + +[[package]] +name = "libm" +version = "0.2.8" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4ec2a862134d2a7d32d7983ddcdd1c4923530833c9f2ea1a44fc5fa473989058" + +[[package]] +name = "libredox" +version = "0.1.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c0ff37bd590ca25063e35af745c343cb7a0271906fb7b37e4813e8f79f00268d" +dependencies = [ + "bitflags 2.5.0", + "libc", +] + +[[package]] +name = "libz-sys" +version = "1.1.16" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5e143b5e666b2695d28f6bca6497720813f699c9602dd7f5cac91008b8ada7f9" +dependencies = [ + "cc", + "libc", + "pkg-config", + "vcpkg", +] + +[[package]] +name = "linked-hash-map" +version = "0.5.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0717cef1bc8b636c6e1c1bbdefc09e6322da8a9321966e8928ef80d20f7f770f" + +[[package]] +name = "linux-raw-sys" +version = "0.4.13" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "01cda141df6706de531b6c46c3a33ecca755538219bd484262fa09410c13539c" + +[[package]] +name = "lock_api" +version = "0.4.11" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3c168f8615b12bc01f9c17e2eb0cc07dcae1940121185446edc3744920e8ef45" +dependencies = [ + "autocfg", + "scopeguard", +] + +[[package]] +name = "log" +version = "0.4.21" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "90ed8c1e510134f979dbc4f070f87d4313098b704861a105fe34231c70a3901c" + +[[package]] +name = "lru" +version = "0.12.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d3262e75e648fce39813cb56ac41f3c3e3f65217ebf3844d818d1f9398cfb0dc" +dependencies = [ + "hashbrown 0.14.3", +] + +[[package]] +name = "lru-cache" +version = "0.1.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "31e24f1ad8321ca0e8a1e0ac13f23cb668e6f5466c2c57319f6a5cf1cc8e3b1c" +dependencies = [ + "linked-hash-map", +] + +[[package]] +name = "match_cfg" +version = "0.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ffbee8634e0d45d258acb448e7eaab3fce7a0a467395d4d9f228e3c1f01fb2e4" + +[[package]] +name = "matchers" +version = "0.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8263075bb86c5a1b1427b5ae862e8889656f126e9f77c484496e8b47cf5c5558" +dependencies = [ + "regex-automata 0.1.10", +] + +[[package]] +name = "matchit" +version = "0.7.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0e7465ac9959cc2b1404e8e2367b43684a6d13790fe23056cc8c6c5a6b7bcb94" + +[[package]] +name = "memchr" +version = "2.7.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6c8640c5d730cb13ebd907d8d04b52f55ac9a2eec55b440c8892f40d56c76c1d" + +[[package]] +name = "memuse" +version = "0.2.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2145869435ace5ea6ea3d35f59be559317ec9a0d04e1812d5f185a87b6d36f1a" + +[[package]] +name = "mime" +version = "0.3.17" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6877bb514081ee2a7ff5ef9de3281f14a4dd4bceac4c09388074a6b5df8a139a" + +[[package]] +name = "mime_guess" +version = "2.0.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4192263c238a5f0d0c6bfd21f336a313a4ce1c450542449ca191bb657b4642ef" +dependencies = [ + "mime", + "unicase", +] + +[[package]] +name = "miniz_oxide" +version = "0.7.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9d811f3e15f28568be3407c8e7fdb6514c1cda3cb30683f15b6a1a1dc4ea14a7" +dependencies = [ + "adler", +] + +[[package]] +name = "mio" +version = "0.8.11" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a4a650543ca06a924e8b371db273b2756685faae30f8487da1b56505a8f78b0c" +dependencies = [ + "libc", + "wasi", + "windows-sys 0.48.0", +] + +[[package]] +name = "native-tls" +version = "0.2.11" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "07226173c32f2926027b63cce4bcd8076c3552846cbe7925f3aaffeac0a3b92e" +dependencies = [ + "lazy_static", + "libc", + "log", + "openssl", + "openssl-probe", + "openssl-sys", + "schannel", + "security-framework", + "security-framework-sys", + "tempfile", +] + +[[package]] +name = "nohash-hasher" +version = "0.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2bf50223579dc7cdcfb3bfcacf7069ff68243f8c363f62ffa99cf000a6b9c451" + +[[package]] +name = "nu-ansi-term" +version = "0.46.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "77a8165726e8236064dbb45459242600304b42a5ea24ee2948e18e023bf7ba84" +dependencies = [ + "overload", + "winapi", +] + +[[package]] +name = "num" +version = "0.4.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3135b08af27d103b0a51f2ae0f8632117b7b185ccf931445affa8df530576a41" +dependencies = [ + "num-bigint 0.4.4", + "num-complex", + "num-integer", + "num-iter", + "num-rational", + "num-traits", +] + +[[package]] +name = "num-bigint" +version = "0.3.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5f6f7833f2cbf2360a6cfd58cd41a53aa7a90bd4c202f5b1c7dd2ed73c57b2c3" +dependencies = [ + "autocfg", + "num-integer", + "num-traits", +] + +[[package]] +name = "num-bigint" +version = "0.4.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "608e7659b5c3d7cba262d894801b9ec9d00de989e8a82bd4bef91d08da45cdc0" +dependencies = [ + "autocfg", + "num-integer", + "num-traits", +] + +[[package]] +name = "num-complex" +version = "0.4.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "23c6602fda94a57c990fe0df199a035d83576b496aa29f4e634a8ac6004e68a6" +dependencies = [ + "num-traits", +] + +[[package]] +name = "num-conv" +version = "0.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "51d515d32fb182ee37cda2ccdcb92950d6a3c2893aa280e540671c2cd0f3b1d9" + +[[package]] +name = "num-derive" +version = "0.3.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "876a53fff98e03a936a674b29568b0e605f06b29372c2489ff4de23f1949743d" +dependencies = [ + "proc-macro2", + "quote", + "syn 1.0.109", +] + +[[package]] +name = "num-integer" +version = "0.1.46" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7969661fd2958a5cb096e56c8e1ad0444ac2bbcd0061bd28660485a44879858f" +dependencies = [ + "num-traits", +] + +[[package]] +name = "num-iter" +version = "0.1.44" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d869c01cc0c455284163fd0092f1f93835385ccab5a98a0dcc497b2f8bf055a9" +dependencies = [ + "autocfg", + "num-integer", + "num-traits", +] + +[[package]] +name = "num-rational" +version = "0.4.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0638a1c9d0a3c0914158145bc76cff373a75a627e6ecbfb71cbe6f453a5a19b0" +dependencies = [ + "autocfg", + "num-bigint 0.4.4", + "num-integer", + "num-traits", +] + +[[package]] +name = "num-traits" +version = "0.2.18" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "da0df0e5185db44f69b44f26786fe401b6c293d1907744beaa7fa62b2e5a517a" +dependencies = [ + "autocfg", + "libm", +] + +[[package]] +name = "num_cpus" +version = "1.16.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4161fcb6d602d4d2081af7c3a45852d875a03dd337a6bfdd6e06407b61342a43" +dependencies = [ + "hermit-abi", + "libc", +] + +[[package]] +name = "num_enum" +version = "0.5.11" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1f646caf906c20226733ed5b1374287eb97e3c2a5c227ce668c1f2ce20ae57c9" +dependencies = [ + "num_enum_derive", +] + +[[package]] +name = "num_enum_derive" +version = "0.5.11" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "dcbff9bc912032c62bf65ef1d5aea88983b420f4f839db1e9b0c281a25c9c799" +dependencies = [ + "proc-macro-crate 1.3.1", + "proc-macro2", + "quote", + "syn 1.0.109", +] + +[[package]] +name = "num_threads" +version = "0.1.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5c7398b9c8b70908f6371f47ed36737907c87c52af34c268fed0bf0ceb92ead9" +dependencies = [ + "libc", +] + +[[package]] +name = "number_prefix" +version = "0.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "830b246a0e5f20af87141b25c173cd1b609bd7779a4617d6ec582abaf90870f3" + +[[package]] +name = "object" +version = "0.32.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a6a622008b6e321afc04970976f62ee297fdbaa6f95318ca343e3eebb9648441" +dependencies = [ + "memchr", +] + +[[package]] +name = "once_cell" +version = "1.19.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3fdb12b2476b595f9358c5161aa467c2438859caa136dec86c26fdd2efe17b92" + +[[package]] +name = "opaque-debug" +version = "0.3.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c08d65885ee38876c4f86fa503fb49d7b507c2b62552df7c70b2fce627e06381" + +[[package]] +name = "openssl" +version = "0.10.64" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "95a0481286a310808298130d22dd1fef0fa571e05a8f44ec801801e84b216b1f" +dependencies = [ + "bitflags 2.5.0", + "cfg-if", + "foreign-types", + "libc", + "once_cell", + "openssl-macros", + "openssl-sys", +] + +[[package]] +name = "openssl-macros" +version = "0.1.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a948666b637a0f465e8564c73e89d4dde00d72d4d473cc972f390fc3dcee7d9c" +dependencies = [ + "proc-macro2", + "quote", + "syn 2.0.60", +] + +[[package]] +name = "openssl-probe" +version = "0.1.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ff011a302c396a5197692431fc1948019154afc178baf7d8e37367442a4601cf" + +[[package]] +name = "openssl-sys" +version = "0.9.102" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c597637d56fbc83893a35eb0dd04b2b8e7a50c91e64e9493e398b5df4fb45fa2" +dependencies = [ + "cc", + "libc", + "pkg-config", + "vcpkg", +] + +[[package]] +name = "option-ext" +version = "0.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "04744f49eae99ab78e0d5c0b603ab218f515ea8cfe5a456d7629ad883a3b6e7d" + +[[package]] +name = "overload" +version = "0.1.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b15813163c1d831bf4a13c3610c05c0d03b39feb07f7e09fa234dac9b15aaf39" + +[[package]] +name = "p3-air" +version = "0.1.0" +source = "git+https://github.com/Plonky3/Plonky3.git?branch=sp1#aef4f8f03f960925f7088d757aeeb956a7f4b30c" +dependencies = [ + "p3-field", + "p3-matrix", +] + +[[package]] +name = "p3-baby-bear" +version = "0.1.0" +source = "git+https://github.com/Plonky3/Plonky3.git?branch=sp1#aef4f8f03f960925f7088d757aeeb956a7f4b30c" +dependencies = [ + "num-bigint 0.4.4", + "p3-field", + "p3-mds", + "p3-poseidon2", + "p3-symmetric", + "rand", + "serde", +] + +[[package]] +name = "p3-blake3" +version = "0.1.0" +source = "git+https://github.com/Plonky3/Plonky3.git?branch=sp1#aef4f8f03f960925f7088d757aeeb956a7f4b30c" +dependencies = [ + "blake3", + "p3-symmetric", +] + +[[package]] +name = "p3-bn254-fr" +version = "0.1.0" +source = "git+https://github.com/Plonky3/Plonky3.git?branch=sp1#aef4f8f03f960925f7088d757aeeb956a7f4b30c" +dependencies = [ + "ff 0.13.0", + "num-bigint 0.4.4", + "p3-field", + "p3-poseidon2", + "p3-symmetric", + "rand", + "serde", +] + +[[package]] +name = "p3-challenger" +version = "0.1.0" +source = "git+https://github.com/Plonky3/Plonky3.git?branch=sp1#aef4f8f03f960925f7088d757aeeb956a7f4b30c" +dependencies = [ + "p3-field", + "p3-maybe-rayon", + "p3-symmetric", + "p3-util", + "tracing", +] + +[[package]] +name = "p3-commit" +version = "0.1.0" +source = "git+https://github.com/Plonky3/Plonky3.git?branch=sp1#aef4f8f03f960925f7088d757aeeb956a7f4b30c" +dependencies = [ + "itertools 0.12.1", + "p3-challenger", + "p3-field", + "p3-matrix", + "p3-util", + "serde", +] + +[[package]] +name = "p3-dft" +version = "0.1.0" +source = "git+https://github.com/Plonky3/Plonky3.git?branch=sp1#aef4f8f03f960925f7088d757aeeb956a7f4b30c" +dependencies = [ + "p3-field", + "p3-matrix", + "p3-maybe-rayon", + "p3-util", + "tracing", +] + +[[package]] +name = "p3-field" +version = "0.1.0" +source = "git+https://github.com/Plonky3/Plonky3.git?branch=sp1#aef4f8f03f960925f7088d757aeeb956a7f4b30c" +dependencies = [ + "itertools 0.12.1", + "num-bigint 0.4.4", + "num-traits", + "p3-util", + "rand", + "serde", +] + +[[package]] +name = "p3-fri" +version = "0.1.0" +source = "git+https://github.com/Plonky3/Plonky3.git?branch=sp1#aef4f8f03f960925f7088d757aeeb956a7f4b30c" +dependencies = [ + "itertools 0.12.1", + "p3-challenger", + "p3-commit", + "p3-dft", + "p3-field", + "p3-interpolation", + "p3-matrix", + "p3-maybe-rayon", + "p3-util", + "serde", + "tracing", +] + +[[package]] +name = "p3-interpolation" +version = "0.1.0" +source = "git+https://github.com/Plonky3/Plonky3.git?branch=sp1#aef4f8f03f960925f7088d757aeeb956a7f4b30c" +dependencies = [ + "p3-field", + "p3-matrix", + "p3-util", +] + +[[package]] +name = "p3-keccak" +version = "0.1.0" +source = "git+https://github.com/Plonky3/Plonky3.git?branch=sp1#aef4f8f03f960925f7088d757aeeb956a7f4b30c" +dependencies = [ + "p3-symmetric", + "tiny-keccak", +] + +[[package]] +name = "p3-keccak-air" +version = "0.1.0" +source = "git+https://github.com/Plonky3/Plonky3.git?branch=sp1#aef4f8f03f960925f7088d757aeeb956a7f4b30c" +dependencies = [ + "p3-air", + "p3-field", + "p3-matrix", + "p3-maybe-rayon", + "p3-util", + "tracing", +] + +[[package]] +name = "p3-matrix" +version = "0.1.0" +source = "git+https://github.com/Plonky3/Plonky3.git?branch=sp1#aef4f8f03f960925f7088d757aeeb956a7f4b30c" +dependencies = [ + "itertools 0.12.1", + "p3-field", + "p3-maybe-rayon", + "p3-util", + "rand", + "serde", + "tracing", +] + +[[package]] +name = "p3-maybe-rayon" +version = "0.1.0" +source = "git+https://github.com/Plonky3/Plonky3.git?branch=sp1#aef4f8f03f960925f7088d757aeeb956a7f4b30c" +dependencies = [ + "rayon", +] + +[[package]] +name = "p3-mds" +version = "0.1.0" +source = "git+https://github.com/Plonky3/Plonky3.git?branch=sp1#aef4f8f03f960925f7088d757aeeb956a7f4b30c" +dependencies = [ + "itertools 0.12.1", + "p3-dft", + "p3-field", + "p3-matrix", + "p3-symmetric", + "p3-util", + "rand", +] + +[[package]] +name = "p3-merkle-tree" +version = "0.1.0" +source = "git+https://github.com/Plonky3/Plonky3.git?branch=sp1#aef4f8f03f960925f7088d757aeeb956a7f4b30c" +dependencies = [ + "itertools 0.12.1", + "p3-commit", + "p3-field", + "p3-matrix", + "p3-maybe-rayon", + "p3-symmetric", + "p3-util", + "serde", + "tracing", +] + +[[package]] +name = "p3-poseidon2" +version = "0.1.0" +source = "git+https://github.com/Plonky3/Plonky3.git?branch=sp1#aef4f8f03f960925f7088d757aeeb956a7f4b30c" +dependencies = [ + "gcd", + "p3-field", + "p3-mds", + "p3-symmetric", + "rand", +] + +[[package]] +name = "p3-symmetric" +version = "0.1.0" +source = "git+https://github.com/Plonky3/Plonky3.git?branch=sp1#aef4f8f03f960925f7088d757aeeb956a7f4b30c" +dependencies = [ + "itertools 0.12.1", + "p3-field", + "serde", +] + +[[package]] +name = "p3-uni-stark" +version = "0.1.0" +source = "git+https://github.com/Plonky3/Plonky3.git?branch=sp1#aef4f8f03f960925f7088d757aeeb956a7f4b30c" +dependencies = [ + "itertools 0.12.1", + "p3-air", + "p3-challenger", + "p3-commit", + "p3-dft", + "p3-field", + "p3-matrix", + "p3-maybe-rayon", + "p3-util", + "serde", + "tracing", +] + +[[package]] +name = "p3-util" +version = "0.1.0" +source = "git+https://github.com/Plonky3/Plonky3.git?branch=sp1#aef4f8f03f960925f7088d757aeeb956a7f4b30c" +dependencies = [ + "serde", +] + +[[package]] +name = "pairing" +version = "0.22.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "135590d8bdba2b31346f9cd1fb2a912329f5135e832a4f422942eb6ead8b6b3b" +dependencies = [ + "group 0.12.1", +] + +[[package]] +name = "parity-scale-codec" +version = "3.6.9" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "881331e34fa842a2fb61cc2db9643a8fedc615e47cfcc52597d1af0db9a7e8fe" +dependencies = [ + "arrayvec", + "bitvec", + "byte-slice-cast", + "impl-trait-for-tuples", + "parity-scale-codec-derive", + "serde", +] + +[[package]] +name = "parity-scale-codec-derive" +version = "3.6.9" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "be30eaf4b0a9fba5336683b38de57bb86d179a35862ba6bfcf57625d006bde5b" +dependencies = [ + "proc-macro-crate 2.0.2", + "proc-macro2", + "quote", + "syn 1.0.109", +] + +[[package]] +name = "parking_lot" +version = "0.12.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3742b2c103b9f06bc9fff0a37ff4912935851bee6d36f3c02bcc755bcfec228f" +dependencies = [ + "lock_api", + "parking_lot_core", +] + +[[package]] +name = "parking_lot_core" +version = "0.9.9" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4c42a9226546d68acdd9c0a280d17ce19bfe27a46bf68784e4066115788d008e" +dependencies = [ + "cfg-if", + "libc", + "redox_syscall", + "smallvec", + "windows-targets 0.48.5", +] + +[[package]] +name = "pasta_curves" +version = "0.4.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5cc65faf8e7313b4b1fbaa9f7ca917a0eed499a9663be71477f87993604341d8" +dependencies = [ + "blake2b_simd", + "ff 0.12.1", + "group 0.12.1", + "lazy_static", + "rand", + "static_assertions", + "subtle", +] + +[[package]] +name = "pasta_curves" +version = "0.5.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d3e57598f73cc7e1b2ac63c79c517b31a0877cd7c402cdcaa311b5208de7a095" +dependencies = [ + "blake2b_simd", + "ff 0.13.0", + "group 0.13.0", + "lazy_static", + "rand", + "static_assertions", + "subtle", +] + +[[package]] +name = "paste" +version = "1.0.14" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "de3145af08024dea9fa9914f381a17b8fc6034dfb00f3a84013f7ff43f29ed4c" + +[[package]] +name = "percent-encoding" +version = "2.3.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e3148f5046208a5d56bcfc03053e3ca6334e51da8dfb19b6cdc8b306fae3283e" + +[[package]] +name = "pest" +version = "2.7.9" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "311fb059dee1a7b802f036316d790138c613a4e8b180c822e3925a662e9f0c95" +dependencies = [ + "memchr", + "thiserror", + "ucd-trie", +] + +[[package]] +name = "pin-project" +version = "1.1.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b6bf43b791c5b9e34c3d182969b4abb522f9343702850a2e57f460d00d09b4b3" +dependencies = [ + "pin-project-internal", +] + +[[package]] +name = "pin-project-internal" +version = "1.1.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2f38a4412a78282e09a2cf38d195ea5420d15ba0602cb375210efbc877243965" +dependencies = [ + "proc-macro2", + "quote", + "syn 2.0.60", +] + +[[package]] +name = "pin-project-lite" +version = "0.2.14" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "bda66fc9667c18cb2758a2ac84d1167245054bcf85d5d1aaa6923f45801bdd02" + +[[package]] +name = "pin-utils" +version = "0.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8b870d8c151b6f2fb93e84a13146138f05d02ed11c7e7c54f8826aaaf7c9f184" + +[[package]] +name = "pkcs8" +version = "0.10.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f950b2377845cebe5cf8b5165cb3cc1a5e0fa5cfa3e1f7f55707d8fd82e0a7b7" +dependencies = [ + "der", + "spki", +] + +[[package]] +name = "pkg-config" +version = "0.3.30" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d231b230927b5e4ad203db57bbcbee2802f6bce620b1e4a9024a07d94e2907ec" + +[[package]] +name = "platforms" +version = "3.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "db23d408679286588f4d4644f965003d056e3dd5abcaaa938116871d7ce2fee7" + +[[package]] +name = "portable-atomic" +version = "1.6.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7170ef9988bc169ba16dd36a7fa041e5c4cbeb6a35b76d4c03daded371eae7c0" + +[[package]] +name = "powerfmt" +version = "0.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "439ee305def115ba05938db6eb1644ff94165c5ab5e9420d1c1bcedbba909391" + +[[package]] +name = "ppv-lite86" +version = "0.2.17" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5b40af805b3121feab8a3c29f04d8ad262fa8e0561883e7653e024ae4479e6de" + +[[package]] +name = "primitive-types" +version = "0.12.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0b34d9fd68ae0b74a41b21c03c2f62847aa0ffea044eee893b4c140b37e244e2" +dependencies = [ + "fixed-hash", + "impl-codec", + "uint", +] + +[[package]] +name = "proc-macro-crate" +version = "1.3.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7f4c021e1093a56626774e81216a4ce732a735e5bad4868a03f3ed65ca0c3919" +dependencies = [ + "once_cell", + "toml_edit 0.19.15", +] + +[[package]] +name = "proc-macro-crate" +version = "2.0.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b00f26d3400549137f92511a46ac1cd8ce37cb5598a96d382381458b992a5d24" +dependencies = [ + "toml_datetime", + "toml_edit 0.20.2", +] + +[[package]] +name = "proc-macro-error" +version = "1.0.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "da25490ff9892aab3fcf7c36f08cfb902dd3e71ca0f9f9517bea02a73a5ce38c" +dependencies = [ + "proc-macro-error-attr", + "proc-macro2", + "quote", + "syn 1.0.109", + "version_check", +] + +[[package]] +name = "proc-macro-error-attr" +version = "1.0.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a1be40180e52ecc98ad80b184934baf3d0d29f979574e439af5a55274b35f869" +dependencies = [ + "proc-macro2", + "quote", + "version_check", +] + +[[package]] +name = "proc-macro2" +version = "1.0.81" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3d1597b0c024618f09a9c3b8655b7e430397a36d23fdafec26d6965e9eec3eba" +dependencies = [ + "unicode-ident", +] + +[[package]] +name = "proptest" +version = "1.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "31b476131c3c86cb68032fdc5cb6d5a1045e3e42d96b69fa599fd77701e1f5bf" +dependencies = [ + "bit-set", + "bit-vec", + "bitflags 2.5.0", + "lazy_static", + "num-traits", + "rand", + "rand_chacha", + "rand_xorshift", + "regex-syntax 0.8.3", + "rusty-fork", + "tempfile", + "unarray", +] + +[[package]] +name = "prost" +version = "0.12.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d0f5d036824e4761737860779c906171497f6d55681139d8312388f8fe398922" +dependencies = [ + "bytes", + "prost-derive", +] + +[[package]] +name = "prost-derive" +version = "0.12.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "19de2de2a00075bf566bee3bd4db014b11587e84184d3f7a791bc17f1a8e9e48" +dependencies = [ + "anyhow", + "itertools 0.12.1", + "proc-macro2", + "quote", + "syn 2.0.60", +] + +[[package]] +name = "prost-types" +version = "0.12.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3235c33eb02c1f1e212abdbe34c78b264b038fb58ca612664343271e36e55ffe" +dependencies = [ + "prost", +] + +[[package]] +name = "quick-error" +version = "1.2.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a1d01941d82fa2ab50be1e79e6714289dd7cde78eba4c074bc5a4374f650dfe0" + +[[package]] +name = "quote" +version = "1.0.36" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0fa76aaf39101c457836aec0ce2316dbdc3ab723cdda1c6bd4e6ad4208acaca7" +dependencies = [ + "proc-macro2", +] + +[[package]] +name = "radium" +version = "0.7.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "dc33ff2d4973d518d823d61aa239014831e521c75da58e3df4840d3f47749d09" + +[[package]] +name = "rand" +version = "0.8.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "34af8d1a0e25924bc5b7c43c079c942339d8f0a8b57c39049bef581b46327404" +dependencies = [ + "libc", + "rand_chacha", + "rand_core", +] + +[[package]] +name = "rand_chacha" +version = "0.3.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e6c10a63a0fa32252be49d21e7709d4d4baf8d231c2dbce1eaa8141b9b127d88" +dependencies = [ + "ppv-lite86", + "rand_core", +] + +[[package]] +name = "rand_core" +version = "0.6.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ec0be4795e2f6a28069bec0b5ff3e2ac9bafc99e6a9a7dc3547996c5c816922c" +dependencies = [ + "getrandom", +] + +[[package]] +name = "rand_xorshift" +version = "0.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d25bf25ec5ae4a3f1b92f929810509a2f53d7dca2f50b794ff57e3face536c8f" +dependencies = [ + "rand_core", +] + +[[package]] +name = "rayon" +version = "1.10.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b418a60154510ca1a002a752ca9714984e21e4241e804d32555251faf8b78ffa" +dependencies = [ + "either", + "rayon-core", +] + +[[package]] +name = "rayon-core" +version = "1.12.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1465873a3dfdaa8ae7cb14b4383657caab0b3e8a0aa9ae8e04b044854c8dfce2" +dependencies = [ + "crossbeam-deque", + "crossbeam-utils", +] + +[[package]] +name = "rayon-scan" +version = "0.1.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3f87cc11a0140b4b0da0ffc889885760c61b13672d80a908920b2c0df078fa14" +dependencies = [ + "rayon", +] + +[[package]] +name = "redox_syscall" +version = "0.4.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4722d768eff46b75989dd134e5c353f0d6296e5aaa3132e776cbdb56be7731aa" +dependencies = [ + "bitflags 1.3.2", +] + +[[package]] +name = "redox_users" +version = "0.4.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "bd283d9651eeda4b2a83a43c1c91b266c40fd76ecd39a50a8c630ae69dc72891" +dependencies = [ + "getrandom", + "libredox", + "thiserror", +] + +[[package]] +name = "regex" +version = "1.10.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c117dbdfde9c8308975b6a18d71f3f385c89461f7b3fb054288ecf2a2058ba4c" +dependencies = [ + "aho-corasick", + "memchr", + "regex-automata 0.4.6", + "regex-syntax 0.8.3", +] + +[[package]] +name = "regex-automata" +version = "0.1.10" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6c230d73fb8d8c1b9c0b3135c5142a8acee3a0558fb8db5cf1cb65f8d7862132" +dependencies = [ + "regex-syntax 0.6.29", +] + +[[package]] +name = "regex-automata" +version = "0.4.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "86b83b8b9847f9bf95ef68afb0b8e6cdb80f498442f5179a29fad448fcc1eaea" +dependencies = [ + "aho-corasick", + "memchr", + "regex-syntax 0.8.3", +] + +[[package]] +name = "regex-syntax" +version = "0.6.29" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f162c6dd7b008981e4d40210aca20b4bd0f9b60ca9271061b07f78537722f2e1" + +[[package]] +name = "regex-syntax" +version = "0.8.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "adad44e29e4c806119491a7f06f03de4d1af22c3a680dd47f1e6e179439d1f56" + +[[package]] +name = "reqwest" +version = "0.11.27" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "dd67538700a17451e7cba03ac727fb961abb7607553461627b97de0b89cf4a62" +dependencies = [ + "base64 0.21.7", + "bytes", + "encoding_rs", + "futures-core", + "futures-util", + "h2 0.3.26", + "hickory-resolver", + "http 0.2.12", + "http-body 0.4.6", + "hyper 0.14.28", + "hyper-rustls", + "hyper-tls 0.5.0", + "ipnet", + "js-sys", + "log", + "mime", + "mime_guess", + "native-tls", + "once_cell", + "percent-encoding", + "pin-project-lite", + "rustls", + "rustls-pemfile 1.0.4", + "serde", + "serde_json", + "serde_urlencoded", + "sync_wrapper", + "system-configuration", + "tokio", + "tokio-native-tls", + "tokio-rustls", + "tokio-util", + "tower-service", + "url", + "wasm-bindgen", + "wasm-bindgen-futures", + "wasm-streams", + "web-sys", + "webpki-roots", + "winreg 0.50.0", +] + +[[package]] +name = "reqwest" +version = "0.12.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "566cafdd92868e0939d3fb961bd0dc25fcfaaed179291093b3d43e6b3150ea10" +dependencies = [ + "base64 0.22.0", + "bytes", + "futures-core", + "futures-util", + "http 1.1.0", + "http-body 1.0.0", + "http-body-util", + "hyper 1.3.1", + "hyper-tls 0.6.0", + "hyper-util", + "ipnet", + "js-sys", + "log", + "mime", + "native-tls", + "once_cell", + "percent-encoding", + "pin-project-lite", + "rustls-pemfile 2.1.2", + "serde", + "serde_json", + "serde_urlencoded", + "sync_wrapper", + "tokio", + "tokio-native-tls", + "tower-service", + "url", + "wasm-bindgen", + "wasm-bindgen-futures", + "web-sys", + "winreg 0.52.0", +] + +[[package]] +name = "reqwest-middleware" +version = "0.2.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5a735987236a8e238bf0296c7e351b999c188ccc11477f311b82b55c93984216" +dependencies = [ + "anyhow", + "async-trait", + "http 0.2.12", + "reqwest 0.11.27", + "serde", + "task-local-extensions", + "thiserror", +] + +[[package]] +name = "resolv-conf" +version = "0.7.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "52e44394d2086d010551b14b53b1f24e31647570cd1deb0379e2c21b329aba00" +dependencies = [ + "hostname", + "quick-error", +] + +[[package]] +name = "rfc6979" +version = "0.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f8dd2a808d456c4a54e300a23e9f5a67e122c3024119acbfd73e3bf664491cb2" +dependencies = [ + "hmac", + "subtle", +] + +[[package]] +name = "ring" +version = "0.17.8" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c17fa4cb658e3583423e915b9f3acc01cceaee1860e33d59ebae66adc3a2dc0d" +dependencies = [ + "cc", + "cfg-if", + "getrandom", + "libc", + "spin 0.9.8", + "untrusted", + "windows-sys 0.52.0", +] + +[[package]] +name = "rlp" +version = "0.5.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "bb919243f34364b6bd2fc10ef797edbfa75f33c252e7998527479c6d6b47e1ec" +dependencies = [ + "bytes", + "rustc-hex", +] + +[[package]] +name = "rrs-lib" +version = "0.1.0" +source = "git+https://github.com/GregAC/rrs.git#b23afc16b4e6a1fb5c4a73eb1e337e9400816507" +dependencies = [ + "downcast-rs", + "num_enum", + "paste", +] + +[[package]] +name = "ruint" +version = "1.12.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8f308135fef9fc398342da5472ce7c484529df23743fb7c734e0f3d472971e62" +dependencies = [ + "alloy-rlp", + "ark-ff 0.3.0", + "ark-ff 0.4.2", + "bytes", + "fastrlp", + "num-bigint 0.4.4", + "num-traits", + "parity-scale-codec", + "primitive-types", + "proptest", + "rand", + "rlp", + "ruint-macro", + "serde", + "valuable", + "zeroize", +] + +[[package]] +name = "ruint-macro" +version = "1.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f86854cf50259291520509879a5c294c3c9a4c334e9ff65071c51e42ef1e2343" + +[[package]] +name = "rustc-demangle" +version = "0.1.23" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d626bb9dae77e28219937af045c257c28bfd3f69333c512553507f5f9798cb76" + +[[package]] +name = "rustc-hex" +version = "2.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3e75f6a532d0fd9f7f13144f392b6ad56a32696bfcd9c78f797f16bbb6f072d6" + +[[package]] +name = "rustc_version" +version = "0.3.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f0dfe2087c51c460008730de8b57e6a320782fbfb312e1f4d520e6c6fae155ee" +dependencies = [ + "semver 0.11.0", +] + +[[package]] +name = "rustc_version" +version = "0.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "bfa0f585226d2e68097d4f95d113b15b83a82e819ab25717ec0590d9584ef366" +dependencies = [ + "semver 1.0.22", +] + +[[package]] +name = "rustix" +version = "0.38.34" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "70dc5ec042f7a43c4a73241207cecc9873a06d45debb38b329f8541d85c2730f" +dependencies = [ + "bitflags 2.5.0", + "errno", + "libc", + "linux-raw-sys", + "windows-sys 0.52.0", +] + +[[package]] +name = "rustls" +version = "0.21.11" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7fecbfb7b1444f477b345853b1fce097a2c6fb637b2bfb87e6bc5db0f043fae4" +dependencies = [ + "log", + "ring", + "rustls-webpki", + "sct", +] + +[[package]] +name = "rustls-pemfile" +version = "1.0.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1c74cae0a4cf6ccbbf5f359f08efdf8ee7e1dc532573bf0db71968cb56b1448c" +dependencies = [ + "base64 0.21.7", +] + +[[package]] +name = "rustls-pemfile" +version = "2.1.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "29993a25686778eb88d4189742cd713c9bce943bc54251a33509dc63cbacf73d" +dependencies = [ + "base64 0.22.0", + "rustls-pki-types", +] + +[[package]] +name = "rustls-pki-types" +version = "1.5.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "beb461507cee2c2ff151784c52762cf4d9ff6a61f3e80968600ed24fa837fa54" + +[[package]] +name = "rustls-webpki" +version = "0.101.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8b6275d1ee7a1cd780b64aca7726599a1dbc893b1e64144529e55c3c2f745765" +dependencies = [ + "ring", + "untrusted", +] + +[[package]] +name = "rustversion" +version = "1.0.15" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "80af6f9131f277a45a3fba6ce8e2258037bb0477a67e610d3c1fe046ab31de47" + +[[package]] +name = "rusty-fork" +version = "0.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "cb3dcc6e454c328bb824492db107ab7c0ae8fcffe4ad210136ef014458c1bc4f" +dependencies = [ + "fnv", + "quick-error", + "tempfile", + "wait-timeout", +] + +[[package]] +name = "ryu" +version = "1.0.17" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e86697c916019a8588c99b5fac3cead74ec0b4b819707a682fd4d23fa0ce1ba1" + +[[package]] +name = "scale-info" +version = "2.11.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7c453e59a955f81fb62ee5d596b450383d699f152d350e9d23a0db2adb78e4c0" +dependencies = [ + "cfg-if", + "derive_more", + "parity-scale-codec", + "scale-info-derive", +] + +[[package]] +name = "scale-info-derive" +version = "2.11.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "18cf6c6447f813ef19eb450e985bcce6705f9ce7660db221b59093d15c79c4b7" +dependencies = [ + "proc-macro-crate 1.3.1", + "proc-macro2", + "quote", + "syn 1.0.109", +] + +[[package]] +name = "scc" +version = "2.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ec96560eea317a9cc4e0bb1f6a2c93c09a19b8c4fc5cb3fcc0ec1c094cd783e2" +dependencies = [ + "sdd", +] + +[[package]] +name = "schannel" +version = "0.1.23" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "fbc91545643bcf3a0bbb6569265615222618bdf33ce4ffbbd13c4bbd4c093534" +dependencies = [ + "windows-sys 0.52.0", +] + +[[package]] +name = "scopeguard" +version = "1.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "94143f37725109f92c262ed2cf5e59bce7498c01bcc1502d7b9afe439a4e9f49" + +[[package]] +name = "sct" +version = "0.7.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "da046153aa2352493d6cb7da4b6e5c0c057d8a1d0a9aa8560baffdd945acd414" +dependencies = [ + "ring", + "untrusted", +] + +[[package]] +name = "sdd" +version = "0.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b84345e4c9bd703274a082fb80caaa99b7612be48dfaa1dd9266577ec412309d" + +[[package]] +name = "sec1" +version = "0.7.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d3e97a565f76233a6003f9f5c54be1d9c5bdfa3eccfb189469f11ec4901c47dc" +dependencies = [ + "base16ct", + "der", + "generic-array 0.14.7", + "pkcs8", + "subtle", + "zeroize", +] + +[[package]] +name = "security-framework" +version = "2.10.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "770452e37cad93e0a50d5abc3990d2bc351c36d0328f86cefec2f2fb206eaef6" +dependencies = [ + "bitflags 1.3.2", + "core-foundation", + "core-foundation-sys", + "libc", + "security-framework-sys", +] + +[[package]] +name = "security-framework-sys" +version = "2.10.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "41f3cc463c0ef97e11c3461a9d3787412d30e8e7eb907c79180c4a57bf7c04ef" +dependencies = [ + "core-foundation-sys", + "libc", +] + +[[package]] +name = "semver" +version = "0.11.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f301af10236f6df4160f7c3f04eec6dbc70ace82d23326abad5edee88801c6b6" +dependencies = [ + "semver-parser", +] + +[[package]] +name = "semver" +version = "1.0.22" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "92d43fe69e652f3df9bdc2b85b2854a0825b86e4fb76bc44d945137d053639ca" +dependencies = [ + "serde", +] + +[[package]] +name = "semver-parser" +version = "0.10.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "00b0bef5b7f9e0df16536d3961cfb6e84331c065b4066afb39768d0e319411f7" +dependencies = [ + "pest", +] + +[[package]] +name = "serde" +version = "1.0.198" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9846a40c979031340571da2545a4e5b7c4163bdae79b301d5f86d03979451fcc" +dependencies = [ + "serde_derive", +] + +[[package]] +name = "serde_bytes" +version = "0.11.14" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8b8497c313fd43ab992087548117643f6fcd935cbf36f176ffda0aacf9591734" +dependencies = [ + "serde", +] + +[[package]] +name = "serde_cbor" +version = "0.11.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2bef2ebfde456fb76bbcf9f59315333decc4fda0b2b44b420243c11e0f5ec1f5" +dependencies = [ + "half", + "serde", +] + +[[package]] +name = "serde_derive" +version = "1.0.198" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e88edab869b01783ba905e7d0153f9fc1a6505a96e4ad3018011eedb838566d9" +dependencies = [ + "proc-macro2", + "quote", + "syn 2.0.60", +] + +[[package]] +name = "serde_json" +version = "1.0.116" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3e17db7126d17feb94eb3fad46bf1a96b034e8aacbc2e775fe81505f8b0b2813" +dependencies = [ + "itoa", + "ryu", + "serde", +] + +[[package]] +name = "serde_path_to_error" +version = "0.1.16" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "af99884400da37c88f5e9146b7f1fd0fbcae8f6eec4e9da38b67d05486f814a6" +dependencies = [ + "itoa", + "serde", +] + +[[package]] +name = "serde_repr" +version = "0.1.19" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6c64451ba24fc7a6a2d60fc75dd9c83c90903b19028d4eff35e88fc1e86564e9" +dependencies = [ + "proc-macro2", + "quote", + "syn 2.0.60", +] + +[[package]] +name = "serde_urlencoded" +version = "0.7.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d3491c14715ca2294c4d6a88f15e84739788c1d030eed8c110436aafdaa2f3fd" +dependencies = [ + "form_urlencoded", + "itoa", + "ryu", + "serde", +] + +[[package]] +name = "serde_with" +version = "3.8.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2c85f8e96d1d6857f13768fcbd895fcb06225510022a2774ed8b5150581847b0" +dependencies = [ + "base64 0.22.0", + "chrono", + "hex", + "indexmap 1.9.3", + "indexmap 2.2.6", + "serde", + "serde_derive", + "serde_json", + "serde_with_macros", + "time", +] + +[[package]] +name = "serde_with_macros" +version = "3.8.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c8b3a576c4eb2924262d5951a3b737ccaf16c931e39a2810c36f9a7e25575557" +dependencies = [ + "darling", + "proc-macro2", + "quote", + "syn 2.0.60", +] + +[[package]] +name = "serial_test" +version = "3.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "adb86f9315df5df6a70eae0cc22395a44e544a0d8897586820770a35ede74449" +dependencies = [ + "futures", + "log", + "once_cell", + "parking_lot", + "scc", + "serial_test_derive", +] + +[[package]] +name = "serial_test_derive" +version = "3.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a9bb72430492e9549b0c4596725c0f82729bff861c45aa8099c0a8e67fc3b721" +dependencies = [ + "proc-macro2", + "quote", + "syn 2.0.60", +] + +[[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.8" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "793db75ad2bcafc3ffa7c68b215fee268f537982cd901d132f89c6343f3a3dc8" +dependencies = [ + "cfg-if", + "cpufeatures", + "digest 0.10.7", +] + +[[package]] +name = "sha3" +version = "0.10.8" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "75872d278a8f37ef87fa0ddbda7802605cb18344497949862c0d4dcb291eba60" +dependencies = [ + "digest 0.10.7", + "keccak", +] + +[[package]] +name = "sha3-asm" +version = "0.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "bac61da6b35ad76b195eb4771210f947734321a8d81d7738e1580d953bc7a15e" +dependencies = [ + "cc", + "cfg-if", +] + +[[package]] +name = "sharded-slab" +version = "0.1.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f40ca3c46823713e0d4209592e8d6e826aa57e928f09752619fc696c499637f6" +dependencies = [ + "lazy_static", +] + +[[package]] +name = "signal-hook-registry" +version = "1.4.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a9e9e0b4211b72e7b8b6e85c807d36c212bdb33ea8587f7569562a84df5465b1" +dependencies = [ + "libc", +] + +[[package]] +name = "signature" +version = "2.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "77549399552de45a898a580c1b41d445bf730df867cc44e6c0233bbc4b8329de" +dependencies = [ + "digest 0.10.7", + "rand_core", +] + +[[package]] +name = "size" +version = "0.4.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9fed904c7fb2856d868b92464fc8fa597fce366edea1a9cbfaa8cb5fe080bd6d" + +[[package]] +name = "slab" +version = "0.4.9" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8f92a496fb766b417c996b9c5e57daf2f7ad3b0bebe1ccfca4856390e3d3bb67" +dependencies = [ + "autocfg", +] + +[[package]] +name = "smallvec" +version = "1.13.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3c5e1a9a646d36c3599cd173a41282daf47c44583ad367b8e6837255952e5c67" + +[[package]] +name = "snowbridge-amcl" +version = "1.0.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "460a9ed63cdf03c1b9847e8a12a5f5ba19c4efd5869e4a737e05be25d7c427e5" +dependencies = [ + "parity-scale-codec", + "scale-info", +] + +[[package]] +name = "socket2" +version = "0.5.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "05ffd9c0a93b7543e062e759284fcf5f5e3b098501104bfbdde4d404db792871" +dependencies = [ + "libc", + "windows-sys 0.52.0", +] + +[[package]] +name = "sp1-core" +version = "0.1.0" +dependencies = [ + "anyhow", + "arrayref", + "bincode", + "blake3", + "blake3-zkvm", + "cfg-if", + "curve25519-dalek", + "elf", + "elliptic-curve", + "generic-array 1.0.0", + "hex", + "itertools 0.12.1", + "k256", + "log", + "nohash-hasher", + "num", + "num_cpus", + "p3-air", + "p3-baby-bear", + "p3-blake3", + "p3-challenger", + "p3-commit", + "p3-dft", + "p3-field", + "p3-fri", + "p3-keccak", + "p3-keccak-air", + "p3-matrix", + "p3-maybe-rayon", + "p3-merkle-tree", + "p3-poseidon2", + "p3-symmetric", + "p3-uni-stark", + "p3-util", + "rayon-scan", + "rrs-lib", + "serde", + "serde_with", + "size", + "snowbridge-amcl", + "sp1-derive", + "sp1-primitives", + "strum", + "strum_macros", + "tempfile", + "tracing", + "tracing-forest", + "tracing-subscriber", + "typenum", + "web-time", +] + +[[package]] +name = "sp1-derive" +version = "0.1.0" +dependencies = [ + "proc-macro2", + "quote", + "syn 1.0.109", +] + +[[package]] +name = "sp1-helper" +version = "0.1.0" +dependencies = [ + "cargo_metadata", + "chrono", +] + +[[package]] +name = "sp1-primitives" +version = "0.1.0" +dependencies = [ + "itertools 0.12.1", + "lazy_static", + "p3-baby-bear", + "p3-field", + "p3-poseidon2", + "p3-symmetric", +] + +[[package]] +name = "sp1-prover" +version = "0.1.0" +dependencies = [ + "anyhow", + "backtrace", + "bincode", + "clap", + "hex", + "itertools 0.12.1", + "p3-baby-bear", + "p3-bn254-fr", + "p3-challenger", + "p3-commit", + "p3-field", + "rayon", + "serde", + "serde_json", + "sha2 0.10.8", + "size", + "sp1-core", + "sp1-primitives", + "sp1-recursion-circuit", + "sp1-recursion-compiler", + "sp1-recursion-core", + "sp1-recursion-gnark-ffi", + "sp1-recursion-program", + "subtle-encoding", + "tempfile", + "tracing", + "tracing-appender", + "tracing-subscriber", +] + +[[package]] +name = "sp1-recursion-circuit" +version = "0.1.0" +dependencies = [ + "bincode", + "itertools 0.12.1", + "p3-air", + "p3-baby-bear", + "p3-bn254-fr", + "p3-commit", + "p3-field", + "p3-fri", + "p3-matrix", + "p3-util", + "serde", + "sp1-core", + "sp1-recursion-compiler", + "sp1-recursion-core", + "sp1-recursion-derive", + "sp1-recursion-program", +] + +[[package]] +name = "sp1-recursion-compiler" +version = "0.1.0" +dependencies = [ + "backtrace", + "itertools 0.12.1", + "p3-air", + "p3-baby-bear", + "p3-bn254-fr", + "p3-commit", + "p3-field", + "p3-fri", + "p3-matrix", + "p3-poseidon2", + "p3-symmetric", + "p3-util", + "serde", + "serde_json", + "serial_test", + "sp1-core", + "sp1-recursion-core", + "sp1-recursion-derive", + "tracing", +] + +[[package]] +name = "sp1-recursion-core" +version = "0.1.0" +dependencies = [ + "arrayref", + "backtrace", + "ff 0.13.0", + "hashbrown 0.14.3", + "itertools 0.12.1", + "p3-air", + "p3-baby-bear", + "p3-bn254-fr", + "p3-challenger", + "p3-commit", + "p3-dft", + "p3-field", + "p3-fri", + "p3-matrix", + "p3-maybe-rayon", + "p3-merkle-tree", + "p3-poseidon2", + "p3-symmetric", + "serde", + "serde_with", + "sp1-core", + "sp1-derive", + "sp1-primitives", + "static_assertions", + "tracing", + "zkhash", +] + +[[package]] +name = "sp1-recursion-derive" +version = "0.1.0" +dependencies = [ + "proc-macro2", + "quote", + "syn 1.0.109", +] + +[[package]] +name = "sp1-recursion-gnark-ffi" +version = "0.1.0" +dependencies = [ + "crossbeam", + "log", + "p3-field", + "rand", + "reqwest 0.11.27", + "serde", + "serde_json", + "sp1-recursion-compiler", + "subtle-encoding", + "tempfile", +] + +[[package]] +name = "sp1-recursion-program" +version = "0.1.0" +dependencies = [ + "array-macro", + "itertools 0.12.1", + "p3-air", + "p3-baby-bear", + "p3-challenger", + "p3-commit", + "p3-dft", + "p3-field", + "p3-fri", + "p3-matrix", + "p3-merkle-tree", + "p3-poseidon2", + "p3-symmetric", + "p3-util", + "rand", + "serde", + "sp1-core", + "sp1-recursion-compiler", + "sp1-recursion-core", + "tracing", +] + +[[package]] +name = "sp1-sdk" +version = "0.1.0" +dependencies = [ + "alloy", + "anyhow", + "async-trait", + "axum", + "bincode", + "dirs", + "dotenv", + "futures", + "hex", + "indicatif", + "log", + "p3-commit", + "p3-field", + "p3-matrix", + "prost", + "prost-types", + "reqwest 0.11.27", + "reqwest-middleware", + "serde", + "serde_json", + "sha2 0.10.8", + "sp1-core", + "sp1-prover", + "tempfile", + "tokio", + "tracing", + "twirp", + "vergen", +] + +[[package]] +name = "spin" +version = "0.5.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6e63cff320ae2c57904679ba7cb63280a3dc4613885beafb148ee7bf9aa9042d" + +[[package]] +name = "spin" +version = "0.9.8" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6980e8d7511241f8acf4aebddbb1ff938df5eebe98691418c4468d0b72a96a67" + +[[package]] +name = "spki" +version = "0.7.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d91ed6c858b01f942cd56b37a94b3e0a1798290327d1236e4d9cf4eaca44d29d" +dependencies = [ + "base64ct", + "der", +] + +[[package]] +name = "static_assertions" +version = "1.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a2eb9349b6444b326872e140eb1cf5e7c522154d69e7a0ffb0fb81c06b37543f" + +[[package]] +name = "strsim" +version = "0.10.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "73473c0e59e6d5812c5dfe2a064a6444949f089e20eec9a2e5506596494e4623" + +[[package]] +name = "strsim" +version = "0.11.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7da8b5736845d9f2fcb837ea5d9e2628564b3b043a70948a3f0b778838c5fb4f" + +[[package]] +name = "strum" +version = "0.26.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5d8cec3501a5194c432b2b7976db6b7d10ec95c253208b45f83f7136aa985e29" + +[[package]] +name = "strum_macros" +version = "0.26.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c6cf59daf282c0a494ba14fd21610a0325f9f90ec9d1231dea26bcb1d696c946" +dependencies = [ + "heck 0.4.1", + "proc-macro2", + "quote", + "rustversion", + "syn 2.0.60", +] + +[[package]] +name = "subtle" +version = "2.5.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "81cdd64d312baedb58e21336b31bc043b77e01cc99033ce76ef539f78e965ebc" + +[[package]] +name = "subtle-encoding" +version = "0.5.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7dcb1ed7b8330c5eed5441052651dd7a12c75e2ed88f2ec024ae1fa3a5e59945" +dependencies = [ + "zeroize", +] + +[[package]] +name = "subtle-ng" +version = "2.5.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "734676eb262c623cec13c3155096e08d1f8f29adce39ba17948b18dad1e54142" + +[[package]] +name = "syn" +version = "1.0.109" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "72b64191b275b66ffe2469e8af2c1cfe3bafa67b529ead792a6d0160888b4237" +dependencies = [ + "proc-macro2", + "quote", + "unicode-ident", +] + +[[package]] +name = "syn" +version = "2.0.60" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "909518bc7b1c9b779f1bbf07f2929d35af9f0f37e47c6e9ef7f9dddc1e1821f3" +dependencies = [ + "proc-macro2", + "quote", + "unicode-ident", +] + +[[package]] +name = "syn-solidity" +version = "0.7.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "70aba06097b6eda3c15f6eebab8a6339e121475bcf08bbe6758807e716c372a1" +dependencies = [ + "paste", + "proc-macro2", + "quote", + "syn 2.0.60", +] + +[[package]] +name = "sync_wrapper" +version = "0.1.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2047c6ded9c721764247e62cd3b03c09ffc529b2ba5b10ec482ae507a4a70160" + +[[package]] +name = "system-configuration" +version = "0.5.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ba3a3adc5c275d719af8cb4272ea1c4a6d668a777f37e115f6d11ddbc1c8e0e7" +dependencies = [ + "bitflags 1.3.2", + "core-foundation", + "system-configuration-sys", +] + +[[package]] +name = "system-configuration-sys" +version = "0.5.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a75fb188eb626b924683e3b95e3a48e63551fcfb51949de2f06a9d91dbee93c9" +dependencies = [ + "core-foundation-sys", + "libc", +] + +[[package]] +name = "tap" +version = "1.0.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "55937e1799185b12863d447f42597ed69d9928686b8d88a1df17376a097d8369" + +[[package]] +name = "task-local-extensions" +version = "0.1.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ba323866e5d033818e3240feeb9f7db2c4296674e4d9e16b97b7bf8f490434e8" +dependencies = [ + "pin-utils", +] + +[[package]] +name = "tempfile" +version = "3.10.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "85b77fafb263dd9d05cbeac119526425676db3784113aa9295c88498cbf8bff1" +dependencies = [ + "cfg-if", + "fastrand", + "rustix", + "windows-sys 0.52.0", +] + +[[package]] +name = "tendermint" +version = "0.34.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "15ab8f0a25d0d2ad49ac615da054d6a76aa6603ff95f7d18bafdd34450a1a04b" +dependencies = [ + "bytes", + "digest 0.10.7", + "ed25519", + "ed25519-consensus", + "flex-error", + "futures", + "num-traits", + "once_cell", + "prost", + "prost-types", + "serde", + "serde_bytes", + "serde_json", + "serde_repr", + "sha2 0.10.8", + "signature", + "subtle", + "subtle-encoding", + "tendermint-proto", + "time", + "zeroize", +] + +[[package]] +name = "tendermint-light-client-verifier" +version = "0.34.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9b8090d0eef9ad57b1b913b5e358e26145c86017e87338136509b94383a4af25" +dependencies = [ + "derive_more", + "flex-error", + "serde", + "tendermint", + "time", +] + +[[package]] +name = "tendermint-proto" +version = "0.34.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b797dd3d2beaaee91d2f065e7bdf239dc8d80bba4a183a288bc1279dd5a69a1e" +dependencies = [ + "bytes", + "flex-error", + "num-derive", + "num-traits", + "prost", + "prost-types", + "serde", + "serde_bytes", + "subtle-encoding", + "time", +] + +[[package]] +name = "tendermint-script" +version = "0.1.0" +dependencies = [ + "bincode", + "itertools 0.12.1", + "reqwest 0.11.27", + "serde", + "serde_cbor", + "serde_json", + "sha2 0.10.8", + "sp1-core", + "sp1-helper", + "sp1-sdk", + "tendermint", + "tendermint-light-client-verifier", + "tokio", +] + +[[package]] +name = "thiserror" +version = "1.0.59" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f0126ad08bff79f29fc3ae6a55cc72352056dfff61e3ff8bb7129476d44b23aa" +dependencies = [ + "thiserror-impl", +] + +[[package]] +name = "thiserror-impl" +version = "1.0.59" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d1cd413b5d558b4c5bf3680e324a6fa5014e7b7c067a51e69dbdf47eb7148b66" +dependencies = [ + "proc-macro2", + "quote", + "syn 2.0.60", +] + +[[package]] +name = "thread_local" +version = "1.1.8" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8b9ef9bad013ada3808854ceac7b46812a6465ba368859a37e2100283d2d719c" +dependencies = [ + "cfg-if", + "once_cell", +] + +[[package]] +name = "threadpool" +version = "1.8.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d050e60b33d41c19108b32cea32164033a9013fe3b46cbd4457559bfbf77afaa" +dependencies = [ + "num_cpus", +] + +[[package]] +name = "time" +version = "0.3.36" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5dfd88e563464686c916c7e46e623e520ddc6d79fa6641390f2e3fa86e83e885" +dependencies = [ + "deranged", + "itoa", + "libc", + "num-conv", + "num_threads", + "powerfmt", + "serde", + "time-core", + "time-macros", +] + +[[package]] +name = "time-core" +version = "0.1.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ef927ca75afb808a4d64dd374f00a2adf8d0fcff8e7b184af886c3c87ec4a3f3" + +[[package]] +name = "time-macros" +version = "0.2.18" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3f252a68540fde3a3877aeea552b832b40ab9a69e318efd078774a01ddee1ccf" +dependencies = [ + "num-conv", + "time-core", +] + +[[package]] +name = "tiny-keccak" +version = "2.0.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2c9d3793400a45f954c52e73d068316d76b6f4e36977e3fcebb13a2721e80237" +dependencies = [ + "crunchy", +] + +[[package]] +name = "tinyvec" +version = "1.6.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "87cc5ceb3875bb20c2890005a4e226a4651264a5c75edb2421b52861a0a0cb50" +dependencies = [ + "tinyvec_macros", +] + +[[package]] +name = "tinyvec_macros" +version = "0.1.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1f3ccbac311fea05f86f61904b462b55fb3df8837a366dfc601a0161d0532f20" + +[[package]] +name = "tokio" +version = "1.37.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1adbebffeca75fcfd058afa480fb6c0b81e165a0323f9c9d39c9697e37c46787" +dependencies = [ + "backtrace", + "bytes", + "libc", + "mio", + "num_cpus", + "parking_lot", + "pin-project-lite", + "signal-hook-registry", + "socket2", + "tokio-macros", + "windows-sys 0.48.0", +] + +[[package]] +name = "tokio-macros" +version = "2.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5b8a1e28f2deaa14e508979454cb3a223b10b938b45af148bc0986de36f1923b" +dependencies = [ + "proc-macro2", + "quote", + "syn 2.0.60", +] + +[[package]] +name = "tokio-native-tls" +version = "0.3.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "bbae76ab933c85776efabc971569dd6119c580d8f5d448769dec1764bf796ef2" +dependencies = [ + "native-tls", + "tokio", +] + +[[package]] +name = "tokio-rustls" +version = "0.24.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c28327cf380ac148141087fbfb9de9d7bd4e84ab5d2c28fbc911d753de8a7081" +dependencies = [ + "rustls", + "tokio", +] + +[[package]] +name = "tokio-stream" +version = "0.1.15" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "267ac89e0bec6e691e5813911606935d77c476ff49024f98abcea3e7b15e37af" +dependencies = [ + "futures-core", + "pin-project-lite", + "tokio", + "tokio-util", +] + +[[package]] +name = "tokio-util" +version = "0.7.10" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5419f34732d9eb6ee4c3578b7989078579b7f039cbbb9ca2c4da015749371e15" +dependencies = [ + "bytes", + "futures-core", + "futures-sink", + "pin-project-lite", + "tokio", + "tracing", +] + +[[package]] +name = "toml_datetime" +version = "0.6.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7cda73e2f1397b1262d6dfdcef8aafae14d1de7748d66822d3bfeeb6d03e5e4b" + +[[package]] +name = "toml_edit" +version = "0.19.15" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1b5bb770da30e5cbfde35a2d7b9b8a2c4b8ef89548a7a6aeab5c9a576e3e7421" +dependencies = [ + "indexmap 2.2.6", + "toml_datetime", + "winnow 0.5.40", +] + +[[package]] +name = "toml_edit" +version = "0.20.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "396e4d48bbb2b7554c944bde63101b5ae446cff6ec4a24227428f15eb72ef338" +dependencies = [ + "indexmap 2.2.6", + "toml_datetime", + "winnow 0.5.40", +] + +[[package]] +name = "tower" +version = "0.4.13" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b8fa9be0de6cf49e536ce1851f987bd21a43b771b09473c3549a6c853db37c1c" +dependencies = [ + "futures-core", + "futures-util", + "pin-project", + "pin-project-lite", + "tokio", + "tower-layer", + "tower-service", + "tracing", +] + +[[package]] +name = "tower-layer" +version = "0.3.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c20c8dbed6283a09604c3e69b4b7eeb54e298b8a600d4d5ecb5ad39de609f1d0" + +[[package]] +name = "tower-service" +version = "0.3.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b6bc1c9ce2b5135ac7f93c72918fc37feb872bdc6a5533a8b85eb4b86bfdae52" + +[[package]] +name = "tracing" +version = "0.1.40" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c3523ab5a71916ccf420eebdf5521fcef02141234bbc0b8a49f2fdc4544364ef" +dependencies = [ + "log", + "pin-project-lite", + "tracing-attributes", + "tracing-core", +] + +[[package]] +name = "tracing-appender" +version = "0.2.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3566e8ce28cc0a3fe42519fc80e6b4c943cc4c8cef275620eb8dac2d3d4e06cf" +dependencies = [ + "crossbeam-channel", + "thiserror", + "time", + "tracing-subscriber", +] + +[[package]] +name = "tracing-attributes" +version = "0.1.27" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "34704c8d6ebcbc939824180af020566b01a7c01f80641264eba0999f6c2b6be7" +dependencies = [ + "proc-macro2", + "quote", + "syn 2.0.60", +] + +[[package]] +name = "tracing-core" +version = "0.1.32" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c06d3da6113f116aaee68e4d601191614c9053067f9ab7f6edbcb161237daa54" +dependencies = [ + "once_cell", + "valuable", +] + +[[package]] +name = "tracing-forest" +version = "0.1.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ee40835db14ddd1e3ba414292272eddde9dad04d3d4b65509656414d1c42592f" +dependencies = [ + "ansi_term", + "smallvec", + "thiserror", + "tracing", + "tracing-subscriber", +] + +[[package]] +name = "tracing-log" +version = "0.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ee855f1f400bd0e5c02d150ae5de3840039a3f54b025156404e34c23c03f47c3" +dependencies = [ + "log", + "once_cell", + "tracing-core", +] + +[[package]] +name = "tracing-subscriber" +version = "0.3.18" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ad0f048c97dbd9faa9b7df56362b8ebcaa52adb06b498c050d2f4e32f90a7a8b" +dependencies = [ + "matchers", + "nu-ansi-term", + "once_cell", + "regex", + "sharded-slab", + "smallvec", + "thread_local", + "tracing", + "tracing-core", + "tracing-log", +] + +[[package]] +name = "try-lock" +version = "0.2.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e421abadd41a4225275504ea4d6566923418b7f05506fbc9c0fe86ba7396114b" + +[[package]] +name = "twirp" +version = "0.3.0" +source = "git+https://github.com/github/twirp-rs.git?rev=93d4e4b#93d4e4b4a48f9112c943d2925e8dbb1106bd6a18" +dependencies = [ + "async-trait", + "axum", + "bytes", + "futures", + "http 1.1.0", + "http-body-util", + "hyper 1.3.1", + "prost", + "reqwest 0.11.27", + "serde", + "serde_json", + "thiserror", + "tokio", + "tower", + "url", +] + +[[package]] +name = "typenum" +version = "1.17.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "42ff0bf0c66b8238c6f3b578df37d0b7848e55df8577b3f74f92a69acceeb825" + +[[package]] +name = "ucd-trie" +version = "0.1.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ed646292ffc8188ef8ea4d1e0e0150fb15a5c2e12ad9b8fc191ae7a8a7f3c4b9" + +[[package]] +name = "uint" +version = "0.9.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "76f64bba2c53b04fcab63c01a7d7427eadc821e3bc48c34dc9ba29c501164b52" +dependencies = [ + "byteorder", + "crunchy", + "hex", + "static_assertions", +] + +[[package]] +name = "unarray" +version = "0.1.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "eaea85b334db583fe3274d12b4cd1880032beab409c0d774be044d4480ab9a94" + +[[package]] +name = "unicase" +version = "2.7.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f7d2d4dafb69621809a81864c9c1b864479e1235c0dd4e199924b9742439ed89" +dependencies = [ + "version_check", +] + +[[package]] +name = "unicode-bidi" +version = "0.3.15" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "08f95100a766bf4f8f28f90d77e0a5461bbdb219042e7679bebe79004fed8d75" + +[[package]] +name = "unicode-ident" +version = "1.0.12" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3354b9ac3fae1ff6755cb6db53683adb661634f67557942dea4facebec0fee4b" + +[[package]] +name = "unicode-normalization" +version = "0.1.23" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a56d1686db2308d901306f92a263857ef59ea39678a5458e7cb17f01415101f5" +dependencies = [ + "tinyvec", +] + +[[package]] +name = "unicode-width" +version = "0.1.11" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e51733f11c9c4f72aa0c160008246859e340b00807569a0da0e7a1079b27ba85" + +[[package]] +name = "untrusted" +version = "0.9.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8ecb6da28b8a351d773b68d5825ac39017e680750f980f3a1a85cd8dd28a47c1" + +[[package]] +name = "url" +version = "2.5.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "31e6302e3bb753d46e83516cae55ae196fc0c309407cf11ab35cc51a4c2a4633" +dependencies = [ + "form_urlencoded", + "idna 0.5.0", + "percent-encoding", +] + +[[package]] +name = "utf8parse" +version = "0.2.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "711b9620af191e0cdc7468a8d14e709c3dcdb115b36f838e601583af800a370a" + +[[package]] +name = "valuable" +version = "0.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "830b7e5d4d90034032940e4ace0d9a9a057e7a45cd94e6c007832e39edb82f6d" + +[[package]] +name = "vcpkg" +version = "0.2.15" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "accd4ea62f7bb7a82fe23066fb0957d48ef677f6eeb8215f372f52e48bb32426" + +[[package]] +name = "vergen" +version = "8.3.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e27d6bdd219887a9eadd19e1c34f32e47fa332301184935c6d9bca26f3cca525" +dependencies = [ + "anyhow", + "cfg-if", + "git2", + "rustversion", + "time", +] + +[[package]] +name = "version_check" +version = "0.9.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "49874b5167b65d7193b8aba1567f5c7d93d001cafc34600cee003eda787e483f" + +[[package]] +name = "wait-timeout" +version = "0.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9f200f5b12eb75f8c1ed65abd4b2db8a6e1b138a20de009dacee265a2498f3f6" +dependencies = [ + "libc", +] + +[[package]] +name = "want" +version = "0.3.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "bfa7760aed19e106de2c7c0b581b509f2f25d3dacaf737cb82ac61bc6d760b0e" +dependencies = [ + "try-lock", +] + +[[package]] +name = "wasi" +version = "0.11.0+wasi-snapshot-preview1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9c8d87e72b64a3b4db28d11ce29237c246188f4f51057d65a7eab63b7987e423" + +[[package]] +name = "wasm-bindgen" +version = "0.2.92" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4be2531df63900aeb2bca0daaaddec08491ee64ceecbee5076636a3b026795a8" +dependencies = [ + "cfg-if", + "wasm-bindgen-macro", +] + +[[package]] +name = "wasm-bindgen-backend" +version = "0.2.92" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "614d787b966d3989fa7bb98a654e369c762374fd3213d212cfc0251257e747da" +dependencies = [ + "bumpalo", + "log", + "once_cell", + "proc-macro2", + "quote", + "syn 2.0.60", + "wasm-bindgen-shared", +] + +[[package]] +name = "wasm-bindgen-futures" +version = "0.4.42" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "76bc14366121efc8dbb487ab05bcc9d346b3b5ec0eaa76e46594cabbe51762c0" +dependencies = [ + "cfg-if", + "js-sys", + "wasm-bindgen", + "web-sys", +] + +[[package]] +name = "wasm-bindgen-macro" +version = "0.2.92" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a1f8823de937b71b9460c0c34e25f3da88250760bec0ebac694b49997550d726" +dependencies = [ + "quote", + "wasm-bindgen-macro-support", +] + +[[package]] +name = "wasm-bindgen-macro-support" +version = "0.2.92" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e94f17b526d0a461a191c78ea52bbce64071ed5c04c9ffe424dcb38f74171bb7" +dependencies = [ + "proc-macro2", + "quote", + "syn 2.0.60", + "wasm-bindgen-backend", + "wasm-bindgen-shared", +] + +[[package]] +name = "wasm-bindgen-shared" +version = "0.2.92" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "af190c94f2773fdb3729c55b007a722abb5384da03bc0986df4c289bf5567e96" + +[[package]] +name = "wasm-streams" +version = "0.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b65dc4c90b63b118468cf747d8bf3566c1913ef60be765b5730ead9e0a3ba129" +dependencies = [ + "futures-util", + "js-sys", + "wasm-bindgen", + "wasm-bindgen-futures", + "web-sys", +] + +[[package]] +name = "web-sys" +version = "0.3.69" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "77afa9a11836342370f4817622a2f0f418b134426d91a82dfb48f532d2ec13ef" +dependencies = [ + "js-sys", + "wasm-bindgen", +] + +[[package]] +name = "web-time" +version = "1.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5a6580f308b1fad9207618087a65c04e7a10bc77e02c8e84e9b00dd4b12fa0bb" +dependencies = [ + "js-sys", + "wasm-bindgen", +] + +[[package]] +name = "webpki-roots" +version = "0.25.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5f20c57d8d7db6d3b86154206ae5d8fba62dd39573114de97c2cb0578251f8e1" + +[[package]] +name = "widestring" +version = "1.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7219d36b6eac893fa81e84ebe06485e7dcbb616177469b142df14f1f4deb1311" + +[[package]] +name = "winapi" +version = "0.3.9" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5c839a674fcd7a98952e593242ea400abe93992746761e38641405d28b00f419" +dependencies = [ + "winapi-i686-pc-windows-gnu", + "winapi-x86_64-pc-windows-gnu", +] + +[[package]] +name = "winapi-i686-pc-windows-gnu" +version = "0.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ac3b87c63620426dd9b991e5ce0329eff545bccbbb34f3be09ff6fb6ab51b7b6" + +[[package]] +name = "winapi-x86_64-pc-windows-gnu" +version = "0.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "712e227841d057c1ee1cd2fb22fa7e5a5461ae8e48fa2ca79ec42cfc1931183f" + +[[package]] +name = "windows-core" +version = "0.52.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "33ab640c8d7e35bf8ba19b884ba838ceb4fba93a4e8c65a9059d08afcfc683d9" +dependencies = [ + "windows-targets 0.52.5", +] + +[[package]] +name = "windows-sys" +version = "0.48.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "677d2418bec65e3338edb076e806bc1ec15693c5d0104683f2efe857f61056a9" +dependencies = [ + "windows-targets 0.48.5", +] + +[[package]] +name = "windows-sys" +version = "0.52.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "282be5f36a8ce781fad8c8ae18fa3f9beff57ec1b52cb3de0789201425d9a33d" +dependencies = [ + "windows-targets 0.52.5", +] + +[[package]] +name = "windows-targets" +version = "0.48.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9a2fa6e2155d7247be68c096456083145c183cbbbc2764150dda45a87197940c" +dependencies = [ + "windows_aarch64_gnullvm 0.48.5", + "windows_aarch64_msvc 0.48.5", + "windows_i686_gnu 0.48.5", + "windows_i686_msvc 0.48.5", + "windows_x86_64_gnu 0.48.5", + "windows_x86_64_gnullvm 0.48.5", + "windows_x86_64_msvc 0.48.5", +] + +[[package]] +name = "windows-targets" +version = "0.52.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6f0713a46559409d202e70e28227288446bf7841d3211583a4b53e3f6d96e7eb" +dependencies = [ + "windows_aarch64_gnullvm 0.52.5", + "windows_aarch64_msvc 0.52.5", + "windows_i686_gnu 0.52.5", + "windows_i686_gnullvm", + "windows_i686_msvc 0.52.5", + "windows_x86_64_gnu 0.52.5", + "windows_x86_64_gnullvm 0.52.5", + "windows_x86_64_msvc 0.52.5", +] + +[[package]] +name = "windows_aarch64_gnullvm" +version = "0.48.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2b38e32f0abccf9987a4e3079dfb67dcd799fb61361e53e2882c3cbaf0d905d8" + +[[package]] +name = "windows_aarch64_gnullvm" +version = "0.52.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7088eed71e8b8dda258ecc8bac5fb1153c5cffaf2578fc8ff5d61e23578d3263" + +[[package]] +name = "windows_aarch64_msvc" +version = "0.48.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "dc35310971f3b2dbbf3f0690a219f40e2d9afcf64f9ab7cc1be722937c26b4bc" + +[[package]] +name = "windows_aarch64_msvc" +version = "0.52.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9985fd1504e250c615ca5f281c3f7a6da76213ebd5ccc9561496568a2752afb6" + +[[package]] +name = "windows_i686_gnu" +version = "0.48.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a75915e7def60c94dcef72200b9a8e58e5091744960da64ec734a6c6e9b3743e" + +[[package]] +name = "windows_i686_gnu" +version = "0.52.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "88ba073cf16d5372720ec942a8ccbf61626074c6d4dd2e745299726ce8b89670" + +[[package]] +name = "windows_i686_gnullvm" +version = "0.52.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "87f4261229030a858f36b459e748ae97545d6f1ec60e5e0d6a3d32e0dc232ee9" + +[[package]] +name = "windows_i686_msvc" +version = "0.48.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8f55c233f70c4b27f66c523580f78f1004e8b5a8b659e05a4eb49d4166cca406" + +[[package]] +name = "windows_i686_msvc" +version = "0.52.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "db3c2bf3d13d5b658be73463284eaf12830ac9a26a90c717b7f771dfe97487bf" + +[[package]] +name = "windows_x86_64_gnu" +version = "0.48.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "53d40abd2583d23e4718fddf1ebec84dbff8381c07cae67ff7768bbf19c6718e" + +[[package]] +name = "windows_x86_64_gnu" +version = "0.52.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4e4246f76bdeff09eb48875a0fd3e2af6aada79d409d33011886d3e1581517d9" + +[[package]] +name = "windows_x86_64_gnullvm" +version = "0.48.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0b7b52767868a23d5bab768e390dc5f5c55825b6d30b86c844ff2dc7414044cc" + +[[package]] +name = "windows_x86_64_gnullvm" +version = "0.52.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "852298e482cd67c356ddd9570386e2862b5673c85bd5f88df9ab6802b334c596" + +[[package]] +name = "windows_x86_64_msvc" +version = "0.48.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ed94fce61571a4006852b7389a063ab983c02eb1bb37b47f8272ce92d06d9538" + +[[package]] +name = "windows_x86_64_msvc" +version = "0.52.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "bec47e5bfd1bff0eeaf6d8b485cc1074891a197ab4225d504cb7a1ab88b02bf0" + +[[package]] +name = "winnow" +version = "0.5.40" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f593a95398737aeed53e489c785df13f3618e41dbcd6718c6addbf1395aa6876" +dependencies = [ + "memchr", +] + +[[package]] +name = "winnow" +version = "0.6.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f0c976aaaa0e1f90dbb21e9587cdaf1d9679a1cde8875c0d6bd83ab96a208352" +dependencies = [ + "memchr", +] + +[[package]] +name = "winreg" +version = "0.50.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "524e57b2c537c0f9b1e69f1965311ec12182b4122e45035b1508cd24d2adadb1" +dependencies = [ + "cfg-if", + "windows-sys 0.48.0", +] + +[[package]] +name = "winreg" +version = "0.52.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a277a57398d4bfa075df44f501a17cfdf8542d224f0d36095a2adc7aee4ef0a5" +dependencies = [ + "cfg-if", + "windows-sys 0.48.0", +] + +[[package]] +name = "wyz" +version = "0.5.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "05f360fc0b24296329c78fda852a1e9ae82de9cf7b27dae4b7f62f118f77b9ed" +dependencies = [ + "tap", +] + +[[package]] +name = "zerocopy" +version = "0.7.32" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "74d4d3961e53fa4c9a25a8637fc2bfaf2595b3d3ae34875568a5cf64787716be" +dependencies = [ + "zerocopy-derive", +] + +[[package]] +name = "zerocopy-derive" +version = "0.7.32" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9ce1b18ccd8e73a9321186f97e46f9f04b778851177567b1975109d26a08d2a6" +dependencies = [ + "proc-macro2", + "quote", + "syn 2.0.60", +] + +[[package]] +name = "zeroize" +version = "1.7.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "525b4ec142c6b68a2d10f01f7bbf6755599ca3f81ea53b8431b7dd348f5fdb2d" +dependencies = [ + "zeroize_derive", +] + +[[package]] +name = "zeroize_derive" +version = "1.4.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ce36e65b0d2999d2aafac989fb249189a141aee1f53c612c1f37d72631959f69" +dependencies = [ + "proc-macro2", + "quote", + "syn 2.0.60", +] + +[[package]] +name = "zkhash" +version = "0.2.0" +source = "git+https://github.com/HorizenLabs/poseidon2#bb476b9ca38198cf5092487283c8b8c5d4317c4e" +dependencies = [ + "ark-ff 0.4.2", + "ark-std 0.4.0", + "bitvec", + "blake2", + "bls12_381", + "byteorder", + "cfg-if", + "group 0.12.1", + "group 0.13.0", + "halo2", + "hex", + "jubjub", + "lazy_static", + "pasta_curves 0.5.1", + "rand", + "serde", + "sha2 0.10.8", + "sha3", + "subtle", +] diff --git a/examples/patch-testing/script/Cargo.toml b/examples/patch-testing/script/Cargo.toml new file mode 100644 index 0000000000..e074ce86c5 --- /dev/null +++ b/examples/patch-testing/script/Cargo.toml @@ -0,0 +1,15 @@ +[package] +name = "patch-testing-script" +version = { workspace = true } +edition = { workspace = true } +publish = false + +[dependencies] +rand = "0.8" +ed25519-consensus = "2.1.0" +sp1-core = { workspace = true, features = ["neon"] } +sp1-sdk = { workspace = true } +tiny-keccak = { version = "2.0.2", features = ["keccak"] } + +[build-dependencies] +sp1-helper = { workspace = true } diff --git a/examples/patch-testing/script/build.rs b/examples/patch-testing/script/build.rs new file mode 100644 index 0000000000..03388acab7 --- /dev/null +++ b/examples/patch-testing/script/build.rs @@ -0,0 +1,3 @@ +fn main() { + sp1_helper::build_program(&format!("{}/../program", env!("CARGO_MANIFEST_DIR"))); +} diff --git a/examples/patch-testing/script/src/main.rs b/examples/patch-testing/script/src/main.rs new file mode 100644 index 0000000000..08ccfb356b --- /dev/null +++ b/examples/patch-testing/script/src/main.rs @@ -0,0 +1,51 @@ +use ed25519_consensus::{SigningKey, VerificationKey}; +use rand::thread_rng; +use sp1_sdk::{utils, ProverClient, SP1Stdin}; + +const PATCH_TEST_ELF: &[u8] = include_bytes!("../../program/elf/riscv32im-succinct-zkvm-elf"); + +/// This script is used to test that SP1 patches are correctly applied and syscalls are triggered. +fn main() { + utils::setup_logger(); + + let mut stdin = SP1Stdin::new(); + + let sk = SigningKey::new(thread_rng()); + let vk = VerificationKey::from(&sk); + + let msg = b"ed25519-consensus test message"; + + let sig = sk.sign(msg); + stdin.write(&sig); + stdin.write(&vk); + stdin.write_vec(msg.to_vec()); + + let client = ProverClient::new(); + let (_, report) = client + .execute(PATCH_TEST_ELF, stdin) + .run() + .expect("executing failed"); + + // Confirm there was at least 1 SHA_COMPUTE syscall. + assert!(report + .syscall_counts + .contains_key(&sp1_core::runtime::SyscallCode::SHA_COMPRESS)); + assert!(report + .syscall_counts + .contains_key(&sp1_core::runtime::SyscallCode::SHA_EXTEND)); + + // Confirm there was at least 1 ED25519_COMPUTE syscalls. + assert!(report + .syscall_counts + .contains_key(&sp1_core::runtime::SyscallCode::ED_ADD)); + assert!(report + .syscall_counts + .contains_key(&sp1_core::runtime::SyscallCode::ED_DECOMPRESS)); + + // Confirm there was at least 1 KECCAK_PERMUTE syscall. + assert!(report + .syscall_counts + .contains_key(&sp1_core::runtime::SyscallCode::KECCAK_PERMUTE)); + + println!("Successfully executed the program & confirmed syscalls."); +} diff --git a/examples/regex/program/Cargo.lock b/examples/regex/program/Cargo.lock index d5a4c9bd5d..e99e196c7a 100644 --- a/examples/regex/program/Cargo.lock +++ b/examples/regex/program/Cargo.lock @@ -17,30 +17,6 @@ version = "1.0.83" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "25bdb32cbbdce2b519a9cd7df3a678443100e265d5e25ca763b7572a5104f5f3" -[[package]] -name = "arrayvec" -version = "0.7.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "96d30a06541fbafbc7f82ed10c06164cfbd2c401138f6addd8404629c4b16711" - -[[package]] -name = "autocfg" -version = "1.2.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f1fdabc7756949593fe60f30ec81974b613357de856987752631dea1e3394c80" - -[[package]] -name = "base16ct" -version = "0.2.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4c7f02d4ea65f2c1853089ffd8d2787bdbc63de2f0d29dedbcf8ccdfa0ccd4cf" - -[[package]] -name = "base64ct" -version = "1.6.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8c3c1a368f70d6cf7302d78f8f7093da241fb8e8807c05cc9e51a125895a6d5b" - [[package]] name = "bincode" version = "1.3.3" @@ -50,18 +26,6 @@ dependencies = [ "serde", ] -[[package]] -name = "bitvec" -version = "1.0.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1bc2832c24239b0141d5674bb9174f9d68a8b5b3f2753311927c172ca46f7e9c" -dependencies = [ - "funty", - "radium", - "tap", - "wyz", -] - [[package]] name = "block-buffer" version = "0.10.4" @@ -71,24 +35,12 @@ dependencies = [ "generic-array", ] -[[package]] -name = "byte-slice-cast" -version = "1.2.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c3ac9f8b63eca6fd385229b3675f6cc0dc5c8a5c8a54a59d4f52ffd670d87b0c" - [[package]] name = "cfg-if" version = "1.0.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "baf1de4339761588bc0619e3cbc0120ee582ebb74b53b4efbf79117bd2da40fd" -[[package]] -name = "const-oid" -version = "0.9.6" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c2459377285ad874054d797f3ccebf984978aa39129f6eafde5cdc8315b612f8" - [[package]] name = "cpufeatures" version = "0.2.12" @@ -98,18 +50,6 @@ dependencies = [ "libc", ] -[[package]] -name = "crypto-bigint" -version = "0.5.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0dc92fb57ca44df6db8059111ab3af99a63d5d0f8375d9972e319a379c6bab76" -dependencies = [ - "generic-array", - "rand_core", - "subtle", - "zeroize", -] - [[package]] name = "crypto-common" version = "0.1.6" @@ -120,27 +60,6 @@ dependencies = [ "typenum", ] -[[package]] -name = "der" -version = "0.7.9" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f55bf8e7b65898637379c1b74eb1551107c8294ed26d855ceb9fd1a09cfc9bc0" -dependencies = [ - "const-oid", - "zeroize", -] - -[[package]] -name = "derive_more" -version = "0.99.17" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4fb810d30a7c1953f91334de7244731fc3f3c10d7fe163338a35b9f640960321" -dependencies = [ - "proc-macro2", - "quote", - "syn 1.0.109", -] - [[package]] name = "digest" version = "0.10.7" @@ -148,68 +67,9 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "9ed9a281f7bc9b7576e61468ba615a66a5c8cfdff42420a70aa82701a3b1e292" dependencies = [ "block-buffer", - "const-oid", "crypto-common", - "subtle", -] - -[[package]] -name = "ecdsa" -version = "0.16.9" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ee27f32b5c5292967d2d4a9d7f1e0b0aed2c15daded5a60300e4abb9d8020bca" -dependencies = [ - "der", - "digest", - "elliptic-curve", - "rfc6979", - "signature", - "spki", -] - -[[package]] -name = "elliptic-curve" -version = "0.13.8" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b5e6043086bf7973472e0c7dff2142ea0b680d30e18d9cc40f267efbf222bd47" -dependencies = [ - "base16ct", - "crypto-bigint", - "digest", - "ff", - "generic-array", - "group", - "pkcs8", - "rand_core", - "sec1", - "subtle", - "tap", - "zeroize", -] - -[[package]] -name = "equivalent" -version = "1.0.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5443807d6dff69373d433ab9ef5378ad8df50ca6298caf15de6e52e24aaf54d5" - -[[package]] -name = "ff" -version = "0.13.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ded41244b729663b1e574f1b4fb731469f69f79c17667b5d776b16cda0479449" -dependencies = [ - "bitvec", - "rand_core", - "subtle", ] -[[package]] -name = "funty" -version = "2.0.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e6d5a32815ae3f33302d95fdcb2ce17862f8c65363dcfd29360480ba1001fc9c" - [[package]] name = "generic-array" version = "0.14.7" @@ -218,7 +78,6 @@ checksum = "85649ca51fd72272d7821adaf274ad91c288277713d9c18820d8499a7ff69e9a" dependencies = [ "typenum", "version_check", - "zeroize", ] [[package]] @@ -232,78 +91,11 @@ dependencies = [ "wasi", ] -[[package]] -name = "group" -version = "0.13.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f0f9ef7462f7c099f518d754361858f86d8a07af53ba9af0fe635bbccb151a63" -dependencies = [ - "ff", - "rand_core", - "subtle", -] - -[[package]] -name = "hashbrown" -version = "0.14.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "290f1a1d9242c78d09ce40a5e87e7554ee637af1351968159f4952f028f75604" - -[[package]] -name = "hex" -version = "0.4.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7f24254aa9a54b5c858eaee2f5bccdb46aaf0e486a595ed5fd8f86ba55232a70" - -[[package]] -name = "hmac" -version = "0.12.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6c49c37c09c17a53d937dfbb742eb3a961d65a994e6bcdcf37e7399d0cc8ab5e" -dependencies = [ - "digest", -] - -[[package]] -name = "impl-trait-for-tuples" -version = "0.2.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "11d7a9f6330b71fea57921c9b61c47ee6e84f72d394754eff6163ae67e7395eb" -dependencies = [ - "proc-macro2", - "quote", - "syn 1.0.109", -] - -[[package]] -name = "indexmap" -version = "2.2.6" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "168fb715dda47215e360912c096649d23d58bf392ac62f73919e831745e40f26" -dependencies = [ - "equivalent", - "hashbrown", -] - -[[package]] -name = "k256" -version = "0.13.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "956ff9b67e26e1a6a866cb758f12c6f8746208489e3e4a4b5580802f2f0a587b" -dependencies = [ - "cfg-if", - "ecdsa", - "elliptic-curve", - "once_cell", - "sha2", - "signature", -] - [[package]] name = "lazy_static" -version = "1.4.0" +version = "1.5.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e2abad23fbc42b3700f2f279844dc832adb2b2eb069b2df918f455c4e18cc646" +checksum = "bbd2bcb4c963f2ddae06a2efc7e9f3591312473c50c6685e1f298068316e66fe" [[package]] name = "libc" @@ -323,145 +115,18 @@ version = "2.7.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "6c8640c5d730cb13ebd907d8d04b52f55ac9a2eec55b440c8892f40d56c76c1d" -[[package]] -name = "num" -version = "0.4.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "35bd024e8b2ff75562e5f34e7f4905839deb4b22955ef5e73d2fea1b9813cb23" -dependencies = [ - "num-bigint", - "num-complex", - "num-integer", - "num-iter", - "num-rational", - "num-traits", -] - -[[package]] -name = "num-bigint" -version = "0.4.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c165a9ab64cf766f73521c0dd2cfdff64f488b8f0b3e621face3462d3db536d7" -dependencies = [ - "num-integer", - "num-traits", -] - -[[package]] -name = "num-complex" -version = "0.4.6" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "73f88a1307638156682bada9d7604135552957b7818057dcef22705b4d509495" -dependencies = [ - "num-traits", -] - -[[package]] -name = "num-integer" -version = "0.1.46" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7969661fd2958a5cb096e56c8e1ad0444ac2bbcd0061bd28660485a44879858f" -dependencies = [ - "num-traits", -] - -[[package]] -name = "num-iter" -version = "0.1.45" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1429034a0490724d0075ebb2bc9e875d6503c3cf69e235a8941aa757d83ef5bf" -dependencies = [ - "autocfg", - "num-integer", - "num-traits", -] - -[[package]] -name = "num-rational" -version = "0.4.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f83d14da390562dca69fc84082e73e548e1ad308d24accdedd2720017cb37824" -dependencies = [ - "num-bigint", - "num-integer", - "num-traits", -] - -[[package]] -name = "num-traits" -version = "0.2.19" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "071dfc062690e90b734c0b2273ce72ad0ffa95f0c74596bc250dcfd960262841" -dependencies = [ - "autocfg", -] - [[package]] name = "once_cell" version = "1.19.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "3fdb12b2476b595f9358c5161aa467c2438859caa136dec86c26fdd2efe17b92" -[[package]] -name = "parity-scale-codec" -version = "3.6.9" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "881331e34fa842a2fb61cc2db9643a8fedc615e47cfcc52597d1af0db9a7e8fe" -dependencies = [ - "arrayvec", - "byte-slice-cast", - "impl-trait-for-tuples", - "parity-scale-codec-derive", -] - -[[package]] -name = "parity-scale-codec-derive" -version = "3.6.9" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "be30eaf4b0a9fba5336683b38de57bb86d179a35862ba6bfcf57625d006bde5b" -dependencies = [ - "proc-macro-crate 2.0.2", - "proc-macro2", - "quote", - "syn 1.0.109", -] - -[[package]] -name = "pkcs8" -version = "0.10.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f950b2377845cebe5cf8b5165cb3cc1a5e0fa5cfa3e1f7f55707d8fd82e0a7b7" -dependencies = [ - "der", - "spki", -] - [[package]] name = "ppv-lite86" version = "0.2.17" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "5b40af805b3121feab8a3c29f04d8ad262fa8e0561883e7653e024ae4479e6de" -[[package]] -name = "proc-macro-crate" -version = "1.3.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7f4c021e1093a56626774e81216a4ce732a735e5bad4868a03f3ed65ca0c3919" -dependencies = [ - "once_cell", - "toml_edit 0.19.15", -] - -[[package]] -name = "proc-macro-crate" -version = "2.0.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b00f26d3400549137f92511a46ac1cd8ce37cb5598a96d382381458b992a5d24" -dependencies = [ - "toml_datetime", - "toml_edit 0.20.2", -] - [[package]] name = "proc-macro2" version = "1.0.81" @@ -480,12 +145,6 @@ dependencies = [ "proc-macro2", ] -[[package]] -name = "radium" -version = "0.7.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "dc33ff2d4973d518d823d61aa239014831e521c75da58e3df4840d3f47749d09" - [[package]] name = "rand" version = "0.8.5" @@ -541,7 +200,7 @@ dependencies = [ [[package]] name = "regex-program" -version = "0.1.0" +version = "1.0.0-rc.1" dependencies = [ "regex", "sp1-zkvm", @@ -553,72 +212,24 @@ version = "0.8.3" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "adad44e29e4c806119491a7f06f03de4d1af22c3a680dd47f1e6e179439d1f56" -[[package]] -name = "rfc6979" -version = "0.4.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f8dd2a808d456c4a54e300a23e9f5a67e122c3024119acbfd73e3bf664491cb2" -dependencies = [ - "hmac", - "subtle", -] - -[[package]] -name = "scale-info" -version = "2.11.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7c453e59a955f81fb62ee5d596b450383d699f152d350e9d23a0db2adb78e4c0" -dependencies = [ - "cfg-if", - "derive_more", - "parity-scale-codec", - "scale-info-derive", -] - -[[package]] -name = "scale-info-derive" -version = "2.11.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "18cf6c6447f813ef19eb450e985bcce6705f9ce7660db221b59093d15c79c4b7" -dependencies = [ - "proc-macro-crate 1.3.1", - "proc-macro2", - "quote", - "syn 1.0.109", -] - -[[package]] -name = "sec1" -version = "0.7.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d3e97a565f76233a6003f9f5c54be1d9c5bdfa3eccfb189469f11ec4901c47dc" -dependencies = [ - "base16ct", - "der", - "generic-array", - "pkcs8", - "subtle", - "zeroize", -] - [[package]] name = "serde" -version = "1.0.201" +version = "1.0.204" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "780f1cebed1629e4753a1a38a3c72d30b97ec044f0aef68cb26650a3c5cf363c" +checksum = "bc76f558e0cbb2a839d37354c575f1dc3fdc6546b5be373ba43d95f231bf7c12" dependencies = [ "serde_derive", ] [[package]] name = "serde_derive" -version = "1.0.201" +version = "1.0.204" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c5e405930b9796f1c00bee880d03fc7e0bb4b9a11afc776885ffe84320da2865" +checksum = "e0cd7e117be63d3c3678776753929474f3b04a43a080c744d6b0ae2a8c28e222" dependencies = [ "proc-macro2", "quote", - "syn 2.0.60", + "syn", ] [[package]] @@ -633,83 +244,29 @@ dependencies = [ ] [[package]] -name = "signature" -version = "2.2.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "77549399552de45a898a580c1b41d445bf730df867cc44e6c0233bbc4b8329de" -dependencies = [ - "digest", - "rand_core", -] - -[[package]] -name = "snowbridge-amcl" -version = "1.0.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "460a9ed63cdf03c1b9847e8a12a5f5ba19c4efd5869e4a737e05be25d7c427e5" -dependencies = [ - "parity-scale-codec", - "scale-info", -] - -[[package]] -name = "sp1-precompiles" -version = "0.1.0" +name = "sp1-lib" +version = "1.0.0-rc.1" dependencies = [ "anyhow", "bincode", "cfg-if", - "getrandom", - "hex", - "k256", - "num", - "rand", "serde", - "snowbridge-amcl", ] [[package]] name = "sp1-zkvm" -version = "0.1.0" +version = "1.0.0-rc.1" dependencies = [ "bincode", "cfg-if", "getrandom", - "k256", "lazy_static", "libm", "once_cell", "rand", "serde", "sha2", - "sp1-precompiles", -] - -[[package]] -name = "spki" -version = "0.7.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d91ed6c858b01f942cd56b37a94b3e0a1798290327d1236e4d9cf4eaca44d29d" -dependencies = [ - "base64ct", - "der", -] - -[[package]] -name = "subtle" -version = "2.5.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "81cdd64d312baedb58e21336b31bc043b77e01cc99033ce76ef539f78e965ebc" - -[[package]] -name = "syn" -version = "1.0.109" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "72b64191b275b66ffe2469e8af2c1cfe3bafa67b529ead792a6d0160888b4237" -dependencies = [ - "proc-macro2", - "quote", - "unicode-ident", + "sp1-lib", ] [[package]] @@ -723,40 +280,6 @@ dependencies = [ "unicode-ident", ] -[[package]] -name = "tap" -version = "1.0.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "55937e1799185b12863d447f42597ed69d9928686b8d88a1df17376a097d8369" - -[[package]] -name = "toml_datetime" -version = "0.6.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7cda73e2f1397b1262d6dfdcef8aafae14d1de7748d66822d3bfeeb6d03e5e4b" - -[[package]] -name = "toml_edit" -version = "0.19.15" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1b5bb770da30e5cbfde35a2d7b9b8a2c4b8ef89548a7a6aeab5c9a576e3e7421" -dependencies = [ - "indexmap", - "toml_datetime", - "winnow", -] - -[[package]] -name = "toml_edit" -version = "0.20.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "396e4d48bbb2b7554c944bde63101b5ae446cff6ec4a24227428f15eb72ef338" -dependencies = [ - "indexmap", - "toml_datetime", - "winnow", -] - [[package]] name = "typenum" version = "1.17.0" @@ -780,27 +303,3 @@ name = "wasi" version = "0.11.0+wasi-snapshot-preview1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "9c8d87e72b64a3b4db28d11ce29237c246188f4f51057d65a7eab63b7987e423" - -[[package]] -name = "winnow" -version = "0.5.40" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f593a95398737aeed53e489c785df13f3618e41dbcd6718c6addbf1395aa6876" -dependencies = [ - "memchr", -] - -[[package]] -name = "wyz" -version = "0.5.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "05f360fc0b24296329c78fda852a1e9ae82de9cf7b27dae4b7f62f118f77b9ed" -dependencies = [ - "tap", -] - -[[package]] -name = "zeroize" -version = "1.7.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "525b4ec142c6b68a2d10f01f7bbf6755599ca3f81ea53b8431b7dd348f5fdb2d" diff --git a/examples/regex/program/Cargo.toml b/examples/regex/program/Cargo.toml index a75ed5c5ab..6ebe448da7 100644 --- a/examples/regex/program/Cargo.toml +++ b/examples/regex/program/Cargo.toml @@ -1,8 +1,9 @@ [workspace] [package] -version = "0.1.0" name = "regex-program" +version = "1.0.0-rc.1" edition = "2021" +publish = false [dependencies] sp1-zkvm = { path = "../../../zkvm/entrypoint" } diff --git a/examples/regex/program/elf/riscv32im-succinct-zkvm-elf b/examples/regex/program/elf/riscv32im-succinct-zkvm-elf index 8114ee471d..4a8b114e2e 100755 Binary files a/examples/regex/program/elf/riscv32im-succinct-zkvm-elf and b/examples/regex/program/elf/riscv32im-succinct-zkvm-elf differ diff --git a/examples/regex/script/Cargo.toml b/examples/regex/script/Cargo.toml index f5c6aec68a..4efbee5cb5 100644 --- a/examples/regex/script/Cargo.toml +++ b/examples/regex/script/Cargo.toml @@ -1,10 +1,11 @@ [package] -version = "0.1.0" name = "regex-script" -edition = "2021" +version = { workspace = true } +edition = { workspace = true } +publish = false [dependencies] -sp1-sdk = { path = "../../../sdk" } +sp1-sdk = { workspace = true } [build-dependencies] -sp1-helper = { path = "../../../helper" } +sp1-helper = { workspace = true } diff --git a/examples/regex/script/src/main.rs b/examples/regex/script/src/main.rs index dd8b35d7fa..3c815df04c 100644 --- a/examples/regex/script/src/main.rs +++ b/examples/regex/script/src/main.rs @@ -1,4 +1,4 @@ -use sp1_sdk::{utils, ProverClient, SP1Proof, SP1Stdin}; +use sp1_sdk::{utils, ProverClient, SP1ProofWithPublicValues, SP1Stdin}; /// The ELF we want to execute inside the zkVM. const REGEX_IO_ELF: &[u8] = include_bytes!("../../program/elf/riscv32im-succinct-zkvm-elf"); @@ -20,7 +20,7 @@ fn main() { // Generate the proof for the given program and input. let client = ProverClient::new(); let (pk, vk) = client.setup(REGEX_IO_ELF); - let mut proof = client.prove(&pk, stdin).expect("proving failed"); + let mut proof = client.prove(&pk, stdin).run().expect("proving failed"); // Read the output. let res = proof.public_values.read::(); @@ -33,7 +33,8 @@ fn main() { proof .save("proof-with-pis.bin") .expect("saving proof failed"); - let deserialized_proof = SP1Proof::load("proof-with-pis.bin").expect("loading proof failed"); + let deserialized_proof = + SP1ProofWithPublicValues::load("proof-with-pis.bin").expect("loading proof failed"); // Verify the deserialized proof. client diff --git a/examples/rsa/program/Cargo.lock b/examples/rsa/program/Cargo.lock index 59a046b519..7a55b190c9 100644 --- a/examples/rsa/program/Cargo.lock +++ b/examples/rsa/program/Cargo.lock @@ -8,24 +8,12 @@ version = "1.0.83" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "25bdb32cbbdce2b519a9cd7df3a678443100e265d5e25ca763b7572a5104f5f3" -[[package]] -name = "arrayvec" -version = "0.7.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "96d30a06541fbafbc7f82ed10c06164cfbd2c401138f6addd8404629c4b16711" - [[package]] name = "autocfg" version = "1.2.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "f1fdabc7756949593fe60f30ec81974b613357de856987752631dea1e3394c80" -[[package]] -name = "base16ct" -version = "0.2.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4c7f02d4ea65f2c1853089ffd8d2787bdbc63de2f0d29dedbcf8ccdfa0ccd4cf" - [[package]] name = "base64ct" version = "1.6.0" @@ -41,18 +29,6 @@ dependencies = [ "serde", ] -[[package]] -name = "bitvec" -version = "1.0.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1bc2832c24239b0141d5674bb9174f9d68a8b5b3f2753311927c172ca46f7e9c" -dependencies = [ - "funty", - "radium", - "tap", - "wyz", -] - [[package]] name = "block-buffer" version = "0.9.0" @@ -71,12 +47,6 @@ dependencies = [ "generic-array", ] -[[package]] -name = "byte-slice-cast" -version = "1.2.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c3ac9f8b63eca6fd385229b3675f6cc0dc5c8a5c8a54a59d4f52ffd670d87b0c" - [[package]] name = "byteorder" version = "1.5.0" @@ -95,12 +65,6 @@ version = "0.7.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "e4c78c047431fee22c1a7bb92e00ad095a02a983affe4d8a72e2a2c62c1b94f3" -[[package]] -name = "const-oid" -version = "0.9.6" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c2459377285ad874054d797f3ccebf984978aa39129f6eafde5cdc8315b612f8" - [[package]] name = "cpufeatures" version = "0.2.12" @@ -120,18 +84,6 @@ dependencies = [ "subtle", ] -[[package]] -name = "crypto-bigint" -version = "0.5.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0dc92fb57ca44df6db8059111ab3af99a63d5d0f8375d9972e319a379c6bab76" -dependencies = [ - "generic-array", - "rand_core", - "subtle", - "zeroize", -] - [[package]] name = "crypto-common" version = "0.1.6" @@ -148,32 +100,11 @@ version = "0.5.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "6919815d73839e7ad218de758883aae3a257ba6759ce7a9992501efbb53d705c" dependencies = [ - "const-oid 0.7.1", - "crypto-bigint 0.3.2", + "const-oid", + "crypto-bigint", "pem-rfc7468", ] -[[package]] -name = "der" -version = "0.7.9" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f55bf8e7b65898637379c1b74eb1551107c8294ed26d855ceb9fd1a09cfc9bc0" -dependencies = [ - "const-oid 0.9.6", - "zeroize", -] - -[[package]] -name = "derive_more" -version = "0.99.17" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4fb810d30a7c1953f91334de7244731fc3f3c10d7fe163338a35b9f640960321" -dependencies = [ - "proc-macro2", - "quote", - "syn 1.0.109", -] - [[package]] name = "digest" version = "0.9.0" @@ -190,68 +121,9 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "9ed9a281f7bc9b7576e61468ba615a66a5c8cfdff42420a70aa82701a3b1e292" dependencies = [ "block-buffer 0.10.4", - "const-oid 0.9.6", "crypto-common", - "subtle", -] - -[[package]] -name = "ecdsa" -version = "0.16.9" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ee27f32b5c5292967d2d4a9d7f1e0b0aed2c15daded5a60300e4abb9d8020bca" -dependencies = [ - "der 0.7.9", - "digest 0.10.7", - "elliptic-curve", - "rfc6979", - "signature", - "spki 0.7.3", ] -[[package]] -name = "elliptic-curve" -version = "0.13.8" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b5e6043086bf7973472e0c7dff2142ea0b680d30e18d9cc40f267efbf222bd47" -dependencies = [ - "base16ct", - "crypto-bigint 0.5.5", - "digest 0.10.7", - "ff", - "generic-array", - "group", - "pkcs8 0.10.2", - "rand_core", - "sec1", - "subtle", - "tap", - "zeroize", -] - -[[package]] -name = "equivalent" -version = "1.0.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5443807d6dff69373d433ab9ef5378ad8df50ca6298caf15de6e52e24aaf54d5" - -[[package]] -name = "ff" -version = "0.13.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ded41244b729663b1e574f1b4fb731469f69f79c17667b5d776b16cda0479449" -dependencies = [ - "bitvec", - "rand_core", - "subtle", -] - -[[package]] -name = "funty" -version = "2.0.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e6d5a32815ae3f33302d95fdcb2ce17862f8c65363dcfd29360480ba1001fc9c" - [[package]] name = "generic-array" version = "0.14.7" @@ -260,7 +132,6 @@ checksum = "85649ca51fd72272d7821adaf274ad91c288277713d9c18820d8499a7ff69e9a" dependencies = [ "typenum", "version_check", - "zeroize", ] [[package]] @@ -274,78 +145,11 @@ dependencies = [ "wasi", ] -[[package]] -name = "group" -version = "0.13.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f0f9ef7462f7c099f518d754361858f86d8a07af53ba9af0fe635bbccb151a63" -dependencies = [ - "ff", - "rand_core", - "subtle", -] - -[[package]] -name = "hashbrown" -version = "0.14.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "290f1a1d9242c78d09ce40a5e87e7554ee637af1351968159f4952f028f75604" - -[[package]] -name = "hex" -version = "0.4.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7f24254aa9a54b5c858eaee2f5bccdb46aaf0e486a595ed5fd8f86ba55232a70" - -[[package]] -name = "hmac" -version = "0.12.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6c49c37c09c17a53d937dfbb742eb3a961d65a994e6bcdcf37e7399d0cc8ab5e" -dependencies = [ - "digest 0.10.7", -] - -[[package]] -name = "impl-trait-for-tuples" -version = "0.2.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "11d7a9f6330b71fea57921c9b61c47ee6e84f72d394754eff6163ae67e7395eb" -dependencies = [ - "proc-macro2", - "quote", - "syn 1.0.109", -] - -[[package]] -name = "indexmap" -version = "2.2.6" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "168fb715dda47215e360912c096649d23d58bf392ac62f73919e831745e40f26" -dependencies = [ - "equivalent", - "hashbrown", -] - -[[package]] -name = "k256" -version = "0.13.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "956ff9b67e26e1a6a866cb758f12c6f8746208489e3e4a4b5580802f2f0a587b" -dependencies = [ - "cfg-if", - "ecdsa", - "elliptic-curve", - "once_cell", - "sha2 0.10.8", - "signature", -] - [[package]] name = "lazy_static" -version = "1.4.0" +version = "1.5.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e2abad23fbc42b3700f2f279844dc832adb2b2eb069b2df918f455c4e18cc646" +checksum = "bbd2bcb4c963f2ddae06a2efc7e9f3591312473c50c6685e1f298068316e66fe" dependencies = [ "spin", ] @@ -362,36 +166,6 @@ version = "0.2.8" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "4ec2a862134d2a7d32d7983ddcdd1c4923530833c9f2ea1a44fc5fa473989058" -[[package]] -name = "memchr" -version = "2.7.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6c8640c5d730cb13ebd907d8d04b52f55ac9a2eec55b440c8892f40d56c76c1d" - -[[package]] -name = "num" -version = "0.4.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "35bd024e8b2ff75562e5f34e7f4905839deb4b22955ef5e73d2fea1b9813cb23" -dependencies = [ - "num-bigint", - "num-complex", - "num-integer", - "num-iter", - "num-rational", - "num-traits", -] - -[[package]] -name = "num-bigint" -version = "0.4.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c165a9ab64cf766f73521c0dd2cfdff64f488b8f0b3e621face3462d3db536d7" -dependencies = [ - "num-integer", - "num-traits", -] - [[package]] name = "num-bigint-dig" version = "0.8.4" @@ -409,15 +183,6 @@ dependencies = [ "zeroize", ] -[[package]] -name = "num-complex" -version = "0.4.6" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "73f88a1307638156682bada9d7604135552957b7818057dcef22705b4d509495" -dependencies = [ - "num-traits", -] - [[package]] name = "num-integer" version = "0.1.46" @@ -438,17 +203,6 @@ dependencies = [ "num-traits", ] -[[package]] -name = "num-rational" -version = "0.4.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f83d14da390562dca69fc84082e73e548e1ad308d24accdedd2720017cb37824" -dependencies = [ - "num-bigint", - "num-integer", - "num-traits", -] - [[package]] name = "num-traits" version = "0.2.19" @@ -471,30 +225,6 @@ version = "0.3.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "c08d65885ee38876c4f86fa503fb49d7b507c2b62552df7c70b2fce627e06381" -[[package]] -name = "parity-scale-codec" -version = "3.6.9" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "881331e34fa842a2fb61cc2db9643a8fedc615e47cfcc52597d1af0db9a7e8fe" -dependencies = [ - "arrayvec", - "byte-slice-cast", - "impl-trait-for-tuples", - "parity-scale-codec-derive", -] - -[[package]] -name = "parity-scale-codec-derive" -version = "3.6.9" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "be30eaf4b0a9fba5336683b38de57bb86d179a35862ba6bfcf57625d006bde5b" -dependencies = [ - "proc-macro-crate 2.0.2", - "proc-macro2", - "quote", - "syn 1.0.109", -] - [[package]] name = "pem-rfc7468" version = "0.3.1" @@ -510,8 +240,8 @@ version = "0.3.3" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "a78f66c04ccc83dd4486fd46c33896f4e17b24a7a3a6400dedc48ed0ddd72320" dependencies = [ - "der 0.5.1", - "pkcs8 0.8.0", + "der", + "pkcs8", "zeroize", ] @@ -521,47 +251,17 @@ version = "0.8.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "7cabda3fb821068a9a4fab19a683eac3af12edf0f34b94a8be53c4972b8149d0" dependencies = [ - "der 0.5.1", - "spki 0.5.4", + "der", + "spki", "zeroize", ] -[[package]] -name = "pkcs8" -version = "0.10.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f950b2377845cebe5cf8b5165cb3cc1a5e0fa5cfa3e1f7f55707d8fd82e0a7b7" -dependencies = [ - "der 0.7.9", - "spki 0.7.3", -] - [[package]] name = "ppv-lite86" version = "0.2.17" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "5b40af805b3121feab8a3c29f04d8ad262fa8e0561883e7653e024ae4479e6de" -[[package]] -name = "proc-macro-crate" -version = "1.3.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7f4c021e1093a56626774e81216a4ce732a735e5bad4868a03f3ed65ca0c3919" -dependencies = [ - "once_cell", - "toml_edit 0.19.15", -] - -[[package]] -name = "proc-macro-crate" -version = "2.0.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b00f26d3400549137f92511a46ac1cd8ce37cb5598a96d382381458b992a5d24" -dependencies = [ - "toml_datetime", - "toml_edit 0.20.2", -] - [[package]] name = "proc-macro2" version = "1.0.81" @@ -580,12 +280,6 @@ dependencies = [ "proc-macro2", ] -[[package]] -name = "radium" -version = "0.7.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "dc33ff2d4973d518d823d61aa239014831e521c75da58e3df4840d3f47749d09" - [[package]] name = "rand" version = "0.8.5" @@ -616,16 +310,6 @@ dependencies = [ "getrandom", ] -[[package]] -name = "rfc6979" -version = "0.4.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f8dd2a808d456c4a54e300a23e9f5a67e122c3024119acbfd73e3bf664491cb2" -dependencies = [ - "hmac", - "subtle", -] - [[package]] name = "rsa" version = "0.6.1" @@ -639,7 +323,7 @@ dependencies = [ "num-iter", "num-traits", "pkcs1", - "pkcs8 0.8.0", + "pkcs8", "rand_core", "smallvec", "subtle", @@ -648,7 +332,7 @@ dependencies = [ [[package]] name = "rsa-program" -version = "0.1.0" +version = "1.0.0-rc.1" dependencies = [ "digest 0.10.7", "rand", @@ -657,62 +341,24 @@ dependencies = [ "sp1-zkvm", ] -[[package]] -name = "scale-info" -version = "2.11.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7c453e59a955f81fb62ee5d596b450383d699f152d350e9d23a0db2adb78e4c0" -dependencies = [ - "cfg-if", - "derive_more", - "parity-scale-codec", - "scale-info-derive", -] - -[[package]] -name = "scale-info-derive" -version = "2.11.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "18cf6c6447f813ef19eb450e985bcce6705f9ce7660db221b59093d15c79c4b7" -dependencies = [ - "proc-macro-crate 1.3.1", - "proc-macro2", - "quote", - "syn 1.0.109", -] - -[[package]] -name = "sec1" -version = "0.7.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d3e97a565f76233a6003f9f5c54be1d9c5bdfa3eccfb189469f11ec4901c47dc" -dependencies = [ - "base16ct", - "der 0.7.9", - "generic-array", - "pkcs8 0.10.2", - "subtle", - "zeroize", -] - [[package]] name = "serde" -version = "1.0.201" +version = "1.0.204" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "780f1cebed1629e4753a1a38a3c72d30b97ec044f0aef68cb26650a3c5cf363c" +checksum = "bc76f558e0cbb2a839d37354c575f1dc3fdc6546b5be373ba43d95f231bf7c12" dependencies = [ "serde_derive", ] [[package]] name = "serde_derive" -version = "1.0.201" +version = "1.0.204" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c5e405930b9796f1c00bee880d03fc7e0bb4b9a11afc776885ffe84320da2865" +checksum = "e0cd7e117be63d3c3678776753929474f3b04a43a080c744d6b0ae2a8c28e222" dependencies = [ "proc-macro2", "quote", - "syn 2.0.60", + "syn", ] [[package]] @@ -738,16 +384,6 @@ dependencies = [ "digest 0.10.7", ] -[[package]] -name = "signature" -version = "2.2.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "77549399552de45a898a580c1b41d445bf730df867cc44e6c0233bbc4b8329de" -dependencies = [ - "digest 0.10.7", - "rand_core", -] - [[package]] name = "smallvec" version = "1.13.2" @@ -755,53 +391,36 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "3c5e1a9a646d36c3599cd173a41282daf47c44583ad367b8e6837255952e5c67" [[package]] -name = "snowbridge-amcl" -version = "1.0.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "460a9ed63cdf03c1b9847e8a12a5f5ba19c4efd5869e4a737e05be25d7c427e5" -dependencies = [ - "parity-scale-codec", - "scale-info", -] - -[[package]] -name = "sp1-precompiles" -version = "0.1.0" +name = "sp1-lib" +version = "1.0.0-rc.1" dependencies = [ "anyhow", "bincode", "cfg-if", - "getrandom", - "hex", - "k256", - "num", - "rand", "serde", - "snowbridge-amcl", ] [[package]] name = "sp1-zkvm" -version = "0.1.0" +version = "1.0.0-rc.1" dependencies = [ "bincode", "cfg-if", "getrandom", - "k256", "lazy_static", "libm", "once_cell", "rand", "serde", "sha2 0.10.8", - "sp1-precompiles", + "sp1-lib", ] [[package]] name = "spin" -version = "0.5.2" +version = "0.9.8" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6e63cff320ae2c57904679ba7cb63280a3dc4613885beafb148ee7bf9aa9042d" +checksum = "6980e8d7511241f8acf4aebddbb1ff938df5eebe98691418c4468d0b72a96a67" [[package]] name = "spki" @@ -810,17 +429,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "44d01ac02a6ccf3e07db148d2be087da624fea0221a16152ed01f0496a6b0a27" dependencies = [ "base64ct", - "der 0.5.1", -] - -[[package]] -name = "spki" -version = "0.7.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d91ed6c858b01f942cd56b37a94b3e0a1798290327d1236e4d9cf4eaca44d29d" -dependencies = [ - "base64ct", - "der 0.7.9", + "der", ] [[package]] @@ -829,17 +438,6 @@ version = "2.5.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "81cdd64d312baedb58e21336b31bc043b77e01cc99033ce76ef539f78e965ebc" -[[package]] -name = "syn" -version = "1.0.109" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "72b64191b275b66ffe2469e8af2c1cfe3bafa67b529ead792a6d0160888b4237" -dependencies = [ - "proc-macro2", - "quote", - "unicode-ident", -] - [[package]] name = "syn" version = "2.0.60" @@ -851,40 +449,6 @@ dependencies = [ "unicode-ident", ] -[[package]] -name = "tap" -version = "1.0.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "55937e1799185b12863d447f42597ed69d9928686b8d88a1df17376a097d8369" - -[[package]] -name = "toml_datetime" -version = "0.6.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7cda73e2f1397b1262d6dfdcef8aafae14d1de7748d66822d3bfeeb6d03e5e4b" - -[[package]] -name = "toml_edit" -version = "0.19.15" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1b5bb770da30e5cbfde35a2d7b9b8a2c4b8ef89548a7a6aeab5c9a576e3e7421" -dependencies = [ - "indexmap", - "toml_datetime", - "winnow", -] - -[[package]] -name = "toml_edit" -version = "0.20.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "396e4d48bbb2b7554c944bde63101b5ae446cff6ec4a24227428f15eb72ef338" -dependencies = [ - "indexmap", - "toml_datetime", - "winnow", -] - [[package]] name = "typenum" version = "1.17.0" @@ -909,24 +473,6 @@ version = "0.11.0+wasi-snapshot-preview1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "9c8d87e72b64a3b4db28d11ce29237c246188f4f51057d65a7eab63b7987e423" -[[package]] -name = "winnow" -version = "0.5.40" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f593a95398737aeed53e489c785df13f3618e41dbcd6718c6addbf1395aa6876" -dependencies = [ - "memchr", -] - -[[package]] -name = "wyz" -version = "0.5.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "05f360fc0b24296329c78fda852a1e9ae82de9cf7b27dae4b7f62f118f77b9ed" -dependencies = [ - "tap", -] - [[package]] name = "zeroize" version = "1.7.0" diff --git a/examples/rsa/program/Cargo.toml b/examples/rsa/program/Cargo.toml index a9c166d789..d49f9c5152 100644 --- a/examples/rsa/program/Cargo.toml +++ b/examples/rsa/program/Cargo.toml @@ -1,8 +1,9 @@ [workspace] [package] -version = "0.1.0" name = "rsa-program" +version = "1.0.0-rc.1" edition = "2021" +publish = false [dependencies] sp1-zkvm = { path = "../../../zkvm/entrypoint" } diff --git a/examples/rsa/program/elf/riscv32im-succinct-zkvm-elf b/examples/rsa/program/elf/riscv32im-succinct-zkvm-elf index 688b17c79b..c6eedf5521 100755 Binary files a/examples/rsa/program/elf/riscv32im-succinct-zkvm-elf and b/examples/rsa/program/elf/riscv32im-succinct-zkvm-elf differ diff --git a/examples/rsa/script/Cargo.toml b/examples/rsa/script/Cargo.toml index 962749eaca..709cb17a55 100644 --- a/examples/rsa/script/Cargo.toml +++ b/examples/rsa/script/Cargo.toml @@ -1,11 +1,12 @@ [package] -version = "0.1.0" name = "rsa-script" -edition = "2021" +version = { workspace = true } +edition = { workspace = true } +publish = false [dependencies] rsa = "0.6" -sp1-sdk = { path = "../../../sdk" } +sp1-sdk = { workspace = true } [build-dependencies] -sp1-helper = { path = "../../../helper" } +sp1-helper = { workspace = true } diff --git a/examples/rsa/script/src/main.rs b/examples/rsa/script/src/main.rs index 4b3f237308..d2ffd96f03 100644 --- a/examples/rsa/script/src/main.rs +++ b/examples/rsa/script/src/main.rs @@ -2,7 +2,7 @@ use rsa::{ pkcs8::{DecodePrivateKey, DecodePublicKey}, RsaPrivateKey, RsaPublicKey, }; -use sp1_sdk::{utils, ProverClient, SP1Proof, SP1Stdin}; +use sp1_sdk::{utils, ProverClient, SP1ProofWithPublicValues, SP1Stdin}; use std::vec; /// The ELF we want to execute inside the zkVM. @@ -54,14 +54,15 @@ fn main() { // Generate the proof for the given program and input. let client = ProverClient::new(); let (pk, vk) = client.setup(RSA_ELF); - let proof = client.prove(&pk, stdin).expect("proving failed"); + let proof = client.prove(&pk, stdin).run().expect("proving failed"); // Verify proof. client.verify(&proof, &vk).expect("verification failed"); // Test a round trip of proof serialization and deserialization. proof.save("proof-with-pis").expect("saving proof failed"); - let deserialized_proof = SP1Proof::load("proof-with-pis").expect("loading proof failed"); + let deserialized_proof = + SP1ProofWithPublicValues::load("proof-with-pis").expect("loading proof failed"); // Verify the deserialized proof. client diff --git a/examples/ssz-withdrawals/program/Cargo.lock b/examples/ssz-withdrawals/program/Cargo.lock index 3d8ed90198..006ade59e0 100644 --- a/examples/ssz-withdrawals/program/Cargo.lock +++ b/examples/ssz-withdrawals/program/Cargo.lock @@ -26,9 +26,9 @@ dependencies = [ [[package]] name = "alloy-rlp" -version = "0.3.4" +version = "0.3.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8d58d9f5da7b40e9bfff0b7e7816700be4019db97d4b6359fe7f94a9e22e42ac" +checksum = "b155716bab55763c95ba212806cf43d05bcc70e5f35b02bad20cf5ec7fe11fed" dependencies = [ "arrayvec", "bytes", @@ -51,9 +51,9 @@ dependencies = [ [[package]] name = "anyhow" -version = "1.0.83" +version = "1.0.86" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "25bdb32cbbdce2b519a9cd7df3a678443100e265d5e25ca763b7572a5104f5f3" +checksum = "b3d1d046238990b9cf5bcde22a3fb3584ee5cf65fb2765f454ed428c7a0063da" [[package]] name = "ark-ff" @@ -193,14 +193,14 @@ checksum = "3c87f3f15e7794432337fc718554eaa4dc8f04c9677a950ffe366f20a162ae42" dependencies = [ "proc-macro2", "quote", - "syn 2.0.60", + "syn 2.0.66", ] [[package]] name = "autocfg" -version = "1.2.0" +version = "1.3.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f1fdabc7756949593fe60f30ec81974b613357de856987752631dea1e3394c80" +checksum = "0c4b4d0bd25bd0b74681c0ad21497610ce1b7c91b1022cd21c80c6fbdd9476b0" [[package]] name = "base16ct" @@ -210,9 +210,9 @@ checksum = "4c7f02d4ea65f2c1853089ffd8d2787bdbc63de2f0d29dedbcf8ccdfa0ccd4cf" [[package]] name = "base64" -version = "0.22.0" +version = "0.22.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9475866fec1451be56a3c2400fd081ff546538961565ccb5b7142cbd22bc7a51" +checksum = "72b3254f16251a8381aa12e40e3c4d2f0199f8c6508fbecb9d91f575e0fbb8c6" [[package]] name = "base64ct" @@ -306,9 +306,9 @@ checksum = "514de17de45fdb8dc022b1a7975556c53c86f9f0aa5f534b98977b171857c2c9" [[package]] name = "cc" -version = "1.0.95" +version = "1.0.99" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d32a725bc159af97c3e629873bb9f88fb8cf8a4867175f76dc987815ea07c83b" +checksum = "96c51067fd44124faa7f870b4b1c969379ad32b2ba805aa959430ceaa384f695" [[package]] name = "cfg-if" @@ -331,9 +331,9 @@ dependencies = [ [[package]] name = "const-hex" -version = "1.11.3" +version = "1.12.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5ba00838774b4ab0233e355d26710fbfc8327a05c017f6dc4873f876d1f79f78" +checksum = "94fb8a24a26d37e1ffd45343323dc9fe6654ceea44c12f2fcb3d7ac29e610bc6" dependencies = [ "cfg-if", "cpufeatures", @@ -399,9 +399,9 @@ dependencies = [ [[package]] name = "darling" -version = "0.20.8" +version = "0.20.9" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "54e36fcd13ed84ffdfda6f5be89b31287cbb80c439841fe69e04841435464391" +checksum = "83b2eb4d90d12bdda5ed17de686c2acb4c57914f8f921b8da7e112b5a36f3fe1" dependencies = [ "darling_core", "darling_macro", @@ -409,27 +409,27 @@ dependencies = [ [[package]] name = "darling_core" -version = "0.20.8" +version = "0.20.9" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9c2cf1c23a687a1feeb728783b993c4e1ad83d99f351801977dd809b48d0a70f" +checksum = "622687fe0bac72a04e5599029151f5796111b90f1baaa9b544d807a5e31cd120" dependencies = [ "fnv", "ident_case", "proc-macro2", "quote", "strsim", - "syn 2.0.60", + "syn 2.0.66", ] [[package]] name = "darling_macro" -version = "0.20.8" +version = "0.20.9" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a668eda54683121533a393014d8692171709ff57a7d61f187b6e782719f8933f" +checksum = "733cabb43482b1a1b53eee8583c2b9e8684d592215ea83efd305dd31bc2f0178" dependencies = [ "darling_core", "quote", - "syn 2.0.60", + "syn 2.0.66", ] [[package]] @@ -465,15 +465,15 @@ dependencies = [ [[package]] name = "derive_more" -version = "0.99.17" +version = "0.99.18" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4fb810d30a7c1953f91334de7244731fc3f3c10d7fe163338a35b9f640960321" +checksum = "5f33878137e4dafd7fa914ad4e259e18a4e8e532b9617a2d0150262bf53abfce" dependencies = [ "convert_case", "proc-macro2", "quote", "rustc_version 0.4.0", - "syn 1.0.109", + "syn 2.0.66", ] [[package]] @@ -513,9 +513,9 @@ dependencies = [ [[package]] name = "either" -version = "1.11.0" +version = "1.12.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a47c1c47d2f5964e29c61246e81db715514cd532db6b5116a25ea3c03d6780a2" +checksum = "3dca9240753cf90908d7e4aac30f630662b02aebaa1b58a3cadabdb23385b58b" [[package]] name = "elliptic-curve" @@ -533,7 +533,6 @@ dependencies = [ "rand_core", "sec1", "subtle", - "tap", "zeroize", ] @@ -545,9 +544,9 @@ checksum = "5443807d6dff69373d433ab9ef5378ad8df50ca6298caf15de6e52e24aaf54d5" [[package]] name = "errno" -version = "0.3.8" +version = "0.3.9" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a258e46cdc063eb8519c00b9fc845fc47bcfca4130e2f08e88665ceda8474245" +checksum = "534c5cf6194dfab3db3242765c03bbe257cf92f22b38f6bc0c58d59108a820ba" dependencies = [ "libc", "windows-sys", @@ -555,9 +554,9 @@ dependencies = [ [[package]] name = "fastrand" -version = "2.0.2" +version = "2.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "658bd65b1cf4c852a3cc96f18a8ce7b5640f6b703f905c7d74532294c2a63984" +checksum = "9fc0510504f03c51ada170672ac806f1f105a88aa97a5281117e1ddc3368e51a" [[package]] name = "fastrlp" @@ -576,7 +575,6 @@ version = "0.13.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "ded41244b729663b1e574f1b4fb731469f69f79c17667b5d776b16cda0479449" dependencies = [ - "bitvec", "rand_core", "subtle", ] @@ -646,9 +644,9 @@ checksum = "8a9ee70c43aaf417c914396645a0fa852624801b24ebb7ae78fe8272889ac888" [[package]] name = "hashbrown" -version = "0.14.3" +version = "0.14.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "290f1a1d9242c78d09ce40a5e87e7554ee637af1351968159f4952f028f75604" +checksum = "e5274423e17b7c9fc20b6e7e208532f9b19825d82dfd615708b70edd83df41f1" [[package]] name = "hex" @@ -738,7 +736,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "168fb715dda47215e360912c096649d23d58bf392ac62f73919e831745e40f26" dependencies = [ "equivalent", - "hashbrown 0.14.3", + "hashbrown 0.14.5", "serde", ] @@ -782,9 +780,9 @@ dependencies = [ [[package]] name = "keccak-asm" -version = "0.1.0" +version = "0.1.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bb8515fff80ed850aea4a1595f2e519c003e2a00a82fe168ebf5269196caf444" +checksum = "47a3633291834c4fbebf8673acbc1b04ec9d151418ff9b8e26dcd79129928758" dependencies = [ "digest 0.10.7", "sha3-asm", @@ -792,15 +790,15 @@ dependencies = [ [[package]] name = "lazy_static" -version = "1.4.0" +version = "1.5.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e2abad23fbc42b3700f2f279844dc832adb2b2eb069b2df918f455c4e18cc646" +checksum = "bbd2bcb4c963f2ddae06a2efc7e9f3591312473c50c6685e1f298068316e66fe" [[package]] name = "libc" -version = "0.2.154" +version = "0.2.155" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ae743338b92ff9146ce83992f766a31066a91a8c84a45e0e9f21e7cf6de6d346" +checksum = "97b3888a4aecf77e811145cadf6eef5901f4782c53886191b2f693f24761847c" [[package]] name = "libm" @@ -810,9 +808,9 @@ checksum = "4ec2a862134d2a7d32d7983ddcdd1c4923530833c9f2ea1a44fc5fa473989058" [[package]] name = "linux-raw-sys" -version = "0.4.13" +version = "0.4.14" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "01cda141df6706de531b6c46c3a33ecca755538219bd484262fa09410c13539c" +checksum = "78b3ae25bc7c8c38cec158d1f2757ee79e9b3740fbc7ccf0e59e4b08d793fa89" [[package]] name = "log" @@ -822,23 +820,9 @@ checksum = "90ed8c1e510134f979dbc4f070f87d4313098b704861a105fe34231c70a3901c" [[package]] name = "memchr" -version = "2.7.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6c8640c5d730cb13ebd907d8d04b52f55ac9a2eec55b440c8892f40d56c76c1d" - -[[package]] -name = "num" -version = "0.4.3" +version = "2.7.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "35bd024e8b2ff75562e5f34e7f4905839deb4b22955ef5e73d2fea1b9813cb23" -dependencies = [ - "num-bigint", - "num-complex", - "num-integer", - "num-iter", - "num-rational", - "num-traits", -] +checksum = "78ca9ab1a0babb1e7d5695e3530886289c18cf2f87ec19a575a0abdce112e3a3" [[package]] name = "num-bigint" @@ -850,15 +834,6 @@ dependencies = [ "num-traits", ] -[[package]] -name = "num-complex" -version = "0.4.6" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "73f88a1307638156682bada9d7604135552957b7818057dcef22705b4d509495" -dependencies = [ - "num-traits", -] - [[package]] name = "num-conv" version = "0.1.0" @@ -874,28 +849,6 @@ dependencies = [ "num-traits", ] -[[package]] -name = "num-iter" -version = "0.1.45" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1429034a0490724d0075ebb2bc9e875d6503c3cf69e235a8941aa757d83ef5bf" -dependencies = [ - "autocfg", - "num-integer", - "num-traits", -] - -[[package]] -name = "num-rational" -version = "0.4.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f83d14da390562dca69fc84082e73e548e1ad308d24accdedd2720017cb37824" -dependencies = [ - "num-bigint", - "num-integer", - "num-traits", -] - [[package]] name = "num-traits" version = "0.2.19" @@ -920,9 +873,9 @@ checksum = "c08d65885ee38876c4f86fa503fb49d7b507c2b62552df7c70b2fce627e06381" [[package]] name = "parity-scale-codec" -version = "3.6.9" +version = "3.6.12" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "881331e34fa842a2fb61cc2db9643a8fedc615e47cfcc52597d1af0db9a7e8fe" +checksum = "306800abfa29c7f16596b5970a588435e3d5b3149683d00c12b699cc19f895ee" dependencies = [ "arrayvec", "bitvec", @@ -934,11 +887,11 @@ dependencies = [ [[package]] name = "parity-scale-codec-derive" -version = "3.6.9" +version = "3.6.12" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "be30eaf4b0a9fba5336683b38de57bb86d179a35862ba6bfcf57625d006bde5b" +checksum = "d830939c76d294956402033aee57a6da7b438f2294eb94864c37b0569053a42c" dependencies = [ - "proc-macro-crate 2.0.2", + "proc-macro-crate", "proc-macro2", "quote", "syn 1.0.109", @@ -946,15 +899,15 @@ dependencies = [ [[package]] name = "paste" -version = "1.0.14" +version = "1.0.15" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "de3145af08024dea9fa9914f381a17b8fc6034dfb00f3a84013f7ff43f29ed4c" +checksum = "57c0d7b74b563b49d38dae00a0c37d4d6de9b432382b2892f0574ddcae73fd0a" [[package]] name = "pest" -version = "2.7.9" +version = "2.7.10" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "311fb059dee1a7b802f036316d790138c613a4e8b180c822e3925a662e9f0c95" +checksum = "560131c633294438da9f7c4b08189194b20946c8274c6b9e38881a7874dc8ee8" dependencies = [ "memchr", "thiserror", @@ -996,29 +949,18 @@ dependencies = [ [[package]] name = "proc-macro-crate" -version = "1.3.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7f4c021e1093a56626774e81216a4ce732a735e5bad4868a03f3ed65ca0c3919" -dependencies = [ - "once_cell", - "toml_edit 0.19.15", -] - -[[package]] -name = "proc-macro-crate" -version = "2.0.2" +version = "3.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b00f26d3400549137f92511a46ac1cd8ce37cb5598a96d382381458b992a5d24" +checksum = "6d37c51ca738a55da99dc0c4a34860fd675453b8b36209178c2249bb13651284" dependencies = [ - "toml_datetime", - "toml_edit 0.20.2", + "toml_edit", ] [[package]] name = "proc-macro2" -version = "1.0.81" +version = "1.0.85" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3d1597b0c024618f09a9c3b8655b7e430397a36d23fdafec26d6965e9eec3eba" +checksum = "22244ce15aa966053a896d1accb3a6e68469b97c7f33f284b99f0d576879fc23" dependencies = [ "unicode-ident", ] @@ -1105,9 +1047,9 @@ dependencies = [ [[package]] name = "regex-syntax" -version = "0.8.3" +version = "0.8.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "adad44e29e4c806119491a7f06f03de4d1af22c3a680dd47f1e6e179439d1f56" +checksum = "7a66a03ae7c801facd77a29370b4faec201768915ac14a721ba36f20bc9c209b" [[package]] name = "rfc6979" @@ -1131,9 +1073,9 @@ dependencies = [ [[package]] name = "ruint" -version = "1.12.1" +version = "1.12.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8f308135fef9fc398342da5472ce7c484529df23743fb7c734e0f3d472971e62" +checksum = "2c3cc4c2511671f327125da14133d0c5c5d137f006a1017a16f557bc85b16286" dependencies = [ "alloy-rlp", "ark-ff 0.3.0", @@ -1155,9 +1097,9 @@ dependencies = [ [[package]] name = "ruint-macro" -version = "1.2.0" +version = "1.2.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f86854cf50259291520509879a5c294c3c9a4c334e9ff65071c51e42ef1e2343" +checksum = "48fd7bd8a6377e15ad9d42a8ec25371b94ddc67abe7c8b9127bec79bebaaae18" [[package]] name = "rustc-hex" @@ -1180,7 +1122,7 @@ version = "0.4.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "bfa0f585226d2e68097d4f95d113b15b83a82e819ab25717ec0590d9584ef366" dependencies = [ - "semver 1.0.22", + "semver 1.0.23", ] [[package]] @@ -1210,33 +1152,9 @@ dependencies = [ [[package]] name = "ryu" -version = "1.0.17" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e86697c916019a8588c99b5fac3cead74ec0b4b819707a682fd4d23fa0ce1ba1" - -[[package]] -name = "scale-info" -version = "2.11.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7c453e59a955f81fb62ee5d596b450383d699f152d350e9d23a0db2adb78e4c0" -dependencies = [ - "cfg-if", - "derive_more", - "parity-scale-codec", - "scale-info-derive", -] - -[[package]] -name = "scale-info-derive" -version = "2.11.2" +version = "1.0.18" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "18cf6c6447f813ef19eb450e985bcce6705f9ce7660db221b59093d15c79c4b7" -dependencies = [ - "proc-macro-crate 1.3.1", - "proc-macro2", - "quote", - "syn 1.0.109", -] +checksum = "f3cb5ba0dc43242ce17de99c180e96db90b235b8a9fdc9543c96d2209116bd9f" [[package]] name = "sec1" @@ -1263,9 +1181,9 @@ dependencies = [ [[package]] name = "semver" -version = "1.0.22" +version = "1.0.23" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "92d43fe69e652f3df9bdc2b85b2854a0825b86e4fb76bc44d945137d053639ca" +checksum = "61697e0a1c7e512e84a621326239844a24d8207b4669b41bc18b32ea5cbf988b" [[package]] name = "semver-parser" @@ -1278,29 +1196,29 @@ dependencies = [ [[package]] name = "serde" -version = "1.0.201" +version = "1.0.204" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "780f1cebed1629e4753a1a38a3c72d30b97ec044f0aef68cb26650a3c5cf363c" +checksum = "bc76f558e0cbb2a839d37354c575f1dc3fdc6546b5be373ba43d95f231bf7c12" dependencies = [ "serde_derive", ] [[package]] name = "serde_derive" -version = "1.0.201" +version = "1.0.204" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c5e405930b9796f1c00bee880d03fc7e0bb4b9a11afc776885ffe84320da2865" +checksum = "e0cd7e117be63d3c3678776753929474f3b04a43a080c744d6b0ae2a8c28e222" dependencies = [ "proc-macro2", "quote", - "syn 2.0.60", + "syn 2.0.66", ] [[package]] name = "serde_json" -version = "1.0.116" +version = "1.0.117" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3e17db7126d17feb94eb3fad46bf1a96b034e8aacbc2e775fe81505f8b0b2813" +checksum = "455182ea6142b14f93f4bc5320a2b31c1f266b66a4a5c858b013302a5d8cbfc3" dependencies = [ "itoa", "ryu", @@ -1309,9 +1227,9 @@ dependencies = [ [[package]] name = "serde_with" -version = "3.8.0" +version = "3.8.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2c85f8e96d1d6857f13768fcbd895fcb06225510022a2774ed8b5150581847b0" +checksum = "0ad483d2ab0149d5a5ebcd9972a3852711e0153d863bf5a5d0391d28883c4a20" dependencies = [ "base64", "chrono", @@ -1327,20 +1245,20 @@ dependencies = [ [[package]] name = "serde_with_macros" -version = "3.8.0" +version = "3.8.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c8b3a576c4eb2924262d5951a3b737ccaf16c931e39a2810c36f9a7e25575557" +checksum = "65569b702f41443e8bc8bbb1c5779bd0450bbe723b56198980e80ec45780bce2" dependencies = [ "darling", "proc-macro2", "quote", - "syn 2.0.60", + "syn 2.0.66", ] [[package]] name = "sha2" version = "0.9.8" -source = "git+https://github.com/sp1-patches/RustCrypto-hashes.git?branch=patch-v0.9.8#0b578688db61bb53e15353f5beaa2c11ad93f037" +source = "git+https://github.com/sp1-patches/RustCrypto-hashes.git?branch=patch-v0.9.8#afdbfb09c325f8a69c01d540ec9a261e3637725d" dependencies = [ "block-buffer 0.9.0", "cfg-if", @@ -1374,9 +1292,9 @@ dependencies = [ [[package]] name = "sha3-asm" -version = "0.1.0" +version = "0.1.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bac61da6b35ad76b195eb4771210f947734321a8d81d7738e1580d953bc7a15e" +checksum = "a9b57fd861253bff08bb1919e995f90ba8f4889de2726091c8876f3a4e823b40" dependencies = [ "cc", "cfg-if", @@ -1393,46 +1311,29 @@ dependencies = [ ] [[package]] -name = "snowbridge-amcl" -version = "1.0.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "460a9ed63cdf03c1b9847e8a12a5f5ba19c4efd5869e4a737e05be25d7c427e5" -dependencies = [ - "parity-scale-codec", - "scale-info", -] - -[[package]] -name = "sp1-precompiles" -version = "0.1.0" +name = "sp1-lib" +version = "1.0.0-rc.1" dependencies = [ "anyhow", "bincode", "cfg-if", - "getrandom", - "hex", - "k256", - "num", - "rand", "serde", - "snowbridge-amcl", ] [[package]] name = "sp1-zkvm" -version = "0.1.0" +version = "1.0.0-rc.1" dependencies = [ "bincode", "cfg-if", "getrandom", - "k256", "lazy_static", "libm", "once_cell", "rand", "serde", "sha2 0.10.8", - "sp1-precompiles", + "sp1-lib", ] [[package]] @@ -1447,7 +1348,7 @@ dependencies = [ [[package]] name = "ssz-withdrawals-program" -version = "0.1.0" +version = "1.0.0-rc.1" dependencies = [ "alloy-primitives", "hex", @@ -1493,9 +1394,9 @@ checksum = "a2eb9349b6444b326872e140eb1cf5e7c522154d69e7a0ffb0fb81c06b37543f" [[package]] name = "strsim" -version = "0.10.0" +version = "0.11.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "73473c0e59e6d5812c5dfe2a064a6444949f089e20eec9a2e5506596494e4623" +checksum = "7da8b5736845d9f2fcb837ea5d9e2628564b3b043a70948a3f0b778838c5fb4f" [[package]] name = "subtle" @@ -1516,9 +1417,9 @@ dependencies = [ [[package]] name = "syn" -version = "2.0.60" +version = "2.0.66" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "909518bc7b1c9b779f1bbf07f2929d35af9f0f37e47c6e9ef7f9dddc1e1821f3" +checksum = "c42f3f41a2de00b01c0aaad383c5a45241efc8b2d1eda5661812fda5f3cdcff5" dependencies = [ "proc-macro2", "quote", @@ -1545,22 +1446,22 @@ dependencies = [ [[package]] name = "thiserror" -version = "1.0.59" +version = "1.0.61" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f0126ad08bff79f29fc3ae6a55cc72352056dfff61e3ff8bb7129476d44b23aa" +checksum = "c546c80d6be4bc6a00c0f01730c08df82eaa7a7a61f11d656526506112cc1709" dependencies = [ "thiserror-impl", ] [[package]] name = "thiserror-impl" -version = "1.0.59" +version = "1.0.61" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d1cd413b5d558b4c5bf3680e324a6fa5014e7b7c067a51e69dbdf47eb7148b66" +checksum = "46c3384250002a6d5af4d114f2845d37b57521033f30d5c3f46c4d70e1197533" dependencies = [ "proc-macro2", "quote", - "syn 2.0.60", + "syn 2.0.66", ] [[package]] @@ -1605,26 +1506,15 @@ dependencies = [ [[package]] name = "toml_datetime" -version = "0.6.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7cda73e2f1397b1262d6dfdcef8aafae14d1de7748d66822d3bfeeb6d03e5e4b" - -[[package]] -name = "toml_edit" -version = "0.19.15" +version = "0.6.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1b5bb770da30e5cbfde35a2d7b9b8a2c4b8ef89548a7a6aeab5c9a576e3e7421" -dependencies = [ - "indexmap 2.2.6", - "toml_datetime", - "winnow", -] +checksum = "4badfd56924ae69bcc9039335b2e017639ce3f9b001c393c1b2d1ef846ce2cbf" [[package]] name = "toml_edit" -version = "0.20.2" +version = "0.21.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "396e4d48bbb2b7554c944bde63101b5ae446cff6ec4a24227428f15eb72ef338" +checksum = "6a8534fd7f78b5405e860340ad6575217ce99f38d4d5c8f2442cb5ecb50090e1" dependencies = [ "indexmap 2.2.6", "toml_datetime", @@ -1715,7 +1605,7 @@ dependencies = [ "once_cell", "proc-macro2", "quote", - "syn 2.0.60", + "syn 2.0.66", "wasm-bindgen-shared", ] @@ -1737,7 +1627,7 @@ checksum = "e94f17b526d0a461a191c78ea52bbce64071ed5c04c9ffe424dcb38f74171bb7" dependencies = [ "proc-macro2", "quote", - "syn 2.0.60", + "syn 2.0.66", "wasm-bindgen-backend", "wasm-bindgen-shared", ] @@ -1850,9 +1740,9 @@ dependencies = [ [[package]] name = "zeroize" -version = "1.7.0" +version = "1.8.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "525b4ec142c6b68a2d10f01f7bbf6755599ca3f81ea53b8431b7dd348f5fdb2d" +checksum = "ced3678a2879b30306d323f4542626697a464a97c0a07c9aebf7ebca65cd4dde" dependencies = [ "zeroize_derive", ] @@ -1865,5 +1755,5 @@ checksum = "ce36e65b0d2999d2aafac989fb249189a141aee1f53c612c1f37d72631959f69" dependencies = [ "proc-macro2", "quote", - "syn 2.0.60", + "syn 2.0.66", ] diff --git a/examples/ssz-withdrawals/program/Cargo.toml b/examples/ssz-withdrawals/program/Cargo.toml index 4ed30cec1d..d71eb92a64 100644 --- a/examples/ssz-withdrawals/program/Cargo.toml +++ b/examples/ssz-withdrawals/program/Cargo.toml @@ -1,8 +1,9 @@ [workspace] [package] -version = "0.1.0" name = "ssz-withdrawals-program" +version = "1.0.0-rc.1" edition = "2021" +publish = false [dependencies] sp1-zkvm = { path = "../../../zkvm/entrypoint" } diff --git a/examples/ssz-withdrawals/program/elf/riscv32im-succinct-zkvm-elf b/examples/ssz-withdrawals/program/elf/riscv32im-succinct-zkvm-elf index 599bd4066d..3f6d3b5b27 100755 Binary files a/examples/ssz-withdrawals/program/elf/riscv32im-succinct-zkvm-elf and b/examples/ssz-withdrawals/program/elf/riscv32im-succinct-zkvm-elf differ diff --git a/examples/ssz-withdrawals/script/Cargo.toml b/examples/ssz-withdrawals/script/Cargo.toml index 899e711e7e..50a07d7351 100644 --- a/examples/ssz-withdrawals/script/Cargo.toml +++ b/examples/ssz-withdrawals/script/Cargo.toml @@ -1,10 +1,11 @@ [package] -version = "0.1.0" name = "ssz-withdrawals-script" -edition = "2021" +version = { workspace = true } +edition = { workspace = true } +publish = false [dependencies] -sp1-sdk = { path = "../../../sdk" } +sp1-sdk = { workspace = true } [build-dependencies] -sp1-helper = { path = "../../../helper" } +sp1-helper = { workspace = true } diff --git a/examples/ssz-withdrawals/script/src/main.rs b/examples/ssz-withdrawals/script/src/main.rs index 34b1013835..7a8ccc46df 100644 --- a/examples/ssz-withdrawals/script/src/main.rs +++ b/examples/ssz-withdrawals/script/src/main.rs @@ -1,4 +1,4 @@ -use sp1_sdk::{utils, ProverClient, SP1Proof, SP1Stdin}; +use sp1_sdk::{utils, ProverClient, SP1ProofWithPublicValues, SP1Stdin}; const ELF: &[u8] = include_bytes!("../../program/elf/riscv32im-succinct-zkvm-elf"); @@ -10,7 +10,7 @@ fn main() { let stdin = SP1Stdin::new(); let client = ProverClient::new(); let (pk, vk) = client.setup(ELF); - let proof = client.prove(&pk, stdin).expect("proving failed"); + let proof = client.prove(&pk, stdin).run().expect("proving failed"); // Verify proof. client.verify(&proof, &vk).expect("verification failed"); @@ -19,7 +19,8 @@ fn main() { proof .save("proof-with-pis.bin") .expect("saving proof failed"); - let deserialized_proof = SP1Proof::load("proof-with-pis.bin").expect("loading proof failed"); + let deserialized_proof = + SP1ProofWithPublicValues::load("proof-with-pis.bin").expect("loading proof failed"); // Verify the deserialized proof. client diff --git a/examples/tendermint/program/Cargo.lock b/examples/tendermint/program/Cargo.lock index bf2d905af8..7aea73e5a3 100644 --- a/examples/tendermint/program/Cargo.lock +++ b/examples/tendermint/program/Cargo.lock @@ -4,27 +4,15 @@ version = 3 [[package]] name = "anyhow" -version = "1.0.83" +version = "1.0.86" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "25bdb32cbbdce2b519a9cd7df3a678443100e265d5e25ca763b7572a5104f5f3" - -[[package]] -name = "arrayvec" -version = "0.7.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "96d30a06541fbafbc7f82ed10c06164cfbd2c401138f6addd8404629c4b16711" +checksum = "b3d1d046238990b9cf5bcde22a3fb3584ee5cf65fb2765f454ed428c7a0063da" [[package]] name = "autocfg" -version = "1.2.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f1fdabc7756949593fe60f30ec81974b613357de856987752631dea1e3394c80" - -[[package]] -name = "base16ct" -version = "0.2.0" +version = "1.3.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4c7f02d4ea65f2c1853089ffd8d2787bdbc63de2f0d29dedbcf8ccdfa0ccd4cf" +checksum = "0c4b4d0bd25bd0b74681c0ad21497610ce1b7c91b1022cd21c80c6fbdd9476b0" [[package]] name = "base64ct" @@ -41,18 +29,6 @@ dependencies = [ "serde", ] -[[package]] -name = "bitvec" -version = "1.0.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1bc2832c24239b0141d5674bb9174f9d68a8b5b3f2753311927c172ca46f7e9c" -dependencies = [ - "funty", - "radium", - "tap", - "wyz", -] - [[package]] name = "block-buffer" version = "0.9.0" @@ -71,12 +47,6 @@ dependencies = [ "generic-array", ] -[[package]] -name = "byte-slice-cast" -version = "1.2.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c3ac9f8b63eca6fd385229b3675f6cc0dc5c8a5c8a54a59d4f52ffd670d87b0c" - [[package]] name = "byteorder" version = "1.5.0" @@ -113,18 +83,6 @@ dependencies = [ "libc", ] -[[package]] -name = "crypto-bigint" -version = "0.5.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0dc92fb57ca44df6db8059111ab3af99a63d5d0f8375d9972e319a379c6bab76" -dependencies = [ - "generic-array", - "rand_core", - "subtle", - "zeroize", -] - [[package]] name = "crypto-common" version = "0.1.6" @@ -193,23 +151,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "9ed9a281f7bc9b7576e61468ba615a66a5c8cfdff42420a70aa82701a3b1e292" dependencies = [ "block-buffer 0.10.4", - "const-oid", "crypto-common", - "subtle", -] - -[[package]] -name = "ecdsa" -version = "0.16.9" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ee27f32b5c5292967d2d4a9d7f1e0b0aed2c15daded5a60300e4abb9d8020bca" -dependencies = [ - "der", - "digest 0.10.7", - "elliptic-curve", - "rfc6979", - "signature", - "spki", ] [[package]] @@ -230,52 +172,15 @@ dependencies = [ "curve25519-dalek-ng", "hex", "rand_core", - "sha2 0.9.8", + "sha2 0.9.9", "zeroize", ] [[package]] name = "either" -version = "1.11.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a47c1c47d2f5964e29c61246e81db715514cd532db6b5116a25ea3c03d6780a2" - -[[package]] -name = "elliptic-curve" -version = "0.13.8" +version = "1.12.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b5e6043086bf7973472e0c7dff2142ea0b680d30e18d9cc40f267efbf222bd47" -dependencies = [ - "base16ct", - "crypto-bigint", - "digest 0.10.7", - "ff", - "generic-array", - "group", - "pkcs8", - "rand_core", - "sec1", - "subtle", - "tap", - "zeroize", -] - -[[package]] -name = "equivalent" -version = "1.0.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5443807d6dff69373d433ab9ef5378ad8df50ca6298caf15de6e52e24aaf54d5" - -[[package]] -name = "ff" -version = "0.13.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ded41244b729663b1e574f1b4fb731469f69f79c17667b5d776b16cda0479449" -dependencies = [ - "bitvec", - "rand_core", - "subtle", -] +checksum = "3dca9240753cf90908d7e4aac30f630662b02aebaa1b58a3cadabdb23385b58b" [[package]] name = "flex-error" @@ -286,12 +191,6 @@ dependencies = [ "paste", ] -[[package]] -name = "funty" -version = "2.0.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e6d5a32815ae3f33302d95fdcb2ce17862f8c65363dcfd29360480ba1001fc9c" - [[package]] name = "futures" version = "0.3.30" @@ -361,7 +260,6 @@ checksum = "85649ca51fd72272d7821adaf274ad91c288277713d9c18820d8499a7ff69e9a" dependencies = [ "typenum", "version_check", - "zeroize", ] [[package]] @@ -375,65 +273,18 @@ dependencies = [ "wasi", ] -[[package]] -name = "group" -version = "0.13.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f0f9ef7462f7c099f518d754361858f86d8a07af53ba9af0fe635bbccb151a63" -dependencies = [ - "ff", - "rand_core", - "subtle", -] - [[package]] name = "half" version = "1.8.3" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "1b43ede17f21864e81be2fa654110bf1e793774238d86ef8555c37e6519c0403" -[[package]] -name = "hashbrown" -version = "0.14.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "290f1a1d9242c78d09ce40a5e87e7554ee637af1351968159f4952f028f75604" - [[package]] name = "hex" version = "0.4.3" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "7f24254aa9a54b5c858eaee2f5bccdb46aaf0e486a595ed5fd8f86ba55232a70" -[[package]] -name = "hmac" -version = "0.12.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6c49c37c09c17a53d937dfbb742eb3a961d65a994e6bcdcf37e7399d0cc8ab5e" -dependencies = [ - "digest 0.10.7", -] - -[[package]] -name = "impl-trait-for-tuples" -version = "0.2.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "11d7a9f6330b71fea57921c9b61c47ee6e84f72d394754eff6163ae67e7395eb" -dependencies = [ - "proc-macro2", - "quote", - "syn 1.0.109", -] - -[[package]] -name = "indexmap" -version = "2.2.6" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "168fb715dda47215e360912c096649d23d58bf392ac62f73919e831745e40f26" -dependencies = [ - "equivalent", - "hashbrown", -] - [[package]] name = "itertools" version = "0.12.1" @@ -449,31 +300,17 @@ version = "1.0.11" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "49f1f14873335454500d59611f1cf4a4b0f786f9ac11f4312a78e4cf2566695b" -[[package]] -name = "k256" -version = "0.13.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "956ff9b67e26e1a6a866cb758f12c6f8746208489e3e4a4b5580802f2f0a587b" -dependencies = [ - "cfg-if", - "ecdsa", - "elliptic-curve", - "once_cell", - "sha2 0.10.8", - "signature", -] - [[package]] name = "lazy_static" -version = "1.4.0" +version = "1.5.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e2abad23fbc42b3700f2f279844dc832adb2b2eb069b2df918f455c4e18cc646" +checksum = "bbd2bcb4c963f2ddae06a2efc7e9f3591312473c50c6685e1f298068316e66fe" [[package]] name = "libc" -version = "0.2.154" +version = "0.2.155" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ae743338b92ff9146ce83992f766a31066a91a8c84a45e0e9f21e7cf6de6d346" +checksum = "97b3888a4aecf77e811145cadf6eef5901f4782c53886191b2f693f24761847c" [[package]] name = "libm" @@ -481,45 +318,6 @@ version = "0.2.8" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "4ec2a862134d2a7d32d7983ddcdd1c4923530833c9f2ea1a44fc5fa473989058" -[[package]] -name = "memchr" -version = "2.7.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6c8640c5d730cb13ebd907d8d04b52f55ac9a2eec55b440c8892f40d56c76c1d" - -[[package]] -name = "num" -version = "0.4.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "35bd024e8b2ff75562e5f34e7f4905839deb4b22955ef5e73d2fea1b9813cb23" -dependencies = [ - "num-bigint", - "num-complex", - "num-integer", - "num-iter", - "num-rational", - "num-traits", -] - -[[package]] -name = "num-bigint" -version = "0.4.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c165a9ab64cf766f73521c0dd2cfdff64f488b8f0b3e621face3462d3db536d7" -dependencies = [ - "num-integer", - "num-traits", -] - -[[package]] -name = "num-complex" -version = "0.4.6" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "73f88a1307638156682bada9d7604135552957b7818057dcef22705b4d509495" -dependencies = [ - "num-traits", -] - [[package]] name = "num-conv" version = "0.1.0" @@ -534,38 +332,7 @@ checksum = "ed3955f1a9c7c0c15e092f9c887db08b1fc683305fdf6eb6684f22555355e202" dependencies = [ "proc-macro2", "quote", - "syn 2.0.60", -] - -[[package]] -name = "num-integer" -version = "0.1.46" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7969661fd2958a5cb096e56c8e1ad0444ac2bbcd0061bd28660485a44879858f" -dependencies = [ - "num-traits", -] - -[[package]] -name = "num-iter" -version = "0.1.45" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1429034a0490724d0075ebb2bc9e875d6503c3cf69e235a8941aa757d83ef5bf" -dependencies = [ - "autocfg", - "num-integer", - "num-traits", -] - -[[package]] -name = "num-rational" -version = "0.4.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f83d14da390562dca69fc84082e73e548e1ad308d24accdedd2720017cb37824" -dependencies = [ - "num-bigint", - "num-integer", - "num-traits", + "syn 2.0.66", ] [[package]] @@ -589,35 +356,11 @@ version = "0.3.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "c08d65885ee38876c4f86fa503fb49d7b507c2b62552df7c70b2fce627e06381" -[[package]] -name = "parity-scale-codec" -version = "3.6.9" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "881331e34fa842a2fb61cc2db9643a8fedc615e47cfcc52597d1af0db9a7e8fe" -dependencies = [ - "arrayvec", - "byte-slice-cast", - "impl-trait-for-tuples", - "parity-scale-codec-derive", -] - -[[package]] -name = "parity-scale-codec-derive" -version = "3.6.9" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "be30eaf4b0a9fba5336683b38de57bb86d179a35862ba6bfcf57625d006bde5b" -dependencies = [ - "proc-macro-crate 2.0.2", - "proc-macro2", - "quote", - "syn 1.0.109", -] - [[package]] name = "paste" -version = "1.0.14" +version = "1.0.15" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "de3145af08024dea9fa9914f381a17b8fc6034dfb00f3a84013f7ff43f29ed4c" +checksum = "57c0d7b74b563b49d38dae00a0c37d4d6de9b432382b2892f0574ddcae73fd0a" [[package]] name = "pin-project-lite" @@ -653,40 +396,20 @@ version = "0.2.17" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "5b40af805b3121feab8a3c29f04d8ad262fa8e0561883e7653e024ae4479e6de" -[[package]] -name = "proc-macro-crate" -version = "1.3.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7f4c021e1093a56626774e81216a4ce732a735e5bad4868a03f3ed65ca0c3919" -dependencies = [ - "once_cell", - "toml_edit 0.19.15", -] - -[[package]] -name = "proc-macro-crate" -version = "2.0.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b00f26d3400549137f92511a46ac1cd8ce37cb5598a96d382381458b992a5d24" -dependencies = [ - "toml_datetime", - "toml_edit 0.20.2", -] - [[package]] name = "proc-macro2" -version = "1.0.81" +version = "1.0.85" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3d1597b0c024618f09a9c3b8655b7e430397a36d23fdafec26d6965e9eec3eba" +checksum = "22244ce15aa966053a896d1accb3a6e68469b97c7f33f284b99f0d576879fc23" dependencies = [ "unicode-ident", ] [[package]] name = "prost" -version = "0.12.4" +version = "0.12.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d0f5d036824e4761737860779c906171497f6d55681139d8312388f8fe398922" +checksum = "deb1435c188b76130da55f17a466d252ff7b1418b2ad3e037d127b94e3411f29" dependencies = [ "bytes", "prost-derive", @@ -694,22 +417,22 @@ dependencies = [ [[package]] name = "prost-derive" -version = "0.12.4" +version = "0.12.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "19de2de2a00075bf566bee3bd4db014b11587e84184d3f7a791bc17f1a8e9e48" +checksum = "81bddcdb20abf9501610992b6759a4c888aef7d1a7247ef75e2404275ac24af1" dependencies = [ "anyhow", "itertools", "proc-macro2", "quote", - "syn 2.0.60", + "syn 2.0.66", ] [[package]] name = "prost-types" -version = "0.12.4" +version = "0.12.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3235c33eb02c1f1e212abdbe34c78b264b038fb58ca612664343271e36e55ffe" +checksum = "9091c90b0a32608e984ff2fa4091273cbdd755d54935c51d520887f4a1dbd5b0" dependencies = [ "prost", ] @@ -723,12 +446,6 @@ dependencies = [ "proc-macro2", ] -[[package]] -name = "radium" -version = "0.7.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "dc33ff2d4973d518d823d61aa239014831e521c75da58e3df4840d3f47749d09" - [[package]] name = "rand" version = "0.8.5" @@ -759,65 +476,17 @@ dependencies = [ "getrandom", ] -[[package]] -name = "rfc6979" -version = "0.4.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f8dd2a808d456c4a54e300a23e9f5a67e122c3024119acbfd73e3bf664491cb2" -dependencies = [ - "hmac", - "subtle", -] - [[package]] name = "ryu" -version = "1.0.17" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e86697c916019a8588c99b5fac3cead74ec0b4b819707a682fd4d23fa0ce1ba1" - -[[package]] -name = "scale-info" -version = "2.11.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7c453e59a955f81fb62ee5d596b450383d699f152d350e9d23a0db2adb78e4c0" -dependencies = [ - "cfg-if", - "derive_more", - "parity-scale-codec", - "scale-info-derive", -] - -[[package]] -name = "scale-info-derive" -version = "2.11.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "18cf6c6447f813ef19eb450e985bcce6705f9ce7660db221b59093d15c79c4b7" -dependencies = [ - "proc-macro-crate 1.3.1", - "proc-macro2", - "quote", - "syn 1.0.109", -] - -[[package]] -name = "sec1" -version = "0.7.3" +version = "1.0.18" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d3e97a565f76233a6003f9f5c54be1d9c5bdfa3eccfb189469f11ec4901c47dc" -dependencies = [ - "base16ct", - "der", - "generic-array", - "pkcs8", - "subtle", - "zeroize", -] +checksum = "f3cb5ba0dc43242ce17de99c180e96db90b235b8a9fdc9543c96d2209116bd9f" [[package]] name = "serde" -version = "1.0.201" +version = "1.0.204" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "780f1cebed1629e4753a1a38a3c72d30b97ec044f0aef68cb26650a3c5cf363c" +checksum = "bc76f558e0cbb2a839d37354c575f1dc3fdc6546b5be373ba43d95f231bf7c12" dependencies = [ "serde_derive", ] @@ -843,20 +512,20 @@ dependencies = [ [[package]] name = "serde_derive" -version = "1.0.201" +version = "1.0.204" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c5e405930b9796f1c00bee880d03fc7e0bb4b9a11afc776885ffe84320da2865" +checksum = "e0cd7e117be63d3c3678776753929474f3b04a43a080c744d6b0ae2a8c28e222" dependencies = [ "proc-macro2", "quote", - "syn 2.0.60", + "syn 2.0.66", ] [[package]] name = "serde_json" -version = "1.0.116" +version = "1.0.117" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3e17db7126d17feb94eb3fad46bf1a96b034e8aacbc2e775fe81505f8b0b2813" +checksum = "455182ea6142b14f93f4bc5320a2b31c1f266b66a4a5c858b013302a5d8cbfc3" dependencies = [ "itoa", "ryu", @@ -871,13 +540,13 @@ checksum = "6c64451ba24fc7a6a2d60fc75dd9c83c90903b19028d4eff35e88fc1e86564e9" dependencies = [ "proc-macro2", "quote", - "syn 2.0.60", + "syn 2.0.66", ] [[package]] name = "sha2" -version = "0.9.8" -source = "git+https://github.com/sp1-patches/RustCrypto-hashes?branch=patch-v0.9.8#0b578688db61bb53e15353f5beaa2c11ad93f037" +version = "0.9.9" +source = "git+https://github.com/sp1-patches/RustCrypto-hashes?branch=patch-v0.9.9#db82a4848f8d033eab544255e1efa036cc06f054" dependencies = [ "block-buffer 0.9.0", "cfg-if", @@ -889,8 +558,7 @@ dependencies = [ [[package]] name = "sha2" version = "0.10.8" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "793db75ad2bcafc3ffa7c68b215fee268f537982cd901d132f89c6343f3a3dc8" +source = "git+https://github.com/sp1-patches/RustCrypto-hashes?branch=patch-v0.10.8#1f224388fdede7cef649bce0d63876d1a9e3f515" dependencies = [ "cfg-if", "cpufeatures", @@ -902,52 +570,31 @@ name = "signature" version = "2.2.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "77549399552de45a898a580c1b41d445bf730df867cc44e6c0233bbc4b8329de" -dependencies = [ - "digest 0.10.7", - "rand_core", -] [[package]] -name = "snowbridge-amcl" -version = "1.0.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "460a9ed63cdf03c1b9847e8a12a5f5ba19c4efd5869e4a737e05be25d7c427e5" -dependencies = [ - "parity-scale-codec", - "scale-info", -] - -[[package]] -name = "sp1-precompiles" -version = "0.1.0" +name = "sp1-lib" +version = "1.0.0-rc.1" dependencies = [ "anyhow", "bincode", "cfg-if", - "getrandom", - "hex", - "k256", - "num", - "rand", "serde", - "snowbridge-amcl", ] [[package]] name = "sp1-zkvm" -version = "0.1.0" +version = "1.0.0-rc.1" dependencies = [ "bincode", "cfg-if", "getrandom", - "k256", "lazy_static", "libm", "once_cell", "rand", "serde", "sha2 0.10.8", - "sp1-precompiles", + "sp1-lib", ] [[package]] @@ -994,25 +641,20 @@ dependencies = [ [[package]] name = "syn" -version = "2.0.60" +version = "2.0.66" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "909518bc7b1c9b779f1bbf07f2929d35af9f0f37e47c6e9ef7f9dddc1e1821f3" +checksum = "c42f3f41a2de00b01c0aaad383c5a45241efc8b2d1eda5661812fda5f3cdcff5" dependencies = [ "proc-macro2", "quote", "unicode-ident", ] -[[package]] -name = "tap" -version = "1.0.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "55937e1799185b12863d447f42597ed69d9928686b8d88a1df17376a097d8369" - [[package]] name = "tendermint" -version = "0.34.0" -source = "git+https://github.com/i-m-aditya/tendermint-rs.git?branch=i-m-aditya/break-loop-on-having-enough-voting-power#e14b71cd1808e2682ffe3d81ff0d9182bde496c2" +version = "0.35.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "43f8a10105d0a7c4af0a242e23ed5a12519afe5cc0e68419da441bb5981a6802" dependencies = [ "bytes", "digest 0.10.7", @@ -1039,8 +681,9 @@ dependencies = [ [[package]] name = "tendermint-light-client-verifier" -version = "0.34.0" -source = "git+https://github.com/i-m-aditya/tendermint-rs.git?branch=i-m-aditya/break-loop-on-having-enough-voting-power#e14b71cd1808e2682ffe3d81ff0d9182bde496c2" +version = "0.35.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "35678b66e819659617c2e83f9662b8544425694441990c07137904a07872d871" dependencies = [ "derive_more", "flex-error", @@ -1051,7 +694,7 @@ dependencies = [ [[package]] name = "tendermint-program" -version = "0.1.0" +version = "1.0.0-rc.1" dependencies = [ "serde", "serde_cbor", @@ -1062,8 +705,9 @@ dependencies = [ [[package]] name = "tendermint-proto" -version = "0.34.0" -source = "git+https://github.com/i-m-aditya/tendermint-rs.git?branch=i-m-aditya/break-loop-on-having-enough-voting-power#e14b71cd1808e2682ffe3d81ff0d9182bde496c2" +version = "0.35.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ff525d5540a9fc535c38dc0d92a98da3ee36fcdfbda99cecb9f3cce5cd4d41d7" dependencies = [ "bytes", "flex-error", @@ -1106,34 +750,6 @@ dependencies = [ "time-core", ] -[[package]] -name = "toml_datetime" -version = "0.6.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7cda73e2f1397b1262d6dfdcef8aafae14d1de7748d66822d3bfeeb6d03e5e4b" - -[[package]] -name = "toml_edit" -version = "0.19.15" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1b5bb770da30e5cbfde35a2d7b9b8a2c4b8ef89548a7a6aeab5c9a576e3e7421" -dependencies = [ - "indexmap", - "toml_datetime", - "winnow", -] - -[[package]] -name = "toml_edit" -version = "0.20.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "396e4d48bbb2b7554c944bde63101b5ae446cff6ec4a24227428f15eb72ef338" -dependencies = [ - "indexmap", - "toml_datetime", - "winnow", -] - [[package]] name = "typenum" version = "1.17.0" @@ -1158,29 +774,11 @@ version = "0.11.0+wasi-snapshot-preview1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "9c8d87e72b64a3b4db28d11ce29237c246188f4f51057d65a7eab63b7987e423" -[[package]] -name = "winnow" -version = "0.5.40" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f593a95398737aeed53e489c785df13f3618e41dbcd6718c6addbf1395aa6876" -dependencies = [ - "memchr", -] - -[[package]] -name = "wyz" -version = "0.5.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "05f360fc0b24296329c78fda852a1e9ae82de9cf7b27dae4b7f62f118f77b9ed" -dependencies = [ - "tap", -] - [[package]] name = "zeroize" -version = "1.7.0" +version = "1.8.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "525b4ec142c6b68a2d10f01f7bbf6755599ca3f81ea53b8431b7dd348f5fdb2d" +checksum = "ced3678a2879b30306d323f4542626697a464a97c0a07c9aebf7ebca65cd4dde" dependencies = [ "zeroize_derive", ] @@ -1193,10 +791,5 @@ checksum = "ce36e65b0d2999d2aafac989fb249189a141aee1f53c612c1f37d72631959f69" dependencies = [ "proc-macro2", "quote", - "syn 2.0.60", + "syn 2.0.66", ] - -[[patch.unused]] -name = "sha2" -version = "0.10.6" -source = "git+https://github.com/sp1-patches/RustCrypto-hashes?branch=patch-v0.10.6#482efd7c1a750c300f3740a2c75dda9eb4eb1ddd" diff --git a/examples/tendermint/program/Cargo.toml b/examples/tendermint/program/Cargo.toml index 5ed14c87f5..2da3d65c27 100644 --- a/examples/tendermint/program/Cargo.toml +++ b/examples/tendermint/program/Cargo.toml @@ -1,25 +1,20 @@ [workspace] [package] -version = "0.1.0" name = "tendermint-program" +version = "1.0.0-rc.1" edition = "2021" +publish = false [dependencies] sp1-zkvm = { path = "../../../zkvm/entrypoint" } serde_json = { version = "1.0", default-features = false, features = ["alloc"] } serde = { version = "1.0", default-features = false, features = ["derive"] } -tendermint-light-client-verifier = { git = "https://github.com/i-m-aditya/tendermint-rs.git", branch = "i-m-aditya/break-loop-on-having-enough-voting-power", default-features = false, features = [ +tendermint-light-client-verifier = { version = "0.35.0", default-features = false, features = [ "rust-crypto", ] } -# tendermint-light-client-verifier = { version = "0.34.0", default-features = false, features = [ -# "rust-crypto", -# ] } -# tendermint-light-client-verifier = { path = "../../../../tendermint-rs/light-client-verifier", default-features = false, features = [ -# "rust-crypto", -# ] } serde_cbor = "0.11.2" [patch.crates-io] -sha2-v0-9-8 = { git = "https://github.com/sp1-patches/RustCrypto-hashes", package = "sha2", branch = "patch-v0.9.8" } -sha2-v0-10-6 = { git = "https://github.com/sp1-patches/RustCrypto-hashes", package = "sha2", branch = "patch-v0.10.6" } ed25519-consensus = { git = "https://github.com/sp1-patches/ed25519-consensus", branch = "patch-v2.1.0" } +sha2-v0-9-9 = { git = "https://github.com/sp1-patches/RustCrypto-hashes", package = "sha2", branch = "patch-v0.9.9" } +sha2-v0-10-8 = { git = "https://github.com/sp1-patches/RustCrypto-hashes", package = "sha2", branch = "patch-v0.10.8" } diff --git a/examples/tendermint/program/elf/riscv32im-succinct-zkvm-elf b/examples/tendermint/program/elf/riscv32im-succinct-zkvm-elf index f7ddcd1de0..f1f2001b88 100755 Binary files a/examples/tendermint/program/elf/riscv32im-succinct-zkvm-elf and b/examples/tendermint/program/elf/riscv32im-succinct-zkvm-elf differ diff --git a/examples/tendermint/script/Cargo.toml b/examples/tendermint/script/Cargo.toml index dd43f10dbe..3f676e8d55 100644 --- a/examples/tendermint/script/Cargo.toml +++ b/examples/tendermint/script/Cargo.toml @@ -1,17 +1,18 @@ [package] -version = "0.1.0" name = "tendermint-script" -edition = "2021" +version = { workspace = true } +edition = { workspace = true } +publish = false [dependencies] -sp1-core = { path = "../../../core", features = ["neon"] } -sp1-sdk = { path = "../../../sdk" } +sp1-core = { workspace = true, features = ["neon"] } +sp1-sdk = { workspace = true } reqwest = { version = "0.11", features = ["json"] } tokio = { version = "1", features = ["full"] } serde_json = { version = "1.0", default-features = false, features = ["alloc"] } serde = { version = "1.0", default-features = false, features = ["derive"] } -tendermint = { version = "0.34.0", default-features = false } -tendermint-light-client-verifier = { version = "0.34.0", default-features = false, features = [ +tendermint = { version = "0.35.0", default-features = false } +tendermint-light-client-verifier = { version = "0.35.0", default-features = false, features = [ "rust-crypto", ] } bincode = "1.3.3" @@ -20,4 +21,4 @@ serde_cbor = "0.11.2" sha2 = "0.10.8" [build-dependencies] -sp1-helper = { path = "../../../helper" } +sp1-helper = { workspace = true } diff --git a/examples/tendermint/script/src/main.rs b/examples/tendermint/script/src/main.rs index e2fa14837d..4184fadd0c 100644 --- a/examples/tendermint/script/src/main.rs +++ b/examples/tendermint/script/src/main.rs @@ -1,4 +1,4 @@ -use sp1_sdk::SP1Proof; +use sp1_sdk::SP1ProofWithPublicValues; use std::time::Duration; use tokio::runtime::Runtime; @@ -29,10 +29,10 @@ async fn get_light_blocks() -> (LightBlock, LightBlock) { let latest_commit = fetch_latest_commit(&client, &url).await.unwrap(); let block: u64 = latest_commit.result.signed_header.header.height.into(); println!("Latest block: {}", block); - let light_block_1 = fetch_light_block(block - 20, peer_id, BASE_URL) + let light_block_1 = fetch_light_block(2279100, peer_id, BASE_URL) .await .expect("Failed to generate light block 1"); - let light_block_2 = fetch_light_block(block, peer_id, BASE_URL) + let light_block_2 = fetch_light_block(2279130, peer_id, BASE_URL) .await .expect("Failed to generate light block 2"); (light_block_1, light_block_2) @@ -63,7 +63,7 @@ fn main() { let client = ProverClient::new(); let (pk, vk) = client.setup(TENDERMINT_ELF); - let proof = client.prove(&pk, stdin).expect("proving failed"); + let proof = client.prove(&pk, stdin).compressed().run().expect("proving failed"); // Verify proof. client.verify(&proof, &vk).expect("verification failed"); @@ -80,7 +80,7 @@ fn main() { proof .save("proof-with-pis.bin") .expect("saving proof failed"); - let deserialized_proof = SP1Proof::load("proof-with-pis.bin").expect("loading proof failed"); + let deserialized_proof = SP1ProofWithPublicValues::load("proof-with-pis.bin").expect("loading proof failed"); // Verify the deserialized proof. client diff --git a/helper/CHANGELOG.md b/helper/CHANGELOG.md new file mode 100644 index 0000000000..8d8d0025d8 --- /dev/null +++ b/helper/CHANGELOG.md @@ -0,0 +1,18 @@ +# Changelog + +All notable changes to this project will be documented in this file. + +The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/), +and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html). + +## [Unreleased] + +## [1.0.0-rc.1](https://github.com/succinctlabs/sp1/compare/sp1-helper-v1.0.0-rc.1...sp1-helper-v1.0.0-rc.1) - 2024-07-19 + +### Fixed + +- `sp1-helper` workspace build ([#1119](https://github.com/succinctlabs/sp1/pull/1119)) + +### Other + +- use global workspace version ([#1102](https://github.com/succinctlabs/sp1/pull/1102)) diff --git a/helper/Cargo.toml b/helper/Cargo.toml index 1c03ce433f..5d8d588257 100644 --- a/helper/Cargo.toml +++ b/helper/Cargo.toml @@ -1,8 +1,15 @@ [package] name = "sp1-helper" -version = "0.1.0" -edition = "2021" +description = "Crate for building SP1 programs with build scripts." +readme = "../README.md" +version = { workspace = true } +edition = { workspace = true } +license = { workspace = true } +repository = { workspace = true } +keywords = { workspace = true } +categories = { workspace = true } [dependencies] +sp1-build = { workspace = true } cargo_metadata = "0.18.1" chrono = { version = "0.4.38", default-features = false, features = ["clock"] } diff --git a/helper/src/lib.rs b/helper/src/lib.rs index bfc33a5ace..523c81509d 100644 --- a/helper/src/lib.rs +++ b/helper/src/lib.rs @@ -1,56 +1,54 @@ +use cargo_metadata::Metadata; use chrono::Local; -use std::{ - io::{BufRead, BufReader}, - process::{Command, Stdio}, - thread, -}; +pub use sp1_build::BuildArgs; +use std::{path::Path, process::ExitStatus}; fn current_datetime() -> String { let now = Local::now(); now.format("%Y-%m-%d %H:%M:%S").to_string() } -pub fn build_program(path: &str) { - println!("path: {:?}", path); - let program_dir = std::path::Path::new(path); - - // Tell cargo to rerun the script only if program/{src, Cargo.toml, Cargo.lock} changes +/// Re-run the cargo command if the Cargo.toml or Cargo.lock file changes. +fn cargo_rerun_if_changed(metadata: &Metadata, program_dir: &Path) { + // Tell cargo to rerun the script only if program/{src, bin, build.rs, Cargo.toml} changes // Ref: https://doc.rust-lang.org/nightly/cargo/reference/build-scripts.html#rerun-if-changed let dirs = vec![ program_dir.join("src"), + program_dir.join("bin"), + program_dir.join("build.rs"), program_dir.join("Cargo.toml"), - program_dir.join("Cargo.lock"), ]; for dir in dirs { - println!("cargo::rerun-if-changed={}", dir.display()); + if dir.exists() { + println!( + "cargo::rerun-if-changed={}", + dir.canonicalize().unwrap().display() + ); + } } - // Print a message so the user knows that their program was built. Cargo caches warnings emitted - // from build scripts, so we'll print the date/time when the program was built. - let metadata_file = program_dir.join("Cargo.toml"); - let mut metadata_cmd = cargo_metadata::MetadataCommand::new(); - let metadata = metadata_cmd.manifest_path(metadata_file).exec().unwrap(); - let root_package = metadata.root_package(); - let root_package_name = root_package - .as_ref() - .map(|p| p.name.as_str()) - .unwrap_or("Program"); + // Re-run the build script if the workspace root's Cargo.lock changes. If the program is its own + // workspace, this will be the program's Cargo.lock. println!( - "cargo:warning={} built at {}", - root_package_name, - current_datetime() + "cargo:rerun-if-changed={}", + metadata.workspace_root.join("Cargo.lock").as_str() ); - let status = execute_build_cmd(&program_dir) - .unwrap_or_else(|_| panic!("Failed to build `{}`.", root_package_name)); - if !status.success() { - panic!("Failed to build `{}`.", root_package_name); + // Re-run if any local dependency changes. + for package in &metadata.packages { + for dependency in &package.dependencies { + if let Some(path) = &dependency.path { + println!("cargo:rerun-if-changed={}", path.as_str()); + } + } } } -/// Executes the `cargo prove build` command in the program directory +/// Executes the `cargo prove build` command in the program directory. If there are any cargo prove +/// build arguments, they are added to the command. fn execute_build_cmd( program_dir: &impl AsRef, + args: Option, ) -> Result { // Check if RUSTC_WORKSPACE_WRAPPER is set to clippy-driver (i.e. if `cargo clippy` is the current // compiler). If so, don't execute `cargo prove build` because it breaks rust-analyzer's `cargo clippy` feature. @@ -62,28 +60,86 @@ fn execute_build_cmd( return Ok(std::process::ExitStatus::default()); } - let mut cmd = Command::new("cargo"); - cmd.current_dir(program_dir) - .args(["prove", "build"]) - .env_remove("RUSTC") - .stdout(Stdio::piped()) - .stderr(Stdio::piped()); - let mut child = cmd.spawn()?; + // Build the program with the given arguments. + let path_output = if let Some(args) = args { + sp1_build::build_program(&args, Some(program_dir.as_ref().to_path_buf())) + } else { + sp1_build::build_program( + &BuildArgs::default(), + Some(program_dir.as_ref().to_path_buf()), + ) + }; + if let Err(err) = path_output { + panic!("Failed to build SP1 program: {}.", err); + } - let stdout = BufReader::new(child.stdout.take().unwrap()); - let stderr = BufReader::new(child.stderr.take().unwrap()); + Ok(ExitStatus::default()) +} - // Pipe stdout and stderr to the parent process with [sp1] prefix - let stdout_handle = thread::spawn(move || { - stdout.lines().for_each(|line| { - println!("[sp1] {}", line.unwrap()); - }); - }); - stderr.lines().for_each(|line| { - eprintln!("[sp1] {}", line.unwrap()); - }); +/// Builds the program if the program at the specified path, or one of its dependencies, changes. +/// +/// This function monitors the program and its dependencies for changes. If any changes are detected, +/// it triggers a rebuild of the program. +/// +/// # Arguments +/// +/// * `path` - A string slice that holds the path to the program directory. +/// +/// This function is useful for automatically rebuilding the program during development +/// when changes are made to the source code or its dependencies. +/// +/// Set the `SP1_SKIP_PROGRAM_BUILD` environment variable to `true` to skip building the program. +pub fn build_program(path: &str) { + build_program_internal(path, None) +} - stdout_handle.join().unwrap(); +/// Builds the program with the given arguments if the program at path, or one of its dependencies, +/// changes. +/// +/// # Arguments +/// +/// * `path` - A string slice that holds the path to the program directory. +/// * `args` - A [`BuildArgs`] struct that contains various build configuration options. +/// +/// Set the `SP1_SKIP_PROGRAM_BUILD` environment variable to `true` to skip building the program. +pub fn build_program_with_args(path: &str, args: BuildArgs) { + build_program_internal(path, Some(args)) +} - child.wait() +/// Internal helper function to build the program with or without arguments. +fn build_program_internal(path: &str, args: Option) { + // Get the root package name and metadata. + let program_dir = std::path::Path::new(path); + let metadata_file = program_dir.join("Cargo.toml"); + let mut metadata_cmd = cargo_metadata::MetadataCommand::new(); + let metadata = metadata_cmd.manifest_path(metadata_file).exec().unwrap(); + let root_package = metadata.root_package(); + let root_package_name = root_package + .as_ref() + .map(|p| p.name.as_str()) + .unwrap_or("Program"); + + // Skip the program build if the SP1_SKIP_PROGRAM_BUILD environment variable is set to true. + let skip_program_build = std::env::var("SP1_SKIP_PROGRAM_BUILD") + .map(|v| v.eq_ignore_ascii_case("true")) + .unwrap_or(false); + if skip_program_build { + println!( + "cargo:warning=Build skipped for {} at {} due to SP1_SKIP_PROGRAM_BUILD flag", + root_package_name, + current_datetime() + ); + return; + } + + // Activate the build command if the dependencies change. + cargo_rerun_if_changed(&metadata, program_dir); + + let _ = execute_build_cmd(&program_dir, args); + + println!( + "cargo:warning={} built at {}", + root_package_name, + current_datetime() + ); } diff --git a/primitives/CHANGELOG.md b/primitives/CHANGELOG.md new file mode 100644 index 0000000000..ff4bc3a29b --- /dev/null +++ b/primitives/CHANGELOG.md @@ -0,0 +1,49 @@ +# Changelog + +All notable changes to this project will be documented in this file. + +The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/), +and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html). + +## [Unreleased] + +## [1.0.0-rc.1](https://github.com/succinctlabs/sp1/compare/sp1-primitives-v1.0.0-rc.1...sp1-primitives-v1.0.0-rc.1) - 2024-07-19 + +### Added + +- publish sp1 to crates.io ([#1052](https://github.com/succinctlabs/sp1/pull/1052)) +- plonk circuit optimizations ([#972](https://github.com/succinctlabs/sp1/pull/972)) +- enable arbitrary constraint degree ([#593](https://github.com/succinctlabs/sp1/pull/593)) +- complete reduce program ([#565](https://github.com/succinctlabs/sp1/pull/565)) +- nested sp1 proof verification ([#494](https://github.com/succinctlabs/sp1/pull/494)) +- new README img ([#226](https://github.com/succinctlabs/sp1/pull/226)) +- readme updates ([#205](https://github.com/succinctlabs/sp1/pull/205)) +- more final touches ([#194](https://github.com/succinctlabs/sp1/pull/194)) +- curtaup + release system + cargo prove CLI updates ([#178](https://github.com/succinctlabs/sp1/pull/178)) +- (perf) updates from Plonky3 and verifier refactor ([#156](https://github.com/succinctlabs/sp1/pull/156)) +- developer experience improvements ([#145](https://github.com/succinctlabs/sp1/pull/145)) +- toolchain build from source & install ([#113](https://github.com/succinctlabs/sp1/pull/113)) +- io::read io::write ([#126](https://github.com/succinctlabs/sp1/pull/126)) +- tracing, profiling, benchmarking ([#99](https://github.com/succinctlabs/sp1/pull/99)) + +### Fixed + +- deferred proofs + cleanup hash_vkey ([#615](https://github.com/succinctlabs/sp1/pull/615)) + +### Other + +- use global workspace version ([#1102](https://github.com/succinctlabs/sp1/pull/1102)) +- fix release-plz ([#1088](https://github.com/succinctlabs/sp1/pull/1088)) +- add release-plz ([#1086](https://github.com/succinctlabs/sp1/pull/1086)) +- _(deps)_ bump lazy_static from 1.4.0 to 1.5.0 +- _(deps)_ bump itertools from 0.12.1 to 0.13.0 +- Clean up TOML files ([#796](https://github.com/succinctlabs/sp1/pull/796)) +- prover tweaks ([#610](https://github.com/succinctlabs/sp1/pull/610)) +- final touches for public release ([#239](https://github.com/succinctlabs/sp1/pull/239)) +- update docs with slight nits ([#224](https://github.com/succinctlabs/sp1/pull/224)) +- sp1 rename ([#212](https://github.com/succinctlabs/sp1/pull/212)) +- enshrine AlignedBorrow macro ([#209](https://github.com/succinctlabs/sp1/pull/209)) +- readme cleanup ([#196](https://github.com/succinctlabs/sp1/pull/196)) +- rename succinct to curta ([#192](https://github.com/succinctlabs/sp1/pull/192)) +- better curta graphic ([#184](https://github.com/succinctlabs/sp1/pull/184)) +- Initial commit diff --git a/primitives/Cargo.toml b/primitives/Cargo.toml index 371b9f46a6..f52956802b 100644 --- a/primitives/Cargo.toml +++ b/primitives/Cargo.toml @@ -1,10 +1,16 @@ [package] name = "sp1-primitives" -version = "0.1.0" -edition = "2021" +description = "SP1 is a performant, 100% open-source, contributor-friendly zkVM." +readme = "../README.md" +version = { workspace = true } +edition = { workspace = true } +license = { workspace = true } +repository = { workspace = true } +keywords = { workspace = true } +categories = { workspace = true } [dependencies] -lazy_static = "1.4.0" +lazy_static = "1.5.0" p3-field = { workspace = true } p3-baby-bear = { workspace = true } p3-poseidon2 = { workspace = true } diff --git a/primitives/src/lib.rs b/primitives/src/lib.rs index 97a074cdc3..cd89a5134e 100644 --- a/primitives/src/lib.rs +++ b/primitives/src/lib.rs @@ -6,6 +6,8 @@ use p3_baby_bear::{BabyBear, DiffusionMatrixBabyBear}; use p3_field::AbstractField; use p3_poseidon2::{Poseidon2, Poseidon2ExternalMatrixGeneral}; +pub mod types; + lazy_static! { // These constants are created by a RNG. diff --git a/primitives/src/types.rs b/primitives/src/types.rs index e69de29bb2..c75d210cc1 100644 --- a/primitives/src/types.rs +++ b/primitives/src/types.rs @@ -0,0 +1,8 @@ +#[derive(Debug, Clone, Copy)] +pub enum RecursionProgramType { + Core, + Deferred, + Compress, + Shrink, + Wrap, +} diff --git a/prover/CHANGELOG.md b/prover/CHANGELOG.md new file mode 100644 index 0000000000..b99e027080 --- /dev/null +++ b/prover/CHANGELOG.md @@ -0,0 +1,148 @@ +# Changelog + +All notable changes to this project will be documented in this file. + +The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/), +and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html). + +## [Unreleased] + +## [1.0.0-rc.1](https://github.com/succinctlabs/sp1/compare/sp1-prover-v1.0.0-rc.1...sp1-prover-v1.0.0-rc.1) - 2024-07-19 + +### Added + +- 1.0.0-rc.1 ([#1126](https://github.com/succinctlabs/sp1/pull/1126)) +- parallel recursion tracegen ([#1095](https://github.com/succinctlabs/sp1/pull/1095)) +- result instead of exit(1) on trap in recursion ([#1089](https://github.com/succinctlabs/sp1/pull/1089)) +- publish sp1 to crates.io ([#1052](https://github.com/succinctlabs/sp1/pull/1052)) +- critical constraint changes ([#1046](https://github.com/succinctlabs/sp1/pull/1046)) +- suggest prover network if high cycles ([#1019](https://github.com/succinctlabs/sp1/pull/1019)) +- plonk circuit optimizations ([#972](https://github.com/succinctlabs/sp1/pull/972)) +- poseidon2 hash ([#885](https://github.com/succinctlabs/sp1/pull/885)) +- (breaking changes to SDK API) use builder pattern for SDK execute/prove/verify ([#940](https://github.com/succinctlabs/sp1/pull/940)) +- verify subproof in runtime ([#911](https://github.com/succinctlabs/sp1/pull/911)) +- _(sdk)_ add explorer link ([#858](https://github.com/succinctlabs/sp1/pull/858)) +- generic const expr ([#854](https://github.com/succinctlabs/sp1/pull/854)) +- execute() exposes ExecutionReport ([#847](https://github.com/succinctlabs/sp1/pull/847)) +- update contract artifacts ([#802](https://github.com/succinctlabs/sp1/pull/802)) +- sp1 core prover opts +- batch sized recursion ([#785](https://github.com/succinctlabs/sp1/pull/785)) +- plonk prover ([#795](https://github.com/succinctlabs/sp1/pull/795)) +- groth16 feature flag ([#782](https://github.com/succinctlabs/sp1/pull/782)) +- Implement `verify_groth16` & `prove_groth16` on `MockProver` ([#745](https://github.com/succinctlabs/sp1/pull/745)) +- add proof verification ([#729](https://github.com/succinctlabs/sp1/pull/729)) +- reduce network prover ([#687](https://github.com/succinctlabs/sp1/pull/687)) +- auto rebuild dev artifacts in sdk ([#726](https://github.com/succinctlabs/sp1/pull/726)) +- fix execution + proving errors ([#715](https://github.com/succinctlabs/sp1/pull/715)) +- update groth16 artifacts ([#711](https://github.com/succinctlabs/sp1/pull/711)) +- program refactor ([#651](https://github.com/succinctlabs/sp1/pull/651)) +- serial tests in prover crate ([#673](https://github.com/succinctlabs/sp1/pull/673)) +- e2e groth16 with contract verifier ([#671](https://github.com/succinctlabs/sp1/pull/671)) +- nextgen ci for sp1-prover ([#663](https://github.com/succinctlabs/sp1/pull/663)) +- Adding docs for new `ProverClient` and `groth16` and `compressed` mode ([#627](https://github.com/succinctlabs/sp1/pull/627)) +- add `groth16` verification to gnark server ([#631](https://github.com/succinctlabs/sp1/pull/631)) +- aggregation fixes ([#649](https://github.com/succinctlabs/sp1/pull/649)) +- improve circuit by 3-4x ([#648](https://github.com/succinctlabs/sp1/pull/648)) +- regularize proof shape ([#641](https://github.com/succinctlabs/sp1/pull/641)) +- _(sdk)_ auto setup circuit ([#635](https://github.com/succinctlabs/sp1/pull/635)) +- prover tweaks pt4 ([#632](https://github.com/succinctlabs/sp1/pull/632)) +- groth16 server ([#594](https://github.com/succinctlabs/sp1/pull/594)) +- arbitrary degree in recursion ([#605](https://github.com/succinctlabs/sp1/pull/605)) +- prover tweaks ([#603](https://github.com/succinctlabs/sp1/pull/603)) +- recursion compress layer + RecursionAirWideDeg3 + RecursionAirSkinnyDeg7 + optimized groth16 ([#590](https://github.com/succinctlabs/sp1/pull/590)) +- plonk e2e prover ([#582](https://github.com/succinctlabs/sp1/pull/582)) +- complete reduce program ([#565](https://github.com/succinctlabs/sp1/pull/565)) +- public inputs in gnark circuit ([#576](https://github.com/succinctlabs/sp1/pull/576)) +- e2e groth16 flow ([#549](https://github.com/succinctlabs/sp1/pull/549)) +- stark cleanup and verification ([#556](https://github.com/succinctlabs/sp1/pull/556)) +- recursion experiments ([#522](https://github.com/succinctlabs/sp1/pull/522)) +- groth16 circuit build script ([#541](https://github.com/succinctlabs/sp1/pull/541)) +- verify shard transitions + fixes ([#482](https://github.com/succinctlabs/sp1/pull/482)) +- nested sp1 proof verification ([#494](https://github.com/succinctlabs/sp1/pull/494)) +- verify pc and shard transition in recursive proofs ([#514](https://github.com/succinctlabs/sp1/pull/514)) +- recursion profiling ([#521](https://github.com/succinctlabs/sp1/pull/521)) +- gnark wrap test + cleanup ([#511](https://github.com/succinctlabs/sp1/pull/511)) +- 0 cycle input for recursion program ([#510](https://github.com/succinctlabs/sp1/pull/510)) +- reduce with different configs ([#508](https://github.com/succinctlabs/sp1/pull/508)) +- _(recursion)_ reduce N sp1/recursive proofs ([#503](https://github.com/succinctlabs/sp1/pull/503)) +- recursion optimizations + compiler cleanup ([#499](https://github.com/succinctlabs/sp1/pull/499)) +- recursion vm public values ([#495](https://github.com/succinctlabs/sp1/pull/495)) +- add support for witness in programs ([#476](https://github.com/succinctlabs/sp1/pull/476)) +- setup recursion prover crate ([#475](https://github.com/succinctlabs/sp1/pull/475)) +- new README img ([#226](https://github.com/succinctlabs/sp1/pull/226)) +- readme updates ([#205](https://github.com/succinctlabs/sp1/pull/205)) +- more final touches ([#194](https://github.com/succinctlabs/sp1/pull/194)) +- curtaup + release system + cargo prove CLI updates ([#178](https://github.com/succinctlabs/sp1/pull/178)) +- (perf) updates from Plonky3 and verifier refactor ([#156](https://github.com/succinctlabs/sp1/pull/156)) +- developer experience improvements ([#145](https://github.com/succinctlabs/sp1/pull/145)) +- toolchain build from source & install ([#113](https://github.com/succinctlabs/sp1/pull/113)) +- io::read io::write ([#126](https://github.com/succinctlabs/sp1/pull/126)) +- tracing, profiling, benchmarking ([#99](https://github.com/succinctlabs/sp1/pull/99)) + +### Fixed + +- plonk feature off by default ([#852](https://github.com/succinctlabs/sp1/pull/852)) +- install for `verify_plonk_bn254` ([#798](https://github.com/succinctlabs/sp1/pull/798)) +- groth16 install when in existing runtime ([#735](https://github.com/succinctlabs/sp1/pull/735)) +- shutdown groth16 ([#667](https://github.com/succinctlabs/sp1/pull/667)) +- _(sdk)_ Small fix for getting vkey digest ([#665](https://github.com/succinctlabs/sp1/pull/665)) +- verify reduced proofs ([#655](https://github.com/succinctlabs/sp1/pull/655)) +- high degree constraints in recursion ([#619](https://github.com/succinctlabs/sp1/pull/619)) +- deferred proofs + cleanup hash_vkey ([#615](https://github.com/succinctlabs/sp1/pull/615)) +- groth16 prover issues ([#571](https://github.com/succinctlabs/sp1/pull/571)) +- observe only non-padded public values ([#523](https://github.com/succinctlabs/sp1/pull/523)) +- broken e2e recursion +- don't observe padded public values ([#520](https://github.com/succinctlabs/sp1/pull/520)) + +### Other + +- prover utilization ([#1100](https://github.com/succinctlabs/sp1/pull/1100)) +- _(deps)_ bump clap from 4.5.8 to 4.5.9 ([#1107](https://github.com/succinctlabs/sp1/pull/1107)) +- use global workspace version ([#1102](https://github.com/succinctlabs/sp1/pull/1102)) +- fix release-plz ([#1088](https://github.com/succinctlabs/sp1/pull/1088)) +- add release-plz ([#1086](https://github.com/succinctlabs/sp1/pull/1086)) +- remove async crates `sp1-prover` ([#1042](https://github.com/succinctlabs/sp1/pull/1042)) +- Merge branch 'dev' into dependabot/cargo/dev/clap-4.5.8 +- _(deps)_ bump serde_json from 1.0.117 to 1.0.120 ([#1001](https://github.com/succinctlabs/sp1/pull/1001)) +- _(deps)_ bump num-bigint from 0.4.5 to 0.4.6 +- merge main -> dev ([#969](https://github.com/succinctlabs/sp1/pull/969)) +- cleanup compress ([#928](https://github.com/succinctlabs/sp1/pull/928)) +- v1.0.7-testnet ([#930](https://github.com/succinctlabs/sp1/pull/930)) +- Fixes from review. +- please clippy +- uncomment +- Merge branch 'dev' into erabinov/exp_rev_precompile +- Version of exp_rev_precompile +- _(deps)_ bump tokio from 1.37.0 to 1.38.0 +- update plonk artifacts ([#877](https://github.com/succinctlabs/sp1/pull/877)) +- fixes ([#821](https://github.com/succinctlabs/sp1/pull/821)) +- bump plonk artifacts ([#864](https://github.com/succinctlabs/sp1/pull/864)) +- `prove_plonk` ([#827](https://github.com/succinctlabs/sp1/pull/827)) +- hm +- remove unused deps ([#794](https://github.com/succinctlabs/sp1/pull/794)) +- Clean up TOML files ([#796](https://github.com/succinctlabs/sp1/pull/796)) +- SP1ProvingKey serde ([#772](https://github.com/succinctlabs/sp1/pull/772)) +- update groth16 build ([#758](https://github.com/succinctlabs/sp1/pull/758)) +- _(prover)_ expose functions for getting core/deferred inputs ([#755](https://github.com/succinctlabs/sp1/pull/755)) +- use actual ffi for gnark ([#738](https://github.com/succinctlabs/sp1/pull/738)) +- get_cycles don't need emit events ([#697](https://github.com/succinctlabs/sp1/pull/697)) +- update all dependencies ([#689](https://github.com/succinctlabs/sp1/pull/689)) +- _(recursion)_ poseidon2 loose ends ([#672](https://github.com/succinctlabs/sp1/pull/672)) +- gnark folder ([#677](https://github.com/succinctlabs/sp1/pull/677)) +- sdk tweaks ([#653](https://github.com/succinctlabs/sp1/pull/653)) +- sdk improvements ([#580](https://github.com/succinctlabs/sp1/pull/580)) +- prover tweaks ([#610](https://github.com/succinctlabs/sp1/pull/610)) +- `get_cycles` ([#595](https://github.com/succinctlabs/sp1/pull/595)) +- fixing dep tree for `prover`, `recursion`, `core` and `sdk` ([#545](https://github.com/succinctlabs/sp1/pull/545)) +- cleanup prover ([#551](https://github.com/succinctlabs/sp1/pull/551)) +- cleanup program + add missing constraints ([#547](https://github.com/succinctlabs/sp1/pull/547)) +- make ci faster ([#536](https://github.com/succinctlabs/sp1/pull/536)) +- _(recursion)_ reduce program ([#497](https://github.com/succinctlabs/sp1/pull/497)) +- final touches for public release ([#239](https://github.com/succinctlabs/sp1/pull/239)) +- update docs with slight nits ([#224](https://github.com/succinctlabs/sp1/pull/224)) +- sp1 rename ([#212](https://github.com/succinctlabs/sp1/pull/212)) +- enshrine AlignedBorrow macro ([#209](https://github.com/succinctlabs/sp1/pull/209)) +- readme cleanup ([#196](https://github.com/succinctlabs/sp1/pull/196)) +- rename succinct to curta ([#192](https://github.com/succinctlabs/sp1/pull/192)) +- better curta graphic ([#184](https://github.com/succinctlabs/sp1/pull/184)) +- Initial commit diff --git a/prover/Cargo.toml b/prover/Cargo.toml index 9a508fb74a..bb6347da30 100644 --- a/prover/Cargo.toml +++ b/prover/Cargo.toml @@ -1,51 +1,44 @@ [package] name = "sp1-prover" -version = "0.1.0" -edition = "2021" +description = "SP1 is a performant, 100% open-source, contributor-friendly zkVM." +readme = "../README.md" +version = { workspace = true } +edition = { workspace = true } +license = { workspace = true } +repository = { workspace = true } +keywords = { workspace = true } +categories = { workspace = true } [dependencies] -sp1-recursion-program = { path = "../recursion/program" } -sp1-recursion-circuit = { path = "../recursion/circuit" } -sp1-recursion-compiler = { path = "../recursion/compiler" } -sp1-recursion-core = { path = "../recursion/core" } -sp1-recursion-gnark-ffi = { path = "../recursion/gnark-ffi" } -sp1-core = { path = "../core" } -sp1-primitives = { path = "../primitives" } +sp1-recursion-program = { workspace = true } +sp1-recursion-circuit = { workspace = true } +sp1-recursion-compiler = { workspace = true } +sp1-recursion-core = { workspace = true } +sp1-recursion-gnark-ffi = { workspace = true } +sp1-core = { workspace = true } +sp1-primitives = { workspace = true } p3-field = { workspace = true } p3-challenger = { workspace = true } p3-baby-bear = { workspace = true } p3-bn254-fr = { workspace = true } p3-commit = { workspace = true } -p3-util = { workspace = true } bincode = "1.3.3" serde = { version = "1.0", features = ["derive", "rc"] } -backtrace = "0.3.71" rayon = "1.10.0" itertools = "0.13.0" tracing = "0.1.40" tracing-subscriber = "0.3.18" -serde_json = "1.0.117" -clap = { version = "4.5.7", features = ["derive", "env"] } -sha2 = "0.10.8" +serde_json = "1.0.120" +clap = { version = "4.5.9", features = ["derive", "env"] } hex = "0.4.3" anyhow = "1.0.83" -size = "0.4.1" dirs = "5.0.1" tempfile = "3.10.1" -tokio = { version = "1.38.0", features = ["full"] } -reqwest = { version = "0.12.4", features = [ - "rustls-tls", - "trust-dns", - "stream", -] } -indicatif = "0.17.8" -futures = "0.3.30" subtle-encoding = "0.5.1" serial_test = "3.1.1" -num-bigint = "0.4.5" +num-bigint = "0.4.6" thiserror = "1.0.60" -bytemuck = "1.16.0" -rand = "0.8.4" +oneshot = "0.1.8" [[bin]] name = "build_plonk_bn254" @@ -58,3 +51,4 @@ path = "scripts/e2e.rs" [features] neon = ["sp1-core/neon"] native-gnark = ["sp1-recursion-gnark-ffi/native"] +export-tests = [] diff --git a/prover/Makefile b/prover/Makefile index b4e0999616..8ab442e38b 100644 --- a/prover/Makefile +++ b/prover/Makefile @@ -6,7 +6,7 @@ build-plonk-bn254: rm -rf build && \ mkdir -p build && \ RUSTFLAGS='-C target-cpu=native' \ - cargo run -p sp1-prover --release --bin build_plonk_bn254 -- \ + cargo run -p sp1-prover --release --bin build_plonk_bn254 --features native-gnark -- \ --build-dir=./build release-plonk-bn254: diff --git a/prover/elf/riscv32im-succinct-zkvm-elf b/prover/elf/riscv32im-succinct-zkvm-elf new file mode 100755 index 0000000000..37e56b6dd4 Binary files /dev/null and b/prover/elf/riscv32im-succinct-zkvm-elf differ diff --git a/prover/scripts/e2e.rs b/prover/scripts/e2e.rs index ac2f08170c..21010dad9b 100644 --- a/prover/scripts/e2e.rs +++ b/prover/scripts/e2e.rs @@ -5,6 +5,8 @@ use clap::Parser; use p3_baby_bear::BabyBear; use p3_field::PrimeField; use sp1_core::io::SP1Stdin; +use sp1_core::runtime::SP1Context; +use sp1_core::utils::SP1ProverOpts; use sp1_prover::utils::{babybear_bytes_to_bn254, babybears_to_bn254, words_to_bytes}; use sp1_prover::SP1Prover; use sp1_recursion_circuit::stark::build_wrap_circuit; @@ -28,26 +30,28 @@ pub fn main() { let args = Args::parse(); let build_dir: PathBuf = args.build_dir.into(); - let elf = include_bytes!("../../tests/fibonacci/elf/riscv32im-succinct-zkvm-elf"); + let elf = include_bytes!("../elf/riscv32im-succinct-zkvm-elf"); tracing::info!("initializing prover"); - let prover = SP1Prover::new(); + let prover: SP1Prover = SP1Prover::new(); + let opts = SP1ProverOpts::default(); + let context = SP1Context::default(); tracing::info!("setup elf"); let (pk, vk) = prover.setup(elf); tracing::info!("prove core"); let stdin = SP1Stdin::new(); - let core_proof = prover.prove_core(&pk, &stdin).unwrap(); + let core_proof = prover.prove_core(&pk, &stdin, opts, context).unwrap(); tracing::info!("Compress"); - let reduced_proof = prover.compress(&vk, core_proof, vec![]).unwrap(); + let reduced_proof = prover.compress(&vk, core_proof, vec![], opts).unwrap(); tracing::info!("Shrink"); - let compressed_proof = prover.shrink(reduced_proof).unwrap(); + let compressed_proof = prover.shrink(reduced_proof, opts).unwrap(); tracing::info!("wrap"); - let wrapped_proof = prover.wrap_bn254(compressed_proof).unwrap(); + let wrapped_proof = prover.wrap_bn254(compressed_proof, opts).unwrap(); tracing::info!("building verifier constraints"); let constraints = tracing::info_span!("wrap circuit") diff --git a/prover/scripts/fibonacci_groth16.rs b/prover/scripts/fibonacci_groth16.rs index a1fcf2d640..fb5454274c 100644 --- a/prover/scripts/fibonacci_groth16.rs +++ b/prover/scripts/fibonacci_groth16.rs @@ -3,7 +3,10 @@ use std::time::Instant; use itertools::iproduct; -use sp1_core::io::SP1Stdin; +use sp1_core::{ + io::SP1Stdin, + utils::{SP1ProverOpts, SP1ProverOpts}, +}; use sp1_prover::SP1Prover; use tracing_subscriber::EnvFilter; use tracing_subscriber::{fmt::format::FmtSpan, util::SubscriberInitExt}; @@ -59,7 +62,9 @@ fn main() { proofs: vec![], }; let leaf_proving_start = Instant::now(); - let proof = prover.prove_core(&pk, &stdin).unwrap(); + let proof = prover + .prove_core(&pk, &stdin, SP1ProverOpts::default(), SP1Context::default()) + .unwrap(); let leaf_proving_duration = leaf_proving_start.elapsed().as_secs_f64(); tracing::info!("leaf_proving_duration={}", leaf_proving_duration); diff --git a/prover/scripts/fibonacci_sweep.rs b/prover/scripts/fibonacci_sweep.rs index d509ffb59e..687d7e518d 100644 --- a/prover/scripts/fibonacci_sweep.rs +++ b/prover/scripts/fibonacci_sweep.rs @@ -3,7 +3,10 @@ use std::{fs::File, io::BufWriter, io::Write, time::Instant}; use itertools::iproduct; -use sp1_core::io::SP1Stdin; +use sp1_core::{ + io::SP1Stdin, + utils::{SP1ProverOpts, SP1ProverOpts}, +}; use sp1_prover::SP1Prover; use tracing_subscriber::EnvFilter; use tracing_subscriber::{fmt::format::FmtSpan, util::SubscriberInitExt}; @@ -62,7 +65,9 @@ fn main() { proofs: vec![], }; let leaf_proving_start = Instant::now(); - let proof = prover.prove_core(&pk, &stdin).unwrap(); + let proof = prover + .prove_core(&pk, &stdin, SP1ProverOpts::default(), SP1Context::default()) + .unwrap(); let leaf_proving_duration = leaf_proving_start.elapsed().as_secs_f64(); let recursion_proving_start = Instant::now(); diff --git a/prover/scripts/tendermint_sweep.rs b/prover/scripts/tendermint_sweep.rs index 595970e6ad..efdcad88aa 100644 --- a/prover/scripts/tendermint_sweep.rs +++ b/prover/scripts/tendermint_sweep.rs @@ -3,7 +3,10 @@ use std::{fs::File, io::BufWriter, io::Write, time::Instant}; use itertools::iproduct; -use sp1_core::io::SP1Stdin; +use sp1_core::{ + io::SP1Stdin, + utils::{SP1ProverOpts, SP1ProverOpts}, +}; use sp1_prover::SP1Prover; use tracing_subscriber::EnvFilter; use tracing_subscriber::{fmt::format::FmtSpan, util::SubscriberInitExt}; @@ -62,7 +65,9 @@ fn main() { proofs: vec![], }; let leaf_proving_start = Instant::now(); - let proof = prover.prove_core(&pk, &stdin).unwrap(); + let proof = prover + .prove_core(&pk, &stdin, SP1ProverOpts::default(), SP1Context::default()) + .unwrap(); let leaf_proving_duration = leaf_proving_start.elapsed().as_secs_f64(); let recursion_proving_start = Instant::now(); diff --git a/prover/src/build.rs b/prover/src/build.rs index af7ab82172..96ee23c349 100644 --- a/prover/src/build.rs +++ b/prover/src/build.rs @@ -2,7 +2,9 @@ use std::borrow::Borrow; use std::path::PathBuf; use p3_baby_bear::BabyBear; +use sp1_core::runtime::SP1Context; use sp1_core::stark::StarkVerifyingKey; +use sp1_core::utils::SP1ProverOpts; use sp1_core::{io::SP1Stdin, stark::ShardProof}; pub use sp1_recursion_circuit::stark::build_wrap_circuit; pub use sp1_recursion_circuit::witness::Witnessable; @@ -12,29 +14,8 @@ use sp1_recursion_core::air::RecursionPublicValues; pub use sp1_recursion_core::stark::utils::sp1_dev_mode; use sp1_recursion_gnark_ffi::PlonkBn254Prover; -use crate::install::install_plonk_bn254_artifacts; use crate::utils::{babybear_bytes_to_bn254, babybears_to_bn254, words_to_bytes}; -use crate::{OuterSC, SP1Prover, SP1_CIRCUIT_VERSION}; - -/// Tries to install the PLONK artifacts if they are not already installed. -pub fn try_install_plonk_bn254_artifacts() -> PathBuf { - let build_dir = plonk_bn254_artifacts_dir(); - - if build_dir.exists() { - println!( - "[sp1] plonk bn254 artifacts already seem to exist at {}. if you want to re-download them, delete the directory", - build_dir.display() - ); - } else { - println!( - "[sp1] plonk bn254 artifacts for version {} do not exist at {}. downloading...", - SP1_CIRCUIT_VERSION, - build_dir.display() - ); - install_plonk_bn254_artifacts(build_dir.clone()); - } - build_dir -} +use crate::{OuterSC, SP1Prover}; /// Tries to build the PLONK artifacts inside the development directory. pub fn try_build_plonk_bn254_artifacts_dev( @@ -47,16 +28,6 @@ pub fn try_build_plonk_bn254_artifacts_dev( build_dir } -/// Gets the directory where the PLONK artifacts are installed. -fn plonk_bn254_artifacts_dir() -> PathBuf { - dirs::home_dir() - .unwrap() - .join(".sp1") - .join("circuits") - .join("plonk_bn254") - .join(SP1_CIRCUIT_VERSION) -} - /// Gets the directory where the PLONK artifacts are installed in development mode. pub fn plonk_bn254_artifacts_dev_dir() -> PathBuf { dirs::home_dir() @@ -117,10 +88,12 @@ pub fn build_constraints_and_witness( /// Generate a dummy proof that we can use to build the circuit. We need this to know the shape of /// the proof. pub fn dummy_proof() -> (StarkVerifyingKey, ShardProof) { - let elf = include_bytes!("../../examples/fibonacci/program/elf/riscv32im-succinct-zkvm-elf"); + let elf = include_bytes!("../elf/riscv32im-succinct-zkvm-elf"); tracing::info!("initializing prover"); - let prover = SP1Prover::new(); + let prover: SP1Prover = SP1Prover::new(); + let opts = SP1ProverOpts::default(); + let context = SP1Context::default(); tracing::info!("setup elf"); let (pk, vk) = prover.setup(elf); @@ -128,16 +101,16 @@ pub fn dummy_proof() -> (StarkVerifyingKey, ShardProof) { tracing::info!("prove core"); let mut stdin = SP1Stdin::new(); stdin.write(&500u32); - let core_proof = prover.prove_core(&pk, &stdin).unwrap(); + let core_proof = prover.prove_core(&pk, &stdin, opts, context).unwrap(); tracing::info!("compress"); - let compressed_proof = prover.compress(&vk, core_proof, vec![]).unwrap(); + let compressed_proof = prover.compress(&vk, core_proof, vec![], opts).unwrap(); tracing::info!("shrink"); - let shrink_proof = prover.shrink(compressed_proof).unwrap(); + let shrink_proof = prover.shrink(compressed_proof, opts).unwrap(); tracing::info!("wrap"); - let wrapped_proof = prover.wrap_bn254(shrink_proof).unwrap(); + let wrapped_proof = prover.wrap_bn254(shrink_proof, opts).unwrap(); (prover.wrap_vk, wrapped_proof.proof) } diff --git a/prover/src/components.rs b/prover/src/components.rs new file mode 100644 index 0000000000..407cfa873b --- /dev/null +++ b/prover/src/components.rs @@ -0,0 +1,34 @@ +use sp1_core::stark::{DefaultProver, MachineProver, RiscvAir, StarkGenericConfig}; + +use crate::{CompressAir, CoreSC, InnerSC, OuterSC, ReduceAir, WrapAir}; + +pub trait SP1ProverComponents: Send + Sync { + /// The prover for making SP1 core proofs. + type CoreProver: MachineProver::Val>> + + Send + + Sync; + + /// The prover for making SP1 recursive proofs. + type CompressProver: MachineProver::Val>> + + Send + + Sync; + + /// The prover for shrinking compressed proofs. + type ShrinkProver: MachineProver::Val>> + + Send + + Sync; + + /// The prover for wrapping compressed proofs into SNARK-friendly field elements. + type WrapProver: MachineProver::Val>> + + Send + + Sync; +} + +pub struct DefaultProverComponents; + +impl SP1ProverComponents for DefaultProverComponents { + type CoreProver = DefaultProver::Val>>; + type CompressProver = DefaultProver::Val>>; + type ShrinkProver = DefaultProver::Val>>; + type WrapProver = DefaultProver::Val>>; +} diff --git a/prover/src/lib.rs b/prover/src/lib.rs index 5df8e7058e..efd218f860 100644 --- a/prover/src/lib.rs +++ b/prover/src/lib.rs @@ -9,9 +9,10 @@ #![allow(clippy::too_many_arguments)] #![allow(clippy::new_without_default)] +#![allow(clippy::collapsible_else_if)] pub mod build; -pub mod install; +pub mod components; pub mod types; pub mod utils; pub mod verify; @@ -20,6 +21,7 @@ use std::borrow::Borrow; use std::path::Path; use std::sync::Arc; +use components::{DefaultProverComponents, SP1ProverComponents}; use p3_baby_bear::BabyBear; use p3_challenger::CanObserve; use p3_field::{AbstractField, PrimeField}; @@ -27,18 +29,18 @@ use rayon::iter::{IntoParallelIterator, ParallelIterator}; use rayon::prelude::*; use sp1_core::air::{PublicValues, Word}; pub use sp1_core::io::{SP1PublicValues, SP1Stdin}; -use sp1_core::runtime::{ExecutionError, ExecutionReport, Runtime}; +use sp1_core::runtime::{ExecutionError, ExecutionReport, Runtime, SP1Context}; +use sp1_core::stark::MachineProver; use sp1_core::stark::{Challenge, StarkProvingKey}; use sp1_core::stark::{Challenger, MachineVerificationError}; -use sp1_core::utils::{SP1CoreOpts, DIGEST_SIZE}; +use sp1_core::utils::{SP1CoreOpts, SP1ProverOpts, DIGEST_SIZE}; use sp1_core::{ runtime::Program, - stark::{ - LocalProver, RiscvAir, ShardProof, StarkGenericConfig, StarkMachine, StarkVerifyingKey, Val, - }, + stark::{RiscvAir, ShardProof, StarkGenericConfig, StarkVerifyingKey, Val}, utils::{BabyBearPoseidon2, SP1CoreProverError}, }; use sp1_primitives::hash_deferred_proof; +use sp1_primitives::types::RecursionProgramType; use sp1_recursion_circuit::witness::Witnessable; use sp1_recursion_compiler::config::InnerConfig; use sp1_recursion_compiler::ir::Witness; @@ -74,14 +76,14 @@ pub type OuterSC = BabyBearPoseidon2Outer; const REDUCE_DEGREE: usize = 3; const COMPRESS_DEGREE: usize = 9; -const WRAP_DEGREE: usize = 9; +const WRAP_DEGREE: usize = 17; pub type ReduceAir = RecursionAir; pub type CompressAir = RecursionAir; pub type WrapAir = RecursionAir; /// A end-to-end prover implementation for the SP1 RISC-V zkVM. -pub struct SP1Prover { +pub struct SP1Prover { /// The program that can recursively verify a set of proofs into a single proof. pub recursion_program: RecursionProgram, @@ -128,58 +130,64 @@ pub struct SP1Prover { pub wrap_vk: StarkVerifyingKey, /// The machine used for proving the core step. - pub core_machine: StarkMachine::Val>>, + pub core_prover: C::CoreProver, /// The machine used for proving the recursive and reduction steps. - pub compress_machine: StarkMachine::Val>>, + pub compress_prover: C::CompressProver, /// The machine used for proving the shrink step. - pub shrink_machine: StarkMachine::Val>>, + pub shrink_prover: C::ShrinkProver, /// The machine used for proving the wrapping step. - pub wrap_machine: StarkMachine::Val>>, - - /// The options for the core prover. - pub core_opts: SP1CoreOpts, - - /// The options for the recursion prover. - pub recursion_opts: SP1CoreOpts, + pub wrap_prover: C::WrapProver, } -impl SP1Prover { +impl SP1Prover { /// Initializes a new [SP1Prover]. #[instrument(name = "initialize prover", level = "debug", skip_all)] pub fn new() -> Self { let core_machine = RiscvAir::machine(CoreSC::default()); + let core_prover = C::CoreProver::new(core_machine); // Get the recursive verifier and setup the proving and verifying keys. - let recursion_program = SP1RecursiveVerifier::::build(&core_machine); + let recursion_program = + SP1RecursiveVerifier::::build(core_prover.machine()); let compress_machine = ReduceAir::machine(InnerSC::default()); - let (rec_pk, rec_vk) = compress_machine.setup(&recursion_program); + let compress_prover = C::CompressProver::new(compress_machine); + let (rec_pk, rec_vk) = compress_prover.setup(&recursion_program); // Get the deferred program and keys. - let deferred_program = SP1DeferredVerifier::::build(&compress_machine); - let (deferred_pk, deferred_vk) = compress_machine.setup(&deferred_program); + let deferred_program = + SP1DeferredVerifier::::build(compress_prover.machine()); + let (deferred_pk, deferred_vk) = compress_prover.setup(&deferred_program); // Make the reduce program and keys. let compress_program = SP1CompressVerifier::::build( - &compress_machine, + compress_prover.machine(), &rec_vk, &deferred_vk, ); - let (compress_pk, compress_vk) = compress_machine.setup(&compress_program); + let (compress_pk, compress_vk) = compress_prover.setup(&compress_program); // Get the compress program, machine, and keys. - let shrink_program = - SP1RootVerifier::::build(&compress_machine, &compress_vk, true); + let shrink_program = SP1RootVerifier::::build( + compress_prover.machine(), + &compress_vk, + RecursionProgramType::Shrink, + ); let shrink_machine = CompressAir::wrap_machine_dyn(InnerSC::compressed()); - let (shrink_pk, shrink_vk) = shrink_machine.setup(&shrink_program); + let shrink_prover = C::ShrinkProver::new(shrink_machine); + let (shrink_pk, shrink_vk) = shrink_prover.setup(&shrink_program); // Get the wrap program, machine, and keys. - let wrap_program = - SP1RootVerifier::::build(&shrink_machine, &shrink_vk, false); + let wrap_program = SP1RootVerifier::::build( + shrink_prover.machine(), + &shrink_vk, + RecursionProgramType::Wrap, + ); let wrap_machine = WrapAir::wrap_machine(OuterSC::default()); - let (wrap_pk, wrap_vk) = wrap_machine.setup(&wrap_program); + let wrap_prover = C::WrapProver::new(wrap_machine); + let (wrap_pk, wrap_vk) = wrap_prover.setup(&wrap_program); Self { recursion_program, @@ -197,12 +205,10 @@ impl SP1Prover { wrap_program, wrap_pk, wrap_vk, - core_machine, - compress_machine, - shrink_machine, - wrap_machine, - core_opts: SP1CoreOpts::default(), - recursion_opts: SP1CoreOpts::recursion(), + core_prover, + compress_prover, + shrink_prover, + wrap_prover, } } @@ -210,7 +216,7 @@ impl SP1Prover { #[instrument(name = "setup", level = "debug", skip_all)] pub fn setup(&self, elf: &[u8]) -> (SP1ProvingKey, SP1VerifyingKey) { let program = Program::from(elf); - let (pk, vk) = self.core_machine.setup(&program); + let (pk, vk) = self.core_prover.setup(&program); let vk = SP1VerifyingKey { vk }; let pk = SP1ProvingKey { pk, @@ -225,10 +231,11 @@ impl SP1Prover { pub fn execute( elf: &[u8], stdin: &SP1Stdin, + context: SP1Context, ) -> Result<(SP1PublicValues, ExecutionReport), ExecutionError> { let program = Program::from(elf); let opts = SP1CoreOpts::default(); - let mut runtime = Runtime::new(program, opts); + let mut runtime = Runtime::with_context(program, opts, context); runtime.write_vecs(&stdin.buffer); for (proof, vkey) in stdin.proofs.iter() { runtime.write_proof(proof.clone(), vkey.clone()); @@ -241,27 +248,34 @@ impl SP1Prover { } /// Generate shard proofs which split up and prove the valid execution of a RISC-V program with - /// the core prover. + /// the core prover. Uses the provided context. #[instrument(name = "prove_core", level = "info", skip_all)] - pub fn prove_core( - &self, + pub fn prove_core<'a>( + &'a self, pk: &SP1ProvingKey, stdin: &SP1Stdin, + opts: SP1ProverOpts, + mut context: SP1Context<'a>, ) -> Result { - let config = CoreSC::default(); + context + .subproof_verifier + .get_or_insert_with(|| Arc::new(self)); let program = Program::from(&pk.elf); - let (proof, public_values_stream) = sp1_core::utils::prove_with_subproof_verifier( - program, - stdin, - config, - self.core_opts, - Some(Arc::new(self)), - )?; + let (proof, public_values_stream, cycles) = + sp1_core::utils::prove_with_context::<_, C::CoreProver>( + &self.core_prover, + program, + stdin, + opts.core_opts, + context, + )?; + Self::check_for_high_cycles(cycles); let public_values = SP1PublicValues::from(&public_values_stream); Ok(SP1CoreProof { proof: SP1CoreProofData(proof.shard_proofs), stdin: stdin.clone(), public_values, + cycles, }) } @@ -274,7 +288,7 @@ impl SP1Prover { is_complete: bool, ) -> Vec>> { let mut core_inputs = Vec::new(); - let mut reconstruct_challenger = self.core_machine.config().challenger(); + let mut reconstruct_challenger = self.core_prover.config().challenger(); vk.observe_into(&mut reconstruct_challenger); // Prepare the inputs for the recursion programs. @@ -283,18 +297,17 @@ impl SP1Prover { core_inputs.push(SP1RecursionMemoryLayout { vk, - machine: &self.core_machine, - shard_proofs: proofs, + machine: self.core_prover.machine(), + shard_proofs: proofs.clone(), leaf_challenger, initial_reconstruct_challenger: reconstruct_challenger.clone(), is_complete, - total_core_shards: shard_proofs.len(), }); for proof in batch.iter() { reconstruct_challenger.observe(proof.commitment.main_commit); reconstruct_challenger - .observe_slice(&proof.public_values[0..self.core_machine.num_pv_elts()]); + .observe_slice(&proof.public_values[0..self.core_prover.num_pv_elts()]); } } @@ -321,7 +334,6 @@ impl SP1Prover { last_proof_pv: &PublicValues, BabyBear>, deferred_proofs: &[ShardProof], batch_size: usize, - total_core_shards: usize, ) -> Vec>> { // Prepare the inputs for the deferred proofs recursive verification. let mut deferred_digest = [Val::::zero(); DIGEST_SIZE]; @@ -332,18 +344,20 @@ impl SP1Prover { deferred_inputs.push(SP1DeferredMemoryLayout { compress_vk: &self.compress_vk, - machine: &self.compress_machine, + machine: self.compress_prover.machine(), proofs, start_reconstruct_deferred_digest: deferred_digest.to_vec(), is_complete: false, sp1_vk: vk, - sp1_machine: &self.core_machine, + sp1_machine: self.core_prover.machine(), end_pc: Val::::zero(), end_shard: last_proof_pv.shard + BabyBear::one(), + end_execution_shard: last_proof_pv.execution_shard, + init_addr_bits: last_proof_pv.last_init_addr_bits, + finalize_addr_bits: last_proof_pv.last_finalize_addr_bits, leaf_challenger: leaf_challenger.clone(), committed_value_digest: last_proof_pv.committed_value_digest.to_vec(), deferred_proofs_digest: last_proof_pv.deferred_proofs_digest.to_vec(), - total_core_shards, }); deferred_digest = Self::hash_deferred_proofs(deferred_digest, batch); @@ -372,15 +386,18 @@ impl SP1Prover { batch_size, is_complete, ); - let last_proof_pv = - PublicValues::from_vec(shard_proofs.last().unwrap().public_values.clone()); + let last_proof_pv = shard_proofs + .last() + .unwrap() + .public_values + .as_slice() + .borrow(); let deferred_inputs = self.get_recursion_deferred_inputs( &vk.vk, leaf_challenger, - &last_proof_pv, + last_proof_pv, deferred_proofs, batch_size, - shard_proofs.len(), ); (core_inputs, deferred_inputs) } @@ -392,18 +409,19 @@ impl SP1Prover { vk: &SP1VerifyingKey, proof: SP1CoreProof, deferred_proofs: Vec>, + opts: SP1ProverOpts, ) -> Result, SP1RecursionProverError> { // Set the batch size for the reduction tree. let batch_size = 2; let shard_proofs = &proof.proof.0; - let total_core_shards = shard_proofs.len(); + // Get the leaf challenger. - let mut leaf_challenger = self.core_machine.config().challenger(); + let mut leaf_challenger = self.core_prover.config().challenger(); vk.vk.observe_into(&mut leaf_challenger); shard_proofs.iter().for_each(|proof| { leaf_challenger.observe(proof.commitment.main_commit); - leaf_challenger.observe_slice(&proof.public_values[0..self.core_machine.num_pv_elts()]); + leaf_challenger.observe_slice(&proof.public_values[0..self.core_prover.num_pv_elts()]); }); // Run the recursion and reduce programs. @@ -416,17 +434,15 @@ impl SP1Prover { ); let mut reduce_proofs = Vec::new(); - let opts = self.recursion_opts; - let shard_batch_size = opts.shard_batch_size; + let shard_batch_size = opts.recursion_opts.shard_batch_size; for inputs in core_inputs.chunks(shard_batch_size) { let proofs = inputs .into_par_iter() .map(|input| { - let proof = - self.compress_machine_proof(input, &self.recursion_program, &self.rec_pk); - (proof, ReduceProgramType::Core) + self.compress_machine_proof(input, &self.recursion_program, &self.rec_pk, opts) + .map(|p| (p, ReduceProgramType::Core)) }) - .collect::>(); + .collect::, _>>()?; reduce_proofs.extend(proofs); } @@ -435,14 +451,15 @@ impl SP1Prover { let proofs = inputs .into_par_iter() .map(|input| { - let proof = self.compress_machine_proof( + self.compress_machine_proof( input, &self.deferred_program, &self.deferred_pk, - ); - (proof, ReduceProgramType::Deferred) + opts, + ) + .map(|p| (p, ReduceProgramType::Deferred)) }) - .collect::>(); + .collect::, _>>()?; reduce_proofs.extend(proofs); } @@ -456,7 +473,7 @@ impl SP1Prover { let batched_compress_inputs = compress_inputs.chunks(shard_batch_size).collect::>(); reduce_proofs = batched_compress_inputs - .into_iter() + .into_par_iter() .flat_map(|batches| { batches .par_iter() @@ -466,23 +483,23 @@ impl SP1Prover { let input = SP1ReduceMemoryLayout { compress_vk: &self.compress_vk, - recursive_machine: &self.compress_machine, + recursive_machine: self.compress_prover.machine(), shard_proofs, kinds, is_complete, - total_core_shards, }; - let proof = self.compress_machine_proof( + self.compress_machine_proof( input, &self.compress_program, &self.compress_pk, - ); - (proof, ReduceProgramType::Reduce) + opts, + ) + .map(|p| (p, ReduceProgramType::Reduce)) }) .collect::>() }) - .collect::>(); + .collect::, _>>()?; if reduce_proofs.len() == 1 { break; @@ -496,31 +513,43 @@ impl SP1Prover { }) } + /// Generate a proof with the compress machine. pub fn compress_machine_proof( &self, input: impl Hintable, program: &RecursionProgram, pk: &StarkProvingKey, - ) -> ShardProof { + opts: SP1ProverOpts, + ) -> Result, SP1RecursionProverError> { let mut runtime = RecursionRuntime::, Challenge, _>::new( program, - self.compress_machine.config().perm.clone(), + self.compress_prover.config().perm.clone(), ); let mut witness_stream = Vec::new(); witness_stream.extend(input.write()); runtime.witness_stream = witness_stream.into(); - runtime.run(); + runtime + .run() + .map_err(|e| SP1RecursionProverError::RuntimeError(e.to_string()))?; runtime.print_stats(); - let opts = self.recursion_opts; - let mut recursive_challenger = self.compress_machine.config().challenger(); - self.compress_machine - .prove::>(pk, runtime.record, &mut recursive_challenger, opts) + let mut recursive_challenger = self.compress_prover.config().challenger(); + let proof = self + .compress_prover + .prove( + pk, + vec![runtime.record], + &mut recursive_challenger, + opts.recursion_opts, + ) + .unwrap() .shard_proofs .pop() - .unwrap() + .unwrap(); + + Ok(proof) } /// Wrap a reduce proof into a STARK proven over a SNARK-friendly field. @@ -528,10 +557,11 @@ impl SP1Prover { pub fn shrink( &self, reduced_proof: SP1ReduceProof, + opts: SP1ProverOpts, ) -> Result, SP1RecursionProverError> { // Make the compress proof. let input = SP1RootMemoryLayout { - machine: &self.compress_machine, + machine: self.compress_prover.machine(), proof: reduced_proof.proof, is_reduce: true, }; @@ -539,26 +569,32 @@ impl SP1Prover { // Run the compress program. let mut runtime = RecursionRuntime::, Challenge, _>::new( &self.shrink_program, - self.shrink_machine.config().perm.clone(), + self.shrink_prover.config().perm.clone(), ); let mut witness_stream = Vec::new(); witness_stream.extend(input.write()); runtime.witness_stream = witness_stream.into(); - runtime.run(); + + runtime + .run() + .map_err(|e| SP1RecursionProverError::RuntimeError(e.to_string()))?; + runtime.print_stats(); tracing::debug!("Compress program executed successfully"); // Prove the compress program. - let opts = self.recursion_opts; - let mut compress_challenger = self.shrink_machine.config().challenger(); - let mut compress_proof = self.shrink_machine.prove::>( - &self.shrink_pk, - runtime.record, - &mut compress_challenger, - opts, - ); + let mut compress_challenger = self.shrink_prover.config().challenger(); + let mut compress_proof = self + .shrink_prover + .prove( + &self.shrink_pk, + vec![runtime.record], + &mut compress_challenger, + opts.recursion_opts, + ) + .unwrap(); Ok(SP1ReduceProof { proof: compress_proof.shard_proofs.pop().unwrap(), @@ -570,9 +606,10 @@ impl SP1Prover { pub fn wrap_bn254( &self, compressed_proof: SP1ReduceProof, + opts: SP1ProverOpts, ) -> Result, SP1RecursionProverError> { let input = SP1RootMemoryLayout { - machine: &self.shrink_machine, + machine: self.shrink_prover.machine(), proof: compressed_proof.proof, is_reduce: false, }; @@ -580,33 +617,40 @@ impl SP1Prover { // Run the compress program. let mut runtime = RecursionRuntime::, Challenge, _>::new( &self.wrap_program, - self.shrink_machine.config().perm.clone(), + self.shrink_prover.config().perm.clone(), ); let mut witness_stream = Vec::new(); witness_stream.extend(input.write()); runtime.witness_stream = witness_stream.into(); - runtime.run(); + + runtime + .run() + .map_err(|e| SP1RecursionProverError::RuntimeError(e.to_string()))?; + runtime.print_stats(); tracing::debug!("Wrap program executed successfully"); // Prove the wrap program. - let opts = self.recursion_opts; - let mut wrap_challenger = self.wrap_machine.config().challenger(); + let mut wrap_challenger = self.wrap_prover.config().challenger(); let time = std::time::Instant::now(); - let mut wrap_proof = self.wrap_machine.prove::>( - &self.wrap_pk, - runtime.record, - &mut wrap_challenger, - opts, - ); + let mut wrap_proof = self + .wrap_prover + .prove( + &self.wrap_pk, + vec![runtime.record], + &mut wrap_challenger, + opts.recursion_opts, + ) + .unwrap(); let elapsed = time.elapsed(); tracing::debug!("Wrap proving time: {:?}", elapsed); - let mut wrap_challenger = self.wrap_machine.config().challenger(); - let result = self - .wrap_machine - .verify(&self.wrap_vk, &wrap_proof, &mut wrap_challenger); + let mut wrap_challenger = self.wrap_prover.config().challenger(); + let result = + self.wrap_prover + .machine() + .verify(&self.wrap_vk, &wrap_proof, &mut wrap_challenger); match result { Ok(_) => tracing::info!("Proof verified successfully"), Err(MachineVerificationError::NonZeroCumulativeSum) => { @@ -667,10 +711,18 @@ impl SP1Prover { } digest } + + fn check_for_high_cycles(cycles: u64) { + if cycles > 100_000_000 { + tracing::warn!( + "high cycle count, consider using the prover network for proof generation: https://docs.succinct.xyz/prover-network/setup.html" + ); + } + } } -#[cfg(test)] -mod tests { +#[cfg(any(test, feature = "export-tests"))] +pub mod tests { use std::fs::File; use std::io::{Read, Write}; @@ -680,51 +732,68 @@ mod tests { use anyhow::Result; use build::try_build_plonk_bn254_artifacts_dev; use p3_field::PrimeField32; - use serial_test::serial; use sp1_core::io::SP1Stdin; + + #[cfg(test)] + use serial_test::serial; + #[cfg(test)] use sp1_core::utils::setup_logger; - /// Tests an end-to-end workflow of proving a program across the entire proof generation - /// pipeline. - /// - /// Add `FRI_QUERIES`=1 to your environment for faster execution. Should only take a few minutes - /// on a Mac M2. Note: This test always re-builds the plonk bn254 artifacts, so setting SP1_DEV is - /// not needed. - #[test] - #[serial] - fn test_e2e() -> Result<()> { - setup_logger(); - let elf = include_bytes!("../../tests/fibonacci/elf/riscv32im-succinct-zkvm-elf"); + #[derive(Debug, Clone, Copy, PartialEq, Eq)] + pub enum Test { + Core, + Compress, + Shrink, + Wrap, + Plonk, + } + pub fn test_e2e_prover( + elf: &[u8], + opts: SP1ProverOpts, + test_kind: Test, + ) -> Result<()> { tracing::info!("initializing prover"); - let mut prover = SP1Prover::new(); - prover.core_opts.shard_size = 1 << 12; + let prover: SP1Prover = SP1Prover::::new(); + let context = SP1Context::default(); tracing::info!("setup elf"); let (pk, vk) = prover.setup(elf); tracing::info!("prove core"); let stdin = SP1Stdin::new(); - let core_proof = prover.prove_core(&pk, &stdin)?; + let core_proof = prover.prove_core(&pk, &stdin, opts, context)?; let public_values = core_proof.public_values.clone(); tracing::info!("verify core"); prover.verify(&core_proof.proof, &vk)?; + if test_kind == Test::Core { + return Ok(()); + } + tracing::info!("compress"); - let compressed_proof = prover.compress(&vk, core_proof, vec![])?; + let compressed_proof = prover.compress(&vk, core_proof, vec![], opts)?; tracing::info!("verify compressed"); prover.verify_compressed(&compressed_proof, &vk)?; + if test_kind == Test::Compress { + return Ok(()); + } + tracing::info!("shrink"); - let shrink_proof = prover.shrink(compressed_proof)?; + let shrink_proof = prover.shrink(compressed_proof, opts)?; tracing::info!("verify shrink"); prover.verify_shrink(&shrink_proof, &vk)?; + if test_kind == Test::Shrink { + return Ok(()); + } + tracing::info!("wrap bn254"); - let wrapped_bn254_proof = prover.wrap_bn254(shrink_proof)?; + let wrapped_bn254_proof = prover.wrap_bn254(shrink_proof, opts)?; let bytes = bincode::serialize(&wrapped_bn254_proof).unwrap(); // Save the proof. @@ -741,6 +810,10 @@ mod tests { tracing::info!("verify wrap bn254"); prover.verify_wrap_bn254(&wrapped_bn254_proof, &vk).unwrap(); + if test_kind == Test::Wrap { + return Ok(()); + } + tracing::info!("checking vkey hash babybear"); let vk_digest_babybear = wrapped_bn254_proof.sp1_vkey_digest_babybear(); assert_eq!(vk_digest_babybear, vk.hash_babybear()); @@ -760,13 +833,7 @@ mod tests { Ok(()) } - /// Tests an end-to-end workflow of proving a program across the entire proof generation - /// pipeline in addition to verifying deferred proofs. - #[test] - #[serial] - fn test_e2e_with_deferred_proofs() -> Result<()> { - setup_logger(); - + pub fn test_e2e_with_deferred_proofs_prover() -> Result<()> { // Test program which proves the Keccak-256 hash of various inputs. let keccak_elf = include_bytes!("../../tests/keccak256/elf/riscv32im-succinct-zkvm-elf"); @@ -774,7 +841,8 @@ mod tests { let verify_elf = include_bytes!("../../tests/verify-proof/elf/riscv32im-succinct-zkvm-elf"); tracing::info!("initializing prover"); - let prover = SP1Prover::new(); + let prover: SP1Prover = SP1Prover::new(); + let opts = SP1ProverOpts::default(); tracing::info!("setup keccak elf"); let (keccak_pk, keccak_vk) = prover.setup(keccak_elf); @@ -786,7 +854,7 @@ mod tests { let mut stdin = SP1Stdin::new(); stdin.write(&1usize); stdin.write(&vec![0u8, 0, 0]); - let deferred_proof_1 = prover.prove_core(&keccak_pk, &stdin)?; + let deferred_proof_1 = prover.prove_core(&keccak_pk, &stdin, opts, Default::default())?; let pv_1 = deferred_proof_1.public_values.as_slice().to_vec().clone(); // Generate a second proof of keccak of various inputs. @@ -796,16 +864,16 @@ mod tests { stdin.write(&vec![0u8, 1, 2]); stdin.write(&vec![2, 3, 4]); stdin.write(&vec![5, 6, 7]); - let deferred_proof_2 = prover.prove_core(&keccak_pk, &stdin)?; + let deferred_proof_2 = prover.prove_core(&keccak_pk, &stdin, opts, Default::default())?; let pv_2 = deferred_proof_2.public_values.as_slice().to_vec().clone(); // Generate recursive proof of first subproof. tracing::info!("compress subproof 1"); - let deferred_reduce_1 = prover.compress(&keccak_vk, deferred_proof_1, vec![])?; + let deferred_reduce_1 = prover.compress(&keccak_vk, deferred_proof_1, vec![], opts)?; // Generate recursive proof of second subproof. tracing::info!("compress subproof 2"); - let deferred_reduce_2 = prover.compress(&keccak_vk, deferred_proof_2, vec![])?; + let deferred_reduce_2 = prover.compress(&keccak_vk, deferred_proof_2, vec![], opts)?; // Run verify program with keccak vkey, subproofs, and their committed values. let mut stdin = SP1Stdin::new(); @@ -823,7 +891,7 @@ mod tests { stdin.write_proof(deferred_reduce_2.proof.clone(), keccak_vk.vk.clone()); tracing::info!("proving verify program (core)"); - let verify_proof = prover.prove_core(&verify_pk, &stdin)?; + let verify_proof = prover.prove_core(&verify_pk, &stdin, opts, Default::default())?; // Generate recursive proof of verify program tracing::info!("compress verify program"); @@ -835,6 +903,7 @@ mod tests { deferred_reduce_2.proof.clone(), deferred_reduce_2.proof, ], + opts, )?; let reduce_pv: &RecursionPublicValues<_> = verify_reduce.proof.public_values.as_slice().borrow(); @@ -846,4 +915,28 @@ mod tests { Ok(()) } + + /// Tests an end-to-end workflow of proving a program across the entire proof generation + /// pipeline. + /// + /// Add `FRI_QUERIES`=1 to your environment for faster execution. Should only take a few minutes + /// on a Mac M2. Note: This test always re-builds the plonk bn254 artifacts, so setting SP1_DEV is + /// not needed. + #[test] + #[serial] + fn test_e2e() -> Result<()> { + let elf = include_bytes!("../../tests/fibonacci/elf/riscv32im-succinct-zkvm-elf"); + setup_logger(); + let opts = SP1ProverOpts::default(); + test_e2e_prover::(elf, opts, Test::Plonk) + } + + /// Tests an end-to-end workflow of proving a program across the entire proof generation + /// pipeline in addition to verifying deferred proofs. + #[test] + #[serial] + fn test_e2e_with_deferred_proofs() -> Result<()> { + setup_logger(); + test_e2e_with_deferred_proofs_prover::() + } } diff --git a/prover/src/types.rs b/prover/src/types.rs index d00f021e63..036c94b37a 100644 --- a/prover/src/types.rs +++ b/prover/src/types.rs @@ -114,6 +114,7 @@ pub struct SP1ProofWithMetadata { pub proof: P, pub stdin: SP1Stdin, pub public_values: SP1PublicValues, + pub cycles: u64, } impl SP1ProofWithMetadata

{ @@ -198,4 +199,7 @@ pub enum SP1ReduceProofWrapper { } #[derive(Error, Debug)] -pub enum SP1RecursionProverError {} +pub enum SP1RecursionProverError { + #[error("Runtime error: {0}")] + RuntimeError(String), +} diff --git a/prover/src/utils.rs b/prover/src/utils.rs index 653017b3e2..34dee12712 100644 --- a/prover/src/utils.rs +++ b/prover/src/utils.rs @@ -3,7 +3,6 @@ use std::{ io::Read, }; -use futures::Future; use p3_baby_bear::BabyBear; use p3_bn254_fr::Bn254Fr; use p3_field::AbstractField; @@ -14,7 +13,6 @@ use sp1_core::{ runtime::{Program, Runtime}, utils::SP1CoreOpts, }; -use tokio::{runtime, task::block_in_place}; use crate::SP1CoreProofData; @@ -85,16 +83,3 @@ pub fn words_to_bytes_be(words: &[u32; 8]) -> [u8; 32] { } bytes } - -/// Utility method for blocking on an async function. If we're already in a tokio runtime, we'll -/// block in place. Otherwise, we'll create a new runtime. -pub fn block_on(fut: impl Future) -> T { - // Handle case if we're already in an tokio runtime. - if let Ok(handle) = runtime::Handle::try_current() { - block_in_place(|| handle.block_on(fut)) - } else { - // Otherwise create a new runtime. - let rt = runtime::Runtime::new().expect("Failed to create a new runtime"); - rt.block_on(fut) - } -} diff --git a/prover/src/verify.rs b/prover/src/verify.rs index 3e7ef1c645..5b1554144e 100644 --- a/prover/src/verify.rs +++ b/prover/src/verify.rs @@ -4,8 +4,10 @@ use anyhow::Result; use num_bigint::BigUint; use p3_baby_bear::BabyBear; use p3_field::{AbstractField, PrimeField}; -use sp1_core::air::MachineAir; +use sp1_core::air::{Word, POSEIDON_NUM_WORDS, PV_DIGEST_NUM_WORDS, WORD_SIZE}; +use sp1_core::cpu::MAX_CPU_LOG_DEGREE; use sp1_core::runtime::SubproofVerifier; +use sp1_core::stark::MachineProver; use sp1_core::{ air::PublicValues, io::SP1PublicValues, @@ -16,6 +18,7 @@ use sp1_recursion_core::{air::RecursionPublicValues, stark::config::BabyBearPose use sp1_recursion_gnark_ffi::{PlonkBn254Proof, PlonkBn254Prover}; use thiserror::Error; +use crate::components::SP1ProverComponents; use crate::{ CoreSC, HashableKey, OuterSC, SP1CoreProofData, SP1Prover, SP1ReduceProof, SP1VerifyingKey, }; @@ -32,7 +35,7 @@ pub enum PlonkVerificationError { InvalidPublicValues, } -impl SP1Prover { +impl SP1Prover { /// Verify a core proof by verifying the shards, verifying lookup bus, verifying that the /// shards are contiguous and complete. pub fn verify( @@ -40,105 +43,232 @@ impl SP1Prover { proof: &SP1CoreProofData, vk: &SP1VerifyingKey, ) -> Result<(), MachineVerificationError> { - let mut challenger = self.core_machine.config().challenger(); - let machine_proof = MachineProof { - shard_proofs: proof.0.to_vec(), - }; - self.core_machine - .verify(&vk.vk, &machine_proof, &mut challenger)?; - - let num_shards = proof.0.len(); + // First shard has a "CPU" constraint. + // + // Assert that the first shard has a "CPU". + let first_shard = proof.0.first().unwrap(); + if !first_shard.contains_cpu() { + return Err(MachineVerificationError::MissingCpuInFirstShard); + } - // Verify shard transitions. - for (i, shard_proof) in proof.0.iter().enumerate() { - let public_values = PublicValues::from_vec(shard_proof.public_values.clone()); - // Verify shard transitions - if i == 0 { - // If it's the first shard, index should be 1. - if public_values.shard != BabyBear::one() { - return Err(MachineVerificationError::InvalidPublicValues( - "first shard not 1", - )); - } - if public_values.start_pc != vk.vk.pc_start { - return Err(MachineVerificationError::InvalidPublicValues( - "wrong pc_start", - )); - } - } else { - let prev_shard_proof = &proof.0[i - 1]; - let prev_public_values = - PublicValues::from_vec(prev_shard_proof.public_values.clone()); - // For non-first shards, the index should be the previous index + 1. - if public_values.shard != prev_public_values.shard + BabyBear::one() { - return Err(MachineVerificationError::InvalidPublicValues( - "non incremental shard index", - )); - } - // Start pc should be what the next pc declared in the previous shard was. - if public_values.start_pc != prev_public_values.next_pc { - return Err(MachineVerificationError::InvalidPublicValues("pc mismatch")); - } - // Digests and exit code should be the same in all shards. - if public_values.committed_value_digest != prev_public_values.committed_value_digest - || public_values.deferred_proofs_digest - != prev_public_values.deferred_proofs_digest - || public_values.exit_code != prev_public_values.exit_code - { - return Err(MachineVerificationError::InvalidPublicValues( - "digest or exit code mismatch", + // CPU log degree bound constraints. + // + // Assert that the CPU log degree does not exceed `MAX_CPU_LOG_DEGREE`. This is to ensure + // that the lookup argument's multiplicities do not overflow. + for shard_proof in proof.0.iter() { + if shard_proof.contains_cpu() { + let log_degree_cpu = shard_proof.log_degree_cpu(); + if log_degree_cpu > MAX_CPU_LOG_DEGREE { + return Err(MachineVerificationError::CpuLogDegreeTooLarge( + log_degree_cpu, )); } - // The last shard should be halted. Halt is signaled with next_pc == 0. - if i == proof.0.len() - 1 && public_values.next_pc != BabyBear::zero() { - return Err(MachineVerificationError::InvalidPublicValues( - "last shard isn't halted", - )); - } - // All non-last shards should not be halted. - if i != proof.0.len() - 1 && public_values.next_pc == BabyBear::zero() { + } + } + + // Shard constraints. + // + // Initialization: + // - Shard should start at one. + // + // Transition: + // - Shard should increment by one for each shard. + let mut current_shard = BabyBear::zero(); + for shard_proof in proof.0.iter() { + let public_values: &PublicValues, _> = + shard_proof.public_values.as_slice().borrow(); + current_shard += BabyBear::one(); + if public_values.shard != current_shard { + return Err(MachineVerificationError::InvalidPublicValues( + "shard index should be the previous shard index + 1 and start at 1", + )); + } + } + + // Execution shard constraints. + // + // Initialization: + // - Execution shard should start at one. + // + // Transition: + // - Execution shard should increment by one for each shard with "CPU". + // - Execution shard should stay the same for non-CPU shards. + // - For the other shards, execution shard does not matter. + let mut current_execution_shard = BabyBear::zero(); + for shard_proof in proof.0.iter() { + let public_values: &PublicValues, _> = + shard_proof.public_values.as_slice().borrow(); + if shard_proof.contains_cpu() { + current_execution_shard += BabyBear::one(); + if public_values.execution_shard != current_execution_shard { return Err(MachineVerificationError::InvalidPublicValues( - "non-last shard is halted", + "execution shard index should be the previous execution shard index + 1 if cpu exists and start at 1", )); } } } - // Verify that the number of shards is not too large. - if proof.0.len() > 1 << 16 { - return Err(MachineVerificationError::TooManyShards); + // Program counter constraints. + // + // Initialization: + // - `start_pc` should start as `vk.start_pc`. + // + // Transition: + // - `next_pc` of the previous shard should equal `start_pc`. + // - If it's not a shard with "CPU", then `start_pc` equals `next_pc`. + // - If it's a shard with "CPU", then `start_pc` should never equal zero. + // + // Finalization: + // - `next_pc` should equal zero. + let mut prev_next_pc = BabyBear::zero(); + for (i, shard_proof) in proof.0.iter().enumerate() { + let public_values: &PublicValues, _> = + shard_proof.public_values.as_slice().borrow(); + if i == 0 && public_values.start_pc != vk.vk.pc_start { + return Err(MachineVerificationError::InvalidPublicValues( + "start_pc != vk.start_pc: program counter should start at vk.start_pc", + )); + } else if i != 0 && public_values.start_pc != prev_next_pc { + return Err(MachineVerificationError::InvalidPublicValues( + "start_pc != next_pc_prev: start_pc should equal next_pc_prev for all shards", + )); + } else if !shard_proof.contains_cpu() && public_values.start_pc != public_values.next_pc + { + return Err(MachineVerificationError::InvalidPublicValues( + "start_pc != next_pc: start_pc should equal next_pc for non-cpu shards", + )); + } else if shard_proof.contains_cpu() && public_values.start_pc == BabyBear::zero() { + return Err(MachineVerificationError::InvalidPublicValues( + "start_pc == 0: execution should never start at halted state", + )); + } else if i == proof.0.len() - 1 && public_values.next_pc != BabyBear::zero() { + return Err(MachineVerificationError::InvalidPublicValues( + "next_pc != 0: execution should have halted", + )); + } + prev_next_pc = public_values.next_pc; } - // Verify that the `MemoryInit` and `MemoryFinalize` chips are the last chips in the proof. - for (i, shard_proof) in proof.0.iter().enumerate() { - let chips = self - .core_machine - .shard_chips_ordered(&shard_proof.chip_ordering) - .collect::>(); - let memory_init_count = chips - .clone() - .into_iter() - .filter(|chip| chip.name() == "MemoryInit") - .count(); - let memory_final_count = chips - .into_iter() - .filter(|chip| chip.name() == "MemoryFinalize") - .count(); - - // Assert that the `MemoryInit` and `MemoryFinalize` chips only exist in the last shard. - if i != num_shards - 1 && (memory_final_count > 0 || memory_init_count > 0) { - return Err(MachineVerificationError::InvalidChipOccurence( - "memory init and finalize should not exist anywhere but the last chip" - .to_string(), + // Exit code constraints. + // + // - In every shard, the exit code should be zero. + for shard_proof in proof.0.iter() { + let public_values: &PublicValues, _> = + shard_proof.public_values.as_slice().borrow(); + if public_values.exit_code != BabyBear::zero() { + return Err(MachineVerificationError::InvalidPublicValues( + "exit_code != 0: exit code should be zero for all shards", )); } - if i == num_shards - 1 && (memory_init_count != 1 || memory_final_count != 1) { - return Err(MachineVerificationError::InvalidChipOccurence( - "memory init and finalize should exist in the last chip".to_string(), + } + + // Memory initialization & finalization constraints. + // + // Initialization: + // - `previous_init_addr_bits` should be zero. + // - `previous_finalize_addr_bits` should be zero. + // + // Transition: + // - For all shards, `previous_init_addr_bits` should equal `last_init_addr_bits` of the previous shard. + // - For all shards, `previous_finalize_addr_bits` should equal `last_finalize_addr_bits` of the previous shard. + // - For shards without "MemoryInit", `previous_init_addr_bits` should equal `last_init_addr_bits`. + // - For shards without "MemoryFinalize", `previous_finalize_addr_bits` should equal `last_finalize_addr_bits`. + let mut last_init_addr_bits_prev = [BabyBear::zero(); 32]; + let mut last_finalize_addr_bits_prev = [BabyBear::zero(); 32]; + for shard_proof in proof.0.iter() { + let public_values: &PublicValues, _> = + shard_proof.public_values.as_slice().borrow(); + if public_values.previous_init_addr_bits != last_init_addr_bits_prev { + return Err(MachineVerificationError::InvalidPublicValues( + "previous_init_addr_bits != last_init_addr_bits_prev", + )); + } else if public_values.previous_finalize_addr_bits != last_finalize_addr_bits_prev { + return Err(MachineVerificationError::InvalidPublicValues( + "last_init_addr_bits != last_finalize_addr_bits_prev", + )); + } else if !shard_proof.contains_memory_init() + && public_values.previous_init_addr_bits != public_values.last_init_addr_bits + { + return Err(MachineVerificationError::InvalidPublicValues( + "previous_init_addr_bits != last_init_addr_bits", + )); + } else if !shard_proof.contains_memory_finalize() + && public_values.previous_finalize_addr_bits + != public_values.last_finalize_addr_bits + { + return Err(MachineVerificationError::InvalidPublicValues( + "previous_finalize_addr_bits != last_finalize_addr_bits", + )); + } + last_init_addr_bits_prev = public_values.last_init_addr_bits; + last_finalize_addr_bits_prev = public_values.last_finalize_addr_bits; + } + + // Digest constraints. + // + // Initialization: + // - `committed_value_digest` should be zero. + // - `deferred_proofs_digest` should be zero. + // + // Transition: + // - If `commited_value_digest_prev` is not zero, then `committed_value_digest` should equal + // `commited_value_digest_prev`. Otherwise, `committed_value_digest` should equal zero. + // - If `deferred_proofs_digest_prev` is not zero, then `deferred_proofs_digest` should equal + // `deferred_proofs_digest_prev`. Otherwise, `deferred_proofs_digest` should equal zero. + // - If it's not a shard with "CPU", then `commited_value_digest` should not change from the + // previous shard. + // - If it's not a shard with "CPU", then `deferred_proofs_digest` should not change from the + // previous shard. + let zero_commited_value_digest = [Word([BabyBear::zero(); WORD_SIZE]); PV_DIGEST_NUM_WORDS]; + let zero_deferred_proofs_digest = [BabyBear::zero(); POSEIDON_NUM_WORDS]; + let mut commited_value_digest_prev = zero_commited_value_digest; + let mut deferred_proofs_digest_prev = zero_deferred_proofs_digest; + for shard_proof in proof.0.iter() { + let public_values: &PublicValues, _> = + shard_proof.public_values.as_slice().borrow(); + if commited_value_digest_prev != zero_commited_value_digest + && public_values.committed_value_digest != commited_value_digest_prev + { + return Err(MachineVerificationError::InvalidPublicValues( + "committed_value_digest != commited_value_digest_prev", + )); + } else if deferred_proofs_digest_prev != zero_deferred_proofs_digest + && public_values.deferred_proofs_digest != deferred_proofs_digest_prev + { + return Err(MachineVerificationError::InvalidPublicValues( + "deferred_proofs_digest != deferred_proofs_digest_prev", + )); + } else if !shard_proof.contains_cpu() + && public_values.committed_value_digest != commited_value_digest_prev + { + return Err(MachineVerificationError::InvalidPublicValues( + "committed_value_digest != commited_value_digest_prev", + )); + } else if !shard_proof.contains_cpu() + && public_values.deferred_proofs_digest != deferred_proofs_digest_prev + { + return Err(MachineVerificationError::InvalidPublicValues( + "deferred_proofs_digest != deferred_proofs_digest_prev", )); } + commited_value_digest_prev = public_values.committed_value_digest; + deferred_proofs_digest_prev = public_values.deferred_proofs_digest; } + // Verify that the number of shards is not too large. + if proof.0.len() > 1 << 16 { + return Err(MachineVerificationError::TooManyShards); + } + + // Verify the shard proof. + let mut challenger = self.core_prover.config().challenger(); + let machine_proof = MachineProof { + shard_proofs: proof.0.to_vec(), + }; + self.core_prover + .machine() + .verify(&vk.vk, &machine_proof, &mut challenger)?; + Ok(()) } @@ -148,12 +278,15 @@ impl SP1Prover { proof: &SP1ReduceProof, vk: &SP1VerifyingKey, ) -> Result<(), MachineVerificationError> { - let mut challenger = self.compress_machine.config().challenger(); + let mut challenger = self.compress_prover.config().challenger(); let machine_proof = MachineProof { shard_proofs: vec![proof.proof.clone()], }; - self.compress_machine - .verify(&self.compress_vk, &machine_proof, &mut challenger)?; + self.compress_prover.machine().verify( + &self.compress_vk, + &machine_proof, + &mut challenger, + )?; // Validate public values let public_values: &RecursionPublicValues<_> = @@ -191,11 +324,12 @@ impl SP1Prover { proof: &SP1ReduceProof, vk: &SP1VerifyingKey, ) -> Result<(), MachineVerificationError> { - let mut challenger = self.shrink_machine.config().challenger(); + let mut challenger = self.shrink_prover.config().challenger(); let machine_proof = MachineProof { shard_proofs: vec![proof.proof.clone()], }; - self.shrink_machine + self.shrink_prover + .machine() .verify(&self.shrink_vk, &machine_proof, &mut challenger)?; // Validate public values @@ -226,11 +360,12 @@ impl SP1Prover { proof: &SP1ReduceProof, vk: &SP1VerifyingKey, ) -> Result<(), MachineVerificationError> { - let mut challenger = self.wrap_machine.config().challenger(); + let mut challenger = self.wrap_prover.config().challenger(); let machine_proof = MachineProof { shard_proofs: vec![proof.proof.clone()], }; - self.wrap_machine + self.wrap_prover + .machine() .verify(&self.wrap_vk, &machine_proof, &mut challenger)?; // Validate public values @@ -299,7 +434,7 @@ pub fn verify_plonk_bn254_public_inputs( Ok(()) } -impl SubproofVerifier for &SP1Prover { +impl SubproofVerifier for &SP1Prover { fn verify_deferred_proof( &self, proof: &sp1_core::stark::ShardProof, diff --git a/recursion/circuit/CHANGELOG.md b/recursion/circuit/CHANGELOG.md new file mode 100644 index 0000000000..f5ece00116 --- /dev/null +++ b/recursion/circuit/CHANGELOG.md @@ -0,0 +1,102 @@ +# Changelog + +All notable changes to this project will be documented in this file. + +The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/), +and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html). + +## [Unreleased] + +## [1.0.0-rc.1](https://github.com/succinctlabs/sp1/compare/sp1-recursion-circuit-v1.0.0-rc.1...sp1-recursion-circuit-v1.0.0-rc.1) - 2024-07-19 + +### Added + +- result instead of exit(1) on trap in recursion ([#1089](https://github.com/succinctlabs/sp1/pull/1089)) +- publish sp1 to crates.io ([#1052](https://github.com/succinctlabs/sp1/pull/1052)) +- critical constraint changes ([#1046](https://github.com/succinctlabs/sp1/pull/1046)) +- plonk circuit optimizations ([#972](https://github.com/succinctlabs/sp1/pull/972)) +- poseidon2 hash ([#885](https://github.com/succinctlabs/sp1/pull/885)) +- use docker by default for gnark ([#890](https://github.com/succinctlabs/sp1/pull/890)) +- sp1 core prover opts +- exit code ([#750](https://github.com/succinctlabs/sp1/pull/750)) +- program refactor ([#651](https://github.com/succinctlabs/sp1/pull/651)) +- e2e groth16 with contract verifier ([#671](https://github.com/succinctlabs/sp1/pull/671)) +- improve circuit by 3-4x ([#648](https://github.com/succinctlabs/sp1/pull/648)) +- regularize proof shape ([#641](https://github.com/succinctlabs/sp1/pull/641)) +- _(sdk)_ auto setup circuit ([#635](https://github.com/succinctlabs/sp1/pull/635)) +- arbitrary degree in recursion ([#605](https://github.com/succinctlabs/sp1/pull/605)) +- prover tweaks ([#603](https://github.com/succinctlabs/sp1/pull/603)) +- enable arbitrary constraint degree ([#593](https://github.com/succinctlabs/sp1/pull/593)) +- recursion compress layer + RecursionAirWideDeg3 + RecursionAirSkinnyDeg7 + optimized groth16 ([#590](https://github.com/succinctlabs/sp1/pull/590)) +- _(Recursion)_ evaluate constraints in a single expression ([#592](https://github.com/succinctlabs/sp1/pull/592)) +- expression caching ([#586](https://github.com/succinctlabs/sp1/pull/586)) +- plonk e2e prover ([#582](https://github.com/succinctlabs/sp1/pull/582)) +- public inputs in gnark circuit ([#576](https://github.com/succinctlabs/sp1/pull/576)) +- e2e groth16 flow ([#549](https://github.com/succinctlabs/sp1/pull/549)) +- stark cleanup and verification ([#556](https://github.com/succinctlabs/sp1/pull/556)) +- recursion experiments ([#522](https://github.com/succinctlabs/sp1/pull/522)) +- groth16 circuit build script ([#541](https://github.com/succinctlabs/sp1/pull/541)) +- verify shard transitions + fixes ([#482](https://github.com/succinctlabs/sp1/pull/482)) +- recursion profiling ([#521](https://github.com/succinctlabs/sp1/pull/521)) +- gnark wrap test + cleanup ([#511](https://github.com/succinctlabs/sp1/pull/511)) +- reduce with different configs ([#508](https://github.com/succinctlabs/sp1/pull/508)) +- groth16 recursion e2e ([#502](https://github.com/succinctlabs/sp1/pull/502)) +- logup batching ([#487](https://github.com/succinctlabs/sp1/pull/487)) +- recursion optimizations + compiler cleanup ([#499](https://github.com/succinctlabs/sp1/pull/499)) +- recursion vm public values ([#495](https://github.com/succinctlabs/sp1/pull/495)) +- cleanup compiler ir ([#496](https://github.com/succinctlabs/sp1/pull/496)) +- shard transition public values ([#466](https://github.com/succinctlabs/sp1/pull/466)) +- recursion permutation challenges as variables ([#486](https://github.com/succinctlabs/sp1/pull/486)) +- add support for witness in programs ([#476](https://github.com/succinctlabs/sp1/pull/476)) +- gnark recursive verifier ([#457](https://github.com/succinctlabs/sp1/pull/457)) +- Preprocessing + recursion ([#450](https://github.com/succinctlabs/sp1/pull/450)) +- working two adic pcs verifier in recursive zkvm ([#434](https://github.com/succinctlabs/sp1/pull/434)) +- new README img ([#226](https://github.com/succinctlabs/sp1/pull/226)) +- readme updates ([#205](https://github.com/succinctlabs/sp1/pull/205)) +- more final touches ([#194](https://github.com/succinctlabs/sp1/pull/194)) +- curtaup + release system + cargo prove CLI updates ([#178](https://github.com/succinctlabs/sp1/pull/178)) +- (perf) updates from Plonky3 and verifier refactor ([#156](https://github.com/succinctlabs/sp1/pull/156)) +- developer experience improvements ([#145](https://github.com/succinctlabs/sp1/pull/145)) +- toolchain build from source & install ([#113](https://github.com/succinctlabs/sp1/pull/113)) +- io::read io::write ([#126](https://github.com/succinctlabs/sp1/pull/126)) +- tracing, profiling, benchmarking ([#99](https://github.com/succinctlabs/sp1/pull/99)) + +### Fixed + +- fix overflow when compile to wasm32 ([#812](https://github.com/succinctlabs/sp1/pull/812)) +- p3 audit change ([#964](https://github.com/succinctlabs/sp1/pull/964)) +- _(recursion)_ assert curve bit length in circuit p2_hash ([#736](https://github.com/succinctlabs/sp1/pull/736)) +- fri fold mem access ([#660](https://github.com/succinctlabs/sp1/pull/660)) +- verify reduced proofs ([#655](https://github.com/succinctlabs/sp1/pull/655)) +- high degree constraints in recursion ([#619](https://github.com/succinctlabs/sp1/pull/619)) +- circuit sponge absorb rate ([#618](https://github.com/succinctlabs/sp1/pull/618)) +- groth16 prover issues ([#571](https://github.com/succinctlabs/sp1/pull/571)) +- observe only non-padded public values ([#523](https://github.com/succinctlabs/sp1/pull/523)) +- broken e2e recursion +- don't observe padded public values ([#520](https://github.com/succinctlabs/sp1/pull/520)) + +### Other + +- use global workspace version ([#1102](https://github.com/succinctlabs/sp1/pull/1102)) +- fix release-plz ([#1088](https://github.com/succinctlabs/sp1/pull/1088)) +- add release-plz ([#1086](https://github.com/succinctlabs/sp1/pull/1086)) +- _(deps)_ bump serde from 1.0.203 to 1.0.204 ([#1063](https://github.com/succinctlabs/sp1/pull/1063)) +- _(deps)_ bump itertools from 0.12.1 to 0.13.0 ([#817](https://github.com/succinctlabs/sp1/pull/817)) +- circuit poseidon2 babybear ([#870](https://github.com/succinctlabs/sp1/pull/870)) +- remove unecessary todos in recursion +- permutation argument in circuit ([#804](https://github.com/succinctlabs/sp1/pull/804)) +- remove unecessary todo in bb31 to bn254 ([#805](https://github.com/succinctlabs/sp1/pull/805)) +- remove unecessary todo +- Clean up TOML files ([#796](https://github.com/succinctlabs/sp1/pull/796)) +- update all dependencies ([#689](https://github.com/succinctlabs/sp1/pull/689)) +- cleanup prover ([#551](https://github.com/succinctlabs/sp1/pull/551)) +- make ci faster ([#536](https://github.com/succinctlabs/sp1/pull/536)) +- cleanup for allen ([#518](https://github.com/succinctlabs/sp1/pull/518)) +- final touches for public release ([#239](https://github.com/succinctlabs/sp1/pull/239)) +- update docs with slight nits ([#224](https://github.com/succinctlabs/sp1/pull/224)) +- sp1 rename ([#212](https://github.com/succinctlabs/sp1/pull/212)) +- enshrine AlignedBorrow macro ([#209](https://github.com/succinctlabs/sp1/pull/209)) +- readme cleanup ([#196](https://github.com/succinctlabs/sp1/pull/196)) +- rename succinct to curta ([#192](https://github.com/succinctlabs/sp1/pull/192)) +- better curta graphic ([#184](https://github.com/succinctlabs/sp1/pull/184)) +- Initial commit diff --git a/recursion/circuit/Cargo.toml b/recursion/circuit/Cargo.toml index fc2b0d8441..7fac1a71d4 100644 --- a/recursion/circuit/Cargo.toml +++ b/recursion/circuit/Cargo.toml @@ -1,7 +1,13 @@ [package] name = "sp1-recursion-circuit" -version = "0.1.0" -edition = "2021" +description = "SP1 is a performant, 100% open-source, contributor-friendly zkVM." +readme = "../../README.md" +version = { workspace = true } +edition = { workspace = true } +license = { workspace = true } +repository = { workspace = true } +keywords = { workspace = true } +categories = { workspace = true } [dependencies] p3-air = { workspace = true } @@ -10,13 +16,13 @@ p3-commit = { workspace = true } p3-fri = { workspace = true } p3-matrix = { workspace = true } p3-util = { workspace = true } -sp1-recursion-core = { path = "../core" } -sp1-core = { path = "../../core" } +sp1-recursion-core = { workspace = true } +sp1-core = { workspace = true } itertools = "0.13.0" -serde = { version = "1.0.201", features = ["derive"] } -sp1-recursion-derive = { path = "../derive" } -sp1-recursion-compiler = { path = "../compiler" } -sp1-recursion-program = { path = "../program" } +serde = { version = "1.0.204", features = ["derive"] } +sp1-recursion-derive = { workspace = true } +sp1-recursion-compiler = { workspace = true } +sp1-recursion-program = { workspace = true } p3-bn254-fr = { workspace = true } p3-baby-bear = { workspace = true } bincode = "1.3.3" @@ -28,9 +34,9 @@ p3-symmetric = { workspace = true } p3-dft = { workspace = true } p3-merkle-tree = { workspace = true } p3-poseidon2 = { workspace = true } -zkhash = { git = "https://github.com/HorizenLabs/poseidon2" } +zkhash = "0.2.0" rand = "0.8.5" -sp1-recursion-gnark-ffi = { path = "../gnark-ffi" } +sp1-recursion-gnark-ffi = { workspace = true } [features] native-gnark = ["sp1-recursion-gnark-ffi/native"] diff --git a/recursion/circuit/src/challenger.rs b/recursion/circuit/src/challenger.rs index b688059dd4..aa947f6b04 100644 --- a/recursion/circuit/src/challenger.rs +++ b/recursion/circuit/src/challenger.rs @@ -125,7 +125,7 @@ pub fn reduce_32(builder: &mut Builder, vals: &[Felt]) -> Va let bits = builder.num2bits_f_circuit(*val); let val = builder.bits2num_v_circuit(&bits); builder.assign(result, result + val * power); - power *= C::N::from_canonical_usize(1usize << 32); + power *= C::N::from_canonical_u64(1u64 << 32); } result } diff --git a/recursion/circuit/src/constraints.rs b/recursion/circuit/src/constraints.rs index 3c724f0fe2..7d7cf3c13f 100644 --- a/recursion/circuit/src/constraints.rs +++ b/recursion/circuit/src/constraints.rs @@ -170,8 +170,8 @@ mod tests { use serde::{de::DeserializeOwned, Serialize}; use sp1_core::{ stark::{ - Chip, Com, Dom, LocalProver, OpeningProof, PcsProverData, ShardCommitment, - ShardMainData, ShardProof, StarkGenericConfig, StarkMachine, + Chip, Com, DefaultProver, Dom, MachineProver, OpeningProof, PcsProverData, + ShardCommitment, ShardMainData, ShardProof, StarkGenericConfig, StarkMachine, }, utils::SP1CoreOpts, }; @@ -294,22 +294,25 @@ mod tests { let program = basic_program::(); let config = SC::new(); let mut runtime = Runtime::::new_no_perm(&program); - runtime.run(); + runtime.run().unwrap(); let machine = A::machine(config); - let (pk, vk) = machine.setup(&program); - let mut challenger = machine.config().challenger(); - let proof = machine.prove::>( - &pk, - runtime.record, - &mut challenger, - SP1CoreOpts::recursion(), - ); - - let mut challenger = machine.config().challenger(); + let prover = DefaultProver::new(machine); + let (pk, vk) = prover.setup(&program); + let mut challenger = prover.config().challenger(); + let proof = prover + .prove( + &pk, + vec![runtime.record], + &mut challenger, + SP1CoreOpts::recursion(), + ) + .unwrap(); + + let mut challenger = prover.config().challenger(); vk.observe_into(&mut challenger); proof.shard_proofs.iter().for_each(|proof| { challenger.observe(proof.commitment.main_commit); - challenger.observe_slice(&proof.public_values[0..machine.num_pv_elts()]); + challenger.observe_slice(&proof.public_values[0..prover.num_pv_elts()]); }); // Run the verify inside the DSL and compare it to the calculated value. @@ -323,7 +326,7 @@ mod tests { permutation_challenges, alpha_val, zeta_val, - ) = get_shard_data(&machine, &proof, &mut challenger); + ) = get_shard_data(prover.machine(), &proof, &mut challenger); for (chip, trace_domain_val, qc_domains_vals, values_vals) in izip!( chips.iter(), diff --git a/recursion/circuit/src/fri.rs b/recursion/circuit/src/fri.rs index 151254e2c9..6f8c0b9b4b 100644 --- a/recursion/circuit/src/fri.rs +++ b/recursion/circuit/src/fri.rs @@ -33,6 +33,12 @@ pub fn verify_shape_and_sample_challenges( betas.push(sample); } + // Observe the final polynomial. + let final_poly_felts = builder.ext2felt_circuit(proof.final_poly); + final_poly_felts.iter().for_each(|felt| { + challenger.observe(builder, *felt); + }); + assert_eq!(proof.query_proofs.len(), config.num_queries); challenger.check_witness(builder, config.proof_of_work_bits, proof.pow_witness); @@ -116,13 +122,14 @@ pub fn verify_two_adic_pcs( let x: Felt<_> = builder.eval(g * two_adic_generator_exp); for (z, ps_at_z) in izip!(mat_points, mat_values) { + let mut acc: Ext = + builder.eval(SymbolicExt::from_f(C::EF::zero())); for (p_at_x, &p_at_z) in izip!(mat_opening.clone(), ps_at_z) { - let quotient: SymbolicExt = - (p_at_z - p_at_x[0]) / (*z - x); - ro[log_height] = - builder.eval(ro[log_height] + alpha_pow[log_height] * quotient); + acc = + builder.eval(acc + (alpha_pow[log_height] * (p_at_z - p_at_x[0]))); alpha_pow[log_height] = builder.eval(alpha_pow[log_height] * alpha); } + ro[log_height] = builder.eval(ro[log_height] + acc / (*z - x)); } } } diff --git a/recursion/circuit/src/stark.rs b/recursion/circuit/src/stark.rs index 574a801411..c2986c62a4 100644 --- a/recursion/circuit/src/stark.rs +++ b/recursion/circuit/src/stark.rs @@ -23,7 +23,7 @@ use sp1_recursion_compiler::ir::{Usize, Witness}; use sp1_recursion_compiler::prelude::SymbolicVar; use sp1_recursion_core::air::{RecursionPublicValues, NUM_PV_ELMS_TO_HASH}; use sp1_recursion_core::stark::config::{outer_fri_config, BabyBearPoseidon2Outer}; -use sp1_recursion_core::stark::RecursionAirSkinnyDeg9; +use sp1_recursion_core::stark::RecursionAirWideDeg17; use sp1_recursion_program::commit::PolynomialSpaceVariable; use sp1_recursion_program::stark::RecursiveVerifierConstraintFolder; use sp1_recursion_program::types::QuotientDataValues; @@ -244,7 +244,7 @@ pub fn build_wrap_circuit( template_proof: ShardProof, ) -> Vec { let outer_config = OuterSC::new(); - let outer_machine = RecursionAirSkinnyDeg9::::wrap_machine(outer_config); + let outer_machine = RecursionAirWideDeg17::::wrap_machine(outer_config); let mut builder = Builder::::default(); let mut challenger = MultiField32ChallengerVariable::new(&mut builder); diff --git a/recursion/compiler/CHANGELOG.md b/recursion/compiler/CHANGELOG.md new file mode 100644 index 0000000000..a7c84a38f4 --- /dev/null +++ b/recursion/compiler/CHANGELOG.md @@ -0,0 +1,137 @@ +# Changelog + +All notable changes to this project will be documented in this file. + +The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/), +and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html). + +## [Unreleased] + +## [1.0.0-rc.1](https://github.com/succinctlabs/sp1/compare/sp1-recursion-compiler-v1.0.0-rc.1...sp1-recursion-compiler-v1.0.0-rc.1) - 2024-07-19 + +### Added + +- result instead of exit(1) on trap in recursion ([#1089](https://github.com/succinctlabs/sp1/pull/1089)) +- publish sp1 to crates.io ([#1052](https://github.com/succinctlabs/sp1/pull/1052)) +- plonk circuit optimizations ([#972](https://github.com/succinctlabs/sp1/pull/972)) +- poseidon2 hash ([#885](https://github.com/succinctlabs/sp1/pull/885)) +- plonk prover ([#795](https://github.com/succinctlabs/sp1/pull/795)) +- _(recursion)_ public values constraints ([#748](https://github.com/succinctlabs/sp1/pull/748)) +- _(recursion)_ HALT instruction ([#703](https://github.com/succinctlabs/sp1/pull/703)) +- program refactor ([#651](https://github.com/succinctlabs/sp1/pull/651)) +- improve circuit by 3-4x ([#648](https://github.com/succinctlabs/sp1/pull/648)) +- regularize proof shape ([#641](https://github.com/succinctlabs/sp1/pull/641)) +- groth16 server ([#594](https://github.com/succinctlabs/sp1/pull/594)) +- prover tweaks pt 2 ([#607](https://github.com/succinctlabs/sp1/pull/607)) +- prover tweaks ([#603](https://github.com/succinctlabs/sp1/pull/603)) +- recursion compress layer + RecursionAirWideDeg3 + RecursionAirSkinnyDeg7 + optimized groth16 ([#590](https://github.com/succinctlabs/sp1/pull/590)) +- fixing memory interactions ([#587](https://github.com/succinctlabs/sp1/pull/587)) +- _(Recursion)_ evaluate constraints in a single expression ([#592](https://github.com/succinctlabs/sp1/pull/592)) +- expression caching ([#586](https://github.com/succinctlabs/sp1/pull/586)) +- complete reduce program ([#565](https://github.com/succinctlabs/sp1/pull/565)) +- public inputs in gnark circuit ([#576](https://github.com/succinctlabs/sp1/pull/576)) +- simplify compiler load/store ([#572](https://github.com/succinctlabs/sp1/pull/572)) +- e2e groth16 flow ([#549](https://github.com/succinctlabs/sp1/pull/549)) +- alu cpu columns ([#562](https://github.com/succinctlabs/sp1/pull/562)) +- recursion experiments ([#522](https://github.com/succinctlabs/sp1/pull/522)) +- fix cargo prove new issues ([#542](https://github.com/succinctlabs/sp1/pull/542)) +- nested sp1 proof verification ([#494](https://github.com/succinctlabs/sp1/pull/494)) +- verify pc and shard transition in recursive proofs ([#514](https://github.com/succinctlabs/sp1/pull/514)) +- recursion profiling ([#521](https://github.com/succinctlabs/sp1/pull/521)) +- 0 cycle input for recursion program ([#510](https://github.com/succinctlabs/sp1/pull/510)) +- reduce with different configs ([#508](https://github.com/succinctlabs/sp1/pull/508)) +- groth16 recursion e2e ([#502](https://github.com/succinctlabs/sp1/pull/502)) +- _(recursion)_ reduce N sp1/recursive proofs ([#503](https://github.com/succinctlabs/sp1/pull/503)) +- recursion optimizations + compiler cleanup ([#499](https://github.com/succinctlabs/sp1/pull/499)) +- recursion vm public values ([#495](https://github.com/succinctlabs/sp1/pull/495)) +- cleanup compiler ir ([#496](https://github.com/succinctlabs/sp1/pull/496)) +- add support for witness in programs ([#476](https://github.com/succinctlabs/sp1/pull/476)) +- fri-fold precompile ([#479](https://github.com/succinctlabs/sp1/pull/479)) +- gnark recursive verifier ([#457](https://github.com/succinctlabs/sp1/pull/457)) +- Preprocessing + recursion ([#450](https://github.com/succinctlabs/sp1/pull/450)) +- _(precompile)_ add bn254 precompile ([#384](https://github.com/succinctlabs/sp1/pull/384)) +- verify shard ([#444](https://github.com/succinctlabs/sp1/pull/444)) +- _(WIP)_ end-to-end verfier ([#439](https://github.com/succinctlabs/sp1/pull/439)) +- working two adic pcs verifier in recursive zkvm ([#434](https://github.com/succinctlabs/sp1/pull/434)) +- num2bits ([#426](https://github.com/succinctlabs/sp1/pull/426)) +- plonky3 update ([#428](https://github.com/succinctlabs/sp1/pull/428)) +- dsl derive macro + fri pow witness verify ([#422](https://github.com/succinctlabs/sp1/pull/422)) +- poseidon2 permute ([#423](https://github.com/succinctlabs/sp1/pull/423)) +- verify constraints ([#409](https://github.com/succinctlabs/sp1/pull/409)) +- continue work on fri verifier ([#411](https://github.com/succinctlabs/sp1/pull/411)) +- expression caching ([#407](https://github.com/succinctlabs/sp1/pull/407)) +- in progress fri verifier ([#402](https://github.com/succinctlabs/sp1/pull/402)) +- poseidon2 air ([#397](https://github.com/succinctlabs/sp1/pull/397)) +- update to the latest plonky3 version ([#398](https://github.com/succinctlabs/sp1/pull/398)) +- verify constraints in DSL + basic verifier setup ([#395](https://github.com/succinctlabs/sp1/pull/395)) +- arithmetic bug fix and add compiler to ci ([#394](https://github.com/succinctlabs/sp1/pull/394)) +- array and symbolic evaluation ([#390](https://github.com/succinctlabs/sp1/pull/390)) +- cleanup and array progress ([#387](https://github.com/succinctlabs/sp1/pull/387)) +- gnark if statements evaluation ([#386](https://github.com/succinctlabs/sp1/pull/386)) +- extension in vm backend ([#382](https://github.com/succinctlabs/sp1/pull/382)) +- gnark e2e build ([#381](https://github.com/succinctlabs/sp1/pull/381)) +- new ir ([#373](https://github.com/succinctlabs/sp1/pull/373)) +- builder control flow ([#360](https://github.com/succinctlabs/sp1/pull/360)) +- recursive DSL initial commit ([#357](https://github.com/succinctlabs/sp1/pull/357)) +- new README img ([#226](https://github.com/succinctlabs/sp1/pull/226)) +- readme updates ([#205](https://github.com/succinctlabs/sp1/pull/205)) +- more final touches ([#194](https://github.com/succinctlabs/sp1/pull/194)) +- curtaup + release system + cargo prove CLI updates ([#178](https://github.com/succinctlabs/sp1/pull/178)) +- (perf) updates from Plonky3 and verifier refactor ([#156](https://github.com/succinctlabs/sp1/pull/156)) +- developer experience improvements ([#145](https://github.com/succinctlabs/sp1/pull/145)) +- toolchain build from source & install ([#113](https://github.com/succinctlabs/sp1/pull/113)) +- io::read io::write ([#126](https://github.com/succinctlabs/sp1/pull/126)) +- tracing, profiling, benchmarking ([#99](https://github.com/succinctlabs/sp1/pull/99)) + +### Fixed + +- Allen's Poseidon2 fixes ([#1099](https://github.com/succinctlabs/sp1/pull/1099)) +- range check for shard number in recursion ([#952](https://github.com/succinctlabs/sp1/pull/952)) +- memory finalize duplicate address attack from audit ([#934](https://github.com/succinctlabs/sp1/pull/934)) +- _(recursion)_ num2bits fixes ([#732](https://github.com/succinctlabs/sp1/pull/732)) +- verify reduced proofs ([#655](https://github.com/succinctlabs/sp1/pull/655)) +- better groth16 file handling ([#620](https://github.com/succinctlabs/sp1/pull/620)) +- deferred proofs + cleanup hash_vkey ([#615](https://github.com/succinctlabs/sp1/pull/615)) +- run make on Groth16Prover::test ([#577](https://github.com/succinctlabs/sp1/pull/577)) +- groth16 prover issues ([#571](https://github.com/succinctlabs/sp1/pull/571)) +- don't observe padded public values ([#520](https://github.com/succinctlabs/sp1/pull/520)) +- two adic pcs issue when verifying tables of different heights ([#442](https://github.com/succinctlabs/sp1/pull/442)) +- compiler conditionals + working challenger ([#430](https://github.com/succinctlabs/sp1/pull/430)) +- random ci failure ([#415](https://github.com/succinctlabs/sp1/pull/415)) +- caching conflicts ([#413](https://github.com/succinctlabs/sp1/pull/413)) +- clippy ([#366](https://github.com/succinctlabs/sp1/pull/366)) + +### Other + +- use global workspace version ([#1102](https://github.com/succinctlabs/sp1/pull/1102)) +- fix release-plz ([#1088](https://github.com/succinctlabs/sp1/pull/1088)) +- add release-plz ([#1086](https://github.com/succinctlabs/sp1/pull/1086)) +- _(deps)_ bump serde from 1.0.203 to 1.0.204 ([#1063](https://github.com/succinctlabs/sp1/pull/1063)) +- Fixes from review. +- Update recursion/compiler/src/ir/utils.rs +- please clippy +- Merge branch 'dev' into erabinov/exp_rev_precompile +- Version of exp_rev_precompile +- circuit poseidon2 babybear ([#870](https://github.com/succinctlabs/sp1/pull/870)) +- fixes ([#821](https://github.com/succinctlabs/sp1/pull/821)) +- remove unecessary todos in recursion +- Make some functions const ([#774](https://github.com/succinctlabs/sp1/pull/774)) +- remove unused deps ([#794](https://github.com/succinctlabs/sp1/pull/794)) +- Clean up TOML files ([#796](https://github.com/succinctlabs/sp1/pull/796)) +- _(recursion)_ document IR ([#737](https://github.com/succinctlabs/sp1/pull/737)) +- _(recursion)_ explicitly don't allow witness and public values related apis in sub-builder ([#744](https://github.com/succinctlabs/sp1/pull/744)) +- _(recursion)_ heap ptr checks ([#775](https://github.com/succinctlabs/sp1/pull/775)) +- _(recursion)_ convert ext2felt to hint ([#771](https://github.com/succinctlabs/sp1/pull/771)) +- update all dependencies ([#689](https://github.com/succinctlabs/sp1/pull/689)) +- make ci faster ([#536](https://github.com/succinctlabs/sp1/pull/536)) +- cleanup for allen ([#518](https://github.com/succinctlabs/sp1/pull/518)) +- _(recursion)_ reduce program ([#497](https://github.com/succinctlabs/sp1/pull/497)) +- for loop optimizations +- final touches for public release ([#239](https://github.com/succinctlabs/sp1/pull/239)) +- update docs with slight nits ([#224](https://github.com/succinctlabs/sp1/pull/224)) +- sp1 rename ([#212](https://github.com/succinctlabs/sp1/pull/212)) +- enshrine AlignedBorrow macro ([#209](https://github.com/succinctlabs/sp1/pull/209)) +- readme cleanup ([#196](https://github.com/succinctlabs/sp1/pull/196)) +- rename succinct to curta ([#192](https://github.com/succinctlabs/sp1/pull/192)) +- better curta graphic ([#184](https://github.com/succinctlabs/sp1/pull/184)) +- Initial commit diff --git a/recursion/compiler/Cargo.toml b/recursion/compiler/Cargo.toml index 70aee2868f..56ae5cf40e 100644 --- a/recursion/compiler/Cargo.toml +++ b/recursion/compiler/Cargo.toml @@ -1,24 +1,33 @@ [package] name = "sp1-recursion-compiler" -version = "0.1.0" -edition = "2021" +description = "SP1 is a performant, 100% open-source, contributor-friendly zkVM." +readme = "../../README.md" +version = { workspace = true } +edition = { workspace = true } +license = { workspace = true } +repository = { workspace = true } +keywords = { workspace = true } +categories = { workspace = true } [dependencies] p3-air = { workspace = true } -p3-field = { workspace = true } +p3-bn254-fr = { workspace = true } +p3-baby-bear = { workspace = true } p3-commit = { workspace = true } +p3-field = { workspace = true } p3-fri = { workspace = true } p3-matrix = { workspace = true } +p3-poseidon2 = { workspace = true } p3-symmetric = { workspace = true } p3-util = { workspace = true } -sp1-recursion-core = { path = "../core" } -sp1-core = { path = "../../core" } + +sp1-core = { workspace = true } +sp1-primitives = { workspace = true } +sp1-recursion-core = { workspace = true } +sp1-recursion-derive = { workspace = true } + itertools = "0.13.0" -serde = { version = "1.0.201", features = ["derive"] } -sp1-recursion-derive = { path = "../derive" } -p3-bn254-fr = { workspace = true } -p3-baby-bear = { workspace = true } -p3-poseidon2 = { workspace = true } +serde = { version = "1.0.204", features = ["derive"] } backtrace = "0.3.71" tracing = "0.1.40" diff --git a/recursion/compiler/examples/fibonacci.rs b/recursion/compiler/examples/fibonacci.rs index 2ec62ec1b7..57cd15cbca 100644 --- a/recursion/compiler/examples/fibonacci.rs +++ b/recursion/compiler/examples/fibonacci.rs @@ -52,7 +52,7 @@ fn main() { let config = SC::new(); let mut runtime = Runtime::::new(&program, config.perm.clone()); - runtime.run(); + runtime.run().unwrap(); // let machine = RecursionAir::machine(config); // let (pk, vk) = machine.setup(&program); diff --git a/recursion/compiler/src/asm/compiler.rs b/recursion/compiler/src/asm/compiler.rs index 3ec01ebe48..f2db872bae 100644 --- a/recursion/compiler/src/asm/compiler.rs +++ b/recursion/compiler/src/asm/compiler.rs @@ -517,7 +517,32 @@ impl + TwoAdicField> AsmCo _ => unimplemented!(), } } - + DslIr::Poseidon2AbsorbBabyBear(p2_hash_and_absorb_num, input) => match input { + Array::Dyn(input, input_size) => { + if let Usize::Var(input_size) = input_size { + self.push( + AsmInstruction::Poseidon2Absorb( + p2_hash_and_absorb_num.fp(), + input.fp(), + input_size.fp(), + ), + trace, + ); + } else { + unimplemented!(); + } + } + _ => unimplemented!(), + }, + DslIr::Poseidon2FinalizeBabyBear(p2_hash_num, output) => match output { + Array::Dyn(output, _) => { + self.push( + AsmInstruction::Poseidon2Finalize(p2_hash_num.fp(), output.fp()), + trace, + ); + } + _ => unimplemented!(), + }, DslIr::Commit(val, index) => { self.push(AsmInstruction::Commit(val.fp(), index.fp()), trace); } diff --git a/recursion/compiler/src/asm/instruction.rs b/recursion/compiler/src/asm/instruction.rs index 78befc94d4..0dc9d5767d 100644 --- a/recursion/compiler/src/asm/instruction.rs +++ b/recursion/compiler/src/asm/instruction.rs @@ -147,8 +147,16 @@ pub enum AsmInstruction { /// Perform a permutation of the Poseidon2 hash function on the array specified by the ptr. Poseidon2Permute(i32, i32), + + /// Perform a Poseidon2 compress. Poseidon2Compress(i32, i32, i32), + /// Performs a Posedion2 absorb. + Poseidon2Absorb(i32, i32, i32), + + /// Performs a Poseidon2 finalize. + Poseidon2Finalize(i32, i32), + /// Print a variable. PrintV(i32), @@ -846,6 +854,30 @@ impl> AsmInstruction { false, "".to_string(), ), + AsmInstruction::Poseidon2Absorb(hash_and_absorb_num, input_ptr, input_len) => { + Instruction::new( + Opcode::Poseidon2Absorb, + i32_f(hash_and_absorb_num), + i32_f_arr(input_ptr), + i32_f_arr(input_len), + F::zero(), + F::zero(), + false, + false, + "".to_string(), + ) + } + AsmInstruction::Poseidon2Finalize(hash_num, output_ptr) => Instruction::new( + Opcode::Poseidon2Finalize, + i32_f(hash_num), + i32_f_arr(output_ptr), + f_u32(F::zero()), + F::zero(), + F::zero(), + false, + false, + "".to_string(), + ), AsmInstruction::Commit(val, index) => Instruction::new( Opcode::Commit, i32_f(val), @@ -1144,6 +1176,16 @@ impl> AsmInstruction { result, src1, src2 ) } + AsmInstruction::Poseidon2Absorb(hash_and_absorb_num, input_ptr, input_len) => { + write!( + f, + "poseidon2_absorb ({})fp, {})fp, ({})fp", + hash_and_absorb_num, input_ptr, input_len, + ) + } + AsmInstruction::Poseidon2Finalize(hash_num, output_ptr) => { + write!(f, "poseidon2_finalize ({})fp, ({})fp", hash_num, output_ptr,) + } AsmInstruction::Commit(val, index) => { write!(f, "commit ({})fp ({})fp", val, index) } diff --git a/recursion/compiler/src/ir/bits.rs b/recursion/compiler/src/ir/bits.rs index 396fb92be4..b08a7e29e5 100644 --- a/recursion/compiler/src/ir/bits.rs +++ b/recursion/compiler/src/ir/bits.rs @@ -47,6 +47,15 @@ impl Builder { output } + /// Range checks a felt to a certain number of bits. + pub fn range_check_f(&mut self, num: Felt, num_bits: usize) { + let bits = self.num2bits_f(num); + self.range(num_bits, bits.len()).for_each(|i, builder| { + let bit = builder.get(&bits, i); + builder.assert_var_eq(bit, C::N::zero()); + }); + } + /// Converts a felt to bits. pub fn num2bits_f(&mut self, num: Felt) -> Array> { let output = self.dyn_array::>(NUM_BITS); diff --git a/recursion/compiler/src/ir/builder.rs b/recursion/compiler/src/ir/builder.rs index 19fb164f28..e6480d6632 100644 --- a/recursion/compiler/src/ir/builder.rs +++ b/recursion/compiler/src/ir/builder.rs @@ -2,6 +2,7 @@ use std::{iter::Zip, vec::IntoIter}; use backtrace::Backtrace; use p3_field::AbstractField; +use sp1_primitives::types::RecursionProgramType; use super::{ Array, Config, DslIr, Ext, Felt, FromConstant, SymbolicExt, SymbolicFelt, SymbolicUsize, @@ -90,7 +91,7 @@ impl IntoIterator for TracedVec { /// A builder for the DSL. /// /// Can compile to both assembly and a set of constraints. -#[derive(Debug, Clone, Default)] +#[derive(Debug, Clone)] pub struct Builder { pub(crate) felt_count: u32, pub(crate) ext_count: u32, @@ -100,18 +101,51 @@ pub struct Builder { pub(crate) witness_var_count: u32, pub(crate) witness_felt_count: u32, pub(crate) witness_ext_count: u32, + pub(crate) p2_hash_num: Var, pub(crate) debug: bool, pub(crate) is_sub_builder: bool, + pub program_type: RecursionProgramType, +} + +impl Default for Builder { + fn default() -> Self { + Self::new(RecursionProgramType::Core) + } } impl Builder { + pub fn new(program_type: RecursionProgramType) -> Self { + // We need to create a temporary placeholder for the p2_hash_num variable. + let placeholder_p2_hash_num = Var::new(0); + + let mut new_builder = Self { + felt_count: 0, + ext_count: 0, + var_count: 0, + witness_var_count: 0, + witness_felt_count: 0, + witness_ext_count: 0, + operations: Default::default(), + nb_public_values: None, + p2_hash_num: placeholder_p2_hash_num, + debug: false, + is_sub_builder: false, + program_type, + }; + + new_builder.p2_hash_num = new_builder.uninit(); + new_builder + } + /// Creates a new builder with a given number of counts for each type. pub fn new_sub_builder( var_count: u32, felt_count: u32, ext_count: u32, nb_public_values: Option>, + p2_hash_num: Var, debug: bool, + program_type: RecursionProgramType, ) -> Self { Self { felt_count, @@ -124,8 +158,10 @@ impl Builder { witness_ext_count: 0, operations: Default::default(), nb_public_values, + p2_hash_num, debug, is_sub_builder: true, + program_type, } } @@ -517,9 +553,13 @@ impl<'a, C: Config> IfBuilder<'a, C> { self.builder.felt_count, self.builder.ext_count, self.builder.nb_public_values, + self.builder.p2_hash_num, self.builder.debug, + self.builder.program_type, ); f(&mut f_builder); + self.builder.p2_hash_num = f_builder.p2_hash_num; + let then_instructions = f_builder.operations; // Dispatch instructions to the correct conditional block. @@ -565,11 +605,15 @@ impl<'a, C: Config> IfBuilder<'a, C> { self.builder.felt_count, self.builder.ext_count, self.builder.nb_public_values, + self.builder.p2_hash_num, self.builder.debug, + self.builder.program_type, ); // Execute the `then` and `else_then` blocks and collect the instructions. then_f(&mut then_builder); + self.builder.p2_hash_num = then_builder.p2_hash_num; + let then_instructions = then_builder.operations; let mut else_builder = Builder::::new_sub_builder( @@ -577,9 +621,13 @@ impl<'a, C: Config> IfBuilder<'a, C> { self.builder.felt_count, self.builder.ext_count, self.builder.nb_public_values, + self.builder.p2_hash_num, self.builder.debug, + self.builder.program_type, ); else_f(&mut else_builder); + self.builder.p2_hash_num = else_builder.p2_hash_num; + let else_instructions = else_builder.operations; // Dispatch instructions to the correct conditional block. @@ -711,10 +759,13 @@ impl<'a, C: Config> RangeBuilder<'a, C> { self.builder.felt_count, self.builder.ext_count, self.builder.nb_public_values, + self.builder.p2_hash_num, self.builder.debug, + self.builder.program_type, ); f(loop_variable, &mut loop_body_builder); + self.builder.p2_hash_num = loop_body_builder.p2_hash_num; let loop_instructions = loop_body_builder.operations; diff --git a/recursion/compiler/src/ir/instructions.rs b/recursion/compiler/src/ir/instructions.rs index f5c2a1b856..ab0cb67098 100644 --- a/recursion/compiler/src/ir/instructions.rs +++ b/recursion/compiler/src/ir/instructions.rs @@ -198,6 +198,10 @@ pub enum DslIr { Array>, Array>, ), + /// Absorb an array of baby bear elements for a specified hash instance. + Poseidon2AbsorbBabyBear(Var, Array>), + /// Finalize and return the hash digest of a specified hash instance. + Poseidon2FinalizeBabyBear(Var, Array>), /// Permutes an array of Bn254 elements using Poseidon2 (output = p2_permute(array)). Should only /// be used when target is a gnark circuit. CircuitPoseidon2Permute([Var; 3]), diff --git a/recursion/compiler/src/ir/poseidon.rs b/recursion/compiler/src/ir/poseidon.rs index 2f8b0ef86b..2f7fde76ff 100644 --- a/recursion/compiler/src/ir/poseidon.rs +++ b/recursion/compiler/src/ir/poseidon.rs @@ -32,6 +32,34 @@ impl Builder { )); } + /// Applies the Poseidon2 absorb function to the given array. + /// + /// Reference: [p3_symmetric::PaddingFreeSponge] + pub fn poseidon2_absorb( + &mut self, + p2_hash_and_absorb_num: Var, + input: &Array>, + ) { + self.operations.push(DslIr::Poseidon2AbsorbBabyBear( + p2_hash_and_absorb_num, + input.clone(), + )); + } + + /// Applies the Poseidon2 finalize to the given hash number. + /// + /// Reference: [p3_symmetric::PaddingFreeSponge] + pub fn poseidon2_finalize_mut( + &mut self, + p2_hash_num: Var, + output: &Array>, + ) { + self.operations.push(DslIr::Poseidon2FinalizeBabyBear( + p2_hash_num, + output.clone(), + )); + } + /// Applies the Poseidon2 compression function to the given array. /// /// Reference: [p3_symmetric::TruncatedPermutation] @@ -104,33 +132,24 @@ impl Builder { array: &Array>>, ) -> Array> { self.cycle_tracker("poseidon2-hash"); - let mut state: Array> = self.dyn_array(PERMUTATION_WIDTH); - let idx: Var<_> = self.eval(C::N::zero()); + let p2_hash_num = self.p2_hash_num; + let two_power_12: Var<_> = self.eval(C::N::from_canonical_u32(1 << 12)); + self.range(0, array.len()).for_each(|i, builder| { let subarray = builder.get(array, i); - builder.range(0, subarray.len()).for_each(|j, builder| { - builder.cycle_tracker("poseidon2-hash-setup"); - let element = builder.get(&subarray, j); - builder.set_value(&mut state, idx, element); - builder.assign(idx, idx + C::N::one()); - builder.cycle_tracker("poseidon2-hash-setup"); - builder - .if_eq(idx, C::N::from_canonical_usize(HASH_RATE)) - .then(|builder| { - builder.poseidon2_permute_mut(&state); - builder.assign(idx, C::N::zero()); - }); - }); - }); + let p2_hash_and_absorb_num: Var<_> = builder.eval(p2_hash_num * two_power_12 + i); - self.if_ne(idx, C::N::zero()).then(|builder| { - builder.poseidon2_permute_mut(&state); + builder.poseidon2_absorb(p2_hash_and_absorb_num, &subarray); }); - state.truncate(self, Usize::Const(DIGEST_SIZE)); + let output: Array> = self.dyn_array(DIGEST_SIZE); + self.poseidon2_finalize_mut(self.p2_hash_num, &output); + + self.assign(self.p2_hash_num, self.p2_hash_num + C::N::one()); + self.cycle_tracker("poseidon2-hash"); - state + output } pub fn poseidon2_hash_ext( diff --git a/recursion/compiler/src/ir/utils.rs b/recursion/compiler/src/ir/utils.rs index 3c8a6b5657..5c161a85ca 100644 --- a/recursion/compiler/src/ir/utils.rs +++ b/recursion/compiler/src/ir/utils.rs @@ -140,6 +140,7 @@ impl Builder { // Instantiate an array of length one and store the value of x. let mut x_copy_arr: Array> = self.dyn_array(1); self.set(&mut x_copy_arr, 0, x); + // Get a pointer to the address holding x. let x_copy_arr_ptr = match x_copy_arr { Array::Dyn(ptr, _) => ptr, @@ -325,7 +326,7 @@ mod tests { let program = builder.compile_program(); let mut runtime = Runtime::::new(&program, config.perm.clone()); - runtime.run(); + runtime.run().unwrap(); } #[test] @@ -362,6 +363,6 @@ mod tests { let program = builder.compile_program(); let mut runtime = Runtime::::new(&program, config.perm.clone()); - runtime.run(); + runtime.run().unwrap(); } } diff --git a/recursion/compiler/tests/arithmetic.rs b/recursion/compiler/tests/arithmetic.rs index ce3f214ba1..54148d57ec 100644 --- a/recursion/compiler/tests/arithmetic.rs +++ b/recursion/compiler/tests/arithmetic.rs @@ -79,6 +79,6 @@ fn test_compiler_arithmetic() { let config = SC::default(); let mut runtime = Runtime::::new(&program, config.perm.clone()); - runtime.run(); + runtime.run().unwrap(); runtime.print_stats(); } diff --git a/recursion/compiler/tests/array.rs b/recursion/compiler/tests/array.rs index d48ab4610d..0781f84b39 100644 --- a/recursion/compiler/tests/array.rs +++ b/recursion/compiler/tests/array.rs @@ -121,5 +121,5 @@ fn test_compiler_array() { let config = SC::default(); let mut runtime = Runtime::::new(&program, config.perm.clone()); - runtime.run(); + runtime.run().unwrap(); } diff --git a/recursion/compiler/tests/conditionals.rs b/recursion/compiler/tests/conditionals.rs index 23f2ec8f6b..c3f01eb1aa 100644 --- a/recursion/compiler/tests/conditionals.rs +++ b/recursion/compiler/tests/conditionals.rs @@ -57,7 +57,7 @@ fn test_compiler_conditionals() { let config = SC::default(); let mut runtime = Runtime::::new(&program, config.perm.clone()); - runtime.run(); + runtime.run().unwrap(); } #[test] @@ -93,5 +93,5 @@ fn test_compiler_conditionals_v2() { let config = SC::default(); let mut runtime = Runtime::::new(&program, config.perm.clone()); - runtime.run(); + runtime.run().unwrap(); } diff --git a/recursion/compiler/tests/for_loops.rs b/recursion/compiler/tests/for_loops.rs index 605c5ca5a6..b4227c0b40 100644 --- a/recursion/compiler/tests/for_loops.rs +++ b/recursion/compiler/tests/for_loops.rs @@ -48,7 +48,7 @@ fn test_compiler_for_loops() { let config = SC::default(); let mut runtime = Runtime::::new(&program, config.perm.clone()); - runtime.run(); + runtime.run().unwrap(); } #[test] @@ -86,7 +86,7 @@ fn test_compiler_nested_array_loop() { let config = SC::default(); let mut runtime = Runtime::::new(&program, config.perm.clone()); - runtime.run(); + runtime.run().unwrap(); } #[test] @@ -170,7 +170,7 @@ fn test_compiler_break() { let config = SC::default(); let mut runtime = Runtime::::new(&program, config.perm.clone()); - runtime.run(); + runtime.run().unwrap(); } #[test] @@ -197,7 +197,7 @@ fn test_compiler_step_by() { let config = SC::default(); let mut runtime = Runtime::::new(&program, config.perm.clone()); - runtime.run(); + runtime.run().unwrap(); } #[test] @@ -225,5 +225,5 @@ fn test_compiler_bneinc() { let config = SC::default(); let mut runtime = Runtime::::new(&program, config.perm.clone()); - runtime.run(); + runtime.run().unwrap(); } diff --git a/recursion/compiler/tests/io.rs b/recursion/compiler/tests/io.rs index 1edd13fe09..7ca97a07b2 100644 --- a/recursion/compiler/tests/io.rs +++ b/recursion/compiler/tests/io.rs @@ -39,5 +39,5 @@ fn test_io() { vec![F::one().into(), F::one().into(), F::two().into()], ] .into(); - runtime.run(); + runtime.run().unwrap(); } diff --git a/recursion/compiler/tests/lt.rs b/recursion/compiler/tests/lt.rs index 6ee4815573..72ae9d82e6 100644 --- a/recursion/compiler/tests/lt.rs +++ b/recursion/compiler/tests/lt.rs @@ -26,5 +26,5 @@ fn test_compiler_less_than() { let config = SC::default(); let mut runtime = Runtime::::new(&program, config.perm.clone()); - runtime.run(); + runtime.run().unwrap(); } diff --git a/recursion/compiler/tests/poseidon2.rs b/recursion/compiler/tests/poseidon2.rs index 9ec2098f27..d6a6f65cfb 100644 --- a/recursion/compiler/tests/poseidon2.rs +++ b/recursion/compiler/tests/poseidon2.rs @@ -4,6 +4,7 @@ use p3_symmetric::Permutation; use rand::thread_rng; use rand::Rng; use sp1_core::stark::StarkGenericConfig; +use sp1_core::utils::setup_logger; use sp1_core::utils::BabyBearPoseidon2; use sp1_recursion_compiler::asm::AsmBuilder; use sp1_recursion_compiler::ir::Array; @@ -55,7 +56,7 @@ fn test_compiler_poseidon2_permute() { let program = builder.compile_program(); let mut runtime = Runtime::::new(&program, config.perm.clone()); - runtime.run(); + runtime.run().unwrap(); println!( "The program executed successfully, number of cycles: {}", runtime.clk.as_canonical_u32() / 4 @@ -64,6 +65,7 @@ fn test_compiler_poseidon2_permute() { #[test] fn test_compiler_poseidon2_hash() { + setup_logger(); type SC = BabyBearPoseidon2; type F = ::Val; type EF = ::Challenge; @@ -74,19 +76,32 @@ fn test_compiler_poseidon2_hash() { let mut builder = AsmBuilder::::default(); - let random_state_vals: [F; 42] = rng.gen(); - println!("{:?}", random_state_vals); + let random_state_vals_1: [F; 42] = rng.gen(); + println!("{:?}", random_state_vals_1); + let random_state_vals_2: [F; 42] = rng.gen(); + println!("{:?}", random_state_vals_2); - let mut random_state_v1 = builder.dyn_array(random_state_vals.len()); - for (i, val) in random_state_vals.iter().enumerate() { + let mut random_state_v1 = + builder.dyn_array(random_state_vals_1.len() + random_state_vals_2.len()); + for (i, val) in random_state_vals_1.iter().enumerate() { builder.set(&mut random_state_v1, i, *val); } - let mut random_state_v2 = builder.dyn_array(random_state_vals.len()); - for (i, val) in random_state_vals.iter().enumerate() { - builder.set(&mut random_state_v2, i, *val); + for (i, val) in random_state_vals_2.iter().enumerate() { + builder.set(&mut random_state_v1, i + random_state_vals_1.len(), *val); + } + + let mut random_state_v2_1 = builder.dyn_array(random_state_vals_1.len()); + for (i, val) in random_state_vals_1.iter().enumerate() { + builder.set(&mut random_state_v2_1, i, *val); + } + let mut random_state_v2_2 = builder.dyn_array(random_state_vals_2.len()); + for (i, val) in random_state_vals_2.iter().enumerate() { + builder.set(&mut random_state_v2_2, i, *val); } - let mut nested_random_state = builder.dyn_array(1); - builder.set(&mut nested_random_state, 0, random_state_v2.clone()); + + let mut nested_random_state = builder.dyn_array(2); + builder.set(&mut nested_random_state, 0, random_state_v2_1.clone()); + builder.set(&mut nested_random_state, 1, random_state_v2_2.clone()); let result = builder.poseidon2_hash(&random_state_v1); let result_x = builder.poseidon2_hash_x(&nested_random_state); @@ -100,11 +115,12 @@ fn test_compiler_poseidon2_hash() { let program = builder.compile_program(); let mut runtime = Runtime::::new(&program, config.perm.clone()); - runtime.run(); + runtime.run().unwrap(); println!( "The program executed successfully, number of cycles: {}", runtime.clk.as_canonical_u32() / 4 ); + runtime.print_stats(); } #[test] @@ -135,7 +151,7 @@ fn test_compiler_poseidon2_hash_v2() { let program = builder.compile_program(); let mut runtime = Runtime::::new(&program, config.perm.clone()); - runtime.run(); + runtime.run().unwrap(); println!( "The program executed successfully, number of cycles: {}", runtime.clk.as_canonical_u32() / 4 diff --git a/recursion/compiler/tests/public_values.rs b/recursion/compiler/tests/public_values.rs index 5b7c7c9c96..1ad7f3fe77 100644 --- a/recursion/compiler/tests/public_values.rs +++ b/recursion/compiler/tests/public_values.rs @@ -27,5 +27,5 @@ fn test_compiler_public_values() { let config = SC::default(); let mut runtime = Runtime::::new(&program, config.perm.clone()); - runtime.run(); + runtime.run().unwrap(); } diff --git a/recursion/core/CHANGELOG.md b/recursion/core/CHANGELOG.md new file mode 100644 index 0000000000..dcfd321d6f --- /dev/null +++ b/recursion/core/CHANGELOG.md @@ -0,0 +1,182 @@ +# Changelog + +All notable changes to this project will be documented in this file. + +The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/), +and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html). + +## [Unreleased] + +## [1.0.0-rc.1](https://github.com/succinctlabs/sp1/compare/sp1-recursion-core-v1.0.0-rc.1...sp1-recursion-core-v1.0.0-rc.1) - 2024-07-19 + +### Added + +- parallel recursion tracegen ([#1095](https://github.com/succinctlabs/sp1/pull/1095)) +- result instead of exit(1) on trap in recursion ([#1089](https://github.com/succinctlabs/sp1/pull/1089)) +- publish sp1 to crates.io ([#1052](https://github.com/succinctlabs/sp1/pull/1052)) +- critical constraint changes ([#1046](https://github.com/succinctlabs/sp1/pull/1046)) +- plonk circuit optimizations ([#972](https://github.com/succinctlabs/sp1/pull/972)) +- poseidon2 hash ([#885](https://github.com/succinctlabs/sp1/pull/885)) +- optimize cpu tracegen ([#949](https://github.com/succinctlabs/sp1/pull/949)) +- shrink/wrap multi opt +- generic const expr ([#854](https://github.com/succinctlabs/sp1/pull/854)) +- plonk prover ([#795](https://github.com/succinctlabs/sp1/pull/795)) +- exit code ([#750](https://github.com/succinctlabs/sp1/pull/750)) +- _(recursion)_ public values constraints ([#748](https://github.com/succinctlabs/sp1/pull/748)) +- _(recursion)_ HALT instruction ([#703](https://github.com/succinctlabs/sp1/pull/703)) +- program refactor ([#651](https://github.com/succinctlabs/sp1/pull/651)) +- e2e groth16 with contract verifier ([#671](https://github.com/succinctlabs/sp1/pull/671)) +- nextgen ci for sp1-prover ([#663](https://github.com/succinctlabs/sp1/pull/663)) +- _(recursion)_ Add interactions to poseidon2 skinny ([#658](https://github.com/succinctlabs/sp1/pull/658)) +- Adding docs for new `ProverClient` and `groth16` and `compressed` mode ([#627](https://github.com/succinctlabs/sp1/pull/627)) +- aggregation fixes ([#649](https://github.com/succinctlabs/sp1/pull/649)) +- improve circuit by 3-4x ([#648](https://github.com/succinctlabs/sp1/pull/648)) +- _(recursion)_ poseidon2 max constraint degree const generic ([#634](https://github.com/succinctlabs/sp1/pull/634)) +- regularize proof shape ([#641](https://github.com/succinctlabs/sp1/pull/641)) +- prover tweaks pt4 ([#632](https://github.com/succinctlabs/sp1/pull/632)) +- _(recursion)_ jump instruction constraints ([#617](https://github.com/succinctlabs/sp1/pull/617)) +- _(recursion)_ cpu branch constraints ([#578](https://github.com/succinctlabs/sp1/pull/578)) +- prover tweaks pt 2 ([#607](https://github.com/succinctlabs/sp1/pull/607)) +- prover tweaks ([#603](https://github.com/succinctlabs/sp1/pull/603)) +- _(recursion)_ memory access timestamp constraints ([#589](https://github.com/succinctlabs/sp1/pull/589)) +- enable arbitrary constraint degree ([#593](https://github.com/succinctlabs/sp1/pull/593)) +- recursion compress layer + RecursionAirWideDeg3 + RecursionAirSkinnyDeg7 + optimized groth16 ([#590](https://github.com/succinctlabs/sp1/pull/590)) +- fixing memory interactions ([#587](https://github.com/succinctlabs/sp1/pull/587)) +- _(recursion)_ memory builder + fri-fold precompile ([#581](https://github.com/succinctlabs/sp1/pull/581)) +- complete reduce program ([#565](https://github.com/succinctlabs/sp1/pull/565)) +- public inputs in gnark circuit ([#576](https://github.com/succinctlabs/sp1/pull/576)) +- _(recursion)_ cpu alu constraints ([#570](https://github.com/succinctlabs/sp1/pull/570)) +- _(recursion)_ recursion air builder ([#574](https://github.com/succinctlabs/sp1/pull/574)) +- simplify compiler load/store ([#572](https://github.com/succinctlabs/sp1/pull/572)) +- alu cpu columns ([#562](https://github.com/succinctlabs/sp1/pull/562)) +- recursion experiments ([#522](https://github.com/succinctlabs/sp1/pull/522)) +- _(recursion)_ impl `Poseidon2WideChip` ([#537](https://github.com/succinctlabs/sp1/pull/537)) +- groth16 circuit build script ([#541](https://github.com/succinctlabs/sp1/pull/541)) +- verify shard transitions + fixes ([#482](https://github.com/succinctlabs/sp1/pull/482)) +- preprocess memory program chip ([#480](https://github.com/succinctlabs/sp1/pull/480)) +- nested sp1 proof verification ([#494](https://github.com/succinctlabs/sp1/pull/494)) +- verify pc and shard transition in recursive proofs ([#514](https://github.com/succinctlabs/sp1/pull/514)) +- recursion profiling ([#521](https://github.com/succinctlabs/sp1/pull/521)) +- update to latest p3 ([#515](https://github.com/succinctlabs/sp1/pull/515)) +- gnark wrap test + cleanup ([#511](https://github.com/succinctlabs/sp1/pull/511)) +- reduce with different configs ([#508](https://github.com/succinctlabs/sp1/pull/508)) +- groth16 recursion e2e ([#502](https://github.com/succinctlabs/sp1/pull/502)) +- recursion optimizations + compiler cleanup ([#499](https://github.com/succinctlabs/sp1/pull/499)) +- recursion vm public values ([#495](https://github.com/succinctlabs/sp1/pull/495)) +- shard transition public values ([#466](https://github.com/succinctlabs/sp1/pull/466)) +- add support for witness in programs ([#476](https://github.com/succinctlabs/sp1/pull/476)) +- fri-fold precompile ([#479](https://github.com/succinctlabs/sp1/pull/479)) +- setup recursion prover crate ([#475](https://github.com/succinctlabs/sp1/pull/475)) +- gnark recursive verifier ([#457](https://github.com/succinctlabs/sp1/pull/457)) +- recursion cpu constraints ([#464](https://github.com/succinctlabs/sp1/pull/464)) +- public values ([#455](https://github.com/succinctlabs/sp1/pull/455)) +- Preprocessing + recursion ([#450](https://github.com/succinctlabs/sp1/pull/450)) +- _(precompile)_ add bn254 precompile ([#384](https://github.com/succinctlabs/sp1/pull/384)) +- verify shard ([#444](https://github.com/succinctlabs/sp1/pull/444)) +- _(WIP)_ end-to-end verfier ([#439](https://github.com/succinctlabs/sp1/pull/439)) +- working two adic pcs verifier in recursive zkvm ([#434](https://github.com/succinctlabs/sp1/pull/434)) +- num2bits ([#426](https://github.com/succinctlabs/sp1/pull/426)) +- poseidon2 permute ([#423](https://github.com/succinctlabs/sp1/pull/423)) +- verify constraints ([#409](https://github.com/succinctlabs/sp1/pull/409)) +- poseidon2 air ([#397](https://github.com/succinctlabs/sp1/pull/397)) +- checkpoint runtime for constant memory usage ([#389](https://github.com/succinctlabs/sp1/pull/389)) +- update to the latest plonky3 version ([#398](https://github.com/succinctlabs/sp1/pull/398)) +- array and symbolic evaluation ([#390](https://github.com/succinctlabs/sp1/pull/390)) +- extension in vm backend ([#382](https://github.com/succinctlabs/sp1/pull/382)) +- new ir ([#373](https://github.com/succinctlabs/sp1/pull/373)) +- core recursion air constraints ([#359](https://github.com/succinctlabs/sp1/pull/359)) +- recursive DSL initial commit ([#357](https://github.com/succinctlabs/sp1/pull/357)) +- recursion program table + memory tracing ([#356](https://github.com/succinctlabs/sp1/pull/356)) +- initial recursion core ([#354](https://github.com/succinctlabs/sp1/pull/354)) +- new README img ([#226](https://github.com/succinctlabs/sp1/pull/226)) +- readme updates ([#205](https://github.com/succinctlabs/sp1/pull/205)) +- more final touches ([#194](https://github.com/succinctlabs/sp1/pull/194)) +- curtaup + release system + cargo prove CLI updates ([#178](https://github.com/succinctlabs/sp1/pull/178)) +- (perf) updates from Plonky3 and verifier refactor ([#156](https://github.com/succinctlabs/sp1/pull/156)) +- developer experience improvements ([#145](https://github.com/succinctlabs/sp1/pull/145)) +- toolchain build from source & install ([#113](https://github.com/succinctlabs/sp1/pull/113)) +- io::read io::write ([#126](https://github.com/succinctlabs/sp1/pull/126)) +- tracing, profiling, benchmarking ([#99](https://github.com/succinctlabs/sp1/pull/99)) + +### Fixed + +- Allen's Poseidon2 fixes ([#1099](https://github.com/succinctlabs/sp1/pull/1099)) +- Allen's exp_reverse_bits_len fixes ([#1074](https://github.com/succinctlabs/sp1/pull/1074)) +- multi-builder first/last row issue ([#997](https://github.com/succinctlabs/sp1/pull/997)) +- recursion runtime +- changed fixed size for multi table ([#966](https://github.com/succinctlabs/sp1/pull/966)) +- frifold flag column consistency ([#946](https://github.com/succinctlabs/sp1/pull/946)) +- recursion audit fixes for Issues 7-10 ([#937](https://github.com/succinctlabs/sp1/pull/937)) +- memory finalize duplicate address attack from audit ([#934](https://github.com/succinctlabs/sp1/pull/934)) +- fix things +- fix +- _(recursion)_ num2bits fixes ([#732](https://github.com/succinctlabs/sp1/pull/732)) +- _(recursion)_ poseidon2 external flag ([#747](https://github.com/succinctlabs/sp1/pull/747)) +- _(recursion)_ enable mul constraint ([#686](https://github.com/succinctlabs/sp1/pull/686)) +- fixes to the multi table ([#669](https://github.com/succinctlabs/sp1/pull/669)) +- fri fold mem access ([#660](https://github.com/succinctlabs/sp1/pull/660)) +- verify reduced proofs ([#655](https://github.com/succinctlabs/sp1/pull/655)) +- _(recursion)_ fixes for fri fold and poseidon2 ([#654](https://github.com/succinctlabs/sp1/pull/654)) +- high degree constraints in recursion ([#619](https://github.com/succinctlabs/sp1/pull/619)) +- circuit sponge absorb rate ([#618](https://github.com/succinctlabs/sp1/pull/618)) +- deferred proofs + cleanup hash_vkey ([#615](https://github.com/succinctlabs/sp1/pull/615)) +- comment out MUL constraints ([#602](https://github.com/succinctlabs/sp1/pull/602)) +- update Poseidon2 air to match plonky3 ([#600](https://github.com/succinctlabs/sp1/pull/600)) +- circuit verification ([#599](https://github.com/succinctlabs/sp1/pull/599)) +- poseidon2wide `is_real` ([#591](https://github.com/succinctlabs/sp1/pull/591)) +- _(recursion)_ poseidon2 chip matches plonky3 ([#548](https://github.com/succinctlabs/sp1/pull/548)) +- observe only non-padded public values ([#523](https://github.com/succinctlabs/sp1/pull/523)) +- few regression fixes ([#441](https://github.com/succinctlabs/sp1/pull/441)) +- ci ([#401](https://github.com/succinctlabs/sp1/pull/401)) + +### Other + +- poseidon2 parallel tracegen ([#1118](https://github.com/succinctlabs/sp1/pull/1118)) +- _(deps)_ bump serde_with from 3.8.3 to 3.9.0 ([#1103](https://github.com/succinctlabs/sp1/pull/1103)) +- use global workspace version ([#1102](https://github.com/succinctlabs/sp1/pull/1102)) +- fix release-plz ([#1088](https://github.com/succinctlabs/sp1/pull/1088)) +- add release-plz ([#1086](https://github.com/succinctlabs/sp1/pull/1086)) +- _(deps)_ bump serde_with from 3.8.1 to 3.8.3 ([#1064](https://github.com/succinctlabs/sp1/pull/1064)) +- merge main -> dev ([#969](https://github.com/succinctlabs/sp1/pull/969)) +- format PR [#934](https://github.com/succinctlabs/sp1/pull/934) ([#939](https://github.com/succinctlabs/sp1/pull/939)) +- Refactored is_last and is_first columns; added constraint to make sure that the last real row has is_last on. +- all hail clippy +- Removed defunct test +- please clippy +- Merge branch 'dev' into erabinov/exp_rev_precompile +- Version of exp_rev_precompile +- hm +- remove test +- fixes ([#821](https://github.com/succinctlabs/sp1/pull/821)) +- change challenger rate from 16 to 8 ([#807](https://github.com/succinctlabs/sp1/pull/807)) +- clippy fixes +- remove unecessary todos in recursion +- Make some functions const ([#774](https://github.com/succinctlabs/sp1/pull/774)) +- Clean up TOML files ([#796](https://github.com/succinctlabs/sp1/pull/796)) +- _(recursion)_ heap ptr checks ([#775](https://github.com/succinctlabs/sp1/pull/775)) +- _(recursion)_ convert ext2felt to hint ([#771](https://github.com/succinctlabs/sp1/pull/771)) +- update all dependencies ([#689](https://github.com/succinctlabs/sp1/pull/689)) +- _(recursion)_ poseidon2 loose ends ([#672](https://github.com/succinctlabs/sp1/pull/672)) +- sdk tweaks ([#653](https://github.com/succinctlabs/sp1/pull/653)) +- _(recursion)_ consolidate initial and finalize memory tables ([#656](https://github.com/succinctlabs/sp1/pull/656)) +- _(recursion)_ cpu column chores ([#614](https://github.com/succinctlabs/sp1/pull/614)) +- _(recursion)_ re-organized cpu chip and trace ([#613](https://github.com/succinctlabs/sp1/pull/613)) +- poseidon2 config change ([#609](https://github.com/succinctlabs/sp1/pull/609)) +- cleanup prover ([#551](https://github.com/succinctlabs/sp1/pull/551)) +- cleanup program + add missing constraints ([#547](https://github.com/succinctlabs/sp1/pull/547)) +- make ci faster ([#536](https://github.com/succinctlabs/sp1/pull/536)) +- attach dummy wide poseidon2 ([#512](https://github.com/succinctlabs/sp1/pull/512)) +- add poseidon2 chip to recursionAIR ([#504](https://github.com/succinctlabs/sp1/pull/504)) +- _(recursion)_ reduce program ([#497](https://github.com/succinctlabs/sp1/pull/497)) +- for loop optimizations +- update to latest plonky3 main ([#491](https://github.com/succinctlabs/sp1/pull/491)) +- sunday cleanup ([#363](https://github.com/succinctlabs/sp1/pull/363)) +- recursion core cleanup ([#355](https://github.com/succinctlabs/sp1/pull/355)) +- final touches for public release ([#239](https://github.com/succinctlabs/sp1/pull/239)) +- update docs with slight nits ([#224](https://github.com/succinctlabs/sp1/pull/224)) +- sp1 rename ([#212](https://github.com/succinctlabs/sp1/pull/212)) +- enshrine AlignedBorrow macro ([#209](https://github.com/succinctlabs/sp1/pull/209)) +- readme cleanup ([#196](https://github.com/succinctlabs/sp1/pull/196)) +- rename succinct to curta ([#192](https://github.com/succinctlabs/sp1/pull/192)) +- better curta graphic ([#184](https://github.com/succinctlabs/sp1/pull/184)) +- Initial commit diff --git a/recursion/core/Cargo.toml b/recursion/core/Cargo.toml index 9a6588ec5c..3d8b0d486e 100644 --- a/recursion/core/Cargo.toml +++ b/recursion/core/Cargo.toml @@ -1,7 +1,13 @@ [package] -edition = "2021" name = "sp1-recursion-core" -version = "0.1.0" +description = "SP1 is a performant, 100% open-source, contributor-friendly zkVM." +readme = "../../README.md" +version = { workspace = true } +edition = { workspace = true } +license = { workspace = true } +repository = { workspace = true } +keywords = { workspace = true } +categories = { workspace = true } [dependencies] p3-field = { workspace = true } @@ -12,11 +18,11 @@ p3-matrix = { workspace = true } p3-maybe-rayon = { workspace = true } p3-poseidon2 = { workspace = true } p3-symmetric = { workspace = true } -sp1-derive = { path = "../../derive" } -sp1-primitives = { path = "../../primitives" } +sp1-derive = { workspace = true } +sp1-primitives = { workspace = true } tracing = "0.1.40" -sp1-core = { path = "../../core" } -hashbrown = "0.14.5" +sp1-core = { workspace = true } +hashbrown = { version = "0.14.5", features = ["serde"] } itertools = "0.13.0" p3-bn254-fr = { workspace = true } p3-merkle-tree = { workspace = true } @@ -24,13 +30,14 @@ p3-commit = { workspace = true } p3-dft = { workspace = true } p3-challenger = { workspace = true } p3-fri = { workspace = true } -zkhash = { git = "https://github.com/HorizenLabs/poseidon2" } +zkhash = "0.2.0" ff = { version = "0.13", features = ["derive", "derive_bits"] } serde = { version = "1.0", features = ["derive", "rc"] } -serde_with = "3.8.1" +serde_with = "3.9.0" backtrace = { version = "0.3.71", features = ["serde"] } arrayref = "0.3.7" static_assertions = "1.1.0" +num_cpus = "1.16.0" [dev-dependencies] rand = "0.8.5" diff --git a/recursion/core/src/air/builder.rs b/recursion/core/src/air/builder.rs index ab6e6c1017..e2ea45e4f2 100644 --- a/recursion/core/src/air/builder.rs +++ b/recursion/core/src/air/builder.rs @@ -100,14 +100,14 @@ pub trait RecursionMemoryAirBuilder: RecursionInteractionAirBuilder { )); } - /// Verifies that the memory access happends after the previous memory access. + /// Verifies that the memory access happens after the previous memory access. fn eval_memory_access_timestamp + Clone>( &mut self, timestamp: impl Into, mem_access: &impl MemoryAccessTimestampCols, is_real: impl Into + Clone, ) { - // We substract one since a diff of zero is not valid. + // We subtract one since a diff of zero is not valid. let diff_minus_one: Self::Expr = timestamp.into() - mem_access.prev_timestamp().clone().into() - Self::Expr::one(); diff --git a/recursion/core/src/air/multi_builder.rs b/recursion/core/src/air/multi_builder.rs index 814b3ae3d0..63ad786084 100644 --- a/recursion/core/src/air/multi_builder.rs +++ b/recursion/core/src/air/multi_builder.rs @@ -1,18 +1,35 @@ -use p3_air::{AirBuilder, ExtensionBuilder, FilteredAirBuilder, PermutationAirBuilder}; +use p3_air::{ + AirBuilder, AirBuilderWithPublicValues, ExtensionBuilder, FilteredAirBuilder, + PermutationAirBuilder, +}; use sp1_core::air::MessageBuilder; /// The MultiBuilder is used for the multi table. It is used to create a virtual builder for one of /// the sub tables in the multi table. pub struct MultiBuilder<'a, AB: AirBuilder> { inner: FilteredAirBuilder<'a, AB>, + + /// These fields are used to determine whether a row is is the first or last row of the subtable, + /// which requires hinting from the parent table. + is_first_row: AB::Expr, + is_last_row: AB::Expr, + next_condition: AB::Expr, } impl<'a, AB: AirBuilder> MultiBuilder<'a, AB> { - pub fn new(builder: &'a mut AB, local_condition: AB::Expr, next_condition: AB::Expr) -> Self { + pub fn new( + builder: &'a mut AB, + local_condition: AB::Expr, + is_first_row: AB::Expr, + is_last_row: AB::Expr, + next_condition: AB::Expr, + ) -> Self { let inner = builder.when(local_condition.clone()); Self { inner, + is_first_row, + is_last_row, next_condition, } } @@ -29,11 +46,11 @@ impl<'a, AB: AirBuilder> AirBuilder for MultiBuilder<'a, AB> { } fn is_first_row(&self) -> Self::Expr { - self.inner.is_first_row() + self.is_first_row.clone() } fn is_last_row(&self) -> Self::Expr { - self.inner.is_last_row() + self.is_last_row.clone() } fn is_transition_window(&self, size: usize) -> Self::Expr { @@ -81,3 +98,13 @@ impl<'a, AB: AirBuilder + MessageBuilder, M> MessageBuilder for MultiBuild self.inner.receive(message); } } + +impl<'a, AB: AirBuilder + AirBuilderWithPublicValues> AirBuilderWithPublicValues + for MultiBuilder<'a, AB> +{ + type PublicVar = AB::PublicVar; + + fn public_values(&self) -> &[Self::PublicVar] { + self.inner.public_values() + } +} diff --git a/recursion/core/src/air/public_values.rs b/recursion/core/src/air/public_values.rs index 4f29393761..4c9708e138 100644 --- a/recursion/core/src/air/public_values.rs +++ b/recursion/core/src/air/public_values.rs @@ -80,9 +80,27 @@ pub struct RecursionPublicValues { /// First shard being proven. pub start_shard: T, - /// Next shard that should be proven, if there are more. + /// Next shard that should be proven. pub next_shard: T, + /// First execution shard being proven. + pub start_execution_shard: T, + + /// Next execution shard that should be proven. + pub next_execution_shard: T, + + /// Previous MemoryInit address bits. + pub previous_init_addr_bits: [T; 32], + + /// Last MemoryInit address bits. + pub last_init_addr_bits: [T; 32], + + /// Previous MemoryFinalize address bits. + pub previous_finalize_addr_bits: [T; 32], + + /// Last MemoryFinalize address bits. + pub last_finalize_addr_bits: [T; 32], + /// Start state of reconstruct_challenger. pub start_reconstruct_challenger: ChallengerPublicValues, @@ -110,9 +128,6 @@ pub struct RecursionPublicValues { /// Whether the proof completely proves the program execution. pub is_complete: T, - /// Total number of core shards in the program execution. - pub total_core_shards: T, - /// The digest of all the previous public values elements. pub digest: [T; DIGEST_SIZE], diff --git a/recursion/core/src/cpu/air/alu.rs b/recursion/core/src/cpu/air/alu.rs index 377fc4fe82..761617a90c 100644 --- a/recursion/core/src/cpu/air/alu.rs +++ b/recursion/core/src/cpu/air/alu.rs @@ -10,6 +10,9 @@ use crate::{ impl CpuChip { /// Eval the ALU instructions. + /// + /// # Warning + /// The division constraints allow a = 0/0 for any a. pub fn eval_alu(&self, builder: &mut AB, local: &CpuCols) where AB: SP1RecursionAirBuilder, diff --git a/recursion/core/src/cpu/air/mod.rs b/recursion/core/src/cpu/air/mod.rs index b676d0bb25..2dfcb9a1d4 100644 --- a/recursion/core/src/cpu/air/mod.rs +++ b/recursion/core/src/cpu/air/mod.rs @@ -16,7 +16,7 @@ use sp1_core::air::BaseAirBuilder; use crate::{ air::{RecursionPublicValues, SP1RecursionAirBuilder, RECURSIVE_PROOF_NUM_PV_ELTS}, - cpu::{CpuChip, CpuCols}, + cpu::{columns::SELECTOR_COL_MAP, CpuChip, CpuCols}, memory::MemoryCols, }; @@ -38,6 +38,29 @@ where let one = AB::Expr::one(); // Constrain the program. + + // Constraints for "fake" columns. + builder + .when_not(local.is_real) + .assert_one(local.instruction.imm_b); + builder + .when_not(local.is_real) + .assert_one(local.instruction.imm_c); + builder + .when_not(local.is_real) + .assert_one(local.selectors.is_noop); + + local + .selectors + .into_iter() + .enumerate() + .filter(|(i, _)| *i != SELECTOR_COL_MAP.is_noop) + .for_each(|(_, selector)| builder.when_not(local.is_real).assert_zero(selector)); + + // Initialize clk and pc. + builder.when_first_row().assert_zero(local.clk); + builder.when_first_row().assert_zero(local.pc); + builder.send_program(local.pc, local.instruction, local.selectors, local.is_real); // Constrain the operands. @@ -205,6 +228,10 @@ impl CpuChip { + local.selectors.is_store + local.selectors.is_noop + local.selectors.is_ext_to_felt + + local.selectors.is_commit + + local.selectors.is_trap + + local.selectors.is_halt + + local.selectors.is_exp_reverse_bits_len } /// Expr to check for instructions that are commit instructions. @@ -223,3 +250,75 @@ impl CpuChip { local.selectors.is_trap + local.selectors.is_halt } } + +#[cfg(test)] +mod tests { + use itertools::Itertools; + use std::time::Instant; + + use p3_baby_bear::BabyBear; + use p3_baby_bear::DiffusionMatrixBabyBear; + use p3_field::AbstractField; + use p3_matrix::{dense::RowMajorMatrix, Matrix}; + use p3_poseidon2::Poseidon2; + use p3_poseidon2::Poseidon2ExternalMatrixGeneral; + use sp1_core::stark::StarkGenericConfig; + use sp1_core::{ + air::MachineAir, + utils::{uni_stark_prove, uni_stark_verify, BabyBearPoseidon2}, + }; + + use crate::air::Block; + use crate::memory::MemoryGlobalChip; + use crate::runtime::ExecutionRecord; + + #[test] + fn test_cpu_unistark() { + let config = BabyBearPoseidon2::compressed(); + let mut challenger = config.challenger(); + + let chip = MemoryGlobalChip { + fixed_log2_rows: None, + }; + + let test_vals = (0..16).map(BabyBear::from_canonical_u32).collect_vec(); + + let mut input_exec = ExecutionRecord::::default(); + for val in test_vals.into_iter() { + let event = (val, val, Block::from(BabyBear::zero())); + input_exec.last_memory_record.push(event); + } + + // Add a dummy initialize event because the AIR expects at least one. + input_exec + .first_memory_record + .push((BabyBear::zero(), Block::from(BabyBear::zero()))); + + println!("input exec: {:?}", input_exec.last_memory_record.len()); + let trace: RowMajorMatrix = + chip.generate_trace(&input_exec, &mut ExecutionRecord::::default()); + println!( + "trace dims is width: {:?}, height: {:?}", + trace.width(), + trace.height() + ); + + let start = Instant::now(); + let proof = uni_stark_prove(&config, &chip, &mut challenger, trace); + let duration = start.elapsed().as_secs_f64(); + println!("proof duration = {:?}", duration); + + let mut challenger: p3_challenger::DuplexChallenger< + BabyBear, + Poseidon2, + 16, + 8, + > = config.challenger(); + let start = Instant::now(); + uni_stark_verify(&config, &chip, &mut challenger, &proof) + .expect("expected proof to be valid"); + + let duration = start.elapsed().as_secs_f64(); + println!("verify duration = {:?}", duration); + } +} diff --git a/recursion/core/src/cpu/columns/mod.rs b/recursion/core/src/cpu/columns/mod.rs index 5655a9661a..5cdd25a1c3 100644 --- a/recursion/core/src/cpu/columns/mod.rs +++ b/recursion/core/src/cpu/columns/mod.rs @@ -1,8 +1,7 @@ -use std::mem::{size_of, transmute}; +use std::mem::size_of; use crate::memory::{MemoryReadCols, MemoryReadWriteCols}; use p3_air::BaseAir; -use sp1_core::utils::indices_arr; use sp1_derive::AlignedBorrow; mod branch; @@ -23,13 +22,6 @@ use super::CpuChip; pub const NUM_CPU_COLS: usize = size_of::>(); -const fn make_col_map() -> CpuCols { - let indices_arr = indices_arr::(); - unsafe { transmute::<[usize; NUM_CPU_COLS], CpuCols>(indices_arr) } -} - -pub(crate) const CPU_COL_MAP: CpuCols = make_col_map(); - impl BaseAir for CpuChip { fn width(&self) -> usize { NUM_CPU_COLS diff --git a/recursion/core/src/cpu/columns/opcode.rs b/recursion/core/src/cpu/columns/opcode.rs index 1eeb094899..a3d85a93b4 100644 --- a/recursion/core/src/cpu/columns/opcode.rs +++ b/recursion/core/src/cpu/columns/opcode.rs @@ -1,4 +1,7 @@ +use std::{borrow::BorrowMut, mem::transmute}; + use p3_field::PrimeField32; +use p3_util::indices_arr; use sp1_derive::AlignedBorrow; use crate::{ @@ -6,7 +9,14 @@ use crate::{ runtime::{instruction_is_heap_expand, Opcode}, }; -const OPCODE_COUNT: usize = core::mem::size_of::>(); +pub(crate) const OPCODE_COUNT: usize = core::mem::size_of::>(); + +const fn make_col_map() -> OpcodeSelectorCols { + let indices_arr = indices_arr::(); + unsafe { transmute::<[usize; OPCODE_COUNT], OpcodeSelectorCols>(indices_arr) } +} + +pub(crate) const SELECTOR_COL_MAP: OpcodeSelectorCols = make_col_map(); /// Selectors for the opcode. /// @@ -70,8 +80,10 @@ impl OpcodeSelectorCols { Opcode::TRAP => self.is_trap = F::one(), Opcode::HALT => self.is_halt = F::one(), Opcode::FRIFold => self.is_fri_fold = F::one(), + Opcode::Poseidon2Compress | Opcode::Poseidon2Absorb | Opcode::Poseidon2Finalize => { + self.is_poseidon = F::one() + } Opcode::ExpReverseBitsLen => self.is_exp_reverse_bits_len = F::one(), - Opcode::Poseidon2Compress => self.is_poseidon = F::one(), Opcode::Commit => self.is_commit = F::one(), Opcode::HintExt2Felt => self.is_ext_to_felt = F::one(), @@ -106,29 +118,10 @@ impl IntoIterator for &OpcodeSelectorCols { type IntoIter = std::array::IntoIter; fn into_iter(self) -> Self::IntoIter { - [ - self.is_add, - self.is_sub, - self.is_mul, - self.is_div, - self.is_ext, - self.is_load, - self.is_store, - self.is_beq, - self.is_bne, - self.is_bneinc, - self.is_jal, - self.is_jalr, - self.is_trap, - self.is_halt, - self.is_noop, - self.is_poseidon, - self.is_fri_fold, - self.is_commit, - self.is_ext_to_felt, - self.is_exp_reverse_bits_len, - self.is_heap_expand, - ] - .into_iter() + let mut array = [self.is_add; OPCODE_COUNT]; + let mut_ref: &mut OpcodeSelectorCols = array.as_mut_slice().borrow_mut(); + + *mut_ref = *self; + array.into_iter() } } diff --git a/recursion/core/src/cpu/trace.rs b/recursion/core/src/cpu/trace.rs index c07a355d04..2f47687a17 100644 --- a/recursion/core/src/cpu/trace.rs +++ b/recursion/core/src/cpu/trace.rs @@ -1,13 +1,5 @@ use std::borrow::BorrowMut; -use p3_field::{extension::BinomiallyExtendable, PrimeField32}; -use p3_matrix::{dense::RowMajorMatrix, Matrix}; -use sp1_core::{ - air::{BinomialExtension, MachineAir}, - utils::pad_rows_fixed, -}; -use tracing::instrument; - use crate::{ air::BinomialExtensionUtils, memory::MemoryCols, @@ -16,8 +8,18 @@ use crate::{ RecursionProgram, D, }, }; +use p3_field::{extension::BinomiallyExtendable, PrimeField32}; +use p3_matrix::dense::RowMajorMatrix; +use p3_maybe_rayon::prelude::IndexedParallelIterator; +use p3_maybe_rayon::prelude::ParallelIterator; +use p3_maybe_rayon::prelude::ParallelSliceMut; +use sp1_core::{ + air::{BinomialExtension, MachineAir}, + utils::{next_power_of_two, par_for_each_row}, +}; +use tracing::instrument; -use super::{CpuChip, CpuCols, CPU_COL_MAP, NUM_CPU_COLS}; +use super::{CpuChip, CpuCols, NUM_CPU_COLS}; impl, const L: usize> MachineAir for CpuChip { type Record = ExecutionRecord; @@ -37,114 +39,111 @@ impl, const L: usize> MachineAir fo input: &ExecutionRecord, _: &mut ExecutionRecord, ) -> RowMajorMatrix { - let mut rows = input - .cpu_events - .iter() - .map(|event| { - let mut row = [F::zero(); NUM_CPU_COLS]; - let cols: &mut CpuCols = row.as_mut_slice().borrow_mut(); - - cols.clk = event.clk; - cols.pc = event.pc; - cols.fp = event.fp; - - // Populate the instruction related columns. - cols.selectors.populate(&event.instruction); - cols.instruction.populate(&event.instruction); - - // Populate the register columns. - if let Some(record) = &event.a_record { - cols.a.populate(record); - } - if let Some(record) = &event.b_record { - cols.b.populate(record); - } else { - *cols.b.value_mut() = event.instruction.op_b; - } - if let Some(record) = &event.c_record { - cols.c.populate(record); + let nb_events = input.cpu_events.len(); + let padded_nb_rows = next_power_of_two(nb_events, self.fixed_log2_rows); + let mut values = vec![F::zero(); padded_nb_rows * NUM_CPU_COLS]; + + par_for_each_row(&mut values, NUM_CPU_COLS, |i, row| { + if i >= nb_events { + return; + } + let event = &input.cpu_events[i]; + let cols: &mut CpuCols = row.borrow_mut(); + + cols.clk = event.clk; + cols.pc = event.pc; + cols.fp = event.fp; + + // Populate the instruction related columns. + cols.selectors.populate(&event.instruction); + cols.instruction.populate(&event.instruction); + + // Populate the register columns. + if let Some(record) = &event.a_record { + cols.a.populate(record); + } + if let Some(record) = &event.b_record { + cols.b.populate(record); + } else { + *cols.b.value_mut() = event.instruction.op_b; + } + if let Some(record) = &event.c_record { + cols.c.populate(record); + } else { + *cols.c.value_mut() = event.instruction.op_c; + } + if let Some(record) = &event.memory_record { + let memory_cols = cols.opcode_specific.memory_mut(); + memory_cols.memory.populate(record); + memory_cols.memory_addr = record.addr; + } + + // Populate the heap columns. + if instruction_is_heap_expand(&event.instruction) { + let (u16_range_check, u12_range_check) = + get_heap_size_range_check_events(cols.a.value()[0]); + + let heap_cols = cols.opcode_specific.heap_expand_mut(); + heap_cols.diff_16bit_limb = F::from_canonical_u16(u16_range_check.val); + heap_cols.diff_12bit_limb = F::from_canonical_u16(u12_range_check.val); + } + + // Populate the branch columns. + if matches!( + event.instruction.opcode, + Opcode::BEQ | Opcode::BNE | Opcode::BNEINC + ) { + let branch_cols = cols.opcode_specific.branch_mut(); + let a_ext: BinomialExtension = + BinomialExtensionUtils::from_block(*cols.a.value()); + let b_ext: BinomialExtension = + BinomialExtensionUtils::from_block(*cols.b.value()); + + let (comparison_diff, do_branch) = match event.instruction.opcode { + Opcode::BEQ => (a_ext - b_ext, a_ext == b_ext), + Opcode::BNE | Opcode::BNEINC => (a_ext - b_ext, a_ext != b_ext), + _ => unreachable!(), + }; + + branch_cols + .comparison_diff + .populate((comparison_diff).as_block()); + branch_cols.comparison_diff_val = comparison_diff; + branch_cols.do_branch = F::from_bool(do_branch); + branch_cols.next_pc = if do_branch { + event.pc + event.instruction.op_c[0] } else { - *cols.c.value_mut() = event.instruction.op_c; - } - if let Some(record) = &event.memory_record { - let memory_cols = cols.opcode_specific.memory_mut(); - memory_cols.memory.populate(record); - memory_cols.memory_addr = record.addr; - } - - // Populate the heap columns. - if instruction_is_heap_expand(&event.instruction) { - let (u16_range_check, u12_range_check) = - get_heap_size_range_check_events(cols.a.value()[0]); - - let heap_cols = cols.opcode_specific.heap_expand_mut(); - heap_cols.diff_16bit_limb = F::from_canonical_u16(u16_range_check.val); - heap_cols.diff_12bit_limb = F::from_canonical_u16(u12_range_check.val); - } - - // Populate the branch columns. - if matches!( - event.instruction.opcode, - Opcode::BEQ | Opcode::BNE | Opcode::BNEINC - ) { - let branch_cols = cols.opcode_specific.branch_mut(); - let a_ext: BinomialExtension = - BinomialExtensionUtils::from_block(*cols.a.value()); - let b_ext: BinomialExtension = - BinomialExtensionUtils::from_block(*cols.b.value()); - - let (comparison_diff, do_branch) = match event.instruction.opcode { - Opcode::BEQ => (a_ext - b_ext, a_ext == b_ext), - Opcode::BNE | Opcode::BNEINC => (a_ext - b_ext, a_ext != b_ext), - _ => unreachable!(), - }; - - branch_cols - .comparison_diff - .populate((comparison_diff).as_block()); - branch_cols.comparison_diff_val = comparison_diff; - branch_cols.do_branch = F::from_bool(do_branch); - branch_cols.next_pc = if do_branch { - event.pc + event.instruction.op_c[0] - } else { - event.pc + F::one() - }; - } - - // Populate the public values columns. - if event.instruction.opcode == Opcode::Commit { - let public_values_cols = cols.opcode_specific.public_values_mut(); - let idx = cols.b.prev_value()[0].as_canonical_u32() as usize; - public_values_cols.idx_bitmap[idx] = F::one(); - } - - cols.is_real = F::one(); - row - }) - .collect::>(); - - pad_rows_fixed( - &mut rows, - || { - let mut row = [F::zero(); NUM_CPU_COLS]; - let cols: &mut CpuCols = row.as_mut_slice().borrow_mut(); - cols.selectors.is_noop = F::one(); - row - }, - self.fixed_log2_rows, - ); - - let mut trace = - RowMajorMatrix::new(rows.into_iter().flatten().collect::>(), NUM_CPU_COLS); - - for i in input.cpu_events.len()..trace.height() { - trace.values[i * NUM_CPU_COLS + CPU_COL_MAP.clk] = - F::from_canonical_u32(4) * F::from_canonical_usize(i); - trace.values[i * NUM_CPU_COLS + CPU_COL_MAP.instruction.imm_b] = - F::from_canonical_u32(1); - trace.values[i * NUM_CPU_COLS + CPU_COL_MAP.instruction.imm_c] = - F::from_canonical_u32(1); - } + event.pc + F::one() + }; + } + + // Populate the public values columns. + if event.instruction.opcode == Opcode::Commit { + let public_values_cols = cols.opcode_specific.public_values_mut(); + let idx = cols.b.prev_value()[0].as_canonical_u32() as usize; + public_values_cols.idx_bitmap[idx] = F::one(); + } + + cols.is_real = F::one(); + }); + + let mut trace = RowMajorMatrix::new(values, NUM_CPU_COLS); + + // Fill in the dummy values for the padding rows. + let padded_rows = trace + .values + .par_chunks_mut(NUM_CPU_COLS) + .enumerate() + .skip(input.cpu_events.len()); + padded_rows.for_each(|(i, row)| { + let cols: &mut CpuCols = row.borrow_mut(); + cols.selectors.is_noop = F::one(); + cols.instruction.imm_b = F::one(); + cols.instruction.imm_c = F::one(); + cols.clk = F::from_canonical_u32(4) * F::from_canonical_usize(i); + cols.instruction.imm_b = F::from_canonical_u32(1); + cols.instruction.imm_c = F::from_canonical_u32(1); + }); trace } diff --git a/recursion/core/src/exp_reverse_bits/mod.rs b/recursion/core/src/exp_reverse_bits/mod.rs index 790d745bcc..5bba68f6f5 100644 --- a/recursion/core/src/exp_reverse_bits/mod.rs +++ b/recursion/core/src/exp_reverse_bits/mod.rs @@ -4,7 +4,6 @@ use crate::air::{Block, IsZeroOperation, RecursionMemoryAirBuilder}; use crate::memory::{MemoryReadSingleCols, MemoryReadWriteSingleCols}; use crate::runtime::Opcode; use core::borrow::Borrow; -use itertools::Itertools; use p3_air::{Air, AirBuilder, BaseAir}; use p3_field::AbstractField; use p3_field::PrimeField32; @@ -12,7 +11,7 @@ use p3_matrix::dense::RowMajorMatrix; use p3_matrix::Matrix; use p3_util::reverse_bits_len; use sp1_core::air::{BaseAirBuilder, ExtensionAirBuilder, MachineAir, SP1AirBuilder}; -use sp1_core::utils::pad_rows_fixed; +use sp1_core::utils::{next_power_of_two, par_for_each_row}; use sp1_derive::AlignedBorrow; use std::borrow::BorrowMut; use tracing::instrument; @@ -102,7 +101,7 @@ impl ExpReverseBitsLenEvent { len: new_len, prev_accum, accum, - ptr: F::zero(), + ptr: F::from_canonical_u32(i), base_ptr: F::one(), iteration_num: F::from_canonical_u32(i), }); @@ -187,57 +186,48 @@ impl MachineAir for ExpReverseBitsLenCh input: &ExecutionRecord, _: &mut ExecutionRecord, ) -> RowMajorMatrix { - let mut rows = input - .exp_reverse_bits_len_events - .iter() - .map(|event| { - let mut row = [F::zero(); NUM_EXP_REVERSE_BITS_LEN_COLS]; - - let cols: &mut ExpReverseBitsLenCols = row.as_mut_slice().borrow_mut(); - - cols.clk = event.clk; - - cols.x.populate(&event.x); - cols.current_bit.populate(&event.current_bit); - cols.len = event.len; - cols.accum = event.accum; - cols.prev_accum_squared = event.prev_accum * event.prev_accum; - cols.is_last.populate(F::one() - event.len); - cols.is_first.populate(event.iteration_num); - cols.is_real = F::one(); - cols.iteration_num = event.iteration_num; - cols.multiplier = if event.current_bit.value - == Block([F::one(), F::zero(), F::zero(), F::zero()]) - { + let nb_events = input.exp_reverse_bits_len_events.len(); + let nb_rows = if self.pad { + next_power_of_two(nb_events, self.fixed_log2_rows) + } else { + nb_events + }; + let mut values = vec![F::zero(); nb_rows * NUM_EXP_REVERSE_BITS_LEN_COLS]; + + par_for_each_row(&mut values, NUM_EXP_REVERSE_BITS_LEN_COLS, |i, row| { + if i >= nb_events { + return; + } + let event = &input.exp_reverse_bits_len_events[i]; + let cols: &mut ExpReverseBitsLenCols = row.borrow_mut(); + + cols.clk = event.clk; + + cols.x.populate(&event.x); + cols.current_bit.populate(&event.current_bit); + cols.len = event.len; + cols.accum = event.accum; + cols.prev_accum_squared = event.prev_accum * event.prev_accum; + cols.is_last.populate(F::one() - event.len); + cols.is_first.populate(event.iteration_num); + cols.is_real = F::one(); + cols.iteration_num = event.iteration_num; + cols.multiplier = + if event.current_bit.value == Block([F::one(), F::zero(), F::zero(), F::zero()]) { // The event may change the value stored in the x memory access, and we need to // use the previous value. event.x.prev_value[0] } else { F::one() }; - cols.ptr = event.ptr; - cols.base_ptr = event.base_ptr; - cols.x_mem_access_flag = - F::from_bool(cols.len == F::one() || cols.iteration_num == F::zero()); - - row - }) - .collect_vec(); - - // Pad the trace to a power of two. - if self.pad { - pad_rows_fixed( - &mut rows, - || [F::zero(); NUM_EXP_REVERSE_BITS_LEN_COLS], - self.fixed_log2_rows, - ); - } + cols.ptr = event.ptr; + cols.base_ptr = event.base_ptr; + cols.x_mem_access_flag = + F::from_bool(cols.len == F::one() || cols.iteration_num == F::zero()); + }); // Convert the trace to a row major matrix. - let trace = RowMajorMatrix::new( - rows.into_iter().flatten().collect(), - NUM_EXP_REVERSE_BITS_LEN_COLS, - ); + let trace = RowMajorMatrix::new(values, NUM_EXP_REVERSE_BITS_LEN_COLS); #[cfg(debug_assertions)] println!( @@ -288,12 +278,31 @@ impl ExpReverseBitsLenChip { local.is_first.result, ); + // Make sure that local.is_first.result is not on for fake rows, so we don't receive operands + // for a fake row. + builder + .when_not(local.is_real) + .assert_zero(local.is_first.result); + IsZeroOperation::::eval( builder, AB::Expr::one() - local.len, local.is_last, local.is_real.into(), ); + + IsZeroOperation::::eval( + builder, + local.iteration_num.into(), + local.is_first, + local.is_real.into(), + ); + + // All real columns need to be in succession. + builder + .when_transition() + .assert_zero((AB::Expr::one() - local.is_real) * next.is_real); + // Assert that the boolean columns are boolean. builder.assert_bool(local.is_real); @@ -318,9 +327,15 @@ impl ExpReverseBitsLenChip { // Assert that the last real row has `is_last` on. builder + .when_transition() .when(local.is_real * (AB::Expr::one() - next.is_real)) .assert_one(local.is_last.result); + builder + .when_last_row() + .when(local.is_real) + .assert_one(local.is_last.result); + // `multiplier` is x if the current bit is 1, and 1 if the current bit is 0. builder .when(current_bit_val) @@ -331,10 +346,9 @@ impl ExpReverseBitsLenChip { .assert_eq(local.multiplier, AB::Expr::one()); // To get `next.accum`, we multiply `local.prev_accum_squared` by `local.multiplier` when not - // `is_last`. + // `is_first`. builder - .when_transition() - .when_not(local.is_last.result) + .when_not(local.is_first.result) .assert_eq(local.accum, local.prev_accum_squared * local.multiplier); // Constrain the accum_squared column. @@ -349,6 +363,14 @@ impl ExpReverseBitsLenChip { .when_not(local.is_last.result) .assert_eq(local.base_ptr, next.base_ptr); + // Constrain the memory address `ptr` to increment by one except when + // `is_last` + builder + .when_transition() + .when(next.is_real) + .when_not(local.is_last.result) + .assert_eq(next.ptr, local.ptr + AB::Expr::one()); + // The `len` counter must decrement when not `is_last`. builder .when_transition() @@ -383,6 +405,11 @@ impl ExpReverseBitsLenChip { - local.is_first.result * local.is_last.result, ); + // Make sure that x is only accessed when `is_real` is 1. + builder + .when_not(local.is_real) + .assert_zero(local.x_mem_access_flag); + // Access the memory for x. // This only needs to be done for the first and last iterations. builder.recursion_eval_memory_access_single( @@ -408,6 +435,13 @@ impl ExpReverseBitsLenChip { // Ensure that the value at the x memory access is unchanged when not `is_last`. builder + .when_transition() + .when(next.is_real) + .when_not(local.is_last.result) + .assert_eq(local.x.access.value, next.x.prev_value); + + builder + .when_transition() .when_not(local.is_last.result) .assert_eq(local.x.access.value, local.x.prev_value); diff --git a/recursion/core/src/fri_fold/mod.rs b/recursion/core/src/fri_fold/mod.rs index 7d68c81216..2631737920 100644 --- a/recursion/core/src/fri_fold/mod.rs +++ b/recursion/core/src/fri_fold/mod.rs @@ -1,17 +1,15 @@ #![allow(clippy::needless_range_loop)] -use crate::air::RecursionMemoryAirBuilder; use crate::memory::{MemoryReadCols, MemoryReadSingleCols, MemoryReadWriteCols}; use crate::runtime::Opcode; use core::borrow::Borrow; -use itertools::Itertools; use p3_air::{Air, AirBuilder, BaseAir}; use p3_field::AbstractField; use p3_field::PrimeField32; use p3_matrix::dense::RowMajorMatrix; use p3_matrix::Matrix; -use sp1_core::air::{BaseAirBuilder, BinomialExtension, ExtensionAirBuilder, MachineAir}; -use sp1_core::utils::pad_rows_fixed; +use sp1_core::air::{BaseAirBuilder, BinomialExtension, MachineAir}; +use sp1_core::utils::{next_power_of_two, par_for_each_row}; use sp1_derive::AlignedBorrow; use std::borrow::BorrowMut; use tracing::instrument; @@ -109,51 +107,46 @@ impl MachineAir for FriFoldChip input: &ExecutionRecord, _: &mut ExecutionRecord, ) -> RowMajorMatrix { - let mut rows = input - .fri_fold_events - .iter() - .map(|event| { - let mut row = [F::zero(); NUM_FRI_FOLD_COLS]; - - let cols: &mut FriFoldCols = row.as_mut_slice().borrow_mut(); - - cols.clk = event.clk; - cols.m = event.m; - cols.input_ptr = event.input_ptr; - cols.is_last_iteration = event.is_last_iteration; - cols.is_real = F::one(); - - cols.z.populate(&event.z); - cols.alpha.populate(&event.alpha); - cols.x.populate(&event.x); - cols.log_height.populate(&event.log_height); - cols.mat_opening_ptr.populate(&event.mat_opening_ptr); - cols.ps_at_z_ptr.populate(&event.ps_at_z_ptr); - cols.alpha_pow_ptr.populate(&event.alpha_pow_ptr); - cols.ro_ptr.populate(&event.ro_ptr); - - cols.p_at_x.populate(&event.p_at_x); - cols.p_at_z.populate(&event.p_at_z); - - cols.alpha_pow_at_log_height - .populate(&event.alpha_pow_at_log_height); - cols.ro_at_log_height.populate(&event.ro_at_log_height); - - row - }) - .collect_vec(); - - // Pad the trace to a power of two. - if self.pad { - pad_rows_fixed( - &mut rows, - || [F::zero(); NUM_FRI_FOLD_COLS], - self.fixed_log2_rows, - ); - } + let nb_events = input.fri_fold_events.len(); + let nb_rows = if self.pad { + next_power_of_two(nb_events, self.fixed_log2_rows) + } else { + nb_events + }; + let mut values = vec![F::zero(); nb_rows * NUM_FRI_FOLD_COLS]; + + par_for_each_row(&mut values, NUM_FRI_FOLD_COLS, |i, row| { + if i >= nb_events { + return; + } + let event = &input.fri_fold_events[i]; + let cols: &mut FriFoldCols = row.borrow_mut(); + + cols.clk = event.clk; + cols.m = event.m; + cols.input_ptr = event.input_ptr; + cols.is_last_iteration = event.is_last_iteration; + cols.is_real = F::one(); + + cols.z.populate(&event.z); + cols.alpha.populate(&event.alpha); + cols.x.populate(&event.x); + cols.log_height.populate(&event.log_height); + cols.mat_opening_ptr.populate(&event.mat_opening_ptr); + cols.ps_at_z_ptr.populate(&event.ps_at_z_ptr); + cols.alpha_pow_ptr.populate(&event.alpha_pow_ptr); + cols.ro_ptr.populate(&event.ro_ptr); + + cols.p_at_x.populate(&event.p_at_x); + cols.p_at_z.populate(&event.p_at_z); + + cols.alpha_pow_at_log_height + .populate(&event.alpha_pow_at_log_height); + cols.ro_at_log_height.populate(&event.ro_at_log_height); + }); // Convert the trace to a row major matrix. - let trace = RowMajorMatrix::new(rows.into_iter().flatten().collect(), NUM_FRI_FOLD_COLS); + let trace = RowMajorMatrix::new(values, NUM_FRI_FOLD_COLS); #[cfg(debug_assertions)] println!( @@ -171,7 +164,7 @@ impl MachineAir for FriFoldChip } impl FriFoldChip { - pub fn eval_fri_fold( + pub fn eval_fri_fold( &self, builder: &mut AB, local: &FriFoldCols, @@ -179,16 +172,6 @@ impl FriFoldChip { receive_table: AB::Var, memory_access: AB::Var, ) { - // Dummy constraints to normalize to DEGREE when DEGREE > 3. - if DEGREE > 3 { - let lhs = (0..DEGREE) - .map(|_| local.is_real.into()) - .product::(); - let rhs = (0..DEGREE) - .map(|_| local.is_real.into()) - .product::(); - builder.assert_eq(lhs, rhs); - } // Constraint that the operands are sent from the CPU table. let first_iteration_clk = local.clk.into() - local.m.into(); let total_num_iterations = local.m.into() + AB::Expr::one(); @@ -205,6 +188,26 @@ impl FriFoldChip { ); builder.assert_bool(local.is_last_iteration); + builder.assert_bool(local.is_real); + + builder + .when_transition() + .when_not(local.is_last_iteration) + .assert_eq(local.is_real, next.is_real); + + builder + .when(local.is_last_iteration) + .assert_one(local.is_real); + + builder + .when_transition() + .when_not(local.is_real) + .assert_zero(next.is_real); + + builder + .when_last_row() + .when_not(local.is_last_iteration) + .assert_zero(local.is_real); // Ensure that all first iteration rows has a m value of 0. builder.when_first_row().assert_zero(local.m); @@ -380,6 +383,16 @@ where let (local, next) = (main.row_slice(0), main.row_slice(1)); let local: &FriFoldCols = (*local).borrow(); let next: &FriFoldCols = (*next).borrow(); + + // Dummy constraints to normalize to DEGREE. + let lhs = (0..DEGREE) + .map(|_| local.is_real.into()) + .product::(); + let rhs = (0..DEGREE) + .map(|_| local.is_real.into()) + .product::(); + builder.assert_eq(lhs, rhs); + self.eval_fri_fold::( builder, local, diff --git a/recursion/core/src/lib.rs b/recursion/core/src/lib.rs index 785179fa77..f1c93c956d 100644 --- a/recursion/core/src/lib.rs +++ b/recursion/core/src/lib.rs @@ -4,7 +4,6 @@ pub mod exp_reverse_bits; pub mod fri_fold; pub mod memory; pub mod multi; -pub mod poseidon2; pub mod poseidon2_wide; pub mod program; pub mod range_check; diff --git a/recursion/core/src/memory/air.rs b/recursion/core/src/memory/air.rs index 9fe4161fac..33d7c19df1 100644 --- a/recursion/core/src/memory/air.rs +++ b/recursion/core/src/memory/air.rs @@ -1,16 +1,19 @@ use core::mem::size_of; -use p3_air::{Air, BaseAir}; -use p3_field::PrimeField32; +use p3_air::{Air, AirBuilder, BaseAir}; +use p3_field::{AbstractField, PrimeField32}; use p3_matrix::dense::RowMajorMatrix; use p3_matrix::Matrix; +use sp1_core::air::AirInteraction; use sp1_core::air::MachineAir; -use sp1_core::air::{AirInteraction, SP1AirBuilder}; use sp1_core::lookup::InteractionKind; -use sp1_core::utils::pad_rows_fixed; +use sp1_core::utils::next_power_of_two; +use sp1_core::utils::par_for_each_row; use std::borrow::{Borrow, BorrowMut}; use tracing::instrument; use super::columns::MemoryInitCols; +use crate::air::Block; +use crate::air::SP1RecursionAirBuilder; use crate::memory::MemoryGlobalChip; use crate::runtime::{ExecutionRecord, RecursionProgram}; @@ -40,56 +43,54 @@ impl MachineAir for MemoryGlobalChip { #[instrument(name = "generate memory trace", level = "debug", skip_all, fields(first_rows = input.first_memory_record.len(), last_rows = input.last_memory_record.len()))] fn generate_trace( &self, - input: &ExecutionRecord, - _output: &mut ExecutionRecord, + input: &Self::Record, + _output: &mut Self::Record, ) -> RowMajorMatrix { - let mut rows = Vec::new(); - - // Fill in the initial memory records. - rows.extend( - input - .first_memory_record - .iter() - .map(|(addr, value)| { - let mut row = [F::zero(); NUM_MEMORY_INIT_COLS]; - let cols: &mut MemoryInitCols = row.as_mut_slice().borrow_mut(); - cols.addr = *addr; - cols.timestamp = F::zero(); - cols.value = *value; - cols.is_initialize = F::one(); - row - }) - .collect::>(), - ); + let nb_events = input.first_memory_record.len() + input.last_memory_record.len(); + let nb_rows = next_power_of_two(nb_events, self.fixed_log2_rows); + let mut values = vec![F::zero(); nb_rows * NUM_MEMORY_INIT_COLS]; - // Fill in the finalize memory records. - rows.extend( - input - .last_memory_record - .iter() - .map(|(addr, timestamp, value)| { - let mut row = [F::zero(); NUM_MEMORY_INIT_COLS]; - let cols: &mut MemoryInitCols = row.as_mut_slice().borrow_mut(); - cols.addr = *addr; - cols.timestamp = *timestamp; - cols.value = *value; - cols.is_finalize = F::one(); - row - }) - .collect::>(), - ); + par_for_each_row(&mut values, NUM_MEMORY_INIT_COLS, |i, row| { + if i >= nb_events { + return; + } + let cols: &mut MemoryInitCols = row.borrow_mut(); - // Pad the trace to a power of two. - pad_rows_fixed( - &mut rows, - || [F::zero(); NUM_MEMORY_INIT_COLS], - self.fixed_log2_rows, - ); + if i < input.first_memory_record.len() { + let (addr, value) = &input.first_memory_record[i]; + cols.addr = *addr; + cols.timestamp = F::zero(); + cols.value = *value; + cols.is_initialize = F::one(); + + cols.is_real = F::one(); + } else { + let (addr, timestamp, value) = + &input.last_memory_record[i - input.first_memory_record.len()]; + let last = i == nb_events - 1; + let (next_addr, _, _) = if last { + &(F::zero(), F::zero(), Block::from(F::zero())) + } else { + &input.last_memory_record[i - input.first_memory_record.len() + 1] + }; + cols.addr = *addr; + cols.timestamp = *timestamp; + cols.value = *value; + cols.is_finalize = F::one(); + (cols.diff_16bit_limb, cols.diff_12bit_limb) = if !last { + compute_addr_diff(*next_addr, *addr, true) + } else { + (F::zero(), F::zero()) + }; + (cols.addr_16bit_limb, cols.addr_12bit_limb) = + compute_addr_diff(*addr, F::zero(), false); + + cols.is_real = F::one(); + cols.is_range_check = F::from_bool(!last); + } + }); - RowMajorMatrix::new( - rows.into_iter().flatten().collect::>(), - NUM_MEMORY_INIT_COLS, - ) + RowMajorMatrix::new(values, NUM_MEMORY_INIT_COLS) } fn included(&self, shard: &Self::Record) -> bool { @@ -103,19 +104,95 @@ impl BaseAir for MemoryGlobalChip { } } +/// Computes the difference between the `addr` and `prev_addr` and returns the 16-bit limb and 12-bit +/// limbs of the difference. +/// +/// The parameter `subtract_one` is expected to be `true` when `addr` and `prev_addr` are consecutive +/// addresses in the global memory table (we don't allow repeated addresses), and `false` when this +/// function is used to perform the 28-bit range check on the `addr` field. +pub fn compute_addr_diff(addr: F, prev_addr: F, subtract_one: bool) -> (F, F) { + let diff = addr.as_canonical_u32() - prev_addr.as_canonical_u32() - subtract_one as u32; + let diff_16bit_limb = diff & 0xffff; + let diff_12bit_limb = (diff >> 16) & 0xfff; + ( + F::from_canonical_u32(diff_16bit_limb), + F::from_canonical_u32(diff_12bit_limb), + ) +} + impl Air for MemoryGlobalChip where - AB: SP1AirBuilder, + AB: SP1RecursionAirBuilder, { fn eval(&self, builder: &mut AB) { let main = builder.main(); let local = main.row_slice(0); + let next = main.row_slice(1); let local: &MemoryInitCols = (*local).borrow(); + let next: &MemoryInitCols = (*next).borrow(); - // Verify that is_initialize and is_finalize are bool and that at most one is true. + // Verify that is_initialize and is_finalize and 1-is_real are bool and that at most one + // is true. builder.assert_bool(local.is_initialize); builder.assert_bool(local.is_finalize); - builder.assert_bool(local.is_initialize + local.is_finalize); + builder.assert_bool(local.is_real); + builder.assert_bool( + local.is_initialize + local.is_finalize + (AB::Expr::one() - local.is_real), + ); + builder.assert_bool(local.is_range_check); + + // Assert the is_initialize rows come before the is_finalize rows, and those come before the + // padding rows. + // The first row should be an initialize row. + builder.when_first_row().assert_one(local.is_initialize); + + // After an initialize row, we should either have a finalize row, or another initialize row. + builder + .when_transition() + .when(local.is_initialize) + .assert_one(next.is_initialize + next.is_finalize); + + // After a finalize row, we should either have a finalize row, or a padding row. + builder + .when_transition() + .when(local.is_finalize) + .assert_one(next.is_finalize + (AB::Expr::one() - next.is_real)); + + // After a padding row, we should only have another padding row. + builder + .when_transition() + .when(AB::Expr::one() - local.is_real) + .assert_zero(next.is_real); + + // The last row should be a padding row or a finalize row. + builder + .when_last_row() + .assert_one(local.is_finalize + AB::Expr::one() - local.is_real); + + // Ensure that the is_range_check column is properly computed. + // The flag column `is_range_check` is set iff is_finalize is set AND next.is_finalize is set. + builder + .when(local.is_range_check) + .assert_one(local.is_finalize * next.is_finalize); + builder + .when_not(local.is_range_check) + .assert_zero(local.is_finalize * next.is_finalize); + + // Send requests for the 28-bit range checks and ensure that the limbs are correctly + // computed. + builder.eval_range_check_28bits( + next.addr - local.addr - AB::Expr::one(), + local.diff_16bit_limb, + local.diff_12bit_limb, + local.is_range_check, + ); + + builder.eval_range_check_28bits( + local.addr, + local.addr_16bit_limb, + local.addr_12bit_limb, + local.is_finalize, + ); builder.send(AirInteraction::new( vec![ @@ -143,3 +220,75 @@ where )); } } + +#[cfg(test)] +mod tests { + use itertools::Itertools; + use std::time::Instant; + + use p3_baby_bear::BabyBear; + use p3_baby_bear::DiffusionMatrixBabyBear; + use p3_field::AbstractField; + use p3_matrix::{dense::RowMajorMatrix, Matrix}; + use p3_poseidon2::Poseidon2; + use p3_poseidon2::Poseidon2ExternalMatrixGeneral; + use sp1_core::stark::StarkGenericConfig; + use sp1_core::{ + air::MachineAir, + utils::{uni_stark_prove, uni_stark_verify, BabyBearPoseidon2}, + }; + + use crate::air::Block; + use crate::memory::MemoryGlobalChip; + use crate::runtime::ExecutionRecord; + + #[test] + fn prove_babybear() { + let config = BabyBearPoseidon2::compressed(); + let mut challenger = config.challenger(); + + let chip = MemoryGlobalChip { + fixed_log2_rows: None, + }; + + let test_vals = (0..16).map(BabyBear::from_canonical_u32).collect_vec(); + + let mut input_exec = ExecutionRecord::::default(); + for val in test_vals.into_iter() { + let event = (val, val, Block::from(BabyBear::zero())); + input_exec.last_memory_record.push(event); + } + + // Add a dummy initialize event because the AIR expects at least one. + input_exec + .first_memory_record + .push((BabyBear::zero(), Block::from(BabyBear::zero()))); + + println!("input exec: {:?}", input_exec.last_memory_record.len()); + let trace: RowMajorMatrix = + chip.generate_trace(&input_exec, &mut ExecutionRecord::::default()); + println!( + "trace dims is width: {:?}, height: {:?}", + trace.width(), + trace.height() + ); + + let start = Instant::now(); + let proof = uni_stark_prove(&config, &chip, &mut challenger, trace); + let duration = start.elapsed().as_secs_f64(); + println!("proof duration = {:?}", duration); + + let mut challenger: p3_challenger::DuplexChallenger< + BabyBear, + Poseidon2, + 16, + 8, + > = config.challenger(); + let start = Instant::now(); + uni_stark_verify(&config, &chip, &mut challenger, &proof) + .expect("expected proof to be valid"); + + let duration = start.elapsed().as_secs_f64(); + println!("verify duration = {:?}", duration); + } +} diff --git a/recursion/core/src/memory/columns.rs b/recursion/core/src/memory/columns.rs index 2a3a084504..0b83afa1e4 100644 --- a/recursion/core/src/memory/columns.rs +++ b/recursion/core/src/memory/columns.rs @@ -1,3 +1,4 @@ +use p3_field::PrimeField32; use sp1_derive::AlignedBorrow; use crate::air::Block; @@ -10,6 +11,41 @@ pub struct MemoryInitCols { pub value: Block, pub is_initialize: T, pub is_finalize: T, + + /// This column is the least significant 16 bit limb of next_address - current_address. + pub diff_16bit_limb: T, + + /// This column is the most signficant 8 bit limb of next_address - current_addres. + pub diff_12bit_limb: T, + + /// Same for the address column. + pub addr_16bit_limb: T, + pub addr_12bit_limb: T, + + // An additional column to indicate if the memory row is a padded row. + pub is_real: T, + + // A flag column for when range checks need to be applied to the diff columns. Range checks always + // need to be applied to the address columns. + pub is_range_check: T, +} + +impl MemoryInitCols { + pub fn new() -> Self { + Self { + addr: T::zero(), + timestamp: T::zero(), + value: Block::from([T::zero(); 4]), + is_initialize: T::zero(), + is_finalize: T::zero(), + diff_16bit_limb: T::zero(), + diff_12bit_limb: T::zero(), + addr_16bit_limb: T::zero(), + addr_12bit_limb: T::zero(), + is_real: T::zero(), + is_range_check: T::zero(), + } + } } /// NOTE: These are very similar to core/src/memory/columns.rs diff --git a/recursion/core/src/memory/mod.rs b/recursion/core/src/memory/mod.rs index 834de2e7a0..08e56fb0cf 100644 --- a/recursion/core/src/memory/mod.rs +++ b/recursion/core/src/memory/mod.rs @@ -4,6 +4,7 @@ mod columns; use p3_field::PrimeField32; use crate::air::Block; +pub use air::compute_addr_diff; pub use columns::*; #[allow(clippy::manual_non_exhaustive)] diff --git a/recursion/core/src/multi/mod.rs b/recursion/core/src/multi/mod.rs index 0b93f52aa2..c028fd5450 100644 --- a/recursion/core/src/multi/mod.rs +++ b/recursion/core/src/multi/mod.rs @@ -1,8 +1,11 @@ +use std::array; use std::borrow::{Borrow, BorrowMut}; +use std::cmp::max; +use std::ops::Deref; use itertools::Itertools; use p3_air::{Air, AirBuilder, BaseAir}; -use p3_field::PrimeField32; +use p3_field::{AbstractField, PrimeField32}; use p3_matrix::dense::RowMajorMatrix; use p3_matrix::Matrix; use sp1_core::air::{BaseAirBuilder, MachineAir}; @@ -11,7 +14,8 @@ use sp1_derive::AlignedBorrow; use crate::air::{MultiBuilder, SP1RecursionAirBuilder}; use crate::fri_fold::{FriFoldChip, FriFoldCols}; -use crate::poseidon2::{Poseidon2Chip, Poseidon2Cols}; +use crate::poseidon2_wide::columns::Poseidon2; +use crate::poseidon2_wide::{Poseidon2WideChip, WIDTH}; use crate::runtime::{ExecutionRecord, RecursionProgram}; pub const NUM_MULTI_COLS: usize = core::mem::size_of::>(); @@ -24,27 +28,39 @@ pub struct MultiChip { #[derive(AlignedBorrow, Clone, Copy)] #[repr(C)] pub struct MultiCols { - pub instruction: InstructionSpecificCols, - pub is_fri_fold: T, + + /// Rows that needs to receive a fri_fold syscall. pub fri_fold_receive_table: T, + /// Rows that needs to access memory. pub fri_fold_memory_access: T, pub is_poseidon2: T, - pub poseidon2_receive_table: T, - pub poseidon2_memory_access: T, -} -#[derive(Clone, Copy)] -#[repr(C)] -pub union InstructionSpecificCols { - fri_fold: FriFoldCols, - poseidon2: Poseidon2Cols, + /// A flag column to indicate whether the row is the first poseidon2 row. + pub poseidon2_first_row: T, + /// A flag column to indicate whether the row is the last poseidon2 row. + pub poseidon2_last_row: T, + + /// Similar for Fri_fold. + pub fri_fold_last_row: T, + + /// Rows that needs to receive a poseidon2 syscall. + pub poseidon2_receive_table: T, + /// Hash/Permute state entries that needs to access memory. This is for the the first half of the permute state. + pub poseidon2_1st_half_memory_access: [T; WIDTH / 2], + /// Flag to indicate if all of the second half of a compress state needs to access memory. + pub poseidon2_2nd_half_memory_access: T, + /// Rows that need to send a range check. + pub poseidon2_send_range_check: T, } impl BaseAir for MultiChip { fn width(&self) -> usize { - NUM_MULTI_COLS + let fri_fold_width = Self::fri_fold_width::(); + let poseidon2_width = Self::poseidon2_width::(); + + max(fri_fold_width, poseidon2_width) + NUM_MULTI_COLS } } @@ -57,50 +73,70 @@ impl MachineAir for MultiChip { "Multi".to_string() } - fn generate_dependencies(&self, _: &Self::Record, _: &mut Self::Record) { - // This is a no-op. - } - fn generate_trace( &self, input: &ExecutionRecord, output: &mut ExecutionRecord, ) -> RowMajorMatrix { - let fri_fold_chip = FriFoldChip::<3> { + let fri_fold_chip = FriFoldChip:: { fixed_log2_rows: None, pad: false, }; - let poseidon2 = Poseidon2Chip { + let poseidon2 = Poseidon2WideChip:: { fixed_log2_rows: None, pad: false, }; let fri_fold_trace = fri_fold_chip.generate_trace(input, output); let mut poseidon2_trace = poseidon2.generate_trace(input, output); + let fri_fold_height = fri_fold_trace.height(); + let poseidon2_height = poseidon2_trace.height(); + + let num_columns = as BaseAir>::width(self); + let mut rows = fri_fold_trace .clone() .rows_mut() .chain(poseidon2_trace.rows_mut()) .enumerate() .map(|(i, instruction_row)| { - let mut row = [F::zero(); NUM_MULTI_COLS]; - row[0..instruction_row.len()].copy_from_slice(instruction_row); - let cols: &mut MultiCols = row.as_mut_slice().borrow_mut(); - if i < fri_fold_trace.height() { - cols.is_fri_fold = F::one(); - - let fri_fold_cols = *cols.fri_fold(); - cols.fri_fold_receive_table = - FriFoldChip::<3>::do_receive_table(&fri_fold_cols); - cols.fri_fold_memory_access = - FriFoldChip::<3>::do_memory_access(&fri_fold_cols); + let process_fri_fold = i < fri_fold_trace.height(); + + let mut row = vec![F::zero(); num_columns]; + row[NUM_MULTI_COLS..NUM_MULTI_COLS + instruction_row.len()] + .copy_from_slice(instruction_row); + + if process_fri_fold { + let multi_cols: &mut MultiCols = row[0..NUM_MULTI_COLS].borrow_mut(); + multi_cols.is_fri_fold = F::one(); + + let fri_fold_cols: &FriFoldCols = (*instruction_row).borrow(); + multi_cols.fri_fold_receive_table = + FriFoldChip::::do_receive_table(fri_fold_cols); + multi_cols.fri_fold_memory_access = + FriFoldChip::::do_memory_access(fri_fold_cols); + if i == fri_fold_trace.height() - 1 { + multi_cols.fri_fold_last_row = F::one(); + } } else { - cols.is_poseidon2 = F::one(); - - let poseidon2_cols = *cols.poseidon2(); - cols.poseidon2_receive_table = Poseidon2Chip::do_receive_table(&poseidon2_cols); - cols.poseidon2_memory_access = Poseidon2Chip::do_memory_access(&poseidon2_cols); + let multi_cols: &mut MultiCols = row[0..NUM_MULTI_COLS].borrow_mut(); + multi_cols.is_poseidon2 = F::one(); + + let poseidon2_cols = Poseidon2WideChip::::convert::(instruction_row); + multi_cols.poseidon2_receive_table = + poseidon2_cols.control_flow().is_syscall_row; + multi_cols.poseidon2_1st_half_memory_access = + array::from_fn(|i| poseidon2_cols.memory().memory_slot_used[i]); + multi_cols.poseidon2_2nd_half_memory_access = + poseidon2_cols.control_flow().is_compress; + multi_cols.poseidon2_send_range_check = poseidon2_cols.control_flow().is_absorb; + + // The first row of the poseidon2 trace has index fri_fold_trace.height() + multi_cols.poseidon2_first_row = F::from_bool(i == fri_fold_height); + multi_cols.poseidon2_last_row = + F::from_bool(i == fri_fold_height + poseidon2_height - 1); } + row }) .collect_vec(); @@ -108,12 +144,12 @@ impl MachineAir for MultiChip { // Pad the trace to a power of two. pad_rows_fixed( &mut rows, - || [F::zero(); NUM_MULTI_COLS], + || vec![F::zero(); num_columns], self.fixed_log2_rows, ); // Convert the trace to a row major matrix. - RowMajorMatrix::new(rows.into_iter().flatten().collect(), NUM_MULTI_COLS) + RowMajorMatrix::new(rows.into_iter().flatten().collect(), num_columns) } fn included(&self, _: &Self::Record) -> bool { @@ -124,28 +160,65 @@ impl MachineAir for MultiChip { impl Air for MultiChip where AB: SP1RecursionAirBuilder, + AB::Var: 'static, { fn eval(&self, builder: &mut AB) { let main = builder.main(); let (local, next) = (main.row_slice(0), main.row_slice(1)); - let local: &MultiCols = (*local).borrow(); - let next: &MultiCols = (*next).borrow(); - // Add some dummy constraints to compress the interactions. - let mut expr = local.is_fri_fold * local.is_fri_fold; - for _ in 0..(DEGREE - 2) { - expr *= local.is_fri_fold.into(); - } - builder.assert_eq(expr.clone(), expr.clone()); + let local_slice: &[::Var] = &local; + let next_slice: &[::Var] = &next; + let local_multi_cols: &MultiCols = local_slice[0..NUM_MULTI_COLS].borrow(); + let next_multi_cols: &MultiCols = next_slice[0..NUM_MULTI_COLS].borrow(); - let next_is_real = next.is_fri_fold + next.is_poseidon2; - let local_is_real = local.is_fri_fold + local.is_poseidon2; + // Dummy constraints to normalize to DEGREE. + let lhs = (0..DEGREE) + .map(|_| local_multi_cols.is_poseidon2.into()) + .product::(); + let rhs = (0..DEGREE) + .map(|_| local_multi_cols.is_poseidon2.into()) + .product::(); + builder.assert_eq(lhs, rhs); + + let next_is_real = next_multi_cols.is_fri_fold + next_multi_cols.is_poseidon2; + let local_is_real = local_multi_cols.is_fri_fold + local_multi_cols.is_poseidon2; // Assert that is_fri_fold and is_poseidon2 are bool and that at most one is set. - builder.assert_bool(local.is_fri_fold); - builder.assert_bool(local.is_poseidon2); + builder.assert_bool(local_multi_cols.is_fri_fold); + builder.assert_bool(local_multi_cols.is_poseidon2); builder.assert_bool(local_is_real.clone()); + // Constrain the flags to be boolean. + builder.assert_bool(local_multi_cols.poseidon2_first_row); + builder.assert_bool(local_multi_cols.poseidon2_last_row); + builder.assert_bool(local_multi_cols.fri_fold_last_row); + + // Constrain that the flags are computed correctly. + builder.when_transition().assert_eq( + local_multi_cols.is_fri_fold * (AB::Expr::one() - next_multi_cols.is_fri_fold), + local_multi_cols.fri_fold_last_row, + ); + builder.when_last_row().assert_eq( + local_multi_cols.is_fri_fold, + local_multi_cols.fri_fold_last_row, + ); + builder.when_first_row().assert_eq( + local_multi_cols.is_poseidon2, + local_multi_cols.poseidon2_first_row, + ); + builder.when_transition().assert_eq( + next_multi_cols.poseidon2_first_row, + local_multi_cols.is_fri_fold * next_multi_cols.is_poseidon2, + ); + builder.when_transition().assert_eq( + local_multi_cols.is_poseidon2 * (AB::Expr::one() - next_multi_cols.is_poseidon2), + local_multi_cols.poseidon2_last_row, + ); + builder.when_last_row().assert_eq( + local_multi_cols.is_poseidon2, + local_multi_cols.poseidon2_last_row, + ); + // Fri fold requires that it's rows are contiguous, since each invocation spans multiple rows // and it's AIR checks for consistencies among them. The following constraints enforce that // all the fri fold rows are first, then the posiedon2 rows, and finally any padded (non-real) rows. @@ -160,119 +233,147 @@ where builder .when_transition() .when(next_is_real) - .when(local.is_poseidon2) - .assert_one(next.is_poseidon2); + .when(local_multi_cols.is_poseidon2) + .assert_one(next_multi_cols.is_poseidon2); + + let mut sub_builder = MultiBuilder::new( + builder, + local_multi_cols.is_fri_fold.into(), + builder.is_first_row(), + local_multi_cols.fri_fold_last_row.into(), + next_multi_cols.is_fri_fold.into(), + ); - let mut sub_builder = - MultiBuilder::new(builder, local.is_fri_fold.into(), next.is_fri_fold.into()); + let local_fri_fold_cols = Self::fri_fold(&local); + let next_fri_fold_cols = Self::fri_fold(&next); - let fri_columns_local = local.fri_fold(); sub_builder.assert_eq( - local.is_fri_fold * FriFoldChip::<3>::do_memory_access::(fri_columns_local), - local.fri_fold_memory_access, + local_multi_cols.is_fri_fold + * FriFoldChip::::do_memory_access::(&local_fri_fold_cols), + local_multi_cols.fri_fold_memory_access, ); sub_builder.assert_eq( - local.is_fri_fold * FriFoldChip::<3>::do_receive_table::(fri_columns_local), - local.fri_fold_receive_table, + local_multi_cols.is_fri_fold + * FriFoldChip::::do_receive_table::(&local_fri_fold_cols), + local_multi_cols.fri_fold_receive_table, ); - let fri_fold_chip = FriFoldChip::<3>::default(); + let fri_fold_chip = FriFoldChip::::default(); fri_fold_chip.eval_fri_fold( &mut sub_builder, - local.fri_fold(), - next.fri_fold(), - local.fri_fold_receive_table, - local.fri_fold_memory_access, + &local_fri_fold_cols, + &next_fri_fold_cols, + local_multi_cols.fri_fold_receive_table, + local_multi_cols.fri_fold_memory_access, ); - let mut sub_builder = - MultiBuilder::new(builder, local.is_poseidon2.into(), next.is_poseidon2.into()); + let mut sub_builder = MultiBuilder::new( + builder, + local_multi_cols.is_poseidon2.into(), + local_multi_cols.poseidon2_first_row.into(), + local_multi_cols.poseidon2_last_row.into(), + next_multi_cols.is_poseidon2.into(), + ); - let poseidon2_columns = local.poseidon2(); + let poseidon2_columns = MultiChip::::poseidon2(local_slice); sub_builder.assert_eq( - local.is_poseidon2 * Poseidon2Chip::do_receive_table::(poseidon2_columns), - local.poseidon2_receive_table, + local_multi_cols.is_poseidon2 * poseidon2_columns.control_flow().is_syscall_row, + local_multi_cols.poseidon2_receive_table, ); + local_multi_cols + .poseidon2_1st_half_memory_access + .iter() + .enumerate() + .for_each(|(i, mem_access)| { + sub_builder.assert_eq( + local_multi_cols.is_poseidon2 * poseidon2_columns.memory().memory_slot_used[i], + *mem_access, + ); + }); + sub_builder.assert_eq( - local.is_poseidon2 * Poseidon2Chip::do_memory_access::(poseidon2_columns), - local.poseidon2_memory_access, + local_multi_cols.is_poseidon2 * poseidon2_columns.control_flow().is_compress, + local_multi_cols.poseidon2_2nd_half_memory_access, ); - let poseidon2_chip = Poseidon2Chip::default(); + sub_builder.assert_eq( + local_multi_cols.is_poseidon2 * poseidon2_columns.control_flow().is_absorb, + local_multi_cols.poseidon2_send_range_check, + ); + + let poseidon2_chip = Poseidon2WideChip::::default(); poseidon2_chip.eval_poseidon2( &mut sub_builder, - local.poseidon2(), - next.poseidon2(), - local.poseidon2_receive_table, - local.poseidon2_memory_access, + poseidon2_columns.as_ref(), + MultiChip::::poseidon2(next_slice).as_ref(), + local_multi_cols.poseidon2_receive_table, + local_multi_cols.poseidon2_1st_half_memory_access, + local_multi_cols.poseidon2_2nd_half_memory_access, + local_multi_cols.poseidon2_send_range_check, ); } } -// SAFETY: Each view is a valid interpretation of the underlying array. -impl MultiCols { - pub fn fri_fold(&self) -> &FriFoldCols { - unsafe { &self.instruction.fri_fold } + +impl MultiChip { + fn fri_fold_width() -> usize { + as BaseAir>::width(&FriFoldChip::::default()) + } + + fn fri_fold(row: &dyn Deref) -> FriFoldCols { + let row_slice: &[T] = row; + let fri_fold_width = Self::fri_fold_width::(); + let fri_fold_cols: &FriFoldCols = + (row_slice[NUM_MULTI_COLS..NUM_MULTI_COLS + fri_fold_width]).borrow(); + + *fri_fold_cols + } + + fn poseidon2_width() -> usize { + as BaseAir>::width(&Poseidon2WideChip::::default()) } - pub fn poseidon2(&self) -> &Poseidon2Cols { - unsafe { &self.instruction.poseidon2 } + fn poseidon2<'a, T>(row: impl Deref) -> Box + 'a> + where + T: Copy + 'a, + { + let row_slice: &[T] = &row; + let poseidon2_width = Self::poseidon2_width::(); + + Poseidon2WideChip::::convert::( + &row_slice[NUM_MULTI_COLS..NUM_MULTI_COLS + poseidon2_width], + ) } } #[cfg(test)] mod tests { - use itertools::Itertools; use std::time::Instant; use p3_baby_bear::BabyBear; use p3_baby_bear::DiffusionMatrixBabyBear; - use p3_field::AbstractField; use p3_matrix::{dense::RowMajorMatrix, Matrix}; use p3_poseidon2::Poseidon2; use p3_poseidon2::Poseidon2ExternalMatrixGeneral; use sp1_core::stark::StarkGenericConfig; - use sp1_core::utils::inner_perm; use sp1_core::{ air::MachineAir, utils::{uni_stark_prove, uni_stark_verify, BabyBearPoseidon2}, }; use crate::multi::MultiChip; - use crate::{poseidon2::Poseidon2Event, runtime::ExecutionRecord}; - use p3_symmetric::Permutation; + use crate::poseidon2_wide::tests::generate_test_execution_record; + use crate::runtime::ExecutionRecord; #[test] fn prove_babybear() { let config = BabyBearPoseidon2::compressed(); let mut challenger = config.challenger(); - let chip = MultiChip::<5> { + let chip = MultiChip::<9> { fixed_log2_rows: None, }; - let test_inputs = (0..16) - .map(|i| [BabyBear::from_canonical_u32(i); 16]) - .collect_vec(); - - let gt: Poseidon2< - BabyBear, - Poseidon2ExternalMatrixGeneral, - DiffusionMatrixBabyBear, - 16, - 7, - > = inner_perm(); - - let expected_outputs = test_inputs - .iter() - .map(|input| gt.permute(*input)) - .collect::>(); - - let mut input_exec = ExecutionRecord::::default(); - for (input, output) in test_inputs.into_iter().zip_eq(expected_outputs) { - input_exec - .poseidon2_events - .push(Poseidon2Event::dummy_from_input(input, output)); - } + let input_exec = generate_test_execution_record(false); let trace: RowMajorMatrix = chip.generate_trace(&input_exec, &mut ExecutionRecord::::default()); println!( diff --git a/recursion/core/src/poseidon2/columns.rs b/recursion/core/src/poseidon2/columns.rs deleted file mode 100644 index fa12a655f2..0000000000 --- a/recursion/core/src/poseidon2/columns.rs +++ /dev/null @@ -1,62 +0,0 @@ -use sp1_derive::AlignedBorrow; - -use crate::{memory::MemoryReadWriteSingleCols, poseidon2_wide::external::WIDTH}; - -/// The column layout for the chip. -#[derive(AlignedBorrow, Clone, Copy)] -#[repr(C)] -pub struct Poseidon2Cols { - pub clk: T, - pub dst_input: T, - pub left_input: T, - pub right_input: T, - pub rounds: [T; 24], // 1 round for memory input; 1 round for initialize; 8 rounds for external; 13 rounds for internal; 1 round for memory output - pub do_receive: T, - pub do_memory: T, - pub round_specific_cols: RoundSpecificCols, - pub is_real: T, -} - -#[derive(AlignedBorrow, Clone, Copy)] -#[repr(C)] -pub union RoundSpecificCols { - computation: ComputationCols, - memory_access: MemAccessCols, -} - -// SAFETY: Each view is a valid interpretation of the underlying array. -impl RoundSpecificCols { - pub fn computation(&self) -> &ComputationCols { - unsafe { &self.computation } - } - - pub fn computation_mut(&mut self) -> &mut ComputationCols { - unsafe { &mut self.computation } - } - - pub fn memory_access(&self) -> &MemAccessCols { - unsafe { &self.memory_access } - } - - pub fn memory_access_mut(&mut self) -> &mut MemAccessCols { - unsafe { &mut self.memory_access } - } -} - -#[derive(AlignedBorrow, Clone, Copy)] -#[repr(C)] -pub struct ComputationCols { - pub input: [T; WIDTH], - pub add_rc: [T; WIDTH], - pub sbox_deg_3: [T; WIDTH], - pub sbox_deg_7: [T; WIDTH], - pub output: [T; WIDTH], -} - -#[derive(AlignedBorrow, Clone, Copy)] -#[repr(C)] -pub struct MemAccessCols { - pub addr_first_half: T, - pub addr_second_half: T, - pub mem_access: [MemoryReadWriteSingleCols; WIDTH], -} diff --git a/recursion/core/src/poseidon2/external.rs b/recursion/core/src/poseidon2/external.rs deleted file mode 100644 index 21f56edb0b..0000000000 --- a/recursion/core/src/poseidon2/external.rs +++ /dev/null @@ -1,572 +0,0 @@ -use core::borrow::Borrow; -use core::mem::size_of; -use p3_air::AirBuilder; -use p3_air::{Air, BaseAir}; -use p3_field::AbstractField; -use p3_matrix::Matrix; -use sp1_core::air::{BaseAirBuilder, ExtensionAirBuilder, SP1AirBuilder}; -use sp1_primitives::RC_16_30_U32; - -use crate::air::{RecursionInteractionAirBuilder, RecursionMemoryAirBuilder}; -use crate::memory::MemoryCols; -use crate::poseidon2_wide::{apply_m_4, internal_linear_layer}; -use crate::runtime::Opcode; - -use super::columns::Poseidon2Cols; - -/// The number of main trace columns for `AddChip`. -pub const NUM_POSEIDON2_COLS: usize = size_of::>(); - -/// The width of the permutation. -pub const WIDTH: usize = 16; - -/// A chip that implements addition for the opcode ADD. -#[derive(Default)] -pub struct Poseidon2Chip { - pub fixed_log2_rows: Option, - pub pad: bool, -} - -impl BaseAir for Poseidon2Chip { - fn width(&self) -> usize { - NUM_POSEIDON2_COLS - } -} - -impl Poseidon2Chip { - pub fn eval_poseidon2( - &self, - builder: &mut AB, - local: &Poseidon2Cols, - next: &Poseidon2Cols, - receive_table: AB::Var, - memory_access: AB::Var, - ) { - const NUM_ROUNDS_F: usize = 8; - const NUM_ROUNDS_P: usize = 13; - const ROUNDS_F_1_BEGINNING: usize = 2; // Previous rounds are memory read and initial. - const ROUNDS_P_BEGINNING: usize = ROUNDS_F_1_BEGINNING + NUM_ROUNDS_F / 2; - const ROUNDS_P_END: usize = ROUNDS_P_BEGINNING + NUM_ROUNDS_P; - const ROUND_F_2_END: usize = ROUNDS_P_END + NUM_ROUNDS_F / 2; - - let is_memory_read = local.rounds[0]; - let is_initial = local.rounds[1]; - - // First half of the external rounds. - let mut is_external_layer = (ROUNDS_F_1_BEGINNING..ROUNDS_P_BEGINNING) - .map(|i| local.rounds[i].into()) - .sum::(); - - // Second half of the external rounds. - is_external_layer += (ROUNDS_P_END..ROUND_F_2_END) - .map(|i| local.rounds[i].into()) - .sum::(); - let is_internal_layer = (ROUNDS_P_BEGINNING..ROUNDS_P_END) - .map(|i| local.rounds[i].into()) - .sum::(); - let is_memory_write = local.rounds[local.rounds.len() - 1]; - - self.eval_control_flow_and_inputs(builder, local, next); - - self.eval_syscall(builder, local, receive_table); - - self.eval_mem( - builder, - local, - next, - is_memory_read, - is_memory_write, - memory_access, - ); - - self.eval_computation( - builder, - local, - next, - is_initial.into(), - is_external_layer.clone(), - is_internal_layer.clone(), - NUM_ROUNDS_F + NUM_ROUNDS_P + 1, - ); - } - - fn eval_control_flow_and_inputs( - &self, - builder: &mut AB, - local: &Poseidon2Cols, - next: &Poseidon2Cols, - ) { - let num_total_rounds = local.rounds.len(); - for i in 0..num_total_rounds { - // Verify that the round flags are correct. - builder.assert_bool(local.rounds[i]); - - // Assert that the next round is correct. - builder - .when_transition() - .assert_eq(local.rounds[i], next.rounds[(i + 1) % num_total_rounds]); - - if i != num_total_rounds - 1 { - builder - .when_transition() - .when(local.rounds[i]) - .assert_eq(local.clk, next.clk); - builder - .when_transition() - .when(local.rounds[i]) - .assert_eq(local.dst_input, next.dst_input); - builder - .when_transition() - .when(local.rounds[i]) - .assert_eq(local.left_input, next.left_input); - builder - .when_transition() - .when(local.rounds[i]) - .assert_eq(local.right_input, next.right_input); - } - } - - // Ensure that at most one of the round flags is set. - let round_acc = local - .rounds - .iter() - .fold(AB::Expr::zero(), |acc, round_flag| acc + *round_flag); - builder.assert_bool(round_acc); - - // Verify the do_memory flag. - builder.assert_eq( - local.do_memory, - local.is_real * (local.rounds[0] + local.rounds[23]), - ); - - // Verify the do_receive flag. - builder.assert_eq(local.do_receive, local.is_real * local.rounds[0]); - - // Verify the first row starts at round 0. - builder.when_first_row().assert_one(local.rounds[0]); - // The round count is not a power of 2, so the last row should not be real. - builder.when_last_row().assert_zero(local.is_real); - - // Verify that all is_real flags within a round are equal. - let is_last_round = local.rounds[23]; - builder - .when_transition() - .when_not(is_last_round) - .assert_eq(local.is_real, next.is_real); - } - - fn eval_mem( - &self, - builder: &mut AB, - local: &Poseidon2Cols, - next: &Poseidon2Cols, - is_memory_read: AB::Var, - is_memory_write: AB::Var, - memory_access: AB::Var, - ) { - let memory_access_cols = local.round_specific_cols.memory_access(); - builder - .when(local.is_real) - .when(is_memory_read) - .assert_eq(local.left_input, memory_access_cols.addr_first_half); - builder - .when(local.is_real) - .when(is_memory_read) - .assert_eq(local.right_input, memory_access_cols.addr_second_half); - - builder - .when(local.is_real) - .when(is_memory_write) - .assert_eq(local.dst_input, memory_access_cols.addr_first_half); - builder.when(local.is_real).when(is_memory_write).assert_eq( - local.dst_input + AB::F::from_canonical_usize(WIDTH / 2), - memory_access_cols.addr_second_half, - ); - - for i in 0..WIDTH { - let addr = if i < WIDTH / 2 { - memory_access_cols.addr_first_half + AB::Expr::from_canonical_usize(i) - } else { - memory_access_cols.addr_second_half + AB::Expr::from_canonical_usize(i - WIDTH / 2) - }; - builder.recursion_eval_memory_access_single( - local.clk + AB::Expr::one() * is_memory_write, - addr, - &memory_access_cols.mem_access[i], - memory_access, - ); - builder.when(local.is_real).when(is_memory_read).assert_eq( - *memory_access_cols.mem_access[i].value(), - *memory_access_cols.mem_access[i].prev_value(), - ); - } - - // For the memory read round, need to connect the memory val to the input of the next - // computation round. - let next_computation_col = next.round_specific_cols.computation(); - for i in 0..WIDTH { - builder - .when_transition() - .when(local.is_real) - .when(is_memory_read) - .assert_eq( - *memory_access_cols.mem_access[i].value(), - next_computation_col.input[i], - ); - } - } - - #[allow(clippy::too_many_arguments)] - fn eval_computation( - &self, - builder: &mut AB, - local: &Poseidon2Cols, - next: &Poseidon2Cols, - is_initial: AB::Expr, - is_external_layer: AB::Expr, - is_internal_layer: AB::Expr, - rounds: usize, - ) { - let computation_cols = local.round_specific_cols.computation(); - - // Convert the u32 round constants to field elements. - let constants: [[AB::F; WIDTH]; 30] = RC_16_30_U32 - .iter() - .map(|round| round.map(AB::F::from_wrapped_u32)) - .collect::>() - .try_into() - .unwrap(); - - // Apply the round constants. - // - // Initial Layer: Don't apply the round constants. - // External Layers: Apply the round constants. - // Internal Layers: Only apply the round constants to the first element. - for i in 0..WIDTH { - let mut result: AB::Expr = computation_cols.input[i].into(); - for r in 0..rounds { - if i == 0 { - result += local.rounds[r + 2] - * constants[r][i] - * (is_external_layer.clone() + is_internal_layer.clone()); - } else { - result += local.rounds[r + 2] * constants[r][i] * is_external_layer.clone(); - } - } - builder - .when(local.is_real) - .when(is_initial.clone() + is_external_layer.clone() + is_internal_layer.clone()) - .assert_eq(result, computation_cols.add_rc[i]); - } - - // Apply the sbox. - // - // To differentiate between external and internal layers, we use a masking operation - // to only apply the state change to the first element for internal layers. - for i in 0..WIDTH { - let sbox_deg_3 = computation_cols.add_rc[i] - * computation_cols.add_rc[i] - * computation_cols.add_rc[i]; - builder - .when(local.is_real) - .when(is_initial.clone() + is_external_layer.clone() + is_internal_layer.clone()) - .assert_eq(computation_cols.sbox_deg_3[i], sbox_deg_3); - let sbox_deg_7 = computation_cols.sbox_deg_3[i] - * computation_cols.sbox_deg_3[i] - * computation_cols.add_rc[i]; - builder - .when(local.is_real) - .when(is_initial.clone() + is_external_layer.clone() + is_internal_layer.clone()) - .assert_eq(sbox_deg_7, computation_cols.sbox_deg_7[i]); - } - let sbox_result: [AB::Expr; WIDTH] = computation_cols - .sbox_deg_7 - .iter() - .enumerate() - .map(|(i, x)| { - // The masked first result of the sbox. - // - // Initial Layer: Pass through the result of the round constant layer. - // External Layer: Pass through the result of the sbox layer. - // Internal Layer: Pass through the result of the sbox layer. - if i == 0 { - is_initial.clone() * computation_cols.add_rc[i] - + (is_external_layer.clone() + is_internal_layer.clone()) * *x - } - // The masked result of the rest of the sbox. - // - // Initial layer: Pass through the result of the round constant layer. - // External layer: Pass through the result of the sbox layer. - // Internal layer: Pass through the result of the round constant layer. - else { - (is_initial.clone() + is_internal_layer.clone()) * computation_cols.add_rc[i] - + (is_external_layer.clone()) * *x - } - }) - .collect::>() - .try_into() - .unwrap(); - - // EXTERNAL LAYER + INITIAL LAYER - { - // First, we apply M_4 to each consecutive four elements of the state. - // In Appendix B's terminology, this replaces each x_i with x_i'. - let mut state: [AB::Expr; WIDTH] = sbox_result.clone(); - for i in (0..WIDTH).step_by(4) { - apply_m_4(&mut state[i..i + 4]); - } - - // Now, we apply the outer circulant matrix (to compute the y_i values). - // - // We first precompute the four sums of every four elements. - let sums: [AB::Expr; 4] = core::array::from_fn(|k| { - (0..WIDTH) - .step_by(4) - .map(|j| state[j + k].clone()) - .sum::() - }); - - // The formula for each y_i involves 2x_i' term and x_j' terms for each j that equals i mod 4. - // In other words, we can add a single copy of x_i' to the appropriate one of our precomputed sums. - for i in 0..WIDTH { - state[i] += sums[i % 4].clone(); - builder - .when(local.is_real) - .when(is_external_layer.clone() + is_initial.clone()) - .assert_eq(state[i].clone(), computation_cols.output[i]); - } - } - - // INTERNAL LAYER - { - // Use a simple matrix multiplication as the permutation. - let mut state: [AB::Expr; WIDTH] = sbox_result.clone(); - internal_linear_layer(&mut state); - builder - .when(local.is_real) - .when(is_internal_layer.clone()) - .assert_all_eq(state.clone(), computation_cols.output); - } - - // Assert that the round's output values are equal the the next round's input values. For the - // last computation round, assert athat the output values are equal to the output memory values. - let next_row_computation = next.round_specific_cols.computation(); - let next_row_memory_access = next.round_specific_cols.memory_access(); - for i in 0..WIDTH { - let next_round_value = builder.if_else( - local.rounds[22], - *next_row_memory_access.mem_access[i].value(), - next_row_computation.input[i], - ); - - builder - .when_transition() - .when(local.is_real) - .when(is_initial.clone() + is_external_layer.clone() + is_internal_layer.clone()) - .assert_eq(computation_cols.output[i], next_round_value); - } - } - - fn eval_syscall( - &self, - builder: &mut AB, - local: &Poseidon2Cols, - receive_table: AB::Var, - ) { - // Constraint that the operands are sent from the CPU table. - let operands: [AB::Expr; 4] = [ - local.clk.into(), - local.dst_input.into(), - local.left_input.into(), - local.right_input.into(), - ]; - builder.receive_table( - Opcode::Poseidon2Compress.as_field::(), - &operands, - receive_table, - ); - } - - pub const fn do_receive_table(local: &Poseidon2Cols) -> T { - local.do_receive - } - - pub fn do_memory_access(local: &Poseidon2Cols) -> T { - local.do_memory - } -} - -impl Air for Poseidon2Chip -where - AB: SP1AirBuilder, -{ - fn eval(&self, builder: &mut AB) { - let main = builder.main(); - let local = main.row_slice(0); - let local: &Poseidon2Cols = (*local).borrow(); - let next = main.row_slice(1); - let next: &Poseidon2Cols = (*next).borrow(); - - self.eval_poseidon2::( - builder, - local, - next, - Self::do_receive_table::(local), - Self::do_memory_access::(local), - ); - } -} - -#[cfg(test)] -mod tests { - use itertools::Itertools; - use std::borrow::Borrow; - use std::time::Instant; - use zkhash::ark_ff::UniformRand; - - use p3_baby_bear::BabyBear; - use p3_baby_bear::DiffusionMatrixBabyBear; - use p3_matrix::{dense::RowMajorMatrix, Matrix}; - use p3_poseidon2::Poseidon2; - use p3_poseidon2::Poseidon2ExternalMatrixGeneral; - use sp1_core::stark::StarkGenericConfig; - use sp1_core::utils::inner_perm; - use sp1_core::{ - air::MachineAir, - utils::{uni_stark_prove, uni_stark_verify, BabyBearPoseidon2}, - }; - - use crate::{ - poseidon2::{Poseidon2Chip, Poseidon2Event}, - runtime::ExecutionRecord, - }; - use p3_symmetric::Permutation; - - use super::Poseidon2Cols; - - const ROWS_PER_PERMUTATION: usize = 24; - - #[test] - fn generate_trace() { - let chip = Poseidon2Chip { - fixed_log2_rows: None, - pad: true, - }; - - let rng = &mut rand::thread_rng(); - - let test_inputs: Vec<[BabyBear; 16]> = (0..16) - .map(|_| core::array::from_fn(|_| BabyBear::rand(rng))) - .collect_vec(); - - let gt: Poseidon2< - BabyBear, - Poseidon2ExternalMatrixGeneral, - DiffusionMatrixBabyBear, - 16, - 7, - > = inner_perm(); - - let expected_outputs = test_inputs - .iter() - .map(|input| gt.permute(*input)) - .collect::>(); - - let mut input_exec = ExecutionRecord::::default(); - for (input, output) in test_inputs.into_iter().zip_eq(expected_outputs.clone()) { - input_exec - .poseidon2_events - .push(Poseidon2Event::dummy_from_input(input, output)); - } - - let trace: RowMajorMatrix = - chip.generate_trace(&input_exec, &mut ExecutionRecord::::default()); - - for (i, expected_output) in expected_outputs.iter().enumerate() { - let row = trace.row(ROWS_PER_PERMUTATION * (i + 1) - 2).collect_vec(); - let cols: &Poseidon2Cols = row.as_slice().borrow(); - let computation_cols = cols.round_specific_cols.computation(); - assert_eq!(expected_output, &computation_cols.output); - } - } - - fn prove_babybear(inputs: Vec<[BabyBear; 16]>, outputs: Vec<[BabyBear; 16]>) { - let mut input_exec = ExecutionRecord::::default(); - for (input, output) in inputs.into_iter().zip_eq(outputs) { - input_exec - .poseidon2_events - .push(Poseidon2Event::dummy_from_input(input, output)); - } - - let chip = Poseidon2Chip { - fixed_log2_rows: None, - pad: true, - }; - let trace: RowMajorMatrix = - chip.generate_trace(&input_exec, &mut ExecutionRecord::::default()); - println!( - "trace dims is width: {:?}, height: {:?}", - trace.width(), - trace.height() - ); - - let start = Instant::now(); - let config = BabyBearPoseidon2::compressed(); - let mut challenger = config.challenger(); - let proof = uni_stark_prove(&config, &chip, &mut challenger, trace); - let duration = start.elapsed().as_secs_f64(); - println!("proof duration = {:?}", duration); - - let mut challenger: p3_challenger::DuplexChallenger< - BabyBear, - Poseidon2, - 16, - 8, - > = config.challenger(); - let start = Instant::now(); - uni_stark_verify(&config, &chip, &mut challenger, &proof) - .expect("expected proof to be valid"); - - let duration = start.elapsed().as_secs_f64(); - println!("verify duration = {:?}", duration); - } - - #[test] - fn prove_babybear_success() { - let rng = &mut rand::thread_rng(); - - let test_inputs: Vec<[BabyBear; 16]> = (0..16) - .map(|_| core::array::from_fn(|_| BabyBear::rand(rng))) - .collect_vec(); - - let gt: Poseidon2< - BabyBear, - Poseidon2ExternalMatrixGeneral, - DiffusionMatrixBabyBear, - 16, - 7, - > = inner_perm(); - - let expected_outputs = test_inputs - .iter() - .map(|input| gt.permute(*input)) - .collect::>(); - - prove_babybear(test_inputs, expected_outputs) - } - - #[test] - #[should_panic] - fn prove_babybear_failure() { - let rng = &mut rand::thread_rng(); - let test_inputs: Vec<[BabyBear; 16]> = (0..16) - .map(|_| core::array::from_fn(|_| BabyBear::rand(rng))) - .collect_vec(); - - let bad_outputs: Vec<[BabyBear; 16]> = (0..16) - .map(|_| core::array::from_fn(|_| BabyBear::rand(rng))) - .collect_vec(); - - prove_babybear(test_inputs, bad_outputs) - } -} diff --git a/recursion/core/src/poseidon2/mod.rs b/recursion/core/src/poseidon2/mod.rs deleted file mode 100644 index 2c42ce7219..0000000000 --- a/recursion/core/src/poseidon2/mod.rs +++ /dev/null @@ -1,47 +0,0 @@ -#![allow(clippy::needless_range_loop)] - -use crate::poseidon2::external::WIDTH; -mod columns; -pub mod external; -mod trace; -use crate::air::Block; -use crate::memory::MemoryRecord; -use p3_field::PrimeField32; - -pub use columns::Poseidon2Cols; -pub use external::Poseidon2Chip; - -#[derive(Debug, Clone)] -pub struct Poseidon2Event { - pub clk: F, - pub dst: F, // from a_val - pub left: F, // from b_val - pub right: F, // from c_val - pub input: [F; WIDTH], - pub result_array: [F; WIDTH], - pub input_records: [MemoryRecord; WIDTH], - pub result_records: [MemoryRecord; WIDTH], -} - -impl Poseidon2Event { - /// A way to construct a dummy event from an input array, used for testing. - pub fn dummy_from_input(input: [F; WIDTH], output: [F; WIDTH]) -> Self { - let input_records = core::array::from_fn(|i| { - MemoryRecord::new_read(F::zero(), Block::from(input[i]), F::one(), F::zero()) - }); - let output_records: [MemoryRecord; WIDTH] = core::array::from_fn(|i| { - MemoryRecord::new_read(F::zero(), Block::from(output[i]), F::two(), F::zero()) - }); - - Self { - clk: F::one(), - dst: F::zero(), - left: F::zero(), - right: F::zero(), - input, - result_array: [F::zero(); WIDTH], - input_records, - result_records: output_records, - } - } -} diff --git a/recursion/core/src/poseidon2/trace.rs b/recursion/core/src/poseidon2/trace.rs deleted file mode 100644 index 567c09fc7d..0000000000 --- a/recursion/core/src/poseidon2/trace.rs +++ /dev/null @@ -1,203 +0,0 @@ -use std::borrow::BorrowMut; - -use p3_field::PrimeField32; -use p3_matrix::dense::RowMajorMatrix; -use sp1_core::{air::MachineAir, utils::pad_rows_fixed}; -use sp1_primitives::RC_16_30_U32; -use tracing::instrument; - -use crate::{ - poseidon2_wide::{external_linear_layer, internal_linear_layer}, - runtime::{ExecutionRecord, RecursionProgram}, -}; - -use super::{ - external::{NUM_POSEIDON2_COLS, WIDTH}, - Poseidon2Chip, Poseidon2Cols, -}; - -impl MachineAir for Poseidon2Chip { - type Record = ExecutionRecord; - - type Program = RecursionProgram; - - fn name(&self) -> String { - "Poseidon2".to_string() - } - - fn generate_dependencies(&self, _: &Self::Record, _: &mut Self::Record) { - // This is a no-op. - } - - #[instrument(name = "generate poseidon2 trace", level = "debug", skip_all, fields(rows = input.poseidon2_events.len()))] - fn generate_trace( - &self, - input: &ExecutionRecord, - _: &mut ExecutionRecord, - ) -> RowMajorMatrix { - let mut rows = Vec::new(); - - // 1 round for memory input; 1 round for initialize; 8 rounds for external; 13 rounds for internal; 1 round for memory output - let rounds_f = 8; - let rounds_p = 13; - let rounds = rounds_f + rounds_p + 3; - let rounds_p_beginning = 2 + rounds_f / 2; - let p_end = rounds_p_beginning + rounds_p; - - for poseidon2_event in input.poseidon2_events.iter() { - let mut round_input = Default::default(); - for r in 0..rounds { - let mut row = [F::zero(); NUM_POSEIDON2_COLS]; - let cols: &mut Poseidon2Cols = row.as_mut_slice().borrow_mut(); - cols.is_real = F::one(); - - let is_receive = r == 0; - let is_memory_read = r == 0; - let is_initial_layer = r == 1; - let is_external_layer = - (r >= 2 && r < rounds_p_beginning) || (r >= p_end && r < p_end + rounds_f / 2); - let is_internal_layer = r >= rounds_p_beginning && r < p_end; - let is_memory_write = r == rounds - 1; - - let sum = (is_memory_read as u32) - + (is_initial_layer as u32) - + (is_external_layer as u32) - + (is_internal_layer as u32) - + (is_memory_write as u32); - assert!( - sum == 0 || sum == 1, - "{} {} {} {} {}", - is_memory_read, - is_initial_layer, - is_external_layer, - is_internal_layer, - is_memory_write - ); - - cols.clk = poseidon2_event.clk; - cols.dst_input = poseidon2_event.dst; - cols.left_input = poseidon2_event.left; - cols.right_input = poseidon2_event.right; - cols.rounds[r] = F::one(); - - if is_receive { - cols.do_receive = F::one(); - } - - if is_memory_read || is_memory_write { - let memory_access_cols = cols.round_specific_cols.memory_access_mut(); - - if is_memory_read { - memory_access_cols.addr_first_half = poseidon2_event.left; - memory_access_cols.addr_second_half = poseidon2_event.right; - for i in 0..WIDTH { - memory_access_cols.mem_access[i] - .populate(&poseidon2_event.input_records[i]); - } - } else { - memory_access_cols.addr_first_half = poseidon2_event.dst; - memory_access_cols.addr_second_half = - poseidon2_event.dst + F::from_canonical_usize(WIDTH / 2); - for i in 0..WIDTH { - memory_access_cols.mem_access[i] - .populate(&poseidon2_event.result_records[i]); - } - } - cols.do_memory = F::one(); - } else { - let computation_cols = cols.round_specific_cols.computation_mut(); - - if is_initial_layer { - round_input = poseidon2_event.input; - } - - computation_cols.input = round_input; - - if is_initial_layer { - // Don't apply the round constants. - computation_cols - .add_rc - .copy_from_slice(&computation_cols.input); - } else if is_external_layer { - // Apply the round constants. - for j in 0..WIDTH { - computation_cols.add_rc[j] = computation_cols.input[j] - + F::from_wrapped_u32(RC_16_30_U32[r - 2][j]); - } - } else { - // Apply the round constants only on the first element. - computation_cols - .add_rc - .copy_from_slice(&computation_cols.input); - computation_cols.add_rc[0] = - computation_cols.input[0] + F::from_wrapped_u32(RC_16_30_U32[r - 2][0]); - }; - - // Apply the sbox. - for j in 0..WIDTH { - let sbox_deg_3 = computation_cols.add_rc[j] - * computation_cols.add_rc[j] - * computation_cols.add_rc[j]; - computation_cols.sbox_deg_3[j] = sbox_deg_3; - computation_cols.sbox_deg_7[j] = - sbox_deg_3 * sbox_deg_3 * computation_cols.add_rc[j]; - } - - // What state to use for the linear layer. - let mut state = if is_initial_layer { - computation_cols.add_rc - } else if is_external_layer { - computation_cols.sbox_deg_7 - } else { - let mut state = computation_cols.add_rc; - state[0] = computation_cols.sbox_deg_7[0]; - state - }; - - // Apply either the external or internal linear layer. - if is_initial_layer || is_external_layer { - external_linear_layer(&mut state); - } else if is_internal_layer { - internal_linear_layer(&mut state) - } - - // Copy the state to the output. - computation_cols.output.copy_from_slice(&state); - - round_input = computation_cols.output; - } - - rows.push(row); - } - } - - let num_real_rows = rows.len(); - - // Pad the trace to a power of two. - if self.pad { - pad_rows_fixed( - &mut rows, - || [F::zero(); NUM_POSEIDON2_COLS], - self.fixed_log2_rows, - ); - } - - let mut round_num = 0; - for row in rows[num_real_rows..].iter_mut() { - let cols: &mut Poseidon2Cols = row.as_mut_slice().borrow_mut(); - cols.rounds[round_num] = F::one(); - - round_num = (round_num + 1) % rounds; - } - - // Convert the trace to a row major matrix. - RowMajorMatrix::new( - rows.into_iter().flatten().collect::>(), - NUM_POSEIDON2_COLS, - ) - } - - fn included(&self, record: &Self::Record) -> bool { - !record.poseidon2_events.is_empty() - } -} diff --git a/recursion/core/src/poseidon2_wide/air/control_flow.rs b/recursion/core/src/poseidon2_wide/air/control_flow.rs new file mode 100644 index 0000000000..2b1f559bf3 --- /dev/null +++ b/recursion/core/src/poseidon2_wide/air/control_flow.rs @@ -0,0 +1,435 @@ +use p3_air::AirBuilder; +use p3_field::AbstractField; +use sp1_core::{air::BaseAirBuilder, operations::IsZeroOperation}; + +use crate::{ + air::SP1RecursionAirBuilder, + poseidon2_wide::{ + columns::{ + control_flow::ControlFlow, opcode_workspace::OpcodeWorkspace, + syscall_params::SyscallParams, Poseidon2, + }, + Poseidon2WideChip, RATE, + }, + range_check::RangeCheckOpcode, +}; + +impl Poseidon2WideChip { + /// Constraints related to control flow. + pub(crate) fn eval_control_flow( + &self, + builder: &mut AB, + local_row: &dyn Poseidon2, + next_row: &dyn Poseidon2, + send_range_check: AB::Var, + ) where + AB::Var: 'static, + { + let local_control_flow = local_row.control_flow(); + let next_control_flow = next_row.control_flow(); + + let local_is_real = local_control_flow.is_compress + + local_control_flow.is_absorb + + local_control_flow.is_finalize; + let next_is_real = next_control_flow.is_compress + + next_control_flow.is_absorb + + next_control_flow.is_finalize; + + builder.assert_bool(local_control_flow.is_compress); + builder.assert_bool(local_control_flow.is_compress_output); + builder.assert_bool(local_control_flow.is_absorb); + builder.assert_bool(local_control_flow.is_finalize); + builder.assert_bool(local_control_flow.is_syscall_row); + builder.assert_bool(local_is_real.clone()); + + self.eval_global_control_flow( + builder, + local_control_flow, + next_control_flow, + local_row.syscall_params(), + next_row.syscall_params(), + local_row.opcode_workspace(), + next_row.opcode_workspace(), + local_is_real.clone(), + next_is_real.clone(), + ); + + self.eval_hash_control_flow( + builder, + local_control_flow, + local_row.opcode_workspace(), + next_row.opcode_workspace(), + local_row.syscall_params(), + send_range_check, + ); + + builder + .when(local_control_flow.is_syscall_row) + .assert_one(local_is_real); + } + + /// This function will verify that all hash rows are before the compress rows and that the first + /// row is the first absorb syscall. These constraints will require that there is at least one + /// absorb, finalize, and compress system call. + #[allow(clippy::too_many_arguments)] + fn eval_global_control_flow( + &self, + builder: &mut AB, + local_control_flow: &ControlFlow, + next_control_flow: &ControlFlow, + local_syscall_params: &SyscallParams, + next_syscall_params: &SyscallParams, + local_opcode_workspace: &OpcodeWorkspace, + next_opcode_workspace: &OpcodeWorkspace, + local_is_real: AB::Expr, + next_is_real: AB::Expr, + ) { + // We require that the first row is an absorb syscall and that the hash_num == 0 and absorb_num == 0. + let mut first_row_builder = builder.when_first_row(); + first_row_builder.assert_one(local_control_flow.is_absorb); + first_row_builder.assert_one(local_control_flow.is_syscall_row); + first_row_builder.assert_zero(local_opcode_workspace.absorb().hash_num); + first_row_builder.assert_zero(local_opcode_workspace.absorb().absorb_num); + first_row_builder.assert_one(local_opcode_workspace.absorb().is_first_hash_row); + + // For absorb rows, constrain the following: + // 1) when last absorb row, then the next row is a either an absorb or finalize syscall row. + // 2) when last absorb row and the next row is an absorb row, then absorb_num' = absorb_num + 1. + // 3) when not last absorb row, then the next row is an absorb non syscall row. + // 4) when not last absorb row, then absorb_num' = absorb_num. + // 5) hash_num == hash_num'. + { + let mut transition_builder = builder.when_transition(); + + let mut absorb_last_row_builder = + transition_builder.when(local_control_flow.is_absorb_last_row); + absorb_last_row_builder + .assert_one(next_control_flow.is_absorb + next_control_flow.is_finalize); + absorb_last_row_builder.assert_one(next_control_flow.is_syscall_row); + absorb_last_row_builder + .when(next_control_flow.is_absorb) + .assert_eq( + next_opcode_workspace.absorb().absorb_num, + local_opcode_workspace.absorb().absorb_num + AB::Expr::one(), + ); + + let mut absorb_not_last_row_builder = + transition_builder.when(local_control_flow.is_absorb_not_last_row); + absorb_not_last_row_builder.assert_one(next_control_flow.is_absorb); + absorb_not_last_row_builder.assert_zero(next_control_flow.is_syscall_row); + absorb_not_last_row_builder.assert_eq( + local_opcode_workspace.absorb().absorb_num, + next_opcode_workspace.absorb().absorb_num, + ); + + let mut absorb_transition_builder = + transition_builder.when(local_control_flow.is_absorb); + absorb_transition_builder + .when(next_control_flow.is_absorb) + .assert_eq( + local_opcode_workspace.absorb().hash_num, + next_opcode_workspace.absorb().hash_num, + ); + absorb_transition_builder + .when(next_control_flow.is_finalize) + .assert_eq( + local_opcode_workspace.absorb().hash_num, + next_syscall_params.finalize().hash_num, + ); + } + + // For finalize rows, constrain the following: + // 1) next row is syscall compress or syscall absorb. + // 2) if next row is absorb -> hash_num + 1 == hash_num' + // 3) if next row is absorb -> absorb_num' == 0 + // 4) if next row is absorb -> is_first_hash' == true + { + let mut transition_builder = builder.when_transition(); + let mut finalize_transition_builder = + transition_builder.when(local_control_flow.is_finalize); + + finalize_transition_builder + .assert_one(next_control_flow.is_absorb + next_control_flow.is_compress); + finalize_transition_builder.assert_one(next_control_flow.is_syscall_row); + + finalize_transition_builder + .when(next_control_flow.is_absorb) + .assert_eq( + local_syscall_params.finalize().hash_num + AB::Expr::one(), + next_opcode_workspace.absorb().hash_num, + ); + finalize_transition_builder + .when(next_control_flow.is_absorb) + .assert_zero(next_opcode_workspace.absorb().absorb_num); + finalize_transition_builder + .when(next_control_flow.is_absorb) + .assert_one(next_opcode_workspace.absorb().is_first_hash_row); + } + + // For compress rows, constrain the following: + // 1) if compress syscall -> next row is a compress output + // 2) if compress output -> next row is a compress syscall or not real + { + builder.assert_eq( + local_control_flow.is_compress_output, + local_control_flow.is_compress + * (AB::Expr::one() - local_control_flow.is_syscall_row), + ); + + let mut transition_builder = builder.when_transition(); + + transition_builder + .when(local_control_flow.is_compress) + .when(local_control_flow.is_syscall_row) + .assert_one(next_control_flow.is_compress_output); + + // When we are at a compress output row, then ensure next row is either not real or is a compress syscall row. + transition_builder + .when(local_control_flow.is_compress_output) + .assert_one( + (AB::Expr::one() - next_is_real.clone()) + + next_control_flow.is_compress * next_control_flow.is_syscall_row, + ); + } + + // Constrain that there is only one is_real -> not is real transition. Also contrain that + // the last real row is a compress output row. + { + let mut transition_builder = builder.when_transition(); + + transition_builder + .when_not(local_is_real.clone()) + .assert_zero(next_is_real.clone()); + + transition_builder + .when(local_is_real.clone()) + .when_not(next_is_real.clone()) + .assert_one(local_control_flow.is_compress_output); + + builder + .when_last_row() + .when(local_is_real.clone()) + .assert_one(local_control_flow.is_compress_output); + } + } + + #[allow(clippy::too_many_arguments)] + fn eval_hash_control_flow( + &self, + builder: &mut AB, + local_control_flow: &ControlFlow, + local_opcode_workspace: &OpcodeWorkspace, + next_opcode_workspace: &OpcodeWorkspace, + local_syscall_params: &SyscallParams, + send_range_check: AB::Var, + ) { + let local_hash_workspace = local_opcode_workspace.absorb(); + let next_hash_workspace = next_opcode_workspace.absorb(); + let last_row_ending_cursor_is_seven = + local_hash_workspace.last_row_ending_cursor_is_seven.result; + + // Verify that the hash_num and absorb_num are correctly decomposed from the syscall + // hash_and_absorb_num param. + // Also range check that both hash_num is within [0, 2^16 - 1] and absorb_num is within [0, 2^12 - 1]; + { + let mut absorb_builder = builder.when(local_control_flow.is_absorb); + + absorb_builder.assert_eq( + local_hash_workspace.hash_num * AB::Expr::from_canonical_u32(1 << 12) + + local_hash_workspace.absorb_num, + local_syscall_params.absorb().hash_and_absorb_num, + ); + builder.send_range_check( + AB::Expr::from_canonical_u8(RangeCheckOpcode::U16 as u8), + local_hash_workspace.hash_num, + send_range_check, + ); + builder.send_range_check( + AB::Expr::from_canonical_u8(RangeCheckOpcode::U12 as u8), + local_hash_workspace.absorb_num, + send_range_check, + ); + } + + // Constrain the materialized control flow flags. + { + let mut absorb_builder = builder.when(local_control_flow.is_absorb); + + absorb_builder.assert_eq( + local_hash_workspace.is_syscall_not_last_row, + local_control_flow.is_syscall_row + * (AB::Expr::one() - local_hash_workspace.is_last_row::()), + ); + absorb_builder.assert_eq( + local_hash_workspace.not_syscall_not_last_row, + (AB::Expr::one() - local_control_flow.is_syscall_row) + * (AB::Expr::one() - local_hash_workspace.is_last_row::()), + ); + absorb_builder.assert_eq( + local_hash_workspace.is_syscall_is_last_row, + local_control_flow.is_syscall_row * local_hash_workspace.is_last_row::(), + ); + absorb_builder.assert_eq( + local_hash_workspace.not_syscall_is_last_row, + (AB::Expr::one() - local_control_flow.is_syscall_row) + * local_hash_workspace.is_last_row::(), + ); + absorb_builder.assert_eq( + local_hash_workspace.is_last_row_ending_cursor_is_seven, + local_hash_workspace.is_last_row::() * last_row_ending_cursor_is_seven, + ); + absorb_builder.assert_eq( + local_hash_workspace.is_last_row_ending_cursor_not_seven, + local_hash_workspace.is_last_row::() + * (AB::Expr::one() - last_row_ending_cursor_is_seven), + ); + + builder.assert_eq( + local_control_flow.is_absorb_not_last_row, + local_control_flow.is_absorb + * (AB::Expr::one() - local_hash_workspace.is_last_row::()), + ); + builder.assert_eq( + local_control_flow.is_absorb_last_row, + local_control_flow.is_absorb * local_hash_workspace.is_last_row::(), + ); + + builder.assert_eq( + local_control_flow.is_absorb_no_perm, + local_control_flow.is_absorb + * (AB::Expr::one() - local_hash_workspace.do_perm::()), + ); + } + + // For the absorb syscall row, ensure correct value of num_remaining_rows, last_row_num_consumed, + // and num_remaining_rows_is_zero. + { + let mut absorb_builder = builder.when(local_control_flow.is_absorb); + + // Verify that state_cursor + syscall input_len - 1 == num_remaining_rows * RATE + last_row_ending_cursor. + // The minus one is needed, since `last_row_ending_cursor` is inclusive of the last element, + // while state_cursor + syscall input_len is not. + absorb_builder + .when(local_control_flow.is_syscall_row) + .assert_eq( + local_hash_workspace.state_cursor + local_syscall_params.absorb().input_len + - AB::Expr::one(), + local_hash_workspace.num_remaining_rows * AB::Expr::from_canonical_usize(RATE) + + local_hash_workspace.last_row_ending_cursor, + ); + + // Range check that last_row_ending_cursor is between [0, 7]. + (0..3).for_each(|i| { + absorb_builder.assert_bool(local_hash_workspace.last_row_ending_cursor_bitmap[i]) + }); + let expected_last_row_ending_cursor: AB::Expr = local_hash_workspace + .last_row_ending_cursor_bitmap + .iter() + .zip(0..3) + .map(|(bit, exp)| *bit * AB::Expr::from_canonical_u32(2u32.pow(exp))) + .sum::(); + absorb_builder + .when(local_control_flow.is_syscall_row) + .assert_eq( + local_hash_workspace.last_row_ending_cursor, + expected_last_row_ending_cursor, + ); + + // Range check that input_len < 2^16. This check is only needed for absorb syscall rows, + // but we send it for all absorb rows, since the `is_real` parameter must be an expression + // with at most degree 1. + builder.send_range_check( + AB::Expr::from_canonical_u8(RangeCheckOpcode::U16 as u8), + local_syscall_params.absorb().input_len, + send_range_check, + ); + + // Range check that num_remaining_rows is between [0, 2^16-1]. + builder.send_range_check( + AB::Expr::from_canonical_u8(RangeCheckOpcode::U16 as u8), + local_hash_workspace.num_remaining_rows, + send_range_check, + ); + } + + // For all non last absorb rows, verify that num_remaining_rows decrements and + // that last_row_ending_cursor is copied down. + { + let mut transition_builder = builder.when_transition(); + let mut absorb_transition_builder = + transition_builder.when(local_control_flow.is_absorb); + + absorb_transition_builder + .when_not(local_hash_workspace.is_last_row::()) + .assert_eq( + next_hash_workspace.num_remaining_rows, + local_hash_workspace.num_remaining_rows - AB::Expr::one(), + ); + + // Copy down the last_row_ending_cursor value within the absorb call. + absorb_transition_builder + .when_not(local_hash_workspace.is_last_row::()) + .assert_eq( + next_hash_workspace.last_row_ending_cursor, + local_hash_workspace.last_row_ending_cursor, + ); + } + + // Constrain the state cursor. There are three constraints: + // 1) For the first hash row, verify that state_cursor == 0. + // 2) For the last absorb rows, verify that constrain + // state_cursor' = (last_row_ending_cursor + 1) % RATE. + // 3) For all non syscall rows, the state_cursor should be 0. + { + let mut absorb_builder = builder.when(local_control_flow.is_absorb); + + absorb_builder + .when(local_hash_workspace.is_first_hash_row) + .assert_zero(local_hash_workspace.state_cursor); + + absorb_builder + .when(local_hash_workspace.is_last_row_ending_cursor_is_seven) + .assert_zero(next_hash_workspace.state_cursor); + + absorb_builder + .when(local_hash_workspace.is_last_row_ending_cursor_not_seven) + .assert_eq( + next_hash_workspace.state_cursor, + local_hash_workspace.last_row_ending_cursor + AB::Expr::one(), + ); + + absorb_builder + .when_not(local_control_flow.is_syscall_row) + .assert_zero(local_hash_workspace.state_cursor); + } + + // Eval the absorb's iszero operations. + { + // Drop absorb_builder so that builder can be used in the IsZeroOperation eval. + IsZeroOperation::::eval( + builder, + local_hash_workspace.last_row_ending_cursor - AB::Expr::from_canonical_usize(7), + local_hash_workspace.last_row_ending_cursor_is_seven, + local_control_flow.is_absorb.into(), + ); + + IsZeroOperation::::eval( + builder, + local_hash_workspace.num_remaining_rows.into(), + local_hash_workspace.num_remaining_rows_is_zero, + local_control_flow.is_absorb.into(), + ); + } + + // Apply control flow constraints for finalize. + { + // Eval state_cursor_is_zero. + IsZeroOperation::::eval( + builder, + local_opcode_workspace.finalize().state_cursor.into(), + local_opcode_workspace.finalize().state_cursor_is_zero, + local_control_flow.is_finalize.into(), + ); + } + } +} diff --git a/recursion/core/src/poseidon2_wide/air/memory.rs b/recursion/core/src/poseidon2_wide/air/memory.rs new file mode 100644 index 0000000000..3df855d164 --- /dev/null +++ b/recursion/core/src/poseidon2_wide/air/memory.rs @@ -0,0 +1,231 @@ +use p3_air::AirBuilder; +use p3_field::AbstractField; +use sp1_core::air::BaseAirBuilder; + +use crate::{ + air::SP1RecursionAirBuilder, + memory::MemoryCols, + poseidon2_wide::{ + columns::{ + control_flow::ControlFlow, memory::Memory, opcode_workspace::OpcodeWorkspace, + syscall_params::SyscallParams, + }, + Poseidon2WideChip, WIDTH, + }, +}; + +impl Poseidon2WideChip { + /// Eval the memory related columns. + #[allow(clippy::too_many_arguments)] + pub(crate) fn eval_mem( + &self, + builder: &mut AB, + syscall_params: &SyscallParams, + local_memory: &Memory, + next_memory: &Memory, + opcode_workspace: &OpcodeWorkspace, + control_flow: &ControlFlow, + first_half_memory_access: [AB::Var; WIDTH / 2], + second_half_memory_access: AB::Var, + ) { + let clk = syscall_params.get_raw_params()[0]; + let is_real = control_flow.is_compress + control_flow.is_absorb + control_flow.is_finalize; + + // Constrain the memory flags. + for i in 0..WIDTH / 2 { + builder.assert_bool(local_memory.memory_slot_used[i]); + + // The memory slot flag will be used as the memory access multiplicity flag, so we need to + // ensure that those values are zero for all non real rows. + builder + .when_not(is_real.clone()) + .assert_zero(local_memory.memory_slot_used[i]); + + // For compress and finalize, all of the slots should be true. + builder + .when(control_flow.is_compress + control_flow.is_finalize) + .assert_one(local_memory.memory_slot_used[i]); + + // For absorb, need to make sure the memory_slots_used is consistent with the start_cursor and + // end_cursor (i.e. start_cursor + num_consumed); + self.eval_absorb_memory_slots(builder, control_flow, local_memory, opcode_workspace); + } + + // Verify the start_addr column. + { + // For compress syscall rows, the start_addr should be the param's left ptr. + builder + .when(control_flow.is_compress * control_flow.is_syscall_row) + .assert_eq(syscall_params.compress().left_ptr, local_memory.start_addr); + + // For compress output rows, the start_addr should be the param's dst ptr. + builder + .when(control_flow.is_compress_output) + .assert_eq(syscall_params.compress().dst_ptr, local_memory.start_addr); + + // For absorb syscall rows, the start_addr should initially be from the syscall param's + // input_ptr, and for subsequent rows, it's incremented by the number of consumed elements. + builder + .when(control_flow.is_absorb) + .when(control_flow.is_syscall_row) + .assert_eq(syscall_params.absorb().input_ptr, local_memory.start_addr); + builder.when(control_flow.is_absorb_not_last_row).assert_eq( + next_memory.start_addr, + local_memory.start_addr + opcode_workspace.absorb().num_consumed::(), + ); + + // For finalize syscall rows, the start_addr should be the param's output ptr. + builder.when(control_flow.is_finalize).assert_eq( + syscall_params.finalize().output_ptr, + local_memory.start_addr, + ); + } + + // Contrain memory access for the first half of the memory accesses. + { + let mut addr: AB::Expr = local_memory.start_addr.into(); + for i in 0..WIDTH / 2 { + builder.recursion_eval_memory_access_single( + clk + control_flow.is_compress_output, + addr.clone(), + &local_memory.memory_accesses[i], + first_half_memory_access[i], + ); + + let compress_syscall_row = control_flow.is_compress * control_flow.is_syscall_row; + // For read only accesses, assert the value didn't change. + builder + .when(compress_syscall_row + control_flow.is_absorb) + .assert_eq( + *local_memory.memory_accesses[i].prev_value(), + *local_memory.memory_accesses[i].value(), + ); + + addr = addr.clone() + local_memory.memory_slot_used[i].into(); + } + } + + // Contrain memory access for the 2nd half of the memory accesses. + { + let compress_workspace = opcode_workspace.compress(); + + // Verify the start addr. + let is_compress_syscall = control_flow.is_compress * control_flow.is_syscall_row; + builder.when(is_compress_syscall.clone()).assert_eq( + compress_workspace.start_addr, + syscall_params.compress().right_ptr, + ); + builder.when(control_flow.is_compress_output).assert_eq( + compress_workspace.start_addr, + syscall_params.compress().dst_ptr + AB::Expr::from_canonical_usize(WIDTH / 2), + ); + + let mut addr: AB::Expr = compress_workspace.start_addr.into(); + for i in 0..WIDTH / 2 { + builder.recursion_eval_memory_access_single( + clk + control_flow.is_compress_output, + addr.clone(), + &compress_workspace.memory_accesses[i], + second_half_memory_access, + ); + + // For read only accesses, assert the value didn't change. + builder.when(is_compress_syscall.clone()).assert_eq( + *compress_workspace.memory_accesses[i].prev_value(), + *compress_workspace.memory_accesses[i].value(), + ); + + addr = addr.clone() + AB::Expr::one(); + } + } + } + + fn eval_absorb_memory_slots( + &self, + builder: &mut AB, + control_flow: &ControlFlow, + local_memory: &Memory, + opcode_workspace: &OpcodeWorkspace, + ) { + // To verify that the absorb memory slots are correct, we take the derivative of the memory slots, + // (e.g. memory_slot_used[i] - memory_slot_used[i - 1]), and assert the following: + // 1) when start_mem_idx_bitmap[i] == 1 -> derivative == 1 + // 2) when end_mem_idx_bitmap[i + 1] == 1 -> derivative == -1 + // 3) when start_mem_idx_bitmap[i] == 0 and end_mem_idx_bitmap[i + 1] == 0 -> derivative == 0 + let mut absorb_builder = builder.when(control_flow.is_absorb); + + let start_mem_idx_bitmap = opcode_workspace.absorb().start_mem_idx_bitmap; + let end_mem_idx_bitmap = opcode_workspace.absorb().end_mem_idx_bitmap; + for i in 0..WIDTH / 2 { + let derivative: AB::Expr = if i == 0 { + local_memory.memory_slot_used[i].into() + } else { + local_memory.memory_slot_used[i] - local_memory.memory_slot_used[i - 1] + }; + + let is_start_mem_idx = start_mem_idx_bitmap[i].into(); + + let is_previous_end_mem_idx = if i == 0 { + AB::Expr::zero() + } else { + end_mem_idx_bitmap[i - 1].into() + }; + + absorb_builder + .when(is_start_mem_idx.clone()) + .assert_one(derivative.clone()); + + absorb_builder + .when(is_previous_end_mem_idx.clone()) + .assert_zero(derivative.clone() + AB::Expr::one()); + + absorb_builder + .when_not(is_start_mem_idx + is_previous_end_mem_idx) + .assert_zero(derivative); + } + + // Verify that all elements of start_mem_idx_bitmap and end_mem_idx_bitmap are bool. + // Also verify that exactly one of the bits in start_mem_idx_bitmap and end_mem_idx_bitmap + // is one. + let mut start_mem_idx_bitmap_sum = AB::Expr::zero(); + start_mem_idx_bitmap.iter().for_each(|bit| { + absorb_builder.assert_bool(*bit); + start_mem_idx_bitmap_sum += (*bit).into(); + }); + absorb_builder.assert_one(start_mem_idx_bitmap_sum); + + let mut end_mem_idx_bitmap_sum = AB::Expr::zero(); + end_mem_idx_bitmap.iter().for_each(|bit| { + absorb_builder.assert_bool(*bit); + end_mem_idx_bitmap_sum += (*bit).into(); + }); + absorb_builder.assert_one(end_mem_idx_bitmap_sum); + + // Verify correct value of start_mem_idx_bitmap and end_mem_idx_bitmap. + let start_mem_idx: AB::Expr = start_mem_idx_bitmap + .iter() + .enumerate() + .map(|(i, bit)| AB::Expr::from_canonical_usize(i) * *bit) + .sum(); + absorb_builder.assert_eq(start_mem_idx, opcode_workspace.absorb().state_cursor); + + let end_mem_idx: AB::Expr = end_mem_idx_bitmap + .iter() + .enumerate() + .map(|(i, bit)| AB::Expr::from_canonical_usize(i) * *bit) + .sum(); + + // When we are not in the last row, end_mem_idx should be zero. + absorb_builder + .when_not(opcode_workspace.absorb().is_last_row::()) + .assert_zero(end_mem_idx.clone() - AB::Expr::from_canonical_usize(7)); + + // When we are in the last row, end_mem_idx bitmap should equal last_row_ending_cursor. + absorb_builder + .when(opcode_workspace.absorb().is_last_row::()) + .assert_eq( + end_mem_idx, + opcode_workspace.absorb().last_row_ending_cursor, + ); + } +} diff --git a/recursion/core/src/poseidon2_wide/air/mod.rs b/recursion/core/src/poseidon2_wide/air/mod.rs new file mode 100644 index 0000000000..5780b195a5 --- /dev/null +++ b/recursion/core/src/poseidon2_wide/air/mod.rs @@ -0,0 +1,204 @@ +//! The air module contains the AIR constraints for the poseidon2 chip. Those constraints will +//! enforce the following properties: +//! +//! # Layout of the poseidon2 chip: +//! +//! All the hash related rows should be in the first part of the chip and all the compress +//! related rows in the second part. E.g. the chip should have this format: +//! +//! absorb row (for hash num 1) +//! absorb row (for hash num 1) +//! absorb row (for hash num 1) +//! finalize row (for hash num 1) +//! absorb row (for hash num 2) +//! absorb row (for hash num 2) +//! finalize row (for hash num 2) +//! . +//! . +//! . +//! compress syscall/input row +//! compress output row +//! +//! # Absorb rows +//! +//! For absorb rows, the AIR needs to ensure that all of the input is written into the hash state +//! and that its written into the correct parts of that state. To do this, the AIR will first ensure +//! the correct values for num_remaining_rows (e.g. total number of rows of an absorb syscall) and +//! the last_row_ending_cursor. It does this by checking the following: +//! +//! 1. start_state_cursor + syscall_input_len == num_remaining_rows * RATE + last_row_ending_cursor +//! 2. range check syscall_input_len to be [0, 2^16 - 1] +//! 3. range check last_row_ending_cursor to be [0, RATE] +//! +//! For all subsequent absorb rows, the num_remaining_rows will be decremented by 1, and the +//! last_row_ending_cursor will be copied down to all of the rows. Also, for the next absorb/finalize +//! syscall, its state_cursor is set to (last_row_ending_cursor + 1) % RATE. +//! +//! From num_remaining_rows and syscall column, we know the absorb's first row and last row. +//! From that fact, we can then enforce the following state writes. +//! +//! 1. is_first_row && is_last_row -> state writes are [state_cursor..state_cursor + last_row_ending_cursor] +//! 2. is_first_row && !is_last_row -> state writes are [state_cursor..RATE - 1] +//! 3. !is_first_row && !is_last_row -> state writes are [0..RATE - 1] +//! 4. !is_first_row && is_last_row -> state writes are [0..last_row_ending_cursor] +//! +//! From the state writes range, we can then populate a bitmap that specifies which state elements +//! should be overwritten (stored in Memory.memory_slot_used columns). To verify that this bitmap +//! is correct, we utilize the column's derivative (memory_slot_used[i] - memory_slot_used[i-1], +//! where memory_slot_used[-1] is 0). +//! +//! 1. When idx == state write start_idx -> derivative == 1 +//! 2. When idx == (state write end_idx - 1) -> derivative == -1 +//! 3. For all other cases, derivative == 0 +//! +//! In addition to determining the hash state writes, the AIR also needs to ensure that the do_perm +//! flag is correct (which is used to determine if a permutation should be done). It does this +//! by enforcing the following. +//! +//! 1. is_first_row && !is_last_row -> do_perm == 1 +//! 2. !is_first_row && !is_last_row -> do_perm == 1 +//! 3. is_last_row && last_row_ending_cursor == RATE - 1 -> do_perm == 1 +//! 4. is_last_row && last_row_ending_cursor != RATE - 1 -> do_perm == 0 +//! +//! # Finalize rows +//! +//! For finalize, the main flag that needs to be checked is do_perm. If state_cursor == 0, then +//! do_perm should be 0, otherwise it should be 1. If state_cursor == 0, that means that the +//! previous row did a perm. +//! +//! # Compress rows +//! +//! For compress, the main invariants that needs to be checked is that all syscall compress rows +//! verifies the correct memory read accesses, does the permutation, and copies the permuted value +//! into the next row. That row should then verify the correct memory write accesses. + +use p3_air::{Air, BaseAir}; +use p3_matrix::Matrix; + +use crate::air::SP1RecursionAirBuilder; + +pub mod control_flow; +pub mod memory; +pub mod permutation; +pub mod state_transition; +pub mod syscall_params; + +use super::{ + columns::{Poseidon2, NUM_POSEIDON2_DEGREE3_COLS, NUM_POSEIDON2_DEGREE9_COLS}, + Poseidon2WideChip, WIDTH, +}; + +impl BaseAir for Poseidon2WideChip { + fn width(&self) -> usize { + if DEGREE == 3 { + NUM_POSEIDON2_DEGREE3_COLS + } else if DEGREE == 9 || DEGREE == 17 { + NUM_POSEIDON2_DEGREE9_COLS + } else { + panic!("Unsupported degree: {}", DEGREE); + } + } +} + +impl Air for Poseidon2WideChip +where + AB: SP1RecursionAirBuilder, + AB::Var: 'static, +{ + fn eval(&self, builder: &mut AB) { + let main = builder.main(); + let local_row = Self::convert::(main.row_slice(0)); + let next_row = Self::convert::(main.row_slice(1)); + + // Dummy constraints to normalize to DEGREE. + let lhs = (0..DEGREE) + .map(|_| local_row.control_flow().is_compress.into()) + .product::(); + let rhs = (0..DEGREE) + .map(|_| local_row.control_flow().is_compress.into()) + .product::(); + builder.assert_eq(lhs, rhs); + + self.eval_poseidon2( + builder, + local_row.as_ref(), + next_row.as_ref(), + local_row.control_flow().is_syscall_row, + local_row.memory().memory_slot_used, + local_row.control_flow().is_compress, + local_row.control_flow().is_absorb, + ); + } +} + +impl Poseidon2WideChip { + #[allow(clippy::too_many_arguments)] + pub(crate) fn eval_poseidon2( + &self, + builder: &mut AB, + local_row: &dyn Poseidon2, + next_row: &dyn Poseidon2, + receive_syscall: AB::Var, + first_half_memory_access: [AB::Var; WIDTH / 2], + second_half_memory_access: AB::Var, + send_range_check: AB::Var, + ) where + AB: SP1RecursionAirBuilder, + AB::Var: 'static, + { + let local_control_flow = local_row.control_flow(); + let next_control_flow = next_row.control_flow(); + let local_syscall = local_row.syscall_params(); + let next_syscall = next_row.syscall_params(); + let local_memory = local_row.memory(); + let next_memory = next_row.memory(); + let local_perm = local_row.permutation(); + let local_opcode_workspace = local_row.opcode_workspace(); + let next_opcode_workspace = next_row.opcode_workspace(); + + // Check that all the control flow columns are correct. + self.eval_control_flow(builder, local_row, next_row, send_range_check); + + // Check that the syscall columns are correct. + self.eval_syscall_params( + builder, + local_syscall, + next_syscall, + local_control_flow, + next_control_flow, + receive_syscall, + ); + + // Check that all the memory access columns are correct. + self.eval_mem( + builder, + local_syscall, + local_memory, + next_memory, + local_opcode_workspace, + local_control_flow, + first_half_memory_access, + second_half_memory_access, + ); + + // Check that the permutation columns are correct. + self.eval_perm( + builder, + local_perm.as_ref(), + local_memory, + local_opcode_workspace, + local_control_flow, + ); + + // Check that the permutation output is copied to the next row correctly. + self.eval_state_transition( + builder, + local_control_flow, + local_opcode_workspace, + next_opcode_workspace, + local_perm.as_ref(), + local_memory, + next_memory, + ); + } +} diff --git a/recursion/core/src/poseidon2_wide/air/permutation.rs b/recursion/core/src/poseidon2_wide/air/permutation.rs new file mode 100644 index 0000000000..c9920a8a2e --- /dev/null +++ b/recursion/core/src/poseidon2_wide/air/permutation.rs @@ -0,0 +1,177 @@ +use std::array; + +use p3_field::AbstractField; +use sp1_primitives::RC_16_30_U32; + +use crate::{ + air::SP1RecursionAirBuilder, + memory::MemoryCols, + poseidon2_wide::{ + columns::{ + control_flow::ControlFlow, memory::Memory, opcode_workspace::OpcodeWorkspace, + permutation::Permutation, + }, + external_linear_layer, internal_linear_layer, Poseidon2WideChip, NUM_EXTERNAL_ROUNDS, + NUM_INTERNAL_ROUNDS, WIDTH, + }, +}; + +impl Poseidon2WideChip { + pub(crate) fn eval_perm( + &self, + builder: &mut AB, + perm_cols: &dyn Permutation, + memory: &Memory, + opcode_workspace: &OpcodeWorkspace, + control_flow: &ControlFlow, + ) { + // Construct the input array of the permutation. That array is dependent on the row type. + // For compress_syscall rows, the input is from the memory access values. For absorb, the + // input is the previous state, with select elements being read from the memory access values. + // For finalize, the input is the previous state. + let input: [AB::Expr; WIDTH] = array::from_fn(|i| { + let previous_state = opcode_workspace.absorb().previous_state[i]; + + let (compress_input, absorb_input, finalize_input) = if i < WIDTH / 2 { + let mem_value = *memory.memory_accesses[i].value(); + + let compress_input = mem_value; + let absorb_input = + builder.if_else(memory.memory_slot_used[i], mem_value, previous_state); + let finalize_input = previous_state.into(); + + (compress_input, absorb_input, finalize_input) + } else { + let compress_input = + *opcode_workspace.compress().memory_accesses[i - WIDTH / 2].value(); + let absorb_input = previous_state.into(); + let finalize_input = previous_state.into(); + + (compress_input, absorb_input, finalize_input) + }; + + control_flow.is_compress * compress_input + + control_flow.is_absorb * absorb_input + + control_flow.is_finalize * finalize_input + }); + + // Apply the initial round. + let initial_round_output = { + let mut initial_round_output = input; + external_linear_layer(&mut initial_round_output); + initial_round_output + }; + let external_round_0_state: [AB::Expr; WIDTH] = core::array::from_fn(|i| { + let state = perm_cols.external_rounds_state()[0]; + state[i].into() + }); + + builder.assert_all_eq(external_round_0_state.clone(), initial_round_output); + + // Apply the first half of external rounds. + for r in 0..NUM_EXTERNAL_ROUNDS / 2 { + self.eval_external_round(builder, perm_cols, r); + } + + // Apply the internal rounds. + self.eval_internal_rounds(builder, perm_cols); + + // Apply the second half of external rounds. + for r in NUM_EXTERNAL_ROUNDS / 2..NUM_EXTERNAL_ROUNDS { + self.eval_external_round(builder, perm_cols, r); + } + } + + fn eval_external_round( + &self, + builder: &mut AB, + perm_cols: &dyn Permutation, + r: usize, + ) { + let external_state = perm_cols.external_rounds_state()[r]; + + // Add the round constants. + let round = if r < NUM_EXTERNAL_ROUNDS / 2 { + r + } else { + r + NUM_INTERNAL_ROUNDS + }; + let add_rc: [AB::Expr; WIDTH] = core::array::from_fn(|i| { + external_state[i].into() + AB::F::from_wrapped_u32(RC_16_30_U32[round][i]) + }); + + // Apply the sboxes. + // See `populate_external_round` for why we don't have columns for the sbox output here. + let mut sbox_deg_7: [AB::Expr; WIDTH] = core::array::from_fn(|_| AB::Expr::zero()); + let mut sbox_deg_3: [AB::Expr; WIDTH] = core::array::from_fn(|_| AB::Expr::zero()); + for i in 0..WIDTH { + let calculated_sbox_deg_3 = add_rc[i].clone() * add_rc[i].clone() * add_rc[i].clone(); + + if let Some(external_sbox) = perm_cols.external_rounds_sbox() { + builder.assert_eq(external_sbox[r][i].into(), calculated_sbox_deg_3); + sbox_deg_3[i] = external_sbox[r][i].into(); + } else { + sbox_deg_3[i] = calculated_sbox_deg_3; + } + + sbox_deg_7[i] = sbox_deg_3[i].clone() * sbox_deg_3[i].clone() * add_rc[i].clone(); + } + + // Apply the linear layer. + let mut state = sbox_deg_7; + external_linear_layer(&mut state); + + let next_state_cols = if r == NUM_EXTERNAL_ROUNDS / 2 - 1 { + perm_cols.internal_rounds_state() + } else if r == NUM_EXTERNAL_ROUNDS - 1 { + perm_cols.perm_output() + } else { + &perm_cols.external_rounds_state()[r + 1] + }; + for i in 0..WIDTH { + builder.assert_eq(next_state_cols[i], state[i].clone()); + } + } + + fn eval_internal_rounds( + &self, + builder: &mut AB, + perm_cols: &dyn Permutation, + ) { + let state = &perm_cols.internal_rounds_state(); + let s0 = perm_cols.internal_rounds_s0(); + let mut state: [AB::Expr; WIDTH] = core::array::from_fn(|i| state[i].into()); + for r in 0..NUM_INTERNAL_ROUNDS { + // Add the round constant. + let round = r + NUM_EXTERNAL_ROUNDS / 2; + let add_rc = if r == 0 { + state[0].clone() + } else { + s0[r - 1].into() + } + AB::Expr::from_wrapped_u32(RC_16_30_U32[round][0]); + + let mut sbox_deg_3 = add_rc.clone() * add_rc.clone() * add_rc.clone(); + if let Some(internal_sbox) = perm_cols.internal_rounds_sbox() { + builder.assert_eq(internal_sbox[r], sbox_deg_3); + sbox_deg_3 = internal_sbox[r].into(); + } + + // See `populate_internal_rounds` for why we don't have columns for the sbox output here. + let sbox_deg_7 = sbox_deg_3.clone() * sbox_deg_3.clone() * add_rc.clone(); + + // Apply the linear layer. + // See `populate_internal_rounds` for why we don't have columns for the new state here. + state[0] = sbox_deg_7.clone(); + internal_linear_layer(&mut state); + + if r < NUM_INTERNAL_ROUNDS - 1 { + builder.assert_eq(s0[r], state[0].clone()); + } + } + + let external_state = perm_cols.external_rounds_state()[NUM_EXTERNAL_ROUNDS / 2]; + for i in 0..WIDTH { + builder.assert_eq(external_state[i], state[i].clone()) + } + } +} diff --git a/recursion/core/src/poseidon2_wide/air/state_transition.rs b/recursion/core/src/poseidon2_wide/air/state_transition.rs new file mode 100644 index 0000000000..1b4b522a5d --- /dev/null +++ b/recursion/core/src/poseidon2_wide/air/state_transition.rs @@ -0,0 +1,123 @@ +use std::array; + +use p3_air::AirBuilder; +use sp1_core::{air::BaseAirBuilder, utils::DIGEST_SIZE}; + +use crate::{ + air::SP1RecursionAirBuilder, + memory::MemoryCols, + poseidon2_wide::{ + columns::{ + control_flow::ControlFlow, memory::Memory, opcode_workspace::OpcodeWorkspace, + permutation::Permutation, + }, + Poseidon2WideChip, WIDTH, + }, +}; + +impl Poseidon2WideChip { + #[allow(clippy::too_many_arguments)] + pub(crate) fn eval_state_transition( + &self, + builder: &mut AB, + control_flow: &ControlFlow, + local_opcode_workspace: &OpcodeWorkspace, + next_opcode_workspace: &OpcodeWorkspace, + permutation: &dyn Permutation, + local_memory: &Memory, + next_memory: &Memory, + ) { + // For compress syscall rows, verify that the permutation output's state is equal to + // the compress output memory values. + { + let compress_output_mem_values: [AB::Var; WIDTH] = array::from_fn(|i| { + if i < WIDTH / 2 { + *next_memory.memory_accesses[i].value() + } else { + *next_opcode_workspace.compress().memory_accesses[i - WIDTH / 2].value() + } + }); + + builder + .when_transition() + .when(control_flow.is_compress) + .when(control_flow.is_syscall_row) + .assert_all_eq(compress_output_mem_values, *permutation.perm_output()); + } + + // Absorb rows. + { + // Check that the state is zero on the first_hash_row. + builder + .when(control_flow.is_absorb) + .when(local_opcode_workspace.absorb().is_first_hash_row) + .assert_all_zero(local_opcode_workspace.absorb().previous_state); + + // Check that the state is equal to the permutation output when the permutation is applied. + builder + .when(control_flow.is_absorb) + .when(local_opcode_workspace.absorb().do_perm::()) + .assert_all_eq( + local_opcode_workspace.absorb().state, + *permutation.perm_output(), + ); + + // Construct the input into the permutation. + let input: [AB::Expr; WIDTH] = array::from_fn(|i| { + if i < WIDTH / 2 { + builder.if_else( + local_memory.memory_slot_used[i], + *local_memory.memory_accesses[i].value(), + local_opcode_workspace.absorb().previous_state[i], + ) + } else { + local_opcode_workspace.absorb().previous_state[i].into() + } + }); + + // Check that the state is equal the the permutation input when the permutation is not applied. + builder + .when(control_flow.is_absorb_no_perm) + .assert_all_eq(local_opcode_workspace.absorb().state, input); + + // Check that the state is copied to the next row. + builder + .when_transition() + .when(control_flow.is_absorb) + .assert_all_eq( + local_opcode_workspace.absorb().state, + next_opcode_workspace.absorb().previous_state, + ); + } + + // Finalize rows. + { + // Check that the state is equal to the permutation output when the permutation is applied. + builder + .when(control_flow.is_finalize) + .when(local_opcode_workspace.finalize().do_perm::()) + .assert_all_eq( + local_opcode_workspace.finalize().state, + *permutation.perm_output(), + ); + + // Check that the state is equal to the previous state when the permutation is not applied. + builder + .when(control_flow.is_finalize) + .when_not(local_opcode_workspace.finalize().do_perm::()) + .assert_all_eq( + local_opcode_workspace.finalize().state, + local_opcode_workspace.finalize().previous_state, + ); + + // Check that the finalize memory values are equal to the state. + let output_mem_values: [AB::Var; DIGEST_SIZE] = + array::from_fn(|i| *local_memory.memory_accesses[i].value()); + + builder.when(control_flow.is_finalize).assert_all_eq( + output_mem_values, + local_opcode_workspace.finalize().state[0..DIGEST_SIZE].to_vec(), + ); + } + } +} diff --git a/recursion/core/src/poseidon2_wide/air/syscall_params.rs b/recursion/core/src/poseidon2_wide/air/syscall_params.rs new file mode 100644 index 0000000000..a79878e0ac --- /dev/null +++ b/recursion/core/src/poseidon2_wide/air/syscall_params.rs @@ -0,0 +1,90 @@ +use p3_air::AirBuilder; +use sp1_core::air::BaseAirBuilder; + +use crate::{ + air::SP1RecursionAirBuilder, + poseidon2_wide::{ + columns::{control_flow::ControlFlow, syscall_params::SyscallParams}, + Poseidon2WideChip, + }, + runtime::Opcode, +}; + +impl Poseidon2WideChip { + /// Eval the syscall parameters. + pub(crate) fn eval_syscall_params( + &self, + builder: &mut AB, + local_syscall: &SyscallParams, + next_syscall: &SyscallParams, + local_control_flow: &ControlFlow, + next_control_flow: &ControlFlow, + receive_syscall: AB::Var, + ) { + // Constraint that the operands are sent from the CPU table. + let params = local_syscall.get_raw_params(); + let opcodes: [AB::Expr; 3] = [ + Opcode::Poseidon2Compress, + Opcode::Poseidon2Absorb, + Opcode::Poseidon2Finalize, + ] + .map(|x| x.as_field::().into()); + let opcode_selectors = [ + local_control_flow.is_compress, + local_control_flow.is_absorb, + local_control_flow.is_finalize, + ]; + + let used_opcode: AB::Expr = opcodes + .iter() + .zip(opcode_selectors.iter()) + .map(|(opcode, opcode_selector)| opcode.clone() * *opcode_selector) + .sum(); + + builder.receive_table(used_opcode, ¶ms, receive_syscall); + + let mut transition_builder = builder.when_transition(); + + // Verify that the syscall parameters are copied to the compress output row. + { + let mut compress_syscall_builder = transition_builder + .when(local_control_flow.is_compress * local_control_flow.is_syscall_row); + + let local_syscall_params = local_syscall.compress(); + let next_syscall_params = next_syscall.compress(); + compress_syscall_builder.assert_eq(local_syscall_params.clk, next_syscall_params.clk); + compress_syscall_builder + .assert_eq(local_syscall_params.dst_ptr, next_syscall_params.dst_ptr); + compress_syscall_builder + .assert_eq(local_syscall_params.left_ptr, next_syscall_params.left_ptr); + compress_syscall_builder.assert_eq( + local_syscall_params.right_ptr, + next_syscall_params.right_ptr, + ); + } + + // Verify that the syscall parameters are copied down to all the non syscall absorb rows. + { + let mut absorb_syscall_builder = transition_builder.when(local_control_flow.is_absorb); + let mut absorb_syscall_builder = + absorb_syscall_builder.when_not(next_control_flow.is_syscall_row); + + let local_syscall_params = local_syscall.absorb(); + let next_syscall_params = next_syscall.absorb(); + + absorb_syscall_builder.assert_eq(local_syscall_params.clk, next_syscall_params.clk); + absorb_syscall_builder.assert_eq( + local_syscall_params.hash_and_absorb_num, + next_syscall_params.hash_and_absorb_num, + ); + absorb_syscall_builder.assert_eq( + local_syscall_params.input_ptr, + next_syscall_params.input_ptr, + ); + absorb_syscall_builder.assert_eq( + local_syscall_params.input_len, + next_syscall_params.input_len, + ); + } + } +} diff --git a/recursion/core/src/poseidon2_wide/columns.rs b/recursion/core/src/poseidon2_wide/columns.rs deleted file mode 100644 index 371b9d620d..0000000000 --- a/recursion/core/src/poseidon2_wide/columns.rs +++ /dev/null @@ -1,110 +0,0 @@ -use std::mem::size_of; - -use sp1_derive::AlignedBorrow; - -use crate::memory::{MemoryReadSingleCols, MemoryReadWriteSingleCols}; - -use super::external::{NUM_EXTERNAL_ROUNDS, NUM_INTERNAL_ROUNDS, WIDTH}; - -/// An enum the encapsulates mutable references to a wide version of poseidon2 chip (contains -/// intermediate sbox colunns) and a narrow version of the poseidon2 chip (doesn't contain -/// intermediate sbox columns). -pub(crate) enum Poseidon2ColTypeMut<'a, T> { - Wide(&'a mut Poseidon2SBoxCols), - Narrow(&'a mut Poseidon2Cols), -} - -impl Poseidon2ColTypeMut<'_, T> { - /// Returns mutable references to the poseidon2 columns and optional the intermediate sbox columns. - #[allow(clippy::type_complexity)] - pub fn get_cols_mut( - &mut self, - ) -> ( - &mut Poseidon2Cols, - Option<&mut [[T; WIDTH]; NUM_EXTERNAL_ROUNDS]>, - Option<&mut [T; NUM_INTERNAL_ROUNDS]>, - ) { - match self { - Poseidon2ColTypeMut::Wide(cols) => ( - &mut cols.poseidon2_cols, - Some(&mut cols.external_rounds_sbox), - Some(&mut cols.internal_rounds_sbox), - ), - Poseidon2ColTypeMut::Narrow(cols) => (cols, None, None), - } - } -} - -/// An immutable version of Poseidon2ColTypeMut. -pub(crate) enum Poseidon2ColType { - Wide(Poseidon2SBoxCols), - Narrow(Poseidon2Cols), -} - -impl Poseidon2ColType { - /// Returns reference to the poseidon2 columns. - pub fn get_poseidon2_cols(&self) -> Poseidon2Cols { - match self { - Poseidon2ColType::Wide(cols) => cols.poseidon2_cols.clone(), - Poseidon2ColType::Narrow(cols) => cols.clone(), - } - } - - /// Returns the external sbox columns for the given round. - pub const fn get_external_sbox(&self, round: usize) -> Option<&[T; WIDTH]> { - match self { - Poseidon2ColType::Wide(cols) => Some(&cols.external_rounds_sbox[round]), - Poseidon2ColType::Narrow(_) => None, - } - } - - /// Returns the internal sbox columns. - pub const fn get_internal_sbox(&self) -> Option<&[T; NUM_INTERNAL_ROUNDS]> { - match self { - Poseidon2ColType::Wide(cols) => Some(&cols.internal_rounds_sbox), - Poseidon2ColType::Narrow(_) => None, - } - } -} - -/// Memory columns for Poseidon2. -#[derive(AlignedBorrow, Clone, Copy)] -#[repr(C)] -pub struct Poseidon2MemCols { - pub timestamp: T, - pub dst: T, - pub left: T, - pub right: T, - pub input: [MemoryReadSingleCols; WIDTH], - pub output: [MemoryReadWriteSingleCols; WIDTH], - pub is_real: T, -} - -pub const NUM_POSEIDON2_COLS: usize = size_of::>(); - -/// Columns for the "narrow" Poseidon2 chip. -/// -/// As an optimization, we can represent all of the internal rounds without columns for intermediate -/// states except for the 0th element. This is because the linear layer that comes after the sbox is -/// degree 1, so all state elements at the end can be expressed as a degree-3 polynomial of: -/// 1) the 0th state element at rounds prior to the current round -/// 2) the rest of the state elements at the beginning of the internal rounds -#[derive(AlignedBorrow, Clone, Copy)] -#[repr(C)] -pub struct Poseidon2Cols { - pub(crate) memory: Poseidon2MemCols, - pub(crate) external_rounds_state: [[T; WIDTH]; NUM_EXTERNAL_ROUNDS], - pub(crate) internal_rounds_state: [T; WIDTH], - pub(crate) internal_rounds_s0: [T; NUM_INTERNAL_ROUNDS - 1], -} - -pub const NUM_POSEIDON2_SBOX_COLS: usize = size_of::>(); - -/// Columns for the "wide" Poseidon2 chip. -#[derive(AlignedBorrow, Clone, Copy)] -#[repr(C)] -pub struct Poseidon2SBoxCols { - pub(crate) poseidon2_cols: Poseidon2Cols, - pub(crate) external_rounds_sbox: [[T; WIDTH]; NUM_EXTERNAL_ROUNDS], - pub(crate) internal_rounds_sbox: [T; NUM_INTERNAL_ROUNDS], -} diff --git a/recursion/core/src/poseidon2_wide/columns/control_flow.rs b/recursion/core/src/poseidon2_wide/columns/control_flow.rs new file mode 100644 index 0000000000..06b13534b4 --- /dev/null +++ b/recursion/core/src/poseidon2_wide/columns/control_flow.rs @@ -0,0 +1,26 @@ +use sp1_derive::AlignedBorrow; + +/// Columns related to control flow. +#[derive(AlignedBorrow, Clone, Copy, Debug)] +#[repr(C)] +pub struct ControlFlow { + /// Specifies if this row is for compress. + pub is_compress: T, + /// Specifies if this row is for the compress output. + pub is_compress_output: T, + + /// Specifies if this row is for absorb. + pub is_absorb: T, + /// Specifies if this row is for absorb with no permutation. + pub is_absorb_no_perm: T, + /// Specifies if this row is for an absorb that is not the last row. + pub is_absorb_not_last_row: T, + /// Specifies if this row is for an absorb that is the last row. + pub is_absorb_last_row: T, + + /// Specifies if this row is for finalize. + pub is_finalize: T, + + /// Specifies if this row needs to recieve a syscall interaction. + pub is_syscall_row: T, +} diff --git a/recursion/core/src/poseidon2_wide/columns/memory.rs b/recursion/core/src/poseidon2_wide/columns/memory.rs new file mode 100644 index 0000000000..63b62783ad --- /dev/null +++ b/recursion/core/src/poseidon2_wide/columns/memory.rs @@ -0,0 +1,17 @@ +use sp1_derive::AlignedBorrow; + +use crate::{memory::MemoryReadWriteSingleCols, poseidon2_wide::WIDTH}; + +/// This struct is the columns for the WIDTH/2 sequential memory slots. +/// For compress rows, this is used for the first half of read/write from the permutation state. +/// For hash related rows, this is reading absorb input and writing finalize output. +#[derive(AlignedBorrow, Clone, Copy, Debug)] +#[repr(C)] +pub struct Memory { + /// The first address of the memory sequence. + pub start_addr: T, + /// Bitmap if whether the memory address is accessed. This is set to all 1 for compress and + /// finalize rows. + pub memory_slot_used: [T; WIDTH / 2], + pub memory_accesses: [MemoryReadWriteSingleCols; WIDTH / 2], +} diff --git a/recursion/core/src/poseidon2_wide/columns/mod.rs b/recursion/core/src/poseidon2_wide/columns/mod.rs new file mode 100644 index 0000000000..eafda7b4d6 --- /dev/null +++ b/recursion/core/src/poseidon2_wide/columns/mod.rs @@ -0,0 +1,249 @@ +use std::mem::{size_of, transmute}; + +use sp1_core::utils::indices_arr; +use sp1_derive::AlignedBorrow; + +use self::{ + control_flow::ControlFlow, + memory::Memory, + opcode_workspace::OpcodeWorkspace, + permutation::{Permutation, PermutationNoSbox, PermutationSBox}, + syscall_params::SyscallParams, +}; + +use super::WIDTH; + +pub mod control_flow; +pub mod memory; +pub mod opcode_workspace; +pub mod permutation; +pub mod syscall_params; + +/// Trait for getter methods for Poseidon2 columns. +pub trait Poseidon2<'a, T: Copy + 'a> { + fn control_flow(&self) -> &ControlFlow; + + fn syscall_params(&self) -> &SyscallParams; + + fn memory(&self) -> &Memory; + + fn opcode_workspace(&self) -> &OpcodeWorkspace; + + fn permutation(&self) -> Box + 'a>; +} + +/// Trait for setter methods for Poseidon2 columns. +pub trait Poseidon2Mut<'a, T: Copy + 'a> { + fn control_flow_mut(&mut self) -> &mut ControlFlow; + + fn syscall_params_mut(&mut self) -> &mut SyscallParams; + + fn memory_mut(&mut self) -> &mut Memory; + + fn opcode_workspace_mut(&mut self) -> &mut OpcodeWorkspace; +} + +/// Enum to enable dynamic dispatch for the Poseidon2 columns. +#[allow(dead_code)] +enum Poseidon2Enum { + P2Degree3(Poseidon2Degree3), + P2Degree9(Poseidon2Degree9), +} + +impl<'a, T: Copy + 'a> Poseidon2<'a, T> for Poseidon2Enum { + // type Perm = PermutationSBox; + + fn control_flow(&self) -> &ControlFlow { + match self { + Poseidon2Enum::P2Degree3(p) => p.control_flow(), + Poseidon2Enum::P2Degree9(p) => p.control_flow(), + } + } + + fn syscall_params(&self) -> &SyscallParams { + match self { + Poseidon2Enum::P2Degree3(p) => p.syscall_params(), + Poseidon2Enum::P2Degree9(p) => p.syscall_params(), + } + } + + fn memory(&self) -> &Memory { + match self { + Poseidon2Enum::P2Degree3(p) => p.memory(), + Poseidon2Enum::P2Degree9(p) => p.memory(), + } + } + + fn opcode_workspace(&self) -> &OpcodeWorkspace { + match self { + Poseidon2Enum::P2Degree3(p) => p.opcode_workspace(), + Poseidon2Enum::P2Degree9(p) => p.opcode_workspace(), + } + } + + fn permutation(&self) -> Box + 'a> { + match self { + Poseidon2Enum::P2Degree3(p) => p.permutation(), + Poseidon2Enum::P2Degree9(p) => p.permutation(), + } + } +} + +/// Enum to enable dynamic dispatch for the Poseidon2 columns. +#[allow(dead_code)] +enum Poseidon2MutEnum<'a, T: Copy> { + P2Degree3(&'a mut Poseidon2Degree3), + P2Degree9(&'a mut Poseidon2Degree9), +} + +impl<'a, T: Copy + 'a> Poseidon2Mut<'a, T> for Poseidon2MutEnum<'a, T> { + fn control_flow_mut(&mut self) -> &mut ControlFlow { + match self { + Poseidon2MutEnum::P2Degree3(p) => p.control_flow_mut(), + Poseidon2MutEnum::P2Degree9(p) => p.control_flow_mut(), + } + } + + fn syscall_params_mut(&mut self) -> &mut SyscallParams { + match self { + Poseidon2MutEnum::P2Degree3(p) => p.syscall_params_mut(), + Poseidon2MutEnum::P2Degree9(p) => p.syscall_params_mut(), + } + } + + fn memory_mut(&mut self) -> &mut Memory { + match self { + Poseidon2MutEnum::P2Degree3(p) => p.memory_mut(), + Poseidon2MutEnum::P2Degree9(p) => p.memory_mut(), + } + } + + fn opcode_workspace_mut(&mut self) -> &mut OpcodeWorkspace { + match self { + Poseidon2MutEnum::P2Degree3(p) => p.opcode_workspace_mut(), + Poseidon2MutEnum::P2Degree9(p) => p.opcode_workspace_mut(), + } + } +} + +pub const NUM_POSEIDON2_DEGREE3_COLS: usize = size_of::>(); + +const fn make_col_map_degree3() -> Poseidon2Degree3 { + let indices_arr = indices_arr::(); + unsafe { + transmute::<[usize; NUM_POSEIDON2_DEGREE3_COLS], Poseidon2Degree3>(indices_arr) + } +} +pub const POSEIDON2_DEGREE3_COL_MAP: Poseidon2Degree3 = make_col_map_degree3(); + +/// Struct for the poseidon2 chip that contains sbox columns. +#[derive(AlignedBorrow, Clone, Copy)] +#[repr(C)] +pub struct Poseidon2Degree3 { + pub control_flow: ControlFlow, + pub syscall_input: SyscallParams, + pub memory: Memory, + pub opcode_specific_cols: OpcodeWorkspace, + pub permutation_cols: PermutationSBox, + pub state_cursor: [T; WIDTH / 2], // Only used for absorb +} + +impl<'a, T: Copy + 'a> Poseidon2<'a, T> for Poseidon2Degree3 { + fn control_flow(&self) -> &ControlFlow { + &self.control_flow + } + + fn syscall_params(&self) -> &SyscallParams { + &self.syscall_input + } + + fn memory(&self) -> &Memory { + &self.memory + } + + fn opcode_workspace(&self) -> &OpcodeWorkspace { + &self.opcode_specific_cols + } + + fn permutation(&self) -> Box + 'a> { + Box::new(self.permutation_cols) + } +} + +impl<'a, T: Copy + 'a> Poseidon2Mut<'a, T> for &'a mut Poseidon2Degree3 { + fn control_flow_mut(&mut self) -> &mut ControlFlow { + &mut self.control_flow + } + + fn syscall_params_mut(&mut self) -> &mut SyscallParams { + &mut self.syscall_input + } + + fn memory_mut(&mut self) -> &mut Memory { + &mut self.memory + } + + fn opcode_workspace_mut(&mut self) -> &mut OpcodeWorkspace { + &mut self.opcode_specific_cols + } +} + +pub const NUM_POSEIDON2_DEGREE9_COLS: usize = size_of::>(); +const fn make_col_map_degree9() -> Poseidon2Degree9 { + let indices_arr = indices_arr::(); + unsafe { + transmute::<[usize; NUM_POSEIDON2_DEGREE9_COLS], Poseidon2Degree9>(indices_arr) + } +} +pub const POSEIDON2_DEGREE9_COL_MAP: Poseidon2Degree9 = make_col_map_degree9(); + +/// Struct for the poseidon2 chip that doesn't contain sbox columns. +#[derive(AlignedBorrow, Clone, Copy)] +#[repr(C)] +pub struct Poseidon2Degree9 { + pub control_flow: ControlFlow, + pub syscall_input: SyscallParams, + pub memory: Memory, + pub opcode_specific_cols: OpcodeWorkspace, + pub permutation_cols: PermutationNoSbox, +} + +impl<'a, T: Copy + 'a> Poseidon2<'a, T> for Poseidon2Degree9 { + fn control_flow(&self) -> &ControlFlow { + &self.control_flow + } + + fn syscall_params(&self) -> &SyscallParams { + &self.syscall_input + } + + fn memory(&self) -> &Memory { + &self.memory + } + + fn opcode_workspace(&self) -> &OpcodeWorkspace { + &self.opcode_specific_cols + } + + fn permutation(&self) -> Box + 'a> { + Box::new(self.permutation_cols) + } +} + +impl<'a, T: Copy + 'a> Poseidon2Mut<'a, T> for &'a mut Poseidon2Degree9 { + fn control_flow_mut(&mut self) -> &mut ControlFlow { + &mut self.control_flow + } + + fn syscall_params_mut(&mut self) -> &mut SyscallParams { + &mut self.syscall_input + } + + fn memory_mut(&mut self) -> &mut Memory { + &mut self.memory + } + + fn opcode_workspace_mut(&mut self) -> &mut OpcodeWorkspace { + &mut self.opcode_specific_cols + } +} diff --git a/recursion/core/src/poseidon2_wide/columns/opcode_workspace.rs b/recursion/core/src/poseidon2_wide/columns/opcode_workspace.rs new file mode 100644 index 0000000000..3ff574f3c6 --- /dev/null +++ b/recursion/core/src/poseidon2_wide/columns/opcode_workspace.rs @@ -0,0 +1,145 @@ +use p3_field::AbstractField; +use sp1_core::operations::IsZeroOperation; +use sp1_derive::AlignedBorrow; + +use crate::{ + air::SP1RecursionAirBuilder, + memory::MemoryReadWriteSingleCols, + poseidon2_wide::{RATE, WIDTH}, +}; + +/// Workspace columns. They are different for each opcode. +#[derive(AlignedBorrow, Clone, Copy)] +#[repr(C)] +pub union OpcodeWorkspace { + compress: CompressWorkspace, + absorb: AbsorbWorkspace, + finalize: FinalizeWorkspace, +} +/// Getter and setter functions for the opcode workspace. +impl OpcodeWorkspace { + pub fn compress(&self) -> &CompressWorkspace { + unsafe { &self.compress } + } + + pub fn compress_mut(&mut self) -> &mut CompressWorkspace { + unsafe { &mut self.compress } + } + + pub fn absorb(&self) -> &AbsorbWorkspace { + unsafe { &self.absorb } + } + + pub fn absorb_mut(&mut self) -> &mut AbsorbWorkspace { + unsafe { &mut self.absorb } + } + + pub fn finalize(&self) -> &FinalizeWorkspace { + unsafe { &self.finalize } + } + + pub fn finalize_mut(&mut self) -> &mut FinalizeWorkspace { + unsafe { &mut self.finalize } + } +} + +/// Workspace columns for compress. This is used memory read/writes for the 2nd half of the +/// compress permutation state. +#[derive(AlignedBorrow, Clone, Copy)] +#[repr(C)] +pub struct CompressWorkspace { + pub start_addr: T, + pub memory_accesses: [MemoryReadWriteSingleCols; WIDTH / 2], +} + +/// Workspace columns for absorb. +#[derive(AlignedBorrow, Clone, Copy, Debug)] +#[repr(C)] +pub struct AbsorbWorkspace { + /// State related columns. + pub previous_state: [T; WIDTH], + pub state: [T; WIDTH], + pub state_cursor: T, + + /// Control flow columns. + pub hash_num: T, + pub absorb_num: T, + pub is_first_hash_row: T, + pub num_remaining_rows: T, + pub num_remaining_rows_is_zero: IsZeroOperation, + + /// Memory columns. + pub start_mem_idx_bitmap: [T; WIDTH / 2], + pub end_mem_idx_bitmap: [T; WIDTH / 2], + + /// This is the state index of that last element consumed by the absorb syscall. + pub last_row_ending_cursor: T, + pub last_row_ending_cursor_is_seven: IsZeroOperation, // Needed when doing the (last_row_ending_cursor_is_seven + 1) % 8 calculation. + pub last_row_ending_cursor_bitmap: [T; 3], + + /// Materialized control flow flags to deal with max contraint degree. + /// Is an absorb syscall row which is not the last row for that absorb. + pub is_syscall_not_last_row: T, + /// Is an absorb syscall row that is the last row for that absorb. + pub is_syscall_is_last_row: T, + /// Is not an absorb syscall row and is not the last row for that absorb. + pub not_syscall_not_last_row: T, + /// Is not an absorb syscall row and is last row for that absorb. + pub not_syscall_is_last_row: T, + /// Is the last of an absorb and the state is filled up (e.g. it's ending cursor is 7). + pub is_last_row_ending_cursor_is_seven: T, + /// Is the last of an absorb and the state is not filled up (e.g. it's ending cursor is not 7). + pub is_last_row_ending_cursor_not_seven: T, +} + +/// Methods that are "virtual" columns (e.g. will return expressions). +impl AbsorbWorkspace { + pub(crate) fn is_last_row(&self) -> AB::Expr + where + T: Into, + { + self.num_remaining_rows_is_zero.result.into() + } + + pub(crate) fn do_perm(&self) -> AB::Expr + where + T: Into, + { + self.is_syscall_not_last_row.into() + + self.not_syscall_not_last_row.into() + + self.is_last_row_ending_cursor_is_seven.into() + } + + pub(crate) fn num_consumed(&self) -> AB::Expr + where + T: Into, + { + self.is_syscall_not_last_row.into() + * (AB::Expr::from_canonical_usize(RATE) - self.state_cursor.into()) + + self.is_syscall_is_last_row.into() + * (self.last_row_ending_cursor.into() - self.state_cursor.into() + AB::Expr::one()) + + self.not_syscall_not_last_row.into() * AB::Expr::from_canonical_usize(RATE) + + self.not_syscall_is_last_row.into() + * (self.last_row_ending_cursor.into() + AB::Expr::one()) + } +} + +/// Workspace columns for finalize. +#[derive(AlignedBorrow, Clone, Copy)] +#[repr(C)] +pub struct FinalizeWorkspace { + /// State related columns. + pub previous_state: [T; WIDTH], + pub state: [T; WIDTH], + pub state_cursor: T, + pub state_cursor_is_zero: IsZeroOperation, +} + +impl FinalizeWorkspace { + pub(crate) fn do_perm(&self) -> AB::Expr + where + T: Into, + { + AB::Expr::one() - self.state_cursor_is_zero.result.into() + } +} diff --git a/recursion/core/src/poseidon2_wide/columns/permutation.rs b/recursion/core/src/poseidon2_wide/columns/permutation.rs new file mode 100644 index 0000000000..caaab08fd0 --- /dev/null +++ b/recursion/core/src/poseidon2_wide/columns/permutation.rs @@ -0,0 +1,239 @@ +use std::{borrow::BorrowMut, mem::size_of}; + +use sp1_derive::AlignedBorrow; + +use crate::poseidon2_wide::{NUM_EXTERNAL_ROUNDS, NUM_INTERNAL_ROUNDS, WIDTH}; + +use super::{POSEIDON2_DEGREE3_COL_MAP, POSEIDON2_DEGREE9_COL_MAP}; + +/// Trait that describes getter functions for the permutation columns. +pub trait Permutation { + fn external_rounds_state(&self) -> &[[T; WIDTH]]; + + fn internal_rounds_state(&self) -> &[T; WIDTH]; + + fn internal_rounds_s0(&self) -> &[T; NUM_INTERNAL_ROUNDS - 1]; + + fn external_rounds_sbox(&self) -> Option<&[[T; WIDTH]; NUM_EXTERNAL_ROUNDS]>; + + fn internal_rounds_sbox(&self) -> Option<&[T; NUM_INTERNAL_ROUNDS]>; + + fn perm_output(&self) -> &[T; WIDTH]; +} + +/// Trait that describes setter functions for the permutation columns. +pub trait PermutationMut { + #[allow(clippy::type_complexity)] + fn get_cols_mut( + &mut self, + ) -> ( + &mut [[T; WIDTH]], + &mut [T; WIDTH], + &mut [T; NUM_INTERNAL_ROUNDS - 1], + Option<&mut [[T; WIDTH]; NUM_EXTERNAL_ROUNDS]>, + Option<&mut [T; NUM_INTERNAL_ROUNDS]>, + &mut [T; WIDTH], + ); +} + +/// Permutation columns struct with S-boxes. +#[derive(AlignedBorrow, Clone, Copy)] +#[repr(C)] +pub struct PermutationSBox { + pub external_rounds_state: [[T; WIDTH]; NUM_EXTERNAL_ROUNDS], + pub internal_rounds_state: [T; WIDTH], + pub internal_rounds_s0: [T; NUM_INTERNAL_ROUNDS - 1], + pub external_rounds_sbox: [[T; WIDTH]; NUM_EXTERNAL_ROUNDS], + pub internal_rounds_sbox: [T; NUM_INTERNAL_ROUNDS], + pub output_state: [T; WIDTH], +} + +impl Permutation for PermutationSBox { + fn external_rounds_state(&self) -> &[[T; WIDTH]] { + &self.external_rounds_state + } + + fn internal_rounds_state(&self) -> &[T; WIDTH] { + &self.internal_rounds_state + } + + fn internal_rounds_s0(&self) -> &[T; NUM_INTERNAL_ROUNDS - 1] { + &self.internal_rounds_s0 + } + + fn external_rounds_sbox(&self) -> Option<&[[T; WIDTH]; NUM_EXTERNAL_ROUNDS]> { + Some(&self.external_rounds_sbox) + } + + fn internal_rounds_sbox(&self) -> Option<&[T; NUM_INTERNAL_ROUNDS]> { + Some(&self.internal_rounds_sbox) + } + + fn perm_output(&self) -> &[T; WIDTH] { + &self.output_state + } +} + +impl PermutationMut for &mut PermutationSBox { + fn get_cols_mut( + &mut self, + ) -> ( + &mut [[T; WIDTH]], + &mut [T; WIDTH], + &mut [T; NUM_INTERNAL_ROUNDS - 1], + Option<&mut [[T; WIDTH]; NUM_EXTERNAL_ROUNDS]>, + Option<&mut [T; NUM_INTERNAL_ROUNDS]>, + &mut [T; WIDTH], + ) { + ( + &mut self.external_rounds_state, + &mut self.internal_rounds_state, + &mut self.internal_rounds_s0, + Some(&mut self.external_rounds_sbox), + Some(&mut self.internal_rounds_sbox), + &mut self.output_state, + ) + } +} + +/// Permutation columns struct without S-boxes. +#[derive(AlignedBorrow, Clone, Copy)] +#[repr(C)] +pub struct PermutationNoSbox { + pub external_rounds_state: [[T; WIDTH]; NUM_EXTERNAL_ROUNDS], + pub internal_rounds_state: [T; WIDTH], + pub internal_rounds_s0: [T; NUM_INTERNAL_ROUNDS - 1], + pub output_state: [T; WIDTH], +} + +impl Permutation for PermutationNoSbox { + fn external_rounds_state(&self) -> &[[T; WIDTH]] { + &self.external_rounds_state + } + + fn internal_rounds_state(&self) -> &[T; WIDTH] { + &self.internal_rounds_state + } + + fn internal_rounds_s0(&self) -> &[T; NUM_INTERNAL_ROUNDS - 1] { + &self.internal_rounds_s0 + } + + fn external_rounds_sbox(&self) -> Option<&[[T; WIDTH]; NUM_EXTERNAL_ROUNDS]> { + None + } + + fn internal_rounds_sbox(&self) -> Option<&[T; NUM_INTERNAL_ROUNDS]> { + None + } + + fn perm_output(&self) -> &[T; WIDTH] { + &self.output_state + } +} + +impl PermutationMut for &mut PermutationNoSbox { + fn get_cols_mut( + &mut self, + ) -> ( + &mut [[T; WIDTH]], + &mut [T; WIDTH], + &mut [T; NUM_INTERNAL_ROUNDS - 1], + Option<&mut [[T; WIDTH]; NUM_EXTERNAL_ROUNDS]>, + Option<&mut [T; NUM_INTERNAL_ROUNDS]>, + &mut [T; WIDTH], + ) { + ( + &mut self.external_rounds_state, + &mut self.internal_rounds_state, + &mut self.internal_rounds_s0, + None, + None, + &mut self.output_state, + ) + } +} + +/// Permutation columns struct without S-boxes and half of the external rounds. +#[derive(AlignedBorrow, Clone, Copy)] +#[repr(C)] +pub struct PermutationNoSboxHalfExternal { + pub external_rounds_state: [[T; WIDTH]; NUM_EXTERNAL_ROUNDS / 2], + pub internal_rounds_state: [T; WIDTH], + pub internal_rounds_s0: [T; NUM_INTERNAL_ROUNDS - 1], + pub output_state: [T; WIDTH], +} + +impl Permutation for PermutationNoSboxHalfExternal { + fn external_rounds_state(&self) -> &[[T; WIDTH]] { + &self.external_rounds_state + } + + fn internal_rounds_state(&self) -> &[T; WIDTH] { + &self.internal_rounds_state + } + + fn internal_rounds_s0(&self) -> &[T; NUM_INTERNAL_ROUNDS - 1] { + &self.internal_rounds_s0 + } + + fn external_rounds_sbox(&self) -> Option<&[[T; WIDTH]; NUM_EXTERNAL_ROUNDS]> { + None + } + + fn internal_rounds_sbox(&self) -> Option<&[T; NUM_INTERNAL_ROUNDS]> { + None + } + + fn perm_output(&self) -> &[T; WIDTH] { + &self.output_state + } +} + +impl PermutationMut for &mut PermutationNoSboxHalfExternal { + fn get_cols_mut( + &mut self, + ) -> ( + &mut [[T; WIDTH]], + &mut [T; WIDTH], + &mut [T; NUM_INTERNAL_ROUNDS - 1], + Option<&mut [[T; WIDTH]; NUM_EXTERNAL_ROUNDS]>, + Option<&mut [T; NUM_INTERNAL_ROUNDS]>, + &mut [T; WIDTH], + ) { + ( + &mut self.external_rounds_state, + &mut self.internal_rounds_state, + &mut self.internal_rounds_s0, + None, + None, + &mut self.output_state, + ) + } +} + +pub fn permutation_mut<'a, 'b: 'a, T, const DEGREE: usize>( + row: &'b mut [T], +) -> Box + 'a> +where + T: Copy, +{ + if DEGREE == 3 { + let start = POSEIDON2_DEGREE3_COL_MAP + .permutation_cols + .external_rounds_state[0][0]; + let end = start + size_of::>(); + let convert: &mut PermutationSBox = row[start..end].borrow_mut(); + Box::new(convert) + } else if DEGREE == 9 || DEGREE == 17 { + let start = POSEIDON2_DEGREE9_COL_MAP + .permutation_cols + .external_rounds_state[0][0]; + let end = start + size_of::>(); + + let convert: &mut PermutationNoSbox = row[start..end].borrow_mut(); + Box::new(convert) + } else { + panic!("Unsupported degree"); + } +} diff --git a/recursion/core/src/poseidon2_wide/columns/syscall_params.rs b/recursion/core/src/poseidon2_wide/columns/syscall_params.rs new file mode 100644 index 0000000000..7550cfb8a5 --- /dev/null +++ b/recursion/core/src/poseidon2_wide/columns/syscall_params.rs @@ -0,0 +1,82 @@ +use std::mem::size_of; + +use sp1_derive::AlignedBorrow; + +const SYSCALL_PARAMS_SIZE: usize = size_of::>(); + +/// Syscall params columns. They are different for each opcode. +#[derive(AlignedBorrow, Clone, Copy)] +#[repr(C)] +pub union SyscallParams { + compress: CompressParams, + absorb: AbsorbParams, + finalize: FinalizeParams, +} + +impl SyscallParams { + pub fn compress(&self) -> &CompressParams { + assert!(size_of::>() == SYSCALL_PARAMS_SIZE); + unsafe { &self.compress } + } + + pub fn compress_mut(&mut self) -> &mut CompressParams { + unsafe { &mut self.compress } + } + + pub fn absorb(&self) -> &AbsorbParams { + assert!(size_of::>() == SYSCALL_PARAMS_SIZE); + unsafe { &self.absorb } + } + + pub fn absorb_mut(&mut self) -> &mut AbsorbParams { + unsafe { &mut self.absorb } + } + + pub fn finalize(&self) -> &FinalizeParams { + assert!(size_of::>() == SYSCALL_PARAMS_SIZE); + unsafe { &self.finalize } + } + + pub fn finalize_mut(&mut self) -> &mut FinalizeParams { + unsafe { &mut self.finalize } + } + + pub fn get_raw_params(&self) -> [T; SYSCALL_PARAMS_SIZE] { + // All of the union's fields should have the same size, so just choose one of them to return + // the elements. + let compress = self.compress(); + [ + compress.clk, + compress.dst_ptr, + compress.left_ptr, + compress.right_ptr, + ] + } +} + +#[derive(AlignedBorrow, Clone, Copy)] +#[repr(C)] +pub struct CompressParams { + pub clk: T, + pub dst_ptr: T, + pub left_ptr: T, + pub right_ptr: T, +} + +#[derive(AlignedBorrow, Clone, Copy)] +#[repr(C)] +pub struct AbsorbParams { + pub clk: T, + pub hash_and_absorb_num: T, + pub input_ptr: T, + pub input_len: T, +} + +#[derive(AlignedBorrow, Clone, Copy)] +#[repr(C)] +pub struct FinalizeParams { + pub clk: T, + pub hash_num: T, + pub output_ptr: T, + pub pad: T, +} diff --git a/recursion/core/src/poseidon2_wide/events.rs b/recursion/core/src/poseidon2_wide/events.rs new file mode 100644 index 0000000000..83e22415b2 --- /dev/null +++ b/recursion/core/src/poseidon2_wide/events.rs @@ -0,0 +1,156 @@ +use p3_field::PrimeField32; +use p3_symmetric::Permutation; + +use crate::memory::MemoryRecord; +use crate::poseidon2_wide::WIDTH; +use crate::runtime::DIGEST_SIZE; + +use super::RATE; + +#[derive(Debug, Clone)] +pub enum Poseidon2HashEvent { + Absorb(Poseidon2AbsorbEvent), + Finalize(Poseidon2FinalizeEvent), +} + +#[derive(Debug, Clone)] +pub struct Poseidon2CompressEvent { + pub clk: F, + pub dst: F, // from a_val + pub left: F, // from b_val + pub right: F, // from c_val + pub input: [F; WIDTH], + pub result_array: [F; WIDTH], + pub input_records: [MemoryRecord; WIDTH], + pub result_records: [MemoryRecord; WIDTH], +} + +#[derive(Debug, Clone)] +pub struct Poseidon2AbsorbEvent { + pub clk: F, + pub hash_and_absorb_num: F, // from a_val + pub input_addr: F, // from b_val + pub input_len: F, // from c_val + + pub hash_num: F, + pub absorb_num: F, + pub iterations: Vec>, +} + +impl Poseidon2AbsorbEvent { + pub(crate) fn new( + clk: F, + hash_and_absorb_num: F, + input_addr: F, + input_len: F, + hash_num: F, + absorb_num: F, + ) -> Self { + Self { + clk, + hash_and_absorb_num, + input_addr, + input_len, + hash_num, + absorb_num, + iterations: Vec::new(), + } + } +} + +impl Poseidon2AbsorbEvent { + pub(crate) fn populate_iterations( + &mut self, + start_addr: F, + input_len: F, + memory_records: &[MemoryRecord], + permuter: &impl Permutation<[F; WIDTH]>, + hash_state: &mut [F; WIDTH], + hash_state_cursor: &mut usize, + ) { + let mut input_records = Vec::new(); + let mut previous_state = *hash_state; + let mut iter_num_consumed = 0; + + let start_addr = start_addr.as_canonical_u32(); + let end_addr = start_addr + input_len.as_canonical_u32(); + + for (addr_iter, memory_record) in (start_addr..end_addr).zip(memory_records.iter()) { + input_records.push(*memory_record); + + hash_state[*hash_state_cursor] = memory_record.value[0]; + *hash_state_cursor += 1; + iter_num_consumed += 1; + + // Do a permutation when the hash state is full. + if *hash_state_cursor == RATE { + let perm_input = *hash_state; + *hash_state = permuter.permute(*hash_state); + + self.iterations.push(Poseidon2AbsorbIteration { + state_cursor: *hash_state_cursor - iter_num_consumed, + start_addr: F::from_canonical_u32(addr_iter - iter_num_consumed as u32 + 1), + input_records, + perm_input, + perm_output: *hash_state, + previous_state, + state: *hash_state, + do_perm: true, + }); + + previous_state = *hash_state; + input_records = Vec::new(); + *hash_state_cursor = 0; + iter_num_consumed = 0; + } + } + + if *hash_state_cursor != 0 { + // Note that we still do a permutation, generate the trace and enforce permutation + // constraints for every absorb and finalize row. + self.iterations.push(Poseidon2AbsorbIteration { + state_cursor: *hash_state_cursor - iter_num_consumed, + start_addr: F::from_canonical_u32(end_addr - iter_num_consumed as u32), + input_records, + perm_input: *hash_state, + perm_output: permuter.permute(*hash_state), + previous_state, + state: *hash_state, + do_perm: false, + }); + } + } +} + +#[derive(Debug, Clone)] +pub struct Poseidon2AbsorbIteration { + pub state_cursor: usize, + pub start_addr: F, + pub input_records: Vec>, + + pub perm_input: [F; WIDTH], + pub perm_output: [F; WIDTH], + + pub previous_state: [F; WIDTH], + pub state: [F; WIDTH], + + pub do_perm: bool, +} + +#[derive(Debug, Clone)] +pub struct Poseidon2FinalizeEvent { + pub clk: F, + pub hash_num: F, // from a_val + pub output_ptr: F, // from b_val + pub output_records: [MemoryRecord; DIGEST_SIZE], + + pub state_cursor: usize, + + pub perm_input: [F; WIDTH], + pub perm_output: [F; WIDTH], + + pub previous_state: [F; WIDTH], + pub state: [F; WIDTH], + + pub do_perm: bool, +} diff --git a/recursion/core/src/poseidon2_wide/external.rs b/recursion/core/src/poseidon2_wide/external.rs deleted file mode 100644 index 9181d3a1fa..0000000000 --- a/recursion/core/src/poseidon2_wide/external.rs +++ /dev/null @@ -1,587 +0,0 @@ -use crate::poseidon2_wide::columns::{ - Poseidon2ColType, Poseidon2ColTypeMut, Poseidon2Cols, Poseidon2SBoxCols, NUM_POSEIDON2_COLS, - NUM_POSEIDON2_SBOX_COLS, -}; -use crate::runtime::Opcode; -use core::borrow::Borrow; -use p3_air::{Air, BaseAir}; -use p3_field::{AbstractField, PrimeField32}; -use p3_matrix::dense::RowMajorMatrix; -use p3_matrix::Matrix; -use sp1_core::air::{BaseAirBuilder, MachineAir, SP1AirBuilder}; -use sp1_core::utils::pad_rows_fixed; -use sp1_primitives::RC_16_30_U32; -use std::borrow::BorrowMut; -use tracing::instrument; - -use crate::air::SP1RecursionAirBuilder; -use crate::memory::MemoryCols; - -use crate::poseidon2_wide::{external_linear_layer, internal_linear_layer}; -use crate::runtime::{ExecutionRecord, RecursionProgram}; - -use super::columns::Poseidon2MemCols; - -/// The width of the permutation. -pub const WIDTH: usize = 16; - -pub const NUM_EXTERNAL_ROUNDS: usize = 8; -pub const NUM_INTERNAL_ROUNDS: usize = 13; -pub const NUM_ROUNDS: usize = NUM_EXTERNAL_ROUNDS + NUM_INTERNAL_ROUNDS; - -/// A chip that implements addition for the opcode ADD. -#[derive(Default)] -pub struct Poseidon2WideChip { - pub fixed_log2_rows: Option, -} - -impl MachineAir for Poseidon2WideChip { - type Record = ExecutionRecord; - - type Program = RecursionProgram; - - fn name(&self) -> String { - format!("Poseidon2Wide {}", DEGREE) - } - - fn generate_dependencies(&self, _: &Self::Record, _: &mut Self::Record) { - // This is a no-op. - } - - #[instrument(name = "generate poseidon2 wide trace", level = "debug", skip_all, fields(rows = input.poseidon2_events.len()))] - fn generate_trace( - &self, - input: &ExecutionRecord, - _: &mut ExecutionRecord, - ) -> RowMajorMatrix { - let mut rows = Vec::new(); - - assert!(DEGREE >= 3, "Minimum supported constraint degree is 3"); - let use_sbox_3 = DEGREE < 7; - let num_columns = >::width(self); - - for event in &input.poseidon2_events { - let mut row = vec![F::zero(); num_columns]; - - let mut cols = if use_sbox_3 { - let cols: &mut Poseidon2SBoxCols = row.as_mut_slice().borrow_mut(); - Poseidon2ColTypeMut::Wide(cols) - } else { - let cols: &mut Poseidon2Cols = row.as_mut_slice().borrow_mut(); - Poseidon2ColTypeMut::Narrow(cols) - }; - - let (poseidon2_cols, mut external_sbox, mut internal_sbox) = cols.get_cols_mut(); - - let memory = &mut poseidon2_cols.memory; - memory.timestamp = event.clk; - memory.dst = event.dst; - memory.left = event.left; - memory.right = event.right; - memory.is_real = F::one(); - - // Apply the initial round. - for i in 0..WIDTH { - memory.input[i].populate(&event.input_records[i]); - } - - for i in 0..WIDTH { - memory.output[i].populate(&event.result_records[i]); - } - - poseidon2_cols.external_rounds_state[0] = event.input; - external_linear_layer(&mut poseidon2_cols.external_rounds_state[0]); - - // Apply the first half of external rounds. - for r in 0..NUM_EXTERNAL_ROUNDS / 2 { - let next_state = populate_external_round(poseidon2_cols, &mut external_sbox, r); - - if r == NUM_EXTERNAL_ROUNDS / 2 - 1 { - poseidon2_cols.internal_rounds_state = next_state; - } else { - poseidon2_cols.external_rounds_state[r + 1] = next_state; - } - } - - // Apply the internal rounds. - poseidon2_cols.external_rounds_state[NUM_EXTERNAL_ROUNDS / 2] = - populate_internal_rounds(poseidon2_cols, &mut internal_sbox); - - // Apply the second half of external rounds. - for r in NUM_EXTERNAL_ROUNDS / 2..NUM_EXTERNAL_ROUNDS { - let next_state = populate_external_round(poseidon2_cols, &mut external_sbox, r); - if r == NUM_EXTERNAL_ROUNDS - 1 { - // Do nothing, since we set the cols.output by populating the output records - // after this loop. - for i in 0..WIDTH { - assert_eq!(event.result_records[i].value[0], next_state[i]); - } - } else { - poseidon2_cols.external_rounds_state[r + 1] = next_state; - } - } - - rows.push(row); - } - - // Pad the trace to a power of two. - pad_rows_fixed( - &mut rows, - || vec![F::zero(); num_columns], - self.fixed_log2_rows, - ); - - // Convert the trace to a row major matrix. - let trace = - RowMajorMatrix::new(rows.into_iter().flatten().collect::>(), num_columns); - - #[cfg(debug_assertions)] - println!( - "poseidon2 wide trace dims is width: {:?}, height: {:?}", - trace.width(), - trace.height() - ); - - trace - } - - fn included(&self, record: &Self::Record) -> bool { - !record.poseidon2_events.is_empty() - } -} - -fn populate_external_round( - poseidon2_cols: &mut Poseidon2Cols, - sbox: &mut Option<&mut [[F; WIDTH]; NUM_EXTERNAL_ROUNDS]>, - r: usize, -) -> [F; WIDTH] { - let mut state = { - let round_state: &mut [F; WIDTH] = poseidon2_cols.external_rounds_state[r].borrow_mut(); - - // Add round constants. - // - // Optimization: Since adding a constant is a degree 1 operation, we can avoid adding - // columns for it, and instead include it in the constraint for the x^3 part of the sbox. - let round = if r < NUM_EXTERNAL_ROUNDS / 2 { - r - } else { - r + NUM_INTERNAL_ROUNDS - }; - let mut add_rc = *round_state; - for i in 0..WIDTH { - add_rc[i] += F::from_wrapped_u32(RC_16_30_U32[round][i]); - } - - // Apply the sboxes. - // Optimization: since the linear layer that comes after the sbox is degree 1, we can - // avoid adding columns for the result of the sbox, and instead include the x^3 -> x^7 - // part of the sbox in the constraint for the linear layer - let mut sbox_deg_7: [F; 16] = [F::zero(); WIDTH]; - let mut sbox_deg_3: [F; 16] = [F::zero(); WIDTH]; - for i in 0..WIDTH { - sbox_deg_3[i] = add_rc[i] * add_rc[i] * add_rc[i]; - sbox_deg_7[i] = sbox_deg_3[i] * sbox_deg_3[i] * add_rc[i]; - } - - if let Some(sbox) = sbox.as_deref_mut() { - sbox[r] = sbox_deg_3; - } - - sbox_deg_7 - }; - - // Apply the linear layer. - external_linear_layer(&mut state); - state -} - -fn populate_internal_rounds( - poseidon2_cols: &mut Poseidon2Cols, - sbox: &mut Option<&mut [F; NUM_INTERNAL_ROUNDS]>, -) -> [F; WIDTH] { - let mut state: [F; WIDTH] = poseidon2_cols.internal_rounds_state; - let mut sbox_deg_3: [F; NUM_INTERNAL_ROUNDS] = [F::zero(); NUM_INTERNAL_ROUNDS]; - for r in 0..NUM_INTERNAL_ROUNDS { - // Add the round constant to the 0th state element. - // Optimization: Since adding a constant is a degree 1 operation, we can avoid adding - // columns for it, just like for external rounds. - let round = r + NUM_EXTERNAL_ROUNDS / 2; - let add_rc = state[0] + F::from_wrapped_u32(RC_16_30_U32[round][0]); - - // Apply the sboxes. - // Optimization: since the linear layer that comes after the sbox is degree 1, we can - // avoid adding columns for the result of the sbox, just like for external rounds. - sbox_deg_3[r] = add_rc * add_rc * add_rc; - let sbox_deg_7 = sbox_deg_3[r] * sbox_deg_3[r] * add_rc; - - // Apply the linear layer. - state[0] = sbox_deg_7; - internal_linear_layer(&mut state); - - // Optimization: since we're only applying the sbox to the 0th state element, we only - // need to have columns for the 0th state element at every step. This is because the - // linear layer is degree 1, so all state elements at the end can be expressed as a - // degree-3 polynomial of the state at the beginning of the internal rounds and the 0th - // state element at rounds prior to the current round - if r < NUM_INTERNAL_ROUNDS - 1 { - poseidon2_cols.internal_rounds_s0[r] = state[0]; - } - } - - let ret_state = state; - - if let Some(sbox) = sbox.as_deref_mut() { - *sbox = sbox_deg_3; - } - - ret_state -} - -fn eval_external_round( - builder: &mut AB, - cols: &Poseidon2ColType, - r: usize, - is_real: AB::Var, -) { - let poseidon2_cols = cols.get_poseidon2_cols(); - let external_state = poseidon2_cols.external_rounds_state[r]; - - // Add the round constants. - let round = if r < NUM_EXTERNAL_ROUNDS / 2 { - r - } else { - r + NUM_INTERNAL_ROUNDS - }; - let add_rc: [AB::Expr; WIDTH] = core::array::from_fn(|i| { - external_state[i].into() + is_real * AB::F::from_wrapped_u32(RC_16_30_U32[round][i]) - }); - - // Apply the sboxes. - // See `populate_external_round` for why we don't have columns for the sbox output here. - let mut sbox_deg_7: [AB::Expr; WIDTH] = core::array::from_fn(|_| AB::Expr::zero()); - let mut sbox_deg_3: [AB::Expr; WIDTH] = core::array::from_fn(|_| AB::Expr::zero()); - let expected_sbox_deg_3 = cols.get_external_sbox(r); - for i in 0..WIDTH { - sbox_deg_3[i] = add_rc[i].clone() * add_rc[i].clone() * add_rc[i].clone(); - - if let Some(expected) = expected_sbox_deg_3 { - builder.assert_eq(expected[i], sbox_deg_3[i].clone()); - sbox_deg_3[i] = expected[i].into(); - } - - sbox_deg_7[i] = sbox_deg_3[i].clone() * sbox_deg_3[i].clone() * add_rc[i].clone(); - } - - // Apply the linear layer. - let mut state = sbox_deg_7; - external_linear_layer(&mut state); - - let next_state_cols = if r == NUM_EXTERNAL_ROUNDS / 2 - 1 { - poseidon2_cols.internal_rounds_state - } else if r == NUM_EXTERNAL_ROUNDS - 1 { - core::array::from_fn(|i| *poseidon2_cols.memory.output[i].value()) - } else { - poseidon2_cols.external_rounds_state[r + 1] - }; - for i in 0..WIDTH { - builder.assert_eq(next_state_cols[i], state[i].clone()); - } -} - -fn eval_internal_rounds( - builder: &mut AB, - cols: &Poseidon2ColType, - is_real: AB::Var, -) { - let poseidon2_cols = cols.get_poseidon2_cols(); - let state = &poseidon2_cols.internal_rounds_state; - let s0 = poseidon2_cols.internal_rounds_s0; - let sbox_3 = cols.get_internal_sbox(); - let mut state: [AB::Expr; WIDTH] = core::array::from_fn(|i| state[i].into()); - for r in 0..NUM_INTERNAL_ROUNDS { - // Add the round constant. - let round = r + NUM_EXTERNAL_ROUNDS / 2; - let add_rc = if r == 0 { - state[0].clone() - } else { - s0[r - 1].into() - } + is_real * AB::Expr::from_wrapped_u32(RC_16_30_U32[round][0]); - - let mut sbox_deg_3 = add_rc.clone() * add_rc.clone() * add_rc.clone(); - if let Some(expected) = sbox_3 { - builder.assert_eq(expected[r], sbox_deg_3); - sbox_deg_3 = expected[r].into(); - } - - // See `populate_internal_rounds` for why we don't have columns for the sbox output here. - let sbox_deg_7 = sbox_deg_3.clone() * sbox_deg_3 * add_rc.clone(); - - // Apply the linear layer. - // See `populate_internal_rounds` for why we don't have columns for the new state here. - state[0] = sbox_deg_7.clone(); - internal_linear_layer(&mut state); - - if r < NUM_INTERNAL_ROUNDS - 1 { - builder.assert_eq(s0[r], state[0].clone()); - } - } - - let external_state = poseidon2_cols.external_rounds_state[NUM_EXTERNAL_ROUNDS / 2]; - for i in 0..WIDTH { - builder.assert_eq(external_state[i], state[i].clone()) - } -} - -impl BaseAir for Poseidon2WideChip { - fn width(&self) -> usize { - match DEGREE { - d if d < 7 => NUM_POSEIDON2_SBOX_COLS, - _ => NUM_POSEIDON2_COLS, - } - } -} - -fn eval_mem(builder: &mut AB, local: &Poseidon2MemCols) { - // Evaluate all of the memory. - for i in 0..WIDTH { - let input_addr = if i < WIDTH / 2 { - local.left + AB::F::from_canonical_usize(i) - } else { - local.right + AB::F::from_canonical_usize(i - WIDTH / 2) - }; - - builder.recursion_eval_memory_access_single( - local.timestamp, - input_addr, - &local.input[i], - local.is_real, - ); - - let output_addr = local.dst + AB::F::from_canonical_usize(i); - builder.recursion_eval_memory_access_single( - local.timestamp + AB::F::from_canonical_usize(1), - output_addr, - &local.output[i], - local.is_real, - ); - } - - // Constraint that the operands are sent from the CPU table. - let operands: [AB::Expr; 4] = [ - local.timestamp.into(), - local.dst.into(), - local.left.into(), - local.right.into(), - ]; - builder.receive_table( - Opcode::Poseidon2Compress.as_field::(), - &operands, - local.is_real, - ); -} - -impl Air for Poseidon2WideChip -where - AB: SP1RecursionAirBuilder, -{ - fn eval(&self, builder: &mut AB) { - assert!(DEGREE >= 3, "Minimum supported constraint degree is 3"); - let main = builder.main(); - let cols = main.row_slice(0); - let cols = match DEGREE { - d if d < 7 => { - let cols: &Poseidon2SBoxCols = (*cols).borrow(); - Poseidon2ColType::Wide(*cols) - } - _ => { - let cols: &Poseidon2Cols = (*cols).borrow(); - Poseidon2ColType::Narrow(*cols) - } - }; - - let poseidon2_cols = cols.get_poseidon2_cols(); - let memory = poseidon2_cols.memory; - eval_mem(builder, &memory); - - // Dummy constraints to normalize to DEGREE. - let lhs = (0..DEGREE) - .map(|_| memory.is_real.into()) - .product::(); - let rhs = (0..DEGREE) - .map(|_| memory.is_real.into()) - .product::(); - builder.assert_eq(lhs, rhs); - - // Apply the initial round. - let initial_round_output = { - let mut initial_round_output: [AB::Expr; WIDTH] = - core::array::from_fn(|i| (*poseidon2_cols.memory.input[i].value()).into()); - external_linear_layer(&mut initial_round_output); - initial_round_output - }; - let external_round_0_state: [AB::Expr; WIDTH] = core::array::from_fn(|i| { - let state = poseidon2_cols.external_rounds_state[0]; - state[i].into() - }); - builder - .when(memory.is_real) - .assert_all_eq(external_round_0_state.clone(), initial_round_output); - - // Apply the first half of external rounds. - for r in 0..NUM_EXTERNAL_ROUNDS / 2 { - eval_external_round(builder, &cols, r, memory.is_real); - } - - // Apply the internal rounds. - eval_internal_rounds(builder, &cols, memory.is_real); - - // Apply the second half of external rounds. - for r in NUM_EXTERNAL_ROUNDS / 2..NUM_EXTERNAL_ROUNDS { - eval_external_round(builder, &cols, r, memory.is_real); - } - - // Make the degree equivalent to WIDTH to compress the interaction columns. - let mut dummy = memory.is_real * memory.is_real; - for _ in 0..(DEGREE - 2) { - dummy *= memory.is_real.into(); - } - builder.assert_eq(dummy.clone(), dummy.clone()); - } -} - -#[cfg(test)] -mod tests { - use std::time::Instant; - - use crate::poseidon2::Poseidon2Event; - use crate::poseidon2_wide::external::WIDTH; - use crate::{poseidon2_wide::external::Poseidon2WideChip, runtime::ExecutionRecord}; - use itertools::Itertools; - use p3_baby_bear::{BabyBear, DiffusionMatrixBabyBear}; - use p3_field::AbstractField; - use p3_matrix::dense::RowMajorMatrix; - use p3_poseidon2::{Poseidon2, Poseidon2ExternalMatrixGeneral}; - use p3_symmetric::Permutation; - use sp1_core::air::MachineAir; - use sp1_core::stark::StarkGenericConfig; - use sp1_core::utils::{inner_perm, uni_stark_prove, uni_stark_verify, BabyBearPoseidon2}; - use zkhash::ark_ff::UniformRand; - - fn generate_trace_degree() { - let chip = Poseidon2WideChip:: { - fixed_log2_rows: None, - }; - - let test_inputs = vec![ - [BabyBear::from_canonical_u32(1); WIDTH], - [BabyBear::from_canonical_u32(2); WIDTH], - [BabyBear::from_canonical_u32(3); WIDTH], - [BabyBear::from_canonical_u32(4); WIDTH], - ]; - - let gt: Poseidon2< - BabyBear, - Poseidon2ExternalMatrixGeneral, - DiffusionMatrixBabyBear, - 16, - 7, - > = inner_perm(); - - let expected_outputs = test_inputs - .iter() - .map(|input| gt.permute(*input)) - .collect::>(); - - let mut input_exec = ExecutionRecord::::default(); - for (input, output) in test_inputs.clone().into_iter().zip_eq(expected_outputs) { - input_exec - .poseidon2_events - .push(Poseidon2Event::dummy_from_input(input, output)); - } - - // Generate trace will assert for the expected outputs. - chip.generate_trace(&input_exec, &mut ExecutionRecord::::default()); - } - - /// A test generating a trace for a single permutation that checks that the output is correct - #[test] - fn generate_trace() { - generate_trace_degree::<3>(); - generate_trace_degree::<7>(); - } - - fn poseidon2_wide_prove_babybear_degree( - inputs: Vec<[BabyBear; 16]>, - outputs: Vec<[BabyBear; 16]>, - ) { - let chip = Poseidon2WideChip:: { - fixed_log2_rows: None, - }; - let mut input_exec = ExecutionRecord::::default(); - for (input, output) in inputs.into_iter().zip_eq(outputs) { - input_exec - .poseidon2_events - .push(Poseidon2Event::dummy_from_input(input, output)); - } - let trace: RowMajorMatrix = - chip.generate_trace(&input_exec, &mut ExecutionRecord::::default()); - - let config = BabyBearPoseidon2::compressed(); - let mut challenger = config.challenger(); - - let start = Instant::now(); - let proof = uni_stark_prove(&config, &chip, &mut challenger, trace); - let duration = start.elapsed().as_secs_f64(); - println!("proof duration = {:?}", duration); - - let mut challenger = config.challenger(); - let start = Instant::now(); - uni_stark_verify(&config, &chip, &mut challenger, &proof) - .expect("expected proof to be valid"); - - let duration = start.elapsed().as_secs_f64(); - println!("verify duration = {:?}", duration); - } - - #[test] - fn poseidon2_wide_prove_babybear_success() { - let rng = &mut rand::thread_rng(); - - let test_inputs: Vec<[BabyBear; 16]> = (0..1000) - .map(|_| core::array::from_fn(|_| BabyBear::rand(rng))) - .collect_vec(); - - let gt: Poseidon2< - BabyBear, - Poseidon2ExternalMatrixGeneral, - DiffusionMatrixBabyBear, - 16, - 7, - > = inner_perm(); - - let expected_outputs = test_inputs - .iter() - .map(|input| gt.permute(*input)) - .collect::>(); - - poseidon2_wide_prove_babybear_degree::<3>(test_inputs.clone(), expected_outputs.clone()); - poseidon2_wide_prove_babybear_degree::<7>(test_inputs, expected_outputs); - } - - #[test] - #[should_panic] - fn poseidon2_wide_prove_babybear_failure() { - let rng = &mut rand::thread_rng(); - - let test_inputs = (0..1000) - .map(|i| [BabyBear::from_canonical_u32(i); WIDTH]) - .collect_vec(); - - let bad_outputs: Vec<[BabyBear; 16]> = (0..1000) - .map(|_| core::array::from_fn(|_| BabyBear::rand(rng))) - .collect_vec(); - - poseidon2_wide_prove_babybear_degree::<3>(test_inputs.clone(), bad_outputs.clone()); - poseidon2_wide_prove_babybear_degree::<7>(test_inputs, bad_outputs); - } -} diff --git a/recursion/core/src/poseidon2_wide/mod.rs b/recursion/core/src/poseidon2_wide/mod.rs index f5531bad84..f146593d97 100644 --- a/recursion/core/src/poseidon2_wide/mod.rs +++ b/recursion/core/src/poseidon2_wide/mod.rs @@ -1,19 +1,72 @@ #![allow(clippy::needless_range_loop)] -use crate::poseidon2_wide::external::WIDTH; +use std::borrow::Borrow; +use std::borrow::BorrowMut; +use std::ops::Deref; + use p3_baby_bear::{MONTY_INVERSE, POSEIDON2_INTERNAL_MATRIX_DIAG_16_BABYBEAR_MONTY}; use p3_field::AbstractField; use p3_field::PrimeField32; -mod columns; -pub mod external; +pub mod air; +pub mod columns; +pub mod events; +pub mod trace; -pub use external::Poseidon2WideChip; use p3_poseidon2::matmul_internal; -#[derive(Debug, Clone)] -pub struct Poseidon2Event { - pub input: [F; WIDTH], +use self::columns::Poseidon2; +use self::columns::Poseidon2Degree3; +use self::columns::Poseidon2Degree9; +use self::columns::Poseidon2Mut; + +/// The width of the permutation. +pub const WIDTH: usize = 16; +pub const RATE: usize = WIDTH / 2; + +pub const NUM_EXTERNAL_ROUNDS: usize = 8; +pub const NUM_INTERNAL_ROUNDS: usize = 13; +pub const NUM_ROUNDS: usize = NUM_EXTERNAL_ROUNDS + NUM_INTERNAL_ROUNDS; + +/// A chip that implements addition for the opcode ADD. +#[derive(Default)] +pub struct Poseidon2WideChip { + pub fixed_log2_rows: Option, + pub pad: bool, +} + +impl<'a, const DEGREE: usize> Poseidon2WideChip { + /// Transmute a row it to an immutable Poseidon2 instance. + pub(crate) fn convert(row: impl Deref) -> Box + 'a> + where + T: Copy + 'a, + { + if DEGREE == 3 { + let convert: &Poseidon2Degree3 = (*row).borrow(); + Box::new(*convert) + } else if DEGREE == 9 || DEGREE == 17 { + let convert: &Poseidon2Degree9 = (*row).borrow(); + Box::new(*convert) + } else { + panic!("Unsupported degree"); + } + } + + /// Transmute a row it to a mutable Poseidon2 instance. + pub(crate) fn convert_mut<'b: 'a, F: PrimeField32>( + &self, + row: &'b mut [F], + ) -> Box + 'a> { + if DEGREE == 3 { + let convert: &mut Poseidon2Degree3 = row.borrow_mut(); + Box::new(convert) + } else if DEGREE == 9 || DEGREE == 17 { + let convert: &mut Poseidon2Degree9 = row.borrow_mut(); + Box::new(convert) + } else { + panic!("Unsupported degree"); + } + } } pub fn apply_m_4(x: &mut [AF]) @@ -60,3 +113,220 @@ pub(crate) fn internal_linear_layer(state: &mut [F; WIDTH]) { let monty_inverse = F::from_wrapped_u32(MONTY_INVERSE.as_canonical_u32()); state.iter_mut().for_each(|i| *i *= monty_inverse.clone()); } + +#[cfg(test)] +pub(crate) mod tests { + use std::array; + use std::time::Instant; + + use crate::air::Block; + use crate::memory::MemoryRecord; + use crate::poseidon2_wide::events::Poseidon2HashEvent; + use crate::runtime::{ExecutionRecord, DIGEST_SIZE}; + use itertools::Itertools; + use p3_baby_bear::{BabyBear, DiffusionMatrixBabyBear}; + use p3_field::AbstractField; + use p3_matrix::dense::RowMajorMatrix; + use p3_poseidon2::{Poseidon2, Poseidon2ExternalMatrixGeneral}; + use p3_symmetric::Permutation; + use rand::random; + use sp1_core::air::MachineAir; + use sp1_core::stark::StarkGenericConfig; + use sp1_core::utils::{inner_perm, uni_stark_prove, uni_stark_verify, BabyBearPoseidon2}; + use zkhash::ark_ff::UniformRand; + + use super::events::{Poseidon2AbsorbEvent, Poseidon2CompressEvent, Poseidon2FinalizeEvent}; + use super::{Poseidon2WideChip, WIDTH}; + + fn poseidon2_wide_prove_babybear_degree( + input_exec: ExecutionRecord, + ) { + let chip = Poseidon2WideChip:: { + fixed_log2_rows: None, + pad: true, + }; + + let trace: RowMajorMatrix = + chip.generate_trace(&input_exec, &mut ExecutionRecord::::default()); + + let config = BabyBearPoseidon2::compressed(); + let mut challenger = config.challenger(); + + let start = Instant::now(); + let proof = uni_stark_prove(&config, &chip, &mut challenger, trace); + let duration = start.elapsed().as_secs_f64(); + println!("proof duration = {:?}", duration); + + let mut challenger = config.challenger(); + let start = Instant::now(); + uni_stark_verify(&config, &chip, &mut challenger, &proof) + .expect("expected proof to be valid"); + + let duration = start.elapsed().as_secs_f64(); + println!("verify duration = {:?}", duration); + } + + fn dummy_memory_access_records( + memory_values: Vec, + prev_ts: BabyBear, + ts: BabyBear, + ) -> Vec> { + memory_values + .iter() + .map(|value| MemoryRecord::new_read(BabyBear::zero(), Block::from(*value), ts, prev_ts)) + .collect_vec() + } + + pub(crate) fn generate_test_execution_record( + incorrect_trace: bool, + ) -> ExecutionRecord { + const NUM_ABSORBS: usize = 1000; + const NUM_COMPRESSES: usize = 1000; + + let mut input_exec = ExecutionRecord::::default(); + + let rng = &mut rand::thread_rng(); + let permuter: Poseidon2< + BabyBear, + Poseidon2ExternalMatrixGeneral, + DiffusionMatrixBabyBear, + 16, + 7, + > = inner_perm(); + + // Generate hash test events. + let hash_test_input_sizes: [usize; NUM_ABSORBS] = + array::from_fn(|_| random::() % 128 + 1); + hash_test_input_sizes + .iter() + .enumerate() + .for_each(|(i, input_size)| { + let test_input = (0..*input_size).map(|_| BabyBear::rand(rng)).collect_vec(); + + let prev_ts = BabyBear::from_canonical_usize(i); + let absorb_ts = BabyBear::from_canonical_usize(i + 1); + let finalize_ts = BabyBear::from_canonical_usize(i + 2); + let hash_num = i as u32; + let absorb_num = 0_u32; + let hash_and_absorb_num = + BabyBear::from_canonical_u32(hash_num * (1 << 12) + absorb_num); + let start_addr = BabyBear::from_canonical_usize(i + 1); + let input_len = BabyBear::from_canonical_usize(*input_size); + + let mut absorb_event = Poseidon2AbsorbEvent::new( + absorb_ts, + hash_and_absorb_num, + start_addr, + input_len, + BabyBear::from_canonical_u32(hash_num), + BabyBear::from_canonical_u32(absorb_num), + ); + + let mut hash_state = [BabyBear::zero(); WIDTH]; + let mut hash_state_cursor = 0; + absorb_event.populate_iterations( + start_addr, + input_len, + &dummy_memory_access_records(test_input.clone(), prev_ts, absorb_ts), + &permuter, + &mut hash_state, + &mut hash_state_cursor, + ); + + input_exec + .poseidon2_hash_events + .push(Poseidon2HashEvent::Absorb(absorb_event)); + + let do_perm = hash_state_cursor != 0; + let mut perm_output = permuter.permute(hash_state); + if incorrect_trace { + perm_output = [BabyBear::rand(rng); WIDTH]; + } + + let state = if do_perm { perm_output } else { hash_state }; + + input_exec + .poseidon2_hash_events + .push(Poseidon2HashEvent::Finalize(Poseidon2FinalizeEvent { + clk: finalize_ts, + hash_num: BabyBear::from_canonical_u32(hash_num), + output_ptr: start_addr, + output_records: dummy_memory_access_records( + state.as_slice().to_vec(), + absorb_ts, + finalize_ts, + )[0..DIGEST_SIZE] + .try_into() + .unwrap(), + state_cursor: hash_state_cursor, + perm_input: hash_state, + perm_output, + previous_state: hash_state, + state, + do_perm, + })); + }); + + let compress_test_inputs: Vec<[BabyBear; WIDTH]> = (0..NUM_COMPRESSES) + .map(|_| core::array::from_fn(|_| BabyBear::rand(rng))) + .collect_vec(); + compress_test_inputs + .iter() + .enumerate() + .for_each(|(i, input)| { + let mut result_array = permuter.permute(*input); + if incorrect_trace { + result_array = core::array::from_fn(|_| BabyBear::rand(rng)); + } + let prev_ts = BabyBear::from_canonical_usize(i); + let input_ts = BabyBear::from_canonical_usize(i + 1); + let output_ts = BabyBear::from_canonical_usize(i + 2); + + let dst = BabyBear::from_canonical_usize(i + 1); + let left = dst + BabyBear::from_canonical_usize(WIDTH / 2); + let right = left + BabyBear::from_canonical_usize(WIDTH / 2); + + let compress_event = Poseidon2CompressEvent { + clk: input_ts, + dst, + left, + right, + input: *input, + result_array, + input_records: dummy_memory_access_records(input.to_vec(), prev_ts, input_ts) + .try_into() + .unwrap(), + result_records: dummy_memory_access_records( + result_array.to_vec(), + input_ts, + output_ts, + ) + .try_into() + .unwrap(), + }; + + input_exec.poseidon2_compress_events.push(compress_event); + }); + + input_exec + } + + #[test] + fn poseidon2_wide_prove_babybear_success() { + // Generate test input exec record. + let input_exec = generate_test_execution_record(false); + + poseidon2_wide_prove_babybear_degree::<3>(input_exec.clone()); + poseidon2_wide_prove_babybear_degree::<9>(input_exec); + } + + #[test] + #[should_panic] + fn poseidon2_wide_prove_babybear_failure() { + // Generate test input exec record. + let input_exec = generate_test_execution_record(true); + + poseidon2_wide_prove_babybear_degree::<3>(input_exec.clone()); + poseidon2_wide_prove_babybear_degree::<9>(input_exec); + } +} diff --git a/recursion/core/src/poseidon2_wide/trace.rs b/recursion/core/src/poseidon2_wide/trace.rs new file mode 100644 index 0000000000..3f4612045b --- /dev/null +++ b/recursion/core/src/poseidon2_wide/trace.rs @@ -0,0 +1,573 @@ +use std::borrow::Borrow; + +use p3_air::BaseAir; +use p3_field::PrimeField32; +use p3_matrix::dense::RowMajorMatrix; +use p3_maybe_rayon::prelude::IndexedParallelIterator; +use p3_maybe_rayon::prelude::ParallelIterator; +use p3_maybe_rayon::prelude::ParallelSliceMut; +use sp1_core::air::MachineAir; +use sp1_core::utils::next_power_of_two; +use sp1_core::utils::par_for_each_row; +use sp1_primitives::RC_16_30_U32; +use tracing::instrument; + +use crate::poseidon2_wide::columns::permutation::permutation_mut; +use crate::poseidon2_wide::events::Poseidon2HashEvent; +use crate::range_check::{RangeCheckEvent, RangeCheckOpcode}; +use crate::{ + poseidon2_wide::{external_linear_layer, NUM_EXTERNAL_ROUNDS, WIDTH}, + runtime::{ExecutionRecord, RecursionProgram}, +}; + +use super::events::{Poseidon2AbsorbEvent, Poseidon2CompressEvent, Poseidon2FinalizeEvent}; +use super::RATE; +use super::{internal_linear_layer, Poseidon2WideChip, NUM_INTERNAL_ROUNDS}; + +impl MachineAir for Poseidon2WideChip { + type Record = ExecutionRecord; + + type Program = RecursionProgram; + + fn name(&self) -> String { + format!("Poseidon2Wide {}", DEGREE) + } + + #[instrument(name = "generate poseidon2 wide trace", level = "debug", skip_all, fields(rows = input.poseidon2_compress_events.len()))] + fn generate_trace( + &self, + input: &ExecutionRecord, + output: &mut ExecutionRecord, + ) -> RowMajorMatrix { + // Calculate the number of rows in the trace. + let mut nb_rows = 0; + for event in input.poseidon2_hash_events.iter() { + match event { + Poseidon2HashEvent::Absorb(absorb_event) => { + nb_rows += absorb_event.iterations.len(); + } + Poseidon2HashEvent::Finalize(_) => { + nb_rows += 1; + } + } + } + nb_rows += input.poseidon2_compress_events.len() * 2; + + let nb_padded_rows = if self.pad { + next_power_of_two(nb_rows, self.fixed_log2_rows) + } else { + nb_rows + }; + + let num_columns = as BaseAir>::width(self); + let mut rows = vec![F::zero(); nb_padded_rows * num_columns]; + + // Populate the hash events. We do this serially, since each absorb event could populate a different + // number of rows. Also, most of the rows are populated by the compress events. + let mut row_cursor = 0; + for event in &input.poseidon2_hash_events { + match event { + Poseidon2HashEvent::Absorb(absorb_event) => { + let num_absorb_elements = absorb_event.iterations.len() * num_columns; + let absorb_rows = &mut rows[row_cursor..row_cursor + num_absorb_elements]; + self.populate_absorb_event(absorb_rows, absorb_event, num_columns, output); + row_cursor += num_absorb_elements; + } + + Poseidon2HashEvent::Finalize(finalize_event) => { + let finalize_row = &mut rows[row_cursor..row_cursor + num_columns]; + self.populate_finalize_event(finalize_row, finalize_event); + row_cursor += num_columns; + } + } + } + + // Populate the compress events. + let compress_rows = &mut rows[row_cursor..nb_rows * num_columns]; + par_for_each_row(compress_rows, num_columns * 2, |i, rows| { + self.populate_compress_event(rows, &input.poseidon2_compress_events[i], num_columns); + }); + + // Convert the trace to a row major matrix. + let mut trace = RowMajorMatrix::new(rows, num_columns); + + let padded_rows = trace.values.par_chunks_mut(num_columns).skip(nb_rows); + + if self.pad { + let mut dummy_row = vec![F::zero(); num_columns]; + self.populate_permutation([F::zero(); WIDTH], None, &mut dummy_row); + padded_rows.for_each(|padded_row| { + padded_row.copy_from_slice(&dummy_row); + }); + } + + trace + } + + fn included(&self, record: &Self::Record) -> bool { + !record.poseidon2_compress_events.is_empty() + } +} + +impl Poseidon2WideChip { + pub fn populate_compress_event( + &self, + rows: &mut [F], + compress_event: &Poseidon2CompressEvent, + num_columns: usize, + ) { + let input_row = &mut rows[0..num_columns]; + // Populate the control flow fields. + { + let mut cols = self.convert_mut(input_row); + let control_flow = cols.control_flow_mut(); + + control_flow.is_compress = F::one(); + control_flow.is_syscall_row = F::one(); + } + + // Populate the syscall params fields. + { + let mut cols = self.convert_mut(input_row); + let syscall_params = cols.syscall_params_mut().compress_mut(); + + syscall_params.clk = compress_event.clk; + syscall_params.dst_ptr = compress_event.dst; + syscall_params.left_ptr = compress_event.left; + syscall_params.right_ptr = compress_event.right; + } + + // Populate the memory fields. + { + let mut cols = self.convert_mut(input_row); + let memory = cols.memory_mut(); + + memory.start_addr = compress_event.left; + // Populate the first half of the memory inputs in the memory struct. + for i in 0..WIDTH / 2 { + memory.memory_slot_used[i] = F::one(); + memory.memory_accesses[i].populate(&compress_event.input_records[i]); + } + } + + // Populate the opcode workspace fields. + { + let mut cols = self.convert_mut(input_row); + let compress_cols = cols.opcode_workspace_mut().compress_mut(); + compress_cols.start_addr = compress_event.right; + + // Populate the second half of the memory inputs. + for i in 0..WIDTH / 2 { + compress_cols.memory_accesses[i] + .populate(&compress_event.input_records[i + WIDTH / 2]); + } + } + + // Populate the permutation fields. + self.populate_permutation( + compress_event.input, + Some(compress_event.result_array), + input_row, + ); + + let output_row = &mut rows[num_columns..]; + { + let mut cols = self.convert_mut(output_row); + let control_flow = cols.control_flow_mut(); + + control_flow.is_compress = F::one(); + control_flow.is_compress_output = F::one(); + } + + { + let mut cols = self.convert_mut(output_row); + let syscall_cols = cols.syscall_params_mut().compress_mut(); + + syscall_cols.clk = compress_event.clk; + syscall_cols.dst_ptr = compress_event.dst; + syscall_cols.left_ptr = compress_event.left; + syscall_cols.right_ptr = compress_event.right; + } + + { + let mut cols = self.convert_mut(output_row); + let memory = cols.memory_mut(); + + memory.start_addr = compress_event.dst; + // Populate the first half of the memory inputs in the memory struct. + for i in 0..WIDTH / 2 { + memory.memory_slot_used[i] = F::one(); + memory.memory_accesses[i].populate(&compress_event.result_records[i]); + } + } + + { + let mut cols = self.convert_mut(output_row); + let compress_cols = cols.opcode_workspace_mut().compress_mut(); + + compress_cols.start_addr = compress_event.dst + F::from_canonical_usize(WIDTH / 2); + for i in 0..WIDTH / 2 { + compress_cols.memory_accesses[i] + .populate(&compress_event.result_records[i + WIDTH / 2]); + } + } + + self.populate_permutation(compress_event.result_array, None, output_row); + } + + pub fn populate_absorb_event( + &self, + rows: &mut [F], + absorb_event: &Poseidon2AbsorbEvent, + num_columns: usize, + output: &mut ExecutionRecord, + ) { + // We currently don't support an input_len of 0, since it will need special logic in the AIR. + assert!(absorb_event.input_len > F::zero()); + + let mut last_row_ending_cursor = 0; + let num_absorb_rows = absorb_event.iterations.len(); + + for (iter_num, absorb_iter) in absorb_event.iterations.iter().enumerate() { + let absorb_row = &mut rows[iter_num * num_columns..(iter_num + 1) * num_columns]; + let is_syscall_row = iter_num == 0; + let is_last_row = iter_num == num_absorb_rows - 1; + + // Populate the control flow fields. + { + let mut cols = self.convert_mut(absorb_row); + let control_flow = cols.control_flow_mut(); + + control_flow.is_absorb = F::one(); + control_flow.is_syscall_row = F::from_bool(is_syscall_row); + control_flow.is_absorb_no_perm = F::from_bool(!absorb_iter.do_perm); + control_flow.is_absorb_not_last_row = F::from_bool(!is_last_row); + control_flow.is_absorb_last_row = F::from_bool(is_last_row); + } + + // Populate the syscall params fields. + { + let mut cols = self.convert_mut(absorb_row); + let syscall_params = cols.syscall_params_mut().absorb_mut(); + + syscall_params.clk = absorb_event.clk; + syscall_params.hash_and_absorb_num = absorb_event.hash_and_absorb_num; + syscall_params.input_ptr = absorb_event.input_addr; + syscall_params.input_len = absorb_event.input_len; + + output.add_range_check_events(&[RangeCheckEvent::new( + RangeCheckOpcode::U16, + absorb_event.input_len.as_canonical_u32() as u16, + )]); + } + + // Populate the memory fields. + { + let mut cols = self.convert_mut(absorb_row); + let memory = cols.memory_mut(); + + memory.start_addr = absorb_iter.start_addr; + for (i, input_record) in absorb_iter.input_records.iter().enumerate() { + memory.memory_slot_used[i + absorb_iter.state_cursor] = F::one(); + memory.memory_accesses[i + absorb_iter.state_cursor].populate(input_record); + } + } + + // Populate the opcode workspace fields. + { + let mut cols = self.convert_mut(absorb_row); + let absorb_workspace = cols.opcode_workspace_mut().absorb_mut(); + + absorb_workspace.hash_num = absorb_event.hash_num; + output.add_range_check_events(&[RangeCheckEvent::new( + RangeCheckOpcode::U16, + absorb_event.hash_num.as_canonical_u32() as u16, + )]); + absorb_workspace.absorb_num = absorb_event.absorb_num; + output.add_range_check_events(&[RangeCheckEvent::new( + RangeCheckOpcode::U12, + absorb_event.absorb_num.as_canonical_u32() as u16, + )]); + + let num_remaining_rows = num_absorb_rows - 1 - iter_num; + absorb_workspace.num_remaining_rows = F::from_canonical_usize(num_remaining_rows); + output.add_range_check_events(&[RangeCheckEvent::new( + RangeCheckOpcode::U16, + num_remaining_rows as u16, + )]); + + // Calculate last_row_num_consumed. + // For absorb calls that span multiple rows (e.g. the last row is not the syscall row), + // last_row_num_consumed = (input_len + state_cursor) % 8 at the syscall row. + // For absorb calls that are only one row, last_row_num_consumed = absorb_event.input_len. + if is_syscall_row { + last_row_ending_cursor = (absorb_iter.state_cursor + + absorb_event.input_len.as_canonical_u32() as usize + - 1) + % RATE; + } + + absorb_workspace.last_row_ending_cursor = + F::from_canonical_usize(last_row_ending_cursor); + + absorb_workspace + .last_row_ending_cursor_is_seven + .populate_from_field_element( + F::from_canonical_usize(last_row_ending_cursor) + - F::from_canonical_usize(7), + ); + + (0..3).for_each(|i| { + absorb_workspace.last_row_ending_cursor_bitmap[i] = + F::from_bool((last_row_ending_cursor) & (1 << i) == (1 << i)) + }); + + absorb_workspace + .num_remaining_rows_is_zero + .populate(num_remaining_rows as u32); + + absorb_workspace.is_syscall_not_last_row = + F::from_bool(is_syscall_row && !is_last_row); + absorb_workspace.is_syscall_is_last_row = + F::from_bool(is_syscall_row && is_last_row); + absorb_workspace.not_syscall_not_last_row = + F::from_bool(!is_syscall_row && !is_last_row); + absorb_workspace.not_syscall_is_last_row = + F::from_bool(!is_syscall_row && is_last_row); + absorb_workspace.is_last_row_ending_cursor_is_seven = + F::from_bool(is_last_row && last_row_ending_cursor == 7); + absorb_workspace.is_last_row_ending_cursor_not_seven = + F::from_bool(is_last_row && last_row_ending_cursor != 7); + + absorb_workspace.state = absorb_iter.state; + absorb_workspace.previous_state = absorb_iter.previous_state; + absorb_workspace.state_cursor = F::from_canonical_usize(absorb_iter.state_cursor); + absorb_workspace.is_first_hash_row = + F::from_bool(iter_num == 0 && absorb_event.absorb_num.is_zero()); + + absorb_workspace.start_mem_idx_bitmap[absorb_iter.state_cursor] = F::one(); + if is_last_row { + absorb_workspace.end_mem_idx_bitmap[last_row_ending_cursor] = F::one(); + } else { + absorb_workspace.end_mem_idx_bitmap[7] = F::one(); + } + } + + // Populate the permutation fields. + self.populate_permutation( + absorb_iter.perm_input, + if absorb_iter.do_perm { + Some(absorb_iter.perm_output) + } else { + None + }, + absorb_row, + ); + } + } + + pub fn populate_finalize_event( + &self, + row: &mut [F], + finalize_event: &Poseidon2FinalizeEvent, + ) { + // Populate the control flow fields. + { + let mut cols = self.convert_mut(row); + let control_flow = cols.control_flow_mut(); + control_flow.is_finalize = F::one(); + control_flow.is_syscall_row = F::one(); + } + + // Populate the syscall params fields. + { + let mut cols = self.convert_mut(row); + + let syscall_params = cols.syscall_params_mut().finalize_mut(); + syscall_params.clk = finalize_event.clk; + syscall_params.hash_num = finalize_event.hash_num; + syscall_params.output_ptr = finalize_event.output_ptr; + } + + // Populate the memory fields. + { + let mut cols = self.convert_mut(row); + let memory = cols.memory_mut(); + + memory.start_addr = finalize_event.output_ptr; + for i in 0..WIDTH / 2 { + memory.memory_slot_used[i] = F::one(); + memory.memory_accesses[i].populate(&finalize_event.output_records[i]); + } + } + + // Populate the opcode workspace fields. + { + let mut cols = self.convert_mut(row); + let finalize_workspace = cols.opcode_workspace_mut().finalize_mut(); + + finalize_workspace.previous_state = finalize_event.previous_state; + finalize_workspace.state = finalize_event.state; + finalize_workspace.state_cursor = F::from_canonical_usize(finalize_event.state_cursor); + finalize_workspace + .state_cursor_is_zero + .populate(finalize_event.state_cursor as u32); + } + + // Populate the permutation fields. + self.populate_permutation( + finalize_event.perm_input, + if finalize_event.do_perm { + Some(finalize_event.perm_output) + } else { + None + }, + row, + ); + } + + pub fn populate_permutation( + &self, + input: [F; WIDTH], + expected_output: Option<[F; WIDTH]>, + input_row: &mut [F], + ) { + let mut permutation = permutation_mut::(input_row); + + let ( + external_rounds_state, + internal_rounds_state, + internal_rounds_s0, + mut external_sbox, + mut internal_sbox, + output_state, + ) = permutation.get_cols_mut(); + + external_rounds_state[0] = input; + external_linear_layer(&mut external_rounds_state[0]); + + // Apply the first half of external rounds. + for r in 0..NUM_EXTERNAL_ROUNDS / 2 { + let next_state = + self.populate_external_round(external_rounds_state, &mut external_sbox, r); + if r == NUM_EXTERNAL_ROUNDS / 2 - 1 { + *internal_rounds_state = next_state; + } else { + external_rounds_state[r + 1] = next_state; + } + } + + // Apply the internal rounds. + external_rounds_state[NUM_EXTERNAL_ROUNDS / 2] = self.populate_internal_rounds( + internal_rounds_state, + internal_rounds_s0, + &mut internal_sbox, + ); + + // Apply the second half of external rounds. + for r in NUM_EXTERNAL_ROUNDS / 2..NUM_EXTERNAL_ROUNDS { + let next_state = + self.populate_external_round(external_rounds_state, &mut external_sbox, r); + if r == NUM_EXTERNAL_ROUNDS - 1 { + for i in 0..WIDTH { + output_state[i] = next_state[i]; + if let Some(expected_output) = expected_output { + assert_eq!(expected_output[i], next_state[i]); + } + } + } else { + external_rounds_state[r + 1] = next_state; + } + } + } + + fn populate_external_round( + &self, + external_rounds_state: &[[F; WIDTH]], + sbox: &mut Option<&mut [[F; WIDTH]; NUM_EXTERNAL_ROUNDS]>, + r: usize, + ) -> [F; WIDTH] { + let mut state = { + let round_state: &[F; WIDTH] = external_rounds_state[r].borrow(); + + // Add round constants. + // + // Optimization: Since adding a constant is a degree 1 operation, we can avoid adding + // columns for it, and instead include it in the constraint for the x^3 part of the sbox. + let round = if r < NUM_EXTERNAL_ROUNDS / 2 { + r + } else { + r + NUM_INTERNAL_ROUNDS + }; + let mut add_rc = *round_state; + for i in 0..WIDTH { + add_rc[i] += F::from_wrapped_u32(RC_16_30_U32[round][i]); + } + + // Apply the sboxes. + // Optimization: since the linear layer that comes after the sbox is degree 1, we can + // avoid adding columns for the result of the sbox, and instead include the x^3 -> x^7 + // part of the sbox in the constraint for the linear layer + let mut sbox_deg_7: [F; 16] = [F::zero(); WIDTH]; + let mut sbox_deg_3: [F; 16] = [F::zero(); WIDTH]; + for i in 0..WIDTH { + sbox_deg_3[i] = add_rc[i] * add_rc[i] * add_rc[i]; + sbox_deg_7[i] = sbox_deg_3[i] * sbox_deg_3[i] * add_rc[i]; + } + + if let Some(sbox) = sbox.as_deref_mut() { + sbox[r] = sbox_deg_3; + } + + sbox_deg_7 + }; + + // Apply the linear layer. + external_linear_layer(&mut state); + state + } + + fn populate_internal_rounds( + &self, + internal_rounds_state: &[F; WIDTH], + internal_rounds_s0: &mut [F; NUM_INTERNAL_ROUNDS - 1], + sbox: &mut Option<&mut [F; NUM_INTERNAL_ROUNDS]>, + ) -> [F; WIDTH] { + let mut state: [F; WIDTH] = *internal_rounds_state; + let mut sbox_deg_3: [F; NUM_INTERNAL_ROUNDS] = [F::zero(); NUM_INTERNAL_ROUNDS]; + for r in 0..NUM_INTERNAL_ROUNDS { + // Add the round constant to the 0th state element. + // Optimization: Since adding a constant is a degree 1 operation, we can avoid adding + // columns for it, just like for external rounds. + let round = r + NUM_EXTERNAL_ROUNDS / 2; + let add_rc = state[0] + F::from_wrapped_u32(RC_16_30_U32[round][0]); + + // Apply the sboxes. + // Optimization: since the linear layer that comes after the sbox is degree 1, we can + // avoid adding columns for the result of the sbox, just like for external rounds. + sbox_deg_3[r] = add_rc * add_rc * add_rc; + let sbox_deg_7 = sbox_deg_3[r] * sbox_deg_3[r] * add_rc; + + // Apply the linear layer. + state[0] = sbox_deg_7; + internal_linear_layer(&mut state); + + // Optimization: since we're only applying the sbox to the 0th state element, we only + // need to have columns for the 0th state element at every step. This is because the + // linear layer is degree 1, so all state elements at the end can be expressed as a + // degree-3 polynomial of the state at the beginning of the internal rounds and the 0th + // state element at rounds prior to the current round + if r < NUM_INTERNAL_ROUNDS - 1 { + internal_rounds_s0[r] = state[0]; + } + } + + let ret_state = state; + + if let Some(sbox) = sbox.as_deref_mut() { + *sbox = sbox_deg_3; + } + + ret_state + } +} diff --git a/recursion/core/src/runtime/mod.rs b/recursion/core/src/runtime/mod.rs index bc3fd27913..57ee7bc3e0 100644 --- a/recursion/core/src/runtime/mod.rs +++ b/recursion/core/src/runtime/mod.rs @@ -5,7 +5,7 @@ mod record; mod utils; use std::collections::VecDeque; -use std::process::exit; +use std::{array, fmt}; use std::{marker::PhantomData, sync::Arc}; use hashbrown::HashMap; @@ -24,8 +24,10 @@ use crate::air::{Block, RECURSION_PUBLIC_VALUES_COL_MAP, RECURSIVE_PROOF_NUM_PV_ use crate::cpu::CpuEvent; use crate::exp_reverse_bits::ExpReverseBitsLenEvent; use crate::fri_fold::FriFoldEvent; -use crate::memory::MemoryRecord; -use crate::poseidon2::Poseidon2Event; +use crate::memory::{compute_addr_diff, MemoryRecord}; +use crate::poseidon2_wide::events::{ + Poseidon2AbsorbEvent, Poseidon2CompressEvent, Poseidon2FinalizeEvent, Poseidon2HashEvent, +}; use crate::range_check::{RangeCheckEvent, RangeCheckOpcode}; use p3_field::{ExtensionField, PrimeField32}; @@ -131,9 +133,30 @@ pub struct Runtime, Diffusion> { >, >, + p2_hash_state: [F; PERMUTATION_WIDTH], + + p2_hash_state_cursor: usize, + + p2_current_hash_num: Option, + _marker: PhantomData, } +#[derive(Debug)] +pub enum RuntimeError { + Trap(String), +} + +impl fmt::Display for RuntimeError { + fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> fmt::Result { + match self { + RuntimeError::Trap(msg) => write!(f, "TRAP encountered: {}", msg), + } + } +} + +impl std::error::Error for RuntimeError {} + impl, Diffusion> Runtime where Poseidon2< @@ -179,6 +202,9 @@ where access: CpuRecord::default(), witness_stream: VecDeque::new(), cycle_tracker: HashMap::new(), + p2_hash_state: [F::zero(); PERMUTATION_WIDTH], + p2_hash_state_cursor: 0, + p2_current_hash_num: None, _marker: PhantomData, } } @@ -209,6 +235,9 @@ where access: CpuRecord::default(), witness_stream: VecDeque::new(), cycle_tracker: HashMap::new(), + p2_hash_state: [F::zero(); PERMUTATION_WIDTH], + p2_hash_state_cursor: 0, + p2_current_hash_num: None, _marker: PhantomData, } } @@ -268,6 +297,20 @@ where .add_range_check_events(&[diff_16bit_limb_event, diff_12bit_limb_event]); } + /// Track the range checks for the memory finalize table. This will be used later to set the + /// multiplicities in the range check table. The parameter `subtract_one` should be `true` when + /// used for checking address uniqueness, and `false` when used to range-check the addresses + /// themselves. + fn track_addr_range_check(&mut self, addr: F, next_addr: F, subtract_one: bool) { + let (diff_16, diff_12) = compute_addr_diff(next_addr, addr, subtract_one); + let diff_16bit_limb_event = + RangeCheckEvent::new(RangeCheckOpcode::U16, diff_16.as_canonical_u32() as u16); + let diff_8bit_limb_event = + RangeCheckEvent::new(RangeCheckOpcode::U12, diff_12.as_canonical_u32() as u16); + self.record + .add_range_check_events(&[diff_16bit_limb_event, diff_8bit_limb_event]); + } + fn mr(&mut self, addr: F, timestamp: F) -> (MemoryRecord, Block) { let entry = self .memory @@ -404,7 +447,7 @@ where (a_val, b_val, c_val) } - pub fn run(&mut self) { + pub fn run(&mut self) -> Result<(), RuntimeError> { let early_exit_ts = std::env::var("RECURSION_EARLY_EXIT_TS") .map_or(usize::MAX, |ts: String| ts.parse().unwrap()); while self.pc < F::from_canonical_u32(self.program.instructions.len() as u32) { @@ -593,20 +636,19 @@ where let trace = self.program.traces[trap_pc].clone(); if let Some(mut trace) = trace { trace.resolve(); - panic!("TRAP encountered. Backtrace:\n{:?}", trace); + return Err(RuntimeError::Trap(format!("Backtrace:\n{:?}", trace))); } else { for nearby_pc in (0..trap_pc).rev() { let trace = self.program.traces[nearby_pc].clone(); if let Some(mut trace) = trace { trace.resolve(); - eprintln!( + return Err(RuntimeError::Trap(format!( "TRAP encountered at pc={}. Nearest trace at pc={}: {:?}", trap_pc, nearby_pc, trace - ); - exit(1); + ))); } } - panic!("TRAP encountered. No backtrace available"); + return Err(RuntimeError::Trap("No backtrace available".to_string())); } } Opcode::HALT => { @@ -675,16 +717,115 @@ where )); } - self.record.poseidon2_events.push(Poseidon2Event { - clk: timestamp, - dst, - left, - right, - input: array, - result_array: result, - input_records, - result_records: result_records.try_into().unwrap(), + self.record + .poseidon2_compress_events + .push(Poseidon2CompressEvent { + clk: timestamp, + dst, + left, + right, + input: array, + result_array: result, + input_records, + result_records: result_records.try_into().unwrap(), + }); + + (a, b, c) = (a_val, b_val, c_val); + } + + Opcode::Poseidon2Absorb => { + self.nb_poseidons += 1; + let (a_val, b_val, c_val) = self.all_rr(&instruction); + + let hash_and_absorb_num = a_val[0]; + let start_addr = b_val[0]; + let input_len = c_val[0]; + let timestamp = self.clk; + + let two_pow_12 = 1 << 12; + + let hash_and_absorb_num_u32 = hash_and_absorb_num.as_canonical_u32(); + let hash_num = F::from_canonical_u32(hash_and_absorb_num_u32 / two_pow_12); + let absorb_num = F::from_canonical_u32(hash_and_absorb_num_u32 % two_pow_12); + + // Double check that hash_num is [0, 2^16 - 1] and absorb_num is [0, 2^12 - 1] since + // that is what the AIR will enforce. + assert!(hash_num.as_canonical_u32() < 1 << 16); + assert!(absorb_num.as_canonical_u32() < 1 << 12); + + // We currently don't support an input_len of 0, since it will need special logic in the AIR. + assert!(input_len > F::zero()); + + let mut absorb_event = Poseidon2AbsorbEvent::new( + timestamp, + hash_and_absorb_num, + start_addr, + input_len, + hash_num, + absorb_num, + ); + + let memory_records: Vec> = (0..input_len.as_canonical_u32()) + .map(|i| self.mr(start_addr + F::from_canonical_u32(i), timestamp).0) + .collect_vec(); + + let permuter = self.perm.as_ref().unwrap().clone(); + absorb_event.populate_iterations( + start_addr, + input_len, + &memory_records, + &permuter, + &mut self.p2_hash_state, + &mut self.p2_hash_state_cursor, + ); + + // Update the current hash number. + self.p2_current_hash_num = Some(hash_num); + + self.record + .poseidon2_hash_events + .push(Poseidon2HashEvent::Absorb(absorb_event)); + + (a, b, c) = (a_val, b_val, c_val); + } + + Opcode::Poseidon2Finalize => { + self.nb_poseidons += 1; + let (a_val, b_val, c_val) = self.all_rr(&instruction); + + let p2_hash_num = a_val[0]; + let output_ptr = b_val[0]; + let timestamp = self.clk; + + let do_perm = self.p2_hash_state_cursor != 0; + let perm_output = self.perm.as_ref().unwrap().permute(self.p2_hash_state); + let state = if do_perm { + perm_output + } else { + self.p2_hash_state + }; + let output_records: [MemoryRecord; DIGEST_SIZE] = array::from_fn(|i| { + self.mw(output_ptr + F::from_canonical_usize(i), state[i], timestamp) }); + + self.record + .poseidon2_hash_events + .push(Poseidon2HashEvent::Finalize(Poseidon2FinalizeEvent { + clk: timestamp, + hash_num: p2_hash_num, + output_ptr, + output_records, + state_cursor: self.p2_hash_state_cursor, + perm_input: self.p2_hash_state, + perm_output, + previous_state: self.p2_hash_state, + state, + do_perm, + })); + + self.p2_hash_state_cursor = 0; + self.p2_hash_state = [F::zero(); PERMUTATION_WIDTH]; + (a, b, c) = (a_val, b_val, c_val); } Opcode::HintBits => { @@ -941,6 +1082,29 @@ where entry.value, )) } + self.record + .last_memory_record + .sort_by_key(|(addr, _, _)| *addr); + + // For all the records but the last, need to check that the next address is greater than the + // current address, and that the difference is bounded by 2^28. We also track that the current + // address is bounded by 2^28. + for i in 0..self.record.last_memory_record.len() - 1 { + self.track_addr_range_check( + self.record.last_memory_record[i].0, + self.record.last_memory_record[i + 1].0, + true, + ); + self.track_addr_range_check(F::zero(), self.record.last_memory_record[i].0, false); + } + // Add the last range check event for the last memory address. + self.track_addr_range_check( + F::zero(), + self.record.last_memory_record.last().unwrap().0, + false, + ); + + Ok(()) } } @@ -952,7 +1116,7 @@ mod tests { utils::BabyBearPoseidon2, }; - use super::{Instruction, Opcode, RecursionProgram, Runtime}; + use super::{Instruction, Opcode, RecursionProgram, Runtime, RuntimeError}; type SC = BabyBearPoseidon2; type F = ::Val; @@ -960,7 +1124,7 @@ mod tests { type A = RiscvAir; #[test] - fn test_witness() { + fn test_witness_success() { let zero = F::zero(); let zero_block = [F::zero(); 4]; let program = RecursionProgram { @@ -994,6 +1158,41 @@ mod tests { let mut runtime = Runtime::::new(&program, machine.config().perm.clone()); runtime.witness_stream = vec![vec![F::two().into(), F::two().into(), F::two().into()]].into(); - runtime.run(); + + let result = runtime.run(); + assert!(result.is_ok(), "Expected run to complete successfully"); + } + + #[test] + fn test_witness_trap_error() { + let zero = F::zero(); + let zero_block = [F::zero(); 4]; + let trap_program = RecursionProgram { + traces: vec![None], // None trace for the TRAP instruction + instructions: vec![Instruction::new( + Opcode::TRAP, + zero, + zero_block, + zero_block, + zero, + zero, + false, + false, + "".to_string(), + )], + }; + let machine = A::machine(SC::default()); + let mut trap_runtime = + Runtime::::new(&trap_program, machine.config().perm.clone()); + + let trap_result = trap_runtime.run(); + assert!( + trap_result.is_err(), + "Expected run to return an error due to TRAP instruction" + ); + + if let Err(RuntimeError::Trap(msg)) = trap_result { + println!("Caught expected trap error: {}", msg); + } } } diff --git a/recursion/core/src/runtime/opcode.rs b/recursion/core/src/runtime/opcode.rs index d6db8abc13..fa9913dd34 100644 --- a/recursion/core/src/runtime/opcode.rs +++ b/recursion/core/src/runtime/opcode.rs @@ -32,9 +32,13 @@ pub enum Opcode { TRAP = 30, HALT = 31, - // Hash instructions. + // Poseidon2 compress. Poseidon2Compress = 39, + // Poseidon2 hash. + Poseidon2Absorb = 46, + Poseidon2Finalize = 47, + // Bit instructions. HintBits = 32, diff --git a/recursion/core/src/runtime/record.rs b/recursion/core/src/runtime/record.rs index c6c0217bf3..5e2babb949 100644 --- a/recursion/core/src/runtime/record.rs +++ b/recursion/core/src/runtime/record.rs @@ -1,26 +1,27 @@ +use hashbrown::HashMap; +use sp1_core::utils::SP1CoreOpts; use std::array; -use std::collections::BTreeMap; use std::sync::Arc; use p3_field::{AbstractField, PrimeField32}; use sp1_core::stark::{MachineRecord, PROOF_MAX_NUM_PVS}; -use std::collections::HashMap; use super::RecursionProgram; use crate::air::Block; use crate::cpu::CpuEvent; use crate::exp_reverse_bits::ExpReverseBitsLenEvent; use crate::fri_fold::FriFoldEvent; -use crate::poseidon2::Poseidon2Event; +use crate::poseidon2_wide::events::{Poseidon2CompressEvent, Poseidon2HashEvent}; use crate::range_check::RangeCheckEvent; #[derive(Default, Debug, Clone)] pub struct ExecutionRecord { pub program: Arc>, pub cpu_events: Vec>, - pub poseidon2_events: Vec>, + pub poseidon2_compress_events: Vec>, + pub poseidon2_hash_events: Vec>, pub fri_fold_events: Vec>, - pub range_check_events: BTreeMap, + pub range_check_events: HashMap, pub exp_reverse_bits_len_events: Vec>, // (address, value) pub first_memory_record: Vec<(F, Block)>, @@ -41,18 +42,19 @@ impl ExecutionRecord { } impl MachineRecord for ExecutionRecord { - type Config = (); - - fn index(&self) -> u32 { - 0 - } - - fn set_index(&mut self, _: u32) {} + type Config = SP1CoreOpts; fn stats(&self) -> HashMap { let mut stats = HashMap::new(); stats.insert("cpu_events".to_string(), self.cpu_events.len()); - stats.insert("poseidon2_events".to_string(), self.poseidon2_events.len()); + stats.insert( + "poseidon2_events".to_string(), + self.poseidon2_compress_events.len(), + ); + stats.insert( + "poseidon2_events".to_string(), + self.poseidon2_hash_events.len(), + ); stats.insert("fri_fold_events".to_string(), self.fri_fold_events.len()); stats.insert( "range_check_events".to_string(), @@ -83,10 +85,6 @@ impl MachineRecord for ExecutionRecord { } } - fn shard(self, _: &Self::Config) -> Vec { - vec![self] - } - fn public_values(&self) -> Vec { let ret: [T; PROOF_MAX_NUM_PVS] = array::from_fn(|i| { if i < self.public_values.len() { diff --git a/recursion/core/src/stark/mod.rs b/recursion/core/src/stark/mod.rs index 8f24874f5d..8b63a6a3ae 100644 --- a/recursion/core/src/stark/mod.rs +++ b/recursion/core/src/stark/mod.rs @@ -4,8 +4,8 @@ pub mod utils; use crate::{ cpu::CpuChip, exp_reverse_bits::ExpReverseBitsLenChip, fri_fold::FriFoldChip, - memory::MemoryGlobalChip, multi::MultiChip, poseidon2::Poseidon2Chip, - poseidon2_wide::Poseidon2WideChip, program::ProgramChip, range_check::RangeCheckChip, + memory::MemoryGlobalChip, multi::MultiChip, poseidon2_wide::Poseidon2WideChip, + program::ProgramChip, range_check::RangeCheckChip, }; use core::iter::once; use p3_field::{extension::BinomiallyExtendable, PrimeField32}; @@ -16,19 +16,20 @@ use std::marker::PhantomData; use crate::runtime::D; pub type RecursionAirWideDeg3 = RecursionAir; -pub type RecursionAirSkinnyDeg9 = RecursionAir; +pub type RecursionAirWideDeg9 = RecursionAir; +pub type RecursionAirWideDeg17 = RecursionAir; #[derive(MachineAir)] #[sp1_core_path = "sp1_core"] #[execution_record_path = "crate::runtime::ExecutionRecord"] #[program_path = "crate::runtime::RecursionProgram"] #[builder_path = "crate::air::SP1RecursionAirBuilder"] +#[eval_trait_bound = "AB::Var: 'static"] pub enum RecursionAir, const DEGREE: usize> { Program(ProgramChip), Cpu(CpuChip), MemoryGlobal(MemoryGlobalChip), Poseidon2Wide(Poseidon2WideChip), - Poseidon2Skinny(Poseidon2Chip), FriFold(FriFoldChip), RangeCheck(RangeCheckChip), Multi(MultiChip), @@ -76,6 +77,7 @@ impl, const DEGREE: usize> RecursionAi DEGREE, > { fixed_log2_rows: None, + pad: true, }))) .chain(once(RecursionAir::FriFold(FriFoldChip:: { fixed_log2_rows: None, @@ -123,15 +125,9 @@ impl, const DEGREE: usize> RecursionAi fixed_log2_rows: Some(19), }))) .chain(once(RecursionAir::Multi(MultiChip { - fixed_log2_rows: Some(19), + fixed_log2_rows: Some(17), }))) .chain(once(RecursionAir::RangeCheck(RangeCheckChip::default()))) - .chain(once(RecursionAir::ExpReverseBitsLen( - ExpReverseBitsLenChip:: { - fixed_log2_rows: None, - pad: true, - }, - ))) .collect() } } diff --git a/recursion/core/src/stark/utils.rs b/recursion/core/src/stark/utils.rs index 15c642c046..f56c546fd0 100644 --- a/recursion/core/src/stark/utils.rs +++ b/recursion/core/src/stark/utils.rs @@ -6,8 +6,8 @@ use sp1_core::utils::BabyBearPoseidon2; use crate::air::Block; use crate::runtime::RecursionProgram; use crate::runtime::Runtime; -use crate::stark::RecursionAir; -use crate::stark::RecursionAirSkinnyDeg9; +use crate::stark::RecursionAirWideDeg3; +use crate::stark::RecursionAirWideDeg9; use p3_field::PrimeField32; use sp1_core::utils::run_test_machine; use std::collections::VecDeque; @@ -17,7 +17,7 @@ pub enum TestConfig { All, WideDeg3, SkinnyDeg7, - SkinnyDeg7Wrap, + WideDeg17Wrap, } type Val = ::Val; @@ -37,37 +37,44 @@ pub fn run_test_recursion( if witness.is_some() { runtime.witness_stream = witness.unwrap(); } - runtime.run(); - println!( - "The program executed successfully, number of cycles: {}", - runtime.clk.as_canonical_u32() / 4 - ); + + match runtime.run() { + Ok(_) => { + println!( + "The program executed successfully, number of cycles: {}", + runtime.clk.as_canonical_u32() / 4 + ); + } + Err(e) => { + eprintln!("Runtime error: {:?}", e); + return; + } + } + + let records = vec![runtime.record]; if test_config == TestConfig::All || test_config == TestConfig::WideDeg3 { - let machine = RecursionAir::<_, 3>::machine(BabyBearPoseidon2::default()); + let machine = RecursionAirWideDeg3::machine(BabyBearPoseidon2::default()); let (pk, vk) = machine.setup(&program); - let record = runtime.record.clone(); - let result = run_test_machine(record, machine, pk, vk); + let result = run_test_machine(records.clone(), machine, pk, vk); if let Err(e) = result { panic!("Verification failed: {:?}", e); } } if test_config == TestConfig::All || test_config == TestConfig::SkinnyDeg7 { - let machine = RecursionAirSkinnyDeg9::machine(BabyBearPoseidon2::compressed()); + let machine = RecursionAirWideDeg9::machine(BabyBearPoseidon2::compressed()); let (pk, vk) = machine.setup(&program); - let record = runtime.record.clone(); - let result = run_test_machine(record, machine, pk, vk); + let result = run_test_machine(records.clone(), machine, pk, vk); if let Err(e) = result { panic!("Verification failed: {:?}", e); } } - if test_config == TestConfig::All || test_config == TestConfig::SkinnyDeg7Wrap { - let machine = RecursionAirSkinnyDeg9::wrap_machine(BabyBearPoseidon2::compressed()); + if test_config == TestConfig::All || test_config == TestConfig::WideDeg17Wrap { + let machine = RecursionAirWideDeg9::wrap_machine(BabyBearPoseidon2::compressed()); let (pk, vk) = machine.setup(&program); - let record = runtime.record.clone(); - let result = run_test_machine(record, machine, pk, vk); + let result = run_test_machine(records.clone(), machine, pk, vk); if let Err(e) = result { panic!("Verification failed: {:?}", e); } diff --git a/recursion/derive/CHANGELOG.md b/recursion/derive/CHANGELOG.md new file mode 100644 index 0000000000..5f89140ab1 --- /dev/null +++ b/recursion/derive/CHANGELOG.md @@ -0,0 +1,14 @@ +# Changelog + +All notable changes to this project will be documented in this file. + +The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/), +and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html). + +## [Unreleased] + +## [1.0.0-rc.1](https://github.com/succinctlabs/sp1/compare/sp1-recursion-derive-v1.0.0-rc.1...sp1-recursion-derive-v1.0.0-rc.1) - 2024-07-19 + +### Other + +- use global workspace version ([#1102](https://github.com/succinctlabs/sp1/pull/1102)) diff --git a/recursion/derive/Cargo.toml b/recursion/derive/Cargo.toml index 410e544ce0..44526be4c0 100644 --- a/recursion/derive/Cargo.toml +++ b/recursion/derive/Cargo.toml @@ -1,7 +1,13 @@ [package] name = "sp1-recursion-derive" -version = "0.1.0" -edition = "2021" +description = "SP1 is a performant, 100% open-source, contributor-friendly zkVM." +readme = "../../README.md" +version = { workspace = true } +edition = { workspace = true } +license = { workspace = true } +repository = { workspace = true } +keywords = { workspace = true } +categories = { workspace = true } [lib] proc-macro = true diff --git a/recursion/gnark-cli/CHANGELOG.md b/recursion/gnark-cli/CHANGELOG.md new file mode 100644 index 0000000000..36df8dba2c --- /dev/null +++ b/recursion/gnark-cli/CHANGELOG.md @@ -0,0 +1,39 @@ +# Changelog + +All notable changes to this project will be documented in this file. + +The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/), +and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html). + +## [Unreleased] + +## [1.0.0-rc.1](https://github.com/succinctlabs/sp1/compare/sp1-recursion-gnark-cli-v1.0.0-rc.1...sp1-recursion-gnark-cli-v1.0.0-rc.1) - 2024-07-19 + +### Added + +- publish sp1 to crates.io ([#1052](https://github.com/succinctlabs/sp1/pull/1052)) +- use docker by default for gnark ([#890](https://github.com/succinctlabs/sp1/pull/890)) +- new README img ([#226](https://github.com/succinctlabs/sp1/pull/226)) +- readme updates ([#205](https://github.com/succinctlabs/sp1/pull/205)) +- more final touches ([#194](https://github.com/succinctlabs/sp1/pull/194)) +- curtaup + release system + cargo prove CLI updates ([#178](https://github.com/succinctlabs/sp1/pull/178)) +- (perf) updates from Plonky3 and verifier refactor ([#156](https://github.com/succinctlabs/sp1/pull/156)) +- developer experience improvements ([#145](https://github.com/succinctlabs/sp1/pull/145)) +- toolchain build from source & install ([#113](https://github.com/succinctlabs/sp1/pull/113)) +- io::read io::write ([#126](https://github.com/succinctlabs/sp1/pull/126)) +- tracing, profiling, benchmarking ([#99](https://github.com/succinctlabs/sp1/pull/99)) + +### Other + +- _(deps)_ bump clap from 4.5.8 to 4.5.9 ([#1107](https://github.com/succinctlabs/sp1/pull/1107)) +- use global workspace version ([#1102](https://github.com/succinctlabs/sp1/pull/1102)) +- fix release-plz ([#1088](https://github.com/succinctlabs/sp1/pull/1088)) +- add release-plz ([#1086](https://github.com/succinctlabs/sp1/pull/1086)) +- final touches for public release ([#239](https://github.com/succinctlabs/sp1/pull/239)) +- update docs with slight nits ([#224](https://github.com/succinctlabs/sp1/pull/224)) +- sp1 rename ([#212](https://github.com/succinctlabs/sp1/pull/212)) +- enshrine AlignedBorrow macro ([#209](https://github.com/succinctlabs/sp1/pull/209)) +- readme cleanup ([#196](https://github.com/succinctlabs/sp1/pull/196)) +- rename succinct to curta ([#192](https://github.com/succinctlabs/sp1/pull/192)) +- better curta graphic ([#184](https://github.com/succinctlabs/sp1/pull/184)) +- Initial commit diff --git a/recursion/gnark-cli/Cargo.toml b/recursion/gnark-cli/Cargo.toml index cd6fe2647c..c43a28566b 100644 --- a/recursion/gnark-cli/Cargo.toml +++ b/recursion/gnark-cli/Cargo.toml @@ -1,10 +1,15 @@ -[workspace] [package] name = "sp1-recursion-gnark-cli" -version = "0.1.0" -edition = "2021" +description = "SP1 is a performant, 100% open-source, contributor-friendly zkVM." +readme = "../../README.md" +version = { workspace = true } +edition = { workspace = true } +license = { workspace = true } +repository = { workspace = true } +keywords = { workspace = true } +categories = { workspace = true } [dependencies] -sp1-recursion-gnark-ffi = { path = "../gnark-ffi", features = ["native"] } -clap = { version = "4.3.8", features = ["derive"] } +sp1-recursion-gnark-ffi = { workspace = true, features = ["native"] } +clap = { version = "4.5.9", features = ["derive"] } bincode = "1.3.3" diff --git a/recursion/gnark-ffi/CHANGELOG.md b/recursion/gnark-ffi/CHANGELOG.md new file mode 100644 index 0000000000..08995dbe72 --- /dev/null +++ b/recursion/gnark-ffi/CHANGELOG.md @@ -0,0 +1,87 @@ +# Changelog + +All notable changes to this project will be documented in this file. + +The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/), +and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html). + +## [Unreleased] + +## [1.0.0-rc.1](https://github.com/succinctlabs/sp1/compare/sp1-recursion-gnark-ffi-v1.0.0-rc.1...sp1-recursion-gnark-ffi-v1.0.0-rc.1) - 2024-07-19 + +### Added + +- 1.0.0-rc.1 ([#1126](https://github.com/succinctlabs/sp1/pull/1126)) +- publish sp1 to crates.io ([#1052](https://github.com/succinctlabs/sp1/pull/1052)) +- update verifier contract templates ([#963](https://github.com/succinctlabs/sp1/pull/963)) +- circuit version in proof ([#926](https://github.com/succinctlabs/sp1/pull/926)) +- sp1 circuit version ([#899](https://github.com/succinctlabs/sp1/pull/899)) +- use docker by default for gnark ([#890](https://github.com/succinctlabs/sp1/pull/890)) +- _(sdk)_ add explorer link ([#858](https://github.com/succinctlabs/sp1/pull/858)) +- update contract artifacts ([#802](https://github.com/succinctlabs/sp1/pull/802)) +- plonk prover ([#795](https://github.com/succinctlabs/sp1/pull/795)) +- groth16 feature flag ([#782](https://github.com/succinctlabs/sp1/pull/782)) +- add proof verification ([#729](https://github.com/succinctlabs/sp1/pull/729)) +- e2e groth16 with contract verifier ([#671](https://github.com/succinctlabs/sp1/pull/671)) +- add `groth16` verification to gnark server ([#631](https://github.com/succinctlabs/sp1/pull/631)) +- load circuit artifacts in faster ([#638](https://github.com/succinctlabs/sp1/pull/638)) +- regularize proof shape ([#641](https://github.com/succinctlabs/sp1/pull/641)) +- _(sdk)_ auto setup circuit ([#635](https://github.com/succinctlabs/sp1/pull/635)) +- canonicalize build dir paths ([#637](https://github.com/succinctlabs/sp1/pull/637)) +- groth16 server ([#594](https://github.com/succinctlabs/sp1/pull/594)) +- recursion compress layer + RecursionAirWideDeg3 + RecursionAirSkinnyDeg7 + optimized groth16 ([#590](https://github.com/succinctlabs/sp1/pull/590)) +- plonk e2e prover ([#582](https://github.com/succinctlabs/sp1/pull/582)) +- new README img ([#226](https://github.com/succinctlabs/sp1/pull/226)) +- readme updates ([#205](https://github.com/succinctlabs/sp1/pull/205)) +- more final touches ([#194](https://github.com/succinctlabs/sp1/pull/194)) +- curtaup + release system + cargo prove CLI updates ([#178](https://github.com/succinctlabs/sp1/pull/178)) +- (perf) updates from Plonky3 and verifier refactor ([#156](https://github.com/succinctlabs/sp1/pull/156)) +- developer experience improvements ([#145](https://github.com/succinctlabs/sp1/pull/145)) +- toolchain build from source & install ([#113](https://github.com/succinctlabs/sp1/pull/113)) +- io::read io::write ([#126](https://github.com/succinctlabs/sp1/pull/126)) +- tracing, profiling, benchmarking ([#99](https://github.com/succinctlabs/sp1/pull/99)) + +### Fixed + +- _(contracts)_ check verifier success ([#983](https://github.com/succinctlabs/sp1/pull/983)) +- close unclosed file streams ([#954](https://github.com/succinctlabs/sp1/pull/954)) +- some informational fixes from veridise audit ([#953](https://github.com/succinctlabs/sp1/pull/953)) +- mock verifier ([#936](https://github.com/succinctlabs/sp1/pull/936)) +- reduce minimum Solidity version for SP1 contracts ([#921](https://github.com/succinctlabs/sp1/pull/921)) +- plonk feature off by default ([#852](https://github.com/succinctlabs/sp1/pull/852)) +- gnark-ffi linking on mac +- solidity verifier +- shutdown groth16 ([#667](https://github.com/succinctlabs/sp1/pull/667)) +- better groth16 file handling ([#620](https://github.com/succinctlabs/sp1/pull/620)) + +### Other + +- _(deps)_ bump cc from 1.0.100 to 1.1.5 ([#1104](https://github.com/succinctlabs/sp1/pull/1104)) +- use global workspace version ([#1102](https://github.com/succinctlabs/sp1/pull/1102)) +- fix release-plz ([#1088](https://github.com/succinctlabs/sp1/pull/1088)) +- add release-plz ([#1086](https://github.com/succinctlabs/sp1/pull/1086)) +- _(deps)_ bump serde from 1.0.203 to 1.0.204 ([#1063](https://github.com/succinctlabs/sp1/pull/1063)) +- _(contracts)_ remove mock verifier and interface autogen ([#1045](https://github.com/succinctlabs/sp1/pull/1045)) +- Merge branch 'dev' into dependabot/cargo/dev/log-0.4.22 +- _(deps)_ bump serde_json from 1.0.117 to 1.0.120 ([#1001](https://github.com/succinctlabs/sp1/pull/1001)) +- _(deps)_ bump num-bigint from 0.4.5 to 0.4.6 +- circuit poseidon2 babybear ([#870](https://github.com/succinctlabs/sp1/pull/870)) +- docs +- lint +- encode proof solidity +- `prove_plonk` ([#827](https://github.com/succinctlabs/sp1/pull/827)) +- Make some functions const ([#774](https://github.com/succinctlabs/sp1/pull/774)) +- remove unused deps ([#794](https://github.com/succinctlabs/sp1/pull/794)) +- use actual ffi for gnark ([#738](https://github.com/succinctlabs/sp1/pull/738)) +- update all dependencies ([#689](https://github.com/succinctlabs/sp1/pull/689)) +- gnark folder ([#677](https://github.com/succinctlabs/sp1/pull/677)) +- Implement `Prover` on `MockProver` ([#629](https://github.com/succinctlabs/sp1/pull/629)) +- prover tweaks ([#610](https://github.com/succinctlabs/sp1/pull/610)) +- final touches for public release ([#239](https://github.com/succinctlabs/sp1/pull/239)) +- update docs with slight nits ([#224](https://github.com/succinctlabs/sp1/pull/224)) +- sp1 rename ([#212](https://github.com/succinctlabs/sp1/pull/212)) +- enshrine AlignedBorrow macro ([#209](https://github.com/succinctlabs/sp1/pull/209)) +- readme cleanup ([#196](https://github.com/succinctlabs/sp1/pull/196)) +- rename succinct to curta ([#192](https://github.com/succinctlabs/sp1/pull/192)) +- better curta graphic ([#184](https://github.com/succinctlabs/sp1/pull/184)) +- Initial commit diff --git a/recursion/gnark-ffi/Cargo.toml b/recursion/gnark-ffi/Cargo.toml index 7ac3cea14f..1ef47e6ce1 100644 --- a/recursion/gnark-ffi/Cargo.toml +++ b/recursion/gnark-ffi/Cargo.toml @@ -1,20 +1,26 @@ [package] name = "sp1-recursion-gnark-ffi" -version = "0.1.0" -edition = "2021" +description = "SP1 is a performant, 100% open-source, contributor-friendly zkVM." +readme = "../../README.md" +version = { workspace = true } +edition = { workspace = true } +license = { workspace = true } +repository = { workspace = true } +keywords = { workspace = true } +categories = { workspace = true } [dependencies] p3-field = { workspace = true } p3-symmetric = { workspace = true } p3-baby-bear = { workspace = true } -sp1-recursion-compiler = { path = "../compiler" } -sp1-core = { path = "../../core" } -serde = "1.0.201" -serde_json = "1.0.117" +sp1-recursion-compiler = { workspace = true } +sp1-core = { workspace = true } +serde = "1.0.204" +serde_json = "1.0.120" tempfile = "3.10.1" rand = "0.8" -log = "0.4.21" -num-bigint = "0.4.5" +log = "0.4.22" +num-bigint = "0.4.6" cfg-if = "1.0" bincode = "1.3.3" anyhow = "1.0.86" @@ -23,7 +29,7 @@ hex = "0.4.3" [build-dependencies] bindgen = "0.69.4" -cc = "1.0" +cc = "1.1" cfg-if = "1.0" [features] diff --git a/recursion/gnark-ffi/assets/ISP1Verifier.txt b/recursion/gnark-ffi/assets/ISP1Verifier.txt deleted file mode 100644 index 1ea8727937..0000000000 --- a/recursion/gnark-ffi/assets/ISP1Verifier.txt +++ /dev/null @@ -1,23 +0,0 @@ -// SPDX-License-Identifier: MIT -pragma solidity ^0.8.19; - -/// @title SP1 Verifier Interface -/// @author Succinct Labs -/// @notice This contract is the interface for the SP1 Verifier. -interface ISP1Verifier { - /// @notice Returns the version of SP1 this verifier corresponds to. - function VERSION() external pure returns (string memory); - - /// @notice Returns the hash of the verification key. - function VKEY_HASH() external pure returns (bytes32); - - /// @notice Verifies a proof with given public values and vkey. - /// @param vkey The verification key for the RISC-V program. - /// @param publicValues The public values encoded as bytes. - /// @param proofBytes The proof of the program execution the SP1 zkVM encoded as bytes. - function verifyProof( - bytes32 vkey, - bytes calldata publicValues, - bytes calldata proofBytes - ) external view; -} diff --git a/recursion/gnark-ffi/assets/SP1MockVerifier.txt b/recursion/gnark-ffi/assets/SP1MockVerifier.txt deleted file mode 100644 index 0ca6f4a1fb..0000000000 --- a/recursion/gnark-ffi/assets/SP1MockVerifier.txt +++ /dev/null @@ -1,23 +0,0 @@ -// SPDX-License-Identifier: MIT -pragma solidity ^0.8.19; - -import {ISP1Verifier} from "./ISP1Verifier.sol"; - -/// @title SP1 Mock Verifier -/// @author Succinct Labs -/// @notice This contracts implements a Mock solidity verifier for SP1. -contract SP1MockVerifier is ISP1Verifier { - function VERSION() external pure returns (string memory) { - return "TODO"; - } - - /// @notice Verifies a mock proof with given public values and vkey. - /// @param proofBytes The proof of the program execution the SP1 zkVM encoded as bytes. - function verifyProof( - bytes32, - bytes memory, - bytes memory proofBytes - ) external pure { - assert(proofBytes.length == 0); - } -} diff --git a/recursion/gnark-ffi/assets/SP1Verifier.txt b/recursion/gnark-ffi/assets/SP1Verifier.txt index 2cc044bfb5..0c009135e3 100644 --- a/recursion/gnark-ffi/assets/SP1Verifier.txt +++ b/recursion/gnark-ffi/assets/SP1Verifier.txt @@ -1,21 +1,29 @@ // SPDX-License-Identifier: MIT -pragma solidity ^0.8.19; +pragma solidity ^0.8.20; -import {ISP1Verifier} from "./ISP1Verifier.sol"; +import {ISP1Verifier, ISP1VerifierWithHash} from "../ISP1Verifier.sol"; import {PlonkVerifier} from "./PlonkVerifier.sol"; /// @title SP1 Verifier /// @author Succinct Labs /// @notice This contracts implements a solidity verifier for SP1. -contract SP1Verifier is PlonkVerifier { - error WrongVersionProof(); +contract SP1Verifier is PlonkVerifier, ISP1VerifierWithHash { + /// @notice Thrown when the verifier selector from this proof does not match the one in this + /// verifier. This indicates that this proof was sent to the wrong verifier. + /// @param received The verifier selector from the first 4 bytes of the proof. + /// @param expected The verifier selector from the first 4 bytes of the VERIFIER_HASH(). + error WrongVerifierSelector(bytes4 received, bytes4 expected); + + /// @notice Thrown when the proof is invalid. + error InvalidProof(); function VERSION() external pure returns (string memory) { return "{SP1_CIRCUIT_VERSION}"; } - function VKEY_HASH() public pure returns (bytes32) { - return {VKEY_HASH}; + /// @inheritdoc ISP1VerifierWithHash + function VERIFIER_HASH() public pure returns (bytes32) { + return {VERIFIER_HASH}; } /// @notice Hashes the public values to a field elements inside Bn254. @@ -27,25 +35,27 @@ contract SP1Verifier is PlonkVerifier { } /// @notice Verifies a proof with given public values and vkey. - /// @param vkey The verification key for the RISC-V program. + /// @param programVKey The verification key for the RISC-V program. /// @param publicValues The public values encoded as bytes. /// @param proofBytes The proof of the program execution the SP1 zkVM encoded as bytes. function verifyProof( - bytes32 vkey, + bytes32 programVKey, bytes calldata publicValues, bytes calldata proofBytes - ) public view { - // To ensure the proof corresponds to this verifier, we check that the first 4 bytes of - // proofBytes match the first 4 bytes of VKEY_HASH. - bytes4 proofBytesPrefix = bytes4(proofBytes[:4]); - if (proofBytesPrefix != bytes4(VKEY_HASH())) { - revert WrongVersionProof(); + ) external view { + bytes4 receivedSelector = bytes4(proofBytes[:4]); + bytes4 expectedSelector = bytes4(VERIFIER_HASH()); + if (receivedSelector != expectedSelector) { + revert WrongVerifierSelector(receivedSelector, expectedSelector); } bytes32 publicValuesDigest = hashPublicValues(publicValues); uint256[] memory inputs = new uint256[](2); - inputs[0] = uint256(vkey); + inputs[0] = uint256(programVKey); inputs[1] = uint256(publicValuesDigest); - this.Verify(proofBytes[4:], inputs); + bool success = this.Verify(proofBytes[4:], inputs); + if (!success) { + revert InvalidProof(); + } } -} \ No newline at end of file +} diff --git a/recursion/gnark-ffi/go/sp1/babybear/babybear.go b/recursion/gnark-ffi/go/sp1/babybear/babybear.go index 07ac880298..066edd2653 100644 --- a/recursion/gnark-ffi/go/sp1/babybear/babybear.go +++ b/recursion/gnark-ffi/go/sp1/babybear/babybear.go @@ -13,10 +13,10 @@ import ( "github.com/consensys/gnark/std/rangecheck" ) -var MODULUS = new(big.Int).SetUint64(2013265921) -var W = new(big.Int).SetUint64(11) +var modulus = new(big.Int).SetUint64(2013265921) func init() { + // These functions must be public so Gnark's hint system can access them. solver.RegisterHint(InvFHint) solver.RegisterHint(InvEHint) solver.RegisterHint(ReduceHint) @@ -69,40 +69,40 @@ func (c *Chip) AddF(a, b Variable) Variable { } else { maxBits = b.NbBits } - return c.ReduceFast(Variable{ + return c.reduceFast(Variable{ Value: c.api.Add(a.Value, b.Value), NbBits: maxBits + 1, }) } func (c *Chip) SubF(a, b Variable) Variable { - negB := c.NegF(b) + negB := c.negF(b) return c.AddF(a, negB) } func (c *Chip) MulF(a, b Variable) Variable { - return c.ReduceFast(Variable{ + return c.reduceFast(Variable{ Value: c.api.Mul(a.Value, b.Value), NbBits: a.NbBits + b.NbBits, }) } func (c *Chip) MulFConst(a Variable, b int) Variable { - return c.ReduceFast(Variable{ + return c.reduceFast(Variable{ Value: c.api.Mul(a.Value, b), NbBits: a.NbBits + 4, }) } -func (c *Chip) NegF(a Variable) Variable { +func (c *Chip) negF(a Variable) Variable { if a.NbBits == 31 { - return Variable{Value: c.api.Sub(MODULUS, a.Value), NbBits: 31} + return Variable{Value: c.api.Sub(modulus, a.Value), NbBits: 31} } negOne := NewF("2013265920") return c.MulF(a, negOne) } -func (c *Chip) InvF(in Variable) Variable { +func (c *Chip) invF(in Variable) Variable { in = c.ReduceSlow(in) result, err := c.api.Compiler().NewHint(InvFHint, 1, in.Value) if err != nil { @@ -243,10 +243,10 @@ func (c *Chip) DivE(a, b ExtensionVariable) ExtensionVariable { } func (c *Chip) NegE(a ExtensionVariable) ExtensionVariable { - v1 := c.NegF(a.Value[0]) - v2 := c.NegF(a.Value[1]) - v3 := c.NegF(a.Value[2]) - v4 := c.NegF(a.Value[3]) + v1 := c.negF(a.Value[0]) + v2 := c.negF(a.Value[1]) + v3 := c.negF(a.Value[2]) + v4 := c.negF(a.Value[3]) return ExtensionVariable{Value: [4]Variable{v1, v2, v3, v4}} } @@ -254,10 +254,10 @@ func (c *Chip) ToBinary(in Variable) []frontend.Variable { return c.api.ToBinary(c.ReduceSlow(in).Value, 32) } -func (p *Chip) ReduceFast(x Variable) Variable { +func (p *Chip) reduceFast(x Variable) Variable { if x.NbBits >= uint(120) { return Variable{ - Value: p.ReduceWithMaxBits(x.Value, uint64(x.NbBits)), + Value: p.reduceWithMaxBits(x.Value, uint64(x.NbBits)), NbBits: 31, } } @@ -269,12 +269,12 @@ func (p *Chip) ReduceSlow(x Variable) Variable { return x } return Variable{ - Value: p.ReduceWithMaxBits(x.Value, uint64(x.NbBits)), + Value: p.reduceWithMaxBits(x.Value, uint64(x.NbBits)), NbBits: 31, } } -func (p *Chip) ReduceWithMaxBits(x frontend.Variable, maxNbBits uint64) frontend.Variable { +func (p *Chip) reduceWithMaxBits(x frontend.Variable, maxNbBits uint64) frontend.Variable { result, err := p.api.Compiler().NewHint(ReduceHint, 2, x) if err != nil { panic(err) @@ -286,7 +286,7 @@ func (p *Chip) ReduceWithMaxBits(x frontend.Variable, maxNbBits uint64) frontend remainder := result[1] p.rangeChecker.Check(remainder, 31) - p.api.AssertIsEqual(x, p.api.Add(p.api.Mul(quotient, MODULUS), result[1])) + p.api.AssertIsEqual(x, p.api.Add(p.api.Mul(quotient, modulus), result[1])) return remainder } @@ -294,11 +294,11 @@ func (p *Chip) ReduceWithMaxBits(x frontend.Variable, maxNbBits uint64) frontend // The hint used to compute Reduce. func ReduceHint(_ *big.Int, inputs []*big.Int, results []*big.Int) error { if len(inputs) != 1 { - panic("ReduceHint expects 1 input operand") + panic("reduceHint expects 1 input operand") } input := inputs[0] - quotient := new(big.Int).Div(input, MODULUS) - remainder := new(big.Int).Rem(input, MODULUS) + quotient := new(big.Int).Div(input, modulus) + remainder := new(big.Int).Rem(input, modulus) results[0] = quotient results[1] = remainder return nil diff --git a/recursion/gnark-ffi/go/sp1/build.go b/recursion/gnark-ffi/go/sp1/build.go index ccd278c1d5..5531b7ebb5 100644 --- a/recursion/gnark-ffi/go/sp1/build.go +++ b/recursion/gnark-ffi/go/sp1/build.go @@ -21,7 +21,7 @@ func Build(dataDir string) { // // TODO: There might be some non-determinism if a single process is running this command // multiple times. - os.Setenv("CONSTRAINTS_JSON", dataDir+"/"+CONSTRAINTS_JSON_FILE) + os.Setenv("CONSTRAINTS_JSON", dataDir+"/"+constraintsJsonFile) // Read the file. witnessInputPath := dataDir + "/witness.json" @@ -49,8 +49,8 @@ func Build(dataDir string) { // Download the trusted setup. var srs kzg.SRS = kzg.NewSRS(ecc.BN254) var srsLagrange kzg.SRS = kzg.NewSRS(ecc.BN254) - srsFileName := dataDir + "/" + SRS_FILE - srsLagrangeFileName := dataDir + "/" + SRS_LAGRANGE_FILE + srsFileName := dataDir + "/" + srsFile + srsLagrangeFileName := dataDir + "/" + srsLagrangeFile srsLagrangeFile, err := os.Create(srsLagrangeFileName) if err != nil { @@ -71,7 +71,6 @@ func Build(dataDir string) { defer srsFile.Close() _, err = srs.ReadFrom(srsFile) - srsFile.Close() if err != nil { panic(err) } @@ -89,22 +88,15 @@ func Build(dataDir string) { defer srsFile.Close() _, err = srs.ReadFrom(srsFile) - srsFile.Close() if err != nil { panic(err) } - srsLagrangeFile, err := os.Open(srsLagrangeFileName) - if err != nil { - panic(err) - } - defer srsLagrangeFile.Close() - _, err = srsLagrange.ReadFrom(srsLagrangeFile) - srsLagrangeFile.Close() if err != nil { panic(err) } + } } else { srs, srsLagrange, err = unsafekzg.NewSRS(scs) @@ -160,14 +152,15 @@ func Build(dataDir string) { os.MkdirAll(dataDir, 0755) // Write the solidity verifier. - solidityVerifierFile, err := os.Create(dataDir + "/" + VERIFIER_CONTRACT_PATH) + solidityVerifierFile, err := os.Create(dataDir + "/" + verifierContractPath) if err != nil { panic(err) } vk.ExportSolidity(solidityVerifierFile) + defer solidityVerifierFile.Close() // Write the R1CS. - scsFile, err := os.Create(dataDir + "/" + CIRCUIT_PATH) + scsFile, err := os.Create(dataDir + "/" + circuitPath) if err != nil { panic(err) } @@ -178,7 +171,7 @@ func Build(dataDir string) { } // Write the verifier key. - vkFile, err := os.Create(dataDir + "/" + VK_PATH) + vkFile, err := os.Create(dataDir + "/" + vkPath) if err != nil { panic(err) } @@ -189,7 +182,7 @@ func Build(dataDir string) { } // Write the proving key. - pkFile, err := os.Create(dataDir + "/" + PK_PATH) + pkFile, err := os.Create(dataDir + "/" + pkPath) if err != nil { panic(err) } diff --git a/recursion/gnark-ffi/go/sp1/poseidon2/constants.go b/recursion/gnark-ffi/go/sp1/poseidon2/constants.go index edb5a5e4a7..63f127b60c 100644 --- a/recursion/gnark-ffi/go/sp1/poseidon2/constants.go +++ b/recursion/gnark-ffi/go/sp1/poseidon2/constants.go @@ -7,11 +7,11 @@ import ( ) // Poseidon2 round constants for a state consisting of three BN254 field elements. -var RC3 [NUM_EXTERNAL_ROUNDS + NUM_INTERNAL_ROUNDS][WIDTH]frontend.Variable +var rc3 [numExternalRounds + numInternalRounds][width]frontend.Variable // Poseidon2 round constaints for a state consisting of 16 BabyBear field elements. -var RC16 [30][BABYBEAR_WIDTH]babybear.Variable +var rc16 [30][BABYBEAR_WIDTH]babybear.Variable func init() { init_rc3() @@ -21,448 +21,448 @@ func init() { func init_rc3() { round := 0 - RC3[round] = [WIDTH]frontend.Variable{ + rc3[round] = [width]frontend.Variable{ frontend.Variable("0x1d066a255517b7fd8bddd3a93f7804ef7f8fcde48bb4c37a59a09a1a97052816"), frontend.Variable("0x29daefb55f6f2dc6ac3f089cebcc6120b7c6fef31367b68eb7238547d32c1610"), frontend.Variable("0x1f2cb1624a78ee001ecbd88ad959d7012572d76f08ec5c4f9e8b7ad7b0b4e1d1"), } round += 1 - RC3[round] = [WIDTH]frontend.Variable{ + rc3[round] = [width]frontend.Variable{ frontend.Variable("0x0aad2e79f15735f2bd77c0ed3d14aa27b11f092a53bbc6e1db0672ded84f31e5"), frontend.Variable("0x2252624f8617738cd6f661dd4094375f37028a98f1dece66091ccf1595b43f28"), frontend.Variable("0x1a24913a928b38485a65a84a291da1ff91c20626524b2b87d49f4f2c9018d735"), } round += 1 - RC3[round] = [WIDTH]frontend.Variable{ + rc3[round] = [width]frontend.Variable{ frontend.Variable("0x22fc468f1759b74d7bfc427b5f11ebb10a41515ddff497b14fd6dae1508fc47a"), frontend.Variable("0x1059ca787f1f89ed9cd026e9c9ca107ae61956ff0b4121d5efd65515617f6e4d"), frontend.Variable("0x02be9473358461d8f61f3536d877de982123011f0bf6f155a45cbbfae8b981ce"), } round += 1 - RC3[round] = [WIDTH]frontend.Variable{ + rc3[round] = [width]frontend.Variable{ frontend.Variable("0x0ec96c8e32962d462778a749c82ed623aba9b669ac5b8736a1ff3a441a5084a4"), frontend.Variable("0x292f906e073677405442d9553c45fa3f5a47a7cdb8c99f9648fb2e4d814df57e"), frontend.Variable("0x274982444157b86726c11b9a0f5e39a5cc611160a394ea460c63f0b2ffe5657e"), } round += 1 - RC3[round] = [WIDTH]frontend.Variable{ + rc3[round] = [width]frontend.Variable{ frontend.Variable("0x1a1d063e54b1e764b63e1855bff015b8cedd192f47308731499573f23597d4b5"), frontend.Variable("0x0000000000000000000000000000000000000000000000000000000000000000"), frontend.Variable("0x0000000000000000000000000000000000000000000000000000000000000000"), } round += 1 - RC3[round] = [WIDTH]frontend.Variable{ + rc3[round] = [width]frontend.Variable{ frontend.Variable("0x26abc66f3fdf8e68839d10956259063708235dccc1aa3793b91b002c5b257c37"), frontend.Variable("0x0000000000000000000000000000000000000000000000000000000000000000"), frontend.Variable("0x0000000000000000000000000000000000000000000000000000000000000000"), } round += 1 - RC3[round] = [WIDTH]frontend.Variable{ + rc3[round] = [width]frontend.Variable{ frontend.Variable("0x0c7c64a9d887385381a578cfed5aed370754427aabca92a70b3c2b12ff4d7be8"), frontend.Variable("0x0000000000000000000000000000000000000000000000000000000000000000"), frontend.Variable("0x0000000000000000000000000000000000000000000000000000000000000000"), } round += 1 - RC3[round] = [WIDTH]frontend.Variable{ + rc3[round] = [width]frontend.Variable{ frontend.Variable("0x1cf5998769e9fab79e17f0b6d08b2d1eba2ebac30dc386b0edd383831354b495"), frontend.Variable("0x0000000000000000000000000000000000000000000000000000000000000000"), frontend.Variable("0x0000000000000000000000000000000000000000000000000000000000000000"), } round += 1 - RC3[round] = [WIDTH]frontend.Variable{ + rc3[round] = [width]frontend.Variable{ frontend.Variable("0x0f5e3a8566be31b7564ca60461e9e08b19828764a9669bc17aba0b97e66b0109"), frontend.Variable("0x0000000000000000000000000000000000000000000000000000000000000000"), frontend.Variable("0x0000000000000000000000000000000000000000000000000000000000000000"), } round += 1 - RC3[round] = [WIDTH]frontend.Variable{ + rc3[round] = [width]frontend.Variable{ frontend.Variable("0x18df6a9d19ea90d895e60e4db0794a01f359a53a180b7d4b42bf3d7a531c976e"), frontend.Variable("0x0000000000000000000000000000000000000000000000000000000000000000"), frontend.Variable("0x0000000000000000000000000000000000000000000000000000000000000000"), } round += 1 - RC3[round] = [WIDTH]frontend.Variable{ + rc3[round] = [width]frontend.Variable{ frontend.Variable("0x04f7bf2c5c0538ac6e4b782c3c6e601ad0ea1d3a3b9d25ef4e324055fa3123dc"), frontend.Variable("0x0000000000000000000000000000000000000000000000000000000000000000"), frontend.Variable("0x0000000000000000000000000000000000000000000000000000000000000000"), } round += 1 - RC3[round] = [WIDTH]frontend.Variable{ + rc3[round] = [width]frontend.Variable{ frontend.Variable("0x29c76ce22255206e3c40058523748531e770c0584aa2328ce55d54628b89ebe6"), frontend.Variable("0x0000000000000000000000000000000000000000000000000000000000000000"), frontend.Variable("0x0000000000000000000000000000000000000000000000000000000000000000"), } round += 1 - RC3[round] = [WIDTH]frontend.Variable{ + rc3[round] = [width]frontend.Variable{ frontend.Variable("0x198d425a45b78e85c053659ab4347f5d65b1b8e9c6108dbe00e0e945dbc5ff15"), frontend.Variable("0x0000000000000000000000000000000000000000000000000000000000000000"), frontend.Variable("0x0000000000000000000000000000000000000000000000000000000000000000"), } round += 1 - RC3[round] = [WIDTH]frontend.Variable{ + rc3[round] = [width]frontend.Variable{ frontend.Variable("0x25ee27ab6296cd5e6af3cc79c598a1daa7ff7f6878b3c49d49d3a9a90c3fdf74"), frontend.Variable("0x0000000000000000000000000000000000000000000000000000000000000000"), frontend.Variable("0x0000000000000000000000000000000000000000000000000000000000000000"), } round += 1 - RC3[round] = [WIDTH]frontend.Variable{ + rc3[round] = [width]frontend.Variable{ frontend.Variable("0x138ea8e0af41a1e024561001c0b6eb1505845d7d0c55b1b2c0f88687a96d1381"), frontend.Variable("0x0000000000000000000000000000000000000000000000000000000000000000"), frontend.Variable("0x0000000000000000000000000000000000000000000000000000000000000000"), } round += 1 - RC3[round] = [WIDTH]frontend.Variable{ + rc3[round] = [width]frontend.Variable{ frontend.Variable("0x306197fb3fab671ef6e7c2cba2eefd0e42851b5b9811f2ca4013370a01d95687"), frontend.Variable("0x0000000000000000000000000000000000000000000000000000000000000000"), frontend.Variable("0x0000000000000000000000000000000000000000000000000000000000000000"), } round += 1 - RC3[round] = [WIDTH]frontend.Variable{ + rc3[round] = [width]frontend.Variable{ frontend.Variable("0x1a0c7d52dc32a4432b66f0b4894d4f1a21db7565e5b4250486419eaf00e8f620"), frontend.Variable("0x0000000000000000000000000000000000000000000000000000000000000000"), frontend.Variable("0x0000000000000000000000000000000000000000000000000000000000000000"), } round += 1 - RC3[round] = [WIDTH]frontend.Variable{ + rc3[round] = [width]frontend.Variable{ frontend.Variable("0x2b46b418de80915f3ff86a8e5c8bdfccebfbe5f55163cd6caa52997da2c54a9f"), frontend.Variable("0x0000000000000000000000000000000000000000000000000000000000000000"), frontend.Variable("0x0000000000000000000000000000000000000000000000000000000000000000"), } round += 1 - RC3[round] = [WIDTH]frontend.Variable{ + rc3[round] = [width]frontend.Variable{ frontend.Variable("0x12d3e0dc0085873701f8b777b9673af9613a1af5db48e05bfb46e312b5829f64"), frontend.Variable("0x0000000000000000000000000000000000000000000000000000000000000000"), frontend.Variable("0x0000000000000000000000000000000000000000000000000000000000000000"), } round += 1 - RC3[round] = [WIDTH]frontend.Variable{ + rc3[round] = [width]frontend.Variable{ frontend.Variable("0x263390cf74dc3a8870f5002ed21d089ffb2bf768230f648dba338a5cb19b3a1f"), frontend.Variable("0x0000000000000000000000000000000000000000000000000000000000000000"), frontend.Variable("0x0000000000000000000000000000000000000000000000000000000000000000"), } round += 1 - RC3[round] = [WIDTH]frontend.Variable{ + rc3[round] = [width]frontend.Variable{ frontend.Variable("0x0a14f33a5fe668a60ac884b4ca607ad0f8abb5af40f96f1d7d543db52b003dcd"), frontend.Variable("0x0000000000000000000000000000000000000000000000000000000000000000"), frontend.Variable("0x0000000000000000000000000000000000000000000000000000000000000000"), } round += 1 - RC3[round] = [WIDTH]frontend.Variable{ + rc3[round] = [width]frontend.Variable{ frontend.Variable("0x28ead9c586513eab1a5e86509d68b2da27be3a4f01171a1dd847df829bc683b9"), frontend.Variable("0x0000000000000000000000000000000000000000000000000000000000000000"), frontend.Variable("0x0000000000000000000000000000000000000000000000000000000000000000"), } round += 1 - RC3[round] = [WIDTH]frontend.Variable{ + rc3[round] = [width]frontend.Variable{ frontend.Variable("0x1c6ab1c328c3c6430972031f1bdb2ac9888f0ea1abe71cffea16cda6e1a7416c"), frontend.Variable("0x0000000000000000000000000000000000000000000000000000000000000000"), frontend.Variable("0x0000000000000000000000000000000000000000000000000000000000000000"), } round += 1 - RC3[round] = [WIDTH]frontend.Variable{ + rc3[round] = [width]frontend.Variable{ frontend.Variable("0x1fc7e71bc0b819792b2500239f7f8de04f6decd608cb98a932346015c5b42c94"), frontend.Variable("0x0000000000000000000000000000000000000000000000000000000000000000"), frontend.Variable("0x0000000000000000000000000000000000000000000000000000000000000000"), } round += 1 - RC3[round] = [WIDTH]frontend.Variable{ + rc3[round] = [width]frontend.Variable{ frontend.Variable("0x03e107eb3a42b2ece380e0d860298f17c0c1e197c952650ee6dd85b93a0ddaa8"), frontend.Variable("0x0000000000000000000000000000000000000000000000000000000000000000"), frontend.Variable("0x0000000000000000000000000000000000000000000000000000000000000000"), } round += 1 - RC3[round] = [WIDTH]frontend.Variable{ + rc3[round] = [width]frontend.Variable{ frontend.Variable("0x2d354a251f381a4669c0d52bf88b772c46452ca57c08697f454505f6941d78cd"), frontend.Variable("0x0000000000000000000000000000000000000000000000000000000000000000"), frontend.Variable("0x0000000000000000000000000000000000000000000000000000000000000000"), } round += 1 - RC3[round] = [WIDTH]frontend.Variable{ + rc3[round] = [width]frontend.Variable{ frontend.Variable("0x094af88ab05d94baf687ef14bc566d1c522551d61606eda3d14b4606826f794b"), frontend.Variable("0x0000000000000000000000000000000000000000000000000000000000000000"), frontend.Variable("0x0000000000000000000000000000000000000000000000000000000000000000"), } round += 1 - RC3[round] = [WIDTH]frontend.Variable{ + rc3[round] = [width]frontend.Variable{ frontend.Variable("0x19705b783bf3d2dc19bcaeabf02f8ca5e1ab5b6f2e3195a9d52b2d249d1396f7"), frontend.Variable("0x0000000000000000000000000000000000000000000000000000000000000000"), frontend.Variable("0x0000000000000000000000000000000000000000000000000000000000000000"), } round += 1 - RC3[round] = [WIDTH]frontend.Variable{ + rc3[round] = [width]frontend.Variable{ frontend.Variable("0x09bf4acc3a8bce3f1fcc33fee54fc5b28723b16b7d740a3e60cef6852271200e"), frontend.Variable("0x0000000000000000000000000000000000000000000000000000000000000000"), frontend.Variable("0x0000000000000000000000000000000000000000000000000000000000000000"), } round += 1 - RC3[round] = [WIDTH]frontend.Variable{ + rc3[round] = [width]frontend.Variable{ frontend.Variable("0x1803f8200db6013c50f83c0c8fab62843413732f301f7058543a073f3f3b5e4e"), frontend.Variable("0x0000000000000000000000000000000000000000000000000000000000000000"), frontend.Variable("0x0000000000000000000000000000000000000000000000000000000000000000"), } round += 1 - RC3[round] = [WIDTH]frontend.Variable{ + rc3[round] = [width]frontend.Variable{ frontend.Variable("0x0f80afb5046244de30595b160b8d1f38bf6fb02d4454c0add41f7fef2faf3e5c"), frontend.Variable("0x0000000000000000000000000000000000000000000000000000000000000000"), frontend.Variable("0x0000000000000000000000000000000000000000000000000000000000000000"), } round += 1 - RC3[round] = [WIDTH]frontend.Variable{ + rc3[round] = [width]frontend.Variable{ frontend.Variable("0x126ee1f8504f15c3d77f0088c1cfc964abcfcf643f4a6fea7dc3f98219529d78"), frontend.Variable("0x0000000000000000000000000000000000000000000000000000000000000000"), frontend.Variable("0x0000000000000000000000000000000000000000000000000000000000000000"), } round += 1 - RC3[round] = [WIDTH]frontend.Variable{ + rc3[round] = [width]frontend.Variable{ frontend.Variable("0x23c203d10cfcc60f69bfb3d919552ca10ffb4ee63175ddf8ef86f991d7d0a591"), frontend.Variable("0x0000000000000000000000000000000000000000000000000000000000000000"), frontend.Variable("0x0000000000000000000000000000000000000000000000000000000000000000"), } round += 1 - RC3[round] = [WIDTH]frontend.Variable{ + rc3[round] = [width]frontend.Variable{ frontend.Variable("0x2a2ae15d8b143709ec0d09705fa3a6303dec1ee4eec2cf747c5a339f7744fb94"), frontend.Variable("0x0000000000000000000000000000000000000000000000000000000000000000"), frontend.Variable("0x0000000000000000000000000000000000000000000000000000000000000000"), } round += 1 - RC3[round] = [WIDTH]frontend.Variable{ + rc3[round] = [width]frontend.Variable{ frontend.Variable("0x07b60dee586ed6ef47e5c381ab6343ecc3d3b3006cb461bbb6b5d89081970b2b"), frontend.Variable("0x0000000000000000000000000000000000000000000000000000000000000000"), frontend.Variable("0x0000000000000000000000000000000000000000000000000000000000000000"), } round += 1 - RC3[round] = [WIDTH]frontend.Variable{ + rc3[round] = [width]frontend.Variable{ frontend.Variable("0x27316b559be3edfd885d95c494c1ae3d8a98a320baa7d152132cfe583c9311bd"), frontend.Variable("0x0000000000000000000000000000000000000000000000000000000000000000"), frontend.Variable("0x0000000000000000000000000000000000000000000000000000000000000000"), } round += 1 - RC3[round] = [WIDTH]frontend.Variable{ + rc3[round] = [width]frontend.Variable{ frontend.Variable("0x1d5c49ba157c32b8d8937cb2d3f84311ef834cc2a743ed662f5f9af0c0342e76"), frontend.Variable("0x0000000000000000000000000000000000000000000000000000000000000000"), frontend.Variable("0x0000000000000000000000000000000000000000000000000000000000000000"), } round += 1 - RC3[round] = [WIDTH]frontend.Variable{ + rc3[round] = [width]frontend.Variable{ frontend.Variable("0x2f8b124e78163b2f332774e0b850b5ec09c01bf6979938f67c24bd5940968488"), frontend.Variable("0x0000000000000000000000000000000000000000000000000000000000000000"), frontend.Variable("0x0000000000000000000000000000000000000000000000000000000000000000"), } round += 1 - RC3[round] = [WIDTH]frontend.Variable{ + rc3[round] = [width]frontend.Variable{ frontend.Variable("0x1e6843a5457416b6dc5b7aa09a9ce21b1d4cba6554e51d84665f75260113b3d5"), frontend.Variable("0x0000000000000000000000000000000000000000000000000000000000000000"), frontend.Variable("0x0000000000000000000000000000000000000000000000000000000000000000"), } round += 1 - RC3[round] = [WIDTH]frontend.Variable{ + rc3[round] = [width]frontend.Variable{ frontend.Variable("0x11cdf00a35f650c55fca25c9929c8ad9a68daf9ac6a189ab1f5bc79f21641d4b"), frontend.Variable("0x0000000000000000000000000000000000000000000000000000000000000000"), frontend.Variable("0x0000000000000000000000000000000000000000000000000000000000000000"), } round += 1 - RC3[round] = [WIDTH]frontend.Variable{ + rc3[round] = [width]frontend.Variable{ frontend.Variable("0x21632de3d3bbc5e42ef36e588158d6d4608b2815c77355b7e82b5b9b7eb560bc"), frontend.Variable("0x0000000000000000000000000000000000000000000000000000000000000000"), frontend.Variable("0x0000000000000000000000000000000000000000000000000000000000000000"), } round += 1 - RC3[round] = [WIDTH]frontend.Variable{ + rc3[round] = [width]frontend.Variable{ frontend.Variable("0x0de625758452efbd97b27025fbd245e0255ae48ef2a329e449d7b5c51c18498a"), frontend.Variable("0x0000000000000000000000000000000000000000000000000000000000000000"), frontend.Variable("0x0000000000000000000000000000000000000000000000000000000000000000"), } round += 1 - RC3[round] = [WIDTH]frontend.Variable{ + rc3[round] = [width]frontend.Variable{ frontend.Variable("0x2ad253c053e75213e2febfd4d976cc01dd9e1e1c6f0fb6b09b09546ba0838098"), frontend.Variable("0x0000000000000000000000000000000000000000000000000000000000000000"), frontend.Variable("0x0000000000000000000000000000000000000000000000000000000000000000"), } round += 1 - RC3[round] = [WIDTH]frontend.Variable{ + rc3[round] = [width]frontend.Variable{ frontend.Variable("0x1d6b169ed63872dc6ec7681ec39b3be93dd49cdd13c813b7d35702e38d60b077"), frontend.Variable("0x0000000000000000000000000000000000000000000000000000000000000000"), frontend.Variable("0x0000000000000000000000000000000000000000000000000000000000000000"), } round += 1 - RC3[round] = [WIDTH]frontend.Variable{ + rc3[round] = [width]frontend.Variable{ frontend.Variable("0x1660b740a143664bb9127c4941b67fed0be3ea70a24d5568c3a54e706cfef7fe"), frontend.Variable("0x0000000000000000000000000000000000000000000000000000000000000000"), frontend.Variable("0x0000000000000000000000000000000000000000000000000000000000000000"), } round += 1 - RC3[round] = [WIDTH]frontend.Variable{ + rc3[round] = [width]frontend.Variable{ frontend.Variable("0x0065a92d1de81f34114f4ca2deef76e0ceacdddb12cf879096a29f10376ccbfe"), frontend.Variable("0x0000000000000000000000000000000000000000000000000000000000000000"), frontend.Variable("0x0000000000000000000000000000000000000000000000000000000000000000"), } round += 1 - RC3[round] = [WIDTH]frontend.Variable{ + rc3[round] = [width]frontend.Variable{ frontend.Variable("0x1f11f065202535987367f823da7d672c353ebe2ccbc4869bcf30d50a5871040d"), frontend.Variable("0x0000000000000000000000000000000000000000000000000000000000000000"), frontend.Variable("0x0000000000000000000000000000000000000000000000000000000000000000"), } round += 1 - RC3[round] = [WIDTH]frontend.Variable{ + rc3[round] = [width]frontend.Variable{ frontend.Variable("0x26596f5c5dd5a5d1b437ce7b14a2c3dd3bd1d1a39b6759ba110852d17df0693e"), frontend.Variable("0x0000000000000000000000000000000000000000000000000000000000000000"), frontend.Variable("0x0000000000000000000000000000000000000000000000000000000000000000"), } round += 1 - RC3[round] = [WIDTH]frontend.Variable{ + rc3[round] = [width]frontend.Variable{ frontend.Variable("0x16f49bc727e45a2f7bf3056efcf8b6d38539c4163a5f1e706743db15af91860f"), frontend.Variable("0x0000000000000000000000000000000000000000000000000000000000000000"), frontend.Variable("0x0000000000000000000000000000000000000000000000000000000000000000"), } round += 1 - RC3[round] = [WIDTH]frontend.Variable{ + rc3[round] = [width]frontend.Variable{ frontend.Variable("0x1abe1deb45b3e3119954175efb331bf4568feaf7ea8b3dc5e1a4e7438dd39e5f"), frontend.Variable("0x0000000000000000000000000000000000000000000000000000000000000000"), frontend.Variable("0x0000000000000000000000000000000000000000000000000000000000000000"), } round += 1 - RC3[round] = [WIDTH]frontend.Variable{ + rc3[round] = [width]frontend.Variable{ frontend.Variable("0x0e426ccab66984d1d8993a74ca548b779f5db92aaec5f102020d34aea15fba59"), frontend.Variable("0x0000000000000000000000000000000000000000000000000000000000000000"), frontend.Variable("0x0000000000000000000000000000000000000000000000000000000000000000"), } round += 1 - RC3[round] = [WIDTH]frontend.Variable{ + rc3[round] = [width]frontend.Variable{ frontend.Variable("0x0e7c30c2e2e8957f4933bd1942053f1f0071684b902d534fa841924303f6a6c6"), frontend.Variable("0x0000000000000000000000000000000000000000000000000000000000000000"), frontend.Variable("0x0000000000000000000000000000000000000000000000000000000000000000"), } round += 1 - RC3[round] = [WIDTH]frontend.Variable{ + rc3[round] = [width]frontend.Variable{ frontend.Variable("0x0812a017ca92cf0a1622708fc7edff1d6166ded6e3528ead4c76e1f31d3fc69d"), frontend.Variable("0x0000000000000000000000000000000000000000000000000000000000000000"), frontend.Variable("0x0000000000000000000000000000000000000000000000000000000000000000"), } round += 1 - RC3[round] = [WIDTH]frontend.Variable{ + rc3[round] = [width]frontend.Variable{ frontend.Variable("0x21a5ade3df2bc1b5bba949d1db96040068afe5026edd7a9c2e276b47cf010d54"), frontend.Variable("0x0000000000000000000000000000000000000000000000000000000000000000"), frontend.Variable("0x0000000000000000000000000000000000000000000000000000000000000000"), } round += 1 - RC3[round] = [WIDTH]frontend.Variable{ + rc3[round] = [width]frontend.Variable{ frontend.Variable("0x01f3035463816c84ad711bf1a058c6c6bd101945f50e5afe72b1a5233f8749ce"), frontend.Variable("0x0000000000000000000000000000000000000000000000000000000000000000"), frontend.Variable("0x0000000000000000000000000000000000000000000000000000000000000000"), } round += 1 - RC3[round] = [WIDTH]frontend.Variable{ + rc3[round] = [width]frontend.Variable{ frontend.Variable("0x0b115572f038c0e2028c2aafc2d06a5e8bf2f9398dbd0fdf4dcaa82b0f0c1c8b"), frontend.Variable("0x0000000000000000000000000000000000000000000000000000000000000000"), frontend.Variable("0x0000000000000000000000000000000000000000000000000000000000000000"), } round += 1 - RC3[round] = [WIDTH]frontend.Variable{ + rc3[round] = [width]frontend.Variable{ frontend.Variable("0x1c38ec0b99b62fd4f0ef255543f50d2e27fc24db42bc910a3460613b6ef59e2f"), frontend.Variable("0x0000000000000000000000000000000000000000000000000000000000000000"), frontend.Variable("0x0000000000000000000000000000000000000000000000000000000000000000"), } round += 1 - RC3[round] = [WIDTH]frontend.Variable{ + rc3[round] = [width]frontend.Variable{ frontend.Variable("0x1c89c6d9666272e8425c3ff1f4ac737b2f5d314606a297d4b1d0b254d880c53e"), frontend.Variable("0x0000000000000000000000000000000000000000000000000000000000000000"), frontend.Variable("0x0000000000000000000000000000000000000000000000000000000000000000"), } round += 1 - RC3[round] = [WIDTH]frontend.Variable{ + rc3[round] = [width]frontend.Variable{ frontend.Variable("0x03326e643580356bf6d44008ae4c042a21ad4880097a5eb38b71e2311bb88f8f"), frontend.Variable("0x0000000000000000000000000000000000000000000000000000000000000000"), frontend.Variable("0x0000000000000000000000000000000000000000000000000000000000000000"), } round += 1 - RC3[round] = [WIDTH]frontend.Variable{ + rc3[round] = [width]frontend.Variable{ frontend.Variable("0x268076b0054fb73f67cee9ea0e51e3ad50f27a6434b5dceb5bdde2299910a4c9"), frontend.Variable("0x0000000000000000000000000000000000000000000000000000000000000000"), frontend.Variable("0x0000000000000000000000000000000000000000000000000000000000000000"), } round += 1 - RC3[round] = [WIDTH]frontend.Variable{ + rc3[round] = [width]frontend.Variable{ frontend.Variable("0x1acd63c67fbc9ab1626ed93491bda32e5da18ea9d8e4f10178d04aa6f8747ad0"), frontend.Variable("0x19f8a5d670e8ab66c4e3144be58ef6901bf93375e2323ec3ca8c86cd2a28b5a5"), frontend.Variable("0x1c0dc443519ad7a86efa40d2df10a011068193ea51f6c92ae1cfbb5f7b9b6893"), } round += 1 - RC3[round] = [WIDTH]frontend.Variable{ + rc3[round] = [width]frontend.Variable{ frontend.Variable("0x14b39e7aa4068dbe50fe7190e421dc19fbeab33cb4f6a2c4180e4c3224987d3d"), frontend.Variable("0x1d449b71bd826ec58f28c63ea6c561b7b820fc519f01f021afb1e35e28b0795e"), frontend.Variable("0x1ea2c9a89baaddbb60fa97fe60fe9d8e89de141689d1252276524dc0a9e987fc"), } round += 1 - RC3[round] = [WIDTH]frontend.Variable{ + rc3[round] = [width]frontend.Variable{ frontend.Variable("0x0478d66d43535a8cb57e9c1c3d6a2bd7591f9a46a0e9c058134d5cefdb3c7ff1"), frontend.Variable("0x19272db71eece6a6f608f3b2717f9cd2662e26ad86c400b21cde5e4a7b00bebe"), frontend.Variable("0x14226537335cab33c749c746f09208abb2dd1bd66a87ef75039be846af134166"), } round += 1 - RC3[round] = [WIDTH]frontend.Variable{ + rc3[round] = [width]frontend.Variable{ frontend.Variable("0x01fd6af15956294f9dfe38c0d976a088b21c21e4a1c2e823f912f44961f9a9ce"), frontend.Variable("0x18e5abedd626ec307bca190b8b2cab1aaee2e62ed229ba5a5ad8518d4e5f2a57"), frontend.Variable("0x0fc1bbceba0590f5abbdffa6d3b35e3297c021a3a409926d0e2d54dc1c84fda6"), @@ -472,7 +472,7 @@ func init_rc3() { func init_rc16() { round := 0 - RC16[round] = [BABYBEAR_WIDTH]babybear.Variable{ + rc16[round] = [BABYBEAR_WIDTH]babybear.Variable{ babybear.NewF("2110014213"), babybear.NewF("3964964605"), babybear.NewF("2190662774"), @@ -492,7 +492,7 @@ func init_rc16() { } round += 1 - RC16[round] = [BABYBEAR_WIDTH]babybear.Variable{ + rc16[round] = [BABYBEAR_WIDTH]babybear.Variable{ babybear.NewF("3706859504"), babybear.NewF("759122502"), babybear.NewF("3167665446"), @@ -512,7 +512,7 @@ func init_rc16() { } round += 1 - RC16[round] = [BABYBEAR_WIDTH]babybear.Variable{ + rc16[round] = [BABYBEAR_WIDTH]babybear.Variable{ babybear.NewF("4289086263"), babybear.NewF("1563933798"), babybear.NewF("1440025885"), @@ -532,7 +532,7 @@ func init_rc16() { } round += 1 - RC16[round] = [BABYBEAR_WIDTH]babybear.Variable{ + rc16[round] = [BABYBEAR_WIDTH]babybear.Variable{ babybear.NewF("2641856484"), babybear.NewF("3035743342"), babybear.NewF("3672796326"), @@ -551,7 +551,7 @@ func init_rc16() { babybear.NewF("2572204153"), } round += 1 - RC16[round] = [BABYBEAR_WIDTH]babybear.Variable{ + rc16[round] = [BABYBEAR_WIDTH]babybear.Variable{ babybear.NewF("1196780786"), babybear.NewF("3447394443"), babybear.NewF("747167305"), @@ -570,7 +570,7 @@ func init_rc16() { babybear.NewF("2520191583"), } round += 1 - RC16[round] = [BABYBEAR_WIDTH]babybear.Variable{ + rc16[round] = [BABYBEAR_WIDTH]babybear.Variable{ babybear.NewF("36046858"), babybear.NewF("2927525953"), babybear.NewF("3912129105"), @@ -589,7 +589,7 @@ func init_rc16() { babybear.NewF("4071195740"), } round += 1 - RC16[round] = [BABYBEAR_WIDTH]babybear.Variable{ + rc16[round] = [BABYBEAR_WIDTH]babybear.Variable{ babybear.NewF("3505307391"), babybear.NewF("786445290"), babybear.NewF("3815313971"), @@ -608,7 +608,7 @@ func init_rc16() { babybear.NewF("3843128331"), } round += 1 - RC16[round] = [BABYBEAR_WIDTH]babybear.Variable{ + rc16[round] = [BABYBEAR_WIDTH]babybear.Variable{ babybear.NewF("3878220780"), babybear.NewF("4058162439"), babybear.NewF("1478942487"), @@ -627,7 +627,7 @@ func init_rc16() { babybear.NewF("3852983224"), } round += 1 - RC16[round] = [BABYBEAR_WIDTH]babybear.Variable{ + rc16[round] = [BABYBEAR_WIDTH]babybear.Variable{ babybear.NewF("2896943075"), babybear.NewF("3087590927"), babybear.NewF("992175959"), @@ -646,7 +646,7 @@ func init_rc16() { babybear.NewF("3056104448"), } round += 1 - RC16[round] = [BABYBEAR_WIDTH]babybear.Variable{ + rc16[round] = [BABYBEAR_WIDTH]babybear.Variable{ babybear.NewF("3779109343"), babybear.NewF("536205958"), babybear.NewF("4183458361"), @@ -665,7 +665,7 @@ func init_rc16() { babybear.NewF("1431907253"), } round += 1 - RC16[round] = [BABYBEAR_WIDTH]babybear.Variable{ + rc16[round] = [BABYBEAR_WIDTH]babybear.Variable{ babybear.NewF("1418914503"), babybear.NewF("1365856753"), babybear.NewF("3942715745"), @@ -684,7 +684,7 @@ func init_rc16() { babybear.NewF("1152335780"), } round += 1 - RC16[round] = [BABYBEAR_WIDTH]babybear.Variable{ + rc16[round] = [BABYBEAR_WIDTH]babybear.Variable{ babybear.NewF("3417648695"), babybear.NewF("186040114"), babybear.NewF("3475580573"), @@ -703,7 +703,7 @@ func init_rc16() { babybear.NewF("3829603876"), } round += 1 - RC16[round] = [BABYBEAR_WIDTH]babybear.Variable{ + rc16[round] = [BABYBEAR_WIDTH]babybear.Variable{ babybear.NewF("859661334"), babybear.NewF("3898844357"), babybear.NewF("180258337"), @@ -722,7 +722,7 @@ func init_rc16() { babybear.NewF("2127120275"), } round += 1 - RC16[round] = [BABYBEAR_WIDTH]babybear.Variable{ + rc16[round] = [BABYBEAR_WIDTH]babybear.Variable{ babybear.NewF("1548195514"), babybear.NewF("2378056027"), babybear.NewF("390914568"), @@ -741,7 +741,7 @@ func init_rc16() { babybear.NewF("4101901741"), } round += 1 - RC16[round] = [BABYBEAR_WIDTH]babybear.Variable{ + rc16[round] = [BABYBEAR_WIDTH]babybear.Variable{ babybear.NewF("104929687"), babybear.NewF("1459980974"), babybear.NewF("1831234737"), @@ -760,7 +760,7 @@ func init_rc16() { babybear.NewF("2543469905"), } round += 1 - RC16[round] = [BABYBEAR_WIDTH]babybear.Variable{ + rc16[round] = [BABYBEAR_WIDTH]babybear.Variable{ babybear.NewF("2191909784"), babybear.NewF("3315138460"), babybear.NewF("530414574"), @@ -779,7 +779,7 @@ func init_rc16() { babybear.NewF("924016661"), } round += 1 - RC16[round] = [BABYBEAR_WIDTH]babybear.Variable{ + rc16[round] = [BABYBEAR_WIDTH]babybear.Variable{ babybear.NewF("3633138367"), babybear.NewF("3222789372"), babybear.NewF("809116305"), @@ -798,7 +798,7 @@ func init_rc16() { babybear.NewF("339124269"), } round += 1 - RC16[round] = [BABYBEAR_WIDTH]babybear.Variable{ + rc16[round] = [BABYBEAR_WIDTH]babybear.Variable{ babybear.NewF("130182653"), babybear.NewF("2755946749"), babybear.NewF("542600513"), @@ -817,7 +817,7 @@ func init_rc16() { babybear.NewF("974546524"), } round += 1 - RC16[round] = [BABYBEAR_WIDTH]babybear.Variable{ + rc16[round] = [BABYBEAR_WIDTH]babybear.Variable{ babybear.NewF("3306659113"), babybear.NewF("2234814261"), babybear.NewF("1188782305"), @@ -836,7 +836,7 @@ func init_rc16() { babybear.NewF("4217723909"), } round += 1 - RC16[round] = [BABYBEAR_WIDTH]babybear.Variable{ + rc16[round] = [BABYBEAR_WIDTH]babybear.Variable{ babybear.NewF("1564209905"), babybear.NewF("2154197895"), babybear.NewF("2459687029"), @@ -855,7 +855,7 @@ func init_rc16() { babybear.NewF("4039775921"), } round += 1 - RC16[round] = [BABYBEAR_WIDTH]babybear.Variable{ + rc16[round] = [BABYBEAR_WIDTH]babybear.Variable{ babybear.NewF("1165280628"), babybear.NewF("1203983801"), babybear.NewF("3814740033"), @@ -874,7 +874,7 @@ func init_rc16() { babybear.NewF("1775891321"), } round += 1 - RC16[round] = [BABYBEAR_WIDTH]babybear.Variable{ + rc16[round] = [BABYBEAR_WIDTH]babybear.Variable{ babybear.NewF("1170945922"), babybear.NewF("1105391877"), babybear.NewF("261536467"), @@ -893,7 +893,7 @@ func init_rc16() { babybear.NewF("1643809916"), } round += 1 - RC16[round] = [BABYBEAR_WIDTH]babybear.Variable{ + rc16[round] = [BABYBEAR_WIDTH]babybear.Variable{ babybear.NewF("2922875898"), babybear.NewF("3740690643"), babybear.NewF("3932461140"), @@ -912,7 +912,7 @@ func init_rc16() { babybear.NewF("111611860"), } round += 1 - RC16[round] = [BABYBEAR_WIDTH]babybear.Variable{ + rc16[round] = [BABYBEAR_WIDTH]babybear.Variable{ babybear.NewF("2066954820"), babybear.NewF("2502099969"), babybear.NewF("2915053115"), @@ -931,7 +931,7 @@ func init_rc16() { babybear.NewF("1060867760"), } round += 1 - RC16[round] = [BABYBEAR_WIDTH]babybear.Variable{ + rc16[round] = [BABYBEAR_WIDTH]babybear.Variable{ babybear.NewF("2359801781"), babybear.NewF("2800231467"), babybear.NewF("3010357035"), @@ -950,7 +950,7 @@ func init_rc16() { babybear.NewF("2590164234"), } round += 1 - RC16[round] = [BABYBEAR_WIDTH]babybear.Variable{ + rc16[round] = [BABYBEAR_WIDTH]babybear.Variable{ babybear.NewF("1688530738"), babybear.NewF("1580733335"), babybear.NewF("2443981517"), @@ -969,7 +969,7 @@ func init_rc16() { babybear.NewF("3935186184"), } round += 1 - RC16[round] = [BABYBEAR_WIDTH]babybear.Variable{ + rc16[round] = [BABYBEAR_WIDTH]babybear.Variable{ babybear.NewF("820046587"), babybear.NewF("1393386250"), babybear.NewF("2665818575"), @@ -988,7 +988,7 @@ func init_rc16() { babybear.NewF("2579960095"), } round += 1 - RC16[round] = [BABYBEAR_WIDTH]babybear.Variable{ + rc16[round] = [BABYBEAR_WIDTH]babybear.Variable{ babybear.NewF("3544930873"), babybear.NewF("225847443"), babybear.NewF("3070082278"), @@ -1007,7 +1007,7 @@ func init_rc16() { babybear.NewF("2214923584"), } round += 1 - RC16[round] = [BABYBEAR_WIDTH]babybear.Variable{ + rc16[round] = [BABYBEAR_WIDTH]babybear.Variable{ babybear.NewF("3118792481"), babybear.NewF("2241076515"), babybear.NewF("3983669831"), @@ -1026,7 +1026,7 @@ func init_rc16() { babybear.NewF("3769609014"), } round += 1 - RC16[round] = [BABYBEAR_WIDTH]babybear.Variable{ + rc16[round] = [BABYBEAR_WIDTH]babybear.Variable{ babybear.NewF("2195455495"), babybear.NewF("2596863283"), babybear.NewF("4244994973"), diff --git a/recursion/gnark-ffi/go/sp1/poseidon2/poseidon2.go b/recursion/gnark-ffi/go/sp1/poseidon2/poseidon2.go index 5186b1e230..b737d8368d 100644 --- a/recursion/gnark-ffi/go/sp1/poseidon2/poseidon2.go +++ b/recursion/gnark-ffi/go/sp1/poseidon2/poseidon2.go @@ -4,67 +4,66 @@ import ( "github.com/consensys/gnark/frontend" ) -const WIDTH = 3 -const NUM_EXTERNAL_ROUNDS = 8 -const NUM_INTERNAL_ROUNDS = 56 -const DEGREE = 5 +const width = 3 +const numExternalRounds = 8 +const numInternalRounds = 56 +const degree = 5 type Poseidon2Chip struct { api frontend.API - internal_linear_layer [WIDTH]frontend.Variable - zero, one frontend.Variable + internal_linear_layer [width]frontend.Variable + zero frontend.Variable } func NewChip(api frontend.API) *Poseidon2Chip { return &Poseidon2Chip{ api: api, - internal_linear_layer: [WIDTH]frontend.Variable{ + internal_linear_layer: [width]frontend.Variable{ frontend.Variable(1), frontend.Variable(1), frontend.Variable(2), }, zero: frontend.Variable(0), - one: frontend.Variable(1), } } -func (p *Poseidon2Chip) PermuteMut(state *[WIDTH]frontend.Variable) { +func (p *Poseidon2Chip) PermuteMut(state *[width]frontend.Variable) { // The initial linear layer. - p.MatrixPermuteMut(state) + p.matrixPermuteMut(state) // The first half of the external rounds. - rounds := NUM_EXTERNAL_ROUNDS + NUM_INTERNAL_ROUNDS - rounds_f_beginning := NUM_EXTERNAL_ROUNDS / 2 + rounds := numExternalRounds + numInternalRounds + rounds_f_beginning := numExternalRounds / 2 for r := 0; r < rounds_f_beginning; r++ { - p.AddRc(state, RC3[r]) - p.Sbox(state) - p.MatrixPermuteMut(state) + p.addRc(state, rc3[r]) + p.sbox(state) + p.matrixPermuteMut(state) } // The internal rounds. - p_end := rounds_f_beginning + NUM_INTERNAL_ROUNDS + p_end := rounds_f_beginning + numInternalRounds for r := rounds_f_beginning; r < p_end; r++ { - state[0] = p.api.Add(state[0], RC3[r][0]) - state[0] = p.SboxP(state[0]) - p.DiffusionPermuteMut(state) + state[0] = p.api.Add(state[0], rc3[r][0]) + state[0] = p.sboxP(state[0]) + p.diffusionPermuteMut(state) } // The second half of the external rounds. for r := p_end; r < rounds; r++ { - p.AddRc(state, RC3[r]) - p.Sbox(state) - p.MatrixPermuteMut(state) + p.addRc(state, rc3[r]) + p.sbox(state) + p.matrixPermuteMut(state) } } -func (p *Poseidon2Chip) AddRc(state *[WIDTH]frontend.Variable, rc [WIDTH]frontend.Variable) { - for i := 0; i < WIDTH; i++ { +func (p *Poseidon2Chip) addRc(state *[width]frontend.Variable, rc [width]frontend.Variable) { + for i := 0; i < width; i++ { state[i] = p.api.Add(state[i], rc[i]) } } -func (p *Poseidon2Chip) SboxP(input frontend.Variable) frontend.Variable { - if DEGREE != 5 { +func (p *Poseidon2Chip) sboxP(input frontend.Variable) frontend.Variable { + if degree != 5 { panic("DEGREE is assumed to be 5") } squared := p.api.Mul(input, input) @@ -72,8 +71,8 @@ func (p *Poseidon2Chip) SboxP(input frontend.Variable) frontend.Variable { return p.api.Mul(input_4, input) } -func (p *Poseidon2Chip) Sbox(state *[WIDTH]frontend.Variable) { - for i := 0; i < WIDTH; i++ { - state[i] = p.SboxP(state[i]) +func (p *Poseidon2Chip) sbox(state *[width]frontend.Variable) { + for i := 0; i < width; i++ { + state[i] = p.sboxP(state[i]) } } diff --git a/recursion/gnark-ffi/go/sp1/poseidon2/poseidon2_babybear.go b/recursion/gnark-ffi/go/sp1/poseidon2/poseidon2_babybear.go index 9f83956234..a16cc609fe 100644 --- a/recursion/gnark-ffi/go/sp1/poseidon2/poseidon2_babybear.go +++ b/recursion/gnark-ffi/go/sp1/poseidon2/poseidon2_babybear.go @@ -6,9 +6,8 @@ import ( ) const BABYBEAR_WIDTH = 16 -const BABYBEAR_NUM_EXTERNAL_ROUNDS = 8 -const BABYBEAR_NUM_INTERNAL_ROUNDS = 13 -const BABYBEAR_DEGREE = 7 +const babybearNumExternalRounds = 8 +const babybearNumInternalRounds = 13 type Poseidon2BabyBearChip struct { api frontend.API @@ -27,25 +26,25 @@ func (p *Poseidon2BabyBearChip) PermuteMut(state *[BABYBEAR_WIDTH]babybear.Varia p.externalLinearLayer(state) // The first half of the external rounds. - rounds := BABYBEAR_NUM_EXTERNAL_ROUNDS + BABYBEAR_NUM_INTERNAL_ROUNDS - roundsFBeggining := BABYBEAR_NUM_EXTERNAL_ROUNDS / 2 + rounds := babybearNumExternalRounds + babybearNumInternalRounds + roundsFBeggining := babybearNumExternalRounds / 2 for r := 0; r < roundsFBeggining; r++ { - p.addRc(state, RC16[r]) + p.addRc(state, rc16[r]) p.sbox(state) p.externalLinearLayer(state) } // The internal rounds. - p_end := roundsFBeggining + BABYBEAR_NUM_INTERNAL_ROUNDS + p_end := roundsFBeggining + babybearNumInternalRounds for r := roundsFBeggining; r < p_end; r++ { - state[0] = p.fieldApi.AddF(state[0], RC16[r][0]) + state[0] = p.fieldApi.AddF(state[0], rc16[r][0]) state[0] = p.sboxP(state[0]) p.diffusionPermuteMut(state) } // The second half of the external rounds. for r := p_end; r < rounds; r++ { - p.addRc(state, RC16[r]) + p.addRc(state, rc16[r]) p.sbox(state) p.externalLinearLayer(state) } diff --git a/recursion/gnark-ffi/go/sp1/poseidon2/poseidon2_test.go b/recursion/gnark-ffi/go/sp1/poseidon2/poseidon2_test.go index d7bf417f70..178c9447b1 100644 --- a/recursion/gnark-ffi/go/sp1/poseidon2/poseidon2_test.go +++ b/recursion/gnark-ffi/go/sp1/poseidon2/poseidon2_test.go @@ -10,20 +10,20 @@ import ( ) type TestPoseidon2Circuit struct { - Input, ExpectedOutput [WIDTH]frontend.Variable `gnark:",public"` + Input, ExpectedOutput [width]frontend.Variable `gnark:",public"` } func (circuit *TestPoseidon2Circuit) Define(api frontend.API) error { poseidon2Chip := NewChip(api) - input := [WIDTH]frontend.Variable{} - for i := 0; i < WIDTH; i++ { + input := [width]frontend.Variable{} + for i := 0; i < width; i++ { input[i] = circuit.Input[i] } poseidon2Chip.PermuteMut(&input) - for i := 0; i < WIDTH; i++ { + for i := 0; i < width; i++ { api.AssertIsEqual(circuit.ExpectedOutput[i], input[i]) } @@ -34,13 +34,13 @@ func TestPoseidon2(t *testing.T) { assert := test.NewAssert(t) var circuit, witness TestPoseidon2Circuit - input := [WIDTH]frontend.Variable{ + input := [width]frontend.Variable{ frontend.Variable(0), frontend.Variable(0), frontend.Variable(0), } - expected_output := [WIDTH]frontend.Variable{ + expected_output := [width]frontend.Variable{ frontend.Variable("0x2ED1DA00B14D635BD35B88AB49390D5C13C90DA7E9E3A5F1EA69CD87A0AA3E82"), frontend.Variable("0x1E21E979CC3FD844B88C2016FD18F4DB07A698AA27DECA67CA509F5B0A4480D0"), frontend.Variable("0x2C40D0115DA2C9B55553B231BE55295F411E628ED0CD0E187917066515F0A060"), diff --git a/recursion/gnark-ffi/go/sp1/poseidon2/utils.go b/recursion/gnark-ffi/go/sp1/poseidon2/utils.go index d6cfbbb132..d282ddc347 100644 --- a/recursion/gnark-ffi/go/sp1/poseidon2/utils.go +++ b/recursion/gnark-ffi/go/sp1/poseidon2/utils.go @@ -4,19 +4,19 @@ import ( "github.com/consensys/gnark/frontend" ) -func (p *Poseidon2Chip) DiffusionPermuteMut(state *[WIDTH]frontend.Variable) { +func (p *Poseidon2Chip) diffusionPermuteMut(state *[width]frontend.Variable) { sum := p.zero - for i := 0; i < WIDTH; i++ { + for i := 0; i < width; i++ { sum = p.api.Add(sum, state[i]) } - for i := 0; i < WIDTH; i++ { + for i := 0; i < width; i++ { state[i] = p.api.Mul(state[i], p.internal_linear_layer[i]) state[i] = p.api.Add(state[i], sum) } } -func (p *Poseidon2Chip) MatrixPermuteMut(state *[WIDTH]frontend.Variable) { +func (p *Poseidon2Chip) matrixPermuteMut(state *[width]frontend.Variable) { sum := p.api.Add(state[0], state[1]) sum = p.api.Add(sum, state[2]) state[0] = p.api.Add(state[0], sum) diff --git a/recursion/gnark-ffi/go/sp1/prove.go b/recursion/gnark-ffi/go/sp1/prove.go index 4a71492390..7260f99ff7 100644 --- a/recursion/gnark-ffi/go/sp1/prove.go +++ b/recursion/gnark-ffi/go/sp1/prove.go @@ -15,32 +15,35 @@ func Prove(dataDir string, witnessPath string) Proof { if dataDir == "" { panic("dataDirStr is required") } - os.Setenv("CONSTRAINTS_JSON", dataDir+"/"+CONSTRAINTS_JSON_FILE) + os.Setenv("CONSTRAINTS_JSON", dataDir+"/"+constraintsJsonFile) // Read the R1CS. - scsFile, err := os.Open(dataDir + "/" + CIRCUIT_PATH) + scsFile, err := os.Open(dataDir + "/" + circuitPath) if err != nil { panic(err) } scs := plonk.NewCS(ecc.BN254) scs.ReadFrom(scsFile) + defer scsFile.Close() // Read the proving key. - pkFile, err := os.Open(dataDir + "/" + PK_PATH) + pkFile, err := os.Open(dataDir + "/" + pkPath) if err != nil { panic(err) } pk := plonk.NewProvingKey(ecc.BN254) bufReader := bufio.NewReaderSize(pkFile, 1024*1024) pk.UnsafeReadFrom(bufReader) + defer pkFile.Close() // Read the verifier key. - vkFile, err := os.Open(dataDir + "/" + VK_PATH) + vkFile, err := os.Open(dataDir + "/" + vkPath) if err != nil { panic(err) } vk := plonk.NewVerifyingKey(ecc.BN254) vk.ReadFrom(vkFile) + defer vkFile.Close() // Read the file. data, err := os.ReadFile(witnessPath) diff --git a/recursion/gnark-ffi/go/sp1/sp1.go b/recursion/gnark-ffi/go/sp1/sp1.go index ccde520953..a7fe4b651c 100644 --- a/recursion/gnark-ffi/go/sp1/sp1.go +++ b/recursion/gnark-ffi/go/sp1/sp1.go @@ -11,14 +11,13 @@ import ( "github.com/succinctlabs/sp1-recursion-gnark/sp1/poseidon2" ) -var SRS_FILE string = "srs.bin" -var SRS_LAGRANGE_FILE string = "srs_lagrange.bin" -var CONSTRAINTS_JSON_FILE string = "constraints.json" -var WITNESS_JSON_FILE string = "witness.json" -var VERIFIER_CONTRACT_PATH string = "PlonkVerifier.sol" -var CIRCUIT_PATH string = "circuit.bin" -var VK_PATH string = "vk.bin" -var PK_PATH string = "pk.bin" +var srsFile string = "srs.bin" +var srsLagrangeFile string = "srs_lagrange.bin" +var constraintsJsonFile string = "constraints.json" +var verifierContractPath string = "PlonkVerifier.sol" +var circuitPath string = "circuit.bin" +var vkPath string = "vk.bin" +var pkPath string = "pk.bin" type Circuit struct { VkeyHash frontend.Variable `gnark:",public"` diff --git a/recursion/gnark-ffi/go/sp1/verify.go b/recursion/gnark-ffi/go/sp1/verify.go index 0d7b5f21ad..27c459c991 100644 --- a/recursion/gnark-ffi/go/sp1/verify.go +++ b/recursion/gnark-ffi/go/sp1/verify.go @@ -28,7 +28,7 @@ func Verify(verifyCmdDataDir string, verifyCmdProof string, verifyCmdVkeyHash st } // Read the verifier key. - vkFile, err := os.Open(verifyCmdDataDir + "/" + VK_PATH) + vkFile, err := os.Open(verifyCmdDataDir + "/" + vkPath) if err != nil { panic(err) } diff --git a/recursion/gnark-ffi/src/plonk_bn254.rs b/recursion/gnark-ffi/src/plonk_bn254.rs index 8d13c09946..2b7c071f6c 100644 --- a/recursion/gnark-ffi/src/plonk_bn254.rs +++ b/recursion/gnark-ffi/src/plonk_bn254.rs @@ -81,32 +81,18 @@ impl PlonkBn254Prover { build_plonk_bn254(build_dir.to_str().unwrap()); // Write the corresponding asset files to the build dir. - let sp1_mock_verifier_path = build_dir.join("SP1MockVerifier.sol"); - let sp1_mock_verifier_str = include_str!("../assets/SP1MockVerifier.txt"); - let mut mock_verifier_file = File::create(sp1_mock_verifier_path).unwrap(); - mock_verifier_file - .write_all(sp1_mock_verifier_str.as_bytes()) - .unwrap(); - let sp1_verifier_path = build_dir.join("SP1Verifier.sol"); let vkey_hash = Self::get_vkey_hash(&build_dir); let sp1_verifier_str = include_str!("../assets/SP1Verifier.txt") .replace("{SP1_CIRCUIT_VERSION}", SP1_CIRCUIT_VERSION) .replace( - "{VKEY_HASH}", + "{VERIFIER_HASH}", format!("0x{}", hex::encode(vkey_hash)).as_str(), ); let mut sp1_verifier_file = File::create(sp1_verifier_path).unwrap(); sp1_verifier_file .write_all(sp1_verifier_str.as_bytes()) .unwrap(); - - let interface_sp1_verifier_path = build_dir.join("ISP1Verifier.sol"); - let interface_sp1_verifier_str = include_str!("../assets/ISP1Verifier.txt"); - let mut interface_sp1_verifier_file = File::create(interface_sp1_verifier_path).unwrap(); - interface_sp1_verifier_file - .write_all(interface_sp1_verifier_str.as_bytes()) - .unwrap(); } /// Generates a PLONK proof given a witness. diff --git a/recursion/program/CHANGELOG.md b/recursion/program/CHANGELOG.md new file mode 100644 index 0000000000..0cd85b7d28 --- /dev/null +++ b/recursion/program/CHANGELOG.md @@ -0,0 +1,142 @@ +# Changelog + +All notable changes to this project will be documented in this file. + +The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/), +and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html). + +## [Unreleased] + +## [1.0.0-rc.1](https://github.com/succinctlabs/sp1/compare/sp1-recursion-program-v1.0.0-rc.1...sp1-recursion-program-v1.0.0-rc.1) - 2024-07-19 + +### Added + +- parallel recursion tracegen ([#1095](https://github.com/succinctlabs/sp1/pull/1095)) +- result instead of exit(1) on trap in recursion ([#1089](https://github.com/succinctlabs/sp1/pull/1089)) +- publish sp1 to crates.io ([#1052](https://github.com/succinctlabs/sp1/pull/1052)) +- critical constraint changes ([#1046](https://github.com/succinctlabs/sp1/pull/1046)) +- suggest prover network if high cycles ([#1019](https://github.com/succinctlabs/sp1/pull/1019)) +- plonk circuit optimizations ([#972](https://github.com/succinctlabs/sp1/pull/972)) +- poseidon2 hash ([#885](https://github.com/succinctlabs/sp1/pull/885)) +- generic const expr ([#854](https://github.com/succinctlabs/sp1/pull/854)) +- sp1 core prover opts +- exit code ([#750](https://github.com/succinctlabs/sp1/pull/750)) +- _(recursion)_ public values constraints ([#748](https://github.com/succinctlabs/sp1/pull/748)) +- reduce network prover ([#687](https://github.com/succinctlabs/sp1/pull/687)) +- fix execution + proving errors ([#715](https://github.com/succinctlabs/sp1/pull/715)) +- _(recursion)_ HALT instruction ([#703](https://github.com/succinctlabs/sp1/pull/703)) +- ci refactor ([#684](https://github.com/succinctlabs/sp1/pull/684)) +- program refactor ([#651](https://github.com/succinctlabs/sp1/pull/651)) +- Adding docs for new `ProverClient` and `groth16` and `compressed` mode ([#627](https://github.com/succinctlabs/sp1/pull/627)) +- arbitrary degree in recursion ([#605](https://github.com/succinctlabs/sp1/pull/605)) +- prover tweaks pt 2 ([#607](https://github.com/succinctlabs/sp1/pull/607)) +- prover tweaks ([#603](https://github.com/succinctlabs/sp1/pull/603)) +- _(recursion)_ memory access timestamp constraints ([#589](https://github.com/succinctlabs/sp1/pull/589)) +- enable arbitrary constraint degree ([#593](https://github.com/succinctlabs/sp1/pull/593)) +- recursion compress layer + RecursionAirWideDeg3 + RecursionAirSkinnyDeg7 + optimized groth16 ([#590](https://github.com/succinctlabs/sp1/pull/590)) +- _(Recursion)_ evaluate constraints in a single expression ([#592](https://github.com/succinctlabs/sp1/pull/592)) +- expression caching ([#586](https://github.com/succinctlabs/sp1/pull/586)) +- complete reduce program ([#565](https://github.com/succinctlabs/sp1/pull/565)) +- e2e groth16 flow ([#549](https://github.com/succinctlabs/sp1/pull/549)) +- stark cleanup and verification ([#556](https://github.com/succinctlabs/sp1/pull/556)) +- recursion experiments ([#522](https://github.com/succinctlabs/sp1/pull/522)) +- groth16 circuit build script ([#541](https://github.com/succinctlabs/sp1/pull/541)) +- verify shard transitions + fixes ([#482](https://github.com/succinctlabs/sp1/pull/482)) +- nested sp1 proof verification ([#494](https://github.com/succinctlabs/sp1/pull/494)) +- verify pc and shard transition in recursive proofs ([#514](https://github.com/succinctlabs/sp1/pull/514)) +- recursion profiling ([#521](https://github.com/succinctlabs/sp1/pull/521)) +- update to latest p3 ([#515](https://github.com/succinctlabs/sp1/pull/515)) +- gnark wrap test + cleanup ([#511](https://github.com/succinctlabs/sp1/pull/511)) +- 0 cycle input for recursion program ([#510](https://github.com/succinctlabs/sp1/pull/510)) +- reduce with different configs ([#508](https://github.com/succinctlabs/sp1/pull/508)) +- sdk using secp256k1 auth ([#483](https://github.com/succinctlabs/sp1/pull/483)) +- logup batching ([#487](https://github.com/succinctlabs/sp1/pull/487)) +- _(recursion)_ reduce N sp1/recursive proofs ([#503](https://github.com/succinctlabs/sp1/pull/503)) +- recursion optimizations + compiler cleanup ([#499](https://github.com/succinctlabs/sp1/pull/499)) +- recursion vm public values ([#495](https://github.com/succinctlabs/sp1/pull/495)) +- cleanup compiler ir ([#496](https://github.com/succinctlabs/sp1/pull/496)) +- shard transition public values ([#466](https://github.com/succinctlabs/sp1/pull/466)) +- recursion permutation challenges as variables ([#486](https://github.com/succinctlabs/sp1/pull/486)) +- add support for witness in programs ([#476](https://github.com/succinctlabs/sp1/pull/476)) +- fri-fold precompile ([#479](https://github.com/succinctlabs/sp1/pull/479)) +- setup recursion prover crate ([#475](https://github.com/succinctlabs/sp1/pull/475)) +- gnark recursive verifier ([#457](https://github.com/succinctlabs/sp1/pull/457)) +- add shard to byte and program table ([#463](https://github.com/succinctlabs/sp1/pull/463)) +- recursion cpu constraints ([#464](https://github.com/succinctlabs/sp1/pull/464)) +- public values ([#455](https://github.com/succinctlabs/sp1/pull/455)) +- Preprocessing + recursion ([#450](https://github.com/succinctlabs/sp1/pull/450)) +- sp1-sdk, remote prover ([#370](https://github.com/succinctlabs/sp1/pull/370)) +- _(precompile)_ add bn254 precompile ([#384](https://github.com/succinctlabs/sp1/pull/384)) +- verify shard ([#444](https://github.com/succinctlabs/sp1/pull/444)) +- _(WIP)_ end-to-end verfier ([#439](https://github.com/succinctlabs/sp1/pull/439)) +- new README img ([#226](https://github.com/succinctlabs/sp1/pull/226)) +- readme updates ([#205](https://github.com/succinctlabs/sp1/pull/205)) +- more final touches ([#194](https://github.com/succinctlabs/sp1/pull/194)) +- curtaup + release system + cargo prove CLI updates ([#178](https://github.com/succinctlabs/sp1/pull/178)) +- (perf) updates from Plonky3 and verifier refactor ([#156](https://github.com/succinctlabs/sp1/pull/156)) +- developer experience improvements ([#145](https://github.com/succinctlabs/sp1/pull/145)) +- toolchain build from source & install ([#113](https://github.com/succinctlabs/sp1/pull/113)) +- io::read io::write ([#126](https://github.com/succinctlabs/sp1/pull/126)) +- tracing, profiling, benchmarking ([#99](https://github.com/succinctlabs/sp1/pull/99)) + +### Fixed + +- incorrect checks on deferred digest ([#1116](https://github.com/succinctlabs/sp1/pull/1116)) +- use correct value for blowup ([#965](https://github.com/succinctlabs/sp1/pull/965)) +- p3 audit change ([#964](https://github.com/succinctlabs/sp1/pull/964)) +- some informational fixes from veridise audit ([#953](https://github.com/succinctlabs/sp1/pull/953)) +- set sponge state to be zero ([#951](https://github.com/succinctlabs/sp1/pull/951)) +- range check for shard number in recursion ([#952](https://github.com/succinctlabs/sp1/pull/952)) +- memory finalize duplicate address attack from audit ([#934](https://github.com/succinctlabs/sp1/pull/934)) +- fix things +- unnecessary pc constraint ([#749](https://github.com/succinctlabs/sp1/pull/749)) +- _(recursion)_ enable mul constraint ([#686](https://github.com/succinctlabs/sp1/pull/686)) +- verify reduced proofs ([#655](https://github.com/succinctlabs/sp1/pull/655)) +- high degree constraints in recursion ([#619](https://github.com/succinctlabs/sp1/pull/619)) +- deferred proofs + cleanup hash_vkey ([#615](https://github.com/succinctlabs/sp1/pull/615)) +- observe only non-padded public values ([#523](https://github.com/succinctlabs/sp1/pull/523)) +- broken e2e recursion +- don't observe padded public values ([#520](https://github.com/succinctlabs/sp1/pull/520)) +- public inputs in recursion program ([#467](https://github.com/succinctlabs/sp1/pull/467)) + +### Other + +- use global workspace version ([#1102](https://github.com/succinctlabs/sp1/pull/1102)) +- fix release-plz ([#1088](https://github.com/succinctlabs/sp1/pull/1088)) +- add release-plz ([#1086](https://github.com/succinctlabs/sp1/pull/1086)) +- _(deps)_ bump serde from 1.0.203 to 1.0.204 ([#1063](https://github.com/succinctlabs/sp1/pull/1063)) +- updated p3 dependency to 0.1.3 ([#1059](https://github.com/succinctlabs/sp1/pull/1059)) +- merge main -> dev ([#969](https://github.com/succinctlabs/sp1/pull/969)) +- Fixes from review. +- Reverted to exp_rev_bits_len_fast +- please clippy +- Merge branch 'dev' into erabinov/exp_rev_precompile +- Version of exp_rev_precompile +- fixes ([#821](https://github.com/succinctlabs/sp1/pull/821)) +- program doc and remove unnecessary clones ([#857](https://github.com/succinctlabs/sp1/pull/857)) +- recursive program docs ([#855](https://github.com/succinctlabs/sp1/pull/855)) +- fmt +- change challenger rate from 16 to 8 ([#807](https://github.com/succinctlabs/sp1/pull/807)) +- remove todos in recursion ([#809](https://github.com/succinctlabs/sp1/pull/809)) +- require cpu shard in verifier ([#808](https://github.com/succinctlabs/sp1/pull/808)) +- clippy +- hm +- Make some functions const ([#774](https://github.com/succinctlabs/sp1/pull/774)) +- remove unused deps ([#794](https://github.com/succinctlabs/sp1/pull/794)) +- Clean up TOML files ([#796](https://github.com/succinctlabs/sp1/pull/796)) +- update all dependencies ([#689](https://github.com/succinctlabs/sp1/pull/689)) +- fixing dep tree for `prover`, `recursion`, `core` and `sdk` ([#545](https://github.com/succinctlabs/sp1/pull/545)) +- cleanup prover ([#551](https://github.com/succinctlabs/sp1/pull/551)) +- cleanup program + add missing constraints ([#547](https://github.com/succinctlabs/sp1/pull/547)) +- make ci faster ([#536](https://github.com/succinctlabs/sp1/pull/536)) +- _(recursion)_ reduce program ([#497](https://github.com/succinctlabs/sp1/pull/497)) +- for loop optimizations +- update to latest plonky3 main ([#491](https://github.com/succinctlabs/sp1/pull/491)) +- final touches for public release ([#239](https://github.com/succinctlabs/sp1/pull/239)) +- update docs with slight nits ([#224](https://github.com/succinctlabs/sp1/pull/224)) +- sp1 rename ([#212](https://github.com/succinctlabs/sp1/pull/212)) +- enshrine AlignedBorrow macro ([#209](https://github.com/succinctlabs/sp1/pull/209)) +- readme cleanup ([#196](https://github.com/succinctlabs/sp1/pull/196)) +- rename succinct to curta ([#192](https://github.com/succinctlabs/sp1/pull/192)) +- better curta graphic ([#184](https://github.com/succinctlabs/sp1/pull/184)) +- Initial commit diff --git a/recursion/program/Cargo.toml b/recursion/program/Cargo.toml index decfb2151e..134620d77f 100644 --- a/recursion/program/Cargo.toml +++ b/recursion/program/Cargo.toml @@ -1,7 +1,13 @@ [package] name = "sp1-recursion-program" -version = "0.1.0" -edition = "2021" +description = "SP1 is a performant, 100% open-source, contributor-friendly zkVM." +readme = "../../README.md" +version = { workspace = true } +edition = { workspace = true } +license = { workspace = true } +repository = { workspace = true } +keywords = { workspace = true } +categories = { workspace = true } [dependencies] p3-air = { workspace = true } @@ -17,13 +23,15 @@ p3-baby-bear = { workspace = true } p3-dft = { workspace = true } p3-merkle-tree = { workspace = true } p3-poseidon2 = { workspace = true } -sp1-recursion-core = { path = "../core" } -sp1-recursion-compiler = { path = "../compiler" } -sp1-core = { path = "../../core" } +sp1-recursion-core = { workspace = true } +sp1-recursion-compiler = { workspace = true } +sp1-core = { workspace = true } +sp1-primitives = { workspace = true } itertools = "0.13.0" -serde = { version = "1.0.201", features = ["derive"] } +serde = { version = "1.0.204", features = ["derive"] } rand = "0.8.5" tracing = "0.1.40" +stacker = "0.1" [features] -debug = ["sp1-core/debug"] \ No newline at end of file +debug = ["sp1-core/debug"] diff --git a/recursion/program/src/challenger.rs b/recursion/program/src/challenger.rs index b6943d27f7..d4632a6514 100644 --- a/recursion/program/src/challenger.rs +++ b/recursion/program/src/challenger.rs @@ -49,13 +49,21 @@ pub struct DuplexChallengerVariable { impl DuplexChallengerVariable { /// Creates a new duplex challenger with the default state. pub fn new(builder: &mut Builder) -> Self { - DuplexChallengerVariable:: { + let mut result = DuplexChallengerVariable:: { sponge_state: builder.dyn_array(PERMUTATION_WIDTH), nb_inputs: builder.eval(C::N::zero()), input_buffer: builder.dyn_array(PERMUTATION_WIDTH), nb_outputs: builder.eval(C::N::zero()), output_buffer: builder.dyn_array(PERMUTATION_WIDTH), - } + }; + + // Constrain the state of the challenger to contain all zeroes. + builder.range(0, PERMUTATION_WIDTH).for_each(|i, builder| { + builder.set(&mut result.sponge_state, i, C::F::zero()); + builder.set(&mut result.input_buffer, i, C::F::zero()); + builder.set(&mut result.output_buffer, i, C::F::zero()); + }); + result } /// Creates a new challenger with the same state as an existing challenger. diff --git a/recursion/program/src/constraints.rs b/recursion/program/src/constraints.rs index 67eeea5681..28824c16e4 100644 --- a/recursion/program/src/constraints.rs +++ b/recursion/program/src/constraints.rs @@ -160,6 +160,7 @@ mod tests { use itertools::{izip, Itertools}; use rand::{thread_rng, Rng}; use serde::{de::DeserializeOwned, Serialize}; + use sp1_core::stark::DefaultProver; use sp1_core::{ io::SP1Stdin, runtime::Program, @@ -169,6 +170,7 @@ mod tests { }, utils::{BabyBearPoseidon2, SP1CoreOpts}, }; + use sp1_recursion_core::stark::utils::{run_test_recursion, TestConfig}; use p3_challenger::{CanObserve, FieldChallenger}; @@ -284,7 +286,7 @@ mod tests { let machine = A::machine(SC::default()); let (_, vk) = machine.setup(&Program::from(elf)); let mut challenger = machine.config().challenger(); - let (proof, _) = sp1_core::utils::prove( + let (proof, _, _) = sp1_core::utils::prove::<_, DefaultProver<_, _>>( Program::from(elf), &SP1Stdin::new(), SC::default(), @@ -383,6 +385,33 @@ mod tests { let program = builder.compile_program(); + // We don't test with the config TestConfig::WideDeg17Wrap, since it doesn't have the + // `ExpReverseBitsLen` chip. + run_test_recursion(program.clone(), None, TestConfig::WideDeg3); + run_test_recursion(program, None, TestConfig::SkinnyDeg7); + } + + #[test] + fn test_memory_finalize() { + type SC = BabyBearPoseidon2; + type F = ::Val; + type EF = ::Challenge; + + let mut rng = thread_rng(); + + // Initialize a builder. + let mut builder = AsmBuilder::::default(); + + // Get a random var with `NUM_BITS` bits. + let x_val: F = rng.gen(); + + // Materialize the number as a var + let _x_felt: Felt<_> = builder.eval(x_val); + + builder.halt(); + + let program = builder.compile_program(); + run_test_recursion(program, None, TestConfig::All); } } diff --git a/recursion/program/src/fri/mod.rs b/recursion/program/src/fri/mod.rs index f274a65bd7..a4e61590ec 100644 --- a/recursion/program/src/fri/mod.rs +++ b/recursion/program/src/fri/mod.rs @@ -4,6 +4,7 @@ pub mod two_adic_pcs; pub mod types; pub use domain::*; +use sp1_primitives::types::RecursionProgramType; use sp1_recursion_compiler::ir::ExtensionOperand; use sp1_recursion_compiler::ir::Ptr; use sp1_recursion_core::runtime::DIGEST_SIZE; @@ -51,6 +52,10 @@ pub fn verify_shape_and_sample_challenges( builder.set(&mut betas, i, sample); }); + // Observe the final polynomial. + let final_poly_felts = builder.ext2felt(proof.final_poly); + challenger.observe_slice(builder, final_poly_felts); + let num_query_proofs = proof.query_proofs.len().materialize(builder); builder .if_ne(num_query_proofs, config.num_queries) @@ -137,7 +142,11 @@ where let folded_eval: Ext = builder.eval(C::F::zero()); let two_adic_generator_f = config.get_two_adic_generator(builder, log_max_height); - let x = builder.exp_reverse_bits_len_fast(two_adic_generator_f, index_bits, log_max_height); + let x = if matches!(builder.program_type, RecursionProgramType::Wrap) { + builder.exp_reverse_bits_len(two_adic_generator_f, index_bits, log_max_height) + } else { + builder.exp_reverse_bits_len_fast(two_adic_generator_f, index_bits, log_max_height) + }; let log_max_height = log_max_height.materialize(builder); builder diff --git a/recursion/program/src/fri/two_adic_pcs.rs b/recursion/program/src/fri/two_adic_pcs.rs index 354ff66611..24200696c3 100644 --- a/recursion/program/src/fri/two_adic_pcs.rs +++ b/recursion/program/src/fri/two_adic_pcs.rs @@ -2,6 +2,7 @@ use p3_commit::TwoAdicMultiplicativeCoset; use p3_field::AbstractField; use p3_field::TwoAdicField; use p3_symmetric::Hash; +use sp1_primitives::types::RecursionProgramType; use sp1_recursion_compiler::prelude::*; use sp1_recursion_core::runtime::DIGEST_SIZE; @@ -33,7 +34,7 @@ pub fn verify_two_adic_pcs( let g = builder.generator(); let log_blowup = config.log_blowup; - let blowup = config.log_blowup; + let blowup = config.blowup; let alpha = challenger.sample_ext(builder); builder.cycle_tracker("stage-d-1-verify-shape-and-sample-challenges"); @@ -120,11 +121,22 @@ pub fn verify_two_adic_pcs( let two_adic_generator = config.get_two_adic_generator(builder, log_height); builder.cycle_tracker("exp_reverse_bits_len"); - let two_adic_generator_exp = builder.exp_reverse_bits_len_fast( - two_adic_generator, - &index_bits_shifted, - log_height, - ); + + let two_adic_generator_exp: Felt = + if matches!(builder.program_type, RecursionProgramType::Wrap) { + builder.exp_reverse_bits_len( + two_adic_generator, + &index_bits_shifted, + log_height, + ) + } else { + builder.exp_reverse_bits_len_fast( + two_adic_generator, + &index_bits_shifted, + log_height, + ) + }; + builder.cycle_tracker("exp_reverse_bits_len"); let x: Felt = builder.eval(two_adic_generator_exp * g); @@ -405,6 +417,10 @@ pub mod tests { fn test_two_adic_fri_pcs_single_batch() { use sp1_recursion_core::stark::utils::{run_test_recursion, TestConfig}; let (program, witness) = build_test_fri_with_cols_and_log2_rows(10, 16); - run_test_recursion(program, Some(witness), TestConfig::All); + + // We don't test with the config TestConfig::WideDeg17Wrap, since it doesn't have the + // `ExpReverseBitsLen` chip. + run_test_recursion(program.clone(), Some(witness.clone()), TestConfig::WideDeg3); + run_test_recursion(program, Some(witness), TestConfig::SkinnyDeg7); } } diff --git a/recursion/program/src/hints.rs b/recursion/program/src/hints.rs index e5d889e195..fb5a52e48a 100644 --- a/recursion/program/src/hints.rs +++ b/recursion/program/src/hints.rs @@ -517,7 +517,6 @@ impl<'a, A: MachineAir> Hintable let initial_reconstruct_challenger = DuplexChallenger::::read(builder); let is_complete = builder.hint_var(); - let total_core_shards = builder.hint_var(); SP1RecursionMemoryLayoutVariable { vk, @@ -525,7 +524,6 @@ impl<'a, A: MachineAir> Hintable leaf_challenger, initial_reconstruct_challenger, is_complete, - total_core_shards, } } @@ -545,7 +543,6 @@ impl<'a, A: MachineAir> Hintable stream.extend(self.leaf_challenger.write()); stream.extend(self.initial_reconstruct_challenger.write()); stream.extend((self.is_complete as usize).write()); - stream.extend(self.total_core_shards.write()); stream } @@ -559,14 +556,12 @@ impl<'a, A: MachineAir> Hintable for SP1ReduceMemoryLayout<'a, Baby let shard_proofs = Vec::>::read(builder); let kinds = Vec::::read(builder); let is_complete = builder.hint_var(); - let total_core_shards = builder.hint_var(); SP1ReduceMemoryLayoutVariable { compress_vk, shard_proofs, kinds, is_complete, - total_core_shards, } } @@ -590,7 +585,6 @@ impl<'a, A: MachineAir> Hintable for SP1ReduceMemoryLayout<'a, Baby stream.extend(proof_hints.write()); stream.extend(kinds.write()); stream.extend((self.is_complete as usize).write()); - stream.extend(self.total_core_shards.write()); stream } @@ -635,7 +629,9 @@ impl<'a, A: MachineAir> Hintable let leaf_challenger = DuplexChallenger::::read(builder); let end_pc = InnerVal::read(builder); let end_shard = InnerVal::read(builder); - let total_core_shards = builder.hint_var(); + let end_execution_shard = InnerVal::read(builder); + let init_addr_bits = Vec::::read(builder); + let finalize_addr_bits = Vec::::read(builder); SP1DeferredMemoryLayoutVariable { compress_vk, @@ -648,7 +644,9 @@ impl<'a, A: MachineAir> Hintable leaf_challenger, end_pc, end_shard, - total_core_shards, + end_execution_shard, + init_addr_bits, + finalize_addr_bits, } } @@ -684,7 +682,9 @@ impl<'a, A: MachineAir> Hintable stream.extend(self.leaf_challenger.write()); stream.extend(self.end_pc.write()); stream.extend(self.end_shard.write()); - stream.extend(self.total_core_shards.write()); + stream.extend(self.end_execution_shard.write()); + stream.extend(self.init_addr_bits.to_vec().write()); + stream.extend(self.finalize_addr_bits.to_vec().write()); stream } diff --git a/recursion/program/src/machine/compress.rs b/recursion/program/src/machine/compress.rs index 60a3a6458f..4dec375be3 100644 --- a/recursion/program/src/machine/compress.rs +++ b/recursion/program/src/machine/compress.rs @@ -9,11 +9,12 @@ use p3_baby_bear::BabyBear; use p3_commit::TwoAdicMultiplicativeCoset; use p3_field::{AbstractField, PrimeField32, TwoAdicField}; use serde::{Deserialize, Serialize}; -use sp1_core::air::MachineAir; +use sp1_core::air::{MachineAir, WORD_SIZE}; use sp1_core::air::{Word, POSEIDON_NUM_WORDS, PV_DIGEST_NUM_WORDS}; use sp1_core::stark::StarkMachine; use sp1_core::stark::{Com, ShardProof, StarkGenericConfig, StarkVerifyingKey}; use sp1_core::utils::BabyBearPoseidon2; +use sp1_primitives::types::RecursionProgramType; use sp1_recursion_compiler::config::InnerConfig; use sp1_recursion_compiler::ir::{Array, Builder, Config, Felt, Var}; use sp1_recursion_compiler::prelude::DslVariable; @@ -29,8 +30,8 @@ use crate::stark::{RecursiveVerifierConstraintFolder, StarkVerifier}; use crate::types::ShardProofVariable; use crate::types::VerifyingKeyVariable; use crate::utils::{ - assert_challenger_eq_pv, assign_challenger_from_pv, const_fri_config, - get_challenger_public_values, hash_vkey, var2felt, + assert_challenger_eq_pv, assign_challenger_from_pv, const_fri_config, felt2var, + get_challenger_public_values, hash_vkey, }; use super::utils::{commit_public_values, proof_data_from_vk, verify_public_values_hash}; @@ -59,7 +60,6 @@ pub struct SP1ReduceMemoryLayout<'a, SC: StarkGenericConfig, A: MachineAir>, pub is_complete: bool, pub kinds: Vec, - pub total_core_shards: usize, } #[derive(DslVariable, Clone)] @@ -68,7 +68,6 @@ pub struct SP1ReduceMemoryLayoutVariable { pub shard_proofs: Array>, pub kinds: Array>, pub is_complete: Var, - pub total_core_shards: Var, } impl SP1CompressVerifier @@ -81,7 +80,7 @@ where recursive_vk: &StarkVerifyingKey, deferred_vk: &StarkVerifyingKey, ) -> RecursionProgram { - let mut builder = Builder::::default(); + let mut builder = Builder::::new(RecursionProgramType::Compress); let input: SP1ReduceMemoryLayoutVariable<_> = builder.uninit(); SP1ReduceMemoryLayout::::witness(&input, &mut builder); @@ -140,16 +139,13 @@ where shard_proofs, kinds, is_complete, - total_core_shards, } = input; - let total_core_shards_felt = var2felt(builder, total_core_shards); // Initialize the values for the aggregated public output. let mut reduce_public_values_stream: Vec> = (0..RECURSIVE_PROOF_NUM_PV_ELTS) .map(|_| builder.uninit()) .collect(); - let reduce_public_values: &mut RecursionPublicValues<_> = reduce_public_values_stream.as_mut_slice().borrow_mut(); @@ -161,6 +157,7 @@ where // Assert that there is at least one proof. builder.assert_usize_ne(shard_proofs.len(), 0); + // Assert that the number of proofs is equal to the number of kinds. builder.assert_usize_eq(shard_proofs.len(), kinds.len()); @@ -168,6 +165,7 @@ where let sp1_vk_digest: [Felt<_>; DIGEST_SIZE] = array::from_fn(|_| builder.uninit()); let pc: Felt<_> = builder.uninit(); let shard: Felt<_> = builder.uninit(); + let execution_shard: Felt<_> = builder.uninit(); let mut initial_reconstruct_challenger = DuplexChallengerVariable::new(builder); let mut reconstruct_challenger = DuplexChallengerVariable::new(builder); let mut leaf_challenger = DuplexChallengerVariable::new(builder); @@ -178,6 +176,8 @@ where let reconstruct_deferred_digest: [Felt<_>; POSEIDON_NUM_WORDS] = core::array::from_fn(|_| builder.uninit()); let cumulative_sum: [Felt<_>; D] = core::array::from_fn(|_| builder.eval(C::F::zero())); + let init_addr_bits: [Felt<_>; 32] = core::array::from_fn(|_| builder.uninit()); + let finalize_addr_bits: [Felt<_>; 32] = core::array::from_fn(|_| builder.uninit()); // Collect verifying keys for each kind of program. let recursive_vk_variable = proof_data_from_vk(builder, recursive_vk, machine); @@ -192,6 +192,7 @@ where builder.range(0, shard_proofs.len()).for_each(|i, builder| { // Load the proof. let proof = builder.get(&shard_proofs, i); + // Get the kind of proof we are verifying. let kind = builder.get(&kinds, i); @@ -199,6 +200,7 @@ where // Initialize values for verifying key and proof data. let vk: VerifyingKeyVariable<_> = builder.uninit(); + // Set the correct value given the value of kind, and assert it must be one of the // valid values. We can do that by nested `if-else` statements. builder.if_eq(kind, core_kind).then_or_else( @@ -216,8 +218,7 @@ where builder.assign(vk.clone(), compress_vk.clone()); }, |builder| { - // If the kind is not one of the valid values, raise - // an error. + // If the kind is not one of the valid values, raise an error. builder.error(); }, ); @@ -230,17 +231,19 @@ where // Prepare a challenger. let mut challenger = DuplexChallengerVariable::new(builder); + // Observe the vk and start pc. challenger.observe(builder, vk.commitment.clone()); challenger.observe(builder, vk.pc_start); + // Observe the main commitment and public values. challenger.observe(builder, proof.commitment.main_commit.clone()); for j in 0..machine.num_pv_elts() { let element = builder.get(&proof.public_values, j); challenger.observe(builder, element); } - // verify proof. - let one_var = builder.constant(C::N::one()); + + // Verify proof. StarkVerifier::::verify_shard( builder, &vk, @@ -248,7 +251,7 @@ where machine, &mut challenger, &proof, - one_var, + true, ); // Load the public values from the proof. @@ -302,12 +305,42 @@ where current_public_values.start_shard, ); + // Initialize start execution shard. + builder.assign(execution_shard, current_public_values.start_execution_shard); + builder.assign( + reduce_public_values.start_execution_shard, + current_public_values.start_execution_shard, + ); + + // Initialize the MemoryInitialize address bits. + for (bit, (first_bit, current_bit)) in init_addr_bits.iter().zip( + reduce_public_values + .previous_init_addr_bits + .iter() + .zip(current_public_values.previous_init_addr_bits.iter()), + ) { + builder.assign(*bit, *current_bit); + builder.assign(*first_bit, *current_bit); + } + + // Initialize the MemoryFinalize address bits. + for (bit, (first_bit, current_bit)) in finalize_addr_bits.iter().zip( + reduce_public_values + .previous_finalize_addr_bits + .iter() + .zip(current_public_values.previous_finalize_addr_bits.iter()), + ) { + builder.assign(*bit, *current_bit); + builder.assign(*first_bit, *current_bit); + } + // Initialize the leaf challenger. assign_challenger_from_pv( builder, &mut leaf_challenger, current_public_values.leaf_challenger, ); + // Initialize the reconstruct challenger. assign_challenger_from_pv( builder, @@ -336,20 +369,6 @@ where { builder.assign(*digest, *current_digest); } - - // Initialize the start reconstruct deferred digest. - for (digest, first_digest, global_digest) in izip!( - reconstruct_deferred_digest.iter(), - current_public_values - .start_reconstruct_deferred_digest - .iter(), - reduce_public_values - .start_reconstruct_deferred_digest - .iter() - ) { - builder.assign(*digest, *first_digest); - builder.assign(*global_digest, *first_digest); - } }); // Assert that the current values match the accumulated values. @@ -363,7 +382,7 @@ where builder.assert_felt_eq(*digest, *current_digest); } - // consistency checks for all accumulated values. + // Consistency checks for all accumulated values. // Assert that the sp1_vk digest is always the same. for (digest, current) in sp1_vk_digest @@ -375,10 +394,31 @@ where // Assert that the start pc is equal to the current pc. builder.assert_felt_eq(pc, current_public_values.start_pc); - // Verfiy that the shard is equal to the current shard. + + // Verify that the shard is equal to the current shard. builder.assert_felt_eq(shard, current_public_values.start_shard); + + // Verfiy that the exeuction shard is equal to the current execution shard. + builder.assert_felt_eq(execution_shard, current_public_values.start_execution_shard); + // Assert that the leaf challenger is always the same. + // Assert that the MemoryInitialize address bits are the same. + for (bit, current_bit) in init_addr_bits + .iter() + .zip(current_public_values.previous_init_addr_bits.iter()) + { + builder.assert_felt_eq(*bit, *current_bit); + } + + // Assert that the MemoryFinalize address bits are the same. + for (bit, current_bit) in finalize_addr_bits + .iter() + .zip(current_public_values.previous_finalize_addr_bits.iter()) + { + builder.assert_felt_eq(*bit, *current_bit); + } + assert_challenger_eq_pv( builder, &leaf_challenger, @@ -391,32 +431,73 @@ where current_public_values.start_reconstruct_challenger, ); - // Assert that the commited digests are the same. - for (word, current_word) in committed_value_digest - .iter() - .zip_eq(current_public_values.committed_value_digest.iter()) + // Digest constraints. { - for (byte, current_byte) in word.0.iter().zip_eq(current_word.0.iter()) { - builder.assert_felt_eq(*byte, *current_byte); + // If `commited_value_digest` is not zero, then `public_values.commited_value_digest + // should be the current value. + let is_zero: Var<_> = builder.eval(C::N::one()); + #[allow(clippy::needless_range_loop)] + for i in 0..committed_value_digest.len() { + for j in 0..WORD_SIZE { + let d = felt2var(builder, committed_value_digest[i][j]); + builder.if_ne(d, C::N::zero()).then(|builder| { + builder.assign(is_zero, C::N::zero()); + }); + } + } + builder.if_eq(is_zero, C::N::zero()).then(|builder| { + #[allow(clippy::needless_range_loop)] + for i in 0..committed_value_digest.len() { + for j in 0..WORD_SIZE { + builder.assert_felt_eq( + committed_value_digest[i][j], + current_public_values.committed_value_digest[i][j], + ); + } + } + }); + + // Update the committed value digest. + #[allow(clippy::needless_range_loop)] + for i in 0..committed_value_digest.len() { + for j in 0..WORD_SIZE { + builder.assign( + committed_value_digest[i][j], + current_public_values.committed_value_digest[i][j], + ); + } } - } - // Assert that the deferred proof digests are the same. - for (digest, current_digest) in deferred_proofs_digest - .iter() - .zip_eq(current_public_values.deferred_proofs_digest.iter()) - { - builder.assert_felt_eq(*digest, *current_digest); + // If `deferred_proofs_digest` is not zero, then `public_values.deferred_proofs_digest + // should be the current value. + let is_zero: Var<_> = builder.eval(C::N::one()); + #[allow(clippy::needless_range_loop)] + for i in 0..deferred_proofs_digest.len() { + let d = felt2var(builder, deferred_proofs_digest[i]); + builder.if_ne(d, C::N::zero()).then(|builder| { + builder.assign(is_zero, C::N::zero()); + }); + } + builder.if_eq(is_zero, C::N::zero()).then(|builder| { + #[allow(clippy::needless_range_loop)] + for i in 0..deferred_proofs_digest.len() { + builder.assert_felt_eq( + deferred_proofs_digest[i], + current_public_values.deferred_proofs_digest[i], + ); + } + }); + + // Update the deferred proofs digest. + #[allow(clippy::needless_range_loop)] + for i in 0..deferred_proofs_digest.len() { + builder.assign( + deferred_proofs_digest[i], + current_public_values.deferred_proofs_digest[i], + ); + } } - // Assert that total_core_shards is the same. - builder.assert_felt_eq( - total_core_shards_felt, - current_public_values.total_core_shards, - ); - - // Update the accumulated values. - // Update the deferred proof digest. for (digest, current_digest) in reconstruct_deferred_digest .iter() @@ -428,8 +509,29 @@ where // Update the accumulated values. // Update pc to be the next pc. builder.assign(pc, current_public_values.next_pc); + // Update the shard to be the next shard. builder.assign(shard, current_public_values.next_shard); + + // Update the execution shard to be the next execution shard. + builder.assign(execution_shard, current_public_values.next_execution_shard); + + // Update the MemoryInitialize address bits. + for (bit, next_bit) in init_addr_bits + .iter() + .zip(current_public_values.last_init_addr_bits.iter()) + { + builder.assign(*bit, *next_bit); + } + + // Update the MemoryFinalize address bits. + for (bit, next_bit) in finalize_addr_bits + .iter() + .zip(current_public_values.last_finalize_addr_bits.iter()) + { + builder.assign(*bit, *next_bit); + } + // Update the reconstruct challenger. assign_challenger_from_pv( builder, @@ -451,8 +553,14 @@ where reduce_public_values.sp1_vk_digest = sp1_vk_digest; // Set next_pc to be the last pc (which is the same as accumulated pc) reduce_public_values.next_pc = pc; - // Set next shard to be the last shard (which is the same as accumulated shard) + // Set next shard to be the last shard reduce_public_values.next_shard = shard; + // Set next execution shard to be the last execution shard + reduce_public_values.next_execution_shard = execution_shard; + // Set the MemoryInitialize address bits to be the last MemoryInitialize address bits. + reduce_public_values.last_init_addr_bits = init_addr_bits; + // Set the MemoryFinalize address bits to be the last MemoryFinalize address bits. + reduce_public_values.last_finalize_addr_bits = finalize_addr_bits; // Set the leaf challenger to it's value. let values = get_challenger_public_values(builder, &leaf_challenger); reduce_public_values.leaf_challenger = values; @@ -464,15 +572,12 @@ where reduce_public_values.end_reconstruct_challenger = values; // Set the start reconstruct deferred digest to be the last reconstruct deferred digest. reduce_public_values.end_reconstruct_deferred_digest = reconstruct_deferred_digest; - - // Assign the deffered proof digests. + // Assign the deferred proof digests. reduce_public_values.deferred_proofs_digest = deferred_proofs_digest; // Assign the committed value digests. reduce_public_values.committed_value_digest = committed_value_digest; // Assign the cumulative sum. reduce_public_values.cumulative_sum = cumulative_sum; - // Assign the total number of shards. - reduce_public_values.total_core_shards = total_core_shards_felt; // If the proof is complete, make completeness assertions and set the flag. Otherwise, check // the flag is zero and set the public value to zero. diff --git a/recursion/program/src/machine/core.rs b/recursion/program/src/machine/core.rs index c5d0b6ee9e..97ea98d13b 100644 --- a/recursion/program/src/machine/core.rs +++ b/recursion/program/src/machine/core.rs @@ -1,28 +1,29 @@ use std::array; -use std::borrow::BorrowMut; +use std::borrow::{Borrow, BorrowMut}; use std::marker::PhantomData; use itertools::Itertools; use p3_baby_bear::BabyBear; use p3_commit::TwoAdicMultiplicativeCoset; use p3_field::{AbstractField, PrimeField32, TwoAdicField}; -use sp1_core::air::{MachineAir, PublicValues}; +use sp1_core::air::{MachineAir, PublicValues, WORD_SIZE}; use sp1_core::air::{Word, POSEIDON_NUM_WORDS, PV_DIGEST_NUM_WORDS}; +use sp1_core::cpu::MAX_CPU_LOG_DEGREE; use sp1_core::stark::StarkMachine; use sp1_core::stark::{Com, RiscvAir, ShardProof, StarkGenericConfig, StarkVerifyingKey}; use sp1_core::utils::BabyBearPoseidon2; +use sp1_primitives::types::RecursionProgramType; use sp1_recursion_compiler::config::InnerConfig; use sp1_recursion_compiler::ir::{Array, Builder, Config, Ext, ExtConst, Felt, Var}; use sp1_recursion_compiler::prelude::DslVariable; +use sp1_recursion_compiler::prelude::*; use sp1_recursion_core::air::{RecursionPublicValues, RECURSIVE_PROOF_NUM_PV_ELTS}; use sp1_recursion_core::runtime::{RecursionProgram, DIGEST_SIZE}; -use sp1_recursion_compiler::prelude::*; - use crate::challenger::{CanObserveVariable, DuplexChallengerVariable}; use crate::fri::TwoAdicFriPcsVariable; use crate::hints::Hintable; -use crate::stark::StarkVerifier; +use crate::stark::{StarkVerifier, EMPTY}; use crate::types::ShardProofVariable; use crate::types::VerifyingKeyVariable; use crate::utils::{const_fri_config, felt2var, get_challenger_public_values, hash_vkey, var2felt}; @@ -42,21 +43,15 @@ pub struct SP1RecursionMemoryLayout<'a, SC: StarkGenericConfig, A: MachineAir { pub vk: VerifyingKeyVariable, - pub shard_proofs: Array>, - pub leaf_challenger: DuplexChallengerVariable, pub initial_reconstruct_challenger: DuplexChallengerVariable, - pub is_complete: Var, - - pub total_core_shards: Var, } impl SP1RecursiveVerifier { @@ -64,7 +59,7 @@ impl SP1RecursiveVerifier { pub fn build( machine: &StarkMachine>, ) -> RecursionProgram { - let mut builder = Builder::::default(); + let mut builder = Builder::::new(RecursionProgramType::Core); let input: SP1RecursionMemoryLayoutVariable<_> = builder.uninit(); SP1RecursionMemoryLayout::>::witness(&input, &mut builder); @@ -104,20 +99,15 @@ where /// of verifying the FRI proof for openings and verifying the constraints. /// /// ## Aggregating the shard public values. - /// /// See [SP1Prover::verify] for the verification algorithm of a complete SP1 proof. In this /// function, we are aggregating several shard proofs and attesting to an aggregated state which - /// reprersents all the shards. The consistency conditions of the aggregated state are - /// asserted in the following way: - /// - /// - Start pc for every shardf should be what the next pc declared in the previous shard was. - /// - Public input, deferred proof digests, and exit code should be the same in all shards. + /// represents all the shards. /// /// ## The leaf challenger. /// A key difference between the recursive tree verification and the complete one in - /// [SP1Prover::verify] is that the recursive verifier has no way of reconstructiing the - /// chanllenger only from a part of the shard proof. Therefoee, the value of the leaf challenger - /// is witnessed in the program and the verifier assertds correctness given this challenger. + /// [SP1Prover::verify] is that the recursive verifier has no way of reconstructing the + /// chanllenger only from a part of the shard proof. Therefore, the value of the leaf challenger + /// is witnessed in the program and the verifier asserts correctness given this challenger. /// In the course of the recursive verification, the challenger is reconstructed by observing /// the commitments one by one, and in the final step, the challenger is asserted to be the same /// as the one witnessed here. @@ -134,57 +124,80 @@ where leaf_challenger, initial_reconstruct_challenger, is_complete, - total_core_shards, } = input; - // Initialize values we will commit to public outputs. + // Initialize shard variables. + let initial_shard = builder.uninit(); + let current_shard = builder.uninit(); - // Start and end of program counters. - let start_pc: Felt<_> = builder.uninit(); + // Initialize execution shard variables. + let initial_execution_shard = builder.uninit(); + let current_execution_shard = builder.uninit(); - // Start and end shard indices. - let initial_shard: Felt<_> = builder.uninit(); + // Initialize program counter variables. + let start_pc = builder.uninit(); + let current_pc = builder.uninit(); - // The commited values digest and deferred proof digest. These will be checked to be the - // same for all proofs. + // Initialize memory initialization and finalization variables. + let initial_previous_init_addr_bits: [Felt<_>; 32] = array::from_fn(|_| builder.uninit()); + let initial_previous_finalize_addr_bits: [Felt<_>; 32] = + array::from_fn(|_| builder.uninit()); + let current_init_addr_bits: [Felt<_>; 32] = array::from_fn(|_| builder.uninit()); + let current_finalize_addr_bits: [Felt<_>; 32] = array::from_fn(|_| builder.uninit()); + + // Initialize the exit code variable. + let exit_code: Felt<_> = builder.uninit(); + + // Initialize the public values digest. let committed_value_digest: [Word>; PV_DIGEST_NUM_WORDS] = array::from_fn(|_| Word(array::from_fn(|_| builder.uninit()))); + + // Initialize the deferred proofs digest. let deferred_proofs_digest: [Felt<_>; POSEIDON_NUM_WORDS] = array::from_fn(|_| builder.uninit()); - // Assert that the number of proofs is not zero. - builder.assert_usize_ne(shard_proofs.len(), 0); - + // Initialize the challenger variables. let leaf_challenger_public_values = get_challenger_public_values(builder, &leaf_challenger); - - // Initialize loop variables. - let current_shard: Felt<_> = builder.uninit(); let mut reconstruct_challenger: DuplexChallengerVariable<_> = initial_reconstruct_challenger.copy(builder); + + // Initialize the cumulative sum. let cumulative_sum: Ext<_, _> = builder.eval(C::EF::zero().cons()); - let current_pc: Felt<_> = builder.uninit(); - let exit_code: Felt<_> = builder.uninit(); - // Range check that the number of proofs is sufficiently small. - let num_shard_proofs: Var<_> = shard_proofs.len().materialize(builder); - builder.range_check_v(num_shard_proofs, 16); + // Assert that the number of proofs is not zero. + builder.assert_usize_ne(shard_proofs.len(), 0); // Verify proofs, validate transitions, and update accumulation variables. builder.range(0, shard_proofs.len()).for_each(|i, builder| { // Load the proof. let proof = builder.get(&shard_proofs, i); - // Verify the shard proof. - let mut challenger = leaf_challenger.copy(builder); - StarkVerifier::::verify_shard( - builder, - &vk, - pcs, - machine, - &mut challenger, - &proof, - total_core_shards, - ); + // Compute some flags about which chips exist in the shard. + let contains_cpu: Var<_> = builder.eval(C::N::zero()); + let contains_memory_init: Var<_> = builder.eval(C::N::zero()); + let contains_memory_finalize: Var<_> = builder.eval(C::N::zero()); + for (i, chip) in machine.chips().iter().enumerate() { + let index = builder.get(&proof.sorted_idxs, i); + if chip.name() == "CPU" { + builder + .if_ne(index, C::N::from_canonical_usize(EMPTY)) + .then(|builder| { + builder.assign(contains_cpu, C::N::one()); + }); + } else if chip.name() == "MemoryInit" { + builder + .if_ne(index, C::N::from_canonical_usize(EMPTY)) + .then(|builder| { + builder.assign(contains_memory_init, C::N::one()); + }); + } else if chip.name() == "MemoryFinalize" { + builder + .if_ne(index, C::N::from_canonical_usize(EMPTY)) + .then(|builder| { + builder.assign(contains_memory_finalize, C::N::one()); + }); + } + } // Extract public values. let mut pv_elements = Vec::new(); @@ -192,20 +205,44 @@ where let element = builder.get(&proof.public_values, i); pv_elements.push(element); } - let public_values = PublicValues::>, Felt<_>>::from_vec(pv_elements); + let public_values: &PublicValues>, Felt<_>> = + pv_elements.as_slice().borrow(); - // If this is the first proof in the batch, verify the initial conditions. + // If this is the first proof in the batch, initialize the variables. builder.if_eq(i, C::N::zero()).then(|builder| { - // Initialize the values of accumulated variables. - // Shard. builder.assign(initial_shard, public_values.shard); builder.assign(current_shard, public_values.shard); + // Execution shard. + builder.assign(initial_execution_shard, public_values.execution_shard); + builder.assign(current_execution_shard, public_values.execution_shard); + // Program counter. builder.assign(start_pc, public_values.start_pc); builder.assign(current_pc, public_values.start_pc); + // Memory initialization & finalization. + for ((bit, pub_bit), first_bit) in current_init_addr_bits + .iter() + .zip(public_values.previous_init_addr_bits.iter()) + .zip(initial_previous_init_addr_bits.iter()) + { + builder.assign(*bit, *pub_bit); + builder.assign(*first_bit, *pub_bit); + } + for ((bit, pub_bit), first_bit) in current_finalize_addr_bits + .iter() + .zip(public_values.previous_finalize_addr_bits.iter()) + .zip(initial_previous_finalize_addr_bits.iter()) + { + builder.assign(*bit, *pub_bit); + builder.assign(*first_bit, *pub_bit); + } + + // Exit code. + builder.assign(exit_code, public_values.exit_code); + // Commited public values digests. for (word, first_word) in committed_value_digest .iter() @@ -223,83 +260,294 @@ where { builder.assign(*digest, *first_digest); } - - // Exit code. - builder.assign(exit_code, public_values.exit_code); }); - // If it's first shard, verify the global initial conditions hold on challenger and pc. + // If the shard is the first shard, assert that the initial challenger is equal to a + // fresh challenger observing the verifier key and the initial pc. let shard = felt2var(builder, public_values.shard); builder.if_eq(shard, C::N::one()).then(|builder| { - // This should be the 0th proof in this batch. - builder.assert_var_eq(i, C::N::zero()); - - // Start pc should be vk.pc_start - builder.assert_felt_eq(public_values.start_pc, vk.pc_start); - - // Assert that the initial challenger is equal to a fresh challenger observing the - // verifier key and the initial pc. let mut first_initial_challenger = DuplexChallengerVariable::new(builder); - first_initial_challenger.observe(builder, vk.commitment.clone()); first_initial_challenger.observe(builder, vk.pc_start); - - // Make sure the start reconstruct challenger is correct, since we will - // commit to it in public values. initial_reconstruct_challenger.assert_eq(builder, &first_initial_challenger); }); - // Assert compatibility of the shard values. + // Verify the shard. + // + // Do not verify the cumulative sum here, since the permutation challenge is shared + // between all shards. + let mut challenger = leaf_challenger.copy(builder); + StarkVerifier::::verify_shard( + builder, + &vk, + pcs, + machine, + &mut challenger, + &proof, + false, + ); + + // First shard has a "CPU" constraint. + { + builder.if_eq(shard, C::N::one()).then(|builder| { + builder.assert_var_eq(contains_cpu, C::N::one()); + }); + } - // Assert that the committed value digests are all the same. - for (word, current_word) in committed_value_digest - .iter() - .zip_eq(public_values.committed_value_digest.iter()) + // CPU log degree bound check constraints. { - for (byte, current_byte) in word.0.iter().zip_eq(current_word.0.iter()) { - builder.assert_felt_eq(*byte, *current_byte); + for (i, chip) in machine.chips().iter().enumerate() { + if chip.name() == "CPU" { + builder.if_eq(contains_cpu, C::N::one()).then(|builder| { + let index = builder.get(&proof.sorted_idxs, i); + let cpu_log_degree = + builder.get(&proof.opened_values.chips, index).log_degree; + let cpu_log_degree_lt_max: Var<_> = builder.eval(C::N::zero()); + builder + .range(0, MAX_CPU_LOG_DEGREE + 1) + .for_each(|j, builder| { + builder.if_eq(j, cpu_log_degree).then(|builder| { + builder.assign(cpu_log_degree_lt_max, C::N::one()); + }); + }); + builder.assert_var_eq(cpu_log_degree_lt_max, C::N::one()); + }); + } } } - // Assert that the start_pc of the proof is equal to the current pc. - builder.assert_felt_eq(current_pc, public_values.start_pc); - // Assert that the start_pc is not zero (this means program has halted in a non-last - // shard). - builder.assert_felt_ne(public_values.start_pc, C::F::zero()); + // Shard constraints. + { + // Assert that the shard of the proof is equal to the current shard. + builder.assert_felt_eq(current_shard, public_values.shard); - // Assert that the shard of the proof is equal to the current shard. - builder.assert_felt_eq(current_shard, public_values.shard); + // Increment the current shard by one. + builder.assign(current_shard, current_shard + C::F::one()); + } - // Assert that exit code is the same for all proofs. - builder.assert_felt_eq(exit_code, public_values.exit_code); + // Execution shard constraints. + let execution_shard = felt2var(builder, public_values.execution_shard); + { + // Assert that the shard of the proof is equal to the current shard. + builder.if_eq(contains_cpu, C::N::one()).then(|builder| { + builder.assert_felt_eq(current_execution_shard, public_values.execution_shard); + }); - // Assert that the exit code is zero (success) for all proofs. - builder.assert_felt_eq(exit_code, C::F::zero()); + // If the shard has a "CPU" chip, then the execution shard should be incremented by 1. + builder.if_eq(contains_cpu, C::N::one()).then(|builder| { + builder.assign( + current_execution_shard, + current_execution_shard + C::F::one(), + ); + }); + } - // Assert that the deferred proof digest is the same for all proofs. - for (digest, current_digest) in deferred_proofs_digest - .iter() - .zip_eq(public_values.deferred_proofs_digest.iter()) + // Program counter constraints. { - builder.assert_felt_eq(*digest, *current_digest); + // If it's the first shard (which is the first execution shard), then the start_pc + // should be vk.pc_start. + builder.if_eq(shard, C::N::one()).then(|builder| { + builder.assert_felt_eq(public_values.start_pc, vk.pc_start); + }); + + // Assert that the start_pc of the proof is equal to the current pc. + builder.assert_felt_eq(current_pc, public_values.start_pc); + + // If it's not a shard with "CPU", then assert that the start_pc equals the next_pc. + builder.if_ne(contains_cpu, C::N::one()).then(|builder| { + builder.assert_felt_eq(public_values.start_pc, public_values.next_pc); + }); + + // If it's a shard with "CPU", then assert that the start_pc is not zero. + builder.if_eq(contains_cpu, C::N::one()).then(|builder| { + builder.assert_felt_ne(public_values.start_pc, C::F::zero()); + }); + + // Update current_pc to be the end_pc of the current proof. + builder.assign(current_pc, public_values.next_pc); } - // Update the loop variables: the reconstruct challenger, cumulative sum, shard number, - // and program counter. + // Exit code constraints. + { + // Assert that the exit code is zero (success) for all proofs. + builder.assert_felt_eq(exit_code, C::F::zero()); + } - // Increment the shard index by one. - builder.assign(current_shard, current_shard + C::F::one()); + // Memory initialization & finalization constraints. + { + // Assert that `init_addr_bits` and `finalize_addr_bits` are zero for the first execution shard. + builder.if_eq(execution_shard, C::N::one()).then(|builder| { + // Assert that the MemoryInitialize address bits are zero. + for bit in current_init_addr_bits.iter() { + builder.assert_felt_eq(*bit, C::F::zero()); + } + + // Assert that the MemoryFinalize address bits are zero. + for bit in current_finalize_addr_bits.iter() { + builder.assert_felt_eq(*bit, C::F::zero()); + } + }); + + // Assert that the MemoryInitialize address bits match the current loop variable. + for (bit, current_bit) in current_init_addr_bits + .iter() + .zip_eq(public_values.previous_init_addr_bits.iter()) + { + builder.assert_felt_eq(*bit, *current_bit); + } + + // Assert that the MemoryFinalize address bits match the current loop variable. + for (bit, current_bit) in current_finalize_addr_bits + .iter() + .zip_eq(public_values.previous_finalize_addr_bits.iter()) + { + builder.assert_felt_eq(*bit, *current_bit); + } + + // Assert that if MemoryInit is not present, then the address bits are the same. + builder + .if_ne(contains_memory_init, C::N::one()) + .then(|builder| { + for (prev_bit, last_bit) in public_values + .previous_init_addr_bits + .iter() + .zip_eq(public_values.last_init_addr_bits.iter()) + { + builder.assert_felt_eq(*prev_bit, *last_bit); + } + }); + + // Assert that if MemoryFinalize is not present, then the address bits are the same. + builder + .if_ne(contains_memory_finalize, C::N::one()) + .then(|builder| { + for (prev_bit, last_bit) in public_values + .previous_finalize_addr_bits + .iter() + .zip_eq(public_values.last_finalize_addr_bits.iter()) + { + builder.assert_felt_eq(*prev_bit, *last_bit); + } + }); + + // Update the MemoryInitialize address bits. + for (bit, pub_bit) in current_init_addr_bits + .iter() + .zip(public_values.last_init_addr_bits.iter()) + { + builder.assign(*bit, *pub_bit); + } + + // Update the MemoryFinalize address bits. + for (bit, pub_bit) in current_finalize_addr_bits + .iter() + .zip(public_values.last_finalize_addr_bits.iter()) + { + builder.assign(*bit, *pub_bit); + } + } + + // Digest constraints. + { + // If `commited_value_digest` is not zero, then `public_values.commited_value_digest + // should be the current value. + let is_zero: Var<_> = builder.eval(C::N::one()); + #[allow(clippy::needless_range_loop)] + for i in 0..committed_value_digest.len() { + for j in 0..WORD_SIZE { + let d = felt2var(builder, committed_value_digest[i][j]); + builder.if_ne(d, C::N::zero()).then(|builder| { + builder.assign(is_zero, C::N::zero()); + }); + } + } + builder.if_eq(is_zero, C::N::zero()).then(|builder| { + #[allow(clippy::needless_range_loop)] + for i in 0..committed_value_digest.len() { + for j in 0..WORD_SIZE { + builder.assert_felt_eq( + committed_value_digest[i][j], + public_values.committed_value_digest[i][j], + ); + } + } + }); + + // If it's not a shard with "CPU", then the committed value digest should not change. + builder.if_ne(contains_cpu, C::N::one()).then(|builder| { + #[allow(clippy::needless_range_loop)] + for i in 0..committed_value_digest.len() { + for j in 0..WORD_SIZE { + builder.assert_felt_eq( + committed_value_digest[i][j], + public_values.committed_value_digest[i][j], + ); + } + } + }); + + // Update the committed value digest. + #[allow(clippy::needless_range_loop)] + for i in 0..committed_value_digest.len() { + for j in 0..WORD_SIZE { + builder.assign( + committed_value_digest[i][j], + public_values.committed_value_digest[i][j], + ); + } + } + + // If `deferred_proofs_digest` is not zero, then `public_values.deferred_proofs_digest + // should be the current value. + let is_zero: Var<_> = builder.eval(C::N::one()); + #[allow(clippy::needless_range_loop)] + for i in 0..deferred_proofs_digest.len() { + let d = felt2var(builder, deferred_proofs_digest[i]); + builder.if_ne(d, C::N::zero()).then(|builder| { + builder.assign(is_zero, C::N::zero()); + }); + } + builder.if_eq(is_zero, C::N::zero()).then(|builder| { + #[allow(clippy::needless_range_loop)] + for i in 0..deferred_proofs_digest.len() { + builder.assert_felt_eq( + deferred_proofs_digest[i], + public_values.deferred_proofs_digest[i], + ); + } + }); + + // If it's not a shard with "CPU", then the deferred proofs digest should not change. + builder.if_ne(contains_cpu, C::N::one()).then(|builder| { + #[allow(clippy::needless_range_loop)] + for i in 0..deferred_proofs_digest.len() { + builder.assert_felt_eq( + deferred_proofs_digest[i], + public_values.deferred_proofs_digest[i], + ); + } + }); + + // Update the deferred proofs digest. + #[allow(clippy::needless_range_loop)] + for i in 0..deferred_proofs_digest.len() { + builder.assign( + deferred_proofs_digest[i], + public_values.deferred_proofs_digest[i], + ); + } + } + + // Verify that the number of shards is not too large. + builder.range_check_f(public_values.shard, 16); // Update the reconstruct challenger. - reconstruct_challenger.observe(builder, proof.commitment.main_commit); + reconstruct_challenger.observe(builder, proof.commitment.main_commit.clone()); for j in 0..machine.num_pv_elts() { let element = builder.get(&proof.public_values, j); reconstruct_challenger.observe(builder, element); } - // Update current_pc to be the end_pc of the current proof. - builder.assign(current_pc, public_values.next_pc); - // Cumulative sum is updated by sums of all chips. let opened_values = proof.opened_values.chips; builder @@ -312,59 +560,66 @@ where }); // Write all values to the public values struct and commit to them. + { + // Compute the vk digest. + let vk_digest = hash_vkey(builder, &vk); + let vk_digest: [Felt<_>; DIGEST_SIZE] = array::from_fn(|i| builder.get(&vk_digest, i)); + + // Collect the public values for challengers. + let initial_challenger_public_values = + get_challenger_public_values(builder, &initial_reconstruct_challenger); + let final_challenger_public_values = + get_challenger_public_values(builder, &reconstruct_challenger); + + // Collect the cumulative sum. + let cumulative_sum_array = builder.ext2felt(cumulative_sum); + let cumulative_sum_array = array::from_fn(|i| builder.get(&cumulative_sum_array, i)); + + // Collect the deferred proof digests. + let zero: Felt<_> = builder.eval(C::F::zero()); + let start_deferred_digest = [zero; POSEIDON_NUM_WORDS]; + let end_deferred_digest = [zero; POSEIDON_NUM_WORDS]; + + // Collect the is_complete flag. + let is_complete_felt = var2felt(builder, is_complete); + + // Initialize the public values we will commit to. + let mut recursion_public_values_stream = [zero; RECURSIVE_PROOF_NUM_PV_ELTS]; + let recursion_public_values: &mut RecursionPublicValues<_> = + recursion_public_values_stream.as_mut_slice().borrow_mut(); + recursion_public_values.committed_value_digest = committed_value_digest; + recursion_public_values.deferred_proofs_digest = deferred_proofs_digest; + recursion_public_values.start_pc = start_pc; + recursion_public_values.next_pc = current_pc; + recursion_public_values.start_shard = initial_shard; + recursion_public_values.next_shard = current_shard; + recursion_public_values.start_execution_shard = initial_execution_shard; + recursion_public_values.next_execution_shard = current_execution_shard; + recursion_public_values.previous_init_addr_bits = initial_previous_init_addr_bits; + recursion_public_values.last_init_addr_bits = current_init_addr_bits; + recursion_public_values.previous_finalize_addr_bits = + initial_previous_finalize_addr_bits; + recursion_public_values.last_finalize_addr_bits = current_finalize_addr_bits; + recursion_public_values.sp1_vk_digest = vk_digest; + recursion_public_values.leaf_challenger = leaf_challenger_public_values; + recursion_public_values.start_reconstruct_challenger = initial_challenger_public_values; + recursion_public_values.end_reconstruct_challenger = final_challenger_public_values; + recursion_public_values.cumulative_sum = cumulative_sum_array; + recursion_public_values.start_reconstruct_deferred_digest = start_deferred_digest; + recursion_public_values.end_reconstruct_deferred_digest = end_deferred_digest; + recursion_public_values.exit_code = exit_code; + recursion_public_values.is_complete = is_complete_felt; + + // If the proof represents a complete proof, make completeness assertions. + // + // *Remark*: In this program, this only happends if there is one shard and the program has + // no deferred proofs to verify. However, the completeness check is independent of these + // facts. + builder.if_eq(is_complete, C::N::one()).then(|builder| { + assert_complete(builder, recursion_public_values, &reconstruct_challenger) + }); - // Compute vk digest. - let vk_digest = hash_vkey(builder, &vk); - let vk_digest: [Felt<_>; DIGEST_SIZE] = array::from_fn(|i| builder.get(&vk_digest, i)); - - // Collect values for challenges. - let initial_challenger_public_values = - get_challenger_public_values(builder, &initial_reconstruct_challenger); - let final_challenger_public_values = - get_challenger_public_values(builder, &reconstruct_challenger); - - let cumulative_sum_arrray = builder.ext2felt(cumulative_sum); - let cumulative_sum_arrray = array::from_fn(|i| builder.get(&cumulative_sum_arrray, i)); - - let zero: Felt<_> = builder.eval(C::F::zero()); - - // Initialize the public values we will commit to. - let mut recursion_public_values_stream = [zero; RECURSIVE_PROOF_NUM_PV_ELTS]; - - let recursion_public_values: &mut RecursionPublicValues<_> = - recursion_public_values_stream.as_mut_slice().borrow_mut(); - - let start_deferred_digest = [zero; POSEIDON_NUM_WORDS]; - let end_deferred_digest = [zero; POSEIDON_NUM_WORDS]; - - let is_complete_felt = var2felt(builder, is_complete); - let total_core_shards_felt = var2felt(builder, total_core_shards); - - recursion_public_values.committed_value_digest = committed_value_digest; - recursion_public_values.deferred_proofs_digest = deferred_proofs_digest; - recursion_public_values.start_pc = start_pc; - recursion_public_values.next_pc = current_pc; - recursion_public_values.start_shard = initial_shard; - recursion_public_values.next_shard = current_shard; - recursion_public_values.sp1_vk_digest = vk_digest; - recursion_public_values.leaf_challenger = leaf_challenger_public_values; - recursion_public_values.start_reconstruct_challenger = initial_challenger_public_values; - recursion_public_values.end_reconstruct_challenger = final_challenger_public_values; - recursion_public_values.cumulative_sum = cumulative_sum_arrray; - recursion_public_values.start_reconstruct_deferred_digest = start_deferred_digest; - recursion_public_values.end_reconstruct_deferred_digest = end_deferred_digest; - recursion_public_values.is_complete = is_complete_felt; - recursion_public_values.total_core_shards = total_core_shards_felt; - - // If the proof represents a complete proof, make completeness assertions. - // - // *Remark*: In this program, this only happends if there is one shard and the program has - // no deferred proofs to verify. However, the completeness check is independent of these - // facts. - builder.if_eq(is_complete, C::N::one()).then(|builder| { - assert_complete(builder, recursion_public_values, &reconstruct_challenger) - }); - - commit_public_values(builder, recursion_public_values); + commit_public_values(builder, recursion_public_values); + } } } diff --git a/recursion/program/src/machine/deferred.rs b/recursion/program/src/machine/deferred.rs index 1c6ac7e1b0..9dfef395c4 100644 --- a/recursion/program/src/machine/deferred.rs +++ b/recursion/program/src/machine/deferred.rs @@ -11,6 +11,7 @@ use sp1_core::air::{Word, POSEIDON_NUM_WORDS, PV_DIGEST_NUM_WORDS}; use sp1_core::stark::StarkMachine; use sp1_core::stark::{Com, RiscvAir, ShardProof, StarkGenericConfig, StarkVerifyingKey}; use sp1_core::utils::BabyBearPoseidon2; +use sp1_primitives::types::RecursionProgramType; use sp1_recursion_compiler::config::InnerConfig; use sp1_recursion_compiler::ir::{Array, Builder, Config, Felt, Var}; use sp1_recursion_compiler::prelude::DslVariable; @@ -54,7 +55,9 @@ where pub leaf_challenger: SC::Challenger, pub end_pc: SC::Val, pub end_shard: SC::Val, - pub total_core_shards: usize, + pub end_execution_shard: SC::Val, + pub init_addr_bits: [SC::Val; 32], + pub finalize_addr_bits: [SC::Val; 32], } /// A variable version of the [SP1DeferredMemoryLayout] struct. @@ -74,7 +77,9 @@ pub struct SP1DeferredMemoryLayoutVariable { pub leaf_challenger: DuplexChallengerVariable, pub end_pc: Felt, pub end_shard: Felt, - pub total_core_shards: Var, + pub end_execution_shard: Felt, + pub init_addr_bits: Array>, + pub finalize_addr_bits: Array>, } impl SP1DeferredVerifier @@ -83,7 +88,7 @@ where { /// Create a new instance of the program for the [BabyBearPoseidon2] config. pub fn build(machine: &StarkMachine) -> RecursionProgram { - let mut builder = Builder::::default(); + let mut builder = Builder::::new(RecursionProgramType::Deferred); let input: SP1DeferredMemoryLayoutVariable<_> = builder.uninit(); SP1DeferredMemoryLayout::::witness(&input, &mut builder); @@ -131,13 +136,15 @@ where proofs, start_reconstruct_deferred_digest, is_complete, - total_core_shards, sp1_vk, committed_value_digest, deferred_proofs_digest, leaf_challenger, end_pc, end_shard, + end_execution_shard, + init_addr_bits, + finalize_addr_bits, } = input; // Initialize the values for the aggregated public output as all zeros. @@ -191,7 +198,6 @@ where } // Verify the proof. - let one_var = builder.constant(C::N::one()); StarkVerifier::::verify_shard( builder, &compress_vk, @@ -199,7 +205,7 @@ where machine, &mut challenger, &proof, - one_var, + true, ); // Load the public values from the proof. @@ -263,6 +269,15 @@ where deferred_public_values.next_pc = end_pc; deferred_public_values.start_shard = end_shard; deferred_public_values.next_shard = end_shard; + deferred_public_values.start_execution_shard = end_execution_shard; + deferred_public_values.next_execution_shard = end_execution_shard; + // Set the init and finalize address bits to be the hintred values. + let init_addr_bits = core::array::from_fn(|i| builder.get(&init_addr_bits, i)); + deferred_public_values.previous_init_addr_bits = init_addr_bits; + deferred_public_values.last_init_addr_bits = init_addr_bits; + let finalize_addr_bits = core::array::from_fn(|i| builder.get(&finalize_addr_bits, i)); + deferred_public_values.previous_finalize_addr_bits = finalize_addr_bits; + deferred_public_values.last_finalize_addr_bits = finalize_addr_bits; // Set the sp1_vk_digest to be the hitned value. let sp1_vk_digest = hash_vkey(builder, &sp1_vk); @@ -294,7 +309,6 @@ where // Set the is_complete flag. deferred_public_values.is_complete = var2felt(builder, is_complete); - deferred_public_values.total_core_shards = var2felt(builder, total_core_shards); commit_public_values(builder, deferred_public_values); } diff --git a/recursion/program/src/machine/mod.rs b/recursion/program/src/machine/mod.rs index 23235b260f..38e17690f8 100644 --- a/recursion/program/src/machine/mod.rs +++ b/recursion/program/src/machine/mod.rs @@ -9,430 +9,3 @@ pub use core::*; pub use deferred::*; pub use root::*; pub use utils::*; - -#[cfg(test)] -mod tests { - - use p3_baby_bear::BabyBear; - use p3_challenger::CanObserve; - use p3_maybe_rayon::prelude::*; - use sp1_core::stark::{MachineVerificationError, RiscvAir, StarkGenericConfig}; - use sp1_core::utils::{BabyBearPoseidon2, SP1CoreOpts}; - use sp1_core::{ - io::SP1Stdin, - runtime::Program, - stark::{Challenge, LocalProver}, - }; - use sp1_recursion_compiler::config::InnerConfig; - use sp1_recursion_core::{ - runtime::Runtime, - stark::{config::BabyBearPoseidon2Outer, RecursionAir}, - }; - - use crate::hints::Hintable; - - use super::*; - - enum Test { - Recursion, - Reduce, - Compress, - Wrap, - } - - fn test_sp1_recursive_machine_verify(program: Program, batch_size: usize, test: Test) { - type SC = BabyBearPoseidon2; - type F = BabyBear; - type EF = Challenge; - - sp1_core::utils::setup_logger(); - - let machine = RiscvAir::machine(SC::default()); - let (_, vk) = machine.setup(&program); - - // Make the recursion program. - let recursive_program = SP1RecursiveVerifier::::build(&machine); - let recursive_config = SC::default(); - type A = RecursionAir; - let recursive_machine = A::machine(recursive_config.clone()); - let (rec_pk, rec_vk) = recursive_machine.setup(&recursive_program); - - // Make the deferred program. - let deferred_program = SP1DeferredVerifier::::build(&recursive_machine); - let (_, deferred_vk) = recursive_machine.setup(&deferred_program); - - // Make the compress program. - let reduce_program = SP1CompressVerifier::::build( - &recursive_machine, - &rec_vk, - &deferred_vk, - ); - - let (reduce_pk, compress_vk) = recursive_machine.setup(&reduce_program); - - // Make the compress program. - let compress_machine = RecursionAir::<_, 9>::machine(SC::compressed()); - let compress_program = - SP1RootVerifier::::build(&recursive_machine, &compress_vk, true); - let (compress_pk, compress_vk) = compress_machine.setup(&compress_program); - - // Make the wrap program. - let wrap_machine = RecursionAir::<_, 5>::machine(BabyBearPoseidon2Outer::default()); - let wrap_program = - SP1RootVerifier::::build(&compress_machine, &compress_vk, false); - - let mut challenger = machine.config().challenger(); - let time = std::time::Instant::now(); - let (proof, _) = sp1_core::utils::prove( - program, - &SP1Stdin::new(), - SC::default(), - SP1CoreOpts::default(), - ) - .unwrap(); - machine.verify(&vk, &proof, &mut challenger).unwrap(); - let total_core_shards = proof.shard_proofs.len(); - tracing::info!("Proof generated successfully"); - let elapsed = time.elapsed(); - tracing::info!("Execution proof time: {:?}", elapsed); - - // Get the and leaf challenger. - let mut leaf_challenger = machine.config().challenger(); - vk.observe_into(&mut leaf_challenger); - proof.shard_proofs.iter().for_each(|proof| { - leaf_challenger.observe(proof.commitment.main_commit); - leaf_challenger.observe_slice(&proof.public_values[0..machine.num_pv_elts()]); - }); - // Make sure leaf challenger is not mutable anymore. - let leaf_challenger = leaf_challenger; - - let mut layouts = Vec::new(); - - let mut reconstruct_challenger = machine.config().challenger(); - vk.observe_into(&mut reconstruct_challenger); - - let is_complete = proof.shard_proofs.len() == 1; - for batch in proof.shard_proofs.chunks(batch_size) { - let proofs = batch.to_vec(); - - layouts.push(SP1RecursionMemoryLayout { - vk: &vk, - machine: &machine, - shard_proofs: proofs, - leaf_challenger: &leaf_challenger, - initial_reconstruct_challenger: reconstruct_challenger.clone(), - is_complete, - total_core_shards, - }); - - for proof in batch.iter() { - reconstruct_challenger.observe(proof.commitment.main_commit); - reconstruct_challenger - .observe_slice(&proof.public_values[0..machine.num_pv_elts()]); - } - } - - assert_eq!( - reconstruct_challenger.sponge_state, - leaf_challenger.sponge_state - ); - assert_eq!( - reconstruct_challenger.input_buffer, - leaf_challenger.input_buffer - ); - assert_eq!( - reconstruct_challenger.output_buffer, - leaf_challenger.output_buffer - ); - - // Run the recursion programs. - let mut records = Vec::new(); - - for layout in layouts { - let mut runtime = - Runtime::::new(&recursive_program, machine.config().perm.clone()); - - let mut witness_stream = Vec::new(); - witness_stream.extend(layout.write()); - - runtime.witness_stream = witness_stream.into(); - runtime.run(); - runtime.print_stats(); - - records.push(runtime.record); - } - - // Prove all recursion programs and verify the recursive proofs. - - // Make the recursive proofs. - let time = std::time::Instant::now(); - let recursive_proofs = records - .into_par_iter() - .map(|record| { - let mut recursive_challenger = recursive_machine.config().challenger(); - recursive_machine.prove::>( - &rec_pk, - record, - &mut recursive_challenger, - SP1CoreOpts::recursion(), - ) - }) - .collect::>(); - let elapsed = time.elapsed(); - tracing::info!("Recursive first layer proving time: {:?}", elapsed); - - // Verify the recursive proofs. - for rec_proof in recursive_proofs.iter() { - let mut recursive_challenger = recursive_machine.config().challenger(); - let result = recursive_machine.verify(&rec_vk, rec_proof, &mut recursive_challenger); - - match result { - Ok(_) => tracing::info!("Proof verified successfully"), - Err(MachineVerificationError::NonZeroCumulativeSum) => { - tracing::info!("Proof verification failed: NonZeroCumulativeSum") - } - e => panic!("Proof verification failed: {:?}", e), - } - } - if let Test::Recursion = test { - return; - } - - tracing::info!("Recursive proofs verified successfully"); - - // Chain all the individual shard proofs. - let mut recursive_proofs = recursive_proofs - .into_iter() - .flat_map(|proof| proof.shard_proofs) - .collect::>(); - - // Iterate over the recursive proof batches until there is one proof remaining. - let mut is_first_layer = true; - let mut is_complete; - let time = std::time::Instant::now(); - loop { - tracing::info!("Recursive proofs: {}", recursive_proofs.len()); - is_complete = recursive_proofs.len() <= batch_size; - recursive_proofs = recursive_proofs - .par_chunks(batch_size) - .map(|batch| { - let kind = if is_first_layer { - ReduceProgramType::Core - } else { - ReduceProgramType::Reduce - }; - let kinds = batch.iter().map(|_| kind).collect::>(); - let input = SP1ReduceMemoryLayout { - compress_vk: &compress_vk, - recursive_machine: &recursive_machine, - shard_proofs: batch.to_vec(), - kinds, - is_complete, - total_core_shards, - }; - - let mut runtime = Runtime::::new( - &reduce_program, - recursive_machine.config().perm.clone(), - ); - - let mut witness_stream = Vec::new(); - witness_stream.extend(input.write()); - - runtime.witness_stream = witness_stream.into(); - runtime.run(); - runtime.print_stats(); - - let mut recursive_challenger = recursive_machine.config().challenger(); - let mut proof = recursive_machine.prove::>( - &reduce_pk, - runtime.record, - &mut recursive_challenger, - SP1CoreOpts::recursion(), - ); - let mut recursive_challenger = recursive_machine.config().challenger(); - let result = - recursive_machine.verify(&compress_vk, &proof, &mut recursive_challenger); - - match result { - Ok(_) => tracing::info!("Proof verified successfully"), - Err(MachineVerificationError::NonZeroCumulativeSum) => { - tracing::info!("Proof verification failed: NonZeroCumulativeSum") - } - e => panic!("Proof verification failed: {:?}", e), - } - - assert_eq!(proof.shard_proofs.len(), 1); - proof.shard_proofs.pop().unwrap() - }) - .collect(); - is_first_layer = false; - - if recursive_proofs.len() == 1 { - break; - } - } - let elapsed = time.elapsed(); - tracing::info!("Reduction successful, time: {:?}", elapsed); - if let Test::Reduce = test { - return; - } - - assert_eq!(recursive_proofs.len(), 1); - let reduce_proof = recursive_proofs.pop().unwrap(); - - // Make the compress proof. - let input = SP1RootMemoryLayout { - machine: &recursive_machine, - proof: reduce_proof, - is_reduce: true, - }; - - // Run the compress program. - let mut runtime = - Runtime::::new(&compress_program, compress_machine.config().perm.clone()); - - let mut witness_stream = Vec::new(); - witness_stream.extend(input.write()); - - runtime.witness_stream = witness_stream.into(); - runtime.run(); - runtime.print_stats(); - tracing::info!("Compress program executed successfully"); - - // Prove the compress program. - let mut compress_challenger = compress_machine.config().challenger(); - - let time = std::time::Instant::now(); - let mut compress_proof = compress_machine.prove::>( - &compress_pk, - runtime.record, - &mut compress_challenger, - SP1CoreOpts::default(), - ); - let elapsed = time.elapsed(); - tracing::info!("Compress proving time: {:?}", elapsed); - let mut compress_challenger = compress_machine.config().challenger(); - let result = - compress_machine.verify(&compress_vk, &compress_proof, &mut compress_challenger); - match result { - Ok(_) => tracing::info!("Proof verified successfully"), - Err(MachineVerificationError::NonZeroCumulativeSum) => { - tracing::info!("Proof verification failed: NonZeroCumulativeSum") - } - e => panic!("Proof verification failed: {:?}", e), - } - - if let Test::Compress = test { - return; - } - - // Run and prove the wrap program. - - let (wrap_pk, wrap_vk) = wrap_machine.setup(&wrap_program); - - let compress_proof = compress_proof.shard_proofs.pop().unwrap(); - let input = SP1RootMemoryLayout { - machine: &compress_machine, - proof: compress_proof, - is_reduce: false, - }; - - // Run the compress program. - let mut runtime = - Runtime::::new(&wrap_program, compress_machine.config().perm.clone()); - - let mut witness_stream = Vec::new(); - witness_stream.extend(input.write()); - - runtime.witness_stream = witness_stream.into(); - runtime.run(); - runtime.print_stats(); - tracing::info!("Wrap program executed successfully"); - - // Prove the wrap program. - let mut wrap_challenger = wrap_machine.config().challenger(); - let time = std::time::Instant::now(); - let wrap_proof = wrap_machine.prove::>( - &wrap_pk, - runtime.record, - &mut wrap_challenger, - SP1CoreOpts::recursion(), - ); - let elapsed = time.elapsed(); - tracing::info!("Wrap proving time: {:?}", elapsed); - let mut wrap_challenger = wrap_machine.config().challenger(); - let result = wrap_machine.verify(&wrap_vk, &wrap_proof, &mut wrap_challenger); - match result { - Ok(_) => tracing::info!("Proof verified successfully"), - Err(MachineVerificationError::NonZeroCumulativeSum) => { - tracing::info!("Proof verification failed: NonZeroCumulativeSum") - } - e => panic!("Proof verification failed: {:?}", e), - } - tracing::info!("Wrapping successful"); - } - - #[test] - fn test_sp1_recursive_machine_verify_fibonacci() { - let elf = include_bytes!("../../../../tests/fibonacci/elf/riscv32im-succinct-zkvm-elf"); - test_sp1_recursive_machine_verify(Program::from(elf), 1, Test::Recursion) - } - - #[test] - #[ignore] - fn test_sp1_reduce_machine_verify_fibonacci() { - let elf = include_bytes!("../../../../tests/fibonacci/elf/riscv32im-succinct-zkvm-elf"); - test_sp1_recursive_machine_verify(Program::from(elf), 1, Test::Reduce) - } - - #[test] - #[ignore] - fn test_sp1_compress_machine_verify_fibonacci() { - let elf = include_bytes!("../../../../tests/fibonacci/elf/riscv32im-succinct-zkvm-elf"); - test_sp1_recursive_machine_verify(Program::from(elf), 1, Test::Compress) - } - - #[test] - #[ignore] - fn test_sp1_wrap_machine_verify_fibonacci() { - let elf = include_bytes!("../../../../tests/fibonacci/elf/riscv32im-succinct-zkvm-elf"); - test_sp1_recursive_machine_verify(Program::from(elf), 1, Test::Wrap) - } - - #[test] - #[ignore] - fn test_sp1_reduce_machine_verify_tendermint() { - let elf = include_bytes!( - "../../../../tests/tendermint-benchmark/elf/riscv32im-succinct-zkvm-elf" - ); - test_sp1_recursive_machine_verify(Program::from(elf), 2, Test::Reduce) - } - - #[test] - #[ignore] - fn test_sp1_recursive_machine_verify_tendermint() { - let elf = include_bytes!( - "../../../../tests/tendermint-benchmark/elf/riscv32im-succinct-zkvm-elf" - ); - test_sp1_recursive_machine_verify(Program::from(elf), 2, Test::Recursion) - } - - #[test] - #[ignore] - fn test_sp1_compress_machine_verify_tendermint() { - let elf = include_bytes!( - "../../../../tests/tendermint-benchmark/elf/riscv32im-succinct-zkvm-elf" - ); - test_sp1_recursive_machine_verify(Program::from(elf), 2, Test::Compress) - } - - #[test] - #[ignore] - fn test_sp1_wrap_machine_verify_tendermint() { - let elf = include_bytes!( - "../../../../tests/tendermint-benchmark/elf/riscv32im-succinct-zkvm-elf" - ); - test_sp1_recursive_machine_verify(Program::from(elf), 2, Test::Wrap) - } -} diff --git a/recursion/program/src/machine/root.rs b/recursion/program/src/machine/root.rs index e5a9613d08..6662c2b8e2 100644 --- a/recursion/program/src/machine/root.rs +++ b/recursion/program/src/machine/root.rs @@ -8,6 +8,7 @@ use sp1_core::air::MachineAir; use sp1_core::stark::StarkMachine; use sp1_core::stark::{Com, ShardProof, StarkGenericConfig, StarkVerifyingKey}; use sp1_core::utils::BabyBearPoseidon2; +use sp1_primitives::types::RecursionProgramType; use sp1_recursion_compiler::config::InnerConfig; use sp1_recursion_compiler::ir::{Builder, Config, Felt, Var}; use sp1_recursion_compiler::prelude::DslVariable; @@ -52,9 +53,15 @@ where pub fn build( machine: &StarkMachine, vk: &StarkVerifyingKey, - is_compress: bool, + program_type: RecursionProgramType, ) -> RecursionProgram { - let mut builder = Builder::::default(); + assert!(matches!( + program_type, + RecursionProgramType::Shrink | RecursionProgramType::Wrap + )); + + let mut builder = Builder::::new(program_type); + let proof: ShardProofVariable<_> = builder.uninit(); ShardProofHint::::witness(&proof, &mut builder); @@ -62,7 +69,7 @@ where config: const_fri_config(&mut builder, machine.config().pcs().fri_config()), }; - SP1RootVerifier::verify(&mut builder, &pcs, machine, vk, &proof, is_compress); + SP1RootVerifier::verify(&mut builder, &pcs, machine, vk, &proof); builder.compile_program() } @@ -89,7 +96,6 @@ where machine: &StarkMachine, vk: &StarkVerifyingKey, proof: &ShardProofVariable, - is_compress: bool, ) { // Get the verifying key info from the vk. let vk = proof_data_from_vk(builder, vk, machine); @@ -107,7 +113,6 @@ where challenger.observe(builder, element); } // verify proof. - let one = builder.constant(C::N::one()); StarkVerifier::::verify_shard( builder, &vk, @@ -115,7 +120,7 @@ where machine, &mut challenger, proof, - one, + true, ); // Get the public inputs from the proof. @@ -135,9 +140,9 @@ where // checking the `is_complete` flag in this program. builder.assert_felt_eq(public_values.is_complete, C::F::one()); - // If the proof is a compress proof, assert that the vk is the same as the compress vk from - // the public values. - if is_compress { + // If this is a Shrink program (when it's verifying a compress proof), then assert that the + // vk is the same as the compress vk from the public values. + if matches!(builder.program_type, RecursionProgramType::Shrink) { let vk_digest = hash_vkey(builder, &vk); for (i, reduce_digest_elem) in public_values.compress_vk_digest.iter().enumerate() { let vk_digest_elem = builder.get(&vk_digest, i); diff --git a/recursion/program/src/machine/utils.rs b/recursion/program/src/machine/utils.rs index 514fe08337..424d1a229d 100644 --- a/recursion/program/src/machine/utils.rs +++ b/recursion/program/src/machine/utils.rs @@ -34,40 +34,40 @@ pub(crate) fn assert_complete( next_pc, start_shard, next_shard, + start_execution_shard, + next_execution_shard, cumulative_sum, start_reconstruct_deferred_digest, end_reconstruct_deferred_digest, leaf_challenger, - total_core_shards, .. } = public_values; - // Assert that `end_pc` is equal to zero (so program execution has completed) + // Assert that `next_pc` is equal to zero (so program execution has completed) builder.assert_felt_eq(*next_pc, C::F::zero()); - // Assert that the start shard is equal to 1. + // Assert that start shard is equal to 1. builder.assert_felt_eq(*start_shard, C::F::one()); - // Assert that total_core_shards is correct by ensuring it equals next_shard - 1. - builder.assert_felt_eq(*total_core_shards, *next_shard - C::F::one()); + // Assert that the next shard is not equal to one. This guarantees that there is at least one shard. + builder.assert_felt_ne(*next_shard, C::F::one()); - // The challenger has been fully verified. + // Assert that the start execution shard is equal to 1. + builder.assert_felt_eq(*start_execution_shard, C::F::one()); - // The start_reconstruct_challenger should be the same as an empty challenger observing the - // verifier key and the start pc. This was already verified when verifying the leaf proofs so - // there is no need to assert it here. + // Assert that next shard is not equal to one. This guarantees that there is at least one shard + // with CPU. + builder.assert_felt_ne(*next_execution_shard, C::F::one()); // Assert that the end reconstruct challenger is equal to the leaf challenger. assert_challenger_eq_pv(builder, end_reconstruct_challenger, *leaf_challenger); - // The deferred digest has been fully reconstructed. - - // The start reconstruct digest should be zero. + // The start reconstruct deffered digest should be zero. for start_digest_word in start_reconstruct_deferred_digest { builder.assert_felt_eq(*start_digest_word, C::F::zero()); } - // The end reconstruct digest should be equal to the deferred proofs digest. + // The end reconstruct deffered digest should be equal to the deferred proofs digest. for (end_digest_word, deferred_digest_word) in end_reconstruct_deferred_digest .iter() .zip_eq(deferred_proofs_digest.iter()) @@ -129,7 +129,7 @@ where } /// Calculates the digest of the recursion public values. -pub(crate) fn calculate_public_values_digest( +fn calculate_public_values_digest( builder: &mut Builder, public_values: &RecursionPublicValues>, ) -> Array> { diff --git a/recursion/program/src/stark.rs b/recursion/program/src/stark.rs index 4daa1f2561..63a7438c7d 100644 --- a/recursion/program/src/stark.rs +++ b/recursion/program/src/stark.rs @@ -3,8 +3,6 @@ use p3_commit::TwoAdicMultiplicativeCoset; use p3_field::AbstractField; use p3_field::TwoAdicField; use sp1_core::air::MachineAir; -use sp1_core::air::PublicValues; -use sp1_core::air::Word; use sp1_core::stark::Com; use sp1_core::stark::GenericVerifierConstraintFolder; use sp1_core::stark::ShardProof; @@ -14,6 +12,7 @@ use sp1_core::stark::StarkMachine; use sp1_core::stark::StarkVerifyingKey; use sp1_recursion_compiler::ir::Array; use sp1_recursion_compiler::ir::Ext; +use sp1_recursion_compiler::ir::ExtConst; use sp1_recursion_compiler::ir::SymbolicExt; use sp1_recursion_compiler::ir::SymbolicVar; use sp1_recursion_compiler::ir::Var; @@ -120,7 +119,7 @@ where machine: &StarkMachine, challenger: &mut DuplexChallengerVariable, proof: &ShardProofVariable, - total_shards: Var, + check_cumulative_sum: bool, ) where A: MachineAir + for<'a> Air>, C::F: TwoAdicField, @@ -135,14 +134,6 @@ where .. } = proof; - // Extract public values. - let mut pv_elements = Vec::new(); - for i in 0..machine.num_pv_elts() { - let element = builder.get(&proof.public_values, i); - pv_elements.push(element); - } - let public_values = PublicValues::>, Felt<_>>::from_vec(pv_elements); - let ShardCommitmentVariable { main_commit, permutation_commit, @@ -155,7 +146,6 @@ where challenger.observe(builder, permutation_commit.clone()); - #[allow(unused_variables)] let alpha = challenger.sample_ext(builder); challenger.observe(builder, quotient_commit.clone()); @@ -233,7 +223,6 @@ where builder.set_value(&mut quotient_domains, i, quotient_domain.clone()); // Get trace_opening_points. - let mut trace_points = builder.dyn_array::>(2); let zeta_next = domain.next_point(builder, zeta); builder.set_value(&mut trace_points, 0, zeta); @@ -262,7 +251,6 @@ where builder.set_value(&mut perm_mats, i, perm_mat); // Get the quotient matrices and values. - let qc_domains = quotient_domain.split_domains(builder, log_quotient_degree, quotient_size); @@ -313,42 +301,15 @@ where builder.cycle_tracker("stage-e-verify-constraints"); - let shard_bits = builder.num2bits_f(public_values.shard); - let shard = builder.bits2num_v(&shard_bits); + let num_shard_chips_enabled: Var<_> = builder.eval(C::N::zero()); for (i, chip) in machine.chips().iter().enumerate() { tracing::debug!("verifying constraints for chip: {}", chip.name()); let index = builder.get(&proof.sorted_idxs, i); - if chip.name() == "CPU" { - builder.assert_var_ne(index, C::N::from_canonical_usize(EMPTY)); - } - if chip.preprocessed_width() > 0 { builder.assert_var_ne(index, C::N::from_canonical_usize(EMPTY)); } - if chip.name() == "MemoryInit" { - builder.if_eq(shard, total_shards).then_or_else( - |builder| { - builder.assert_var_ne(index, C::N::from_canonical_usize(EMPTY)); - }, - |builder| { - builder.assert_var_eq(index, C::N::from_canonical_usize(EMPTY)); - }, - ); - } - - if chip.name() == "MemoryFinalize" { - builder.if_eq(shard, total_shards).then_or_else( - |builder| { - builder.assert_var_ne(index, C::N::from_canonical_usize(EMPTY)); - }, - |builder| { - builder.assert_var_eq(index, C::N::from_canonical_usize(EMPTY)); - }, - ); - } - builder .if_ne(index, C::N::from_canonical_usize(EMPTY)) .then(|builder| { @@ -372,19 +333,44 @@ where let qc_domains = quotient_domain.split_domains_const(builder, log_quotient_degree); - Self::verify_constraints( - builder, - chip, - &values, - proof.public_values.clone(), - trace_domain, - qc_domains, - zeta, - alpha, - &permutation_challenges, + // Verify the constraints. + stacker::maybe_grow(16 * 1024 * 1024, 16 * 1024 * 1024, || { + Self::verify_constraints( + builder, + chip, + &values, + proof.public_values.clone(), + trace_domain, + qc_domains, + zeta, + alpha, + &permutation_challenges, + ); + }); + + // Increment the number of shard chips that are enabled. + builder.assign( + num_shard_chips_enabled, + num_shard_chips_enabled + C::N::one(), ); }); } + + // Assert that the number of chips in `opened_values` matches the number of shard chips enabled. + builder.assert_var_eq(num_shard_chips_enabled, num_shard_chips); + + // If we're checking the cumulative sum, assert that the sum of the cumulative sums is zero. + if check_cumulative_sum { + let sum: Ext<_, _> = builder.eval(C::EF::zero().cons()); + builder + .range(0, proof.opened_values.chips.len()) + .for_each(|i, builder| { + let cumulative_sum = builder.get(&proof.opened_values.chips, i).cumulative_sum; + builder.assign(sum, sum + cumulative_sum); + }); + builder.assert_ext_eq(sum, C::EF::zero().cons()); + } + builder.cycle_tracker("stage-e-verify-constraints"); } } @@ -408,7 +394,8 @@ pub(crate) mod tests { use sp1_core::air::POSEIDON_NUM_WORDS; use sp1_core::io::SP1Stdin; use sp1_core::runtime::Program; - use sp1_core::stark::LocalProver; + use sp1_core::stark::DefaultProver; + use sp1_core::stark::MachineProver; use sp1_core::utils::setup_logger; use sp1_core::utils::InnerChallenge; use sp1_core::utils::InnerVal; @@ -454,7 +441,7 @@ pub(crate) mod tests { let machine = A::machine(SC::default()); let (_, vk) = machine.setup(&Program::from(elf)); let mut challenger_val = machine.config().challenger(); - let (proof, _) = sp1_core::utils::prove( + let (proof, _, _) = sp1_core::utils::prove::<_, DefaultProver<_, _>>( Program::from(elf), &SP1Stdin::new(), SC::default(), @@ -478,6 +465,10 @@ pub(crate) mod tests { // Observe all the commitments. let mut builder = Builder::::default(); + // Add a hash invocation, since the poseidon2 table expects that it's in the first row. + let hash_input = builder.constant(vec![vec![F::one()]]); + builder.poseidon2_hash_x(&hash_input); + let mut challenger = DuplexChallengerVariable::new(&mut builder); let preprocessed_commit_val: [F; DIGEST_SIZE] = vk.commit.into(); @@ -519,6 +510,10 @@ pub(crate) mod tests { fn test_public_values_program() -> RecursionProgram { let mut builder = Builder::::default(); + // Add a hash invocation, since the poseidon2 table expects that it's in the first row. + let hash_input = builder.constant(vec![vec![F::one()]]); + builder.poseidon2_hash_x(&hash_input); + let mut public_values_stream: Vec> = (0..RECURSIVE_PROOF_NUM_PV_ELTS) .map(|_| builder.uninit()) .collect(); @@ -528,7 +523,7 @@ pub(crate) mod tests { public_values.sp1_vk_digest = [builder.constant(::F::zero()); DIGEST_SIZE]; public_values.next_pc = builder.constant(::F::one()); - public_values.next_shard = builder.constant(::F::two()); + public_values.next_execution_shard = builder.constant(::F::two()); public_values.end_reconstruct_deferred_digest = [builder.constant(::F::from_canonical_usize(3)); POSEIDON_NUM_WORDS]; @@ -551,22 +546,20 @@ pub(crate) mod tests { let config = SC::default(); let mut runtime = Runtime::::new(&program, config.perm.clone()); - runtime.run(); + runtime.run().unwrap(); let machine = RecursionAir::<_, 3>::machine(SC::default()); - let (pk, vk) = machine.setup(&program); + let prover = DefaultProver::new(machine); + let (pk, vk) = prover.setup(&program); let record = runtime.record.clone(); - let mut challenger = machine.config().challenger(); - let mut proof = machine.prove::>>( - &pk, - record, - &mut challenger, - SP1CoreOpts::recursion(), - ); + let mut challenger = prover.config().challenger(); + let mut proof = prover + .prove(&pk, vec![record], &mut challenger, SP1CoreOpts::recursion()) + .unwrap(); - let mut challenger = machine.config().challenger(); - let verification_result = machine.verify(&vk, &proof, &mut challenger); + let mut challenger = prover.config().challenger(); + let verification_result = prover.machine().verify(&vk, &proof, &mut challenger); if verification_result.is_err() { panic!("Proof should verify successfully"); } @@ -574,7 +567,7 @@ pub(crate) mod tests { // Corrupt the public values. proof.shard_proofs[0].public_values[RECURSION_PUBLIC_VALUES_COL_MAP.digest[0]] = InnerVal::zero(); - let verification_result = machine.verify(&vk, &proof, &mut challenger); + let verification_result = prover.machine().verify(&vk, &proof, &mut challenger); if verification_result.is_ok() { panic!("Proof should not verify successfully"); } diff --git a/release-plz.toml b/release-plz.toml new file mode 100644 index 0000000000..ced25f8913 --- /dev/null +++ b/release-plz.toml @@ -0,0 +1,5 @@ +[workspace] +# Disable git releases for all packages by default +git_release_enable = false +# Disable git tags for all packages by default +git_tag_enable = false diff --git a/sdk/CHANGELOG.md b/sdk/CHANGELOG.md new file mode 100644 index 0000000000..8c73016ec1 --- /dev/null +++ b/sdk/CHANGELOG.md @@ -0,0 +1,148 @@ +# Changelog + +All notable changes to this project will be documented in this file. + +The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/), +and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html). + +## [Unreleased] + +## [1.0.0-rc.1](https://github.com/succinctlabs/sp1/compare/sp1-sdk-v1.0.0-rc.1...sp1-sdk-v1.0.0-rc.1) - 2024-07-19 + +### Added + +- 1.0.0-rc.1 ([#1126](https://github.com/succinctlabs/sp1/pull/1126)) +- publish sp1 to crates.io ([#1052](https://github.com/succinctlabs/sp1/pull/1052)) +- critical constraint changes ([#1046](https://github.com/succinctlabs/sp1/pull/1046)) +- cycle limit ([#1027](https://github.com/succinctlabs/sp1/pull/1027)) +- improve network prover error output ([#991](https://github.com/succinctlabs/sp1/pull/991)) +- _(sdk)_ finish mock prover implementation ([#1008](https://github.com/succinctlabs/sp1/pull/1008)) +- (breaking changes to SDK API) use builder pattern for SDK execute/prove/verify ([#940](https://github.com/succinctlabs/sp1/pull/940)) +- circuit version in proof ([#926](https://github.com/succinctlabs/sp1/pull/926)) +- sp1 circuit version ([#899](https://github.com/succinctlabs/sp1/pull/899)) +- use docker by default for gnark ([#890](https://github.com/succinctlabs/sp1/pull/890)) +- _(sdk)_ add explorer link ([#858](https://github.com/succinctlabs/sp1/pull/858)) +- check version for proof requests ([#862](https://github.com/succinctlabs/sp1/pull/862)) +- feature flag `alloy_sol_types` ([#850](https://github.com/succinctlabs/sp1/pull/850)) +- generic const expr ([#854](https://github.com/succinctlabs/sp1/pull/854)) +- execute() exposes ExecutionReport ([#847](https://github.com/succinctlabs/sp1/pull/847)) +- encode proof solidity ([#836](https://github.com/succinctlabs/sp1/pull/836)) +- switch to ethers ([#826](https://github.com/succinctlabs/sp1/pull/826)) +- sp1 core prover opts +- plonk prover ([#795](https://github.com/succinctlabs/sp1/pull/795)) +- groth16 feature flag ([#782](https://github.com/succinctlabs/sp1/pull/782)) +- Implement `verify_groth16` & `prove_groth16` on `MockProver` ([#745](https://github.com/succinctlabs/sp1/pull/745)) +- add proof verification ([#729](https://github.com/succinctlabs/sp1/pull/729)) +- reduce network prover ([#687](https://github.com/succinctlabs/sp1/pull/687)) +- auto rebuild dev artifacts in sdk ([#726](https://github.com/succinctlabs/sp1/pull/726)) +- fix execution + proving errors ([#715](https://github.com/succinctlabs/sp1/pull/715)) +- update docs + add some tests around solidity contract export ([#693](https://github.com/succinctlabs/sp1/pull/693)) +- add sp1-sdk tests with SP1_DEV=0 for release ci ([#694](https://github.com/succinctlabs/sp1/pull/694)) +- program refactor ([#651](https://github.com/succinctlabs/sp1/pull/651)) +- e2e groth16 with contract verifier ([#671](https://github.com/succinctlabs/sp1/pull/671)) +- nextgen ci for sp1-prover ([#663](https://github.com/succinctlabs/sp1/pull/663)) +- Adding docs for new `ProverClient` and `groth16` and `compressed` mode ([#627](https://github.com/succinctlabs/sp1/pull/627)) +- add multiple proving modes to network client ([#630](https://github.com/succinctlabs/sp1/pull/630)) +- aggregation fixes ([#649](https://github.com/succinctlabs/sp1/pull/649)) +- _(recursion)_ poseidon2 max constraint degree const generic ([#634](https://github.com/succinctlabs/sp1/pull/634)) +- _(sdk)_ auto setup circuit ([#635](https://github.com/succinctlabs/sp1/pull/635)) +- complete reduce program ([#565](https://github.com/succinctlabs/sp1/pull/565)) +- update network client with claim and fulfill ([#546](https://github.com/succinctlabs/sp1/pull/546)) +- fix cargo prove new issues ([#542](https://github.com/succinctlabs/sp1/pull/542)) +- verify shard transitions + fixes ([#482](https://github.com/succinctlabs/sp1/pull/482)) +- execute before `prove_remote_async` ([#530](https://github.com/succinctlabs/sp1/pull/530)) +- nonce in signed messages ([#507](https://github.com/succinctlabs/sp1/pull/507)) +- _(sdk)_ add `prove_async` ([#505](https://github.com/succinctlabs/sp1/pull/505)) +- sdk using secp256k1 auth ([#483](https://github.com/succinctlabs/sp1/pull/483)) +- recursion vm public values ([#495](https://github.com/succinctlabs/sp1/pull/495)) +- relay proofs ([#458](https://github.com/succinctlabs/sp1/pull/458)) +- setup recursion prover crate ([#475](https://github.com/succinctlabs/sp1/pull/475)) +- public values ([#455](https://github.com/succinctlabs/sp1/pull/455)) +- one cycle input ([#451](https://github.com/succinctlabs/sp1/pull/451)) +- sp1-sdk, remote prover ([#370](https://github.com/succinctlabs/sp1/pull/370)) +- new README img ([#226](https://github.com/succinctlabs/sp1/pull/226)) +- readme updates ([#205](https://github.com/succinctlabs/sp1/pull/205)) +- more final touches ([#194](https://github.com/succinctlabs/sp1/pull/194)) +- curtaup + release system + cargo prove CLI updates ([#178](https://github.com/succinctlabs/sp1/pull/178)) +- (perf) updates from Plonky3 and verifier refactor ([#156](https://github.com/succinctlabs/sp1/pull/156)) +- developer experience improvements ([#145](https://github.com/succinctlabs/sp1/pull/145)) +- toolchain build from source & install ([#113](https://github.com/succinctlabs/sp1/pull/113)) +- io::read io::write ([#126](https://github.com/succinctlabs/sp1/pull/126)) +- tracing, profiling, benchmarking ([#99](https://github.com/succinctlabs/sp1/pull/99)) + +### Fixed + +- _(sdk)_ options warning when using network prover ([#1069](https://github.com/succinctlabs/sp1/pull/1069)) +- _(sdk)_ lock axum to 0.7.4 ([#1029](https://github.com/succinctlabs/sp1/pull/1029)) +- plonk feature off by default ([#852](https://github.com/succinctlabs/sp1/pull/852)) +- fix +- install for `verify_plonk_bn254` ([#798](https://github.com/succinctlabs/sp1/pull/798)) +- download Groth16 artifacts on `prove_groth16` invocation ([#674](https://github.com/succinctlabs/sp1/pull/674)) +- _(sdk)_ Small fix for getting vkey digest ([#665](https://github.com/succinctlabs/sp1/pull/665)) +- verify reduced proofs ([#655](https://github.com/succinctlabs/sp1/pull/655)) +- compress before wrap ([#624](https://github.com/succinctlabs/sp1/pull/624)) +- fix +- return fulfilled proof ([#573](https://github.com/succinctlabs/sp1/pull/573)) +- use REMOTE_PROVE to check local or remote ([#524](https://github.com/succinctlabs/sp1/pull/524)) +- `prove_remote` serialization ([#509](https://github.com/succinctlabs/sp1/pull/509)) +- use bincode for sdk serialization ([#506](https://github.com/succinctlabs/sp1/pull/506)) +- fibonacci io ([#478](https://github.com/succinctlabs/sp1/pull/478)) + +### Other + +- export execution report ([#1112](https://github.com/succinctlabs/sp1/pull/1112)) +- prover utilization ([#1100](https://github.com/succinctlabs/sp1/pull/1100)) +- _(deps)_ bump async-trait from 0.1.80 to 0.1.81 ([#1105](https://github.com/succinctlabs/sp1/pull/1105)) +- _(deps)_ bump sysinfo from 0.30.12 to 0.30.13 ([#1106](https://github.com/succinctlabs/sp1/pull/1106)) +- use global workspace version ([#1102](https://github.com/succinctlabs/sp1/pull/1102)) +- fix release-plz ([#1088](https://github.com/succinctlabs/sp1/pull/1088)) +- add release-plz ([#1086](https://github.com/succinctlabs/sp1/pull/1086)) +- remove async crates `sp1-prover` ([#1042](https://github.com/succinctlabs/sp1/pull/1042)) +- _(deps)_ bump serde from 1.0.203 to 1.0.204 ([#1063](https://github.com/succinctlabs/sp1/pull/1063)) +- switch to p3 from crates.io ([#1038](https://github.com/succinctlabs/sp1/pull/1038)) +- hm +- add memory error +- cycle limit +- Merge branch 'dev' into dependabot/cargo/dev/log-0.4.22 +- _(deps)_ bump serde_json from 1.0.117 to 1.0.120 ([#1001](https://github.com/succinctlabs/sp1/pull/1001)) +- _(deps)_ bump num-bigint from 0.4.5 to 0.4.6 ([#1002](https://github.com/succinctlabs/sp1/pull/1002)) +- _(deps)_ bump reqwest-middleware from 0.3.1 to 0.3.2 +- _(deps)_ bump strum from 0.26.2 to 0.26.3 +- v1.0.7-testnet ([#930](https://github.com/succinctlabs/sp1/pull/930)) +- add version to sdk ([#923](https://github.com/succinctlabs/sp1/pull/923)) +- hm +- network docs + cleanup ([#913](https://github.com/succinctlabs/sp1/pull/913)) +- _(deps)_ bump strum_macros from 0.26.3 to 0.26.4 ([#907](https://github.com/succinctlabs/sp1/pull/907)) +- _(deps)_ bump alloy-sol-types from 0.7.4 to 0.7.6 ([#909](https://github.com/succinctlabs/sp1/pull/909)) +- _(deps)_ bump tokio from 1.37.0 to 1.38.0 ([#882](https://github.com/succinctlabs/sp1/pull/882)) +- _(deps)_ bump strum_macros from 0.26.2 to 0.26.3 +- add network requester to requested proof ([#845](https://github.com/succinctlabs/sp1/pull/845)) +- Merge branch 'main' into dev +- clean +- change to network +- lint +- prover type +- update comments +- prover type +- encode proof solidity +- `prove_plonk` ([#827](https://github.com/succinctlabs/sp1/pull/827)) +- Make some functions const ([#774](https://github.com/succinctlabs/sp1/pull/774)) +- remove unused deps ([#794](https://github.com/succinctlabs/sp1/pull/794)) +- Clean up TOML files ([#796](https://github.com/succinctlabs/sp1/pull/796)) +- merge main into dev ([#801](https://github.com/succinctlabs/sp1/pull/801)) +- update dev with latest main ([#728](https://github.com/succinctlabs/sp1/pull/728)) +- _(deps)_ bump axum from 0.7.4 to 0.7.5 +- update all dependencies ([#689](https://github.com/succinctlabs/sp1/pull/689)) +- sdk tweaks ([#653](https://github.com/succinctlabs/sp1/pull/653)) +- Implement `Prover` on `MockProver` ([#629](https://github.com/succinctlabs/sp1/pull/629)) +- sdk improvements ([#580](https://github.com/succinctlabs/sp1/pull/580)) +- fixing dep tree for `prover`, `recursion`, `core` and `sdk` ([#545](https://github.com/succinctlabs/sp1/pull/545)) +- cleanup prover ([#551](https://github.com/succinctlabs/sp1/pull/551)) +- final touches for public release ([#239](https://github.com/succinctlabs/sp1/pull/239)) +- update docs with slight nits ([#224](https://github.com/succinctlabs/sp1/pull/224)) +- sp1 rename ([#212](https://github.com/succinctlabs/sp1/pull/212)) +- enshrine AlignedBorrow macro ([#209](https://github.com/succinctlabs/sp1/pull/209)) +- readme cleanup ([#196](https://github.com/succinctlabs/sp1/pull/196)) +- rename succinct to curta ([#192](https://github.com/succinctlabs/sp1/pull/192)) +- better curta graphic ([#184](https://github.com/succinctlabs/sp1/pull/184)) +- Initial commit diff --git a/sdk/Cargo.toml b/sdk/Cargo.toml index 991d454113..36da7fe893 100644 --- a/sdk/Cargo.toml +++ b/sdk/Cargo.toml @@ -1,48 +1,57 @@ [package] name = "sp1-sdk" -version = "0.1.0" -edition = "2021" +description = "SP1 is a performant, 100% open-source, contributor-friendly zkVM." +readme = "../README.md" +version = { workspace = true } +edition = { workspace = true } +license = { workspace = true } +repository = { workspace = true } +keywords = { workspace = true } +categories = { workspace = true } [dependencies] prost = "0.12" -serde = { version = "1.0.201", features = ["derive"] } -serde_json = "1.0.117" -twirp = { git = "https://github.com/github/twirp-rs.git", rev = "c85f31f9c54957374e7dcb3534fc52cff0aa2dc5" } -async-trait = "0.1.80" -reqwest-middleware = "0.3.1" +serde = { version = "1.0.204", features = ["derive"] } +serde_json = "1.0.120" +twirp = { package = "twirp-rs", version = "0.3.0-succinct" } +async-trait = "0.1.81" +reqwest-middleware = "0.3.2" reqwest = { version = "0.12.4", features = [ "rustls-tls", "trust-dns", "stream", ] } anyhow = "1.0.83" -sp1-prover = { path = "../prover" } -sp1-core = { path = "../core" } +sp1-prover = { workspace = true } +sp1-core = { workspace = true } futures = "0.3.30" bincode = "1.3.3" tokio = { version = "1.38.0", features = ["full"] } p3-matrix = { workspace = true } p3-commit = { workspace = true } p3-field = { workspace = true } +p3-baby-bear = { workspace = true } +p3-fri = { workspace = true } indicatif = "0.17.8" tracing = "0.1.40" hex = "0.4.3" -log = "0.4.21" -axum = "=0.7.5" +log = "0.4.22" +axum = "=0.7.4" alloy-sol-types = { version = "0.7.6", optional = true } sha2 = "0.10.8" dirs = "5.0.1" tempfile = "3.10.1" -num-bigint = "0.4.5" +num-bigint = "0.4.6" cfg-if = "1.0" ethers = { version = "2", default-features = false } strum_macros = "0.26.4" -strum = "0.26.2" +strum = "0.26.3" thiserror = "1.0.61" +hashbrown = "0.14.5" +sysinfo = "0.30.13" [features] default = ["network"] - neon = ["sp1-core/neon"] native-gnark = ["sp1-prover/native-gnark"] # TODO: Once alloy has a 1.* release, we can likely remove this feature flag, as there will be less diff --git a/sdk/src/action.rs b/sdk/src/action.rs new file mode 100644 index 0000000000..7c712b36c1 --- /dev/null +++ b/sdk/src/action.rs @@ -0,0 +1,211 @@ +use sp1_core::{ + runtime::{ExecutionReport, HookEnv, SP1ContextBuilder}, + utils::{SP1CoreOpts, SP1ProverOpts}, +}; +use sp1_prover::{ + components::DefaultProverComponents, SP1Prover, SP1ProvingKey, SP1PublicValues, SP1Stdin, +}; + +use anyhow::{Ok, Result}; + +use crate::{Prover, SP1ProofKind, SP1ProofWithPublicValues}; + +/// Builder to prepare and configure execution of a program on an input. +/// May be run with [Self::run]. +#[derive(Default)] +pub struct Execute<'a> { + context_builder: SP1ContextBuilder<'a>, + elf: &'a [u8], + stdin: SP1Stdin, +} + +impl<'a> Execute<'a> { + /// Prepare to execute the given program on the given input (without generating a proof). + /// + /// Prefer using [ProverClient::execute](super::ProverClient::execute). + /// See there for more documentation. + pub fn new(elf: &'a [u8], stdin: SP1Stdin) -> Self { + Self { + elf, + stdin, + context_builder: Default::default(), + } + } + + /// Execute the program on the input, consuming the built action `self`. + pub fn run(self) -> Result<(SP1PublicValues, ExecutionReport)> { + let Self { + elf, + stdin, + mut context_builder, + } = self; + let context = context_builder.build(); + Ok(SP1Prover::::execute( + elf, &stdin, context, + )?) + } + + /// Add a runtime [Hook](super::Hook) into the context. + /// + /// Hooks may be invoked from within SP1 by writing to the specified file descriptor `fd` + /// with [`sp1_zkvm::io::write`], returning a list of arbitrary data that may be read + /// with successive calls to [`sp1_zkvm::io::read`]. + pub fn with_hook( + mut self, + fd: u32, + f: impl FnMut(HookEnv, &[u8]) -> Vec> + Send + Sync + 'a, + ) -> Self { + self.context_builder.hook(fd, f); + self + } + + /// Avoid registering the default hooks in the runtime. + /// + /// It is not necessary to call this to override hooks --- instead, simply + /// register a hook with the same value of `fd` by calling [`Self::hook`]. + pub fn without_default_hooks(mut self) -> Self { + self.context_builder.without_default_hooks(); + self + } + + /// Set the maximum number of cpu cycles to use for execution. + /// + /// If the cycle limit is exceeded, execution will return [sp1_core::runtime::ExecutionError::ExceededCycleLimit]. + pub fn max_cycles(mut self, max_cycles: u64) -> Self { + self.context_builder.max_cycles(max_cycles); + self + } +} + +/// Builder to prepare and configure proving execution of a program on an input. +/// May be run with [Self::run]. +pub struct Prove<'a> { + prover: &'a dyn Prover, + kind: SP1ProofKind, + context_builder: SP1ContextBuilder<'a>, + pk: &'a SP1ProvingKey, + stdin: SP1Stdin, + core_opts: SP1CoreOpts, + recursion_opts: SP1CoreOpts, +} + +impl<'a> Prove<'a> { + /// Prepare to prove the execution of the given program with the given input. + /// + /// Prefer using [ProverClient::prove](super::ProverClient::prove). + /// See there for more documentation. + pub fn new( + prover: &'a dyn Prover, + pk: &'a SP1ProvingKey, + stdin: SP1Stdin, + ) -> Self { + Self { + prover, + kind: Default::default(), + pk, + stdin, + context_builder: Default::default(), + core_opts: SP1CoreOpts::default(), + recursion_opts: SP1CoreOpts::recursion(), + } + } + + /// Prove the execution of the program on the input, consuming the built action `self`. + pub fn run(self) -> Result { + let Self { + prover, + kind, + pk, + stdin, + mut context_builder, + core_opts, + recursion_opts, + } = self; + let opts = SP1ProverOpts { + core_opts, + recursion_opts, + }; + let context = context_builder.build(); + + prover.prove(pk, stdin, opts, context, kind) + } + + /// Set the proof kind to the core mode. This is the default. + pub fn core(mut self) -> Self { + self.kind = SP1ProofKind::Core; + self + } + + /// Set the proof kind to the compressed mode. + pub fn compressed(mut self) -> Self { + self.kind = SP1ProofKind::Compressed; + self + } + + /// Set the proof mode to the plonk bn254 mode. + pub fn plonk(mut self) -> Self { + self.kind = SP1ProofKind::Plonk; + self + } + + /// Add a runtime [Hook](super::Hook) into the context. + /// + /// Hooks may be invoked from within SP1 by writing to the specified file descriptor `fd` + /// with [`sp1_zkvm::io::write`], returning a list of arbitrary data that may be read + /// with successive calls to [`sp1_zkvm::io::read`]. + pub fn with_hook( + mut self, + fd: u32, + f: impl FnMut(HookEnv, &[u8]) -> Vec> + Send + Sync + 'a, + ) -> Self { + self.context_builder.hook(fd, f); + self + } + + /// Avoid registering the default hooks in the runtime. + /// + /// It is not necessary to call this to override hooks --- instead, simply + /// register a hook with the same value of `fd` by calling [`Self::hook`]. + pub fn without_default_hooks(mut self) -> Self { + self.context_builder.without_default_hooks(); + self + } + + /// Set the shard size for proving. + pub fn shard_size(mut self, value: usize) -> Self { + self.core_opts.shard_size = value; + self + } + + /// Set the shard batch size for proving. + pub fn shard_batch_size(mut self, value: usize) -> Self { + self.core_opts.shard_batch_size = value; + self + } + + /// Set the commit stream capacity for proving. + pub fn commit_stream_capacity(mut self, value: usize) -> Self { + self.core_opts.commit_stream_capacity = value; + self + } + + /// Set the prove stream capacity for proving. + pub fn prove_stream_capacity(mut self, value: usize) -> Self { + self.core_opts.prove_stream_capacity = value; + self + } + + /// Set whether we should reconstruct commitments while proving. + pub fn reconstruct_commitments(mut self, value: bool) -> Self { + self.core_opts.reconstruct_commitments = value; + self + } + + /// Set the maximum number of cpu cycles to use for execution. + /// + /// If the cycle limit is exceeded, execution will return [sp1_core::runtime::ExecutionError::ExceededCycleLimit]. + pub fn cycle_limit(mut self, cycle_limit: u64) -> Self { + self.context_builder.max_cycles(cycle_limit); + self + } +} diff --git a/sdk/src/artifacts.rs b/sdk/src/artifacts.rs index 2cc7be7d0d..cb88316ea9 100644 --- a/sdk/src/artifacts.rs +++ b/sdk/src/artifacts.rs @@ -4,9 +4,9 @@ use anyhow::{Context, Result}; use futures::StreamExt; use indicatif::{ProgressBar, ProgressStyle}; use reqwest::Client; -pub use sp1_prover::build::{ - build_plonk_bn254_artifacts_with_dummy, try_install_plonk_bn254_artifacts, -}; +pub use sp1_prover::build::build_plonk_bn254_artifacts_with_dummy; + +use crate::install::try_install_plonk_bn254_artifacts; /// Exports the solidity verifier for PLONK proofs to the specified output directory. /// @@ -17,7 +17,7 @@ pub fn export_solidity_plonk_bn254_verifier(output_dir: impl Into) -> R let artifacts_dir = if sp1_prover::build::sp1_dev_mode() { sp1_prover::build::plonk_bn254_artifacts_dev_dir() } else { - sp1_prover::build::try_install_plonk_bn254_artifacts() + try_install_plonk_bn254_artifacts() }; let verifier_path = artifacts_dir.join("SP1Verifier.sol"); diff --git a/prover/src/install.rs b/sdk/src/install.rs similarity index 66% rename from prover/src/install.rs rename to sdk/src/install.rs index 8971661bd7..8c6e250560 100644 --- a/prover/src/install.rs +++ b/sdk/src/install.rs @@ -1,14 +1,45 @@ use std::{cmp::min, io::Write, path::PathBuf, process::Command}; -use futures::StreamExt; +use futures::{Future, StreamExt}; use indicatif::{ProgressBar, ProgressStyle}; use reqwest::Client; +use tokio::{runtime, task::block_in_place}; -use crate::{utils::block_on, SP1_CIRCUIT_VERSION}; +use crate::SP1_CIRCUIT_VERSION; /// The base URL for the S3 bucket containing the plonk bn254 artifacts. pub const PLONK_BN254_ARTIFACTS_URL_BASE: &str = "https://sp1-circuits.s3-us-east-2.amazonaws.com"; +/// Gets the directory where the PLONK artifacts are installed. +fn plonk_bn254_artifacts_dir() -> PathBuf { + dirs::home_dir() + .unwrap() + .join(".sp1") + .join("circuits") + .join("plonk_bn254") + .join(SP1_CIRCUIT_VERSION) +} + +/// Tries to install the PLONK artifacts if they are not already installed. +pub fn try_install_plonk_bn254_artifacts() -> PathBuf { + let build_dir = plonk_bn254_artifacts_dir(); + + if build_dir.exists() { + println!( + "[sp1] plonk bn254 artifacts already seem to exist at {}. if you want to re-download them, delete the directory", + build_dir.display() + ); + } else { + println!( + "[sp1] plonk bn254 artifacts for version {} do not exist at {}. downloading...", + SP1_CIRCUIT_VERSION, + build_dir.display() + ); + install_plonk_bn254_artifacts(build_dir.clone()); + } + build_dir +} + /// Install the latest plonk bn254 artifacts. /// /// This function will download the latest plonk bn254 artifacts from the S3 bucket and extract them to @@ -98,3 +129,16 @@ pub async fn download_file( Ok(()) } + +/// Utility method for blocking on an async function. If we're already in a tokio runtime, we'll +/// block in place. Otherwise, we'll create a new runtime. +pub fn block_on(fut: impl Future) -> T { + // Handle case if we're already in an tokio runtime. + if let Ok(handle) = runtime::Handle::try_current() { + block_in_place(|| handle.block_on(fut)) + } else { + // Otherwise create a new runtime. + let rt = runtime::Runtime::new().expect("Failed to create a new runtime"); + rt.block_on(fut) + } +} diff --git a/sdk/src/lib.rs b/sdk/src/lib.rs index 55fe50d0d7..8f8b01ecd7 100644 --- a/sdk/src/lib.rs +++ b/sdk/src/lib.rs @@ -9,31 +9,30 @@ pub mod proto { pub mod network; } +pub mod action; pub mod artifacts; +pub mod install; #[cfg(feature = "network")] pub mod network; #[cfg(feature = "network")] pub use crate::network::prover::NetworkProver; +pub mod proof; pub mod provers; pub mod utils { pub use sp1_core::utils::setup_logger; } use cfg_if::cfg_if; +pub use proof::*; pub use provers::SP1VerificationError; -use std::{env, fmt::Debug, fs::File, path::Path}; - -use anyhow::{Ok, Result}; +use sp1_prover::components::DefaultProverComponents; +use std::env; pub use provers::{LocalProver, MockProver, Prover}; -use serde::{de::DeserializeOwned, Deserialize, Serialize}; -use sp1_core::{ - runtime::ExecutionReport, - stark::{MachineVerificationError, ShardProof}, - SP1_CIRCUIT_VERSION, -}; +pub use sp1_core::runtime::{ExecutionReport, Hook, HookEnv, SP1Context, SP1ContextBuilder}; +use sp1_core::SP1_CIRCUIT_VERSION; pub use sp1_prover::{ CoreSC, HashableKey, InnerSC, OuterSC, PlonkBn254Proof, SP1Prover, SP1ProvingKey, SP1PublicValues, SP1Stdin, SP1VerifyingKey, @@ -42,31 +41,9 @@ pub use sp1_prover::{ /// A client for interacting with SP1. pub struct ProverClient { /// The underlying prover implementation. - pub prover: Box, + pub prover: Box>, } -/// A proof generated with SP1. -#[derive(Debug, Clone, Serialize, Deserialize)] -#[serde(bound(serialize = "P: Serialize + Debug + Clone"))] -#[serde(bound(deserialize = "P: DeserializeOwned + Debug + Clone"))] -pub struct SP1ProofWithPublicValues

{ - pub proof: P, - pub stdin: SP1Stdin, - pub public_values: SP1PublicValues, - pub sp1_version: String, -} - -/// A [SP1ProofWithPublicValues] generated with [ProverClient::prove]. -pub type SP1Proof = SP1ProofWithPublicValues>>; -pub type SP1ProofVerificationError = MachineVerificationError; - -/// A [SP1ProofWithPublicValues] generated with [ProverClient::prove_compressed]. -pub type SP1CompressedProof = SP1ProofWithPublicValues>; -pub type SP1CompressedProofVerificationError = MachineVerificationError; - -/// A [SP1ProofWithPublicValues] generated with [ProverClient::prove_plonk]. -pub type SP1PlonkBn254Proof = SP1ProofWithPublicValues; - impl ProverClient { /// Creates a new [ProverClient]. /// @@ -172,21 +149,16 @@ impl ProverClient { } } - /// Gets the current version of the SP1 zkVM. - /// - /// Note: This is not the same as the version of the SP1 SDK. - pub fn version(&self) -> String { - SP1_CIRCUIT_VERSION.to_string() - } - - /// Executes the given program on the given input (without generating a proof). - /// - /// Returns the public values and execution report of the program after it has been executed. + /// Prepare to execute the given program on the given input (without generating a proof). + /// The returned [action::Execute] may be configured via its methods before running. + /// For example, calling [action::Execute::with_hook] registers hooks for execution. /// + /// To execute, call [action::Execute::run], which returns + /// the public values and execution report of the program after it has been executed. /// /// ### Examples /// ```no_run - /// use sp1_sdk::{ProverClient, SP1Stdin}; + /// use sp1_sdk::{ProverClient, SP1Stdin, SP1Context}; /// /// // Load the program. /// let elf = include_bytes!("../../examples/fibonacci/program/elf/riscv32im-succinct-zkvm-elf"); @@ -199,107 +171,24 @@ impl ProverClient { /// stdin.write(&10usize); /// /// // Execute the program on the inputs. - /// let (public_values, report) = client.execute(elf, stdin).unwrap(); - /// ``` - pub fn execute( - &self, - elf: &[u8], - stdin: SP1Stdin, - ) -> Result<(SP1PublicValues, ExecutionReport)> { - Ok(SP1Prover::execute(elf, &stdin)?) - } - - /// Setup a program to be proven and verified by the SP1 RISC-V zkVM by computing the proving - /// and verifying keys. - /// - /// The proving key and verifying key essentially embed the program, as well as other auxiliary - /// data (such as lookup tables) that are used to prove the program's correctness. - /// - /// ### Examples - /// ```no_run - /// use sp1_sdk::{ProverClient, SP1Stdin}; - /// - /// let elf = include_bytes!("../../examples/fibonacci/program/elf/riscv32im-succinct-zkvm-elf"); - /// let client = ProverClient::new(); - /// let mut stdin = SP1Stdin::new(); - /// stdin.write(&10usize); - /// let (pk, vk) = client.setup(elf); + /// let (public_values, report) = client.execute(elf, stdin).run().unwrap(); /// ``` - pub fn setup(&self, elf: &[u8]) -> (SP1ProvingKey, SP1VerifyingKey) { - self.prover.setup(elf) + pub fn execute<'a>(&self, elf: &'a [u8], stdin: SP1Stdin) -> action::Execute<'a> { + action::Execute::new(elf, stdin) } - /// Proves the execution of the given program with the given input in the default mode. + /// Prepare to prove the execution of the given program with the given input in the default mode. + /// The returned [action::Prove] may be configured via its methods before running. + /// For example, calling [action::Prove::compress] sets the mode to compressed mode. /// - /// Returns a proof of the program's execution. By default the proof generated will not be - /// compressed to constant size. To create a more succinct proof, use the [Self::prove_compressed], + /// To prove, call [action::Prove::run], which returns a proof of the program's execution. + /// By default the proof generated will not be compressed to constant size. + /// To create a more succinct proof, use the [Self::prove_compressed], /// [Self::prove_plonk], or [Self::prove_plonk] methods. /// /// ### Examples /// ```no_run - /// use sp1_sdk::{ProverClient, SP1Stdin}; - /// - /// // Load the program. - /// let elf = include_bytes!("../../examples/fibonacci/program/elf/riscv32im-succinct-zkvm-elf"); - /// - /// // Initialize the prover client. - /// let client = ProverClient::new(); - /// - /// // Setup the program. - /// let (pk, vk) = client.setup(elf); - /// - /// // Setup the inputs. - /// let mut stdin = SP1Stdin::new(); - /// stdin.write(&10usize); - /// - /// // Generate the proof. - /// let proof = client.prove(&pk, stdin).unwrap(); - /// ``` - pub fn prove(&self, pk: &SP1ProvingKey, stdin: SP1Stdin) -> Result { - self.prover.prove(pk, stdin) - } - - /// Proves the execution of the given program with the given input in the compressed mode. - /// - /// Returns a compressed proof of the program's execution. The compressed proof is a succinct - /// proof that is of constant size and friendly for recursion and off-chain verification. - /// - /// ### Examples - /// ```no_run - /// use sp1_sdk::{ProverClient, SP1Stdin}; - /// - /// // Load the program. - /// let elf = include_bytes!("../../examples/fibonacci/program/elf/riscv32im-succinct-zkvm-elf"); - /// - /// // Initialize the prover client. - /// let client = ProverClient::new(); - /// - /// // Setup the program. - /// let (pk, vk) = client.setup(elf); - /// - /// // Setup the inputs. - /// let mut stdin = SP1Stdin::new(); - /// stdin.write(&10usize); - /// - /// // Generate the proof. - /// let proof = client.prove_compressed(&pk, stdin).unwrap(); - /// ``` - pub fn prove_compressed( - &self, - pk: &SP1ProvingKey, - stdin: SP1Stdin, - ) -> Result { - self.prover.prove_compressed(pk, stdin) - } - - /// Proves the execution of the given program with the given input in the plonk bn254 mode. - /// - /// Returns a proof of the program's execution in the plonk bn254format. The proof is a succinct - /// proof that is of constant size and friendly for on-chain verification. - /// - /// ### Examples - /// ```no_run - /// use sp1_sdk::{ProverClient, SP1Stdin}; + /// use sp1_sdk::{ProverClient, SP1Stdin, SP1Context}; /// /// // Load the program. /// let elf = include_bytes!("../../examples/fibonacci/program/elf/riscv32im-succinct-zkvm-elf"); @@ -315,11 +204,10 @@ impl ProverClient { /// stdin.write(&10usize); /// /// // Generate the proof. - /// let proof = client.prove_plonk(&pk, stdin).unwrap(); + /// let proof = client.prove(&pk, stdin).run().unwrap(); /// ``` - /// Generates a plonk bn254 proof, verifiable onchain, of the given elf and stdin. - pub fn prove_plonk(&self, pk: &SP1ProvingKey, stdin: SP1Stdin) -> Result { - self.prover.prove_plonk(pk, stdin) + pub fn prove<'a>(&'a self, pk: &'a SP1ProvingKey, stdin: SP1Stdin) -> action::Prove<'a> { + action::Prove::new(self.prover.as_ref(), pk, stdin) } /// Verifies that the given proof is valid and matches the given verification key produced by @@ -334,81 +222,42 @@ impl ProverClient { /// let (pk, vk) = client.setup(elf); /// let mut stdin = SP1Stdin::new(); /// stdin.write(&10usize); - /// let proof = client.prove(&pk, stdin).unwrap(); + /// let proof = client.prove(&pk, stdin).run().unwrap(); /// client.verify(&proof, &vk).unwrap(); /// ``` pub fn verify( &self, - proof: &SP1Proof, - vkey: &SP1VerifyingKey, + proof: &SP1ProofWithPublicValues, + vk: &SP1VerifyingKey, ) -> Result<(), SP1VerificationError> { - self.prover.verify(proof, vkey) + self.prover.verify(proof, vk) } - /// Verifies that the given compressed proof is valid and matches the given verification key - /// produced by [Self::setup]. - /// - /// ### Examples - /// ```no_run - /// use sp1_sdk::{ProverClient, SP1Stdin}; - /// - /// // Load the program. - /// let elf = include_bytes!("../../examples/fibonacci/program/elf/riscv32im-succinct-zkvm-elf"); - /// - /// // Initialize the prover client. - /// let client = ProverClient::new(); - /// - /// // Setup the program. - /// let (pk, vk) = client.setup(elf); - /// - /// // Setup the inputs. - /// let mut stdin = SP1Stdin::new(); - /// stdin.write(&10usize); + /// Gets the current version of the SP1 zkVM. /// - /// // Generate the proof. - /// let proof = client.prove_compressed(&pk, stdin).unwrap(); - /// client.verify_compressed(&proof, &vk).unwrap(); - /// ``` - pub fn verify_compressed( - &self, - proof: &SP1CompressedProof, - vkey: &SP1VerifyingKey, - ) -> Result<(), SP1VerificationError> { - self.prover.verify_compressed(proof, vkey) + /// Note: This is not the same as the version of the SP1 SDK. + pub fn version(&self) -> String { + SP1_CIRCUIT_VERSION.to_string() } - /// Verifies that the given plonk bn254 proof is valid and matches the given verification key - /// produced by [Self::setup]. + /// Setup a program to be proven and verified by the SP1 RISC-V zkVM by computing the proving + /// and verifying keys. + /// + /// The proving key and verifying key essentially embed the program, as well as other auxiliary + /// data (such as lookup tables) that are used to prove the program's correctness. /// /// ### Examples /// ```no_run /// use sp1_sdk::{ProverClient, SP1Stdin}; /// - /// // Load the program. /// let elf = include_bytes!("../../examples/fibonacci/program/elf/riscv32im-succinct-zkvm-elf"); - /// - /// // Initialize the prover client. /// let client = ProverClient::new(); - /// - /// // Setup the program. - /// let (pk, vk) = client.setup(elf); - /// - /// // Setup the inputs. /// let mut stdin = SP1Stdin::new(); /// stdin.write(&10usize); - /// - /// // Generate the proof. - /// let proof = client.prove_plonk(&pk, stdin).unwrap(); - /// - /// // Verify the proof. - /// client.verify_plonk(&proof, &vk).unwrap(); + /// let (pk, vk) = client.setup(elf); /// ``` - pub fn verify_plonk( - &self, - proof: &SP1PlonkBn254Proof, - vkey: &SP1VerifyingKey, - ) -> Result<(), SP1VerificationError> { - self.prover.verify_plonk(proof, vkey) + pub fn setup(&self, elf: &[u8]) -> (SP1ProvingKey, SP1VerifyingKey) { + self.prover.setup(elf) } } @@ -418,34 +267,13 @@ impl Default for ProverClient { } } -impl SP1ProofWithPublicValues

{ - /// Saves the proof to a path. - pub fn save(&self, path: impl AsRef) -> Result<()> { - bincode::serialize_into(File::create(path).expect("failed to open file"), self) - .map_err(Into::into) - } - - /// Loads a proof from a path. - pub fn load(path: impl AsRef) -> Result { - bincode::deserialize_from(File::open(path).expect("failed to open file")) - .map_err(Into::into) - } -} - -impl SP1PlonkBn254Proof { - /// Returns the encoded proof bytes with a prefix of the VK hash. - pub fn bytes(&self) -> String { - format!( - "0x{}{}", - hex::encode(&self.proof.plonk_vkey_hash[..4]), - &self.proof.encoded_proof - ) - } -} - #[cfg(test)] mod tests { + use std::sync::atomic::{AtomicU32, Ordering}; + + use sp1_core::runtime::{hook_ecrecover, FD_ECRECOVER_HOOK}; + use crate::{utils, ProverClient, SP1Stdin}; #[test] @@ -456,7 +284,46 @@ mod tests { include_bytes!("../../examples/fibonacci/program/elf/riscv32im-succinct-zkvm-elf"); let mut stdin = SP1Stdin::new(); stdin.write(&10usize); - client.execute(elf, stdin).unwrap(); + client.execute(elf, stdin).run().unwrap(); + } + + #[test] + fn test_execute_new() { + // Wrap the hook and check that it was called. + let call_ct = AtomicU32::new(0); + utils::setup_logger(); + let client = ProverClient::local(); + let elf = include_bytes!("../../tests/ecrecover/elf/riscv32im-succinct-zkvm-elf"); + let stdin = SP1Stdin::new(); + client + .execute(elf, stdin) + .with_hook(FD_ECRECOVER_HOOK, |env, buf| { + call_ct.fetch_add(1, Ordering::Relaxed); + hook_ecrecover(env, buf) + }) + .run() + .unwrap(); + assert_ne!(call_ct.into_inner(), 0); + } + + #[test] + fn test_prove_new() { + // Wrap the hook and check that it was called. + let call_ct = AtomicU32::new(0); + utils::setup_logger(); + let client = ProverClient::local(); + let elf = include_bytes!("../../tests/ecrecover/elf/riscv32im-succinct-zkvm-elf"); + let stdin = SP1Stdin::new(); + let (pk, _) = client.setup(elf); + client + .prove(&pk, stdin) + .with_hook(FD_ECRECOVER_HOOK, |env, buf| { + call_ct.fetch_add(1, Ordering::Relaxed); + hook_ecrecover(env, buf) + }) + .run() + .unwrap(); + assert_ne!(call_ct.into_inner(), 0); } #[test] @@ -467,7 +334,18 @@ mod tests { let elf = include_bytes!("../../tests/panic/elf/riscv32im-succinct-zkvm-elf"); let mut stdin = SP1Stdin::new(); stdin.write(&10usize); - client.execute(elf, stdin).unwrap(); + client.execute(elf, stdin).run().unwrap(); + } + + #[should_panic] + #[test] + fn test_cycle_limit_fail() { + utils::setup_logger(); + let client = ProverClient::local(); + let elf = include_bytes!("../../tests/panic/elf/riscv32im-succinct-zkvm-elf"); + let mut stdin = SP1Stdin::new(); + stdin.write(&10usize); + client.execute(elf, stdin).max_cycles(1).run().unwrap(); } #[test] @@ -479,8 +357,8 @@ mod tests { let (pk, vk) = client.setup(elf); let mut stdin = SP1Stdin::new(); stdin.write(&10usize); - let proof = client.prove_plonk(&pk, stdin).unwrap(); - client.verify_plonk(&proof, &vk).unwrap(); + let proof = client.prove(&pk, stdin).plonk().run().unwrap(); + client.verify(&proof, &vk).unwrap(); } #[test] @@ -492,7 +370,7 @@ mod tests { let (pk, vk) = client.setup(elf); let mut stdin = SP1Stdin::new(); stdin.write(&10usize); - let proof = client.prove_plonk(&pk, stdin).unwrap(); - client.verify_plonk(&proof, &vk).unwrap(); + let proof = client.prove(&pk, stdin).plonk().run().unwrap(); + client.verify(&proof, &vk).unwrap(); } } diff --git a/sdk/src/network/auth.rs b/sdk/src/network/auth.rs index 2f34fd0f02..0ec918d778 100644 --- a/sdk/src/network/auth.rs +++ b/sdk/src/network/auth.rs @@ -39,15 +39,6 @@ sol! { uint64 nonce; string proof_id; } - - struct RelayProof { - uint64 nonce; - string proof_id; - uint32 chain_id; - address verifier; - address callback; - bytes callback_data; - } } /// Handles authentication for the Succinct prover network. All interactions that could potentially @@ -150,26 +141,4 @@ impl NetworkAuth { }; self.sign_message(type_struct).await } - - /// Signs a message to remote relay a proof to a specific chain with the verifier and callback - /// specified. - pub async fn sign_relay_proof_message( - &self, - nonce: u64, - proof_id: &str, - chain_id: u32, - verifier: [u8; 20], - callback: [u8; 20], - callback_data: &[u8], - ) -> Result> { - let type_struct = RelayProof { - nonce, - proof_id: proof_id.to_string(), - chain_id, - verifier: verifier.into(), - callback: callback.into(), - callback_data: callback_data.to_vec().into(), - }; - self.sign_message(type_struct).await - } } diff --git a/sdk/src/network/client.rs b/sdk/src/network/client.rs index 9b04ae3b00..9e789c7253 100644 --- a/sdk/src/network/client.rs +++ b/sdk/src/network/client.rs @@ -5,28 +5,25 @@ use crate::{ proto::network::{UnclaimProofRequest, UnclaimReason}, }; use anyhow::{Context, Ok, Result}; -use futures::future::join_all; +use futures::{future::join_all, Future}; use reqwest::{Client as HttpClient, Url}; use reqwest_middleware::ClientWithMiddleware as HttpClientWithMiddleware; use serde::de::DeserializeOwned; use sp1_prover::SP1Stdin; +use std::result::Result::Ok as StdOk; use std::time::{SystemTime, UNIX_EPOCH}; -use twirp::Client as TwirpClient; +use twirp::{Client as TwirpClient, ClientError}; use crate::proto::network::{ ClaimProofRequest, ClaimProofResponse, CreateProofRequest, FulfillProofRequest, FulfillProofResponse, GetNonceRequest, GetProofRequestsRequest, GetProofRequestsResponse, - GetProofStatusRequest, GetProofStatusResponse, GetRelayStatusRequest, GetRelayStatusResponse, - NetworkServiceClient, ProofMode, ProofStatus, RelayProofRequest, SubmitProofRequest, - TransactionStatus, + GetProofStatusRequest, GetProofStatusResponse, NetworkServiceClient, ProofMode, ProofStatus, + SubmitProofRequest, }; /// The default RPC endpoint for the Succinct prover network. pub const DEFAULT_PROVER_NETWORK_RPC: &str = "https://rpc.succinct.xyz/"; -/// The default SP1 Verifier address on all chains. -const DEFAULT_SP1_VERIFIER_ADDRESS: &str = "0xed2107448519345059eab9cddab42ddc78fbebe9"; - /// The timeout for a proof request to be fulfilled. const TIMEOUT: Duration = Duration::from_secs(60 * 60); @@ -37,11 +34,12 @@ pub struct NetworkClient { } impl NetworkClient { + /// Returns the currently configured RPC endpoint for the Succinct prover network. pub fn rpc_url() -> String { env::var("PROVER_NETWORK_RPC").unwrap_or_else(|_| DEFAULT_PROVER_NETWORK_RPC.to_string()) } - // Create a new NetworkClient with the given private key for authentication. + /// Create a new NetworkClient with the given private key for authentication. pub fn new(private_key: &str) -> Self { let auth = NetworkAuth::new(private_key); @@ -68,45 +66,31 @@ impl NetworkClient { } } - // Get the address for the SP1 Verifier contract. - pub fn get_sp1_verifier_address() -> [u8; 20] { - let verifier_hex = env::var("SP1_VERIFIER_ADDRESS") - .unwrap_or_else(|_| DEFAULT_SP1_VERIFIER_ADDRESS.to_string()); - let verifier_bytes = hex::decode(verifier_hex.trim_start_matches("0x")) - .expect("Invalid SP1_VERIFIER_ADDRESS format"); - - verifier_bytes - .try_into() - .expect("SP1_VERIFIER_ADDRESS must be 20 bytes") - } - /// Gets the latest nonce for this auth's account. pub async fn get_nonce(&self) -> Result { let res = self - .rpc - .get_nonce(GetNonceRequest { + .with_error_handling(self.rpc.get_nonce(GetNonceRequest { address: self.auth.get_address().to_vec(), - }) + })) .await?; Ok(res.nonce) } - // Upload a file to the specified url. + /// Upload a file to the specified url. async fn upload_file(&self, url: &str, data: Vec) -> Result<()> { self.http.put(url).body(data).send().await?; Ok(()) } - // Get the status of a given proof. If the status is ProofFulfilled, the proof is also returned. + /// Get the status of a given proof. If the status is ProofFulfilled, the proof is also returned. pub async fn get_proof_status( &self, proof_id: &str, ) -> Result<(GetProofStatusResponse, Option

)> { let res = self - .rpc - .get_proof_status(GetProofStatusRequest { + .with_error_handling(self.rpc.get_proof_status(GetProofStatusRequest { proof_id: proof_id.to_string(), - }) + })) .await .context("Failed to get proof status")?; @@ -131,44 +115,15 @@ impl NetworkClient { Ok((res, proof)) } - // Get all the proof requests for a given status. + /// Get all the proof requests for a given status. pub async fn get_proof_requests( &self, status: ProofStatus, ) -> Result { - let res = self - .rpc - .get_proof_requests(GetProofRequestsRequest { - status: status.into(), - }) - .await?; - - Ok(res) - } - - // Get the status of a relay transaction request. - pub async fn get_relay_status( - &self, - tx_id: &str, - ) -> Result<(GetRelayStatusResponse, Option, Option)> { - let res = self - .rpc - .get_relay_status(GetRelayStatusRequest { - tx_id: tx_id.to_string(), - }) - .await?; - - let tx_hash = match res.status() { - TransactionStatus::TransactionScheduled => None, - _ => Some(format!("0x{}", hex::encode(res.tx_hash.clone()))), - }; - - let simulation_url = match res.status() { - TransactionStatus::TransactionFailed => Some(res.simulation_url.clone()), - _ => None, - }; - - Ok((res, tx_hash, simulation_url)) + self.with_error_handling(self.rpc.get_proof_requests(GetProofRequestsRequest { + status: status.into(), + })) + .await } /// Creates a proof request for the given ELF and stdin. @@ -190,15 +145,15 @@ impl NetworkClient { .auth .sign_create_proof_message(nonce, deadline, mode.into(), version) .await?; + let res = self - .rpc - .create_proof(CreateProofRequest { + .with_error_handling(self.rpc.create_proof(CreateProofRequest { signature: create_proof_signature.to_vec(), nonce, deadline, mode: mode.into(), version: version.to_string(), - }) + })) .await?; let program_bytes = bincode::serialize(elf)?; @@ -215,37 +170,34 @@ impl NetworkClient { .auth .sign_submit_proof_message(nonce, &res.proof_id) .await?; - self.rpc - .submit_proof(SubmitProofRequest { - signature: submit_proof_signature.to_vec(), - nonce, - proof_id: res.proof_id.clone(), - }) - .await?; + + self.with_error_handling(self.rpc.submit_proof(SubmitProofRequest { + signature: submit_proof_signature.to_vec(), + nonce, + proof_id: res.proof_id.clone(), + })) + .await?; Ok(res.proof_id) } - // Claim a proof that was requested. This commits to generating a proof and fulfilling it. - // Returns an error if the proof is not in a PROOF_REQUESTED state. + /// Claim a proof that was requested. This commits to generating a proof and fulfilling it. + /// Returns an error if the proof is not in a PROOF_REQUESTED state. pub async fn claim_proof(&self, proof_id: &str) -> Result { let nonce = self.get_nonce().await?; let signature = self.auth.sign_claim_proof_message(nonce, proof_id).await?; - let res = self - .rpc - .claim_proof(ClaimProofRequest { - signature, - nonce, - proof_id: proof_id.to_string(), - }) - .await?; - Ok(res) + self.with_error_handling(self.rpc.claim_proof(ClaimProofRequest { + signature, + nonce, + proof_id: proof_id.to_string(), + })) + .await } - // Unclaim a proof that was claimed. This should only be called if the proof has not been - // fulfilled yet. Returns an error if the proof is not in a PROOF_CLAIMED state or if the caller - // is not the claimer. + /// Unclaim a proof that was claimed. This should only be called if the proof has not been + /// fulfilled yet. Returns an error if the proof is not in a PROOF_CLAIMED state or if the caller + /// is not the claimer. pub async fn unclaim_proof( &self, proof_id: String, @@ -257,21 +209,21 @@ impl NetworkClient { .auth .sign_unclaim_proof_message(nonce, proof_id.clone(), reason, description.clone()) .await?; - self.rpc - .unclaim_proof(UnclaimProofRequest { - signature, - nonce, - proof_id, - reason: reason.into(), - description, - }) - .await?; + + self.with_error_handling(self.rpc.unclaim_proof(UnclaimProofRequest { + signature, + nonce, + proof_id, + reason: reason.into(), + description, + })) + .await?; Ok(()) } - // Fulfill a proof. Should only be called after the proof has been uploaded. Returns an error - // if the proof is not in a PROOF_CLAIMED state or if the caller is not the claimer. + /// Fulfill a proof. Should only be called after the proof has been uploaded. Returns an error + /// if the proof is not in a PROOF_CLAIMED state or if the caller is not the claimer. pub async fn fulfill_proof(&self, proof_id: &str) -> Result { let nonce = self.get_nonce().await?; let signature = self @@ -279,41 +231,34 @@ impl NetworkClient { .sign_fulfill_proof_message(nonce, proof_id) .await?; let res = self - .rpc - .fulfill_proof(FulfillProofRequest { + .with_error_handling(self.rpc.fulfill_proof(FulfillProofRequest { signature, nonce, proof_id: proof_id.to_string(), - }) + })) .await?; Ok(res) } - // Relay a proof. Returns an error if the proof is not in a PROOF_FULFILLED state. - pub async fn relay_proof( - &self, - proof_id: &str, - chain_id: u32, - verifier: [u8; 20], - callback: [u8; 20], - callback_data: &[u8], - ) -> Result { - let nonce = self.get_nonce().await?; - let signature = self - .auth - .sign_relay_proof_message(nonce, proof_id, chain_id, verifier, callback, callback_data) - .await?; - let req = RelayProofRequest { - signature, - nonce, - proof_id: proof_id.to_string(), - chain_id, - verifier: verifier.to_vec(), - callback: callback.to_vec(), - callback_data: callback_data.to_vec(), - }; - let result = self.rpc.relay_proof(req).await?; - Ok(result.tx_id) + /// Awaits the future, then handles Succinct prover network errors. + async fn with_error_handling(&self, future: F) -> Result + where + F: Future>, + { + let result = future.await; + self.handle_twirp_error(result) + } + + /// Handles Twirp errors by formatting them into more readable error messages. + fn handle_twirp_error(&self, result: std::result::Result) -> Result { + match result { + StdOk(response) => StdOk(response), + Err(ClientError::TwirpError(err)) => { + let display_err = format!("error: \"{:?}\" message: {:?}", err.code, err.msg); + Err(anyhow::anyhow!(display_err)) + } + Err(err) => Err(err.into()), + } } } diff --git a/sdk/src/network/prover.rs b/sdk/src/network/prover.rs index ba54cb6d9e..5a9d4672ac 100644 --- a/sdk/src/network/prover.rs +++ b/sdk/src/network/prover.rs @@ -1,15 +1,17 @@ use std::{env, time::Duration}; +use crate::install::block_on; use crate::proto::network::ProofMode; use crate::{ network::client::{NetworkClient, DEFAULT_PROVER_NETWORK_RPC}, proto::network::ProofStatus, Prover, }; -use crate::{SP1CompressedProof, SP1PlonkBn254Proof, SP1Proof, SP1ProvingKey, SP1VerifyingKey}; +use crate::{SP1Context, SP1ProofKind, SP1ProofWithPublicValues, SP1ProvingKey, SP1VerifyingKey}; use anyhow::Result; use serde::de::DeserializeOwned; -use sp1_prover::utils::block_on; +use sp1_core::utils::SP1ProverOpts; +use sp1_prover::components::DefaultProverComponents; use sp1_prover::{SP1Prover, SP1Stdin, SP1_CIRCUIT_VERSION}; use tokio::time::sleep; @@ -18,7 +20,7 @@ use crate::provers::{LocalProver, ProverType}; /// An implementation of [crate::ProverClient] that can generate proofs on a remote RPC server. pub struct NetworkProver { client: NetworkClient, - local_prover: LocalProver, + local_prover: LocalProver, } impl NetworkProver { @@ -55,7 +57,8 @@ impl NetworkProver { .unwrap_or(false); if !skip_simulation { - let (_, report) = SP1Prover::execute(elf, &stdin)?; + let (_, report) = + SP1Prover::::execute(elf, &stdin, Default::default())?; log::info!( "Simulation complete, cycles: {}", report.total_instruction_count() @@ -107,13 +110,18 @@ impl NetworkProver { } /// Requests a proof from the prover network and waits for it to be generated. - pub async fn prove(&self, elf: &[u8], stdin: SP1Stdin) -> Result

{ - let proof_id = self.request_proof(elf, stdin, P::PROOF_MODE).await?; + pub async fn prove( + &self, + elf: &[u8], + stdin: SP1Stdin, + mode: ProofMode, + ) -> Result { + let proof_id = self.request_proof(elf, stdin, mode).await?; self.wait_proof(&proof_id).await } } -impl Prover for NetworkProver { +impl Prover for NetworkProver { fn id(&self) -> ProverType { ProverType::Network } @@ -126,16 +134,16 @@ impl Prover for NetworkProver { self.local_prover.sp1_prover() } - fn prove(&self, pk: &SP1ProvingKey, stdin: SP1Stdin) -> Result { - block_on(self.prove(&pk.elf, stdin)) - } - - fn prove_compressed(&self, pk: &SP1ProvingKey, stdin: SP1Stdin) -> Result { - block_on(self.prove(&pk.elf, stdin)) - } - - fn prove_plonk(&self, pk: &SP1ProvingKey, stdin: SP1Stdin) -> Result { - block_on(self.prove(&pk.elf, stdin)) + fn prove<'a>( + &'a self, + pk: &SP1ProvingKey, + stdin: SP1Stdin, + opts: SP1ProverOpts, + context: SP1Context<'a>, + kind: SP1ProofKind, + ) -> Result { + warn_if_not_default(&opts, &context); + block_on(self.prove(&pk.elf, stdin, kind.into())) } } @@ -145,19 +153,39 @@ impl Default for NetworkProver { } } -/// A deserializable proof struct that has an associated ProofMode. -pub trait ProofType: DeserializeOwned { - const PROOF_MODE: ProofMode; -} - -impl ProofType for SP1Proof { - const PROOF_MODE: ProofMode = ProofMode::Core; -} - -impl ProofType for SP1CompressedProof { - const PROOF_MODE: ProofMode = ProofMode::Compressed; +/// Warns if `opts` or `context` are not default values, since they are currently unsupported. +fn warn_if_not_default(opts: &SP1ProverOpts, context: &SP1Context) { + let _guard = tracing::warn_span!("network_prover").entered(); + if opts != &SP1ProverOpts::default() { + tracing::warn!("non-default opts will be ignored: {:?}", opts.core_opts); + tracing::warn!("custom SP1ProverOpts are currently unsupported by the network prover"); + } + // Exhaustive match is done to ensure we update the warnings if the types change. + let SP1Context { + hook_registry, + subproof_verifier, + .. + } = context; + if hook_registry.is_some() { + tracing::warn!( + "non-default context.hook_registry will be ignored: {:?}", + hook_registry + ); + tracing::warn!("custom runtime hooks are currently unsupported by the network prover"); + tracing::warn!("proving may fail due to missing hooks"); + } + if subproof_verifier.is_some() { + tracing::warn!("non-default context.subproof_verifier will be ignored"); + tracing::warn!("custom subproof verifiers are currently unsupported by the network prover"); + } } -impl ProofType for SP1PlonkBn254Proof { - const PROOF_MODE: ProofMode = ProofMode::Plonk; +impl From for ProofMode { + fn from(value: SP1ProofKind) -> Self { + match value { + SP1ProofKind::Core => Self::Core, + SP1ProofKind::Compressed => Self::Compressed, + SP1ProofKind::Plonk => Self::Plonk, + } + } } diff --git a/sdk/src/proof.rs b/sdk/src/proof.rs new file mode 100644 index 0000000000..86d8939f74 --- /dev/null +++ b/sdk/src/proof.rs @@ -0,0 +1,70 @@ +use std::{fmt::Debug, fs::File, path::Path}; + +use anyhow::Result; +use serde::{Deserialize, Serialize}; +use strum_macros::{EnumDiscriminants, EnumTryAs}; + +use sp1_core::stark::{MachineVerificationError, ShardProof}; +use sp1_prover::{CoreSC, InnerSC, PlonkBn254Proof, SP1PublicValues, SP1Stdin}; + +/// A proof generated with SP1 of a particular proof mode. +#[derive(Debug, Clone, Serialize, Deserialize, EnumDiscriminants, EnumTryAs)] +#[strum_discriminants(derive(Default, Hash, PartialOrd, Ord))] +#[strum_discriminants(name(SP1ProofKind))] +pub enum SP1Proof { + #[strum_discriminants(default)] + Core(Vec>), + Compressed(ShardProof), + Plonk(PlonkBn254Proof), +} + +/// A proof generated with SP1, bundled together with stdin, public values, and the SP1 version. +#[derive(Debug, Clone, Serialize, Deserialize)] +pub struct SP1ProofWithPublicValues { + pub proof: SP1Proof, + pub stdin: SP1Stdin, + pub public_values: SP1PublicValues, + pub sp1_version: String, +} + +impl SP1ProofWithPublicValues { + /// Saves the proof to a path. + pub fn save(&self, path: impl AsRef) -> Result<()> { + bincode::serialize_into(File::create(path).expect("failed to open file"), self) + .map_err(Into::into) + } + + /// Loads a proof from a path. + pub fn load(path: impl AsRef) -> Result { + bincode::deserialize_from(File::open(path).expect("failed to open file")) + .map_err(Into::into) + } + + /// Returns the raw proof as a string. + pub fn raw(&self) -> String { + match &self.proof { + SP1Proof::Plonk(plonk) => plonk.raw_proof.clone(), + _ => unimplemented!(), + } + } + + /// For Plonk proofs, returns the proof in a byte encoding the onchain verifier accepts. + /// The bytes consist of the first four bytes of Plonk vkey hash followed by the encoded proof. + pub fn bytes(&self) -> Vec { + match &self.proof { + SP1Proof::Plonk(plonk_proof) => { + let mut bytes = Vec::with_capacity(4 + plonk_proof.encoded_proof.len()); + bytes.extend_from_slice(&plonk_proof.plonk_vkey_hash[..4]); + bytes.extend_from_slice( + &hex::decode(&plonk_proof.encoded_proof).expect("Invalid Plonk proof"), + ); + bytes + } + _ => unimplemented!("only Plonk proofs are verifiable onchain"), + } + } +} + +pub type SP1CoreProofVerificationError = MachineVerificationError; + +pub type SP1CompressedProofVerificationError = MachineVerificationError; diff --git a/sdk/src/provers/local.rs b/sdk/src/provers/local.rs index d3c60cdac1..f192455e43 100644 --- a/sdk/src/provers/local.rs +++ b/sdk/src/provers/local.rs @@ -1,27 +1,34 @@ use anyhow::Result; -use sp1_prover::{SP1Prover, SP1Stdin}; +use sp1_core::{runtime::SP1Context, utils::SP1ProverOpts}; +use sp1_prover::{components::SP1ProverComponents, SP1Prover, SP1Stdin}; +use sysinfo::System; use crate::{ - Prover, SP1CompressedProof, SP1PlonkBn254Proof, SP1Proof, SP1ProofWithPublicValues, - SP1ProvingKey, SP1VerifyingKey, + install::try_install_plonk_bn254_artifacts, Prover, SP1Proof, SP1ProofKind, + SP1ProofWithPublicValues, SP1ProvingKey, SP1VerifyingKey, }; use super::ProverType; /// An implementation of [crate::ProverClient] that can generate end-to-end proofs locally. -pub struct LocalProver { - prover: SP1Prover, +pub struct LocalProver { + prover: SP1Prover, } -impl LocalProver { +impl LocalProver { /// Creates a new [LocalProver]. pub fn new() -> Self { let prover = SP1Prover::new(); Self { prover } } + + /// Creates a new [LocalProver] from an existing [SP1Prover]. + pub fn from_prover(prover: SP1Prover) -> Self { + Self { prover } + } } -impl Prover for LocalProver { +impl Prover for LocalProver { fn id(&self) -> ProverType { ProverType::Local } @@ -30,40 +37,47 @@ impl Prover for LocalProver { self.prover.setup(elf) } - fn sp1_prover(&self) -> &SP1Prover { + fn sp1_prover(&self) -> &SP1Prover { &self.prover } - fn prove(&self, pk: &SP1ProvingKey, stdin: SP1Stdin) -> Result { - let proof = self.prover.prove_core(pk, &stdin)?; - Ok(SP1ProofWithPublicValues { - proof: proof.proof.0, - stdin: proof.stdin, - public_values: proof.public_values, - sp1_version: self.version().to_string(), - }) - } - - fn prove_compressed(&self, pk: &SP1ProvingKey, stdin: SP1Stdin) -> Result { - let proof = self.prover.prove_core(pk, &stdin)?; - let deferred_proofs = stdin.proofs.iter().map(|p| p.0.clone()).collect(); - let public_values = proof.public_values.clone(); - let reduce_proof = self.prover.compress(&pk.vk, proof, deferred_proofs)?; - Ok(SP1CompressedProof { - proof: reduce_proof.proof, - stdin, - public_values, - sp1_version: self.version().to_string(), - }) - } + fn prove<'a>( + &'a self, + pk: &SP1ProvingKey, + stdin: SP1Stdin, + opts: SP1ProverOpts, + context: SP1Context<'a>, + kind: SP1ProofKind, + ) -> Result { + let total_ram_gb = System::new_all().total_memory() / 1_000_000_000; + if kind == SP1ProofKind::Plonk && total_ram_gb <= 120 { + return Err(anyhow::anyhow!( + "not enough memory to generate plonk proof. at least 128GB is required." + )); + } - fn prove_plonk(&self, pk: &SP1ProvingKey, stdin: SP1Stdin) -> Result { - let proof = self.prover.prove_core(pk, &stdin)?; + let proof = self.prover.prove_core(pk, &stdin, opts, context)?; + if kind == SP1ProofKind::Core { + return Ok(SP1ProofWithPublicValues { + proof: SP1Proof::Core(proof.proof.0), + stdin: proof.stdin, + public_values: proof.public_values, + sp1_version: self.version().to_string(), + }); + } let deferred_proofs = stdin.proofs.iter().map(|p| p.0.clone()).collect(); let public_values = proof.public_values.clone(); - let reduce_proof = self.prover.compress(&pk.vk, proof, deferred_proofs)?; - let compress_proof = self.prover.shrink(reduce_proof)?; - let outer_proof = self.prover.wrap_bn254(compress_proof)?; + let reduce_proof = self.prover.compress(&pk.vk, proof, deferred_proofs, opts)?; + if kind == SP1ProofKind::Compressed { + return Ok(SP1ProofWithPublicValues { + proof: SP1Proof::Compressed(reduce_proof.proof), + stdin, + public_values, + sp1_version: self.version().to_string(), + }); + } + let compress_proof = self.prover.shrink(reduce_proof, opts)?; + let outer_proof = self.prover.wrap_bn254(compress_proof, opts)?; let plonk_bn254_aritfacts = if sp1_prover::build::sp1_dev_mode() { sp1_prover::build::try_build_plonk_bn254_artifacts_dev( @@ -71,21 +85,24 @@ impl Prover for LocalProver { &outer_proof.proof, ) } else { - sp1_prover::build::try_install_plonk_bn254_artifacts() + try_install_plonk_bn254_artifacts() }; let proof = self .prover .wrap_plonk_bn254(outer_proof, &plonk_bn254_aritfacts); - Ok(SP1ProofWithPublicValues { - proof, - stdin, - public_values, - sp1_version: self.version().to_string(), - }) + if kind == SP1ProofKind::Plonk { + return Ok(SP1ProofWithPublicValues { + proof: SP1Proof::Plonk(proof), + stdin, + public_values, + sp1_version: self.version().to_string(), + }); + } + unreachable!() } } -impl Default for LocalProver { +impl Default for LocalProver { fn default() -> Self { Self::new() } diff --git a/sdk/src/provers/mock.rs b/sdk/src/provers/mock.rs index 8c5859ea82..0b41471c1f 100644 --- a/sdk/src/provers/mock.rs +++ b/sdk/src/provers/mock.rs @@ -1,12 +1,22 @@ #![allow(unused_variables)] +use hashbrown::HashMap; + use crate::{ - Prover, SP1CompressedProof, SP1PlonkBn254Proof, SP1Proof, SP1ProofWithPublicValues, - SP1ProvingKey, SP1VerificationError, SP1VerifyingKey, + Prover, SP1Proof, SP1ProofKind, SP1ProofWithPublicValues, SP1ProvingKey, SP1VerificationError, + SP1VerifyingKey, }; use anyhow::Result; -use p3_field::PrimeField; +use p3_baby_bear::BabyBear; +use p3_field::{AbstractField, PrimeField}; +use p3_fri::{FriProof, TwoAdicFriPcsProof}; +use sp1_core::{ + runtime::SP1Context, + stark::{ShardCommitment, ShardOpenedValues, ShardProof}, + utils::SP1ProverOpts, +}; use sp1_prover::{ - verify::verify_plonk_bn254_public_inputs, HashableKey, PlonkBn254Proof, SP1Prover, SP1Stdin, + components::DefaultProverComponents, verify::verify_plonk_bn254_public_inputs, HashableKey, + PlonkBn254Proof, SP1Prover, SP1Stdin, }; use super::ProverType; @@ -24,7 +34,7 @@ impl MockProver { } } -impl Prover for MockProver { +impl Prover for MockProver { fn id(&self) -> ProverType { ProverType::Mock } @@ -34,69 +44,89 @@ impl Prover for MockProver { } fn sp1_prover(&self) -> &SP1Prover { - unimplemented!("MockProver does not support SP1Prover") - } - - fn prove(&self, pk: &SP1ProvingKey, stdin: SP1Stdin) -> Result { - let (public_values, _) = SP1Prover::execute(&pk.elf, &stdin)?; - Ok(SP1ProofWithPublicValues { - proof: vec![], - stdin, - public_values, - sp1_version: self.version().to_string(), - }) + &self.prover } - fn prove_compressed( - &self, - _pk: &SP1ProvingKey, - _stdin: SP1Stdin, - ) -> Result { - unimplemented!() - } - - fn prove_plonk(&self, pk: &SP1ProvingKey, stdin: SP1Stdin) -> Result { - let (public_values, _) = SP1Prover::execute(&pk.elf, &stdin)?; - Ok(SP1PlonkBn254Proof { - proof: PlonkBn254Proof { - public_inputs: [ - pk.vk.hash_bn254().as_canonical_biguint().to_string(), - public_values.hash().to_string(), - ], - encoded_proof: "".to_string(), - raw_proof: "".to_string(), - plonk_vkey_hash: [0; 32], - }, - stdin, - public_values, - sp1_version: self.version().to_string(), - }) + fn prove<'a>( + &'a self, + pk: &SP1ProvingKey, + stdin: SP1Stdin, + opts: SP1ProverOpts, + context: SP1Context<'a>, + kind: SP1ProofKind, + ) -> Result { + match kind { + SP1ProofKind::Core => { + let (public_values, _) = + SP1Prover::::execute(&pk.elf, &stdin, context)?; + Ok(SP1ProofWithPublicValues { + proof: SP1Proof::Core(vec![]), + stdin, + public_values, + sp1_version: self.version().to_string(), + }) + } + SP1ProofKind::Compressed => { + let (public_values, _) = + SP1Prover::::execute(&pk.elf, &stdin, context)?; + Ok(SP1ProofWithPublicValues { + proof: SP1Proof::Compressed(ShardProof { + commitment: ShardCommitment { + main_commit: [BabyBear::zero(); 8].into(), + permutation_commit: [BabyBear::zero(); 8].into(), + quotient_commit: [BabyBear::zero(); 8].into(), + }, + opened_values: ShardOpenedValues { chips: vec![] }, + opening_proof: TwoAdicFriPcsProof { + fri_proof: FriProof { + commit_phase_commits: vec![], + query_proofs: vec![], + final_poly: Default::default(), + pow_witness: BabyBear::zero(), + }, + query_openings: vec![], + }, + chip_ordering: HashMap::new(), + public_values: vec![], + }), + stdin, + public_values, + sp1_version: self.version().to_string(), + }) + } + SP1ProofKind::Plonk => { + let (public_values, _) = + SP1Prover::::execute(&pk.elf, &stdin, context)?; + Ok(SP1ProofWithPublicValues { + proof: SP1Proof::Plonk(PlonkBn254Proof { + public_inputs: [ + pk.vk.hash_bn254().as_canonical_biguint().to_string(), + public_values.hash().to_string(), + ], + encoded_proof: "".to_string(), + raw_proof: "".to_string(), + plonk_vkey_hash: [0; 32], + }), + stdin, + public_values, + sp1_version: self.version().to_string(), + }) + } + } } fn verify( &self, - _proof: &SP1Proof, - _vkey: &SP1VerifyingKey, - ) -> Result<(), SP1VerificationError> { - Ok(()) - } - - fn verify_compressed( - &self, - _proof: &SP1CompressedProof, - _vkey: &SP1VerifyingKey, - ) -> Result<(), SP1VerificationError> { - Ok(()) - } - - fn verify_plonk( - &self, - proof: &SP1PlonkBn254Proof, + bundle: &SP1ProofWithPublicValues, vkey: &SP1VerifyingKey, ) -> Result<(), SP1VerificationError> { - verify_plonk_bn254_public_inputs(vkey, &proof.public_values, &proof.proof.public_inputs) - .map_err(SP1VerificationError::Plonk)?; - Ok(()) + match &bundle.proof { + SP1Proof::Plonk(PlonkBn254Proof { public_inputs, .. }) => { + verify_plonk_bn254_public_inputs(vkey, &bundle.public_values, public_inputs) + .map_err(SP1VerificationError::Plonk) + } + _ => Ok(()), + } } } diff --git a/sdk/src/provers/mod.rs b/sdk/src/provers/mod.rs index f682601a56..75acc8e488 100644 --- a/sdk/src/provers/mod.rs +++ b/sdk/src/provers/mod.rs @@ -1,12 +1,14 @@ mod local; mod mock; -use crate::{SP1CompressedProof, SP1PlonkBn254Proof, SP1Proof}; use anyhow::Result; pub use local::LocalProver; pub use mock::MockProver; +use sp1_core::runtime::SP1Context; use sp1_core::stark::MachineVerificationError; +use sp1_core::utils::SP1ProverOpts; use sp1_core::SP1_CIRCUIT_VERSION; +use sp1_prover::components::SP1ProverComponents; use sp1_prover::CoreSC; use sp1_prover::InnerSC; use sp1_prover::SP1CoreProofData; @@ -16,6 +18,11 @@ use sp1_prover::{SP1ProvingKey, SP1Stdin, SP1VerifyingKey}; use strum_macros::EnumString; use thiserror::Error; +use crate::install::try_install_plonk_bn254_artifacts; +use crate::SP1Proof; +use crate::SP1ProofKind; +use crate::SP1ProofWithPublicValues; + /// The type of prover. #[derive(Debug, PartialEq, EnumString)] pub enum ProverType { @@ -37,10 +44,10 @@ pub enum SP1VerificationError { } /// An implementation of [crate::ProverClient]. -pub trait Prover: Send + Sync { +pub trait Prover: Send + Sync { fn id(&self) -> ProverType; - fn sp1_prover(&self) -> &SP1Prover; + fn sp1_prover(&self) -> &SP1Prover; fn version(&self) -> &str { SP1_CIRCUIT_VERSION @@ -48,76 +55,51 @@ pub trait Prover: Send + Sync { fn setup(&self, elf: &[u8]) -> (SP1ProvingKey, SP1VerifyingKey); - /// Prove the execution of a RISCV ELF with the given inputs. - fn prove(&self, pk: &SP1ProvingKey, stdin: SP1Stdin) -> Result; - - /// Generate a compressed proof of the execution of a RISCV ELF with the given inputs. - fn prove_compressed(&self, pk: &SP1ProvingKey, stdin: SP1Stdin) -> Result; - - /// Given an SP1 program and input, generate a PLONK proof that can be verified on-chain. - fn prove_plonk(&self, pk: &SP1ProvingKey, stdin: SP1Stdin) -> Result; + /// Prove the execution of a RISCV ELF with the given inputs, according to the given proof mode. + fn prove<'a>( + &'a self, + pk: &SP1ProvingKey, + stdin: SP1Stdin, + opts: SP1ProverOpts, + context: SP1Context<'a>, + kind: SP1ProofKind, + ) -> Result; /// Verify that an SP1 proof is valid given its vkey and metadata. - fn verify(&self, proof: &SP1Proof, vkey: &SP1VerifyingKey) -> Result<(), SP1VerificationError> { - if proof.sp1_version != self.version() { - return Err(SP1VerificationError::VersionMismatch( - proof.sp1_version.clone(), - )); - } - self.sp1_prover() - .verify(&SP1CoreProofData(proof.proof.clone()), vkey) - .map_err(SP1VerificationError::Core) - } - - /// Verify that a compressed SP1 proof is valid given its vkey and metadata. - fn verify_compressed( - &self, - proof: &SP1CompressedProof, - vkey: &SP1VerifyingKey, - ) -> Result<(), SP1VerificationError> { - if proof.sp1_version != self.version() { - return Err(SP1VerificationError::VersionMismatch( - proof.sp1_version.clone(), - )); - } - self.sp1_prover() - .verify_compressed( - &SP1ReduceProof { - proof: proof.proof.clone(), - }, - vkey, - ) - .map_err(SP1VerificationError::Recursion) - } - - /// Verify that a SP1 PLONK proof is valid. Verify that the public inputs of the PlonkBn254 proof match + /// For Plonk proofs, verifies that the public inputs of the PlonkBn254 proof match /// the hash of the VK and the committed public values of the SP1ProofWithPublicValues. - fn verify_plonk( + fn verify( &self, - proof: &SP1PlonkBn254Proof, + bundle: &SP1ProofWithPublicValues, vkey: &SP1VerifyingKey, ) -> Result<(), SP1VerificationError> { - if proof.sp1_version != self.version() { + if bundle.sp1_version != self.version() { return Err(SP1VerificationError::VersionMismatch( - proof.sp1_version.clone(), + bundle.sp1_version.clone(), )); } - let sp1_prover = self.sp1_prover(); - - let plonk_bn254_aritfacts = if sp1_prover::build::sp1_dev_mode() { - sp1_prover::build::plonk_bn254_artifacts_dev_dir() - } else { - sp1_prover::build::try_install_plonk_bn254_artifacts() - }; - sp1_prover - .verify_plonk_bn254( - &proof.proof, - vkey, - &proof.public_values, - &plonk_bn254_aritfacts, - ) - .map_err(SP1VerificationError::Plonk)?; - - Ok(()) + match bundle.proof.clone() { + SP1Proof::Core(proof) => self + .sp1_prover() + .verify(&SP1CoreProofData(proof), vkey) + .map_err(SP1VerificationError::Core), + SP1Proof::Compressed(proof) => self + .sp1_prover() + .verify_compressed(&SP1ReduceProof { proof }, vkey) + .map_err(SP1VerificationError::Recursion), + SP1Proof::Plonk(proof) => self + .sp1_prover() + .verify_plonk_bn254( + &proof, + vkey, + &bundle.public_values, + &if sp1_prover::build::sp1_dev_mode() { + sp1_prover::build::plonk_bn254_artifacts_dev_dir() + } else { + try_install_plonk_bn254_artifacts() + }, + ) + .map_err(SP1VerificationError::Plonk), + } } } diff --git a/sp1up/install b/sp1up/install index 6e0ce40a5d..39dd6b941d 100644 --- a/sp1up/install +++ b/sp1up/install @@ -6,7 +6,7 @@ set -e echo Installing sp1up... -BASE_DIR=${XDG_CONFIG_HOME:-$HOME} +BASE_DIR=$HOME SP1_DIR=${SP1_DIR-"$BASE_DIR/.sp1"} SP1_BIN_DIR="$SP1_DIR/bin" diff --git a/sp1up/sp1up b/sp1up/sp1up index 94341ec117..d6ec849b75 100644 --- a/sp1up/sp1up +++ b/sp1up/sp1up @@ -4,7 +4,7 @@ set -eo pipefail -BASE_DIR=${XDG_CONFIG_HOME:-$HOME} +BASE_DIR=$HOME SP1_DIR=${SP1_DIR:-"$BASE_DIR/.sp1"} SP1_BIN_DIR="$SP1_DIR/bin" mkdir -p $SP1_BIN_DIR @@ -29,6 +29,7 @@ main() { -C|--commit) shift; SP1UP_COMMIT=$1;; --arch) shift; SP1UP_ARCH=$1;; --platform) shift; SP1UP_PLATFORM=$1;; + -t|--token) shift; GITHUB_TOKEN=$1;; -h|--help) usage exit 0 diff --git a/tests/bls12381-add/Cargo.lock b/tests/bls12381-add/Cargo.lock index a5ff069cb6..a2890ce511 100644 --- a/tests/bls12381-add/Cargo.lock +++ b/tests/bls12381-add/Cargo.lock @@ -8,30 +8,12 @@ version = "1.0.86" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "b3d1d046238990b9cf5bcde22a3fb3584ee5cf65fb2765f454ed428c7a0063da" -[[package]] -name = "arrayvec" -version = "0.7.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "96d30a06541fbafbc7f82ed10c06164cfbd2c401138f6addd8404629c4b16711" - [[package]] name = "autocfg" version = "1.2.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "f1fdabc7756949593fe60f30ec81974b613357de856987752631dea1e3394c80" -[[package]] -name = "base16ct" -version = "0.2.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4c7f02d4ea65f2c1853089ffd8d2787bdbc63de2f0d29dedbcf8ccdfa0ccd4cf" - -[[package]] -name = "base64ct" -version = "1.6.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8c3c1a368f70d6cf7302d78f8f7093da241fb8e8807c05cc9e51a125895a6d5b" - [[package]] name = "bincode" version = "1.3.3" @@ -41,18 +23,6 @@ dependencies = [ "serde", ] -[[package]] -name = "bitvec" -version = "1.0.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1bc2832c24239b0141d5674bb9174f9d68a8b5b3f2753311927c172ca46f7e9c" -dependencies = [ - "funty", - "radium", - "tap", - "wyz", -] - [[package]] name = "block-buffer" version = "0.10.4" @@ -70,24 +40,12 @@ dependencies = [ "sp1-zkvm", ] -[[package]] -name = "byte-slice-cast" -version = "1.2.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c3ac9f8b63eca6fd385229b3675f6cc0dc5c8a5c8a54a59d4f52ffd670d87b0c" - [[package]] name = "cfg-if" version = "1.0.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "baf1de4339761588bc0619e3cbc0120ee582ebb74b53b4efbf79117bd2da40fd" -[[package]] -name = "const-oid" -version = "0.9.6" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c2459377285ad874054d797f3ccebf984978aa39129f6eafde5cdc8315b612f8" - [[package]] name = "cpufeatures" version = "0.2.12" @@ -97,18 +55,6 @@ dependencies = [ "libc", ] -[[package]] -name = "crypto-bigint" -version = "0.5.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0dc92fb57ca44df6db8059111ab3af99a63d5d0f8375d9972e319a379c6bab76" -dependencies = [ - "generic-array", - "rand_core", - "subtle", - "zeroize", -] - [[package]] name = "crypto-common" version = "0.1.6" @@ -119,27 +65,6 @@ dependencies = [ "typenum", ] -[[package]] -name = "der" -version = "0.7.8" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "fffa369a668c8af7dbf8b5e56c9f744fbd399949ed171606040001947de40b1c" -dependencies = [ - "const-oid", - "zeroize", -] - -[[package]] -name = "derive_more" -version = "0.99.17" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4fb810d30a7c1953f91334de7244731fc3f3c10d7fe163338a35b9f640960321" -dependencies = [ - "proc-macro2", - "quote", - "syn 1.0.109", -] - [[package]] name = "digest" version = "0.10.7" @@ -147,68 +72,9 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "9ed9a281f7bc9b7576e61468ba615a66a5c8cfdff42420a70aa82701a3b1e292" dependencies = [ "block-buffer", - "const-oid", "crypto-common", - "subtle", -] - -[[package]] -name = "ecdsa" -version = "0.16.9" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ee27f32b5c5292967d2d4a9d7f1e0b0aed2c15daded5a60300e4abb9d8020bca" -dependencies = [ - "der", - "digest", - "elliptic-curve", - "rfc6979", - "signature", - "spki", -] - -[[package]] -name = "elliptic-curve" -version = "0.13.8" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b5e6043086bf7973472e0c7dff2142ea0b680d30e18d9cc40f267efbf222bd47" -dependencies = [ - "base16ct", - "crypto-bigint", - "digest", - "ff", - "generic-array", - "group", - "pkcs8", - "rand_core", - "sec1", - "subtle", - "tap", - "zeroize", -] - -[[package]] -name = "equivalent" -version = "1.0.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5443807d6dff69373d433ab9ef5378ad8df50ca6298caf15de6e52e24aaf54d5" - -[[package]] -name = "ff" -version = "0.13.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ded41244b729663b1e574f1b4fb731469f69f79c17667b5d776b16cda0479449" -dependencies = [ - "bitvec", - "rand_core", - "subtle", ] -[[package]] -name = "funty" -version = "2.0.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e6d5a32815ae3f33302d95fdcb2ce17862f8c65363dcfd29360480ba1001fc9c" - [[package]] name = "generic-array" version = "0.14.7" @@ -217,7 +83,6 @@ checksum = "85649ca51fd72272d7821adaf274ad91c288277713d9c18820d8499a7ff69e9a" dependencies = [ "typenum", "version_check", - "zeroize", ] [[package]] @@ -232,71 +97,10 @@ dependencies = [ ] [[package]] -name = "group" -version = "0.13.0" +name = "lazy_static" +version = "1.5.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f0f9ef7462f7c099f518d754361858f86d8a07af53ba9af0fe635bbccb151a63" -dependencies = [ - "ff", - "rand_core", - "subtle", -] - -[[package]] -name = "hashbrown" -version = "0.14.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "290f1a1d9242c78d09ce40a5e87e7554ee637af1351968159f4952f028f75604" - -[[package]] -name = "hex" -version = "0.4.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7f24254aa9a54b5c858eaee2f5bccdb46aaf0e486a595ed5fd8f86ba55232a70" - -[[package]] -name = "hmac" -version = "0.12.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6c49c37c09c17a53d937dfbb742eb3a961d65a994e6bcdcf37e7399d0cc8ab5e" -dependencies = [ - "digest", -] - -[[package]] -name = "impl-trait-for-tuples" -version = "0.2.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "11d7a9f6330b71fea57921c9b61c47ee6e84f72d394754eff6163ae67e7395eb" -dependencies = [ - "proc-macro2", - "quote", - "syn 1.0.109", -] - -[[package]] -name = "indexmap" -version = "2.2.6" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "168fb715dda47215e360912c096649d23d58bf392ac62f73919e831745e40f26" -dependencies = [ - "equivalent", - "hashbrown", -] - -[[package]] -name = "k256" -version = "0.13.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "956ff9b67e26e1a6a866cb758f12c6f8746208489e3e4a4b5580802f2f0a587b" -dependencies = [ - "cfg-if", - "ecdsa", - "elliptic-curve", - "once_cell", - "sha2", - "signature", -] +checksum = "bbd2bcb4c963f2ddae06a2efc7e9f3591312473c50c6685e1f298068316e66fe" [[package]] name = "libc" @@ -310,19 +114,12 @@ version = "0.2.8" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "4ec2a862134d2a7d32d7983ddcdd1c4923530833c9f2ea1a44fc5fa473989058" -[[package]] -name = "memchr" -version = "2.7.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6c8640c5d730cb13ebd907d8d04b52f55ac9a2eec55b440c8892f40d56c76c1d" - [[package]] name = "num" version = "0.4.3" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "35bd024e8b2ff75562e5f34e7f4905839deb4b22955ef5e73d2fea1b9813cb23" dependencies = [ - "num-bigint", "num-complex", "num-integer", "num-iter", @@ -330,16 +127,6 @@ dependencies = [ "num-traits", ] -[[package]] -name = "num-bigint" -version = "0.4.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c165a9ab64cf766f73521c0dd2cfdff64f488b8f0b3e621face3462d3db536d7" -dependencies = [ - "num-integer", - "num-traits", -] - [[package]] name = "num-complex" version = "0.4.6" @@ -375,7 +162,6 @@ version = "0.4.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "f83d14da390562dca69fc84082e73e548e1ad308d24accdedd2720017cb37824" dependencies = [ - "num-bigint", "num-integer", "num-traits", ] @@ -395,66 +181,12 @@ version = "1.19.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "3fdb12b2476b595f9358c5161aa467c2438859caa136dec86c26fdd2efe17b92" -[[package]] -name = "parity-scale-codec" -version = "3.6.9" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "881331e34fa842a2fb61cc2db9643a8fedc615e47cfcc52597d1af0db9a7e8fe" -dependencies = [ - "arrayvec", - "byte-slice-cast", - "impl-trait-for-tuples", - "parity-scale-codec-derive", -] - -[[package]] -name = "parity-scale-codec-derive" -version = "3.6.9" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "be30eaf4b0a9fba5336683b38de57bb86d179a35862ba6bfcf57625d006bde5b" -dependencies = [ - "proc-macro-crate 2.0.2", - "proc-macro2", - "quote", - "syn 1.0.109", -] - -[[package]] -name = "pkcs8" -version = "0.10.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f950b2377845cebe5cf8b5165cb3cc1a5e0fa5cfa3e1f7f55707d8fd82e0a7b7" -dependencies = [ - "der", - "spki", -] - [[package]] name = "ppv-lite86" version = "0.2.17" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "5b40af805b3121feab8a3c29f04d8ad262fa8e0561883e7653e024ae4479e6de" -[[package]] -name = "proc-macro-crate" -version = "1.3.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7f4c021e1093a56626774e81216a4ce732a735e5bad4868a03f3ed65ca0c3919" -dependencies = [ - "once_cell", - "toml_edit 0.19.15", -] - -[[package]] -name = "proc-macro-crate" -version = "2.0.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b00f26d3400549137f92511a46ac1cd8ce37cb5598a96d382381458b992a5d24" -dependencies = [ - "toml_datetime", - "toml_edit 0.20.2", -] - [[package]] name = "proc-macro2" version = "1.0.79" @@ -473,12 +205,6 @@ dependencies = [ "proc-macro2", ] -[[package]] -name = "radium" -version = "0.7.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "dc33ff2d4973d518d823d61aa239014831e521c75da58e3df4840d3f47749d09" - [[package]] name = "rand" version = "0.8.5" @@ -509,54 +235,6 @@ dependencies = [ "getrandom", ] -[[package]] -name = "rfc6979" -version = "0.4.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f8dd2a808d456c4a54e300a23e9f5a67e122c3024119acbfd73e3bf664491cb2" -dependencies = [ - "hmac", - "subtle", -] - -[[package]] -name = "scale-info" -version = "2.11.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7c453e59a955f81fb62ee5d596b450383d699f152d350e9d23a0db2adb78e4c0" -dependencies = [ - "cfg-if", - "derive_more", - "parity-scale-codec", - "scale-info-derive", -] - -[[package]] -name = "scale-info-derive" -version = "2.11.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "18cf6c6447f813ef19eb450e985bcce6705f9ce7660db221b59093d15c79c4b7" -dependencies = [ - "proc-macro-crate 1.3.1", - "proc-macro2", - "quote", - "syn 1.0.109", -] - -[[package]] -name = "sec1" -version = "0.7.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d3e97a565f76233a6003f9f5c54be1d9c5bdfa3eccfb189469f11ec4901c47dc" -dependencies = [ - "base16ct", - "der", - "generic-array", - "pkcs8", - "subtle", - "zeroize", -] - [[package]] name = "serde" version = "1.0.203" @@ -574,7 +252,7 @@ checksum = "500cbc0ebeb6f46627f50f3f5811ccf6bf00643be300b4c3eabc0ef55dc5b5ba" dependencies = [ "proc-macro2", "quote", - "syn 2.0.55", + "syn", ] [[package]] @@ -589,39 +267,13 @@ dependencies = [ ] [[package]] -name = "signature" -version = "2.2.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "77549399552de45a898a580c1b41d445bf730df867cc44e6c0233bbc4b8329de" -dependencies = [ - "digest", - "rand_core", -] - -[[package]] -name = "snowbridge-amcl" -version = "1.0.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "460a9ed63cdf03c1b9847e8a12a5f5ba19c4efd5869e4a737e05be25d7c427e5" -dependencies = [ - "parity-scale-codec", - "scale-info", -] - -[[package]] -name = "sp1-precompiles" +name = "sp1-lib" version = "0.1.0" dependencies = [ "anyhow", "bincode", "cfg-if", - "getrandom", - "hex", - "k256", - "num", - "rand", "serde", - "snowbridge-amcl", ] [[package]] @@ -631,40 +283,13 @@ dependencies = [ "bincode", "cfg-if", "getrandom", - "k256", + "lazy_static", "libm", "once_cell", "rand", "serde", "sha2", - "sp1-precompiles", -] - -[[package]] -name = "spki" -version = "0.7.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d91ed6c858b01f942cd56b37a94b3e0a1798290327d1236e4d9cf4eaca44d29d" -dependencies = [ - "base64ct", - "der", -] - -[[package]] -name = "subtle" -version = "2.5.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "81cdd64d312baedb58e21336b31bc043b77e01cc99033ce76ef539f78e965ebc" - -[[package]] -name = "syn" -version = "1.0.109" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "72b64191b275b66ffe2469e8af2c1cfe3bafa67b529ead792a6d0160888b4237" -dependencies = [ - "proc-macro2", - "quote", - "unicode-ident", + "sp1-lib", ] [[package]] @@ -678,40 +303,6 @@ dependencies = [ "unicode-ident", ] -[[package]] -name = "tap" -version = "1.0.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "55937e1799185b12863d447f42597ed69d9928686b8d88a1df17376a097d8369" - -[[package]] -name = "toml_datetime" -version = "0.6.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7cda73e2f1397b1262d6dfdcef8aafae14d1de7748d66822d3bfeeb6d03e5e4b" - -[[package]] -name = "toml_edit" -version = "0.19.15" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1b5bb770da30e5cbfde35a2d7b9b8a2c4b8ef89548a7a6aeab5c9a576e3e7421" -dependencies = [ - "indexmap", - "toml_datetime", - "winnow", -] - -[[package]] -name = "toml_edit" -version = "0.20.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "396e4d48bbb2b7554c944bde63101b5ae446cff6ec4a24227428f15eb72ef338" -dependencies = [ - "indexmap", - "toml_datetime", - "winnow", -] - [[package]] name = "typenum" version = "1.17.0" @@ -735,27 +326,3 @@ name = "wasi" version = "0.11.0+wasi-snapshot-preview1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "9c8d87e72b64a3b4db28d11ce29237c246188f4f51057d65a7eab63b7987e423" - -[[package]] -name = "winnow" -version = "0.5.40" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f593a95398737aeed53e489c785df13f3618e41dbcd6718c6addbf1395aa6876" -dependencies = [ - "memchr", -] - -[[package]] -name = "wyz" -version = "0.5.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "05f360fc0b24296329c78fda852a1e9ae82de9cf7b27dae4b7f62f118f77b9ed" -dependencies = [ - "tap", -] - -[[package]] -name = "zeroize" -version = "1.7.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "525b4ec142c6b68a2d10f01f7bbf6755599ca3f81ea53b8431b7dd348f5fdb2d" diff --git a/tests/bls12381-add/Cargo.toml b/tests/bls12381-add/Cargo.toml index 16e8468311..ff3fbc99f8 100644 --- a/tests/bls12381-add/Cargo.toml +++ b/tests/bls12381-add/Cargo.toml @@ -1,8 +1,9 @@ [workspace] [package] -version = "0.1.0" name = "bls12381-add-test" +version = "1.0.0-rc.1" edition = "2021" +publish = false [dependencies] sp1-zkvm = { path = "../../zkvm/entrypoint" } diff --git a/tests/bls12381-add/elf/riscv32im-succinct-zkvm-elf b/tests/bls12381-add/elf/riscv32im-succinct-zkvm-elf index 6e2c7e6866..add0efd030 100755 Binary files a/tests/bls12381-add/elf/riscv32im-succinct-zkvm-elf and b/tests/bls12381-add/elf/riscv32im-succinct-zkvm-elf differ diff --git a/tests/bls12381-add/src/main.rs b/tests/bls12381-add/src/main.rs index 681cf39afe..e40026e528 100644 --- a/tests/bls12381-add/src/main.rs +++ b/tests/bls12381-add/src/main.rs @@ -1,9 +1,8 @@ #![no_main] -sp1_zkvm::entrypoint!(main); -extern "C" { - fn syscall_bls12381_add(p: *mut u32, q: *const u32); -} +use sp1_zkvm::syscalls::syscall_bls12381_add; + +sp1_zkvm::entrypoint!(main); pub fn main() { for _ in 0..4 { @@ -31,9 +30,7 @@ pub fn main() { 22, ]; - unsafe { - syscall_bls12381_add(a.as_mut_ptr() as *mut u32, b.as_ptr() as *const u32); - } + syscall_bls12381_add(a.as_mut_ptr() as *mut u32, b.as_ptr() as *const u32); // 3 * generator. // 1527649530533633684281386512094328299672026648504329745640827351945739272160755686119065091946435084697047221031460 diff --git a/tests/bls12381-decompress/Cargo.lock b/tests/bls12381-decompress/Cargo.lock index 3f7f5f367e..1dacc7f0db 100644 --- a/tests/bls12381-decompress/Cargo.lock +++ b/tests/bls12381-decompress/Cargo.lock @@ -14,24 +14,6 @@ version = "0.7.4" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "96d30a06541fbafbc7f82ed10c06164cfbd2c401138f6addd8404629c4b16711" -[[package]] -name = "autocfg" -version = "1.2.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f1fdabc7756949593fe60f30ec81974b613357de856987752631dea1e3394c80" - -[[package]] -name = "base16ct" -version = "0.2.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4c7f02d4ea65f2c1853089ffd8d2787bdbc63de2f0d29dedbcf8ccdfa0ccd4cf" - -[[package]] -name = "base64ct" -version = "1.6.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8c3c1a368f70d6cf7302d78f8f7093da241fb8e8807c05cc9e51a125895a6d5b" - [[package]] name = "bincode" version = "1.3.3" @@ -41,18 +23,6 @@ dependencies = [ "serde", ] -[[package]] -name = "bitvec" -version = "1.0.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1bc2832c24239b0141d5674bb9174f9d68a8b5b3f2753311927c172ca46f7e9c" -dependencies = [ - "funty", - "radium", - "tap", - "wyz", -] - [[package]] name = "block-buffer" version = "0.10.4" @@ -64,7 +34,7 @@ dependencies = [ [[package]] name = "bls-decompress-test" -version = "0.1.0" +version = "1.0.0-rc.1" dependencies = [ "sp1-zkvm", ] @@ -81,12 +51,6 @@ version = "1.0.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "baf1de4339761588bc0619e3cbc0120ee582ebb74b53b4efbf79117bd2da40fd" -[[package]] -name = "const-oid" -version = "0.9.6" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c2459377285ad874054d797f3ccebf984978aa39129f6eafde5cdc8315b612f8" - [[package]] name = "cpufeatures" version = "0.2.12" @@ -96,18 +60,6 @@ dependencies = [ "libc", ] -[[package]] -name = "crypto-bigint" -version = "0.5.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0dc92fb57ca44df6db8059111ab3af99a63d5d0f8375d9972e319a379c6bab76" -dependencies = [ - "generic-array", - "rand_core", - "subtle", - "zeroize", -] - [[package]] name = "crypto-common" version = "0.1.6" @@ -118,25 +70,15 @@ dependencies = [ "typenum", ] -[[package]] -name = "der" -version = "0.7.8" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "fffa369a668c8af7dbf8b5e56c9f744fbd399949ed171606040001947de40b1c" -dependencies = [ - "const-oid", - "zeroize", -] - [[package]] name = "derive_more" -version = "0.99.17" +version = "0.99.18" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4fb810d30a7c1953f91334de7244731fc3f3c10d7fe163338a35b9f640960321" +checksum = "5f33878137e4dafd7fa914ad4e259e18a4e8e532b9617a2d0150262bf53abfce" dependencies = [ "proc-macro2", "quote", - "syn 1.0.109", + "syn 2.0.55", ] [[package]] @@ -146,43 +88,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "9ed9a281f7bc9b7576e61468ba615a66a5c8cfdff42420a70aa82701a3b1e292" dependencies = [ "block-buffer", - "const-oid", "crypto-common", - "subtle", -] - -[[package]] -name = "ecdsa" -version = "0.16.9" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ee27f32b5c5292967d2d4a9d7f1e0b0aed2c15daded5a60300e4abb9d8020bca" -dependencies = [ - "der", - "digest", - "elliptic-curve", - "rfc6979", - "signature", - "spki", -] - -[[package]] -name = "elliptic-curve" -version = "0.13.8" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b5e6043086bf7973472e0c7dff2142ea0b680d30e18d9cc40f267efbf222bd47" -dependencies = [ - "base16ct", - "crypto-bigint", - "digest", - "ff", - "generic-array", - "group", - "pkcs8", - "rand_core", - "sec1", - "subtle", - "tap", - "zeroize", ] [[package]] @@ -191,23 +97,6 @@ version = "1.0.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "5443807d6dff69373d433ab9ef5378ad8df50ca6298caf15de6e52e24aaf54d5" -[[package]] -name = "ff" -version = "0.13.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ded41244b729663b1e574f1b4fb731469f69f79c17667b5d776b16cda0479449" -dependencies = [ - "bitvec", - "rand_core", - "subtle", -] - -[[package]] -name = "funty" -version = "2.0.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e6d5a32815ae3f33302d95fdcb2ce17862f8c65363dcfd29360480ba1001fc9c" - [[package]] name = "generic-array" version = "0.14.7" @@ -216,7 +105,6 @@ checksum = "85649ca51fd72272d7821adaf274ad91c288277713d9c18820d8499a7ff69e9a" dependencies = [ "typenum", "version_check", - "zeroize", ] [[package]] @@ -230,22 +118,11 @@ dependencies = [ "wasi", ] -[[package]] -name = "group" -version = "0.13.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f0f9ef7462f7c099f518d754361858f86d8a07af53ba9af0fe635bbccb151a63" -dependencies = [ - "ff", - "rand_core", - "subtle", -] - [[package]] name = "hashbrown" -version = "0.14.3" +version = "0.14.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "290f1a1d9242c78d09ce40a5e87e7554ee637af1351968159f4952f028f75604" +checksum = "e5274423e17b7c9fc20b6e7e208532f9b19825d82dfd615708b70edd83df41f1" [[package]] name = "hex" @@ -253,15 +130,6 @@ version = "0.4.3" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "7f24254aa9a54b5c858eaee2f5bccdb46aaf0e486a595ed5fd8f86ba55232a70" -[[package]] -name = "hmac" -version = "0.12.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6c49c37c09c17a53d937dfbb742eb3a961d65a994e6bcdcf37e7399d0cc8ab5e" -dependencies = [ - "digest", -] - [[package]] name = "impl-trait-for-tuples" version = "0.2.2" @@ -284,18 +152,10 @@ dependencies = [ ] [[package]] -name = "k256" -version = "0.13.3" +name = "lazy_static" +version = "1.5.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "956ff9b67e26e1a6a866cb758f12c6f8746208489e3e4a4b5580802f2f0a587b" -dependencies = [ - "cfg-if", - "ecdsa", - "elliptic-curve", - "once_cell", - "sha2", - "signature", -] +checksum = "bbd2bcb4c963f2ddae06a2efc7e9f3591312473c50c6685e1f298068316e66fe" [[package]] name = "libc" @@ -311,82 +171,9 @@ checksum = "4ec2a862134d2a7d32d7983ddcdd1c4923530833c9f2ea1a44fc5fa473989058" [[package]] name = "memchr" -version = "2.7.2" +version = "2.7.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6c8640c5d730cb13ebd907d8d04b52f55ac9a2eec55b440c8892f40d56c76c1d" - -[[package]] -name = "num" -version = "0.4.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "35bd024e8b2ff75562e5f34e7f4905839deb4b22955ef5e73d2fea1b9813cb23" -dependencies = [ - "num-bigint", - "num-complex", - "num-integer", - "num-iter", - "num-rational", - "num-traits", -] - -[[package]] -name = "num-bigint" -version = "0.4.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c165a9ab64cf766f73521c0dd2cfdff64f488b8f0b3e621face3462d3db536d7" -dependencies = [ - "num-integer", - "num-traits", -] - -[[package]] -name = "num-complex" -version = "0.4.6" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "73f88a1307638156682bada9d7604135552957b7818057dcef22705b4d509495" -dependencies = [ - "num-traits", -] - -[[package]] -name = "num-integer" -version = "0.1.46" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7969661fd2958a5cb096e56c8e1ad0444ac2bbcd0061bd28660485a44879858f" -dependencies = [ - "num-traits", -] - -[[package]] -name = "num-iter" -version = "0.1.45" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1429034a0490724d0075ebb2bc9e875d6503c3cf69e235a8941aa757d83ef5bf" -dependencies = [ - "autocfg", - "num-integer", - "num-traits", -] - -[[package]] -name = "num-rational" -version = "0.4.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f83d14da390562dca69fc84082e73e548e1ad308d24accdedd2720017cb37824" -dependencies = [ - "num-bigint", - "num-integer", - "num-traits", -] - -[[package]] -name = "num-traits" -version = "0.2.19" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "071dfc062690e90b734c0b2273ce72ad0ffa95f0c74596bc250dcfd960262841" -dependencies = [ - "autocfg", -] +checksum = "78ca9ab1a0babb1e7d5695e3530886289c18cf2f87ec19a575a0abdce112e3a3" [[package]] name = "once_cell" @@ -396,9 +183,9 @@ checksum = "3fdb12b2476b595f9358c5161aa467c2438859caa136dec86c26fdd2efe17b92" [[package]] name = "parity-scale-codec" -version = "3.6.9" +version = "3.6.12" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "881331e34fa842a2fb61cc2db9643a8fedc615e47cfcc52597d1af0db9a7e8fe" +checksum = "306800abfa29c7f16596b5970a588435e3d5b3149683d00c12b699cc19f895ee" dependencies = [ "arrayvec", "byte-slice-cast", @@ -408,26 +195,16 @@ dependencies = [ [[package]] name = "parity-scale-codec-derive" -version = "3.6.9" +version = "3.6.12" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "be30eaf4b0a9fba5336683b38de57bb86d179a35862ba6bfcf57625d006bde5b" +checksum = "d830939c76d294956402033aee57a6da7b438f2294eb94864c37b0569053a42c" dependencies = [ - "proc-macro-crate 2.0.2", + "proc-macro-crate", "proc-macro2", "quote", "syn 1.0.109", ] -[[package]] -name = "pkcs8" -version = "0.10.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f950b2377845cebe5cf8b5165cb3cc1a5e0fa5cfa3e1f7f55707d8fd82e0a7b7" -dependencies = [ - "der", - "spki", -] - [[package]] name = "ppv-lite86" version = "0.2.17" @@ -436,22 +213,11 @@ checksum = "5b40af805b3121feab8a3c29f04d8ad262fa8e0561883e7653e024ae4479e6de" [[package]] name = "proc-macro-crate" -version = "1.3.1" +version = "3.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7f4c021e1093a56626774e81216a4ce732a735e5bad4868a03f3ed65ca0c3919" +checksum = "6d37c51ca738a55da99dc0c4a34860fd675453b8b36209178c2249bb13651284" dependencies = [ - "once_cell", - "toml_edit 0.19.15", -] - -[[package]] -name = "proc-macro-crate" -version = "2.0.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b00f26d3400549137f92511a46ac1cd8ce37cb5598a96d382381458b992a5d24" -dependencies = [ - "toml_datetime", - "toml_edit 0.20.2", + "toml_edit", ] [[package]] @@ -472,12 +238,6 @@ dependencies = [ "proc-macro2", ] -[[package]] -name = "radium" -version = "0.7.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "dc33ff2d4973d518d823d61aa239014831e521c75da58e3df4840d3f47749d09" - [[package]] name = "rand" version = "0.8.5" @@ -508,21 +268,11 @@ dependencies = [ "getrandom", ] -[[package]] -name = "rfc6979" -version = "0.4.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f8dd2a808d456c4a54e300a23e9f5a67e122c3024119acbfd73e3bf664491cb2" -dependencies = [ - "hmac", - "subtle", -] - [[package]] name = "scale-info" -version = "2.11.2" +version = "2.11.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7c453e59a955f81fb62ee5d596b450383d699f152d350e9d23a0db2adb78e4c0" +checksum = "eca070c12893629e2cc820a9761bedf6ce1dcddc9852984d1dc734b8bd9bd024" dependencies = [ "cfg-if", "derive_more", @@ -532,44 +282,30 @@ dependencies = [ [[package]] name = "scale-info-derive" -version = "2.11.2" +version = "2.11.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "18cf6c6447f813ef19eb450e985bcce6705f9ce7660db221b59093d15c79c4b7" +checksum = "2d35494501194174bda522a32605929eefc9ecf7e0a326c26db1fdd85881eb62" dependencies = [ - "proc-macro-crate 1.3.1", + "proc-macro-crate", "proc-macro2", "quote", "syn 1.0.109", ] -[[package]] -name = "sec1" -version = "0.7.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d3e97a565f76233a6003f9f5c54be1d9c5bdfa3eccfb189469f11ec4901c47dc" -dependencies = [ - "base16ct", - "der", - "generic-array", - "pkcs8", - "subtle", - "zeroize", -] - [[package]] name = "serde" -version = "1.0.203" +version = "1.0.204" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7253ab4de971e72fb7be983802300c30b5a7f0c2e56fab8abfc6a214307c0094" +checksum = "bc76f558e0cbb2a839d37354c575f1dc3fdc6546b5be373ba43d95f231bf7c12" dependencies = [ "serde_derive", ] [[package]] name = "serde_derive" -version = "1.0.203" +version = "1.0.204" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "500cbc0ebeb6f46627f50f3f5811ccf6bf00643be300b4c3eabc0ef55dc5b5ba" +checksum = "e0cd7e117be63d3c3678776753929474f3b04a43a080c744d6b0ae2a8c28e222" dependencies = [ "proc-macro2", "quote", @@ -587,16 +323,6 @@ dependencies = [ "digest", ] -[[package]] -name = "signature" -version = "2.2.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "77549399552de45a898a580c1b41d445bf730df867cc44e6c0233bbc4b8329de" -dependencies = [ - "digest", - "rand_core", -] - [[package]] name = "snowbridge-amcl" version = "1.0.2" @@ -608,53 +334,33 @@ dependencies = [ ] [[package]] -name = "sp1-precompiles" -version = "0.1.0" +name = "sp1-lib" +version = "1.0.0-rc.1" dependencies = [ "anyhow", "bincode", "cfg-if", - "getrandom", "hex", - "k256", - "num", - "rand", "serde", "snowbridge-amcl", ] [[package]] name = "sp1-zkvm" -version = "0.1.0" +version = "1.0.0-rc.1" dependencies = [ "bincode", "cfg-if", "getrandom", - "k256", + "lazy_static", "libm", "once_cell", "rand", "serde", "sha2", - "sp1-precompiles", + "sp1-lib", ] -[[package]] -name = "spki" -version = "0.7.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d91ed6c858b01f942cd56b37a94b3e0a1798290327d1236e4d9cf4eaca44d29d" -dependencies = [ - "base64ct", - "der", -] - -[[package]] -name = "subtle" -version = "2.5.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "81cdd64d312baedb58e21336b31bc043b77e01cc99033ce76ef539f78e965ebc" - [[package]] name = "syn" version = "1.0.109" @@ -677,34 +383,17 @@ dependencies = [ "unicode-ident", ] -[[package]] -name = "tap" -version = "1.0.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "55937e1799185b12863d447f42597ed69d9928686b8d88a1df17376a097d8369" - [[package]] name = "toml_datetime" -version = "0.6.3" +version = "0.6.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7cda73e2f1397b1262d6dfdcef8aafae14d1de7748d66822d3bfeeb6d03e5e4b" +checksum = "4badfd56924ae69bcc9039335b2e017639ce3f9b001c393c1b2d1ef846ce2cbf" [[package]] name = "toml_edit" -version = "0.19.15" +version = "0.21.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1b5bb770da30e5cbfde35a2d7b9b8a2c4b8ef89548a7a6aeab5c9a576e3e7421" -dependencies = [ - "indexmap", - "toml_datetime", - "winnow", -] - -[[package]] -name = "toml_edit" -version = "0.20.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "396e4d48bbb2b7554c944bde63101b5ae446cff6ec4a24227428f15eb72ef338" +checksum = "6a8534fd7f78b5405e860340ad6575217ce99f38d4d5c8f2442cb5ecb50090e1" dependencies = [ "indexmap", "toml_datetime", @@ -743,18 +432,3 @@ checksum = "f593a95398737aeed53e489c785df13f3618e41dbcd6718c6addbf1395aa6876" dependencies = [ "memchr", ] - -[[package]] -name = "wyz" -version = "0.5.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "05f360fc0b24296329c78fda852a1e9ae82de9cf7b27dae4b7f62f118f77b9ed" -dependencies = [ - "tap", -] - -[[package]] -name = "zeroize" -version = "1.7.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "525b4ec142c6b68a2d10f01f7bbf6755599ca3f81ea53b8431b7dd348f5fdb2d" diff --git a/tests/bls12381-decompress/Cargo.toml b/tests/bls12381-decompress/Cargo.toml index e0c9c15b9c..2b837fce72 100644 --- a/tests/bls12381-decompress/Cargo.toml +++ b/tests/bls12381-decompress/Cargo.toml @@ -1,8 +1,9 @@ [workspace] [package] -version = "0.1.0" name = "bls-decompress-test" +version = "1.0.0-rc.1" edition = "2021" +publish = false [dependencies] -sp1-zkvm = { path = "../../zkvm/entrypoint" } +sp1-zkvm = { path = "../../zkvm/entrypoint", features = ["bls12381"] } diff --git a/tests/bls12381-decompress/elf/riscv32im-succinct-zkvm-elf b/tests/bls12381-decompress/elf/riscv32im-succinct-zkvm-elf index 3a8f2e1872..6891d2cfc2 100755 Binary files a/tests/bls12381-decompress/elf/riscv32im-succinct-zkvm-elf and b/tests/bls12381-decompress/elf/riscv32im-succinct-zkvm-elf differ diff --git a/tests/bls12381-decompress/src/main.rs b/tests/bls12381-decompress/src/main.rs index a359fa9f7c..93bd728cc2 100644 --- a/tests/bls12381-decompress/src/main.rs +++ b/tests/bls12381-decompress/src/main.rs @@ -1,26 +1,16 @@ #![no_main] + sp1_zkvm::entrypoint!(main); -extern "C" { - fn syscall_bls12381_decompress(p: &mut [u8; 96], is_odd: bool); -} +use sp1_zkvm::lib::bls12381::decompress_pubkey; pub fn main() { let compressed_key: [u8; 48] = sp1_zkvm::io::read_vec().try_into().unwrap(); for _ in 0..4 { - let mut decompressed_key: [u8; 96] = [0u8; 96]; - - decompressed_key[..48].copy_from_slice(&compressed_key); - - println!("before: {:?}", decompressed_key); - - let is_odd = (decompressed_key[0] & 0b_0010_0000) >> 5 == 0; - decompressed_key[0] &= 0b_0001_1111; + println!("before: {:?}", compressed_key); - unsafe { - syscall_bls12381_decompress(&mut decompressed_key, is_odd); - } + let decompressed_key = decompress_pubkey(&compressed_key).unwrap(); println!("after: {:?}", decompressed_key); sp1_zkvm::io::commit_slice(&decompressed_key); diff --git a/tests/bls12381-double/Cargo.lock b/tests/bls12381-double/Cargo.lock index baaa834932..ee66717ce6 100644 --- a/tests/bls12381-double/Cargo.lock +++ b/tests/bls12381-double/Cargo.lock @@ -8,30 +8,12 @@ version = "1.0.86" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "b3d1d046238990b9cf5bcde22a3fb3584ee5cf65fb2765f454ed428c7a0063da" -[[package]] -name = "arrayvec" -version = "0.7.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "96d30a06541fbafbc7f82ed10c06164cfbd2c401138f6addd8404629c4b16711" - [[package]] name = "autocfg" version = "1.2.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "f1fdabc7756949593fe60f30ec81974b613357de856987752631dea1e3394c80" -[[package]] -name = "base16ct" -version = "0.2.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4c7f02d4ea65f2c1853089ffd8d2787bdbc63de2f0d29dedbcf8ccdfa0ccd4cf" - -[[package]] -name = "base64ct" -version = "1.6.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8c3c1a368f70d6cf7302d78f8f7093da241fb8e8807c05cc9e51a125895a6d5b" - [[package]] name = "bincode" version = "1.3.3" @@ -41,18 +23,6 @@ dependencies = [ "serde", ] -[[package]] -name = "bitvec" -version = "1.0.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1bc2832c24239b0141d5674bb9174f9d68a8b5b3f2753311927c172ca46f7e9c" -dependencies = [ - "funty", - "radium", - "tap", - "wyz", -] - [[package]] name = "block-buffer" version = "0.10.4" @@ -70,24 +40,12 @@ dependencies = [ "sp1-zkvm", ] -[[package]] -name = "byte-slice-cast" -version = "1.2.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c3ac9f8b63eca6fd385229b3675f6cc0dc5c8a5c8a54a59d4f52ffd670d87b0c" - [[package]] name = "cfg-if" version = "1.0.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "baf1de4339761588bc0619e3cbc0120ee582ebb74b53b4efbf79117bd2da40fd" -[[package]] -name = "const-oid" -version = "0.9.6" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c2459377285ad874054d797f3ccebf984978aa39129f6eafde5cdc8315b612f8" - [[package]] name = "cpufeatures" version = "0.2.12" @@ -97,18 +55,6 @@ dependencies = [ "libc", ] -[[package]] -name = "crypto-bigint" -version = "0.5.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0dc92fb57ca44df6db8059111ab3af99a63d5d0f8375d9972e319a379c6bab76" -dependencies = [ - "generic-array", - "rand_core", - "subtle", - "zeroize", -] - [[package]] name = "crypto-common" version = "0.1.6" @@ -119,27 +65,6 @@ dependencies = [ "typenum", ] -[[package]] -name = "der" -version = "0.7.8" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "fffa369a668c8af7dbf8b5e56c9f744fbd399949ed171606040001947de40b1c" -dependencies = [ - "const-oid", - "zeroize", -] - -[[package]] -name = "derive_more" -version = "0.99.17" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4fb810d30a7c1953f91334de7244731fc3f3c10d7fe163338a35b9f640960321" -dependencies = [ - "proc-macro2", - "quote", - "syn 1.0.109", -] - [[package]] name = "digest" version = "0.10.7" @@ -147,68 +72,9 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "9ed9a281f7bc9b7576e61468ba615a66a5c8cfdff42420a70aa82701a3b1e292" dependencies = [ "block-buffer", - "const-oid", "crypto-common", - "subtle", -] - -[[package]] -name = "ecdsa" -version = "0.16.9" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ee27f32b5c5292967d2d4a9d7f1e0b0aed2c15daded5a60300e4abb9d8020bca" -dependencies = [ - "der", - "digest", - "elliptic-curve", - "rfc6979", - "signature", - "spki", -] - -[[package]] -name = "elliptic-curve" -version = "0.13.8" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b5e6043086bf7973472e0c7dff2142ea0b680d30e18d9cc40f267efbf222bd47" -dependencies = [ - "base16ct", - "crypto-bigint", - "digest", - "ff", - "generic-array", - "group", - "pkcs8", - "rand_core", - "sec1", - "subtle", - "tap", - "zeroize", -] - -[[package]] -name = "equivalent" -version = "1.0.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5443807d6dff69373d433ab9ef5378ad8df50ca6298caf15de6e52e24aaf54d5" - -[[package]] -name = "ff" -version = "0.13.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ded41244b729663b1e574f1b4fb731469f69f79c17667b5d776b16cda0479449" -dependencies = [ - "bitvec", - "rand_core", - "subtle", ] -[[package]] -name = "funty" -version = "2.0.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e6d5a32815ae3f33302d95fdcb2ce17862f8c65363dcfd29360480ba1001fc9c" - [[package]] name = "generic-array" version = "0.14.7" @@ -217,7 +83,6 @@ checksum = "85649ca51fd72272d7821adaf274ad91c288277713d9c18820d8499a7ff69e9a" dependencies = [ "typenum", "version_check", - "zeroize", ] [[package]] @@ -232,71 +97,10 @@ dependencies = [ ] [[package]] -name = "group" -version = "0.13.0" +name = "lazy_static" +version = "1.5.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f0f9ef7462f7c099f518d754361858f86d8a07af53ba9af0fe635bbccb151a63" -dependencies = [ - "ff", - "rand_core", - "subtle", -] - -[[package]] -name = "hashbrown" -version = "0.14.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "290f1a1d9242c78d09ce40a5e87e7554ee637af1351968159f4952f028f75604" - -[[package]] -name = "hex" -version = "0.4.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7f24254aa9a54b5c858eaee2f5bccdb46aaf0e486a595ed5fd8f86ba55232a70" - -[[package]] -name = "hmac" -version = "0.12.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6c49c37c09c17a53d937dfbb742eb3a961d65a994e6bcdcf37e7399d0cc8ab5e" -dependencies = [ - "digest", -] - -[[package]] -name = "impl-trait-for-tuples" -version = "0.2.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "11d7a9f6330b71fea57921c9b61c47ee6e84f72d394754eff6163ae67e7395eb" -dependencies = [ - "proc-macro2", - "quote", - "syn 1.0.109", -] - -[[package]] -name = "indexmap" -version = "2.2.6" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "168fb715dda47215e360912c096649d23d58bf392ac62f73919e831745e40f26" -dependencies = [ - "equivalent", - "hashbrown", -] - -[[package]] -name = "k256" -version = "0.13.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "956ff9b67e26e1a6a866cb758f12c6f8746208489e3e4a4b5580802f2f0a587b" -dependencies = [ - "cfg-if", - "ecdsa", - "elliptic-curve", - "once_cell", - "sha2", - "signature", -] +checksum = "bbd2bcb4c963f2ddae06a2efc7e9f3591312473c50c6685e1f298068316e66fe" [[package]] name = "libc" @@ -310,19 +114,12 @@ version = "0.2.8" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "4ec2a862134d2a7d32d7983ddcdd1c4923530833c9f2ea1a44fc5fa473989058" -[[package]] -name = "memchr" -version = "2.7.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6c8640c5d730cb13ebd907d8d04b52f55ac9a2eec55b440c8892f40d56c76c1d" - [[package]] name = "num" version = "0.4.3" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "35bd024e8b2ff75562e5f34e7f4905839deb4b22955ef5e73d2fea1b9813cb23" dependencies = [ - "num-bigint", "num-complex", "num-integer", "num-iter", @@ -330,16 +127,6 @@ dependencies = [ "num-traits", ] -[[package]] -name = "num-bigint" -version = "0.4.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c165a9ab64cf766f73521c0dd2cfdff64f488b8f0b3e621face3462d3db536d7" -dependencies = [ - "num-integer", - "num-traits", -] - [[package]] name = "num-complex" version = "0.4.6" @@ -375,7 +162,6 @@ version = "0.4.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "f83d14da390562dca69fc84082e73e548e1ad308d24accdedd2720017cb37824" dependencies = [ - "num-bigint", "num-integer", "num-traits", ] @@ -395,66 +181,12 @@ version = "1.19.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "3fdb12b2476b595f9358c5161aa467c2438859caa136dec86c26fdd2efe17b92" -[[package]] -name = "parity-scale-codec" -version = "3.6.9" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "881331e34fa842a2fb61cc2db9643a8fedc615e47cfcc52597d1af0db9a7e8fe" -dependencies = [ - "arrayvec", - "byte-slice-cast", - "impl-trait-for-tuples", - "parity-scale-codec-derive", -] - -[[package]] -name = "parity-scale-codec-derive" -version = "3.6.9" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "be30eaf4b0a9fba5336683b38de57bb86d179a35862ba6bfcf57625d006bde5b" -dependencies = [ - "proc-macro-crate 2.0.2", - "proc-macro2", - "quote", - "syn 1.0.109", -] - -[[package]] -name = "pkcs8" -version = "0.10.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f950b2377845cebe5cf8b5165cb3cc1a5e0fa5cfa3e1f7f55707d8fd82e0a7b7" -dependencies = [ - "der", - "spki", -] - [[package]] name = "ppv-lite86" version = "0.2.17" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "5b40af805b3121feab8a3c29f04d8ad262fa8e0561883e7653e024ae4479e6de" -[[package]] -name = "proc-macro-crate" -version = "1.3.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7f4c021e1093a56626774e81216a4ce732a735e5bad4868a03f3ed65ca0c3919" -dependencies = [ - "once_cell", - "toml_edit 0.19.15", -] - -[[package]] -name = "proc-macro-crate" -version = "2.0.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b00f26d3400549137f92511a46ac1cd8ce37cb5598a96d382381458b992a5d24" -dependencies = [ - "toml_datetime", - "toml_edit 0.20.2", -] - [[package]] name = "proc-macro2" version = "1.0.79" @@ -473,12 +205,6 @@ dependencies = [ "proc-macro2", ] -[[package]] -name = "radium" -version = "0.7.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "dc33ff2d4973d518d823d61aa239014831e521c75da58e3df4840d3f47749d09" - [[package]] name = "rand" version = "0.8.5" @@ -509,54 +235,6 @@ dependencies = [ "getrandom", ] -[[package]] -name = "rfc6979" -version = "0.4.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f8dd2a808d456c4a54e300a23e9f5a67e122c3024119acbfd73e3bf664491cb2" -dependencies = [ - "hmac", - "subtle", -] - -[[package]] -name = "scale-info" -version = "2.11.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7c453e59a955f81fb62ee5d596b450383d699f152d350e9d23a0db2adb78e4c0" -dependencies = [ - "cfg-if", - "derive_more", - "parity-scale-codec", - "scale-info-derive", -] - -[[package]] -name = "scale-info-derive" -version = "2.11.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "18cf6c6447f813ef19eb450e985bcce6705f9ce7660db221b59093d15c79c4b7" -dependencies = [ - "proc-macro-crate 1.3.1", - "proc-macro2", - "quote", - "syn 1.0.109", -] - -[[package]] -name = "sec1" -version = "0.7.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d3e97a565f76233a6003f9f5c54be1d9c5bdfa3eccfb189469f11ec4901c47dc" -dependencies = [ - "base16ct", - "der", - "generic-array", - "pkcs8", - "subtle", - "zeroize", -] - [[package]] name = "serde" version = "1.0.203" @@ -574,7 +252,7 @@ checksum = "500cbc0ebeb6f46627f50f3f5811ccf6bf00643be300b4c3eabc0ef55dc5b5ba" dependencies = [ "proc-macro2", "quote", - "syn 2.0.55", + "syn", ] [[package]] @@ -589,39 +267,13 @@ dependencies = [ ] [[package]] -name = "signature" -version = "2.2.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "77549399552de45a898a580c1b41d445bf730df867cc44e6c0233bbc4b8329de" -dependencies = [ - "digest", - "rand_core", -] - -[[package]] -name = "snowbridge-amcl" -version = "1.0.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "460a9ed63cdf03c1b9847e8a12a5f5ba19c4efd5869e4a737e05be25d7c427e5" -dependencies = [ - "parity-scale-codec", - "scale-info", -] - -[[package]] -name = "sp1-precompiles" +name = "sp1-lib" version = "0.1.0" dependencies = [ "anyhow", "bincode", "cfg-if", - "getrandom", - "hex", - "k256", - "num", - "rand", "serde", - "snowbridge-amcl", ] [[package]] @@ -631,40 +283,13 @@ dependencies = [ "bincode", "cfg-if", "getrandom", - "k256", + "lazy_static", "libm", "once_cell", "rand", "serde", "sha2", - "sp1-precompiles", -] - -[[package]] -name = "spki" -version = "0.7.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d91ed6c858b01f942cd56b37a94b3e0a1798290327d1236e4d9cf4eaca44d29d" -dependencies = [ - "base64ct", - "der", -] - -[[package]] -name = "subtle" -version = "2.5.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "81cdd64d312baedb58e21336b31bc043b77e01cc99033ce76ef539f78e965ebc" - -[[package]] -name = "syn" -version = "1.0.109" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "72b64191b275b66ffe2469e8af2c1cfe3bafa67b529ead792a6d0160888b4237" -dependencies = [ - "proc-macro2", - "quote", - "unicode-ident", + "sp1-lib", ] [[package]] @@ -678,40 +303,6 @@ dependencies = [ "unicode-ident", ] -[[package]] -name = "tap" -version = "1.0.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "55937e1799185b12863d447f42597ed69d9928686b8d88a1df17376a097d8369" - -[[package]] -name = "toml_datetime" -version = "0.6.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7cda73e2f1397b1262d6dfdcef8aafae14d1de7748d66822d3bfeeb6d03e5e4b" - -[[package]] -name = "toml_edit" -version = "0.19.15" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1b5bb770da30e5cbfde35a2d7b9b8a2c4b8ef89548a7a6aeab5c9a576e3e7421" -dependencies = [ - "indexmap", - "toml_datetime", - "winnow", -] - -[[package]] -name = "toml_edit" -version = "0.20.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "396e4d48bbb2b7554c944bde63101b5ae446cff6ec4a24227428f15eb72ef338" -dependencies = [ - "indexmap", - "toml_datetime", - "winnow", -] - [[package]] name = "typenum" version = "1.17.0" @@ -735,27 +326,3 @@ name = "wasi" version = "0.11.0+wasi-snapshot-preview1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "9c8d87e72b64a3b4db28d11ce29237c246188f4f51057d65a7eab63b7987e423" - -[[package]] -name = "winnow" -version = "0.5.40" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f593a95398737aeed53e489c785df13f3618e41dbcd6718c6addbf1395aa6876" -dependencies = [ - "memchr", -] - -[[package]] -name = "wyz" -version = "0.5.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "05f360fc0b24296329c78fda852a1e9ae82de9cf7b27dae4b7f62f118f77b9ed" -dependencies = [ - "tap", -] - -[[package]] -name = "zeroize" -version = "1.7.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "525b4ec142c6b68a2d10f01f7bbf6755599ca3f81ea53b8431b7dd348f5fdb2d" diff --git a/tests/bls12381-double/Cargo.toml b/tests/bls12381-double/Cargo.toml index 196c93ab2e..cb43319a31 100644 --- a/tests/bls12381-double/Cargo.toml +++ b/tests/bls12381-double/Cargo.toml @@ -1,8 +1,9 @@ [workspace] [package] -version = "0.1.0" name = "bls12381-double-test" +version = "1.0.0-rc.1" edition = "2021" +publish = false [dependencies] sp1-zkvm = { path = "../../zkvm/entrypoint" } diff --git a/tests/bls12381-double/elf/riscv32im-succinct-zkvm-elf b/tests/bls12381-double/elf/riscv32im-succinct-zkvm-elf index 50470172a8..649ee6fc26 100755 Binary files a/tests/bls12381-double/elf/riscv32im-succinct-zkvm-elf and b/tests/bls12381-double/elf/riscv32im-succinct-zkvm-elf differ diff --git a/tests/bls12381-double/src/main.rs b/tests/bls12381-double/src/main.rs index 49ec1a49c3..e83fc56109 100644 --- a/tests/bls12381-double/src/main.rs +++ b/tests/bls12381-double/src/main.rs @@ -1,9 +1,8 @@ #![no_main] -sp1_zkvm::entrypoint!(main); -extern "C" { - fn syscall_bls12381_double(p: *mut u32); -} +use sp1_zkvm::syscalls::syscall_bls12381_double; + +sp1_zkvm::entrypoint!(main); pub fn main() { for _ in 0..10i64.pow(3) { @@ -19,9 +18,7 @@ pub fn main() { 179, 8, ]; - unsafe { - syscall_bls12381_double(a.as_mut_ptr() as *mut u32); - } + syscall_bls12381_double(a.as_mut_ptr() as *mut u32); // 2 * generator. // 838589206289216005799424730305866328161735431124665289961769162861615689790485775997575391185127590486775437397838 diff --git a/tests/bls12381-mul/Cargo.lock b/tests/bls12381-mul/Cargo.lock index b9194ffe94..4347dd4dc8 100644 --- a/tests/bls12381-mul/Cargo.lock +++ b/tests/bls12381-mul/Cargo.lock @@ -14,24 +14,6 @@ version = "0.7.4" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "96d30a06541fbafbc7f82ed10c06164cfbd2c401138f6addd8404629c4b16711" -[[package]] -name = "autocfg" -version = "1.2.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f1fdabc7756949593fe60f30ec81974b613357de856987752631dea1e3394c80" - -[[package]] -name = "base16ct" -version = "0.2.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4c7f02d4ea65f2c1853089ffd8d2787bdbc63de2f0d29dedbcf8ccdfa0ccd4cf" - -[[package]] -name = "base64ct" -version = "1.6.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8c3c1a368f70d6cf7302d78f8f7093da241fb8e8807c05cc9e51a125895a6d5b" - [[package]] name = "bincode" version = "1.3.3" @@ -41,18 +23,6 @@ dependencies = [ "serde", ] -[[package]] -name = "bitvec" -version = "1.0.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1bc2832c24239b0141d5674bb9174f9d68a8b5b3f2753311927c172ca46f7e9c" -dependencies = [ - "funty", - "radium", - "tap", - "wyz", -] - [[package]] name = "block-buffer" version = "0.10.4" @@ -82,12 +52,6 @@ version = "1.0.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "baf1de4339761588bc0619e3cbc0120ee582ebb74b53b4efbf79117bd2da40fd" -[[package]] -name = "const-oid" -version = "0.9.6" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c2459377285ad874054d797f3ccebf984978aa39129f6eafde5cdc8315b612f8" - [[package]] name = "cpufeatures" version = "0.2.12" @@ -97,18 +61,6 @@ dependencies = [ "libc", ] -[[package]] -name = "crypto-bigint" -version = "0.5.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0dc92fb57ca44df6db8059111ab3af99a63d5d0f8375d9972e319a379c6bab76" -dependencies = [ - "generic-array", - "rand_core", - "subtle", - "zeroize", -] - [[package]] name = "crypto-common" version = "0.1.6" @@ -119,25 +71,15 @@ dependencies = [ "typenum", ] -[[package]] -name = "der" -version = "0.7.8" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "fffa369a668c8af7dbf8b5e56c9f744fbd399949ed171606040001947de40b1c" -dependencies = [ - "const-oid", - "zeroize", -] - [[package]] name = "derive_more" -version = "0.99.17" +version = "0.99.18" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4fb810d30a7c1953f91334de7244731fc3f3c10d7fe163338a35b9f640960321" +checksum = "5f33878137e4dafd7fa914ad4e259e18a4e8e532b9617a2d0150262bf53abfce" dependencies = [ "proc-macro2", "quote", - "syn 1.0.109", + "syn 2.0.55", ] [[package]] @@ -147,43 +89,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "9ed9a281f7bc9b7576e61468ba615a66a5c8cfdff42420a70aa82701a3b1e292" dependencies = [ "block-buffer", - "const-oid", "crypto-common", - "subtle", -] - -[[package]] -name = "ecdsa" -version = "0.16.9" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ee27f32b5c5292967d2d4a9d7f1e0b0aed2c15daded5a60300e4abb9d8020bca" -dependencies = [ - "der", - "digest", - "elliptic-curve", - "rfc6979", - "signature", - "spki", -] - -[[package]] -name = "elliptic-curve" -version = "0.13.8" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b5e6043086bf7973472e0c7dff2142ea0b680d30e18d9cc40f267efbf222bd47" -dependencies = [ - "base16ct", - "crypto-bigint", - "digest", - "ff", - "generic-array", - "group", - "pkcs8", - "rand_core", - "sec1", - "subtle", - "tap", - "zeroize", ] [[package]] @@ -192,23 +98,6 @@ version = "1.0.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "5443807d6dff69373d433ab9ef5378ad8df50ca6298caf15de6e52e24aaf54d5" -[[package]] -name = "ff" -version = "0.13.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ded41244b729663b1e574f1b4fb731469f69f79c17667b5d776b16cda0479449" -dependencies = [ - "bitvec", - "rand_core", - "subtle", -] - -[[package]] -name = "funty" -version = "2.0.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e6d5a32815ae3f33302d95fdcb2ce17862f8c65363dcfd29360480ba1001fc9c" - [[package]] name = "generic-array" version = "0.14.7" @@ -217,7 +106,6 @@ checksum = "85649ca51fd72272d7821adaf274ad91c288277713d9c18820d8499a7ff69e9a" dependencies = [ "typenum", "version_check", - "zeroize", ] [[package]] @@ -231,22 +119,11 @@ dependencies = [ "wasi", ] -[[package]] -name = "group" -version = "0.13.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f0f9ef7462f7c099f518d754361858f86d8a07af53ba9af0fe635bbccb151a63" -dependencies = [ - "ff", - "rand_core", - "subtle", -] - [[package]] name = "hashbrown" -version = "0.14.3" +version = "0.14.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "290f1a1d9242c78d09ce40a5e87e7554ee637af1351968159f4952f028f75604" +checksum = "e5274423e17b7c9fc20b6e7e208532f9b19825d82dfd615708b70edd83df41f1" [[package]] name = "hex" @@ -254,15 +131,6 @@ version = "0.4.3" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "7f24254aa9a54b5c858eaee2f5bccdb46aaf0e486a595ed5fd8f86ba55232a70" -[[package]] -name = "hmac" -version = "0.12.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6c49c37c09c17a53d937dfbb742eb3a961d65a994e6bcdcf37e7399d0cc8ab5e" -dependencies = [ - "digest", -] - [[package]] name = "impl-trait-for-tuples" version = "0.2.2" @@ -285,18 +153,10 @@ dependencies = [ ] [[package]] -name = "k256" -version = "0.13.3" +name = "lazy_static" +version = "1.5.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "956ff9b67e26e1a6a866cb758f12c6f8746208489e3e4a4b5580802f2f0a587b" -dependencies = [ - "cfg-if", - "ecdsa", - "elliptic-curve", - "once_cell", - "sha2", - "signature", -] +checksum = "bbd2bcb4c963f2ddae06a2efc7e9f3591312473c50c6685e1f298068316e66fe" [[package]] name = "libc" @@ -312,82 +172,9 @@ checksum = "4ec2a862134d2a7d32d7983ddcdd1c4923530833c9f2ea1a44fc5fa473989058" [[package]] name = "memchr" -version = "2.7.2" +version = "2.7.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6c8640c5d730cb13ebd907d8d04b52f55ac9a2eec55b440c8892f40d56c76c1d" - -[[package]] -name = "num" -version = "0.4.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "35bd024e8b2ff75562e5f34e7f4905839deb4b22955ef5e73d2fea1b9813cb23" -dependencies = [ - "num-bigint", - "num-complex", - "num-integer", - "num-iter", - "num-rational", - "num-traits", -] - -[[package]] -name = "num-bigint" -version = "0.4.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c165a9ab64cf766f73521c0dd2cfdff64f488b8f0b3e621face3462d3db536d7" -dependencies = [ - "num-integer", - "num-traits", -] - -[[package]] -name = "num-complex" -version = "0.4.6" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "73f88a1307638156682bada9d7604135552957b7818057dcef22705b4d509495" -dependencies = [ - "num-traits", -] - -[[package]] -name = "num-integer" -version = "0.1.46" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7969661fd2958a5cb096e56c8e1ad0444ac2bbcd0061bd28660485a44879858f" -dependencies = [ - "num-traits", -] - -[[package]] -name = "num-iter" -version = "0.1.45" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1429034a0490724d0075ebb2bc9e875d6503c3cf69e235a8941aa757d83ef5bf" -dependencies = [ - "autocfg", - "num-integer", - "num-traits", -] - -[[package]] -name = "num-rational" -version = "0.4.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f83d14da390562dca69fc84082e73e548e1ad308d24accdedd2720017cb37824" -dependencies = [ - "num-bigint", - "num-integer", - "num-traits", -] - -[[package]] -name = "num-traits" -version = "0.2.19" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "071dfc062690e90b734c0b2273ce72ad0ffa95f0c74596bc250dcfd960262841" -dependencies = [ - "autocfg", -] +checksum = "78ca9ab1a0babb1e7d5695e3530886289c18cf2f87ec19a575a0abdce112e3a3" [[package]] name = "once_cell" @@ -397,9 +184,9 @@ checksum = "3fdb12b2476b595f9358c5161aa467c2438859caa136dec86c26fdd2efe17b92" [[package]] name = "parity-scale-codec" -version = "3.6.9" +version = "3.6.12" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "881331e34fa842a2fb61cc2db9643a8fedc615e47cfcc52597d1af0db9a7e8fe" +checksum = "306800abfa29c7f16596b5970a588435e3d5b3149683d00c12b699cc19f895ee" dependencies = [ "arrayvec", "byte-slice-cast", @@ -409,26 +196,16 @@ dependencies = [ [[package]] name = "parity-scale-codec-derive" -version = "3.6.9" +version = "3.6.12" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "be30eaf4b0a9fba5336683b38de57bb86d179a35862ba6bfcf57625d006bde5b" +checksum = "d830939c76d294956402033aee57a6da7b438f2294eb94864c37b0569053a42c" dependencies = [ - "proc-macro-crate 2.0.2", + "proc-macro-crate", "proc-macro2", "quote", "syn 1.0.109", ] -[[package]] -name = "pkcs8" -version = "0.10.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f950b2377845cebe5cf8b5165cb3cc1a5e0fa5cfa3e1f7f55707d8fd82e0a7b7" -dependencies = [ - "der", - "spki", -] - [[package]] name = "ppv-lite86" version = "0.2.17" @@ -437,22 +214,11 @@ checksum = "5b40af805b3121feab8a3c29f04d8ad262fa8e0561883e7653e024ae4479e6de" [[package]] name = "proc-macro-crate" -version = "1.3.1" +version = "3.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7f4c021e1093a56626774e81216a4ce732a735e5bad4868a03f3ed65ca0c3919" +checksum = "6d37c51ca738a55da99dc0c4a34860fd675453b8b36209178c2249bb13651284" dependencies = [ - "once_cell", - "toml_edit 0.19.15", -] - -[[package]] -name = "proc-macro-crate" -version = "2.0.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b00f26d3400549137f92511a46ac1cd8ce37cb5598a96d382381458b992a5d24" -dependencies = [ - "toml_datetime", - "toml_edit 0.20.2", + "toml_edit", ] [[package]] @@ -473,12 +239,6 @@ dependencies = [ "proc-macro2", ] -[[package]] -name = "radium" -version = "0.7.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "dc33ff2d4973d518d823d61aa239014831e521c75da58e3df4840d3f47749d09" - [[package]] name = "rand" version = "0.8.5" @@ -509,21 +269,11 @@ dependencies = [ "getrandom", ] -[[package]] -name = "rfc6979" -version = "0.4.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f8dd2a808d456c4a54e300a23e9f5a67e122c3024119acbfd73e3bf664491cb2" -dependencies = [ - "hmac", - "subtle", -] - [[package]] name = "scale-info" -version = "2.11.2" +version = "2.11.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7c453e59a955f81fb62ee5d596b450383d699f152d350e9d23a0db2adb78e4c0" +checksum = "eca070c12893629e2cc820a9761bedf6ce1dcddc9852984d1dc734b8bd9bd024" dependencies = [ "cfg-if", "derive_more", @@ -533,30 +283,16 @@ dependencies = [ [[package]] name = "scale-info-derive" -version = "2.11.2" +version = "2.11.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "18cf6c6447f813ef19eb450e985bcce6705f9ce7660db221b59093d15c79c4b7" +checksum = "2d35494501194174bda522a32605929eefc9ecf7e0a326c26db1fdd85881eb62" dependencies = [ - "proc-macro-crate 1.3.1", + "proc-macro-crate", "proc-macro2", "quote", "syn 1.0.109", ] -[[package]] -name = "sec1" -version = "0.7.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d3e97a565f76233a6003f9f5c54be1d9c5bdfa3eccfb189469f11ec4901c47dc" -dependencies = [ - "base16ct", - "der", - "generic-array", - "pkcs8", - "subtle", - "zeroize", -] - [[package]] name = "serde" version = "1.0.202" @@ -588,16 +324,6 @@ dependencies = [ "digest", ] -[[package]] -name = "signature" -version = "2.2.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "77549399552de45a898a580c1b41d445bf730df867cc44e6c0233bbc4b8329de" -dependencies = [ - "digest", - "rand_core", -] - [[package]] name = "snowbridge-amcl" version = "1.0.2" @@ -618,17 +344,13 @@ dependencies = [ ] [[package]] -name = "sp1-precompiles" +name = "sp1-lib" version = "0.1.0" dependencies = [ "anyhow", "bincode", "cfg-if", - "getrandom", "hex", - "k256", - "num", - "rand", "serde", "snowbridge-amcl", ] @@ -640,31 +362,15 @@ dependencies = [ "bincode", "cfg-if", "getrandom", - "k256", + "lazy_static", "libm", "once_cell", "rand", "serde", "sha2", - "sp1-precompiles", + "sp1-lib", ] -[[package]] -name = "spki" -version = "0.7.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d91ed6c858b01f942cd56b37a94b3e0a1798290327d1236e4d9cf4eaca44d29d" -dependencies = [ - "base64ct", - "der", -] - -[[package]] -name = "subtle" -version = "2.5.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "81cdd64d312baedb58e21336b31bc043b77e01cc99033ce76ef539f78e965ebc" - [[package]] name = "syn" version = "1.0.109" @@ -687,34 +393,17 @@ dependencies = [ "unicode-ident", ] -[[package]] -name = "tap" -version = "1.0.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "55937e1799185b12863d447f42597ed69d9928686b8d88a1df17376a097d8369" - [[package]] name = "toml_datetime" -version = "0.6.3" +version = "0.6.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7cda73e2f1397b1262d6dfdcef8aafae14d1de7748d66822d3bfeeb6d03e5e4b" +checksum = "4badfd56924ae69bcc9039335b2e017639ce3f9b001c393c1b2d1ef846ce2cbf" [[package]] name = "toml_edit" -version = "0.19.15" +version = "0.21.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1b5bb770da30e5cbfde35a2d7b9b8a2c4b8ef89548a7a6aeab5c9a576e3e7421" -dependencies = [ - "indexmap", - "toml_datetime", - "winnow", -] - -[[package]] -name = "toml_edit" -version = "0.20.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "396e4d48bbb2b7554c944bde63101b5ae446cff6ec4a24227428f15eb72ef338" +checksum = "6a8534fd7f78b5405e860340ad6575217ce99f38d4d5c8f2442cb5ecb50090e1" dependencies = [ "indexmap", "toml_datetime", @@ -753,18 +442,3 @@ checksum = "f593a95398737aeed53e489c785df13f3618e41dbcd6718c6addbf1395aa6876" dependencies = [ "memchr", ] - -[[package]] -name = "wyz" -version = "0.5.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "05f360fc0b24296329c78fda852a1e9ae82de9cf7b27dae4b7f62f118f77b9ed" -dependencies = [ - "tap", -] - -[[package]] -name = "zeroize" -version = "1.7.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "525b4ec142c6b68a2d10f01f7bbf6755599ca3f81ea53b8431b7dd348f5fdb2d" diff --git a/tests/bls12381-mul/Cargo.toml b/tests/bls12381-mul/Cargo.toml index 3ba324ce9a..b9b519bae1 100644 --- a/tests/bls12381-mul/Cargo.toml +++ b/tests/bls12381-mul/Cargo.toml @@ -1,9 +1,10 @@ [workspace] [package] name = "bls12381-mul-test" -version = "0.1.0" -edition = "2021" +version = "1.0.0-rc.1" +publish = false + [dependencies] -sp1-zkvm = { path = "../../zkvm/entrypoint" } +sp1-zkvm = { path = "../../zkvm/entrypoint", features = ["bls12381"] } sp1-derive = { path = "../../derive" } diff --git a/tests/bls12381-mul/elf/riscv32im-succinct-zkvm-elf b/tests/bls12381-mul/elf/riscv32im-succinct-zkvm-elf index d1fe6cdf6f..f2088e19bd 100755 Binary files a/tests/bls12381-mul/elf/riscv32im-succinct-zkvm-elf and b/tests/bls12381-mul/elf/riscv32im-succinct-zkvm-elf differ diff --git a/tests/bls12381-mul/src/main.rs b/tests/bls12381-mul/src/main.rs index 89169660a3..0326f9edac 100644 --- a/tests/bls12381-mul/src/main.rs +++ b/tests/bls12381-mul/src/main.rs @@ -1,8 +1,8 @@ #![no_main] sp1_zkvm::entrypoint!(main); -use sp1_zkvm::precompiles::bls12381::Bls12381; -use sp1_zkvm::precompiles::utils::AffinePoint; +use sp1_zkvm::lib::bls12381::Bls12381; +use sp1_zkvm::lib::utils::AffinePoint; #[sp1_derive::cycle_tracker] pub fn main() { diff --git a/tests/bn254-add/Cargo.lock b/tests/bn254-add/Cargo.lock index eaae54efbf..be1ce9abff 100644 --- a/tests/bn254-add/Cargo.lock +++ b/tests/bn254-add/Cargo.lock @@ -8,30 +8,12 @@ version = "1.0.86" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "b3d1d046238990b9cf5bcde22a3fb3584ee5cf65fb2765f454ed428c7a0063da" -[[package]] -name = "arrayvec" -version = "0.7.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "96d30a06541fbafbc7f82ed10c06164cfbd2c401138f6addd8404629c4b16711" - [[package]] name = "autocfg" version = "1.2.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "f1fdabc7756949593fe60f30ec81974b613357de856987752631dea1e3394c80" -[[package]] -name = "base16ct" -version = "0.2.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4c7f02d4ea65f2c1853089ffd8d2787bdbc63de2f0d29dedbcf8ccdfa0ccd4cf" - -[[package]] -name = "base64ct" -version = "1.6.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8c3c1a368f70d6cf7302d78f8f7093da241fb8e8807c05cc9e51a125895a6d5b" - [[package]] name = "bincode" version = "1.3.3" @@ -41,18 +23,6 @@ dependencies = [ "serde", ] -[[package]] -name = "bitvec" -version = "1.0.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1bc2832c24239b0141d5674bb9174f9d68a8b5b3f2753311927c172ca46f7e9c" -dependencies = [ - "funty", - "radium", - "tap", - "wyz", -] - [[package]] name = "block-buffer" version = "0.10.4" @@ -70,24 +40,12 @@ dependencies = [ "sp1-zkvm", ] -[[package]] -name = "byte-slice-cast" -version = "1.2.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c3ac9f8b63eca6fd385229b3675f6cc0dc5c8a5c8a54a59d4f52ffd670d87b0c" - [[package]] name = "cfg-if" version = "1.0.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "baf1de4339761588bc0619e3cbc0120ee582ebb74b53b4efbf79117bd2da40fd" -[[package]] -name = "const-oid" -version = "0.9.6" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c2459377285ad874054d797f3ccebf984978aa39129f6eafde5cdc8315b612f8" - [[package]] name = "cpufeatures" version = "0.2.12" @@ -97,18 +55,6 @@ dependencies = [ "libc", ] -[[package]] -name = "crypto-bigint" -version = "0.5.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0dc92fb57ca44df6db8059111ab3af99a63d5d0f8375d9972e319a379c6bab76" -dependencies = [ - "generic-array", - "rand_core", - "subtle", - "zeroize", -] - [[package]] name = "crypto-common" version = "0.1.6" @@ -119,27 +65,6 @@ dependencies = [ "typenum", ] -[[package]] -name = "der" -version = "0.7.8" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "fffa369a668c8af7dbf8b5e56c9f744fbd399949ed171606040001947de40b1c" -dependencies = [ - "const-oid", - "zeroize", -] - -[[package]] -name = "derive_more" -version = "0.99.17" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4fb810d30a7c1953f91334de7244731fc3f3c10d7fe163338a35b9f640960321" -dependencies = [ - "proc-macro2", - "quote", - "syn 1.0.109", -] - [[package]] name = "digest" version = "0.10.7" @@ -147,68 +72,9 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "9ed9a281f7bc9b7576e61468ba615a66a5c8cfdff42420a70aa82701a3b1e292" dependencies = [ "block-buffer", - "const-oid", "crypto-common", - "subtle", -] - -[[package]] -name = "ecdsa" -version = "0.16.9" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ee27f32b5c5292967d2d4a9d7f1e0b0aed2c15daded5a60300e4abb9d8020bca" -dependencies = [ - "der", - "digest", - "elliptic-curve", - "rfc6979", - "signature", - "spki", -] - -[[package]] -name = "elliptic-curve" -version = "0.13.8" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b5e6043086bf7973472e0c7dff2142ea0b680d30e18d9cc40f267efbf222bd47" -dependencies = [ - "base16ct", - "crypto-bigint", - "digest", - "ff", - "generic-array", - "group", - "pkcs8", - "rand_core", - "sec1", - "subtle", - "tap", - "zeroize", -] - -[[package]] -name = "equivalent" -version = "1.0.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5443807d6dff69373d433ab9ef5378ad8df50ca6298caf15de6e52e24aaf54d5" - -[[package]] -name = "ff" -version = "0.13.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ded41244b729663b1e574f1b4fb731469f69f79c17667b5d776b16cda0479449" -dependencies = [ - "bitvec", - "rand_core", - "subtle", ] -[[package]] -name = "funty" -version = "2.0.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e6d5a32815ae3f33302d95fdcb2ce17862f8c65363dcfd29360480ba1001fc9c" - [[package]] name = "generic-array" version = "0.14.7" @@ -217,7 +83,6 @@ checksum = "85649ca51fd72272d7821adaf274ad91c288277713d9c18820d8499a7ff69e9a" dependencies = [ "typenum", "version_check", - "zeroize", ] [[package]] @@ -232,71 +97,10 @@ dependencies = [ ] [[package]] -name = "group" -version = "0.13.0" +name = "lazy_static" +version = "1.5.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f0f9ef7462f7c099f518d754361858f86d8a07af53ba9af0fe635bbccb151a63" -dependencies = [ - "ff", - "rand_core", - "subtle", -] - -[[package]] -name = "hashbrown" -version = "0.14.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "290f1a1d9242c78d09ce40a5e87e7554ee637af1351968159f4952f028f75604" - -[[package]] -name = "hex" -version = "0.4.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7f24254aa9a54b5c858eaee2f5bccdb46aaf0e486a595ed5fd8f86ba55232a70" - -[[package]] -name = "hmac" -version = "0.12.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6c49c37c09c17a53d937dfbb742eb3a961d65a994e6bcdcf37e7399d0cc8ab5e" -dependencies = [ - "digest", -] - -[[package]] -name = "impl-trait-for-tuples" -version = "0.2.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "11d7a9f6330b71fea57921c9b61c47ee6e84f72d394754eff6163ae67e7395eb" -dependencies = [ - "proc-macro2", - "quote", - "syn 1.0.109", -] - -[[package]] -name = "indexmap" -version = "2.2.6" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "168fb715dda47215e360912c096649d23d58bf392ac62f73919e831745e40f26" -dependencies = [ - "equivalent", - "hashbrown", -] - -[[package]] -name = "k256" -version = "0.13.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "956ff9b67e26e1a6a866cb758f12c6f8746208489e3e4a4b5580802f2f0a587b" -dependencies = [ - "cfg-if", - "ecdsa", - "elliptic-curve", - "once_cell", - "sha2", - "signature", -] +checksum = "bbd2bcb4c963f2ddae06a2efc7e9f3591312473c50c6685e1f298068316e66fe" [[package]] name = "libc" @@ -310,19 +114,12 @@ version = "0.2.8" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "4ec2a862134d2a7d32d7983ddcdd1c4923530833c9f2ea1a44fc5fa473989058" -[[package]] -name = "memchr" -version = "2.7.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6c8640c5d730cb13ebd907d8d04b52f55ac9a2eec55b440c8892f40d56c76c1d" - [[package]] name = "num" version = "0.4.3" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "35bd024e8b2ff75562e5f34e7f4905839deb4b22955ef5e73d2fea1b9813cb23" dependencies = [ - "num-bigint", "num-complex", "num-integer", "num-iter", @@ -330,16 +127,6 @@ dependencies = [ "num-traits", ] -[[package]] -name = "num-bigint" -version = "0.4.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c165a9ab64cf766f73521c0dd2cfdff64f488b8f0b3e621face3462d3db536d7" -dependencies = [ - "num-integer", - "num-traits", -] - [[package]] name = "num-complex" version = "0.4.6" @@ -375,7 +162,6 @@ version = "0.4.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "f83d14da390562dca69fc84082e73e548e1ad308d24accdedd2720017cb37824" dependencies = [ - "num-bigint", "num-integer", "num-traits", ] @@ -395,66 +181,12 @@ version = "1.19.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "3fdb12b2476b595f9358c5161aa467c2438859caa136dec86c26fdd2efe17b92" -[[package]] -name = "parity-scale-codec" -version = "3.6.9" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "881331e34fa842a2fb61cc2db9643a8fedc615e47cfcc52597d1af0db9a7e8fe" -dependencies = [ - "arrayvec", - "byte-slice-cast", - "impl-trait-for-tuples", - "parity-scale-codec-derive", -] - -[[package]] -name = "parity-scale-codec-derive" -version = "3.6.9" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "be30eaf4b0a9fba5336683b38de57bb86d179a35862ba6bfcf57625d006bde5b" -dependencies = [ - "proc-macro-crate 2.0.2", - "proc-macro2", - "quote", - "syn 1.0.109", -] - -[[package]] -name = "pkcs8" -version = "0.10.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f950b2377845cebe5cf8b5165cb3cc1a5e0fa5cfa3e1f7f55707d8fd82e0a7b7" -dependencies = [ - "der", - "spki", -] - [[package]] name = "ppv-lite86" version = "0.2.17" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "5b40af805b3121feab8a3c29f04d8ad262fa8e0561883e7653e024ae4479e6de" -[[package]] -name = "proc-macro-crate" -version = "1.3.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7f4c021e1093a56626774e81216a4ce732a735e5bad4868a03f3ed65ca0c3919" -dependencies = [ - "once_cell", - "toml_edit 0.19.15", -] - -[[package]] -name = "proc-macro-crate" -version = "2.0.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b00f26d3400549137f92511a46ac1cd8ce37cb5598a96d382381458b992a5d24" -dependencies = [ - "toml_datetime", - "toml_edit 0.20.2", -] - [[package]] name = "proc-macro2" version = "1.0.79" @@ -473,12 +205,6 @@ dependencies = [ "proc-macro2", ] -[[package]] -name = "radium" -version = "0.7.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "dc33ff2d4973d518d823d61aa239014831e521c75da58e3df4840d3f47749d09" - [[package]] name = "rand" version = "0.8.5" @@ -509,54 +235,6 @@ dependencies = [ "getrandom", ] -[[package]] -name = "rfc6979" -version = "0.4.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f8dd2a808d456c4a54e300a23e9f5a67e122c3024119acbfd73e3bf664491cb2" -dependencies = [ - "hmac", - "subtle", -] - -[[package]] -name = "scale-info" -version = "2.11.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7c453e59a955f81fb62ee5d596b450383d699f152d350e9d23a0db2adb78e4c0" -dependencies = [ - "cfg-if", - "derive_more", - "parity-scale-codec", - "scale-info-derive", -] - -[[package]] -name = "scale-info-derive" -version = "2.11.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "18cf6c6447f813ef19eb450e985bcce6705f9ce7660db221b59093d15c79c4b7" -dependencies = [ - "proc-macro-crate 1.3.1", - "proc-macro2", - "quote", - "syn 1.0.109", -] - -[[package]] -name = "sec1" -version = "0.7.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d3e97a565f76233a6003f9f5c54be1d9c5bdfa3eccfb189469f11ec4901c47dc" -dependencies = [ - "base16ct", - "der", - "generic-array", - "pkcs8", - "subtle", - "zeroize", -] - [[package]] name = "serde" version = "1.0.203" @@ -574,7 +252,7 @@ checksum = "500cbc0ebeb6f46627f50f3f5811ccf6bf00643be300b4c3eabc0ef55dc5b5ba" dependencies = [ "proc-macro2", "quote", - "syn 2.0.55", + "syn", ] [[package]] @@ -589,39 +267,13 @@ dependencies = [ ] [[package]] -name = "signature" -version = "2.2.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "77549399552de45a898a580c1b41d445bf730df867cc44e6c0233bbc4b8329de" -dependencies = [ - "digest", - "rand_core", -] - -[[package]] -name = "snowbridge-amcl" -version = "1.0.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "460a9ed63cdf03c1b9847e8a12a5f5ba19c4efd5869e4a737e05be25d7c427e5" -dependencies = [ - "parity-scale-codec", - "scale-info", -] - -[[package]] -name = "sp1-precompiles" +name = "sp1-lib" version = "0.1.0" dependencies = [ "anyhow", "bincode", "cfg-if", - "getrandom", - "hex", - "k256", - "num", - "rand", "serde", - "snowbridge-amcl", ] [[package]] @@ -631,40 +283,13 @@ dependencies = [ "bincode", "cfg-if", "getrandom", - "k256", + "lazy_static", "libm", "once_cell", "rand", "serde", "sha2", - "sp1-precompiles", -] - -[[package]] -name = "spki" -version = "0.7.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d91ed6c858b01f942cd56b37a94b3e0a1798290327d1236e4d9cf4eaca44d29d" -dependencies = [ - "base64ct", - "der", -] - -[[package]] -name = "subtle" -version = "2.5.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "81cdd64d312baedb58e21336b31bc043b77e01cc99033ce76ef539f78e965ebc" - -[[package]] -name = "syn" -version = "1.0.109" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "72b64191b275b66ffe2469e8af2c1cfe3bafa67b529ead792a6d0160888b4237" -dependencies = [ - "proc-macro2", - "quote", - "unicode-ident", + "sp1-lib", ] [[package]] @@ -678,40 +303,6 @@ dependencies = [ "unicode-ident", ] -[[package]] -name = "tap" -version = "1.0.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "55937e1799185b12863d447f42597ed69d9928686b8d88a1df17376a097d8369" - -[[package]] -name = "toml_datetime" -version = "0.6.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7cda73e2f1397b1262d6dfdcef8aafae14d1de7748d66822d3bfeeb6d03e5e4b" - -[[package]] -name = "toml_edit" -version = "0.19.15" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1b5bb770da30e5cbfde35a2d7b9b8a2c4b8ef89548a7a6aeab5c9a576e3e7421" -dependencies = [ - "indexmap", - "toml_datetime", - "winnow", -] - -[[package]] -name = "toml_edit" -version = "0.20.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "396e4d48bbb2b7554c944bde63101b5ae446cff6ec4a24227428f15eb72ef338" -dependencies = [ - "indexmap", - "toml_datetime", - "winnow", -] - [[package]] name = "typenum" version = "1.17.0" @@ -735,27 +326,3 @@ name = "wasi" version = "0.11.0+wasi-snapshot-preview1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "9c8d87e72b64a3b4db28d11ce29237c246188f4f51057d65a7eab63b7987e423" - -[[package]] -name = "winnow" -version = "0.5.40" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f593a95398737aeed53e489c785df13f3618e41dbcd6718c6addbf1395aa6876" -dependencies = [ - "memchr", -] - -[[package]] -name = "wyz" -version = "0.5.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "05f360fc0b24296329c78fda852a1e9ae82de9cf7b27dae4b7f62f118f77b9ed" -dependencies = [ - "tap", -] - -[[package]] -name = "zeroize" -version = "1.7.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "525b4ec142c6b68a2d10f01f7bbf6755599ca3f81ea53b8431b7dd348f5fdb2d" diff --git a/tests/bn254-add/Cargo.toml b/tests/bn254-add/Cargo.toml index 4d07db91e7..f9dd6654a8 100644 --- a/tests/bn254-add/Cargo.toml +++ b/tests/bn254-add/Cargo.toml @@ -1,8 +1,9 @@ [workspace] [package] -version = "0.1.0" name = "bn254-add-test" +version = "1.0.0-rc.1" edition = "2021" +publish = false [dependencies] sp1-zkvm = { path = "../../zkvm/entrypoint" } diff --git a/tests/bn254-add/elf/riscv32im-succinct-zkvm-elf b/tests/bn254-add/elf/riscv32im-succinct-zkvm-elf index a55b917d17..c11e7cfa19 100755 Binary files a/tests/bn254-add/elf/riscv32im-succinct-zkvm-elf and b/tests/bn254-add/elf/riscv32im-succinct-zkvm-elf differ diff --git a/tests/bn254-add/src/main.rs b/tests/bn254-add/src/main.rs index 406681d656..7674aac7e8 100644 --- a/tests/bn254-add/src/main.rs +++ b/tests/bn254-add/src/main.rs @@ -1,9 +1,8 @@ #![no_main] -sp1_zkvm::entrypoint!(main); -extern "C" { - fn syscall_bn254_add(p: *mut u32, q: *const u32); -} +use sp1_zkvm::syscalls::syscall_bn254_add; + +sp1_zkvm::entrypoint!(main); pub fn main() { for _ in 0..4 { @@ -26,9 +25,7 @@ pub fn main() { 124, 10, 14, 140, 115, 237, 21, ]; - unsafe { - syscall_bn254_add(a.as_mut_ptr() as *mut u32, b.as_ptr() as *const u32); - } + syscall_bn254_add(a.as_mut_ptr() as *mut u32, b.as_ptr() as *const u32); // 3 * generator. // 3353031288059533942658390886683067124040920775575537747144343083137631628272 diff --git a/tests/bn254-double/Cargo.lock b/tests/bn254-double/Cargo.lock index 9248c331b9..88c638f591 100644 --- a/tests/bn254-double/Cargo.lock +++ b/tests/bn254-double/Cargo.lock @@ -8,30 +8,12 @@ version = "1.0.86" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "b3d1d046238990b9cf5bcde22a3fb3584ee5cf65fb2765f454ed428c7a0063da" -[[package]] -name = "arrayvec" -version = "0.7.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "96d30a06541fbafbc7f82ed10c06164cfbd2c401138f6addd8404629c4b16711" - [[package]] name = "autocfg" version = "1.2.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "f1fdabc7756949593fe60f30ec81974b613357de856987752631dea1e3394c80" -[[package]] -name = "base16ct" -version = "0.2.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4c7f02d4ea65f2c1853089ffd8d2787bdbc63de2f0d29dedbcf8ccdfa0ccd4cf" - -[[package]] -name = "base64ct" -version = "1.6.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8c3c1a368f70d6cf7302d78f8f7093da241fb8e8807c05cc9e51a125895a6d5b" - [[package]] name = "bincode" version = "1.3.3" @@ -41,18 +23,6 @@ dependencies = [ "serde", ] -[[package]] -name = "bitvec" -version = "1.0.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1bc2832c24239b0141d5674bb9174f9d68a8b5b3f2753311927c172ca46f7e9c" -dependencies = [ - "funty", - "radium", - "tap", - "wyz", -] - [[package]] name = "block-buffer" version = "0.10.4" @@ -71,24 +41,12 @@ dependencies = [ "sp1-zkvm", ] -[[package]] -name = "byte-slice-cast" -version = "1.2.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c3ac9f8b63eca6fd385229b3675f6cc0dc5c8a5c8a54a59d4f52ffd670d87b0c" - [[package]] name = "cfg-if" version = "1.0.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "baf1de4339761588bc0619e3cbc0120ee582ebb74b53b4efbf79117bd2da40fd" -[[package]] -name = "const-oid" -version = "0.9.6" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c2459377285ad874054d797f3ccebf984978aa39129f6eafde5cdc8315b612f8" - [[package]] name = "cpufeatures" version = "0.2.12" @@ -98,18 +56,6 @@ dependencies = [ "libc", ] -[[package]] -name = "crypto-bigint" -version = "0.5.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0dc92fb57ca44df6db8059111ab3af99a63d5d0f8375d9972e319a379c6bab76" -dependencies = [ - "generic-array", - "rand_core", - "subtle", - "zeroize", -] - [[package]] name = "crypto-common" version = "0.1.6" @@ -120,27 +66,6 @@ dependencies = [ "typenum", ] -[[package]] -name = "der" -version = "0.7.8" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "fffa369a668c8af7dbf8b5e56c9f744fbd399949ed171606040001947de40b1c" -dependencies = [ - "const-oid", - "zeroize", -] - -[[package]] -name = "derive_more" -version = "0.99.17" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4fb810d30a7c1953f91334de7244731fc3f3c10d7fe163338a35b9f640960321" -dependencies = [ - "proc-macro2", - "quote", - "syn 1.0.109", -] - [[package]] name = "digest" version = "0.10.7" @@ -148,68 +73,9 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "9ed9a281f7bc9b7576e61468ba615a66a5c8cfdff42420a70aa82701a3b1e292" dependencies = [ "block-buffer", - "const-oid", "crypto-common", - "subtle", -] - -[[package]] -name = "ecdsa" -version = "0.16.9" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ee27f32b5c5292967d2d4a9d7f1e0b0aed2c15daded5a60300e4abb9d8020bca" -dependencies = [ - "der", - "digest", - "elliptic-curve", - "rfc6979", - "signature", - "spki", -] - -[[package]] -name = "elliptic-curve" -version = "0.13.8" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b5e6043086bf7973472e0c7dff2142ea0b680d30e18d9cc40f267efbf222bd47" -dependencies = [ - "base16ct", - "crypto-bigint", - "digest", - "ff", - "generic-array", - "group", - "pkcs8", - "rand_core", - "sec1", - "subtle", - "tap", - "zeroize", -] - -[[package]] -name = "equivalent" -version = "1.0.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5443807d6dff69373d433ab9ef5378ad8df50ca6298caf15de6e52e24aaf54d5" - -[[package]] -name = "ff" -version = "0.13.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ded41244b729663b1e574f1b4fb731469f69f79c17667b5d776b16cda0479449" -dependencies = [ - "bitvec", - "rand_core", - "subtle", ] -[[package]] -name = "funty" -version = "2.0.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e6d5a32815ae3f33302d95fdcb2ce17862f8c65363dcfd29360480ba1001fc9c" - [[package]] name = "generic-array" version = "0.14.7" @@ -218,7 +84,6 @@ checksum = "85649ca51fd72272d7821adaf274ad91c288277713d9c18820d8499a7ff69e9a" dependencies = [ "typenum", "version_check", - "zeroize", ] [[package]] @@ -232,29 +97,6 @@ dependencies = [ "wasi", ] -[[package]] -name = "group" -version = "0.13.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f0f9ef7462f7c099f518d754361858f86d8a07af53ba9af0fe635bbccb151a63" -dependencies = [ - "ff", - "rand_core", - "subtle", -] - -[[package]] -name = "hashbrown" -version = "0.14.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "290f1a1d9242c78d09ce40a5e87e7554ee637af1351968159f4952f028f75604" - -[[package]] -name = "hex" -version = "0.4.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7f24254aa9a54b5c858eaee2f5bccdb46aaf0e486a595ed5fd8f86ba55232a70" - [[package]] name = "hex-literal" version = "0.4.1" @@ -262,48 +104,10 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "6fe2267d4ed49bc07b63801559be28c718ea06c4738b7a03c94df7386d2cde46" [[package]] -name = "hmac" -version = "0.12.1" +name = "lazy_static" +version = "1.5.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6c49c37c09c17a53d937dfbb742eb3a961d65a994e6bcdcf37e7399d0cc8ab5e" -dependencies = [ - "digest", -] - -[[package]] -name = "impl-trait-for-tuples" -version = "0.2.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "11d7a9f6330b71fea57921c9b61c47ee6e84f72d394754eff6163ae67e7395eb" -dependencies = [ - "proc-macro2", - "quote", - "syn 1.0.109", -] - -[[package]] -name = "indexmap" -version = "2.2.6" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "168fb715dda47215e360912c096649d23d58bf392ac62f73919e831745e40f26" -dependencies = [ - "equivalent", - "hashbrown", -] - -[[package]] -name = "k256" -version = "0.13.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "956ff9b67e26e1a6a866cb758f12c6f8746208489e3e4a4b5580802f2f0a587b" -dependencies = [ - "cfg-if", - "ecdsa", - "elliptic-curve", - "once_cell", - "sha2", - "signature", -] +checksum = "bbd2bcb4c963f2ddae06a2efc7e9f3591312473c50c6685e1f298068316e66fe" [[package]] name = "libc" @@ -317,19 +121,12 @@ version = "0.2.8" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "4ec2a862134d2a7d32d7983ddcdd1c4923530833c9f2ea1a44fc5fa473989058" -[[package]] -name = "memchr" -version = "2.7.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6c8640c5d730cb13ebd907d8d04b52f55ac9a2eec55b440c8892f40d56c76c1d" - [[package]] name = "num" version = "0.4.3" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "35bd024e8b2ff75562e5f34e7f4905839deb4b22955ef5e73d2fea1b9813cb23" dependencies = [ - "num-bigint", "num-complex", "num-integer", "num-iter", @@ -337,16 +134,6 @@ dependencies = [ "num-traits", ] -[[package]] -name = "num-bigint" -version = "0.4.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c165a9ab64cf766f73521c0dd2cfdff64f488b8f0b3e621face3462d3db536d7" -dependencies = [ - "num-integer", - "num-traits", -] - [[package]] name = "num-complex" version = "0.4.6" @@ -382,7 +169,6 @@ version = "0.4.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "f83d14da390562dca69fc84082e73e548e1ad308d24accdedd2720017cb37824" dependencies = [ - "num-bigint", "num-integer", "num-traits", ] @@ -402,66 +188,12 @@ version = "1.19.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "3fdb12b2476b595f9358c5161aa467c2438859caa136dec86c26fdd2efe17b92" -[[package]] -name = "parity-scale-codec" -version = "3.6.9" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "881331e34fa842a2fb61cc2db9643a8fedc615e47cfcc52597d1af0db9a7e8fe" -dependencies = [ - "arrayvec", - "byte-slice-cast", - "impl-trait-for-tuples", - "parity-scale-codec-derive", -] - -[[package]] -name = "parity-scale-codec-derive" -version = "3.6.9" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "be30eaf4b0a9fba5336683b38de57bb86d179a35862ba6bfcf57625d006bde5b" -dependencies = [ - "proc-macro-crate 2.0.2", - "proc-macro2", - "quote", - "syn 1.0.109", -] - -[[package]] -name = "pkcs8" -version = "0.10.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f950b2377845cebe5cf8b5165cb3cc1a5e0fa5cfa3e1f7f55707d8fd82e0a7b7" -dependencies = [ - "der", - "spki", -] - [[package]] name = "ppv-lite86" version = "0.2.17" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "5b40af805b3121feab8a3c29f04d8ad262fa8e0561883e7653e024ae4479e6de" -[[package]] -name = "proc-macro-crate" -version = "1.3.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7f4c021e1093a56626774e81216a4ce732a735e5bad4868a03f3ed65ca0c3919" -dependencies = [ - "once_cell", - "toml_edit 0.19.15", -] - -[[package]] -name = "proc-macro-crate" -version = "2.0.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b00f26d3400549137f92511a46ac1cd8ce37cb5598a96d382381458b992a5d24" -dependencies = [ - "toml_datetime", - "toml_edit 0.20.2", -] - [[package]] name = "proc-macro2" version = "1.0.79" @@ -480,12 +212,6 @@ dependencies = [ "proc-macro2", ] -[[package]] -name = "radium" -version = "0.7.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "dc33ff2d4973d518d823d61aa239014831e521c75da58e3df4840d3f47749d09" - [[package]] name = "rand" version = "0.8.5" @@ -516,54 +242,6 @@ dependencies = [ "getrandom", ] -[[package]] -name = "rfc6979" -version = "0.4.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f8dd2a808d456c4a54e300a23e9f5a67e122c3024119acbfd73e3bf664491cb2" -dependencies = [ - "hmac", - "subtle", -] - -[[package]] -name = "scale-info" -version = "2.11.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7c453e59a955f81fb62ee5d596b450383d699f152d350e9d23a0db2adb78e4c0" -dependencies = [ - "cfg-if", - "derive_more", - "parity-scale-codec", - "scale-info-derive", -] - -[[package]] -name = "scale-info-derive" -version = "2.11.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "18cf6c6447f813ef19eb450e985bcce6705f9ce7660db221b59093d15c79c4b7" -dependencies = [ - "proc-macro-crate 1.3.1", - "proc-macro2", - "quote", - "syn 1.0.109", -] - -[[package]] -name = "sec1" -version = "0.7.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d3e97a565f76233a6003f9f5c54be1d9c5bdfa3eccfb189469f11ec4901c47dc" -dependencies = [ - "base16ct", - "der", - "generic-array", - "pkcs8", - "subtle", - "zeroize", -] - [[package]] name = "serde" version = "1.0.203" @@ -581,7 +259,7 @@ checksum = "500cbc0ebeb6f46627f50f3f5811ccf6bf00643be300b4c3eabc0ef55dc5b5ba" dependencies = [ "proc-macro2", "quote", - "syn 2.0.55", + "syn", ] [[package]] @@ -596,39 +274,13 @@ dependencies = [ ] [[package]] -name = "signature" -version = "2.2.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "77549399552de45a898a580c1b41d445bf730df867cc44e6c0233bbc4b8329de" -dependencies = [ - "digest", - "rand_core", -] - -[[package]] -name = "snowbridge-amcl" -version = "1.0.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "460a9ed63cdf03c1b9847e8a12a5f5ba19c4efd5869e4a737e05be25d7c427e5" -dependencies = [ - "parity-scale-codec", - "scale-info", -] - -[[package]] -name = "sp1-precompiles" +name = "sp1-lib" version = "0.1.0" dependencies = [ "anyhow", "bincode", "cfg-if", - "getrandom", - "hex", - "k256", - "num", - "rand", "serde", - "snowbridge-amcl", ] [[package]] @@ -638,40 +290,13 @@ dependencies = [ "bincode", "cfg-if", "getrandom", - "k256", + "lazy_static", "libm", "once_cell", "rand", "serde", "sha2", - "sp1-precompiles", -] - -[[package]] -name = "spki" -version = "0.7.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d91ed6c858b01f942cd56b37a94b3e0a1798290327d1236e4d9cf4eaca44d29d" -dependencies = [ - "base64ct", - "der", -] - -[[package]] -name = "subtle" -version = "2.5.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "81cdd64d312baedb58e21336b31bc043b77e01cc99033ce76ef539f78e965ebc" - -[[package]] -name = "syn" -version = "1.0.109" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "72b64191b275b66ffe2469e8af2c1cfe3bafa67b529ead792a6d0160888b4237" -dependencies = [ - "proc-macro2", - "quote", - "unicode-ident", + "sp1-lib", ] [[package]] @@ -685,40 +310,6 @@ dependencies = [ "unicode-ident", ] -[[package]] -name = "tap" -version = "1.0.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "55937e1799185b12863d447f42597ed69d9928686b8d88a1df17376a097d8369" - -[[package]] -name = "toml_datetime" -version = "0.6.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7cda73e2f1397b1262d6dfdcef8aafae14d1de7748d66822d3bfeeb6d03e5e4b" - -[[package]] -name = "toml_edit" -version = "0.19.15" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1b5bb770da30e5cbfde35a2d7b9b8a2c4b8ef89548a7a6aeab5c9a576e3e7421" -dependencies = [ - "indexmap", - "toml_datetime", - "winnow", -] - -[[package]] -name = "toml_edit" -version = "0.20.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "396e4d48bbb2b7554c944bde63101b5ae446cff6ec4a24227428f15eb72ef338" -dependencies = [ - "indexmap", - "toml_datetime", - "winnow", -] - [[package]] name = "typenum" version = "1.17.0" @@ -742,27 +333,3 @@ name = "wasi" version = "0.11.0+wasi-snapshot-preview1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "9c8d87e72b64a3b4db28d11ce29237c246188f4f51057d65a7eab63b7987e423" - -[[package]] -name = "winnow" -version = "0.5.40" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f593a95398737aeed53e489c785df13f3618e41dbcd6718c6addbf1395aa6876" -dependencies = [ - "memchr", -] - -[[package]] -name = "wyz" -version = "0.5.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "05f360fc0b24296329c78fda852a1e9ae82de9cf7b27dae4b7f62f118f77b9ed" -dependencies = [ - "tap", -] - -[[package]] -name = "zeroize" -version = "1.7.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "525b4ec142c6b68a2d10f01f7bbf6755599ca3f81ea53b8431b7dd348f5fdb2d" diff --git a/tests/bn254-double/Cargo.toml b/tests/bn254-double/Cargo.toml index d0d3f75d34..c95972dda2 100644 --- a/tests/bn254-double/Cargo.toml +++ b/tests/bn254-double/Cargo.toml @@ -1,8 +1,9 @@ [workspace] [package] -version = "0.1.0" name = "bn254-double-test" +version = "1.0.0-rc.1" edition = "2021" +publish = false [dependencies] sp1-zkvm = { path = "../../zkvm/entrypoint" } diff --git a/tests/bn254-double/elf/riscv32im-succinct-zkvm-elf b/tests/bn254-double/elf/riscv32im-succinct-zkvm-elf index b571be7344..fa1f465b82 100755 Binary files a/tests/bn254-double/elf/riscv32im-succinct-zkvm-elf and b/tests/bn254-double/elf/riscv32im-succinct-zkvm-elf differ diff --git a/tests/bn254-double/src/main.rs b/tests/bn254-double/src/main.rs index 7d27ef058d..9e77b3cf3b 100644 --- a/tests/bn254-double/src/main.rs +++ b/tests/bn254-double/src/main.rs @@ -1,9 +1,8 @@ #![no_main] -sp1_zkvm::entrypoint!(main); -extern "C" { - fn syscall_bn254_double(p: *mut u32); -} +use sp1_zkvm::syscalls::syscall_bn254_double; + +sp1_zkvm::entrypoint!(main); pub fn main() { for _ in 0..10i64.pow(3) { @@ -16,9 +15,7 @@ pub fn main() { 0, 0, 0, 0, 0, 0, ]; - unsafe { - syscall_bn254_double(a.as_mut_ptr() as *mut u32); - } + syscall_bn254_double(a.as_mut_ptr() as *mut u32); // 2 * generator. // 1368015179489954701390400359078579693043519447331113978918064868415326638035 diff --git a/tests/bn254-mul/Cargo.lock b/tests/bn254-mul/Cargo.lock index 4b769f4bcd..de1f150dc6 100644 --- a/tests/bn254-mul/Cargo.lock +++ b/tests/bn254-mul/Cargo.lock @@ -8,30 +8,6 @@ version = "1.0.86" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "b3d1d046238990b9cf5bcde22a3fb3584ee5cf65fb2765f454ed428c7a0063da" -[[package]] -name = "arrayvec" -version = "0.7.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "96d30a06541fbafbc7f82ed10c06164cfbd2c401138f6addd8404629c4b16711" - -[[package]] -name = "autocfg" -version = "1.2.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f1fdabc7756949593fe60f30ec81974b613357de856987752631dea1e3394c80" - -[[package]] -name = "base16ct" -version = "0.2.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4c7f02d4ea65f2c1853089ffd8d2787bdbc63de2f0d29dedbcf8ccdfa0ccd4cf" - -[[package]] -name = "base64ct" -version = "1.6.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8c3c1a368f70d6cf7302d78f8f7093da241fb8e8807c05cc9e51a125895a6d5b" - [[package]] name = "bincode" version = "1.3.3" @@ -41,18 +17,6 @@ dependencies = [ "serde", ] -[[package]] -name = "bitvec" -version = "1.0.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1bc2832c24239b0141d5674bb9174f9d68a8b5b3f2753311927c172ca46f7e9c" -dependencies = [ - "funty", - "radium", - "tap", - "wyz", -] - [[package]] name = "block-buffer" version = "0.10.4" @@ -70,24 +34,12 @@ dependencies = [ "sp1-zkvm", ] -[[package]] -name = "byte-slice-cast" -version = "1.2.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c3ac9f8b63eca6fd385229b3675f6cc0dc5c8a5c8a54a59d4f52ffd670d87b0c" - [[package]] name = "cfg-if" version = "1.0.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "baf1de4339761588bc0619e3cbc0120ee582ebb74b53b4efbf79117bd2da40fd" -[[package]] -name = "const-oid" -version = "0.9.6" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c2459377285ad874054d797f3ccebf984978aa39129f6eafde5cdc8315b612f8" - [[package]] name = "cpufeatures" version = "0.2.12" @@ -97,18 +49,6 @@ dependencies = [ "libc", ] -[[package]] -name = "crypto-bigint" -version = "0.5.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0dc92fb57ca44df6db8059111ab3af99a63d5d0f8375d9972e319a379c6bab76" -dependencies = [ - "generic-array", - "rand_core", - "subtle", - "zeroize", -] - [[package]] name = "crypto-common" version = "0.1.6" @@ -119,27 +59,6 @@ dependencies = [ "typenum", ] -[[package]] -name = "der" -version = "0.7.8" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "fffa369a668c8af7dbf8b5e56c9f744fbd399949ed171606040001947de40b1c" -dependencies = [ - "const-oid", - "zeroize", -] - -[[package]] -name = "derive_more" -version = "0.99.17" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4fb810d30a7c1953f91334de7244731fc3f3c10d7fe163338a35b9f640960321" -dependencies = [ - "proc-macro2", - "quote", - "syn 1.0.109", -] - [[package]] name = "digest" version = "0.10.7" @@ -147,68 +66,9 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "9ed9a281f7bc9b7576e61468ba615a66a5c8cfdff42420a70aa82701a3b1e292" dependencies = [ "block-buffer", - "const-oid", "crypto-common", - "subtle", -] - -[[package]] -name = "ecdsa" -version = "0.16.9" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ee27f32b5c5292967d2d4a9d7f1e0b0aed2c15daded5a60300e4abb9d8020bca" -dependencies = [ - "der", - "digest", - "elliptic-curve", - "rfc6979", - "signature", - "spki", -] - -[[package]] -name = "elliptic-curve" -version = "0.13.8" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b5e6043086bf7973472e0c7dff2142ea0b680d30e18d9cc40f267efbf222bd47" -dependencies = [ - "base16ct", - "crypto-bigint", - "digest", - "ff", - "generic-array", - "group", - "pkcs8", - "rand_core", - "sec1", - "subtle", - "tap", - "zeroize", -] - -[[package]] -name = "equivalent" -version = "1.0.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5443807d6dff69373d433ab9ef5378ad8df50ca6298caf15de6e52e24aaf54d5" - -[[package]] -name = "ff" -version = "0.13.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ded41244b729663b1e574f1b4fb731469f69f79c17667b5d776b16cda0479449" -dependencies = [ - "bitvec", - "rand_core", - "subtle", ] -[[package]] -name = "funty" -version = "2.0.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e6d5a32815ae3f33302d95fdcb2ce17862f8c65363dcfd29360480ba1001fc9c" - [[package]] name = "generic-array" version = "0.14.7" @@ -217,7 +77,6 @@ checksum = "85649ca51fd72272d7821adaf274ad91c288277713d9c18820d8499a7ff69e9a" dependencies = [ "typenum", "version_check", - "zeroize", ] [[package]] @@ -232,71 +91,10 @@ dependencies = [ ] [[package]] -name = "group" -version = "0.13.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f0f9ef7462f7c099f518d754361858f86d8a07af53ba9af0fe635bbccb151a63" -dependencies = [ - "ff", - "rand_core", - "subtle", -] - -[[package]] -name = "hashbrown" -version = "0.14.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "290f1a1d9242c78d09ce40a5e87e7554ee637af1351968159f4952f028f75604" - -[[package]] -name = "hex" -version = "0.4.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7f24254aa9a54b5c858eaee2f5bccdb46aaf0e486a595ed5fd8f86ba55232a70" - -[[package]] -name = "hmac" -version = "0.12.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6c49c37c09c17a53d937dfbb742eb3a961d65a994e6bcdcf37e7399d0cc8ab5e" -dependencies = [ - "digest", -] - -[[package]] -name = "impl-trait-for-tuples" -version = "0.2.2" +name = "lazy_static" +version = "1.5.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "11d7a9f6330b71fea57921c9b61c47ee6e84f72d394754eff6163ae67e7395eb" -dependencies = [ - "proc-macro2", - "quote", - "syn 1.0.109", -] - -[[package]] -name = "indexmap" -version = "2.2.6" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "168fb715dda47215e360912c096649d23d58bf392ac62f73919e831745e40f26" -dependencies = [ - "equivalent", - "hashbrown", -] - -[[package]] -name = "k256" -version = "0.13.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "956ff9b67e26e1a6a866cb758f12c6f8746208489e3e4a4b5580802f2f0a587b" -dependencies = [ - "cfg-if", - "ecdsa", - "elliptic-curve", - "once_cell", - "sha2", - "signature", -] +checksum = "bbd2bcb4c963f2ddae06a2efc7e9f3591312473c50c6685e1f298068316e66fe" [[package]] name = "libc" @@ -310,151 +108,18 @@ version = "0.2.8" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "4ec2a862134d2a7d32d7983ddcdd1c4923530833c9f2ea1a44fc5fa473989058" -[[package]] -name = "memchr" -version = "2.7.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6c8640c5d730cb13ebd907d8d04b52f55ac9a2eec55b440c8892f40d56c76c1d" - -[[package]] -name = "num" -version = "0.4.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "35bd024e8b2ff75562e5f34e7f4905839deb4b22955ef5e73d2fea1b9813cb23" -dependencies = [ - "num-bigint", - "num-complex", - "num-integer", - "num-iter", - "num-rational", - "num-traits", -] - -[[package]] -name = "num-bigint" -version = "0.4.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c165a9ab64cf766f73521c0dd2cfdff64f488b8f0b3e621face3462d3db536d7" -dependencies = [ - "num-integer", - "num-traits", -] - -[[package]] -name = "num-complex" -version = "0.4.6" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "73f88a1307638156682bada9d7604135552957b7818057dcef22705b4d509495" -dependencies = [ - "num-traits", -] - -[[package]] -name = "num-integer" -version = "0.1.46" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7969661fd2958a5cb096e56c8e1ad0444ac2bbcd0061bd28660485a44879858f" -dependencies = [ - "num-traits", -] - -[[package]] -name = "num-iter" -version = "0.1.45" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1429034a0490724d0075ebb2bc9e875d6503c3cf69e235a8941aa757d83ef5bf" -dependencies = [ - "autocfg", - "num-integer", - "num-traits", -] - -[[package]] -name = "num-rational" -version = "0.4.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f83d14da390562dca69fc84082e73e548e1ad308d24accdedd2720017cb37824" -dependencies = [ - "num-bigint", - "num-integer", - "num-traits", -] - -[[package]] -name = "num-traits" -version = "0.2.19" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "071dfc062690e90b734c0b2273ce72ad0ffa95f0c74596bc250dcfd960262841" -dependencies = [ - "autocfg", -] - [[package]] name = "once_cell" version = "1.19.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "3fdb12b2476b595f9358c5161aa467c2438859caa136dec86c26fdd2efe17b92" -[[package]] -name = "parity-scale-codec" -version = "3.6.9" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "881331e34fa842a2fb61cc2db9643a8fedc615e47cfcc52597d1af0db9a7e8fe" -dependencies = [ - "arrayvec", - "byte-slice-cast", - "impl-trait-for-tuples", - "parity-scale-codec-derive", -] - -[[package]] -name = "parity-scale-codec-derive" -version = "3.6.9" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "be30eaf4b0a9fba5336683b38de57bb86d179a35862ba6bfcf57625d006bde5b" -dependencies = [ - "proc-macro-crate 2.0.2", - "proc-macro2", - "quote", - "syn 1.0.109", -] - -[[package]] -name = "pkcs8" -version = "0.10.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f950b2377845cebe5cf8b5165cb3cc1a5e0fa5cfa3e1f7f55707d8fd82e0a7b7" -dependencies = [ - "der", - "spki", -] - [[package]] name = "ppv-lite86" version = "0.2.17" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "5b40af805b3121feab8a3c29f04d8ad262fa8e0561883e7653e024ae4479e6de" -[[package]] -name = "proc-macro-crate" -version = "1.3.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7f4c021e1093a56626774e81216a4ce732a735e5bad4868a03f3ed65ca0c3919" -dependencies = [ - "once_cell", - "toml_edit 0.19.15", -] - -[[package]] -name = "proc-macro-crate" -version = "2.0.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b00f26d3400549137f92511a46ac1cd8ce37cb5598a96d382381458b992a5d24" -dependencies = [ - "toml_datetime", - "toml_edit 0.20.2", -] - [[package]] name = "proc-macro2" version = "1.0.79" @@ -473,12 +138,6 @@ dependencies = [ "proc-macro2", ] -[[package]] -name = "radium" -version = "0.7.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "dc33ff2d4973d518d823d61aa239014831e521c75da58e3df4840d3f47749d09" - [[package]] name = "rand" version = "0.8.5" @@ -509,54 +168,6 @@ dependencies = [ "getrandom", ] -[[package]] -name = "rfc6979" -version = "0.4.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f8dd2a808d456c4a54e300a23e9f5a67e122c3024119acbfd73e3bf664491cb2" -dependencies = [ - "hmac", - "subtle", -] - -[[package]] -name = "scale-info" -version = "2.11.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7c453e59a955f81fb62ee5d596b450383d699f152d350e9d23a0db2adb78e4c0" -dependencies = [ - "cfg-if", - "derive_more", - "parity-scale-codec", - "scale-info-derive", -] - -[[package]] -name = "scale-info-derive" -version = "2.11.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "18cf6c6447f813ef19eb450e985bcce6705f9ce7660db221b59093d15c79c4b7" -dependencies = [ - "proc-macro-crate 1.3.1", - "proc-macro2", - "quote", - "syn 1.0.109", -] - -[[package]] -name = "sec1" -version = "0.7.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d3e97a565f76233a6003f9f5c54be1d9c5bdfa3eccfb189469f11ec4901c47dc" -dependencies = [ - "base16ct", - "der", - "generic-array", - "pkcs8", - "subtle", - "zeroize", -] - [[package]] name = "serde" version = "1.0.202" @@ -588,26 +199,6 @@ dependencies = [ "digest", ] -[[package]] -name = "signature" -version = "2.2.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "77549399552de45a898a580c1b41d445bf730df867cc44e6c0233bbc4b8329de" -dependencies = [ - "digest", - "rand_core", -] - -[[package]] -name = "snowbridge-amcl" -version = "1.0.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "460a9ed63cdf03c1b9847e8a12a5f5ba19c4efd5869e4a737e05be25d7c427e5" -dependencies = [ - "parity-scale-codec", - "scale-info", -] - [[package]] name = "sp1-derive" version = "0.1.0" @@ -618,19 +209,13 @@ dependencies = [ ] [[package]] -name = "sp1-precompiles" +name = "sp1-lib" version = "0.1.0" dependencies = [ "anyhow", "bincode", "cfg-if", - "getrandom", - "hex", - "k256", - "num", - "rand", "serde", - "snowbridge-amcl", ] [[package]] @@ -640,31 +225,15 @@ dependencies = [ "bincode", "cfg-if", "getrandom", - "k256", + "lazy_static", "libm", "once_cell", "rand", "serde", "sha2", - "sp1-precompiles", + "sp1-lib", ] -[[package]] -name = "spki" -version = "0.7.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d91ed6c858b01f942cd56b37a94b3e0a1798290327d1236e4d9cf4eaca44d29d" -dependencies = [ - "base64ct", - "der", -] - -[[package]] -name = "subtle" -version = "2.5.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "81cdd64d312baedb58e21336b31bc043b77e01cc99033ce76ef539f78e965ebc" - [[package]] name = "syn" version = "1.0.109" @@ -687,40 +256,6 @@ dependencies = [ "unicode-ident", ] -[[package]] -name = "tap" -version = "1.0.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "55937e1799185b12863d447f42597ed69d9928686b8d88a1df17376a097d8369" - -[[package]] -name = "toml_datetime" -version = "0.6.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7cda73e2f1397b1262d6dfdcef8aafae14d1de7748d66822d3bfeeb6d03e5e4b" - -[[package]] -name = "toml_edit" -version = "0.19.15" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1b5bb770da30e5cbfde35a2d7b9b8a2c4b8ef89548a7a6aeab5c9a576e3e7421" -dependencies = [ - "indexmap", - "toml_datetime", - "winnow", -] - -[[package]] -name = "toml_edit" -version = "0.20.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "396e4d48bbb2b7554c944bde63101b5ae446cff6ec4a24227428f15eb72ef338" -dependencies = [ - "indexmap", - "toml_datetime", - "winnow", -] - [[package]] name = "typenum" version = "1.17.0" @@ -744,27 +279,3 @@ name = "wasi" version = "0.11.0+wasi-snapshot-preview1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "9c8d87e72b64a3b4db28d11ce29237c246188f4f51057d65a7eab63b7987e423" - -[[package]] -name = "winnow" -version = "0.5.40" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f593a95398737aeed53e489c785df13f3618e41dbcd6718c6addbf1395aa6876" -dependencies = [ - "memchr", -] - -[[package]] -name = "wyz" -version = "0.5.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "05f360fc0b24296329c78fda852a1e9ae82de9cf7b27dae4b7f62f118f77b9ed" -dependencies = [ - "tap", -] - -[[package]] -name = "zeroize" -version = "1.7.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "525b4ec142c6b68a2d10f01f7bbf6755599ca3f81ea53b8431b7dd348f5fdb2d" diff --git a/tests/bn254-mul/Cargo.toml b/tests/bn254-mul/Cargo.toml index fdf493b3f8..b891e5fd8a 100644 --- a/tests/bn254-mul/Cargo.toml +++ b/tests/bn254-mul/Cargo.toml @@ -1,9 +1,10 @@ [workspace] [package] name = "bn254-mul-test" -version = "0.1.0" +version = "1.0.0-rc.1" edition = "2021" +publish = false [dependencies] -sp1-zkvm = { path = "../../zkvm/entrypoint" } +sp1-zkvm = { path = "../../zkvm/entrypoint", features = ["bn254"] } sp1-derive = { path = "../../derive" } diff --git a/tests/bn254-mul/elf/riscv32im-succinct-zkvm-elf b/tests/bn254-mul/elf/riscv32im-succinct-zkvm-elf index dd1506ddc7..027b403a89 100755 Binary files a/tests/bn254-mul/elf/riscv32im-succinct-zkvm-elf and b/tests/bn254-mul/elf/riscv32im-succinct-zkvm-elf differ diff --git a/tests/bn254-mul/src/main.rs b/tests/bn254-mul/src/main.rs index 3086c3806f..8ed9555cd3 100644 --- a/tests/bn254-mul/src/main.rs +++ b/tests/bn254-mul/src/main.rs @@ -1,8 +1,8 @@ #![no_main] sp1_zkvm::entrypoint!(main); -use sp1_zkvm::precompiles::bn254::Bn254; -use sp1_zkvm::precompiles::utils::AffinePoint; +use sp1_zkvm::lib::bn254::Bn254; +use sp1_zkvm::lib::utils::AffinePoint; #[sp1_derive::cycle_tracker] pub fn main() { diff --git a/tests/cycle-tracker/Cargo.lock b/tests/cycle-tracker/Cargo.lock index d8b648297e..2fd2144114 100644 --- a/tests/cycle-tracker/Cargo.lock +++ b/tests/cycle-tracker/Cargo.lock @@ -8,30 +8,6 @@ version = "1.0.86" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "b3d1d046238990b9cf5bcde22a3fb3584ee5cf65fb2765f454ed428c7a0063da" -[[package]] -name = "arrayvec" -version = "0.7.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "96d30a06541fbafbc7f82ed10c06164cfbd2c401138f6addd8404629c4b16711" - -[[package]] -name = "autocfg" -version = "1.2.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f1fdabc7756949593fe60f30ec81974b613357de856987752631dea1e3394c80" - -[[package]] -name = "base16ct" -version = "0.2.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4c7f02d4ea65f2c1853089ffd8d2787bdbc63de2f0d29dedbcf8ccdfa0ccd4cf" - -[[package]] -name = "base64ct" -version = "1.6.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8c3c1a368f70d6cf7302d78f8f7093da241fb8e8807c05cc9e51a125895a6d5b" - [[package]] name = "bincode" version = "1.3.3" @@ -41,18 +17,6 @@ dependencies = [ "serde", ] -[[package]] -name = "bitvec" -version = "1.0.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1bc2832c24239b0141d5674bb9174f9d68a8b5b3f2753311927c172ca46f7e9c" -dependencies = [ - "funty", - "radium", - "tap", - "wyz", -] - [[package]] name = "block-buffer" version = "0.10.4" @@ -62,24 +26,12 @@ dependencies = [ "generic-array", ] -[[package]] -name = "byte-slice-cast" -version = "1.2.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c3ac9f8b63eca6fd385229b3675f6cc0dc5c8a5c8a54a59d4f52ffd670d87b0c" - [[package]] name = "cfg-if" version = "1.0.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "baf1de4339761588bc0619e3cbc0120ee582ebb74b53b4efbf79117bd2da40fd" -[[package]] -name = "const-oid" -version = "0.9.6" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c2459377285ad874054d797f3ccebf984978aa39129f6eafde5cdc8315b612f8" - [[package]] name = "cpufeatures" version = "0.2.12" @@ -89,18 +41,6 @@ dependencies = [ "libc", ] -[[package]] -name = "crypto-bigint" -version = "0.5.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0dc92fb57ca44df6db8059111ab3af99a63d5d0f8375d9972e319a379c6bab76" -dependencies = [ - "generic-array", - "rand_core", - "subtle", - "zeroize", -] - [[package]] name = "crypto-common" version = "0.1.6" @@ -119,27 +59,6 @@ dependencies = [ "sp1-zkvm", ] -[[package]] -name = "der" -version = "0.7.8" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "fffa369a668c8af7dbf8b5e56c9f744fbd399949ed171606040001947de40b1c" -dependencies = [ - "const-oid", - "zeroize", -] - -[[package]] -name = "derive_more" -version = "0.99.17" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4fb810d30a7c1953f91334de7244731fc3f3c10d7fe163338a35b9f640960321" -dependencies = [ - "proc-macro2", - "quote", - "syn 1.0.109", -] - [[package]] name = "digest" version = "0.10.7" @@ -147,68 +66,9 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "9ed9a281f7bc9b7576e61468ba615a66a5c8cfdff42420a70aa82701a3b1e292" dependencies = [ "block-buffer", - "const-oid", "crypto-common", - "subtle", -] - -[[package]] -name = "ecdsa" -version = "0.16.9" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ee27f32b5c5292967d2d4a9d7f1e0b0aed2c15daded5a60300e4abb9d8020bca" -dependencies = [ - "der", - "digest", - "elliptic-curve", - "rfc6979", - "signature", - "spki", -] - -[[package]] -name = "elliptic-curve" -version = "0.13.8" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b5e6043086bf7973472e0c7dff2142ea0b680d30e18d9cc40f267efbf222bd47" -dependencies = [ - "base16ct", - "crypto-bigint", - "digest", - "ff", - "generic-array", - "group", - "pkcs8", - "rand_core", - "sec1", - "subtle", - "tap", - "zeroize", -] - -[[package]] -name = "equivalent" -version = "1.0.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5443807d6dff69373d433ab9ef5378ad8df50ca6298caf15de6e52e24aaf54d5" - -[[package]] -name = "ff" -version = "0.13.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ded41244b729663b1e574f1b4fb731469f69f79c17667b5d776b16cda0479449" -dependencies = [ - "bitvec", - "rand_core", - "subtle", ] -[[package]] -name = "funty" -version = "2.0.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e6d5a32815ae3f33302d95fdcb2ce17862f8c65363dcfd29360480ba1001fc9c" - [[package]] name = "generic-array" version = "0.14.7" @@ -217,7 +77,6 @@ checksum = "85649ca51fd72272d7821adaf274ad91c288277713d9c18820d8499a7ff69e9a" dependencies = [ "typenum", "version_check", - "zeroize", ] [[package]] @@ -232,71 +91,10 @@ dependencies = [ ] [[package]] -name = "group" -version = "0.13.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f0f9ef7462f7c099f518d754361858f86d8a07af53ba9af0fe635bbccb151a63" -dependencies = [ - "ff", - "rand_core", - "subtle", -] - -[[package]] -name = "hashbrown" -version = "0.14.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "290f1a1d9242c78d09ce40a5e87e7554ee637af1351968159f4952f028f75604" - -[[package]] -name = "hex" -version = "0.4.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7f24254aa9a54b5c858eaee2f5bccdb46aaf0e486a595ed5fd8f86ba55232a70" - -[[package]] -name = "hmac" -version = "0.12.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6c49c37c09c17a53d937dfbb742eb3a961d65a994e6bcdcf37e7399d0cc8ab5e" -dependencies = [ - "digest", -] - -[[package]] -name = "impl-trait-for-tuples" -version = "0.2.2" +name = "lazy_static" +version = "1.5.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "11d7a9f6330b71fea57921c9b61c47ee6e84f72d394754eff6163ae67e7395eb" -dependencies = [ - "proc-macro2", - "quote", - "syn 1.0.109", -] - -[[package]] -name = "indexmap" -version = "2.2.6" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "168fb715dda47215e360912c096649d23d58bf392ac62f73919e831745e40f26" -dependencies = [ - "equivalent", - "hashbrown", -] - -[[package]] -name = "k256" -version = "0.13.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "956ff9b67e26e1a6a866cb758f12c6f8746208489e3e4a4b5580802f2f0a587b" -dependencies = [ - "cfg-if", - "ecdsa", - "elliptic-curve", - "once_cell", - "sha2", - "signature", -] +checksum = "bbd2bcb4c963f2ddae06a2efc7e9f3591312473c50c6685e1f298068316e66fe" [[package]] name = "libc" @@ -310,151 +108,18 @@ version = "0.2.8" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "4ec2a862134d2a7d32d7983ddcdd1c4923530833c9f2ea1a44fc5fa473989058" -[[package]] -name = "memchr" -version = "2.7.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6c8640c5d730cb13ebd907d8d04b52f55ac9a2eec55b440c8892f40d56c76c1d" - -[[package]] -name = "num" -version = "0.4.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "35bd024e8b2ff75562e5f34e7f4905839deb4b22955ef5e73d2fea1b9813cb23" -dependencies = [ - "num-bigint", - "num-complex", - "num-integer", - "num-iter", - "num-rational", - "num-traits", -] - -[[package]] -name = "num-bigint" -version = "0.4.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c165a9ab64cf766f73521c0dd2cfdff64f488b8f0b3e621face3462d3db536d7" -dependencies = [ - "num-integer", - "num-traits", -] - -[[package]] -name = "num-complex" -version = "0.4.6" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "73f88a1307638156682bada9d7604135552957b7818057dcef22705b4d509495" -dependencies = [ - "num-traits", -] - -[[package]] -name = "num-integer" -version = "0.1.46" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7969661fd2958a5cb096e56c8e1ad0444ac2bbcd0061bd28660485a44879858f" -dependencies = [ - "num-traits", -] - -[[package]] -name = "num-iter" -version = "0.1.45" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1429034a0490724d0075ebb2bc9e875d6503c3cf69e235a8941aa757d83ef5bf" -dependencies = [ - "autocfg", - "num-integer", - "num-traits", -] - -[[package]] -name = "num-rational" -version = "0.4.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f83d14da390562dca69fc84082e73e548e1ad308d24accdedd2720017cb37824" -dependencies = [ - "num-bigint", - "num-integer", - "num-traits", -] - -[[package]] -name = "num-traits" -version = "0.2.19" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "071dfc062690e90b734c0b2273ce72ad0ffa95f0c74596bc250dcfd960262841" -dependencies = [ - "autocfg", -] - [[package]] name = "once_cell" version = "1.19.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "3fdb12b2476b595f9358c5161aa467c2438859caa136dec86c26fdd2efe17b92" -[[package]] -name = "parity-scale-codec" -version = "3.6.9" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "881331e34fa842a2fb61cc2db9643a8fedc615e47cfcc52597d1af0db9a7e8fe" -dependencies = [ - "arrayvec", - "byte-slice-cast", - "impl-trait-for-tuples", - "parity-scale-codec-derive", -] - -[[package]] -name = "parity-scale-codec-derive" -version = "3.6.9" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "be30eaf4b0a9fba5336683b38de57bb86d179a35862ba6bfcf57625d006bde5b" -dependencies = [ - "proc-macro-crate 2.0.2", - "proc-macro2", - "quote", - "syn 1.0.109", -] - -[[package]] -name = "pkcs8" -version = "0.10.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f950b2377845cebe5cf8b5165cb3cc1a5e0fa5cfa3e1f7f55707d8fd82e0a7b7" -dependencies = [ - "der", - "spki", -] - [[package]] name = "ppv-lite86" version = "0.2.17" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "5b40af805b3121feab8a3c29f04d8ad262fa8e0561883e7653e024ae4479e6de" -[[package]] -name = "proc-macro-crate" -version = "1.3.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7f4c021e1093a56626774e81216a4ce732a735e5bad4868a03f3ed65ca0c3919" -dependencies = [ - "once_cell", - "toml_edit 0.19.15", -] - -[[package]] -name = "proc-macro-crate" -version = "2.0.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b00f26d3400549137f92511a46ac1cd8ce37cb5598a96d382381458b992a5d24" -dependencies = [ - "toml_datetime", - "toml_edit 0.20.2", -] - [[package]] name = "proc-macro2" version = "1.0.78" @@ -473,12 +138,6 @@ dependencies = [ "proc-macro2", ] -[[package]] -name = "radium" -version = "0.7.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "dc33ff2d4973d518d823d61aa239014831e521c75da58e3df4840d3f47749d09" - [[package]] name = "rand" version = "0.8.5" @@ -509,54 +168,6 @@ dependencies = [ "getrandom", ] -[[package]] -name = "rfc6979" -version = "0.4.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f8dd2a808d456c4a54e300a23e9f5a67e122c3024119acbfd73e3bf664491cb2" -dependencies = [ - "hmac", - "subtle", -] - -[[package]] -name = "scale-info" -version = "2.11.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7c453e59a955f81fb62ee5d596b450383d699f152d350e9d23a0db2adb78e4c0" -dependencies = [ - "cfg-if", - "derive_more", - "parity-scale-codec", - "scale-info-derive", -] - -[[package]] -name = "scale-info-derive" -version = "2.11.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "18cf6c6447f813ef19eb450e985bcce6705f9ce7660db221b59093d15c79c4b7" -dependencies = [ - "proc-macro-crate 1.3.1", - "proc-macro2", - "quote", - "syn 1.0.109", -] - -[[package]] -name = "sec1" -version = "0.7.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d3e97a565f76233a6003f9f5c54be1d9c5bdfa3eccfb189469f11ec4901c47dc" -dependencies = [ - "base16ct", - "der", - "generic-array", - "pkcs8", - "subtle", - "zeroize", -] - [[package]] name = "serde" version = "1.0.203" @@ -588,26 +199,6 @@ dependencies = [ "digest", ] -[[package]] -name = "signature" -version = "2.2.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "77549399552de45a898a580c1b41d445bf730df867cc44e6c0233bbc4b8329de" -dependencies = [ - "digest", - "rand_core", -] - -[[package]] -name = "snowbridge-amcl" -version = "1.0.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "460a9ed63cdf03c1b9847e8a12a5f5ba19c4efd5869e4a737e05be25d7c427e5" -dependencies = [ - "parity-scale-codec", - "scale-info", -] - [[package]] name = "sp1-derive" version = "0.1.0" @@ -618,19 +209,13 @@ dependencies = [ ] [[package]] -name = "sp1-precompiles" +name = "sp1-lib" version = "0.1.0" dependencies = [ "anyhow", "bincode", "cfg-if", - "getrandom", - "hex", - "k256", - "num", - "rand", "serde", - "snowbridge-amcl", ] [[package]] @@ -640,31 +225,15 @@ dependencies = [ "bincode", "cfg-if", "getrandom", - "k256", + "lazy_static", "libm", "once_cell", "rand", "serde", "sha2", - "sp1-precompiles", + "sp1-lib", ] -[[package]] -name = "spki" -version = "0.7.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d91ed6c858b01f942cd56b37a94b3e0a1798290327d1236e4d9cf4eaca44d29d" -dependencies = [ - "base64ct", - "der", -] - -[[package]] -name = "subtle" -version = "2.5.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "81cdd64d312baedb58e21336b31bc043b77e01cc99033ce76ef539f78e965ebc" - [[package]] name = "syn" version = "1.0.109" @@ -687,40 +256,6 @@ dependencies = [ "unicode-ident", ] -[[package]] -name = "tap" -version = "1.0.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "55937e1799185b12863d447f42597ed69d9928686b8d88a1df17376a097d8369" - -[[package]] -name = "toml_datetime" -version = "0.6.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7cda73e2f1397b1262d6dfdcef8aafae14d1de7748d66822d3bfeeb6d03e5e4b" - -[[package]] -name = "toml_edit" -version = "0.19.15" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1b5bb770da30e5cbfde35a2d7b9b8a2c4b8ef89548a7a6aeab5c9a576e3e7421" -dependencies = [ - "indexmap", - "toml_datetime", - "winnow", -] - -[[package]] -name = "toml_edit" -version = "0.20.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "396e4d48bbb2b7554c944bde63101b5ae446cff6ec4a24227428f15eb72ef338" -dependencies = [ - "indexmap", - "toml_datetime", - "winnow", -] - [[package]] name = "typenum" version = "1.17.0" @@ -744,27 +279,3 @@ name = "wasi" version = "0.11.0+wasi-snapshot-preview1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "9c8d87e72b64a3b4db28d11ce29237c246188f4f51057d65a7eab63b7987e423" - -[[package]] -name = "winnow" -version = "0.5.40" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f593a95398737aeed53e489c785df13f3618e41dbcd6718c6addbf1395aa6876" -dependencies = [ - "memchr", -] - -[[package]] -name = "wyz" -version = "0.5.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "05f360fc0b24296329c78fda852a1e9ae82de9cf7b27dae4b7f62f118f77b9ed" -dependencies = [ - "tap", -] - -[[package]] -name = "zeroize" -version = "1.7.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "525b4ec142c6b68a2d10f01f7bbf6755599ca3f81ea53b8431b7dd348f5fdb2d" diff --git a/tests/cycle-tracker/Cargo.toml b/tests/cycle-tracker/Cargo.toml index b9c2ebf69d..fb04b2465c 100644 --- a/tests/cycle-tracker/Cargo.toml +++ b/tests/cycle-tracker/Cargo.toml @@ -1,8 +1,9 @@ [workspace] [package] -version = "0.1.0" name = "cycle-tracker-test" +version = "1.0.0-rc.1" edition = "2021" +publish = false [dependencies] sp1-zkvm = { path = "../../zkvm/entrypoint" } diff --git a/tests/cycle-tracker/elf/riscv32im-succinct-zkvm-elf b/tests/cycle-tracker/elf/riscv32im-succinct-zkvm-elf index 6e2531ad0b..cb9be2c075 100755 Binary files a/tests/cycle-tracker/elf/riscv32im-succinct-zkvm-elf and b/tests/cycle-tracker/elf/riscv32im-succinct-zkvm-elf differ diff --git a/tests/ecrecover/Cargo.lock b/tests/ecrecover/Cargo.lock index 373e948bda..6e1140252a 100644 --- a/tests/ecrecover/Cargo.lock +++ b/tests/ecrecover/Cargo.lock @@ -8,12 +8,6 @@ version = "1.0.86" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "b3d1d046238990b9cf5bcde22a3fb3584ee5cf65fb2765f454ed428c7a0063da" -[[package]] -name = "arrayvec" -version = "0.7.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "96d30a06541fbafbc7f82ed10c06164cfbd2c401138f6addd8404629c4b16711" - [[package]] name = "autocfg" version = "1.2.0" @@ -62,12 +56,6 @@ dependencies = [ "generic-array", ] -[[package]] -name = "byte-slice-cast" -version = "1.2.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c3ac9f8b63eca6fd385229b3675f6cc0dc5c8a5c8a54a59d4f52ffd670d87b0c" - [[package]] name = "cfg-if" version = "1.0.0" @@ -121,17 +109,6 @@ dependencies = [ "zeroize", ] -[[package]] -name = "derive_more" -version = "0.99.17" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4fb810d30a7c1953f91334de7244731fc3f3c10d7fe163338a35b9f640960321" -dependencies = [ - "proc-macro2", - "quote", - "syn 1.0.109", -] - [[package]] name = "digest" version = "0.10.7" @@ -188,12 +165,6 @@ dependencies = [ "zeroize", ] -[[package]] -name = "equivalent" -version = "1.0.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5443807d6dff69373d433ab9ef5378ad8df50ca6298caf15de6e52e24aaf54d5" - [[package]] name = "ff" version = "0.13.0" @@ -244,18 +215,6 @@ dependencies = [ "subtle", ] -[[package]] -name = "hashbrown" -version = "0.14.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "290f1a1d9242c78d09ce40a5e87e7554ee637af1351968159f4952f028f75604" - -[[package]] -name = "hex" -version = "0.4.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7f24254aa9a54b5c858eaee2f5bccdb46aaf0e486a595ed5fd8f86ba55232a70" - [[package]] name = "hex-literal" version = "0.4.1" @@ -271,27 +230,6 @@ dependencies = [ "digest", ] -[[package]] -name = "impl-trait-for-tuples" -version = "0.2.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "11d7a9f6330b71fea57921c9b61c47ee6e84f72d394754eff6163ae67e7395eb" -dependencies = [ - "proc-macro2", - "quote", - "syn 1.0.109", -] - -[[package]] -name = "indexmap" -version = "2.2.6" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "168fb715dda47215e360912c096649d23d58bf392ac62f73919e831745e40f26" -dependencies = [ - "equivalent", - "hashbrown", -] - [[package]] name = "k256" version = "0.13.3" @@ -306,6 +244,12 @@ dependencies = [ "signature", ] +[[package]] +name = "lazy_static" +version = "1.5.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "bbd2bcb4c963f2ddae06a2efc7e9f3591312473c50c6685e1f298068316e66fe" + [[package]] name = "libc" version = "0.2.155" @@ -318,19 +262,12 @@ version = "0.2.8" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "4ec2a862134d2a7d32d7983ddcdd1c4923530833c9f2ea1a44fc5fa473989058" -[[package]] -name = "memchr" -version = "2.7.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6c8640c5d730cb13ebd907d8d04b52f55ac9a2eec55b440c8892f40d56c76c1d" - [[package]] name = "num" version = "0.4.3" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "35bd024e8b2ff75562e5f34e7f4905839deb4b22955ef5e73d2fea1b9813cb23" dependencies = [ - "num-bigint", "num-complex", "num-integer", "num-iter", @@ -338,16 +275,6 @@ dependencies = [ "num-traits", ] -[[package]] -name = "num-bigint" -version = "0.4.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c165a9ab64cf766f73521c0dd2cfdff64f488b8f0b3e621face3462d3db536d7" -dependencies = [ - "num-integer", - "num-traits", -] - [[package]] name = "num-complex" version = "0.4.6" @@ -383,7 +310,6 @@ version = "0.4.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "f83d14da390562dca69fc84082e73e548e1ad308d24accdedd2720017cb37824" dependencies = [ - "num-bigint", "num-integer", "num-traits", ] @@ -403,30 +329,6 @@ version = "1.19.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "3fdb12b2476b595f9358c5161aa467c2438859caa136dec86c26fdd2efe17b92" -[[package]] -name = "parity-scale-codec" -version = "3.6.9" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "881331e34fa842a2fb61cc2db9643a8fedc615e47cfcc52597d1af0db9a7e8fe" -dependencies = [ - "arrayvec", - "byte-slice-cast", - "impl-trait-for-tuples", - "parity-scale-codec-derive", -] - -[[package]] -name = "parity-scale-codec-derive" -version = "3.6.9" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "be30eaf4b0a9fba5336683b38de57bb86d179a35862ba6bfcf57625d006bde5b" -dependencies = [ - "proc-macro-crate 2.0.2", - "proc-macro2", - "quote", - "syn 1.0.109", -] - [[package]] name = "pkcs8" version = "0.10.2" @@ -443,26 +345,6 @@ version = "0.2.17" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "5b40af805b3121feab8a3c29f04d8ad262fa8e0561883e7653e024ae4479e6de" -[[package]] -name = "proc-macro-crate" -version = "1.3.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7f4c021e1093a56626774e81216a4ce732a735e5bad4868a03f3ed65ca0c3919" -dependencies = [ - "once_cell", - "toml_edit 0.19.15", -] - -[[package]] -name = "proc-macro-crate" -version = "2.0.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b00f26d3400549137f92511a46ac1cd8ce37cb5598a96d382381458b992a5d24" -dependencies = [ - "toml_datetime", - "toml_edit 0.20.2", -] - [[package]] name = "proc-macro2" version = "1.0.79" @@ -527,30 +409,6 @@ dependencies = [ "subtle", ] -[[package]] -name = "scale-info" -version = "2.11.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7c453e59a955f81fb62ee5d596b450383d699f152d350e9d23a0db2adb78e4c0" -dependencies = [ - "cfg-if", - "derive_more", - "parity-scale-codec", - "scale-info-derive", -] - -[[package]] -name = "scale-info-derive" -version = "2.11.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "18cf6c6447f813ef19eb450e985bcce6705f9ce7660db221b59093d15c79c4b7" -dependencies = [ - "proc-macro-crate 1.3.1", - "proc-macro2", - "quote", - "syn 1.0.109", -] - [[package]] name = "sec1" version = "0.7.3" @@ -582,7 +440,7 @@ checksum = "500cbc0ebeb6f46627f50f3f5811ccf6bf00643be300b4c3eabc0ef55dc5b5ba" dependencies = [ "proc-macro2", "quote", - "syn 2.0.55", + "syn", ] [[package]] @@ -607,29 +465,14 @@ dependencies = [ ] [[package]] -name = "snowbridge-amcl" -version = "1.0.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "460a9ed63cdf03c1b9847e8a12a5f5ba19c4efd5869e4a737e05be25d7c427e5" -dependencies = [ - "parity-scale-codec", - "scale-info", -] - -[[package]] -name = "sp1-precompiles" +name = "sp1-lib" version = "0.1.0" dependencies = [ "anyhow", "bincode", "cfg-if", - "getrandom", - "hex", "k256", - "num", - "rand", "serde", - "snowbridge-amcl", ] [[package]] @@ -639,13 +482,13 @@ dependencies = [ "bincode", "cfg-if", "getrandom", - "k256", + "lazy_static", "libm", "once_cell", "rand", "serde", "sha2", - "sp1-precompiles", + "sp1-lib", ] [[package]] @@ -664,17 +507,6 @@ version = "2.5.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "81cdd64d312baedb58e21336b31bc043b77e01cc99033ce76ef539f78e965ebc" -[[package]] -name = "syn" -version = "1.0.109" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "72b64191b275b66ffe2469e8af2c1cfe3bafa67b529ead792a6d0160888b4237" -dependencies = [ - "proc-macro2", - "quote", - "unicode-ident", -] - [[package]] name = "syn" version = "2.0.55" @@ -692,34 +524,6 @@ version = "1.0.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "55937e1799185b12863d447f42597ed69d9928686b8d88a1df17376a097d8369" -[[package]] -name = "toml_datetime" -version = "0.6.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7cda73e2f1397b1262d6dfdcef8aafae14d1de7748d66822d3bfeeb6d03e5e4b" - -[[package]] -name = "toml_edit" -version = "0.19.15" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1b5bb770da30e5cbfde35a2d7b9b8a2c4b8ef89548a7a6aeab5c9a576e3e7421" -dependencies = [ - "indexmap", - "toml_datetime", - "winnow", -] - -[[package]] -name = "toml_edit" -version = "0.20.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "396e4d48bbb2b7554c944bde63101b5ae446cff6ec4a24227428f15eb72ef338" -dependencies = [ - "indexmap", - "toml_datetime", - "winnow", -] - [[package]] name = "typenum" version = "1.17.0" @@ -744,15 +548,6 @@ version = "0.11.0+wasi-snapshot-preview1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "9c8d87e72b64a3b4db28d11ce29237c246188f4f51057d65a7eab63b7987e423" -[[package]] -name = "winnow" -version = "0.5.40" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f593a95398737aeed53e489c785df13f3618e41dbcd6718c6addbf1395aa6876" -dependencies = [ - "memchr", -] - [[package]] name = "wyz" version = "0.5.1" diff --git a/tests/ecrecover/Cargo.toml b/tests/ecrecover/Cargo.toml index c3384dde07..1c74f8af73 100644 --- a/tests/ecrecover/Cargo.toml +++ b/tests/ecrecover/Cargo.toml @@ -1,11 +1,12 @@ [workspace] [package] -version = "0.1.0" name = "ecrecover-test" +version = "1.0.0-rc.1" edition = "2021" +publish = false [dependencies] -sp1-zkvm = { path = "../../zkvm/entrypoint" } +sp1-zkvm = { path = "../../zkvm/entrypoint", features = ["secp256k1"] } hex-literal = "0.4.1" num = { version = "0.4.1", default-features = false } k256 = { version = "0.13.3", features = ["ecdsa"] } diff --git a/tests/ecrecover/elf/riscv32im-succinct-zkvm-elf b/tests/ecrecover/elf/riscv32im-succinct-zkvm-elf index 912b0a3e2e..8d82912412 100755 Binary files a/tests/ecrecover/elf/riscv32im-succinct-zkvm-elf and b/tests/ecrecover/elf/riscv32im-succinct-zkvm-elf differ diff --git a/tests/ecrecover/src/main.rs b/tests/ecrecover/src/main.rs index 4f2a0b5782..0de8192a95 100644 --- a/tests/ecrecover/src/main.rs +++ b/tests/ecrecover/src/main.rs @@ -2,8 +2,8 @@ sp1_zkvm::entrypoint!(main); use hex_literal::hex; -use sp1_zkvm::precompiles::io; -use sp1_zkvm::precompiles::secp256k1::ecrecover; +use sp1_zkvm::lib::io; +use sp1_zkvm::lib::secp256k1::ecrecover; pub fn main() { // recovery param: 1 @@ -12,7 +12,9 @@ pub fn main() { // pubkey: 044a071e8a6e10aada2b8cf39fa3b5fb3400b04e99ea8ae64ceea1a977dbeaf5d5f8c8fbd10b71ab14cd561f7df8eb6da50f8a8d81ba564342244d26d1d4211595 let msg_hash = hex!("5ae8317d34d1e595e3fa7247db80c0af4320cce1116de187f8f7e2e099c0d8d0"); - let sig = hex!("45c0b7f8c09a9e1f1cea0c25785594427b6bf8f9f878a8af0b1abbb48e16d0920d8becd0c220f67c51217eecfd7184ef0732481c843857e6bc7fc095c4f6b78801"); + let sig = hex!( + "45c0b7f8c09a9e1f1cea0c25785594427b6bf8f9f878a8af0b1abbb48e16d0920d8becd0c220f67c51217eecfd7184ef0732481c843857e6bc7fc095c4f6b78801" + ); let pubkey = ecrecover(&sig, &msg_hash).unwrap(); io::commit_slice(&pubkey); diff --git a/tests/ed-add/Cargo.lock b/tests/ed-add/Cargo.lock index 0505b59e04..4204ecedbe 100644 --- a/tests/ed-add/Cargo.lock +++ b/tests/ed-add/Cargo.lock @@ -8,30 +8,12 @@ version = "1.0.86" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "b3d1d046238990b9cf5bcde22a3fb3584ee5cf65fb2765f454ed428c7a0063da" -[[package]] -name = "arrayvec" -version = "0.7.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "96d30a06541fbafbc7f82ed10c06164cfbd2c401138f6addd8404629c4b16711" - [[package]] name = "autocfg" version = "1.2.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "f1fdabc7756949593fe60f30ec81974b613357de856987752631dea1e3394c80" -[[package]] -name = "base16ct" -version = "0.2.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4c7f02d4ea65f2c1853089ffd8d2787bdbc63de2f0d29dedbcf8ccdfa0ccd4cf" - -[[package]] -name = "base64ct" -version = "1.6.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8c3c1a368f70d6cf7302d78f8f7093da241fb8e8807c05cc9e51a125895a6d5b" - [[package]] name = "bincode" version = "1.3.3" @@ -41,18 +23,6 @@ dependencies = [ "serde", ] -[[package]] -name = "bitvec" -version = "1.0.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1bc2832c24239b0141d5674bb9174f9d68a8b5b3f2753311927c172ca46f7e9c" -dependencies = [ - "funty", - "radium", - "tap", - "wyz", -] - [[package]] name = "block-buffer" version = "0.10.4" @@ -62,24 +32,12 @@ dependencies = [ "generic-array", ] -[[package]] -name = "byte-slice-cast" -version = "1.2.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c3ac9f8b63eca6fd385229b3675f6cc0dc5c8a5c8a54a59d4f52ffd670d87b0c" - [[package]] name = "cfg-if" version = "1.0.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "baf1de4339761588bc0619e3cbc0120ee582ebb74b53b4efbf79117bd2da40fd" -[[package]] -name = "const-oid" -version = "0.9.6" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c2459377285ad874054d797f3ccebf984978aa39129f6eafde5cdc8315b612f8" - [[package]] name = "cpufeatures" version = "0.2.12" @@ -89,18 +47,6 @@ dependencies = [ "libc", ] -[[package]] -name = "crypto-bigint" -version = "0.5.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0dc92fb57ca44df6db8059111ab3af99a63d5d0f8375d9972e319a379c6bab76" -dependencies = [ - "generic-array", - "rand_core", - "subtle", - "zeroize", -] - [[package]] name = "crypto-common" version = "0.1.6" @@ -111,27 +57,6 @@ dependencies = [ "typenum", ] -[[package]] -name = "der" -version = "0.7.8" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "fffa369a668c8af7dbf8b5e56c9f744fbd399949ed171606040001947de40b1c" -dependencies = [ - "const-oid", - "zeroize", -] - -[[package]] -name = "derive_more" -version = "0.99.17" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4fb810d30a7c1953f91334de7244731fc3f3c10d7fe163338a35b9f640960321" -dependencies = [ - "proc-macro2", - "quote", - "syn 1.0.109", -] - [[package]] name = "digest" version = "0.10.7" @@ -139,23 +64,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "9ed9a281f7bc9b7576e61468ba615a66a5c8cfdff42420a70aa82701a3b1e292" dependencies = [ "block-buffer", - "const-oid", "crypto-common", - "subtle", -] - -[[package]] -name = "ecdsa" -version = "0.16.9" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ee27f32b5c5292967d2d4a9d7f1e0b0aed2c15daded5a60300e4abb9d8020bca" -dependencies = [ - "der", - "digest", - "elliptic-curve", - "rfc6979", - "signature", - "spki", ] [[package]] @@ -167,49 +76,6 @@ dependencies = [ "sp1-zkvm", ] -[[package]] -name = "elliptic-curve" -version = "0.13.8" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b5e6043086bf7973472e0c7dff2142ea0b680d30e18d9cc40f267efbf222bd47" -dependencies = [ - "base16ct", - "crypto-bigint", - "digest", - "ff", - "generic-array", - "group", - "pkcs8", - "rand_core", - "sec1", - "subtle", - "tap", - "zeroize", -] - -[[package]] -name = "equivalent" -version = "1.0.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5443807d6dff69373d433ab9ef5378ad8df50ca6298caf15de6e52e24aaf54d5" - -[[package]] -name = "ff" -version = "0.13.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ded41244b729663b1e574f1b4fb731469f69f79c17667b5d776b16cda0479449" -dependencies = [ - "bitvec", - "rand_core", - "subtle", -] - -[[package]] -name = "funty" -version = "2.0.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e6d5a32815ae3f33302d95fdcb2ce17862f8c65363dcfd29360480ba1001fc9c" - [[package]] name = "generic-array" version = "0.14.7" @@ -218,7 +84,6 @@ checksum = "85649ca51fd72272d7821adaf274ad91c288277713d9c18820d8499a7ff69e9a" dependencies = [ "typenum", "version_check", - "zeroize", ] [[package]] @@ -232,29 +97,6 @@ dependencies = [ "wasi", ] -[[package]] -name = "group" -version = "0.13.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f0f9ef7462f7c099f518d754361858f86d8a07af53ba9af0fe635bbccb151a63" -dependencies = [ - "ff", - "rand_core", - "subtle", -] - -[[package]] -name = "hashbrown" -version = "0.14.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "290f1a1d9242c78d09ce40a5e87e7554ee637af1351968159f4952f028f75604" - -[[package]] -name = "hex" -version = "0.4.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7f24254aa9a54b5c858eaee2f5bccdb46aaf0e486a595ed5fd8f86ba55232a70" - [[package]] name = "hex-literal" version = "0.4.1" @@ -262,48 +104,10 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "6fe2267d4ed49bc07b63801559be28c718ea06c4738b7a03c94df7386d2cde46" [[package]] -name = "hmac" -version = "0.12.1" +name = "lazy_static" +version = "1.5.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6c49c37c09c17a53d937dfbb742eb3a961d65a994e6bcdcf37e7399d0cc8ab5e" -dependencies = [ - "digest", -] - -[[package]] -name = "impl-trait-for-tuples" -version = "0.2.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "11d7a9f6330b71fea57921c9b61c47ee6e84f72d394754eff6163ae67e7395eb" -dependencies = [ - "proc-macro2", - "quote", - "syn 1.0.109", -] - -[[package]] -name = "indexmap" -version = "2.2.6" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "168fb715dda47215e360912c096649d23d58bf392ac62f73919e831745e40f26" -dependencies = [ - "equivalent", - "hashbrown", -] - -[[package]] -name = "k256" -version = "0.13.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "956ff9b67e26e1a6a866cb758f12c6f8746208489e3e4a4b5580802f2f0a587b" -dependencies = [ - "cfg-if", - "ecdsa", - "elliptic-curve", - "once_cell", - "sha2", - "signature", -] +checksum = "bbd2bcb4c963f2ddae06a2efc7e9f3591312473c50c6685e1f298068316e66fe" [[package]] name = "libc" @@ -317,19 +121,12 @@ version = "0.2.8" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "4ec2a862134d2a7d32d7983ddcdd1c4923530833c9f2ea1a44fc5fa473989058" -[[package]] -name = "memchr" -version = "2.7.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6c8640c5d730cb13ebd907d8d04b52f55ac9a2eec55b440c8892f40d56c76c1d" - [[package]] name = "num" version = "0.4.3" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "35bd024e8b2ff75562e5f34e7f4905839deb4b22955ef5e73d2fea1b9813cb23" dependencies = [ - "num-bigint", "num-complex", "num-integer", "num-iter", @@ -337,16 +134,6 @@ dependencies = [ "num-traits", ] -[[package]] -name = "num-bigint" -version = "0.4.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c165a9ab64cf766f73521c0dd2cfdff64f488b8f0b3e621face3462d3db536d7" -dependencies = [ - "num-integer", - "num-traits", -] - [[package]] name = "num-complex" version = "0.4.6" @@ -382,7 +169,6 @@ version = "0.4.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "f83d14da390562dca69fc84082e73e548e1ad308d24accdedd2720017cb37824" dependencies = [ - "num-bigint", "num-integer", "num-traits", ] @@ -402,66 +188,12 @@ version = "1.19.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "3fdb12b2476b595f9358c5161aa467c2438859caa136dec86c26fdd2efe17b92" -[[package]] -name = "parity-scale-codec" -version = "3.6.9" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "881331e34fa842a2fb61cc2db9643a8fedc615e47cfcc52597d1af0db9a7e8fe" -dependencies = [ - "arrayvec", - "byte-slice-cast", - "impl-trait-for-tuples", - "parity-scale-codec-derive", -] - -[[package]] -name = "parity-scale-codec-derive" -version = "3.6.9" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "be30eaf4b0a9fba5336683b38de57bb86d179a35862ba6bfcf57625d006bde5b" -dependencies = [ - "proc-macro-crate 2.0.2", - "proc-macro2", - "quote", - "syn 1.0.109", -] - -[[package]] -name = "pkcs8" -version = "0.10.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f950b2377845cebe5cf8b5165cb3cc1a5e0fa5cfa3e1f7f55707d8fd82e0a7b7" -dependencies = [ - "der", - "spki", -] - [[package]] name = "ppv-lite86" version = "0.2.17" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "5b40af805b3121feab8a3c29f04d8ad262fa8e0561883e7653e024ae4479e6de" -[[package]] -name = "proc-macro-crate" -version = "1.3.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7f4c021e1093a56626774e81216a4ce732a735e5bad4868a03f3ed65ca0c3919" -dependencies = [ - "once_cell", - "toml_edit 0.19.15", -] - -[[package]] -name = "proc-macro-crate" -version = "2.0.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b00f26d3400549137f92511a46ac1cd8ce37cb5598a96d382381458b992a5d24" -dependencies = [ - "toml_datetime", - "toml_edit 0.20.2", -] - [[package]] name = "proc-macro2" version = "1.0.79" @@ -480,12 +212,6 @@ dependencies = [ "proc-macro2", ] -[[package]] -name = "radium" -version = "0.7.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "dc33ff2d4973d518d823d61aa239014831e521c75da58e3df4840d3f47749d09" - [[package]] name = "rand" version = "0.8.5" @@ -516,54 +242,6 @@ dependencies = [ "getrandom", ] -[[package]] -name = "rfc6979" -version = "0.4.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f8dd2a808d456c4a54e300a23e9f5a67e122c3024119acbfd73e3bf664491cb2" -dependencies = [ - "hmac", - "subtle", -] - -[[package]] -name = "scale-info" -version = "2.11.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7c453e59a955f81fb62ee5d596b450383d699f152d350e9d23a0db2adb78e4c0" -dependencies = [ - "cfg-if", - "derive_more", - "parity-scale-codec", - "scale-info-derive", -] - -[[package]] -name = "scale-info-derive" -version = "2.11.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "18cf6c6447f813ef19eb450e985bcce6705f9ce7660db221b59093d15c79c4b7" -dependencies = [ - "proc-macro-crate 1.3.1", - "proc-macro2", - "quote", - "syn 1.0.109", -] - -[[package]] -name = "sec1" -version = "0.7.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d3e97a565f76233a6003f9f5c54be1d9c5bdfa3eccfb189469f11ec4901c47dc" -dependencies = [ - "base16ct", - "der", - "generic-array", - "pkcs8", - "subtle", - "zeroize", -] - [[package]] name = "serde" version = "1.0.203" @@ -581,7 +259,7 @@ checksum = "500cbc0ebeb6f46627f50f3f5811ccf6bf00643be300b4c3eabc0ef55dc5b5ba" dependencies = [ "proc-macro2", "quote", - "syn 2.0.55", + "syn", ] [[package]] @@ -596,39 +274,13 @@ dependencies = [ ] [[package]] -name = "signature" -version = "2.2.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "77549399552de45a898a580c1b41d445bf730df867cc44e6c0233bbc4b8329de" -dependencies = [ - "digest", - "rand_core", -] - -[[package]] -name = "snowbridge-amcl" -version = "1.0.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "460a9ed63cdf03c1b9847e8a12a5f5ba19c4efd5869e4a737e05be25d7c427e5" -dependencies = [ - "parity-scale-codec", - "scale-info", -] - -[[package]] -name = "sp1-precompiles" +name = "sp1-lib" version = "0.1.0" dependencies = [ "anyhow", "bincode", "cfg-if", - "getrandom", - "hex", - "k256", - "num", - "rand", "serde", - "snowbridge-amcl", ] [[package]] @@ -638,40 +290,13 @@ dependencies = [ "bincode", "cfg-if", "getrandom", - "k256", + "lazy_static", "libm", "once_cell", "rand", "serde", "sha2", - "sp1-precompiles", -] - -[[package]] -name = "spki" -version = "0.7.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d91ed6c858b01f942cd56b37a94b3e0a1798290327d1236e4d9cf4eaca44d29d" -dependencies = [ - "base64ct", - "der", -] - -[[package]] -name = "subtle" -version = "2.5.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "81cdd64d312baedb58e21336b31bc043b77e01cc99033ce76ef539f78e965ebc" - -[[package]] -name = "syn" -version = "1.0.109" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "72b64191b275b66ffe2469e8af2c1cfe3bafa67b529ead792a6d0160888b4237" -dependencies = [ - "proc-macro2", - "quote", - "unicode-ident", + "sp1-lib", ] [[package]] @@ -685,40 +310,6 @@ dependencies = [ "unicode-ident", ] -[[package]] -name = "tap" -version = "1.0.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "55937e1799185b12863d447f42597ed69d9928686b8d88a1df17376a097d8369" - -[[package]] -name = "toml_datetime" -version = "0.6.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7cda73e2f1397b1262d6dfdcef8aafae14d1de7748d66822d3bfeeb6d03e5e4b" - -[[package]] -name = "toml_edit" -version = "0.19.15" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1b5bb770da30e5cbfde35a2d7b9b8a2c4b8ef89548a7a6aeab5c9a576e3e7421" -dependencies = [ - "indexmap", - "toml_datetime", - "winnow", -] - -[[package]] -name = "toml_edit" -version = "0.20.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "396e4d48bbb2b7554c944bde63101b5ae446cff6ec4a24227428f15eb72ef338" -dependencies = [ - "indexmap", - "toml_datetime", - "winnow", -] - [[package]] name = "typenum" version = "1.17.0" @@ -742,27 +333,3 @@ name = "wasi" version = "0.11.0+wasi-snapshot-preview1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "9c8d87e72b64a3b4db28d11ce29237c246188f4f51057d65a7eab63b7987e423" - -[[package]] -name = "winnow" -version = "0.5.40" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f593a95398737aeed53e489c785df13f3618e41dbcd6718c6addbf1395aa6876" -dependencies = [ - "memchr", -] - -[[package]] -name = "wyz" -version = "0.5.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "05f360fc0b24296329c78fda852a1e9ae82de9cf7b27dae4b7f62f118f77b9ed" -dependencies = [ - "tap", -] - -[[package]] -name = "zeroize" -version = "1.7.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "525b4ec142c6b68a2d10f01f7bbf6755599ca3f81ea53b8431b7dd348f5fdb2d" diff --git a/tests/ed-add/Cargo.toml b/tests/ed-add/Cargo.toml index 2b4b819bfd..b8323c2e8f 100644 --- a/tests/ed-add/Cargo.toml +++ b/tests/ed-add/Cargo.toml @@ -1,8 +1,9 @@ [workspace] [package] name = "ed-add-test" -version = "0.1.0" +version = "1.0.0-rc.1" edition = "2021" +publish = false [dependencies] sp1-zkvm = { path = "../../zkvm/entrypoint" } diff --git a/tests/ed-add/elf/riscv32im-succinct-zkvm-elf b/tests/ed-add/elf/riscv32im-succinct-zkvm-elf index 5916c8a800..e8bcfa625a 100755 Binary files a/tests/ed-add/elf/riscv32im-succinct-zkvm-elf and b/tests/ed-add/elf/riscv32im-succinct-zkvm-elf differ diff --git a/tests/ed-add/src/main.rs b/tests/ed-add/src/main.rs index 3deafa0c76..2c98ca702a 100644 --- a/tests/ed-add/src/main.rs +++ b/tests/ed-add/src/main.rs @@ -1,9 +1,8 @@ #![no_main] -sp1_zkvm::entrypoint!(main); -extern "C" { - fn syscall_ed_add(p: *mut u32, q: *const u32); -} +use sp1_zkvm::syscalls::syscall_ed_add; + +sp1_zkvm::entrypoint!(main); pub fn main() { for _ in 0..4 { @@ -25,9 +24,7 @@ pub fn main() { 167, 131, 199, 47, 82, 134, 53, 62, ]; - unsafe { - syscall_ed_add(a.as_mut_ptr() as *mut u32, b.as_ptr() as *const u32); - } + syscall_ed_add(a.as_mut_ptr() as *mut u32, b.as_ptr() as *mut u32); // 36213413123116753589144482590359479011148956763279542162278577842046663495729 // 17093345531692682197799066694073110060588941459686871373458223451938707761683 diff --git a/tests/ed-decompress/Cargo.lock b/tests/ed-decompress/Cargo.lock index b7a6913b2e..4f8ba9dedd 100644 --- a/tests/ed-decompress/Cargo.lock +++ b/tests/ed-decompress/Cargo.lock @@ -8,30 +8,6 @@ version = "1.0.86" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "b3d1d046238990b9cf5bcde22a3fb3584ee5cf65fb2765f454ed428c7a0063da" -[[package]] -name = "arrayvec" -version = "0.7.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "96d30a06541fbafbc7f82ed10c06164cfbd2c401138f6addd8404629c4b16711" - -[[package]] -name = "autocfg" -version = "1.2.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f1fdabc7756949593fe60f30ec81974b613357de856987752631dea1e3394c80" - -[[package]] -name = "base16ct" -version = "0.2.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4c7f02d4ea65f2c1853089ffd8d2787bdbc63de2f0d29dedbcf8ccdfa0ccd4cf" - -[[package]] -name = "base64ct" -version = "1.6.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8c3c1a368f70d6cf7302d78f8f7093da241fb8e8807c05cc9e51a125895a6d5b" - [[package]] name = "bincode" version = "1.3.3" @@ -41,18 +17,6 @@ dependencies = [ "serde", ] -[[package]] -name = "bitvec" -version = "1.0.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1bc2832c24239b0141d5674bb9174f9d68a8b5b3f2753311927c172ca46f7e9c" -dependencies = [ - "funty", - "radium", - "tap", - "wyz", -] - [[package]] name = "block-buffer" version = "0.10.4" @@ -62,24 +26,12 @@ dependencies = [ "generic-array", ] -[[package]] -name = "byte-slice-cast" -version = "1.2.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c3ac9f8b63eca6fd385229b3675f6cc0dc5c8a5c8a54a59d4f52ffd670d87b0c" - [[package]] name = "cfg-if" version = "1.0.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "baf1de4339761588bc0619e3cbc0120ee582ebb74b53b4efbf79117bd2da40fd" -[[package]] -name = "const-oid" -version = "0.9.6" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c2459377285ad874054d797f3ccebf984978aa39129f6eafde5cdc8315b612f8" - [[package]] name = "cpufeatures" version = "0.2.12" @@ -89,18 +41,6 @@ dependencies = [ "libc", ] -[[package]] -name = "crypto-bigint" -version = "0.5.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0dc92fb57ca44df6db8059111ab3af99a63d5d0f8375d9972e319a379c6bab76" -dependencies = [ - "generic-array", - "rand_core", - "subtle", - "zeroize", -] - [[package]] name = "crypto-common" version = "0.1.6" @@ -111,27 +51,6 @@ dependencies = [ "typenum", ] -[[package]] -name = "der" -version = "0.7.8" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "fffa369a668c8af7dbf8b5e56c9f744fbd399949ed171606040001947de40b1c" -dependencies = [ - "const-oid", - "zeroize", -] - -[[package]] -name = "derive_more" -version = "0.99.17" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4fb810d30a7c1953f91334de7244731fc3f3c10d7fe163338a35b9f640960321" -dependencies = [ - "proc-macro2", - "quote", - "syn 1.0.109", -] - [[package]] name = "digest" version = "0.10.7" @@ -139,23 +58,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "9ed9a281f7bc9b7576e61468ba615a66a5c8cfdff42420a70aa82701a3b1e292" dependencies = [ "block-buffer", - "const-oid", "crypto-common", - "subtle", -] - -[[package]] -name = "ecdsa" -version = "0.16.9" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ee27f32b5c5292967d2d4a9d7f1e0b0aed2c15daded5a60300e4abb9d8020bca" -dependencies = [ - "der", - "digest", - "elliptic-curve", - "rfc6979", - "signature", - "spki", ] [[package]] @@ -166,49 +69,6 @@ dependencies = [ "sp1-zkvm", ] -[[package]] -name = "elliptic-curve" -version = "0.13.8" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b5e6043086bf7973472e0c7dff2142ea0b680d30e18d9cc40f267efbf222bd47" -dependencies = [ - "base16ct", - "crypto-bigint", - "digest", - "ff", - "generic-array", - "group", - "pkcs8", - "rand_core", - "sec1", - "subtle", - "tap", - "zeroize", -] - -[[package]] -name = "equivalent" -version = "1.0.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5443807d6dff69373d433ab9ef5378ad8df50ca6298caf15de6e52e24aaf54d5" - -[[package]] -name = "ff" -version = "0.13.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ded41244b729663b1e574f1b4fb731469f69f79c17667b5d776b16cda0479449" -dependencies = [ - "bitvec", - "rand_core", - "subtle", -] - -[[package]] -name = "funty" -version = "2.0.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e6d5a32815ae3f33302d95fdcb2ce17862f8c65363dcfd29360480ba1001fc9c" - [[package]] name = "generic-array" version = "0.14.7" @@ -217,7 +77,6 @@ checksum = "85649ca51fd72272d7821adaf274ad91c288277713d9c18820d8499a7ff69e9a" dependencies = [ "typenum", "version_check", - "zeroize", ] [[package]] @@ -231,29 +90,6 @@ dependencies = [ "wasi", ] -[[package]] -name = "group" -version = "0.13.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f0f9ef7462f7c099f518d754361858f86d8a07af53ba9af0fe635bbccb151a63" -dependencies = [ - "ff", - "rand_core", - "subtle", -] - -[[package]] -name = "hashbrown" -version = "0.14.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "290f1a1d9242c78d09ce40a5e87e7554ee637af1351968159f4952f028f75604" - -[[package]] -name = "hex" -version = "0.4.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7f24254aa9a54b5c858eaee2f5bccdb46aaf0e486a595ed5fd8f86ba55232a70" - [[package]] name = "hex-literal" version = "0.4.1" @@ -261,48 +97,10 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "6fe2267d4ed49bc07b63801559be28c718ea06c4738b7a03c94df7386d2cde46" [[package]] -name = "hmac" -version = "0.12.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6c49c37c09c17a53d937dfbb742eb3a961d65a994e6bcdcf37e7399d0cc8ab5e" -dependencies = [ - "digest", -] - -[[package]] -name = "impl-trait-for-tuples" -version = "0.2.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "11d7a9f6330b71fea57921c9b61c47ee6e84f72d394754eff6163ae67e7395eb" -dependencies = [ - "proc-macro2", - "quote", - "syn 1.0.109", -] - -[[package]] -name = "indexmap" -version = "2.2.6" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "168fb715dda47215e360912c096649d23d58bf392ac62f73919e831745e40f26" -dependencies = [ - "equivalent", - "hashbrown", -] - -[[package]] -name = "k256" -version = "0.13.3" +name = "lazy_static" +version = "1.5.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "956ff9b67e26e1a6a866cb758f12c6f8746208489e3e4a4b5580802f2f0a587b" -dependencies = [ - "cfg-if", - "ecdsa", - "elliptic-curve", - "once_cell", - "sha2", - "signature", -] +checksum = "bbd2bcb4c963f2ddae06a2efc7e9f3591312473c50c6685e1f298068316e66fe" [[package]] name = "libc" @@ -316,151 +114,18 @@ version = "0.2.8" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "4ec2a862134d2a7d32d7983ddcdd1c4923530833c9f2ea1a44fc5fa473989058" -[[package]] -name = "memchr" -version = "2.7.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6c8640c5d730cb13ebd907d8d04b52f55ac9a2eec55b440c8892f40d56c76c1d" - -[[package]] -name = "num" -version = "0.4.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "35bd024e8b2ff75562e5f34e7f4905839deb4b22955ef5e73d2fea1b9813cb23" -dependencies = [ - "num-bigint", - "num-complex", - "num-integer", - "num-iter", - "num-rational", - "num-traits", -] - -[[package]] -name = "num-bigint" -version = "0.4.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c165a9ab64cf766f73521c0dd2cfdff64f488b8f0b3e621face3462d3db536d7" -dependencies = [ - "num-integer", - "num-traits", -] - -[[package]] -name = "num-complex" -version = "0.4.6" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "73f88a1307638156682bada9d7604135552957b7818057dcef22705b4d509495" -dependencies = [ - "num-traits", -] - -[[package]] -name = "num-integer" -version = "0.1.46" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7969661fd2958a5cb096e56c8e1ad0444ac2bbcd0061bd28660485a44879858f" -dependencies = [ - "num-traits", -] - -[[package]] -name = "num-iter" -version = "0.1.45" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1429034a0490724d0075ebb2bc9e875d6503c3cf69e235a8941aa757d83ef5bf" -dependencies = [ - "autocfg", - "num-integer", - "num-traits", -] - -[[package]] -name = "num-rational" -version = "0.4.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f83d14da390562dca69fc84082e73e548e1ad308d24accdedd2720017cb37824" -dependencies = [ - "num-bigint", - "num-integer", - "num-traits", -] - -[[package]] -name = "num-traits" -version = "0.2.19" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "071dfc062690e90b734c0b2273ce72ad0ffa95f0c74596bc250dcfd960262841" -dependencies = [ - "autocfg", -] - [[package]] name = "once_cell" version = "1.19.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "3fdb12b2476b595f9358c5161aa467c2438859caa136dec86c26fdd2efe17b92" -[[package]] -name = "parity-scale-codec" -version = "3.6.9" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "881331e34fa842a2fb61cc2db9643a8fedc615e47cfcc52597d1af0db9a7e8fe" -dependencies = [ - "arrayvec", - "byte-slice-cast", - "impl-trait-for-tuples", - "parity-scale-codec-derive", -] - -[[package]] -name = "parity-scale-codec-derive" -version = "3.6.9" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "be30eaf4b0a9fba5336683b38de57bb86d179a35862ba6bfcf57625d006bde5b" -dependencies = [ - "proc-macro-crate 2.0.2", - "proc-macro2", - "quote", - "syn 1.0.109", -] - -[[package]] -name = "pkcs8" -version = "0.10.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f950b2377845cebe5cf8b5165cb3cc1a5e0fa5cfa3e1f7f55707d8fd82e0a7b7" -dependencies = [ - "der", - "spki", -] - [[package]] name = "ppv-lite86" version = "0.2.17" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "5b40af805b3121feab8a3c29f04d8ad262fa8e0561883e7653e024ae4479e6de" -[[package]] -name = "proc-macro-crate" -version = "1.3.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7f4c021e1093a56626774e81216a4ce732a735e5bad4868a03f3ed65ca0c3919" -dependencies = [ - "once_cell", - "toml_edit 0.19.15", -] - -[[package]] -name = "proc-macro-crate" -version = "2.0.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b00f26d3400549137f92511a46ac1cd8ce37cb5598a96d382381458b992a5d24" -dependencies = [ - "toml_datetime", - "toml_edit 0.20.2", -] - [[package]] name = "proc-macro2" version = "1.0.78" @@ -479,12 +144,6 @@ dependencies = [ "proc-macro2", ] -[[package]] -name = "radium" -version = "0.7.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "dc33ff2d4973d518d823d61aa239014831e521c75da58e3df4840d3f47749d09" - [[package]] name = "rand" version = "0.8.5" @@ -515,54 +174,6 @@ dependencies = [ "getrandom", ] -[[package]] -name = "rfc6979" -version = "0.4.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f8dd2a808d456c4a54e300a23e9f5a67e122c3024119acbfd73e3bf664491cb2" -dependencies = [ - "hmac", - "subtle", -] - -[[package]] -name = "scale-info" -version = "2.11.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7c453e59a955f81fb62ee5d596b450383d699f152d350e9d23a0db2adb78e4c0" -dependencies = [ - "cfg-if", - "derive_more", - "parity-scale-codec", - "scale-info-derive", -] - -[[package]] -name = "scale-info-derive" -version = "2.11.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "18cf6c6447f813ef19eb450e985bcce6705f9ce7660db221b59093d15c79c4b7" -dependencies = [ - "proc-macro-crate 1.3.1", - "proc-macro2", - "quote", - "syn 1.0.109", -] - -[[package]] -name = "sec1" -version = "0.7.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d3e97a565f76233a6003f9f5c54be1d9c5bdfa3eccfb189469f11ec4901c47dc" -dependencies = [ - "base16ct", - "der", - "generic-array", - "pkcs8", - "subtle", - "zeroize", -] - [[package]] name = "serde" version = "1.0.203" @@ -580,7 +191,7 @@ checksum = "500cbc0ebeb6f46627f50f3f5811ccf6bf00643be300b4c3eabc0ef55dc5b5ba" dependencies = [ "proc-macro2", "quote", - "syn 2.0.48", + "syn", ] [[package]] @@ -595,39 +206,13 @@ dependencies = [ ] [[package]] -name = "signature" -version = "2.2.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "77549399552de45a898a580c1b41d445bf730df867cc44e6c0233bbc4b8329de" -dependencies = [ - "digest", - "rand_core", -] - -[[package]] -name = "snowbridge-amcl" -version = "1.0.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "460a9ed63cdf03c1b9847e8a12a5f5ba19c4efd5869e4a737e05be25d7c427e5" -dependencies = [ - "parity-scale-codec", - "scale-info", -] - -[[package]] -name = "sp1-precompiles" +name = "sp1-lib" version = "0.1.0" dependencies = [ "anyhow", "bincode", "cfg-if", - "getrandom", - "hex", - "k256", - "num", - "rand", "serde", - "snowbridge-amcl", ] [[package]] @@ -637,40 +222,13 @@ dependencies = [ "bincode", "cfg-if", "getrandom", - "k256", + "lazy_static", "libm", "once_cell", "rand", "serde", "sha2", - "sp1-precompiles", -] - -[[package]] -name = "spki" -version = "0.7.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d91ed6c858b01f942cd56b37a94b3e0a1798290327d1236e4d9cf4eaca44d29d" -dependencies = [ - "base64ct", - "der", -] - -[[package]] -name = "subtle" -version = "2.5.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "81cdd64d312baedb58e21336b31bc043b77e01cc99033ce76ef539f78e965ebc" - -[[package]] -name = "syn" -version = "1.0.109" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "72b64191b275b66ffe2469e8af2c1cfe3bafa67b529ead792a6d0160888b4237" -dependencies = [ - "proc-macro2", - "quote", - "unicode-ident", + "sp1-lib", ] [[package]] @@ -684,40 +242,6 @@ dependencies = [ "unicode-ident", ] -[[package]] -name = "tap" -version = "1.0.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "55937e1799185b12863d447f42597ed69d9928686b8d88a1df17376a097d8369" - -[[package]] -name = "toml_datetime" -version = "0.6.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7cda73e2f1397b1262d6dfdcef8aafae14d1de7748d66822d3bfeeb6d03e5e4b" - -[[package]] -name = "toml_edit" -version = "0.19.15" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1b5bb770da30e5cbfde35a2d7b9b8a2c4b8ef89548a7a6aeab5c9a576e3e7421" -dependencies = [ - "indexmap", - "toml_datetime", - "winnow", -] - -[[package]] -name = "toml_edit" -version = "0.20.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "396e4d48bbb2b7554c944bde63101b5ae446cff6ec4a24227428f15eb72ef338" -dependencies = [ - "indexmap", - "toml_datetime", - "winnow", -] - [[package]] name = "typenum" version = "1.17.0" @@ -741,27 +265,3 @@ name = "wasi" version = "0.11.0+wasi-snapshot-preview1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "9c8d87e72b64a3b4db28d11ce29237c246188f4f51057d65a7eab63b7987e423" - -[[package]] -name = "winnow" -version = "0.5.40" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f593a95398737aeed53e489c785df13f3618e41dbcd6718c6addbf1395aa6876" -dependencies = [ - "memchr", -] - -[[package]] -name = "wyz" -version = "0.5.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "05f360fc0b24296329c78fda852a1e9ae82de9cf7b27dae4b7f62f118f77b9ed" -dependencies = [ - "tap", -] - -[[package]] -name = "zeroize" -version = "1.7.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "525b4ec142c6b68a2d10f01f7bbf6755599ca3f81ea53b8431b7dd348f5fdb2d" diff --git a/tests/ed-decompress/Cargo.toml b/tests/ed-decompress/Cargo.toml index 676a808cbb..31cc9802e4 100644 --- a/tests/ed-decompress/Cargo.toml +++ b/tests/ed-decompress/Cargo.toml @@ -1,8 +1,9 @@ [workspace] [package] -version = "0.1.0" name = "ed-decompress-test" +version = "1.0.0-rc.1" edition = "2021" +publish = false [dependencies] sp1-zkvm = { path = "../../zkvm/entrypoint" } diff --git a/tests/ed-decompress/elf/riscv32im-succinct-zkvm-elf b/tests/ed-decompress/elf/riscv32im-succinct-zkvm-elf index 233f1ab1cb..cbdfc6e541 100755 Binary files a/tests/ed-decompress/elf/riscv32im-succinct-zkvm-elf and b/tests/ed-decompress/elf/riscv32im-succinct-zkvm-elf differ diff --git a/tests/ed-decompress/src/main.rs b/tests/ed-decompress/src/main.rs index 0b6929dde4..994c51facd 100644 --- a/tests/ed-decompress/src/main.rs +++ b/tests/ed-decompress/src/main.rs @@ -1,11 +1,9 @@ #![no_main] -sp1_zkvm::entrypoint!(main); use hex_literal::hex; +use sp1_zkvm::syscalls::syscall_ed_decompress; -extern "C" { - fn syscall_ed_decompress(p: *mut u8); -} +sp1_zkvm::entrypoint!(main); pub fn main() { for _ in 0..4 { @@ -16,9 +14,7 @@ pub fn main() { println!("before: {:?}", decompressed); - unsafe { - syscall_ed_decompress(decompressed.as_mut_ptr()); - } + syscall_ed_decompress(&mut decompressed); let expected: [u8; 64] = [ 47, 252, 114, 91, 153, 234, 110, 201, 201, 153, 152, 14, 68, 231, 90, 221, 137, 110, diff --git a/tests/ed25519/Cargo.lock b/tests/ed25519/Cargo.lock index c6baa674b2..beb740d5da 100644 --- a/tests/ed25519/Cargo.lock +++ b/tests/ed25519/Cargo.lock @@ -8,24 +8,6 @@ version = "1.0.86" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "b3d1d046238990b9cf5bcde22a3fb3584ee5cf65fb2765f454ed428c7a0063da" -[[package]] -name = "arrayvec" -version = "0.7.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "96d30a06541fbafbc7f82ed10c06164cfbd2c401138f6addd8404629c4b16711" - -[[package]] -name = "autocfg" -version = "1.2.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f1fdabc7756949593fe60f30ec81974b613357de856987752631dea1e3394c80" - -[[package]] -name = "base16ct" -version = "0.2.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4c7f02d4ea65f2c1853089ffd8d2787bdbc63de2f0d29dedbcf8ccdfa0ccd4cf" - [[package]] name = "base64ct" version = "1.6.0" @@ -41,18 +23,6 @@ dependencies = [ "serde", ] -[[package]] -name = "bitvec" -version = "1.0.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1bc2832c24239b0141d5674bb9174f9d68a8b5b3f2753311927c172ca46f7e9c" -dependencies = [ - "funty", - "radium", - "tap", - "wyz", -] - [[package]] name = "block-buffer" version = "0.10.4" @@ -62,12 +32,6 @@ dependencies = [ "generic-array", ] -[[package]] -name = "byte-slice-cast" -version = "1.2.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c3ac9f8b63eca6fd385229b3675f6cc0dc5c8a5c8a54a59d4f52ffd670d87b0c" - [[package]] name = "cfg-if" version = "1.0.0" @@ -89,18 +53,6 @@ dependencies = [ "libc", ] -[[package]] -name = "crypto-bigint" -version = "0.5.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0dc92fb57ca44df6db8059111ab3af99a63d5d0f8375d9972e319a379c6bab76" -dependencies = [ - "generic-array", - "rand_core", - "subtle", - "zeroize", -] - [[package]] name = "crypto-common" version = "0.1.6" @@ -134,7 +86,7 @@ source = "git+https://github.com/sp1-patches/curve25519-dalek?branch=patch-v4.1. dependencies = [ "proc-macro2", "quote", - "syn 2.0.60", + "syn", ] [[package]] @@ -147,17 +99,6 @@ dependencies = [ "zeroize", ] -[[package]] -name = "derive_more" -version = "0.99.17" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4fb810d30a7c1953f91334de7244731fc3f3c10d7fe163338a35b9f640960321" -dependencies = [ - "proc-macro2", - "quote", - "syn 1.0.109", -] - [[package]] name = "digest" version = "0.10.7" @@ -165,23 +106,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "9ed9a281f7bc9b7576e61468ba615a66a5c8cfdff42420a70aa82701a3b1e292" dependencies = [ "block-buffer", - "const-oid", "crypto-common", - "subtle", -] - -[[package]] -name = "ecdsa" -version = "0.16.9" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ee27f32b5c5292967d2d4a9d7f1e0b0aed2c15daded5a60300e4abb9d8020bca" -dependencies = [ - "der", - "digest", - "elliptic-curve", - "rfc6979", - "signature", - "spki", ] [[package]] @@ -216,55 +141,12 @@ dependencies = [ "sp1-zkvm", ] -[[package]] -name = "elliptic-curve" -version = "0.13.8" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b5e6043086bf7973472e0c7dff2142ea0b680d30e18d9cc40f267efbf222bd47" -dependencies = [ - "base16ct", - "crypto-bigint", - "digest", - "ff", - "generic-array", - "group", - "pkcs8", - "rand_core", - "sec1", - "subtle", - "tap", - "zeroize", -] - -[[package]] -name = "equivalent" -version = "1.0.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5443807d6dff69373d433ab9ef5378ad8df50ca6298caf15de6e52e24aaf54d5" - -[[package]] -name = "ff" -version = "0.13.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ded41244b729663b1e574f1b4fb731469f69f79c17667b5d776b16cda0479449" -dependencies = [ - "bitvec", - "rand_core", - "subtle", -] - [[package]] name = "fiat-crypto" version = "0.2.8" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "38793c55593b33412e3ae40c2c9781ffaa6f438f6f8c10f24e71846fbd7ae01e" -[[package]] -name = "funty" -version = "2.0.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e6d5a32815ae3f33302d95fdcb2ce17862f8c65363dcfd29360480ba1001fc9c" - [[package]] name = "generic-array" version = "0.14.7" @@ -273,7 +155,6 @@ checksum = "85649ca51fd72272d7821adaf274ad91c288277713d9c18820d8499a7ff69e9a" dependencies = [ "typenum", "version_check", - "zeroize", ] [[package]] @@ -287,29 +168,6 @@ dependencies = [ "wasi", ] -[[package]] -name = "group" -version = "0.13.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f0f9ef7462f7c099f518d754361858f86d8a07af53ba9af0fe635bbccb151a63" -dependencies = [ - "ff", - "rand_core", - "subtle", -] - -[[package]] -name = "hashbrown" -version = "0.14.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "290f1a1d9242c78d09ce40a5e87e7554ee637af1351968159f4952f028f75604" - -[[package]] -name = "hex" -version = "0.4.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7f24254aa9a54b5c858eaee2f5bccdb46aaf0e486a595ed5fd8f86ba55232a70" - [[package]] name = "hex-literal" version = "0.4.1" @@ -317,48 +175,10 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "6fe2267d4ed49bc07b63801559be28c718ea06c4738b7a03c94df7386d2cde46" [[package]] -name = "hmac" -version = "0.12.1" +name = "lazy_static" +version = "1.5.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6c49c37c09c17a53d937dfbb742eb3a961d65a994e6bcdcf37e7399d0cc8ab5e" -dependencies = [ - "digest", -] - -[[package]] -name = "impl-trait-for-tuples" -version = "0.2.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "11d7a9f6330b71fea57921c9b61c47ee6e84f72d394754eff6163ae67e7395eb" -dependencies = [ - "proc-macro2", - "quote", - "syn 1.0.109", -] - -[[package]] -name = "indexmap" -version = "2.2.6" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "168fb715dda47215e360912c096649d23d58bf392ac62f73919e831745e40f26" -dependencies = [ - "equivalent", - "hashbrown", -] - -[[package]] -name = "k256" -version = "0.13.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "956ff9b67e26e1a6a866cb758f12c6f8746208489e3e4a4b5580802f2f0a587b" -dependencies = [ - "cfg-if", - "ecdsa", - "elliptic-curve", - "once_cell", - "sha2", - "signature", -] +checksum = "bbd2bcb4c963f2ddae06a2efc7e9f3591312473c50c6685e1f298068316e66fe" [[package]] name = "libc" @@ -372,115 +192,12 @@ version = "0.2.8" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "4ec2a862134d2a7d32d7983ddcdd1c4923530833c9f2ea1a44fc5fa473989058" -[[package]] -name = "memchr" -version = "2.7.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6c8640c5d730cb13ebd907d8d04b52f55ac9a2eec55b440c8892f40d56c76c1d" - -[[package]] -name = "num" -version = "0.4.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "35bd024e8b2ff75562e5f34e7f4905839deb4b22955ef5e73d2fea1b9813cb23" -dependencies = [ - "num-bigint", - "num-complex", - "num-integer", - "num-iter", - "num-rational", - "num-traits", -] - -[[package]] -name = "num-bigint" -version = "0.4.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c165a9ab64cf766f73521c0dd2cfdff64f488b8f0b3e621face3462d3db536d7" -dependencies = [ - "num-integer", - "num-traits", -] - -[[package]] -name = "num-complex" -version = "0.4.6" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "73f88a1307638156682bada9d7604135552957b7818057dcef22705b4d509495" -dependencies = [ - "num-traits", -] - -[[package]] -name = "num-integer" -version = "0.1.46" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7969661fd2958a5cb096e56c8e1ad0444ac2bbcd0061bd28660485a44879858f" -dependencies = [ - "num-traits", -] - -[[package]] -name = "num-iter" -version = "0.1.45" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1429034a0490724d0075ebb2bc9e875d6503c3cf69e235a8941aa757d83ef5bf" -dependencies = [ - "autocfg", - "num-integer", - "num-traits", -] - -[[package]] -name = "num-rational" -version = "0.4.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f83d14da390562dca69fc84082e73e548e1ad308d24accdedd2720017cb37824" -dependencies = [ - "num-bigint", - "num-integer", - "num-traits", -] - -[[package]] -name = "num-traits" -version = "0.2.19" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "071dfc062690e90b734c0b2273ce72ad0ffa95f0c74596bc250dcfd960262841" -dependencies = [ - "autocfg", -] - [[package]] name = "once_cell" version = "1.19.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "3fdb12b2476b595f9358c5161aa467c2438859caa136dec86c26fdd2efe17b92" -[[package]] -name = "parity-scale-codec" -version = "3.6.9" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "881331e34fa842a2fb61cc2db9643a8fedc615e47cfcc52597d1af0db9a7e8fe" -dependencies = [ - "arrayvec", - "byte-slice-cast", - "impl-trait-for-tuples", - "parity-scale-codec-derive", -] - -[[package]] -name = "parity-scale-codec-derive" -version = "3.6.9" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "be30eaf4b0a9fba5336683b38de57bb86d179a35862ba6bfcf57625d006bde5b" -dependencies = [ - "proc-macro-crate 2.0.2", - "proc-macro2", - "quote", - "syn 1.0.109", -] - [[package]] name = "pkcs8" version = "0.10.2" @@ -503,26 +220,6 @@ version = "0.2.17" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "5b40af805b3121feab8a3c29f04d8ad262fa8e0561883e7653e024ae4479e6de" -[[package]] -name = "proc-macro-crate" -version = "1.3.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7f4c021e1093a56626774e81216a4ce732a735e5bad4868a03f3ed65ca0c3919" -dependencies = [ - "once_cell", - "toml_edit 0.19.15", -] - -[[package]] -name = "proc-macro-crate" -version = "2.0.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b00f26d3400549137f92511a46ac1cd8ce37cb5598a96d382381458b992a5d24" -dependencies = [ - "toml_datetime", - "toml_edit 0.20.2", -] - [[package]] name = "proc-macro2" version = "1.0.81" @@ -541,12 +238,6 @@ dependencies = [ "proc-macro2", ] -[[package]] -name = "radium" -version = "0.7.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "dc33ff2d4973d518d823d61aa239014831e521c75da58e3df4840d3f47749d09" - [[package]] name = "rand" version = "0.8.5" @@ -577,16 +268,6 @@ dependencies = [ "getrandom", ] -[[package]] -name = "rfc6979" -version = "0.4.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f8dd2a808d456c4a54e300a23e9f5a67e122c3024119acbfd73e3bf664491cb2" -dependencies = [ - "hmac", - "subtle", -] - [[package]] name = "rustc_version" version = "0.4.0" @@ -596,44 +277,6 @@ dependencies = [ "semver", ] -[[package]] -name = "scale-info" -version = "2.11.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7c453e59a955f81fb62ee5d596b450383d699f152d350e9d23a0db2adb78e4c0" -dependencies = [ - "cfg-if", - "derive_more", - "parity-scale-codec", - "scale-info-derive", -] - -[[package]] -name = "scale-info-derive" -version = "2.11.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "18cf6c6447f813ef19eb450e985bcce6705f9ce7660db221b59093d15c79c4b7" -dependencies = [ - "proc-macro-crate 1.3.1", - "proc-macro2", - "quote", - "syn 1.0.109", -] - -[[package]] -name = "sec1" -version = "0.7.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d3e97a565f76233a6003f9f5c54be1d9c5bdfa3eccfb189469f11ec4901c47dc" -dependencies = [ - "base16ct", - "der", - "generic-array", - "pkcs8", - "subtle", - "zeroize", -] - [[package]] name = "semver" version = "1.0.22" @@ -657,7 +300,7 @@ checksum = "500cbc0ebeb6f46627f50f3f5811ccf6bf00643be300b4c3eabc0ef55dc5b5ba" dependencies = [ "proc-macro2", "quote", - "syn 2.0.60", + "syn", ] [[package]] @@ -677,34 +320,17 @@ version = "2.2.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "77549399552de45a898a580c1b41d445bf730df867cc44e6c0233bbc4b8329de" dependencies = [ - "digest", "rand_core", ] [[package]] -name = "snowbridge-amcl" -version = "1.0.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "460a9ed63cdf03c1b9847e8a12a5f5ba19c4efd5869e4a737e05be25d7c427e5" -dependencies = [ - "parity-scale-codec", - "scale-info", -] - -[[package]] -name = "sp1-precompiles" +name = "sp1-lib" version = "0.1.0" dependencies = [ "anyhow", "bincode", "cfg-if", - "getrandom", - "hex", - "k256", - "num", - "rand", "serde", - "snowbridge-amcl", ] [[package]] @@ -714,13 +340,13 @@ dependencies = [ "bincode", "cfg-if", "getrandom", - "k256", + "lazy_static", "libm", "once_cell", "rand", "serde", "sha2", - "sp1-precompiles", + "sp1-lib", ] [[package]] @@ -739,17 +365,6 @@ version = "2.5.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "81cdd64d312baedb58e21336b31bc043b77e01cc99033ce76ef539f78e965ebc" -[[package]] -name = "syn" -version = "1.0.109" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "72b64191b275b66ffe2469e8af2c1cfe3bafa67b529ead792a6d0160888b4237" -dependencies = [ - "proc-macro2", - "quote", - "unicode-ident", -] - [[package]] name = "syn" version = "2.0.60" @@ -761,40 +376,6 @@ dependencies = [ "unicode-ident", ] -[[package]] -name = "tap" -version = "1.0.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "55937e1799185b12863d447f42597ed69d9928686b8d88a1df17376a097d8369" - -[[package]] -name = "toml_datetime" -version = "0.6.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7cda73e2f1397b1262d6dfdcef8aafae14d1de7748d66822d3bfeeb6d03e5e4b" - -[[package]] -name = "toml_edit" -version = "0.19.15" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1b5bb770da30e5cbfde35a2d7b9b8a2c4b8ef89548a7a6aeab5c9a576e3e7421" -dependencies = [ - "indexmap", - "toml_datetime", - "winnow", -] - -[[package]] -name = "toml_edit" -version = "0.20.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "396e4d48bbb2b7554c944bde63101b5ae446cff6ec4a24227428f15eb72ef338" -dependencies = [ - "indexmap", - "toml_datetime", - "winnow", -] - [[package]] name = "typenum" version = "1.17.0" @@ -819,24 +400,6 @@ version = "0.11.0+wasi-snapshot-preview1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "9c8d87e72b64a3b4db28d11ce29237c246188f4f51057d65a7eab63b7987e423" -[[package]] -name = "winnow" -version = "0.5.40" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f593a95398737aeed53e489c785df13f3618e41dbcd6718c6addbf1395aa6876" -dependencies = [ - "memchr", -] - -[[package]] -name = "wyz" -version = "0.5.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "05f360fc0b24296329c78fda852a1e9ae82de9cf7b27dae4b7f62f118f77b9ed" -dependencies = [ - "tap", -] - [[package]] name = "zeroize" version = "1.7.0" diff --git a/tests/ed25519/Cargo.toml b/tests/ed25519/Cargo.toml index 412f7f58ac..cdf64839d8 100644 --- a/tests/ed25519/Cargo.toml +++ b/tests/ed25519/Cargo.toml @@ -1,8 +1,9 @@ [workspace] [package] -version = "0.1.0" name = "ed25519-program" +version = "1.0.0-rc.1" edition = "2021" +publish = false [dependencies] sp1-zkvm = { path = "../../zkvm/entrypoint" } diff --git a/tests/ed25519/elf/riscv32im-succinct-zkvm-elf b/tests/ed25519/elf/riscv32im-succinct-zkvm-elf index 5f149617c0..6c402f62bf 100755 Binary files a/tests/ed25519/elf/riscv32im-succinct-zkvm-elf and b/tests/ed25519/elf/riscv32im-succinct-zkvm-elf differ diff --git a/tests/fibonacci/Cargo.lock b/tests/fibonacci/Cargo.lock index 2fd3884c54..3148be746d 100644 --- a/tests/fibonacci/Cargo.lock +++ b/tests/fibonacci/Cargo.lock @@ -8,30 +8,6 @@ version = "1.0.86" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "b3d1d046238990b9cf5bcde22a3fb3584ee5cf65fb2765f454ed428c7a0063da" -[[package]] -name = "arrayvec" -version = "0.7.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "96d30a06541fbafbc7f82ed10c06164cfbd2c401138f6addd8404629c4b16711" - -[[package]] -name = "autocfg" -version = "1.2.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f1fdabc7756949593fe60f30ec81974b613357de856987752631dea1e3394c80" - -[[package]] -name = "base16ct" -version = "0.2.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4c7f02d4ea65f2c1853089ffd8d2787bdbc63de2f0d29dedbcf8ccdfa0ccd4cf" - -[[package]] -name = "base64ct" -version = "1.6.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8c3c1a368f70d6cf7302d78f8f7093da241fb8e8807c05cc9e51a125895a6d5b" - [[package]] name = "bincode" version = "1.3.3" @@ -41,18 +17,6 @@ dependencies = [ "serde", ] -[[package]] -name = "bitvec" -version = "1.0.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1bc2832c24239b0141d5674bb9174f9d68a8b5b3f2753311927c172ca46f7e9c" -dependencies = [ - "funty", - "radium", - "tap", - "wyz", -] - [[package]] name = "block-buffer" version = "0.10.4" @@ -62,24 +26,12 @@ dependencies = [ "generic-array", ] -[[package]] -name = "byte-slice-cast" -version = "1.2.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c3ac9f8b63eca6fd385229b3675f6cc0dc5c8a5c8a54a59d4f52ffd670d87b0c" - [[package]] name = "cfg-if" version = "1.0.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "baf1de4339761588bc0619e3cbc0120ee582ebb74b53b4efbf79117bd2da40fd" -[[package]] -name = "const-oid" -version = "0.9.6" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c2459377285ad874054d797f3ccebf984978aa39129f6eafde5cdc8315b612f8" - [[package]] name = "cpufeatures" version = "0.2.12" @@ -89,18 +41,6 @@ dependencies = [ "libc", ] -[[package]] -name = "crypto-bigint" -version = "0.5.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0dc92fb57ca44df6db8059111ab3af99a63d5d0f8375d9972e319a379c6bab76" -dependencies = [ - "generic-array", - "rand_core", - "subtle", - "zeroize", -] - [[package]] name = "crypto-common" version = "0.1.6" @@ -111,27 +51,6 @@ dependencies = [ "typenum", ] -[[package]] -name = "der" -version = "0.7.9" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f55bf8e7b65898637379c1b74eb1551107c8294ed26d855ceb9fd1a09cfc9bc0" -dependencies = [ - "const-oid", - "zeroize", -] - -[[package]] -name = "derive_more" -version = "0.99.17" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4fb810d30a7c1953f91334de7244731fc3f3c10d7fe163338a35b9f640960321" -dependencies = [ - "proc-macro2", - "quote", - "syn 1.0.109", -] - [[package]] name = "digest" version = "0.10.7" @@ -139,75 +58,16 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "9ed9a281f7bc9b7576e61468ba615a66a5c8cfdff42420a70aa82701a3b1e292" dependencies = [ "block-buffer", - "const-oid", "crypto-common", - "subtle", -] - -[[package]] -name = "ecdsa" -version = "0.16.9" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ee27f32b5c5292967d2d4a9d7f1e0b0aed2c15daded5a60300e4abb9d8020bca" -dependencies = [ - "der", - "digest", - "elliptic-curve", - "rfc6979", - "signature", - "spki", -] - -[[package]] -name = "elliptic-curve" -version = "0.13.8" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b5e6043086bf7973472e0c7dff2142ea0b680d30e18d9cc40f267efbf222bd47" -dependencies = [ - "base16ct", - "crypto-bigint", - "digest", - "ff", - "generic-array", - "group", - "pkcs8", - "rand_core", - "sec1", - "subtle", - "tap", - "zeroize", -] - -[[package]] -name = "equivalent" -version = "1.0.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5443807d6dff69373d433ab9ef5378ad8df50ca6298caf15de6e52e24aaf54d5" - -[[package]] -name = "ff" -version = "0.13.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ded41244b729663b1e574f1b4fb731469f69f79c17667b5d776b16cda0479449" -dependencies = [ - "bitvec", - "rand_core", - "subtle", ] [[package]] -name = "fibonacci-program" +name = "fibonacci-program-tests" version = "0.1.0" dependencies = [ "sp1-zkvm", ] -[[package]] -name = "funty" -version = "2.0.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e6d5a32815ae3f33302d95fdcb2ce17862f8c65363dcfd29360480ba1001fc9c" - [[package]] name = "generic-array" version = "0.14.7" @@ -216,7 +76,6 @@ checksum = "85649ca51fd72272d7821adaf274ad91c288277713d9c18820d8499a7ff69e9a" dependencies = [ "typenum", "version_check", - "zeroize", ] [[package]] @@ -231,71 +90,10 @@ dependencies = [ ] [[package]] -name = "group" -version = "0.13.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f0f9ef7462f7c099f518d754361858f86d8a07af53ba9af0fe635bbccb151a63" -dependencies = [ - "ff", - "rand_core", - "subtle", -] - -[[package]] -name = "hashbrown" -version = "0.14.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "290f1a1d9242c78d09ce40a5e87e7554ee637af1351968159f4952f028f75604" - -[[package]] -name = "hex" -version = "0.4.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7f24254aa9a54b5c858eaee2f5bccdb46aaf0e486a595ed5fd8f86ba55232a70" - -[[package]] -name = "hmac" -version = "0.12.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6c49c37c09c17a53d937dfbb742eb3a961d65a994e6bcdcf37e7399d0cc8ab5e" -dependencies = [ - "digest", -] - -[[package]] -name = "impl-trait-for-tuples" -version = "0.2.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "11d7a9f6330b71fea57921c9b61c47ee6e84f72d394754eff6163ae67e7395eb" -dependencies = [ - "proc-macro2", - "quote", - "syn 1.0.109", -] - -[[package]] -name = "indexmap" -version = "2.2.6" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "168fb715dda47215e360912c096649d23d58bf392ac62f73919e831745e40f26" -dependencies = [ - "equivalent", - "hashbrown", -] - -[[package]] -name = "k256" -version = "0.13.3" +name = "lazy_static" +version = "1.5.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "956ff9b67e26e1a6a866cb758f12c6f8746208489e3e4a4b5580802f2f0a587b" -dependencies = [ - "cfg-if", - "ecdsa", - "elliptic-curve", - "once_cell", - "sha2", - "signature", -] +checksum = "bbd2bcb4c963f2ddae06a2efc7e9f3591312473c50c6685e1f298068316e66fe" [[package]] name = "libc" @@ -309,151 +107,18 @@ version = "0.2.8" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "4ec2a862134d2a7d32d7983ddcdd1c4923530833c9f2ea1a44fc5fa473989058" -[[package]] -name = "memchr" -version = "2.7.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6c8640c5d730cb13ebd907d8d04b52f55ac9a2eec55b440c8892f40d56c76c1d" - -[[package]] -name = "num" -version = "0.4.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "35bd024e8b2ff75562e5f34e7f4905839deb4b22955ef5e73d2fea1b9813cb23" -dependencies = [ - "num-bigint", - "num-complex", - "num-integer", - "num-iter", - "num-rational", - "num-traits", -] - -[[package]] -name = "num-bigint" -version = "0.4.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c165a9ab64cf766f73521c0dd2cfdff64f488b8f0b3e621face3462d3db536d7" -dependencies = [ - "num-integer", - "num-traits", -] - -[[package]] -name = "num-complex" -version = "0.4.6" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "73f88a1307638156682bada9d7604135552957b7818057dcef22705b4d509495" -dependencies = [ - "num-traits", -] - -[[package]] -name = "num-integer" -version = "0.1.46" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7969661fd2958a5cb096e56c8e1ad0444ac2bbcd0061bd28660485a44879858f" -dependencies = [ - "num-traits", -] - -[[package]] -name = "num-iter" -version = "0.1.45" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1429034a0490724d0075ebb2bc9e875d6503c3cf69e235a8941aa757d83ef5bf" -dependencies = [ - "autocfg", - "num-integer", - "num-traits", -] - -[[package]] -name = "num-rational" -version = "0.4.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f83d14da390562dca69fc84082e73e548e1ad308d24accdedd2720017cb37824" -dependencies = [ - "num-bigint", - "num-integer", - "num-traits", -] - -[[package]] -name = "num-traits" -version = "0.2.19" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "071dfc062690e90b734c0b2273ce72ad0ffa95f0c74596bc250dcfd960262841" -dependencies = [ - "autocfg", -] - [[package]] name = "once_cell" version = "1.19.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "3fdb12b2476b595f9358c5161aa467c2438859caa136dec86c26fdd2efe17b92" -[[package]] -name = "parity-scale-codec" -version = "3.6.9" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "881331e34fa842a2fb61cc2db9643a8fedc615e47cfcc52597d1af0db9a7e8fe" -dependencies = [ - "arrayvec", - "byte-slice-cast", - "impl-trait-for-tuples", - "parity-scale-codec-derive", -] - -[[package]] -name = "parity-scale-codec-derive" -version = "3.6.9" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "be30eaf4b0a9fba5336683b38de57bb86d179a35862ba6bfcf57625d006bde5b" -dependencies = [ - "proc-macro-crate 2.0.2", - "proc-macro2", - "quote", - "syn 1.0.109", -] - -[[package]] -name = "pkcs8" -version = "0.10.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f950b2377845cebe5cf8b5165cb3cc1a5e0fa5cfa3e1f7f55707d8fd82e0a7b7" -dependencies = [ - "der", - "spki", -] - [[package]] name = "ppv-lite86" version = "0.2.17" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "5b40af805b3121feab8a3c29f04d8ad262fa8e0561883e7653e024ae4479e6de" -[[package]] -name = "proc-macro-crate" -version = "1.3.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7f4c021e1093a56626774e81216a4ce732a735e5bad4868a03f3ed65ca0c3919" -dependencies = [ - "once_cell", - "toml_edit 0.19.15", -] - -[[package]] -name = "proc-macro-crate" -version = "2.0.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b00f26d3400549137f92511a46ac1cd8ce37cb5598a96d382381458b992a5d24" -dependencies = [ - "toml_datetime", - "toml_edit 0.20.2", -] - [[package]] name = "proc-macro2" version = "1.0.81" @@ -472,12 +137,6 @@ dependencies = [ "proc-macro2", ] -[[package]] -name = "radium" -version = "0.7.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "dc33ff2d4973d518d823d61aa239014831e521c75da58e3df4840d3f47749d09" - [[package]] name = "rand" version = "0.8.5" @@ -508,54 +167,6 @@ dependencies = [ "getrandom", ] -[[package]] -name = "rfc6979" -version = "0.4.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f8dd2a808d456c4a54e300a23e9f5a67e122c3024119acbfd73e3bf664491cb2" -dependencies = [ - "hmac", - "subtle", -] - -[[package]] -name = "scale-info" -version = "2.11.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7c453e59a955f81fb62ee5d596b450383d699f152d350e9d23a0db2adb78e4c0" -dependencies = [ - "cfg-if", - "derive_more", - "parity-scale-codec", - "scale-info-derive", -] - -[[package]] -name = "scale-info-derive" -version = "2.11.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "18cf6c6447f813ef19eb450e985bcce6705f9ce7660db221b59093d15c79c4b7" -dependencies = [ - "proc-macro-crate 1.3.1", - "proc-macro2", - "quote", - "syn 1.0.109", -] - -[[package]] -name = "sec1" -version = "0.7.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d3e97a565f76233a6003f9f5c54be1d9c5bdfa3eccfb189469f11ec4901c47dc" -dependencies = [ - "base16ct", - "der", - "generic-array", - "pkcs8", - "subtle", - "zeroize", -] - [[package]] name = "serde" version = "1.0.203" @@ -573,7 +184,7 @@ checksum = "500cbc0ebeb6f46627f50f3f5811ccf6bf00643be300b4c3eabc0ef55dc5b5ba" dependencies = [ "proc-macro2", "quote", - "syn 2.0.60", + "syn", ] [[package]] @@ -588,39 +199,13 @@ dependencies = [ ] [[package]] -name = "signature" -version = "2.2.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "77549399552de45a898a580c1b41d445bf730df867cc44e6c0233bbc4b8329de" -dependencies = [ - "digest", - "rand_core", -] - -[[package]] -name = "snowbridge-amcl" -version = "1.0.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "460a9ed63cdf03c1b9847e8a12a5f5ba19c4efd5869e4a737e05be25d7c427e5" -dependencies = [ - "parity-scale-codec", - "scale-info", -] - -[[package]] -name = "sp1-precompiles" +name = "sp1-lib" version = "0.1.0" dependencies = [ "anyhow", "bincode", "cfg-if", - "getrandom", - "hex", - "k256", - "num", - "rand", "serde", - "snowbridge-amcl", ] [[package]] @@ -630,40 +215,13 @@ dependencies = [ "bincode", "cfg-if", "getrandom", - "k256", + "lazy_static", "libm", "once_cell", "rand", "serde", "sha2", - "sp1-precompiles", -] - -[[package]] -name = "spki" -version = "0.7.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d91ed6c858b01f942cd56b37a94b3e0a1798290327d1236e4d9cf4eaca44d29d" -dependencies = [ - "base64ct", - "der", -] - -[[package]] -name = "subtle" -version = "2.5.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "81cdd64d312baedb58e21336b31bc043b77e01cc99033ce76ef539f78e965ebc" - -[[package]] -name = "syn" -version = "1.0.109" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "72b64191b275b66ffe2469e8af2c1cfe3bafa67b529ead792a6d0160888b4237" -dependencies = [ - "proc-macro2", - "quote", - "unicode-ident", + "sp1-lib", ] [[package]] @@ -677,40 +235,6 @@ dependencies = [ "unicode-ident", ] -[[package]] -name = "tap" -version = "1.0.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "55937e1799185b12863d447f42597ed69d9928686b8d88a1df17376a097d8369" - -[[package]] -name = "toml_datetime" -version = "0.6.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7cda73e2f1397b1262d6dfdcef8aafae14d1de7748d66822d3bfeeb6d03e5e4b" - -[[package]] -name = "toml_edit" -version = "0.19.15" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1b5bb770da30e5cbfde35a2d7b9b8a2c4b8ef89548a7a6aeab5c9a576e3e7421" -dependencies = [ - "indexmap", - "toml_datetime", - "winnow", -] - -[[package]] -name = "toml_edit" -version = "0.20.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "396e4d48bbb2b7554c944bde63101b5ae446cff6ec4a24227428f15eb72ef338" -dependencies = [ - "indexmap", - "toml_datetime", - "winnow", -] - [[package]] name = "typenum" version = "1.17.0" @@ -734,27 +258,3 @@ name = "wasi" version = "0.11.0+wasi-snapshot-preview1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "9c8d87e72b64a3b4db28d11ce29237c246188f4f51057d65a7eab63b7987e423" - -[[package]] -name = "winnow" -version = "0.5.40" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f593a95398737aeed53e489c785df13f3618e41dbcd6718c6addbf1395aa6876" -dependencies = [ - "memchr", -] - -[[package]] -name = "wyz" -version = "0.5.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "05f360fc0b24296329c78fda852a1e9ae82de9cf7b27dae4b7f62f118f77b9ed" -dependencies = [ - "tap", -] - -[[package]] -name = "zeroize" -version = "1.7.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "525b4ec142c6b68a2d10f01f7bbf6755599ca3f81ea53b8431b7dd348f5fdb2d" diff --git a/tests/fibonacci/Cargo.toml b/tests/fibonacci/Cargo.toml index 231775d5be..bbe0fde81a 100644 --- a/tests/fibonacci/Cargo.toml +++ b/tests/fibonacci/Cargo.toml @@ -1,8 +1,9 @@ [workspace] [package] -version = "0.1.0" name = "fibonacci-program-tests" +version = "1.0.0-rc.1" edition = "2021" +publish = false [dependencies] sp1-zkvm = { path = "../../zkvm/entrypoint" } diff --git a/tests/fibonacci/elf/riscv32im-succinct-zkvm-elf b/tests/fibonacci/elf/riscv32im-succinct-zkvm-elf index 7a61102c17..9f1aa66747 100755 Binary files a/tests/fibonacci/elf/riscv32im-succinct-zkvm-elf and b/tests/fibonacci/elf/riscv32im-succinct-zkvm-elf differ diff --git a/tests/hint-io/Cargo.lock b/tests/hint-io/Cargo.lock index 7f101bd208..769ca532f6 100644 --- a/tests/hint-io/Cargo.lock +++ b/tests/hint-io/Cargo.lock @@ -8,30 +8,6 @@ version = "1.0.86" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "b3d1d046238990b9cf5bcde22a3fb3584ee5cf65fb2765f454ed428c7a0063da" -[[package]] -name = "arrayvec" -version = "0.7.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "96d30a06541fbafbc7f82ed10c06164cfbd2c401138f6addd8404629c4b16711" - -[[package]] -name = "autocfg" -version = "1.2.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f1fdabc7756949593fe60f30ec81974b613357de856987752631dea1e3394c80" - -[[package]] -name = "base16ct" -version = "0.2.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4c7f02d4ea65f2c1853089ffd8d2787bdbc63de2f0d29dedbcf8ccdfa0ccd4cf" - -[[package]] -name = "base64ct" -version = "1.6.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8c3c1a368f70d6cf7302d78f8f7093da241fb8e8807c05cc9e51a125895a6d5b" - [[package]] name = "bincode" version = "1.3.3" @@ -41,18 +17,6 @@ dependencies = [ "serde", ] -[[package]] -name = "bitvec" -version = "1.0.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1bc2832c24239b0141d5674bb9174f9d68a8b5b3f2753311927c172ca46f7e9c" -dependencies = [ - "funty", - "radium", - "tap", - "wyz", -] - [[package]] name = "block-buffer" version = "0.10.4" @@ -62,24 +26,12 @@ dependencies = [ "generic-array", ] -[[package]] -name = "byte-slice-cast" -version = "1.2.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c3ac9f8b63eca6fd385229b3675f6cc0dc5c8a5c8a54a59d4f52ffd670d87b0c" - [[package]] name = "cfg-if" version = "1.0.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "baf1de4339761588bc0619e3cbc0120ee582ebb74b53b4efbf79117bd2da40fd" -[[package]] -name = "const-oid" -version = "0.9.6" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c2459377285ad874054d797f3ccebf984978aa39129f6eafde5cdc8315b612f8" - [[package]] name = "cpufeatures" version = "0.2.12" @@ -89,18 +41,6 @@ dependencies = [ "libc", ] -[[package]] -name = "crypto-bigint" -version = "0.5.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0dc92fb57ca44df6db8059111ab3af99a63d5d0f8375d9972e319a379c6bab76" -dependencies = [ - "generic-array", - "rand_core", - "subtle", - "zeroize", -] - [[package]] name = "crypto-common" version = "0.1.6" @@ -111,27 +51,6 @@ dependencies = [ "typenum", ] -[[package]] -name = "der" -version = "0.7.8" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "fffa369a668c8af7dbf8b5e56c9f744fbd399949ed171606040001947de40b1c" -dependencies = [ - "const-oid", - "zeroize", -] - -[[package]] -name = "derive_more" -version = "0.99.17" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4fb810d30a7c1953f91334de7244731fc3f3c10d7fe163338a35b9f640960321" -dependencies = [ - "proc-macro2", - "quote", - "syn 1.0.109", -] - [[package]] name = "digest" version = "0.10.7" @@ -139,68 +58,9 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "9ed9a281f7bc9b7576e61468ba615a66a5c8cfdff42420a70aa82701a3b1e292" dependencies = [ "block-buffer", - "const-oid", "crypto-common", - "subtle", -] - -[[package]] -name = "ecdsa" -version = "0.16.9" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ee27f32b5c5292967d2d4a9d7f1e0b0aed2c15daded5a60300e4abb9d8020bca" -dependencies = [ - "der", - "digest", - "elliptic-curve", - "rfc6979", - "signature", - "spki", ] -[[package]] -name = "elliptic-curve" -version = "0.13.8" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b5e6043086bf7973472e0c7dff2142ea0b680d30e18d9cc40f267efbf222bd47" -dependencies = [ - "base16ct", - "crypto-bigint", - "digest", - "ff", - "generic-array", - "group", - "pkcs8", - "rand_core", - "sec1", - "subtle", - "tap", - "zeroize", -] - -[[package]] -name = "equivalent" -version = "1.0.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5443807d6dff69373d433ab9ef5378ad8df50ca6298caf15de6e52e24aaf54d5" - -[[package]] -name = "ff" -version = "0.13.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ded41244b729663b1e574f1b4fb731469f69f79c17667b5d776b16cda0479449" -dependencies = [ - "bitvec", - "rand_core", - "subtle", -] - -[[package]] -name = "funty" -version = "2.0.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e6d5a32815ae3f33302d95fdcb2ce17862f8c65363dcfd29360480ba1001fc9c" - [[package]] name = "generic-array" version = "0.14.7" @@ -209,7 +69,6 @@ checksum = "85649ca51fd72272d7821adaf274ad91c288277713d9c18820d8499a7ff69e9a" dependencies = [ "typenum", "version_check", - "zeroize", ] [[package]] @@ -223,29 +82,6 @@ dependencies = [ "wasi", ] -[[package]] -name = "group" -version = "0.13.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f0f9ef7462f7c099f518d754361858f86d8a07af53ba9af0fe635bbccb151a63" -dependencies = [ - "ff", - "rand_core", - "subtle", -] - -[[package]] -name = "hashbrown" -version = "0.14.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "290f1a1d9242c78d09ce40a5e87e7554ee637af1351968159f4952f028f75604" - -[[package]] -name = "hex" -version = "0.4.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7f24254aa9a54b5c858eaee2f5bccdb46aaf0e486a595ed5fd8f86ba55232a70" - [[package]] name = "hint-io-test" version = "0.1.0" @@ -254,48 +90,16 @@ dependencies = [ ] [[package]] -name = "hmac" -version = "0.12.1" +name = "lazy_static" +version = "1.5.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6c49c37c09c17a53d937dfbb742eb3a961d65a994e6bcdcf37e7399d0cc8ab5e" -dependencies = [ - "digest", -] - -[[package]] -name = "impl-trait-for-tuples" -version = "0.2.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "11d7a9f6330b71fea57921c9b61c47ee6e84f72d394754eff6163ae67e7395eb" -dependencies = [ - "proc-macro2", - "quote", - "syn 1.0.109", -] +checksum = "bbd2bcb4c963f2ddae06a2efc7e9f3591312473c50c6685e1f298068316e66fe" [[package]] -name = "indexmap" -version = "2.2.6" +name = "lazy_static" +version = "1.5.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "168fb715dda47215e360912c096649d23d58bf392ac62f73919e831745e40f26" -dependencies = [ - "equivalent", - "hashbrown", -] - -[[package]] -name = "k256" -version = "0.13.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "956ff9b67e26e1a6a866cb758f12c6f8746208489e3e4a4b5580802f2f0a587b" -dependencies = [ - "cfg-if", - "ecdsa", - "elliptic-curve", - "once_cell", - "sha2", - "signature", -] +checksum = "bbd2bcb4c963f2ddae06a2efc7e9f3591312473c50c6685e1f298068316e66fe" [[package]] name = "libc" @@ -309,151 +113,18 @@ version = "0.2.8" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "4ec2a862134d2a7d32d7983ddcdd1c4923530833c9f2ea1a44fc5fa473989058" -[[package]] -name = "memchr" -version = "2.7.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6c8640c5d730cb13ebd907d8d04b52f55ac9a2eec55b440c8892f40d56c76c1d" - -[[package]] -name = "num" -version = "0.4.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "35bd024e8b2ff75562e5f34e7f4905839deb4b22955ef5e73d2fea1b9813cb23" -dependencies = [ - "num-bigint", - "num-complex", - "num-integer", - "num-iter", - "num-rational", - "num-traits", -] - -[[package]] -name = "num-bigint" -version = "0.4.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c165a9ab64cf766f73521c0dd2cfdff64f488b8f0b3e621face3462d3db536d7" -dependencies = [ - "num-integer", - "num-traits", -] - -[[package]] -name = "num-complex" -version = "0.4.6" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "73f88a1307638156682bada9d7604135552957b7818057dcef22705b4d509495" -dependencies = [ - "num-traits", -] - -[[package]] -name = "num-integer" -version = "0.1.46" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7969661fd2958a5cb096e56c8e1ad0444ac2bbcd0061bd28660485a44879858f" -dependencies = [ - "num-traits", -] - -[[package]] -name = "num-iter" -version = "0.1.45" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1429034a0490724d0075ebb2bc9e875d6503c3cf69e235a8941aa757d83ef5bf" -dependencies = [ - "autocfg", - "num-integer", - "num-traits", -] - -[[package]] -name = "num-rational" -version = "0.4.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f83d14da390562dca69fc84082e73e548e1ad308d24accdedd2720017cb37824" -dependencies = [ - "num-bigint", - "num-integer", - "num-traits", -] - -[[package]] -name = "num-traits" -version = "0.2.19" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "071dfc062690e90b734c0b2273ce72ad0ffa95f0c74596bc250dcfd960262841" -dependencies = [ - "autocfg", -] - [[package]] name = "once_cell" version = "1.19.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "3fdb12b2476b595f9358c5161aa467c2438859caa136dec86c26fdd2efe17b92" -[[package]] -name = "parity-scale-codec" -version = "3.6.9" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "881331e34fa842a2fb61cc2db9643a8fedc615e47cfcc52597d1af0db9a7e8fe" -dependencies = [ - "arrayvec", - "byte-slice-cast", - "impl-trait-for-tuples", - "parity-scale-codec-derive", -] - -[[package]] -name = "parity-scale-codec-derive" -version = "3.6.9" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "be30eaf4b0a9fba5336683b38de57bb86d179a35862ba6bfcf57625d006bde5b" -dependencies = [ - "proc-macro-crate 2.0.2", - "proc-macro2", - "quote", - "syn 1.0.109", -] - -[[package]] -name = "pkcs8" -version = "0.10.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f950b2377845cebe5cf8b5165cb3cc1a5e0fa5cfa3e1f7f55707d8fd82e0a7b7" -dependencies = [ - "der", - "spki", -] - [[package]] name = "ppv-lite86" version = "0.2.17" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "5b40af805b3121feab8a3c29f04d8ad262fa8e0561883e7653e024ae4479e6de" -[[package]] -name = "proc-macro-crate" -version = "1.3.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7f4c021e1093a56626774e81216a4ce732a735e5bad4868a03f3ed65ca0c3919" -dependencies = [ - "once_cell", - "toml_edit 0.19.15", -] - -[[package]] -name = "proc-macro-crate" -version = "2.0.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b00f26d3400549137f92511a46ac1cd8ce37cb5598a96d382381458b992a5d24" -dependencies = [ - "toml_datetime", - "toml_edit 0.20.2", -] - [[package]] name = "proc-macro2" version = "1.0.79" @@ -472,12 +143,6 @@ dependencies = [ "proc-macro2", ] -[[package]] -name = "radium" -version = "0.7.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "dc33ff2d4973d518d823d61aa239014831e521c75da58e3df4840d3f47749d09" - [[package]] name = "rand" version = "0.8.5" @@ -508,54 +173,6 @@ dependencies = [ "getrandom", ] -[[package]] -name = "rfc6979" -version = "0.4.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f8dd2a808d456c4a54e300a23e9f5a67e122c3024119acbfd73e3bf664491cb2" -dependencies = [ - "hmac", - "subtle", -] - -[[package]] -name = "scale-info" -version = "2.11.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7c453e59a955f81fb62ee5d596b450383d699f152d350e9d23a0db2adb78e4c0" -dependencies = [ - "cfg-if", - "derive_more", - "parity-scale-codec", - "scale-info-derive", -] - -[[package]] -name = "scale-info-derive" -version = "2.11.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "18cf6c6447f813ef19eb450e985bcce6705f9ce7660db221b59093d15c79c4b7" -dependencies = [ - "proc-macro-crate 1.3.1", - "proc-macro2", - "quote", - "syn 1.0.109", -] - -[[package]] -name = "sec1" -version = "0.7.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d3e97a565f76233a6003f9f5c54be1d9c5bdfa3eccfb189469f11ec4901c47dc" -dependencies = [ - "base16ct", - "der", - "generic-array", - "pkcs8", - "subtle", - "zeroize", -] - [[package]] name = "serde" version = "1.0.203" @@ -573,7 +190,7 @@ checksum = "500cbc0ebeb6f46627f50f3f5811ccf6bf00643be300b4c3eabc0ef55dc5b5ba" dependencies = [ "proc-macro2", "quote", - "syn 2.0.55", + "syn", ] [[package]] @@ -588,39 +205,13 @@ dependencies = [ ] [[package]] -name = "signature" -version = "2.2.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "77549399552de45a898a580c1b41d445bf730df867cc44e6c0233bbc4b8329de" -dependencies = [ - "digest", - "rand_core", -] - -[[package]] -name = "snowbridge-amcl" -version = "1.0.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "460a9ed63cdf03c1b9847e8a12a5f5ba19c4efd5869e4a737e05be25d7c427e5" -dependencies = [ - "parity-scale-codec", - "scale-info", -] - -[[package]] -name = "sp1-precompiles" +name = "sp1-lib" version = "0.1.0" dependencies = [ "anyhow", "bincode", "cfg-if", - "getrandom", - "hex", - "k256", - "num", - "rand", "serde", - "snowbridge-amcl", ] [[package]] @@ -630,40 +221,13 @@ dependencies = [ "bincode", "cfg-if", "getrandom", - "k256", + "lazy_static", "libm", "once_cell", "rand", "serde", "sha2", - "sp1-precompiles", -] - -[[package]] -name = "spki" -version = "0.7.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d91ed6c858b01f942cd56b37a94b3e0a1798290327d1236e4d9cf4eaca44d29d" -dependencies = [ - "base64ct", - "der", -] - -[[package]] -name = "subtle" -version = "2.5.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "81cdd64d312baedb58e21336b31bc043b77e01cc99033ce76ef539f78e965ebc" - -[[package]] -name = "syn" -version = "1.0.109" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "72b64191b275b66ffe2469e8af2c1cfe3bafa67b529ead792a6d0160888b4237" -dependencies = [ - "proc-macro2", - "quote", - "unicode-ident", + "sp1-lib", ] [[package]] @@ -677,40 +241,6 @@ dependencies = [ "unicode-ident", ] -[[package]] -name = "tap" -version = "1.0.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "55937e1799185b12863d447f42597ed69d9928686b8d88a1df17376a097d8369" - -[[package]] -name = "toml_datetime" -version = "0.6.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7cda73e2f1397b1262d6dfdcef8aafae14d1de7748d66822d3bfeeb6d03e5e4b" - -[[package]] -name = "toml_edit" -version = "0.19.15" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1b5bb770da30e5cbfde35a2d7b9b8a2c4b8ef89548a7a6aeab5c9a576e3e7421" -dependencies = [ - "indexmap", - "toml_datetime", - "winnow", -] - -[[package]] -name = "toml_edit" -version = "0.20.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "396e4d48bbb2b7554c944bde63101b5ae446cff6ec4a24227428f15eb72ef338" -dependencies = [ - "indexmap", - "toml_datetime", - "winnow", -] - [[package]] name = "typenum" version = "1.17.0" @@ -734,27 +264,3 @@ name = "wasi" version = "0.11.0+wasi-snapshot-preview1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "9c8d87e72b64a3b4db28d11ce29237c246188f4f51057d65a7eab63b7987e423" - -[[package]] -name = "winnow" -version = "0.5.40" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f593a95398737aeed53e489c785df13f3618e41dbcd6718c6addbf1395aa6876" -dependencies = [ - "memchr", -] - -[[package]] -name = "wyz" -version = "0.5.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "05f360fc0b24296329c78fda852a1e9ae82de9cf7b27dae4b7f62f118f77b9ed" -dependencies = [ - "tap", -] - -[[package]] -name = "zeroize" -version = "1.7.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "525b4ec142c6b68a2d10f01f7bbf6755599ca3f81ea53b8431b7dd348f5fdb2d" diff --git a/tests/hint-io/Cargo.toml b/tests/hint-io/Cargo.toml index 71afe02854..1e8caf9ef3 100644 --- a/tests/hint-io/Cargo.toml +++ b/tests/hint-io/Cargo.toml @@ -1,8 +1,8 @@ [workspace] [package] -version = "0.1.0" name = "hint-io-test" -edition = "2021" +version = "1.0.0-rc.1" +publish = false [dependencies] sp1-zkvm = { path = "../../zkvm/entrypoint" } diff --git a/tests/hint-io/elf/riscv32im-succinct-zkvm-elf b/tests/hint-io/elf/riscv32im-succinct-zkvm-elf index ac7a2fc293..51074260c8 100755 Binary files a/tests/hint-io/elf/riscv32im-succinct-zkvm-elf and b/tests/hint-io/elf/riscv32im-succinct-zkvm-elf differ diff --git a/tests/keccak-permute/Cargo.lock b/tests/keccak-permute/Cargo.lock index 92931e9308..95eddbe6dc 100644 --- a/tests/keccak-permute/Cargo.lock +++ b/tests/keccak-permute/Cargo.lock @@ -8,30 +8,6 @@ version = "1.0.86" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "b3d1d046238990b9cf5bcde22a3fb3584ee5cf65fb2765f454ed428c7a0063da" -[[package]] -name = "arrayvec" -version = "0.7.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "96d30a06541fbafbc7f82ed10c06164cfbd2c401138f6addd8404629c4b16711" - -[[package]] -name = "autocfg" -version = "1.2.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f1fdabc7756949593fe60f30ec81974b613357de856987752631dea1e3394c80" - -[[package]] -name = "base16ct" -version = "0.2.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4c7f02d4ea65f2c1853089ffd8d2787bdbc63de2f0d29dedbcf8ccdfa0ccd4cf" - -[[package]] -name = "base64ct" -version = "1.6.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8c3c1a368f70d6cf7302d78f8f7093da241fb8e8807c05cc9e51a125895a6d5b" - [[package]] name = "bincode" version = "1.3.3" @@ -41,18 +17,6 @@ dependencies = [ "serde", ] -[[package]] -name = "bitvec" -version = "1.0.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1bc2832c24239b0141d5674bb9174f9d68a8b5b3f2753311927c172ca46f7e9c" -dependencies = [ - "funty", - "radium", - "tap", - "wyz", -] - [[package]] name = "block-buffer" version = "0.10.4" @@ -62,24 +26,12 @@ dependencies = [ "generic-array", ] -[[package]] -name = "byte-slice-cast" -version = "1.2.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c3ac9f8b63eca6fd385229b3675f6cc0dc5c8a5c8a54a59d4f52ffd670d87b0c" - [[package]] name = "cfg-if" version = "1.0.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "baf1de4339761588bc0619e3cbc0120ee582ebb74b53b4efbf79117bd2da40fd" -[[package]] -name = "const-oid" -version = "0.9.6" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c2459377285ad874054d797f3ccebf984978aa39129f6eafde5cdc8315b612f8" - [[package]] name = "cpufeatures" version = "0.2.12" @@ -89,18 +41,6 @@ dependencies = [ "libc", ] -[[package]] -name = "crypto-bigint" -version = "0.5.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0dc92fb57ca44df6db8059111ab3af99a63d5d0f8375d9972e319a379c6bab76" -dependencies = [ - "generic-array", - "rand_core", - "subtle", - "zeroize", -] - [[package]] name = "crypto-common" version = "0.1.6" @@ -111,27 +51,6 @@ dependencies = [ "typenum", ] -[[package]] -name = "der" -version = "0.7.8" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "fffa369a668c8af7dbf8b5e56c9f744fbd399949ed171606040001947de40b1c" -dependencies = [ - "const-oid", - "zeroize", -] - -[[package]] -name = "derive_more" -version = "0.99.17" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4fb810d30a7c1953f91334de7244731fc3f3c10d7fe163338a35b9f640960321" -dependencies = [ - "proc-macro2", - "quote", - "syn 1.0.109", -] - [[package]] name = "digest" version = "0.10.7" @@ -139,68 +58,9 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "9ed9a281f7bc9b7576e61468ba615a66a5c8cfdff42420a70aa82701a3b1e292" dependencies = [ "block-buffer", - "const-oid", "crypto-common", - "subtle", ] -[[package]] -name = "ecdsa" -version = "0.16.9" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ee27f32b5c5292967d2d4a9d7f1e0b0aed2c15daded5a60300e4abb9d8020bca" -dependencies = [ - "der", - "digest", - "elliptic-curve", - "rfc6979", - "signature", - "spki", -] - -[[package]] -name = "elliptic-curve" -version = "0.13.8" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b5e6043086bf7973472e0c7dff2142ea0b680d30e18d9cc40f267efbf222bd47" -dependencies = [ - "base16ct", - "crypto-bigint", - "digest", - "ff", - "generic-array", - "group", - "pkcs8", - "rand_core", - "sec1", - "subtle", - "tap", - "zeroize", -] - -[[package]] -name = "equivalent" -version = "1.0.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5443807d6dff69373d433ab9ef5378ad8df50ca6298caf15de6e52e24aaf54d5" - -[[package]] -name = "ff" -version = "0.13.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ded41244b729663b1e574f1b4fb731469f69f79c17667b5d776b16cda0479449" -dependencies = [ - "bitvec", - "rand_core", - "subtle", -] - -[[package]] -name = "funty" -version = "2.0.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e6d5a32815ae3f33302d95fdcb2ce17862f8c65363dcfd29360480ba1001fc9c" - [[package]] name = "generic-array" version = "0.14.7" @@ -209,7 +69,6 @@ checksum = "85649ca51fd72272d7821adaf274ad91c288277713d9c18820d8499a7ff69e9a" dependencies = [ "typenum", "version_check", - "zeroize", ] [[package]] @@ -223,73 +82,6 @@ dependencies = [ "wasi", ] -[[package]] -name = "group" -version = "0.13.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f0f9ef7462f7c099f518d754361858f86d8a07af53ba9af0fe635bbccb151a63" -dependencies = [ - "ff", - "rand_core", - "subtle", -] - -[[package]] -name = "hashbrown" -version = "0.14.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "290f1a1d9242c78d09ce40a5e87e7554ee637af1351968159f4952f028f75604" - -[[package]] -name = "hex" -version = "0.4.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7f24254aa9a54b5c858eaee2f5bccdb46aaf0e486a595ed5fd8f86ba55232a70" - -[[package]] -name = "hmac" -version = "0.12.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6c49c37c09c17a53d937dfbb742eb3a961d65a994e6bcdcf37e7399d0cc8ab5e" -dependencies = [ - "digest", -] - -[[package]] -name = "impl-trait-for-tuples" -version = "0.2.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "11d7a9f6330b71fea57921c9b61c47ee6e84f72d394754eff6163ae67e7395eb" -dependencies = [ - "proc-macro2", - "quote", - "syn 1.0.109", -] - -[[package]] -name = "indexmap" -version = "2.2.6" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "168fb715dda47215e360912c096649d23d58bf392ac62f73919e831745e40f26" -dependencies = [ - "equivalent", - "hashbrown", -] - -[[package]] -name = "k256" -version = "0.13.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "956ff9b67e26e1a6a866cb758f12c6f8746208489e3e4a4b5580802f2f0a587b" -dependencies = [ - "cfg-if", - "ecdsa", - "elliptic-curve", - "once_cell", - "sha2", - "signature", -] - [[package]] name = "keccak-permute-test" version = "0.1.0" @@ -297,6 +89,12 @@ dependencies = [ "sp1-zkvm", ] +[[package]] +name = "lazy_static" +version = "1.5.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "bbd2bcb4c963f2ddae06a2efc7e9f3591312473c50c6685e1f298068316e66fe" + [[package]] name = "libc" version = "0.2.155" @@ -309,151 +107,18 @@ version = "0.2.8" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "4ec2a862134d2a7d32d7983ddcdd1c4923530833c9f2ea1a44fc5fa473989058" -[[package]] -name = "memchr" -version = "2.7.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6c8640c5d730cb13ebd907d8d04b52f55ac9a2eec55b440c8892f40d56c76c1d" - -[[package]] -name = "num" -version = "0.4.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "35bd024e8b2ff75562e5f34e7f4905839deb4b22955ef5e73d2fea1b9813cb23" -dependencies = [ - "num-bigint", - "num-complex", - "num-integer", - "num-iter", - "num-rational", - "num-traits", -] - -[[package]] -name = "num-bigint" -version = "0.4.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c165a9ab64cf766f73521c0dd2cfdff64f488b8f0b3e621face3462d3db536d7" -dependencies = [ - "num-integer", - "num-traits", -] - -[[package]] -name = "num-complex" -version = "0.4.6" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "73f88a1307638156682bada9d7604135552957b7818057dcef22705b4d509495" -dependencies = [ - "num-traits", -] - -[[package]] -name = "num-integer" -version = "0.1.46" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7969661fd2958a5cb096e56c8e1ad0444ac2bbcd0061bd28660485a44879858f" -dependencies = [ - "num-traits", -] - -[[package]] -name = "num-iter" -version = "0.1.45" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1429034a0490724d0075ebb2bc9e875d6503c3cf69e235a8941aa757d83ef5bf" -dependencies = [ - "autocfg", - "num-integer", - "num-traits", -] - -[[package]] -name = "num-rational" -version = "0.4.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f83d14da390562dca69fc84082e73e548e1ad308d24accdedd2720017cb37824" -dependencies = [ - "num-bigint", - "num-integer", - "num-traits", -] - -[[package]] -name = "num-traits" -version = "0.2.19" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "071dfc062690e90b734c0b2273ce72ad0ffa95f0c74596bc250dcfd960262841" -dependencies = [ - "autocfg", -] - [[package]] name = "once_cell" version = "1.19.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "3fdb12b2476b595f9358c5161aa467c2438859caa136dec86c26fdd2efe17b92" -[[package]] -name = "parity-scale-codec" -version = "3.6.9" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "881331e34fa842a2fb61cc2db9643a8fedc615e47cfcc52597d1af0db9a7e8fe" -dependencies = [ - "arrayvec", - "byte-slice-cast", - "impl-trait-for-tuples", - "parity-scale-codec-derive", -] - -[[package]] -name = "parity-scale-codec-derive" -version = "3.6.9" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "be30eaf4b0a9fba5336683b38de57bb86d179a35862ba6bfcf57625d006bde5b" -dependencies = [ - "proc-macro-crate 2.0.2", - "proc-macro2", - "quote", - "syn 1.0.109", -] - -[[package]] -name = "pkcs8" -version = "0.10.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f950b2377845cebe5cf8b5165cb3cc1a5e0fa5cfa3e1f7f55707d8fd82e0a7b7" -dependencies = [ - "der", - "spki", -] - [[package]] name = "ppv-lite86" version = "0.2.17" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "5b40af805b3121feab8a3c29f04d8ad262fa8e0561883e7653e024ae4479e6de" -[[package]] -name = "proc-macro-crate" -version = "1.3.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7f4c021e1093a56626774e81216a4ce732a735e5bad4868a03f3ed65ca0c3919" -dependencies = [ - "once_cell", - "toml_edit 0.19.15", -] - -[[package]] -name = "proc-macro-crate" -version = "2.0.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b00f26d3400549137f92511a46ac1cd8ce37cb5598a96d382381458b992a5d24" -dependencies = [ - "toml_datetime", - "toml_edit 0.20.2", -] - [[package]] name = "proc-macro2" version = "1.0.78" @@ -472,12 +137,6 @@ dependencies = [ "proc-macro2", ] -[[package]] -name = "radium" -version = "0.7.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "dc33ff2d4973d518d823d61aa239014831e521c75da58e3df4840d3f47749d09" - [[package]] name = "rand" version = "0.8.5" @@ -508,54 +167,6 @@ dependencies = [ "getrandom", ] -[[package]] -name = "rfc6979" -version = "0.4.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f8dd2a808d456c4a54e300a23e9f5a67e122c3024119acbfd73e3bf664491cb2" -dependencies = [ - "hmac", - "subtle", -] - -[[package]] -name = "scale-info" -version = "2.11.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7c453e59a955f81fb62ee5d596b450383d699f152d350e9d23a0db2adb78e4c0" -dependencies = [ - "cfg-if", - "derive_more", - "parity-scale-codec", - "scale-info-derive", -] - -[[package]] -name = "scale-info-derive" -version = "2.11.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "18cf6c6447f813ef19eb450e985bcce6705f9ce7660db221b59093d15c79c4b7" -dependencies = [ - "proc-macro-crate 1.3.1", - "proc-macro2", - "quote", - "syn 1.0.109", -] - -[[package]] -name = "sec1" -version = "0.7.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d3e97a565f76233a6003f9f5c54be1d9c5bdfa3eccfb189469f11ec4901c47dc" -dependencies = [ - "base16ct", - "der", - "generic-array", - "pkcs8", - "subtle", - "zeroize", -] - [[package]] name = "serde" version = "1.0.203" @@ -573,7 +184,7 @@ checksum = "500cbc0ebeb6f46627f50f3f5811ccf6bf00643be300b4c3eabc0ef55dc5b5ba" dependencies = [ "proc-macro2", "quote", - "syn 2.0.48", + "syn", ] [[package]] @@ -588,39 +199,13 @@ dependencies = [ ] [[package]] -name = "signature" -version = "2.2.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "77549399552de45a898a580c1b41d445bf730df867cc44e6c0233bbc4b8329de" -dependencies = [ - "digest", - "rand_core", -] - -[[package]] -name = "snowbridge-amcl" -version = "1.0.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "460a9ed63cdf03c1b9847e8a12a5f5ba19c4efd5869e4a737e05be25d7c427e5" -dependencies = [ - "parity-scale-codec", - "scale-info", -] - -[[package]] -name = "sp1-precompiles" +name = "sp1-lib" version = "0.1.0" dependencies = [ "anyhow", "bincode", "cfg-if", - "getrandom", - "hex", - "k256", - "num", - "rand", "serde", - "snowbridge-amcl", ] [[package]] @@ -630,40 +215,13 @@ dependencies = [ "bincode", "cfg-if", "getrandom", - "k256", + "lazy_static", "libm", "once_cell", "rand", "serde", "sha2", - "sp1-precompiles", -] - -[[package]] -name = "spki" -version = "0.7.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d91ed6c858b01f942cd56b37a94b3e0a1798290327d1236e4d9cf4eaca44d29d" -dependencies = [ - "base64ct", - "der", -] - -[[package]] -name = "subtle" -version = "2.5.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "81cdd64d312baedb58e21336b31bc043b77e01cc99033ce76ef539f78e965ebc" - -[[package]] -name = "syn" -version = "1.0.109" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "72b64191b275b66ffe2469e8af2c1cfe3bafa67b529ead792a6d0160888b4237" -dependencies = [ - "proc-macro2", - "quote", - "unicode-ident", + "sp1-lib", ] [[package]] @@ -677,40 +235,6 @@ dependencies = [ "unicode-ident", ] -[[package]] -name = "tap" -version = "1.0.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "55937e1799185b12863d447f42597ed69d9928686b8d88a1df17376a097d8369" - -[[package]] -name = "toml_datetime" -version = "0.6.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7cda73e2f1397b1262d6dfdcef8aafae14d1de7748d66822d3bfeeb6d03e5e4b" - -[[package]] -name = "toml_edit" -version = "0.19.15" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1b5bb770da30e5cbfde35a2d7b9b8a2c4b8ef89548a7a6aeab5c9a576e3e7421" -dependencies = [ - "indexmap", - "toml_datetime", - "winnow", -] - -[[package]] -name = "toml_edit" -version = "0.20.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "396e4d48bbb2b7554c944bde63101b5ae446cff6ec4a24227428f15eb72ef338" -dependencies = [ - "indexmap", - "toml_datetime", - "winnow", -] - [[package]] name = "typenum" version = "1.17.0" @@ -734,27 +258,3 @@ name = "wasi" version = "0.11.0+wasi-snapshot-preview1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "9c8d87e72b64a3b4db28d11ce29237c246188f4f51057d65a7eab63b7987e423" - -[[package]] -name = "winnow" -version = "0.5.40" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f593a95398737aeed53e489c785df13f3618e41dbcd6718c6addbf1395aa6876" -dependencies = [ - "memchr", -] - -[[package]] -name = "wyz" -version = "0.5.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "05f360fc0b24296329c78fda852a1e9ae82de9cf7b27dae4b7f62f118f77b9ed" -dependencies = [ - "tap", -] - -[[package]] -name = "zeroize" -version = "1.7.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "525b4ec142c6b68a2d10f01f7bbf6755599ca3f81ea53b8431b7dd348f5fdb2d" diff --git a/tests/keccak-permute/Cargo.toml b/tests/keccak-permute/Cargo.toml index ce764242b5..1836a61e6a 100644 --- a/tests/keccak-permute/Cargo.toml +++ b/tests/keccak-permute/Cargo.toml @@ -1,8 +1,8 @@ [workspace] [package] -version = "0.1.0" name = "keccak-permute-test" -edition = "2021" +version = "1.0.0-rc.1" +publish = false [dependencies] sp1-zkvm = { path = "../../zkvm/entrypoint" } diff --git a/tests/keccak-permute/elf/riscv32im-succinct-zkvm-elf b/tests/keccak-permute/elf/riscv32im-succinct-zkvm-elf index 15dee99151..598aee937d 100755 Binary files a/tests/keccak-permute/elf/riscv32im-succinct-zkvm-elf and b/tests/keccak-permute/elf/riscv32im-succinct-zkvm-elf differ diff --git a/tests/keccak256/Cargo.lock b/tests/keccak256/Cargo.lock index dc41372bae..e7146242e9 100644 --- a/tests/keccak256/Cargo.lock +++ b/tests/keccak256/Cargo.lock @@ -8,30 +8,6 @@ version = "1.0.86" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "b3d1d046238990b9cf5bcde22a3fb3584ee5cf65fb2765f454ed428c7a0063da" -[[package]] -name = "arrayvec" -version = "0.7.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "96d30a06541fbafbc7f82ed10c06164cfbd2c401138f6addd8404629c4b16711" - -[[package]] -name = "autocfg" -version = "1.2.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f1fdabc7756949593fe60f30ec81974b613357de856987752631dea1e3394c80" - -[[package]] -name = "base16ct" -version = "0.2.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4c7f02d4ea65f2c1853089ffd8d2787bdbc63de2f0d29dedbcf8ccdfa0ccd4cf" - -[[package]] -name = "base64ct" -version = "1.6.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8c3c1a368f70d6cf7302d78f8f7093da241fb8e8807c05cc9e51a125895a6d5b" - [[package]] name = "bincode" version = "1.3.3" @@ -41,18 +17,6 @@ dependencies = [ "serde", ] -[[package]] -name = "bitvec" -version = "1.0.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1bc2832c24239b0141d5674bb9174f9d68a8b5b3f2753311927c172ca46f7e9c" -dependencies = [ - "funty", - "radium", - "tap", - "wyz", -] - [[package]] name = "block-buffer" version = "0.10.4" @@ -62,24 +26,12 @@ dependencies = [ "generic-array", ] -[[package]] -name = "byte-slice-cast" -version = "1.2.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c3ac9f8b63eca6fd385229b3675f6cc0dc5c8a5c8a54a59d4f52ffd670d87b0c" - [[package]] name = "cfg-if" version = "1.0.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "baf1de4339761588bc0619e3cbc0120ee582ebb74b53b4efbf79117bd2da40fd" -[[package]] -name = "const-oid" -version = "0.9.6" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c2459377285ad874054d797f3ccebf984978aa39129f6eafde5cdc8315b612f8" - [[package]] name = "cpufeatures" version = "0.2.12" @@ -95,18 +47,6 @@ version = "0.2.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "7a81dae078cea95a014a339291cec439d2f232ebe854a9d672b796c6afafa9b7" -[[package]] -name = "crypto-bigint" -version = "0.5.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0dc92fb57ca44df6db8059111ab3af99a63d5d0f8375d9972e319a379c6bab76" -dependencies = [ - "generic-array", - "rand_core", - "subtle", - "zeroize", -] - [[package]] name = "crypto-common" version = "0.1.6" @@ -117,27 +57,6 @@ dependencies = [ "typenum", ] -[[package]] -name = "der" -version = "0.7.8" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "fffa369a668c8af7dbf8b5e56c9f744fbd399949ed171606040001947de40b1c" -dependencies = [ - "const-oid", - "zeroize", -] - -[[package]] -name = "derive_more" -version = "0.99.17" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4fb810d30a7c1953f91334de7244731fc3f3c10d7fe163338a35b9f640960321" -dependencies = [ - "proc-macro2", - "quote", - "syn 1.0.109", -] - [[package]] name = "digest" version = "0.10.7" @@ -145,68 +64,9 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "9ed9a281f7bc9b7576e61468ba615a66a5c8cfdff42420a70aa82701a3b1e292" dependencies = [ "block-buffer", - "const-oid", "crypto-common", - "subtle", ] -[[package]] -name = "ecdsa" -version = "0.16.9" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ee27f32b5c5292967d2d4a9d7f1e0b0aed2c15daded5a60300e4abb9d8020bca" -dependencies = [ - "der", - "digest", - "elliptic-curve", - "rfc6979", - "signature", - "spki", -] - -[[package]] -name = "elliptic-curve" -version = "0.13.8" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b5e6043086bf7973472e0c7dff2142ea0b680d30e18d9cc40f267efbf222bd47" -dependencies = [ - "base16ct", - "crypto-bigint", - "digest", - "ff", - "generic-array", - "group", - "pkcs8", - "rand_core", - "sec1", - "subtle", - "tap", - "zeroize", -] - -[[package]] -name = "equivalent" -version = "1.0.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5443807d6dff69373d433ab9ef5378ad8df50ca6298caf15de6e52e24aaf54d5" - -[[package]] -name = "ff" -version = "0.13.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ded41244b729663b1e574f1b4fb731469f69f79c17667b5d776b16cda0479449" -dependencies = [ - "bitvec", - "rand_core", - "subtle", -] - -[[package]] -name = "funty" -version = "2.0.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e6d5a32815ae3f33302d95fdcb2ce17862f8c65363dcfd29360480ba1001fc9c" - [[package]] name = "generic-array" version = "0.14.7" @@ -215,7 +75,6 @@ checksum = "85649ca51fd72272d7821adaf274ad91c288277713d9c18820d8499a7ff69e9a" dependencies = [ "typenum", "version_check", - "zeroize", ] [[package]] @@ -229,73 +88,6 @@ dependencies = [ "wasi", ] -[[package]] -name = "group" -version = "0.13.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f0f9ef7462f7c099f518d754361858f86d8a07af53ba9af0fe635bbccb151a63" -dependencies = [ - "ff", - "rand_core", - "subtle", -] - -[[package]] -name = "hashbrown" -version = "0.14.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "290f1a1d9242c78d09ce40a5e87e7554ee637af1351968159f4952f028f75604" - -[[package]] -name = "hex" -version = "0.4.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7f24254aa9a54b5c858eaee2f5bccdb46aaf0e486a595ed5fd8f86ba55232a70" - -[[package]] -name = "hmac" -version = "0.12.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6c49c37c09c17a53d937dfbb742eb3a961d65a994e6bcdcf37e7399d0cc8ab5e" -dependencies = [ - "digest", -] - -[[package]] -name = "impl-trait-for-tuples" -version = "0.2.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "11d7a9f6330b71fea57921c9b61c47ee6e84f72d394754eff6163ae67e7395eb" -dependencies = [ - "proc-macro2", - "quote", - "syn 1.0.109", -] - -[[package]] -name = "indexmap" -version = "2.2.6" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "168fb715dda47215e360912c096649d23d58bf392ac62f73919e831745e40f26" -dependencies = [ - "equivalent", - "hashbrown", -] - -[[package]] -name = "k256" -version = "0.13.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "956ff9b67e26e1a6a866cb758f12c6f8746208489e3e4a4b5580802f2f0a587b" -dependencies = [ - "cfg-if", - "ecdsa", - "elliptic-curve", - "once_cell", - "sha2", - "signature", -] - [[package]] name = "keccak256-test" version = "0.1.0" @@ -304,6 +96,12 @@ dependencies = [ "tiny-keccak", ] +[[package]] +name = "lazy_static" +version = "1.5.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "bbd2bcb4c963f2ddae06a2efc7e9f3591312473c50c6685e1f298068316e66fe" + [[package]] name = "libc" version = "0.2.155" @@ -316,151 +114,18 @@ version = "0.2.8" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "4ec2a862134d2a7d32d7983ddcdd1c4923530833c9f2ea1a44fc5fa473989058" -[[package]] -name = "memchr" -version = "2.7.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6c8640c5d730cb13ebd907d8d04b52f55ac9a2eec55b440c8892f40d56c76c1d" - -[[package]] -name = "num" -version = "0.4.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "35bd024e8b2ff75562e5f34e7f4905839deb4b22955ef5e73d2fea1b9813cb23" -dependencies = [ - "num-bigint", - "num-complex", - "num-integer", - "num-iter", - "num-rational", - "num-traits", -] - -[[package]] -name = "num-bigint" -version = "0.4.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c165a9ab64cf766f73521c0dd2cfdff64f488b8f0b3e621face3462d3db536d7" -dependencies = [ - "num-integer", - "num-traits", -] - -[[package]] -name = "num-complex" -version = "0.4.6" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "73f88a1307638156682bada9d7604135552957b7818057dcef22705b4d509495" -dependencies = [ - "num-traits", -] - -[[package]] -name = "num-integer" -version = "0.1.46" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7969661fd2958a5cb096e56c8e1ad0444ac2bbcd0061bd28660485a44879858f" -dependencies = [ - "num-traits", -] - -[[package]] -name = "num-iter" -version = "0.1.45" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1429034a0490724d0075ebb2bc9e875d6503c3cf69e235a8941aa757d83ef5bf" -dependencies = [ - "autocfg", - "num-integer", - "num-traits", -] - -[[package]] -name = "num-rational" -version = "0.4.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f83d14da390562dca69fc84082e73e548e1ad308d24accdedd2720017cb37824" -dependencies = [ - "num-bigint", - "num-integer", - "num-traits", -] - -[[package]] -name = "num-traits" -version = "0.2.19" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "071dfc062690e90b734c0b2273ce72ad0ffa95f0c74596bc250dcfd960262841" -dependencies = [ - "autocfg", -] - [[package]] name = "once_cell" version = "1.19.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "3fdb12b2476b595f9358c5161aa467c2438859caa136dec86c26fdd2efe17b92" -[[package]] -name = "parity-scale-codec" -version = "3.6.9" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "881331e34fa842a2fb61cc2db9643a8fedc615e47cfcc52597d1af0db9a7e8fe" -dependencies = [ - "arrayvec", - "byte-slice-cast", - "impl-trait-for-tuples", - "parity-scale-codec-derive", -] - -[[package]] -name = "parity-scale-codec-derive" -version = "3.6.9" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "be30eaf4b0a9fba5336683b38de57bb86d179a35862ba6bfcf57625d006bde5b" -dependencies = [ - "proc-macro-crate 2.0.2", - "proc-macro2", - "quote", - "syn 1.0.109", -] - -[[package]] -name = "pkcs8" -version = "0.10.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f950b2377845cebe5cf8b5165cb3cc1a5e0fa5cfa3e1f7f55707d8fd82e0a7b7" -dependencies = [ - "der", - "spki", -] - [[package]] name = "ppv-lite86" version = "0.2.17" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "5b40af805b3121feab8a3c29f04d8ad262fa8e0561883e7653e024ae4479e6de" -[[package]] -name = "proc-macro-crate" -version = "1.3.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7f4c021e1093a56626774e81216a4ce732a735e5bad4868a03f3ed65ca0c3919" -dependencies = [ - "once_cell", - "toml_edit 0.19.15", -] - -[[package]] -name = "proc-macro-crate" -version = "2.0.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b00f26d3400549137f92511a46ac1cd8ce37cb5598a96d382381458b992a5d24" -dependencies = [ - "toml_datetime", - "toml_edit 0.20.2", -] - [[package]] name = "proc-macro2" version = "1.0.78" @@ -479,12 +144,6 @@ dependencies = [ "proc-macro2", ] -[[package]] -name = "radium" -version = "0.7.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "dc33ff2d4973d518d823d61aa239014831e521c75da58e3df4840d3f47749d09" - [[package]] name = "rand" version = "0.8.5" @@ -515,54 +174,6 @@ dependencies = [ "getrandom", ] -[[package]] -name = "rfc6979" -version = "0.4.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f8dd2a808d456c4a54e300a23e9f5a67e122c3024119acbfd73e3bf664491cb2" -dependencies = [ - "hmac", - "subtle", -] - -[[package]] -name = "scale-info" -version = "2.11.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7c453e59a955f81fb62ee5d596b450383d699f152d350e9d23a0db2adb78e4c0" -dependencies = [ - "cfg-if", - "derive_more", - "parity-scale-codec", - "scale-info-derive", -] - -[[package]] -name = "scale-info-derive" -version = "2.11.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "18cf6c6447f813ef19eb450e985bcce6705f9ce7660db221b59093d15c79c4b7" -dependencies = [ - "proc-macro-crate 1.3.1", - "proc-macro2", - "quote", - "syn 1.0.109", -] - -[[package]] -name = "sec1" -version = "0.7.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d3e97a565f76233a6003f9f5c54be1d9c5bdfa3eccfb189469f11ec4901c47dc" -dependencies = [ - "base16ct", - "der", - "generic-array", - "pkcs8", - "subtle", - "zeroize", -] - [[package]] name = "serde" version = "1.0.203" @@ -580,7 +191,7 @@ checksum = "500cbc0ebeb6f46627f50f3f5811ccf6bf00643be300b4c3eabc0ef55dc5b5ba" dependencies = [ "proc-macro2", "quote", - "syn 2.0.48", + "syn", ] [[package]] @@ -595,39 +206,13 @@ dependencies = [ ] [[package]] -name = "signature" -version = "2.2.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "77549399552de45a898a580c1b41d445bf730df867cc44e6c0233bbc4b8329de" -dependencies = [ - "digest", - "rand_core", -] - -[[package]] -name = "snowbridge-amcl" -version = "1.0.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "460a9ed63cdf03c1b9847e8a12a5f5ba19c4efd5869e4a737e05be25d7c427e5" -dependencies = [ - "parity-scale-codec", - "scale-info", -] - -[[package]] -name = "sp1-precompiles" +name = "sp1-lib" version = "0.1.0" dependencies = [ "anyhow", "bincode", "cfg-if", - "getrandom", - "hex", - "k256", - "num", - "rand", "serde", - "snowbridge-amcl", ] [[package]] @@ -637,40 +222,13 @@ dependencies = [ "bincode", "cfg-if", "getrandom", - "k256", + "lazy_static", "libm", "once_cell", "rand", "serde", "sha2", - "sp1-precompiles", -] - -[[package]] -name = "spki" -version = "0.7.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d91ed6c858b01f942cd56b37a94b3e0a1798290327d1236e4d9cf4eaca44d29d" -dependencies = [ - "base64ct", - "der", -] - -[[package]] -name = "subtle" -version = "2.5.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "81cdd64d312baedb58e21336b31bc043b77e01cc99033ce76ef539f78e965ebc" - -[[package]] -name = "syn" -version = "1.0.109" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "72b64191b275b66ffe2469e8af2c1cfe3bafa67b529ead792a6d0160888b4237" -dependencies = [ - "proc-macro2", - "quote", - "unicode-ident", + "sp1-lib", ] [[package]] @@ -684,12 +242,6 @@ dependencies = [ "unicode-ident", ] -[[package]] -name = "tap" -version = "1.0.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "55937e1799185b12863d447f42597ed69d9928686b8d88a1df17376a097d8369" - [[package]] name = "tiny-keccak" version = "2.0.2" @@ -699,34 +251,6 @@ dependencies = [ "crunchy", ] -[[package]] -name = "toml_datetime" -version = "0.6.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7cda73e2f1397b1262d6dfdcef8aafae14d1de7748d66822d3bfeeb6d03e5e4b" - -[[package]] -name = "toml_edit" -version = "0.19.15" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1b5bb770da30e5cbfde35a2d7b9b8a2c4b8ef89548a7a6aeab5c9a576e3e7421" -dependencies = [ - "indexmap", - "toml_datetime", - "winnow", -] - -[[package]] -name = "toml_edit" -version = "0.20.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "396e4d48bbb2b7554c944bde63101b5ae446cff6ec4a24227428f15eb72ef338" -dependencies = [ - "indexmap", - "toml_datetime", - "winnow", -] - [[package]] name = "typenum" version = "1.17.0" @@ -750,27 +274,3 @@ name = "wasi" version = "0.11.0+wasi-snapshot-preview1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "9c8d87e72b64a3b4db28d11ce29237c246188f4f51057d65a7eab63b7987e423" - -[[package]] -name = "winnow" -version = "0.5.40" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f593a95398737aeed53e489c785df13f3618e41dbcd6718c6addbf1395aa6876" -dependencies = [ - "memchr", -] - -[[package]] -name = "wyz" -version = "0.5.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "05f360fc0b24296329c78fda852a1e9ae82de9cf7b27dae4b7f62f118f77b9ed" -dependencies = [ - "tap", -] - -[[package]] -name = "zeroize" -version = "1.7.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "525b4ec142c6b68a2d10f01f7bbf6755599ca3f81ea53b8431b7dd348f5fdb2d" diff --git a/tests/keccak256/Cargo.toml b/tests/keccak256/Cargo.toml index 679b2a6581..4d6b9d1f40 100644 --- a/tests/keccak256/Cargo.toml +++ b/tests/keccak256/Cargo.toml @@ -1,8 +1,9 @@ [workspace] [package] -version = "0.1.0" name = "keccak256-test" +version = "1.0.0-rc.1" edition = "2021" +publish = false [dependencies] sp1-zkvm = { path = "../../zkvm/entrypoint" } diff --git a/tests/keccak256/elf/riscv32im-succinct-zkvm-elf b/tests/keccak256/elf/riscv32im-succinct-zkvm-elf index 311da32c16..5986157666 100755 Binary files a/tests/keccak256/elf/riscv32im-succinct-zkvm-elf and b/tests/keccak256/elf/riscv32im-succinct-zkvm-elf differ diff --git a/tests/panic/Cargo.lock b/tests/panic/Cargo.lock index 9a09c235c9..67fde20e85 100644 --- a/tests/panic/Cargo.lock +++ b/tests/panic/Cargo.lock @@ -8,30 +8,6 @@ version = "1.0.83" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "25bdb32cbbdce2b519a9cd7df3a678443100e265d5e25ca763b7572a5104f5f3" -[[package]] -name = "arrayvec" -version = "0.7.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "96d30a06541fbafbc7f82ed10c06164cfbd2c401138f6addd8404629c4b16711" - -[[package]] -name = "autocfg" -version = "1.3.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0c4b4d0bd25bd0b74681c0ad21497610ce1b7c91b1022cd21c80c6fbdd9476b0" - -[[package]] -name = "base16ct" -version = "0.2.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4c7f02d4ea65f2c1853089ffd8d2787bdbc63de2f0d29dedbcf8ccdfa0ccd4cf" - -[[package]] -name = "base64ct" -version = "1.6.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8c3c1a368f70d6cf7302d78f8f7093da241fb8e8807c05cc9e51a125895a6d5b" - [[package]] name = "bincode" version = "1.3.3" @@ -41,18 +17,6 @@ dependencies = [ "serde", ] -[[package]] -name = "bitvec" -version = "1.0.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1bc2832c24239b0141d5674bb9174f9d68a8b5b3f2753311927c172ca46f7e9c" -dependencies = [ - "funty", - "radium", - "tap", - "wyz", -] - [[package]] name = "block-buffer" version = "0.10.4" @@ -62,24 +26,12 @@ dependencies = [ "generic-array", ] -[[package]] -name = "byte-slice-cast" -version = "1.2.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c3ac9f8b63eca6fd385229b3675f6cc0dc5c8a5c8a54a59d4f52ffd670d87b0c" - [[package]] name = "cfg-if" version = "1.0.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "baf1de4339761588bc0619e3cbc0120ee582ebb74b53b4efbf79117bd2da40fd" -[[package]] -name = "const-oid" -version = "0.9.6" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c2459377285ad874054d797f3ccebf984978aa39129f6eafde5cdc8315b612f8" - [[package]] name = "cpufeatures" version = "0.2.12" @@ -89,18 +41,6 @@ dependencies = [ "libc", ] -[[package]] -name = "crypto-bigint" -version = "0.5.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0dc92fb57ca44df6db8059111ab3af99a63d5d0f8375d9972e319a379c6bab76" -dependencies = [ - "generic-array", - "rand_core", - "subtle", - "zeroize", -] - [[package]] name = "crypto-common" version = "0.1.6" @@ -111,27 +51,6 @@ dependencies = [ "typenum", ] -[[package]] -name = "der" -version = "0.7.9" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f55bf8e7b65898637379c1b74eb1551107c8294ed26d855ceb9fd1a09cfc9bc0" -dependencies = [ - "const-oid", - "zeroize", -] - -[[package]] -name = "derive_more" -version = "0.99.17" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4fb810d30a7c1953f91334de7244731fc3f3c10d7fe163338a35b9f640960321" -dependencies = [ - "proc-macro2", - "quote", - "syn 1.0.109", -] - [[package]] name = "digest" version = "0.10.7" @@ -139,68 +58,9 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "9ed9a281f7bc9b7576e61468ba615a66a5c8cfdff42420a70aa82701a3b1e292" dependencies = [ "block-buffer", - "const-oid", "crypto-common", - "subtle", -] - -[[package]] -name = "ecdsa" -version = "0.16.9" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ee27f32b5c5292967d2d4a9d7f1e0b0aed2c15daded5a60300e4abb9d8020bca" -dependencies = [ - "der", - "digest", - "elliptic-curve", - "rfc6979", - "signature", - "spki", -] - -[[package]] -name = "elliptic-curve" -version = "0.13.8" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b5e6043086bf7973472e0c7dff2142ea0b680d30e18d9cc40f267efbf222bd47" -dependencies = [ - "base16ct", - "crypto-bigint", - "digest", - "ff", - "generic-array", - "group", - "pkcs8", - "rand_core", - "sec1", - "subtle", - "tap", - "zeroize", -] - -[[package]] -name = "equivalent" -version = "1.0.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5443807d6dff69373d433ab9ef5378ad8df50ca6298caf15de6e52e24aaf54d5" - -[[package]] -name = "ff" -version = "0.13.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ded41244b729663b1e574f1b4fb731469f69f79c17667b5d776b16cda0479449" -dependencies = [ - "bitvec", - "rand_core", - "subtle", ] -[[package]] -name = "funty" -version = "2.0.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e6d5a32815ae3f33302d95fdcb2ce17862f8c65363dcfd29360480ba1001fc9c" - [[package]] name = "generic-array" version = "0.14.7" @@ -209,7 +69,6 @@ checksum = "85649ca51fd72272d7821adaf274ad91c288277713d9c18820d8499a7ff69e9a" dependencies = [ "typenum", "version_check", - "zeroize", ] [[package]] @@ -224,71 +83,10 @@ dependencies = [ ] [[package]] -name = "group" -version = "0.13.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f0f9ef7462f7c099f518d754361858f86d8a07af53ba9af0fe635bbccb151a63" -dependencies = [ - "ff", - "rand_core", - "subtle", -] - -[[package]] -name = "hashbrown" -version = "0.14.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e5274423e17b7c9fc20b6e7e208532f9b19825d82dfd615708b70edd83df41f1" - -[[package]] -name = "hex" -version = "0.4.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7f24254aa9a54b5c858eaee2f5bccdb46aaf0e486a595ed5fd8f86ba55232a70" - -[[package]] -name = "hmac" -version = "0.12.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6c49c37c09c17a53d937dfbb742eb3a961d65a994e6bcdcf37e7399d0cc8ab5e" -dependencies = [ - "digest", -] - -[[package]] -name = "impl-trait-for-tuples" -version = "0.2.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "11d7a9f6330b71fea57921c9b61c47ee6e84f72d394754eff6163ae67e7395eb" -dependencies = [ - "proc-macro2", - "quote", - "syn 1.0.109", -] - -[[package]] -name = "indexmap" -version = "2.2.6" +name = "lazy_static" +version = "1.5.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "168fb715dda47215e360912c096649d23d58bf392ac62f73919e831745e40f26" -dependencies = [ - "equivalent", - "hashbrown", -] - -[[package]] -name = "k256" -version = "0.13.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "956ff9b67e26e1a6a866cb758f12c6f8746208489e3e4a4b5580802f2f0a587b" -dependencies = [ - "cfg-if", - "ecdsa", - "elliptic-curve", - "once_cell", - "sha2", - "signature", -] +checksum = "bbd2bcb4c963f2ddae06a2efc7e9f3591312473c50c6685e1f298068316e66fe" [[package]] name = "libc" @@ -302,85 +100,6 @@ version = "0.2.8" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "4ec2a862134d2a7d32d7983ddcdd1c4923530833c9f2ea1a44fc5fa473989058" -[[package]] -name = "memchr" -version = "2.7.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6c8640c5d730cb13ebd907d8d04b52f55ac9a2eec55b440c8892f40d56c76c1d" - -[[package]] -name = "num" -version = "0.4.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "35bd024e8b2ff75562e5f34e7f4905839deb4b22955ef5e73d2fea1b9813cb23" -dependencies = [ - "num-bigint", - "num-complex", - "num-integer", - "num-iter", - "num-rational", - "num-traits", -] - -[[package]] -name = "num-bigint" -version = "0.4.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c165a9ab64cf766f73521c0dd2cfdff64f488b8f0b3e621face3462d3db536d7" -dependencies = [ - "num-integer", - "num-traits", -] - -[[package]] -name = "num-complex" -version = "0.4.6" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "73f88a1307638156682bada9d7604135552957b7818057dcef22705b4d509495" -dependencies = [ - "num-traits", -] - -[[package]] -name = "num-integer" -version = "0.1.46" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7969661fd2958a5cb096e56c8e1ad0444ac2bbcd0061bd28660485a44879858f" -dependencies = [ - "num-traits", -] - -[[package]] -name = "num-iter" -version = "0.1.45" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1429034a0490724d0075ebb2bc9e875d6503c3cf69e235a8941aa757d83ef5bf" -dependencies = [ - "autocfg", - "num-integer", - "num-traits", -] - -[[package]] -name = "num-rational" -version = "0.4.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f83d14da390562dca69fc84082e73e548e1ad308d24accdedd2720017cb37824" -dependencies = [ - "num-bigint", - "num-integer", - "num-traits", -] - -[[package]] -name = "num-traits" -version = "0.2.19" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "071dfc062690e90b734c0b2273ce72ad0ffa95f0c74596bc250dcfd960262841" -dependencies = [ - "autocfg", -] - [[package]] name = "once_cell" version = "1.19.0" @@ -395,55 +114,12 @@ dependencies = [ "sp1-zkvm", ] -[[package]] -name = "parity-scale-codec" -version = "3.6.12" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "306800abfa29c7f16596b5970a588435e3d5b3149683d00c12b699cc19f895ee" -dependencies = [ - "arrayvec", - "byte-slice-cast", - "impl-trait-for-tuples", - "parity-scale-codec-derive", -] - -[[package]] -name = "parity-scale-codec-derive" -version = "3.6.12" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d830939c76d294956402033aee57a6da7b438f2294eb94864c37b0569053a42c" -dependencies = [ - "proc-macro-crate", - "proc-macro2", - "quote", - "syn 1.0.109", -] - -[[package]] -name = "pkcs8" -version = "0.10.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f950b2377845cebe5cf8b5165cb3cc1a5e0fa5cfa3e1f7f55707d8fd82e0a7b7" -dependencies = [ - "der", - "spki", -] - [[package]] name = "ppv-lite86" version = "0.2.17" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "5b40af805b3121feab8a3c29f04d8ad262fa8e0561883e7653e024ae4479e6de" -[[package]] -name = "proc-macro-crate" -version = "3.1.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6d37c51ca738a55da99dc0c4a34860fd675453b8b36209178c2249bb13651284" -dependencies = [ - "toml_edit", -] - [[package]] name = "proc-macro2" version = "1.0.82" @@ -462,12 +138,6 @@ dependencies = [ "proc-macro2", ] -[[package]] -name = "radium" -version = "0.7.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "dc33ff2d4973d518d823d61aa239014831e521c75da58e3df4840d3f47749d09" - [[package]] name = "rand" version = "0.8.5" @@ -498,54 +168,6 @@ dependencies = [ "getrandom", ] -[[package]] -name = "rfc6979" -version = "0.4.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f8dd2a808d456c4a54e300a23e9f5a67e122c3024119acbfd73e3bf664491cb2" -dependencies = [ - "hmac", - "subtle", -] - -[[package]] -name = "scale-info" -version = "2.11.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "eca070c12893629e2cc820a9761bedf6ce1dcddc9852984d1dc734b8bd9bd024" -dependencies = [ - "cfg-if", - "derive_more", - "parity-scale-codec", - "scale-info-derive", -] - -[[package]] -name = "scale-info-derive" -version = "2.11.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2d35494501194174bda522a32605929eefc9ecf7e0a326c26db1fdd85881eb62" -dependencies = [ - "proc-macro-crate", - "proc-macro2", - "quote", - "syn 1.0.109", -] - -[[package]] -name = "sec1" -version = "0.7.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d3e97a565f76233a6003f9f5c54be1d9c5bdfa3eccfb189469f11ec4901c47dc" -dependencies = [ - "base16ct", - "der", - "generic-array", - "pkcs8", - "subtle", - "zeroize", -] - [[package]] name = "serde" version = "1.0.201" @@ -577,26 +199,6 @@ dependencies = [ "digest", ] -[[package]] -name = "signature" -version = "2.2.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "77549399552de45a898a580c1b41d445bf730df867cc44e6c0233bbc4b8329de" -dependencies = [ - "digest", - "rand_core", -] - -[[package]] -name = "snowbridge-amcl" -version = "1.0.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "460a9ed63cdf03c1b9847e8a12a5f5ba19c4efd5869e4a737e05be25d7c427e5" -dependencies = [ - "parity-scale-codec", - "scale-info", -] - [[package]] name = "sp1-derive" version = "0.1.0" @@ -607,19 +209,13 @@ dependencies = [ ] [[package]] -name = "sp1-precompiles" +name = "sp1-lib" version = "0.1.0" dependencies = [ "anyhow", "bincode", "cfg-if", - "getrandom", - "hex", - "k256", - "num", - "rand", "serde", - "snowbridge-amcl", ] [[package]] @@ -629,31 +225,15 @@ dependencies = [ "bincode", "cfg-if", "getrandom", - "k256", + "lazy_static", "libm", "once_cell", "rand", "serde", "sha2", - "sp1-precompiles", -] - -[[package]] -name = "spki" -version = "0.7.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d91ed6c858b01f942cd56b37a94b3e0a1798290327d1236e4d9cf4eaca44d29d" -dependencies = [ - "base64ct", - "der", + "sp1-lib", ] -[[package]] -name = "subtle" -version = "2.5.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "81cdd64d312baedb58e21336b31bc043b77e01cc99033ce76ef539f78e965ebc" - [[package]] name = "syn" version = "1.0.109" @@ -676,29 +256,6 @@ dependencies = [ "unicode-ident", ] -[[package]] -name = "tap" -version = "1.0.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "55937e1799185b12863d447f42597ed69d9928686b8d88a1df17376a097d8369" - -[[package]] -name = "toml_datetime" -version = "0.6.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3550f4e9685620ac18a50ed434eb3aec30db8ba93b0287467bca5826ea25baf1" - -[[package]] -name = "toml_edit" -version = "0.21.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6a8534fd7f78b5405e860340ad6575217ce99f38d4d5c8f2442cb5ecb50090e1" -dependencies = [ - "indexmap", - "toml_datetime", - "winnow", -] - [[package]] name = "typenum" version = "1.17.0" @@ -722,27 +279,3 @@ name = "wasi" version = "0.11.0+wasi-snapshot-preview1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "9c8d87e72b64a3b4db28d11ce29237c246188f4f51057d65a7eab63b7987e423" - -[[package]] -name = "winnow" -version = "0.5.40" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f593a95398737aeed53e489c785df13f3618e41dbcd6718c6addbf1395aa6876" -dependencies = [ - "memchr", -] - -[[package]] -name = "wyz" -version = "0.5.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "05f360fc0b24296329c78fda852a1e9ae82de9cf7b27dae4b7f62f118f77b9ed" -dependencies = [ - "tap", -] - -[[package]] -name = "zeroize" -version = "1.7.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "525b4ec142c6b68a2d10f01f7bbf6755599ca3f81ea53b8431b7dd348f5fdb2d" diff --git a/tests/panic/Cargo.toml b/tests/panic/Cargo.toml index c81641abb9..73408f84e5 100644 --- a/tests/panic/Cargo.toml +++ b/tests/panic/Cargo.toml @@ -1,8 +1,9 @@ [workspace] [package] name = "panic-test" -version = "0.1.0" +version = "1.0.0-rc.1" edition = "2021" +publish = false [dependencies] sp1-zkvm = { path = "../../zkvm/entrypoint" } diff --git a/tests/panic/elf/riscv32im-succinct-zkvm-elf b/tests/panic/elf/riscv32im-succinct-zkvm-elf index 8debb2189a..befb17540d 100755 Binary files a/tests/panic/elf/riscv32im-succinct-zkvm-elf and b/tests/panic/elf/riscv32im-succinct-zkvm-elf differ diff --git a/tests/rand/Cargo.lock b/tests/rand/Cargo.lock index 6811bed258..49c6428705 100644 --- a/tests/rand/Cargo.lock +++ b/tests/rand/Cargo.lock @@ -8,30 +8,6 @@ version = "1.0.83" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "25bdb32cbbdce2b519a9cd7df3a678443100e265d5e25ca763b7572a5104f5f3" -[[package]] -name = "arrayvec" -version = "0.7.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "96d30a06541fbafbc7f82ed10c06164cfbd2c401138f6addd8404629c4b16711" - -[[package]] -name = "autocfg" -version = "1.3.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0c4b4d0bd25bd0b74681c0ad21497610ce1b7c91b1022cd21c80c6fbdd9476b0" - -[[package]] -name = "base16ct" -version = "0.2.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4c7f02d4ea65f2c1853089ffd8d2787bdbc63de2f0d29dedbcf8ccdfa0ccd4cf" - -[[package]] -name = "base64ct" -version = "1.6.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8c3c1a368f70d6cf7302d78f8f7093da241fb8e8807c05cc9e51a125895a6d5b" - [[package]] name = "bincode" version = "1.3.3" @@ -41,18 +17,6 @@ dependencies = [ "serde", ] -[[package]] -name = "bitvec" -version = "1.0.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1bc2832c24239b0141d5674bb9174f9d68a8b5b3f2753311927c172ca46f7e9c" -dependencies = [ - "funty", - "radium", - "tap", - "wyz", -] - [[package]] name = "block-buffer" version = "0.10.4" @@ -62,24 +26,12 @@ dependencies = [ "generic-array", ] -[[package]] -name = "byte-slice-cast" -version = "1.2.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c3ac9f8b63eca6fd385229b3675f6cc0dc5c8a5c8a54a59d4f52ffd670d87b0c" - [[package]] name = "cfg-if" version = "1.0.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "baf1de4339761588bc0619e3cbc0120ee582ebb74b53b4efbf79117bd2da40fd" -[[package]] -name = "const-oid" -version = "0.9.6" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c2459377285ad874054d797f3ccebf984978aa39129f6eafde5cdc8315b612f8" - [[package]] name = "cpufeatures" version = "0.2.12" @@ -89,18 +41,6 @@ dependencies = [ "libc", ] -[[package]] -name = "crypto-bigint" -version = "0.5.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0dc92fb57ca44df6db8059111ab3af99a63d5d0f8375d9972e319a379c6bab76" -dependencies = [ - "generic-array", - "rand_core", - "subtle", - "zeroize", -] - [[package]] name = "crypto-common" version = "0.1.6" @@ -111,27 +51,6 @@ dependencies = [ "typenum", ] -[[package]] -name = "der" -version = "0.7.9" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f55bf8e7b65898637379c1b74eb1551107c8294ed26d855ceb9fd1a09cfc9bc0" -dependencies = [ - "const-oid", - "zeroize", -] - -[[package]] -name = "derive_more" -version = "0.99.17" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4fb810d30a7c1953f91334de7244731fc3f3c10d7fe163338a35b9f640960321" -dependencies = [ - "proc-macro2", - "quote", - "syn 1.0.109", -] - [[package]] name = "digest" version = "0.10.7" @@ -139,68 +58,9 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "9ed9a281f7bc9b7576e61468ba615a66a5c8cfdff42420a70aa82701a3b1e292" dependencies = [ "block-buffer", - "const-oid", "crypto-common", - "subtle", -] - -[[package]] -name = "ecdsa" -version = "0.16.9" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ee27f32b5c5292967d2d4a9d7f1e0b0aed2c15daded5a60300e4abb9d8020bca" -dependencies = [ - "der", - "digest", - "elliptic-curve", - "rfc6979", - "signature", - "spki", -] - -[[package]] -name = "elliptic-curve" -version = "0.13.8" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b5e6043086bf7973472e0c7dff2142ea0b680d30e18d9cc40f267efbf222bd47" -dependencies = [ - "base16ct", - "crypto-bigint", - "digest", - "ff", - "generic-array", - "group", - "pkcs8", - "rand_core", - "sec1", - "subtle", - "tap", - "zeroize", -] - -[[package]] -name = "equivalent" -version = "1.0.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5443807d6dff69373d433ab9ef5378ad8df50ca6298caf15de6e52e24aaf54d5" - -[[package]] -name = "ff" -version = "0.13.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ded41244b729663b1e574f1b4fb731469f69f79c17667b5d776b16cda0479449" -dependencies = [ - "bitvec", - "rand_core", - "subtle", ] -[[package]] -name = "funty" -version = "2.0.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e6d5a32815ae3f33302d95fdcb2ce17862f8c65363dcfd29360480ba1001fc9c" - [[package]] name = "generic-array" version = "0.14.7" @@ -209,7 +69,6 @@ checksum = "85649ca51fd72272d7821adaf274ad91c288277713d9c18820d8499a7ff69e9a" dependencies = [ "typenum", "version_check", - "zeroize", ] [[package]] @@ -223,78 +82,11 @@ dependencies = [ "wasi", ] -[[package]] -name = "group" -version = "0.13.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f0f9ef7462f7c099f518d754361858f86d8a07af53ba9af0fe635bbccb151a63" -dependencies = [ - "ff", - "rand_core", - "subtle", -] - -[[package]] -name = "hashbrown" -version = "0.14.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e5274423e17b7c9fc20b6e7e208532f9b19825d82dfd615708b70edd83df41f1" - -[[package]] -name = "hex" -version = "0.4.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7f24254aa9a54b5c858eaee2f5bccdb46aaf0e486a595ed5fd8f86ba55232a70" - -[[package]] -name = "hmac" -version = "0.12.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6c49c37c09c17a53d937dfbb742eb3a961d65a994e6bcdcf37e7399d0cc8ab5e" -dependencies = [ - "digest", -] - -[[package]] -name = "impl-trait-for-tuples" -version = "0.2.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "11d7a9f6330b71fea57921c9b61c47ee6e84f72d394754eff6163ae67e7395eb" -dependencies = [ - "proc-macro2", - "quote", - "syn 1.0.109", -] - -[[package]] -name = "indexmap" -version = "2.2.6" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "168fb715dda47215e360912c096649d23d58bf392ac62f73919e831745e40f26" -dependencies = [ - "equivalent", - "hashbrown", -] - -[[package]] -name = "k256" -version = "0.13.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "956ff9b67e26e1a6a866cb758f12c6f8746208489e3e4a4b5580802f2f0a587b" -dependencies = [ - "cfg-if", - "ecdsa", - "elliptic-curve", - "once_cell", - "sha2", - "signature", -] - [[package]] name = "lazy_static" -version = "1.4.0" +version = "1.5.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e2abad23fbc42b3700f2f279844dc832adb2b2eb069b2df918f455c4e18cc646" +checksum = "bbd2bcb4c963f2ddae06a2efc7e9f3591312473c50c6685e1f298068316e66fe" [[package]] name = "libc" @@ -308,140 +100,18 @@ version = "0.2.8" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "4ec2a862134d2a7d32d7983ddcdd1c4923530833c9f2ea1a44fc5fa473989058" -[[package]] -name = "memchr" -version = "2.7.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6c8640c5d730cb13ebd907d8d04b52f55ac9a2eec55b440c8892f40d56c76c1d" - -[[package]] -name = "num" -version = "0.4.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "35bd024e8b2ff75562e5f34e7f4905839deb4b22955ef5e73d2fea1b9813cb23" -dependencies = [ - "num-bigint", - "num-complex", - "num-integer", - "num-iter", - "num-rational", - "num-traits", -] - -[[package]] -name = "num-bigint" -version = "0.4.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c165a9ab64cf766f73521c0dd2cfdff64f488b8f0b3e621face3462d3db536d7" -dependencies = [ - "num-integer", - "num-traits", -] - -[[package]] -name = "num-complex" -version = "0.4.6" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "73f88a1307638156682bada9d7604135552957b7818057dcef22705b4d509495" -dependencies = [ - "num-traits", -] - -[[package]] -name = "num-integer" -version = "0.1.46" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7969661fd2958a5cb096e56c8e1ad0444ac2bbcd0061bd28660485a44879858f" -dependencies = [ - "num-traits", -] - -[[package]] -name = "num-iter" -version = "0.1.45" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1429034a0490724d0075ebb2bc9e875d6503c3cf69e235a8941aa757d83ef5bf" -dependencies = [ - "autocfg", - "num-integer", - "num-traits", -] - -[[package]] -name = "num-rational" -version = "0.4.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f83d14da390562dca69fc84082e73e548e1ad308d24accdedd2720017cb37824" -dependencies = [ - "num-bigint", - "num-integer", - "num-traits", -] - -[[package]] -name = "num-traits" -version = "0.2.19" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "071dfc062690e90b734c0b2273ce72ad0ffa95f0c74596bc250dcfd960262841" -dependencies = [ - "autocfg", -] - [[package]] name = "once_cell" version = "1.19.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "3fdb12b2476b595f9358c5161aa467c2438859caa136dec86c26fdd2efe17b92" -[[package]] -name = "parity-scale-codec" -version = "3.6.12" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "306800abfa29c7f16596b5970a588435e3d5b3149683d00c12b699cc19f895ee" -dependencies = [ - "arrayvec", - "byte-slice-cast", - "impl-trait-for-tuples", - "parity-scale-codec-derive", -] - -[[package]] -name = "parity-scale-codec-derive" -version = "3.6.12" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d830939c76d294956402033aee57a6da7b438f2294eb94864c37b0569053a42c" -dependencies = [ - "proc-macro-crate", - "proc-macro2", - "quote", - "syn 1.0.109", -] - -[[package]] -name = "pkcs8" -version = "0.10.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f950b2377845cebe5cf8b5165cb3cc1a5e0fa5cfa3e1f7f55707d8fd82e0a7b7" -dependencies = [ - "der", - "spki", -] - [[package]] name = "ppv-lite86" version = "0.2.17" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "5b40af805b3121feab8a3c29f04d8ad262fa8e0561883e7653e024ae4479e6de" -[[package]] -name = "proc-macro-crate" -version = "3.1.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6d37c51ca738a55da99dc0c4a34860fd675453b8b36209178c2249bb13651284" -dependencies = [ - "toml_edit", -] - [[package]] name = "proc-macro2" version = "1.0.82" @@ -460,12 +130,6 @@ dependencies = [ "proc-macro2", ] -[[package]] -name = "radium" -version = "0.7.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "dc33ff2d4973d518d823d61aa239014831e521c75da58e3df4840d3f47749d09" - [[package]] name = "rand" version = "0.8.5" @@ -505,54 +169,6 @@ dependencies = [ "getrandom", ] -[[package]] -name = "rfc6979" -version = "0.4.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f8dd2a808d456c4a54e300a23e9f5a67e122c3024119acbfd73e3bf664491cb2" -dependencies = [ - "hmac", - "subtle", -] - -[[package]] -name = "scale-info" -version = "2.11.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "eca070c12893629e2cc820a9761bedf6ce1dcddc9852984d1dc734b8bd9bd024" -dependencies = [ - "cfg-if", - "derive_more", - "parity-scale-codec", - "scale-info-derive", -] - -[[package]] -name = "scale-info-derive" -version = "2.11.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2d35494501194174bda522a32605929eefc9ecf7e0a326c26db1fdd85881eb62" -dependencies = [ - "proc-macro-crate", - "proc-macro2", - "quote", - "syn 1.0.109", -] - -[[package]] -name = "sec1" -version = "0.7.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d3e97a565f76233a6003f9f5c54be1d9c5bdfa3eccfb189469f11ec4901c47dc" -dependencies = [ - "base16ct", - "der", - "generic-array", - "pkcs8", - "subtle", - "zeroize", -] - [[package]] name = "serde" version = "1.0.201" @@ -584,26 +200,6 @@ dependencies = [ "digest", ] -[[package]] -name = "signature" -version = "2.2.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "77549399552de45a898a580c1b41d445bf730df867cc44e6c0233bbc4b8329de" -dependencies = [ - "digest", - "rand_core", -] - -[[package]] -name = "snowbridge-amcl" -version = "1.0.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "460a9ed63cdf03c1b9847e8a12a5f5ba19c4efd5869e4a737e05be25d7c427e5" -dependencies = [ - "parity-scale-codec", - "scale-info", -] - [[package]] name = "sp1-derive" version = "0.1.0" @@ -614,19 +210,13 @@ dependencies = [ ] [[package]] -name = "sp1-precompiles" +name = "sp1-lib" version = "0.1.0" dependencies = [ "anyhow", "bincode", "cfg-if", - "getrandom", - "hex", - "k256", - "num", - "rand", "serde", - "snowbridge-amcl", ] [[package]] @@ -636,32 +226,15 @@ dependencies = [ "bincode", "cfg-if", "getrandom", - "k256", "lazy_static", "libm", "once_cell", "rand", "serde", "sha2", - "sp1-precompiles", -] - -[[package]] -name = "spki" -version = "0.7.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d91ed6c858b01f942cd56b37a94b3e0a1798290327d1236e4d9cf4eaca44d29d" -dependencies = [ - "base64ct", - "der", + "sp1-lib", ] -[[package]] -name = "subtle" -version = "2.5.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "81cdd64d312baedb58e21336b31bc043b77e01cc99033ce76ef539f78e965ebc" - [[package]] name = "syn" version = "1.0.109" @@ -684,29 +257,6 @@ dependencies = [ "unicode-ident", ] -[[package]] -name = "tap" -version = "1.0.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "55937e1799185b12863d447f42597ed69d9928686b8d88a1df17376a097d8369" - -[[package]] -name = "toml_datetime" -version = "0.6.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3550f4e9685620ac18a50ed434eb3aec30db8ba93b0287467bca5826ea25baf1" - -[[package]] -name = "toml_edit" -version = "0.21.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6a8534fd7f78b5405e860340ad6575217ce99f38d4d5c8f2442cb5ecb50090e1" -dependencies = [ - "indexmap", - "toml_datetime", - "winnow", -] - [[package]] name = "typenum" version = "1.17.0" @@ -730,27 +280,3 @@ name = "wasi" version = "0.11.0+wasi-snapshot-preview1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "9c8d87e72b64a3b4db28d11ce29237c246188f4f51057d65a7eab63b7987e423" - -[[package]] -name = "winnow" -version = "0.5.40" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f593a95398737aeed53e489c785df13f3618e41dbcd6718c6addbf1395aa6876" -dependencies = [ - "memchr", -] - -[[package]] -name = "wyz" -version = "0.5.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "05f360fc0b24296329c78fda852a1e9ae82de9cf7b27dae4b7f62f118f77b9ed" -dependencies = [ - "tap", -] - -[[package]] -name = "zeroize" -version = "1.7.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "525b4ec142c6b68a2d10f01f7bbf6755599ca3f81ea53b8431b7dd348f5fdb2d" diff --git a/tests/rand/Cargo.toml b/tests/rand/Cargo.toml index 2ada8cf376..d37f14d2e7 100644 --- a/tests/rand/Cargo.toml +++ b/tests/rand/Cargo.toml @@ -1,8 +1,9 @@ [workspace] [package] name = "rand-test" -version = "0.1.0" +version = "1.0.0-rc.1" edition = "2021" +publish = false [dependencies] sp1-zkvm = { path = "../../zkvm/entrypoint" } diff --git a/tests/rand/elf/riscv32im-succinct-zkvm-elf b/tests/rand/elf/riscv32im-succinct-zkvm-elf index f5ddaebdc2..54fc4a8714 100755 Binary files a/tests/rand/elf/riscv32im-succinct-zkvm-elf and b/tests/rand/elf/riscv32im-succinct-zkvm-elf differ diff --git a/tests/secp256k1-add/Cargo.lock b/tests/secp256k1-add/Cargo.lock index 2f10d263b1..055cdb9e24 100644 --- a/tests/secp256k1-add/Cargo.lock +++ b/tests/secp256k1-add/Cargo.lock @@ -8,30 +8,12 @@ version = "1.0.86" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "b3d1d046238990b9cf5bcde22a3fb3584ee5cf65fb2765f454ed428c7a0063da" -[[package]] -name = "arrayvec" -version = "0.7.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "96d30a06541fbafbc7f82ed10c06164cfbd2c401138f6addd8404629c4b16711" - [[package]] name = "autocfg" version = "1.2.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "f1fdabc7756949593fe60f30ec81974b613357de856987752631dea1e3394c80" -[[package]] -name = "base16ct" -version = "0.2.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4c7f02d4ea65f2c1853089ffd8d2787bdbc63de2f0d29dedbcf8ccdfa0ccd4cf" - -[[package]] -name = "base64ct" -version = "1.6.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8c3c1a368f70d6cf7302d78f8f7093da241fb8e8807c05cc9e51a125895a6d5b" - [[package]] name = "bincode" version = "1.3.3" @@ -41,18 +23,6 @@ dependencies = [ "serde", ] -[[package]] -name = "bitvec" -version = "1.0.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1bc2832c24239b0141d5674bb9174f9d68a8b5b3f2753311927c172ca46f7e9c" -dependencies = [ - "funty", - "radium", - "tap", - "wyz", -] - [[package]] name = "block-buffer" version = "0.10.4" @@ -62,24 +32,12 @@ dependencies = [ "generic-array", ] -[[package]] -name = "byte-slice-cast" -version = "1.2.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c3ac9f8b63eca6fd385229b3675f6cc0dc5c8a5c8a54a59d4f52ffd670d87b0c" - [[package]] name = "cfg-if" version = "1.0.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "baf1de4339761588bc0619e3cbc0120ee582ebb74b53b4efbf79117bd2da40fd" -[[package]] -name = "const-oid" -version = "0.9.6" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c2459377285ad874054d797f3ccebf984978aa39129f6eafde5cdc8315b612f8" - [[package]] name = "cpufeatures" version = "0.2.12" @@ -89,18 +47,6 @@ dependencies = [ "libc", ] -[[package]] -name = "crypto-bigint" -version = "0.5.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0dc92fb57ca44df6db8059111ab3af99a63d5d0f8375d9972e319a379c6bab76" -dependencies = [ - "generic-array", - "rand_core", - "subtle", - "zeroize", -] - [[package]] name = "crypto-common" version = "0.1.6" @@ -111,27 +57,6 @@ dependencies = [ "typenum", ] -[[package]] -name = "der" -version = "0.7.9" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f55bf8e7b65898637379c1b74eb1551107c8294ed26d855ceb9fd1a09cfc9bc0" -dependencies = [ - "const-oid", - "zeroize", -] - -[[package]] -name = "derive_more" -version = "0.99.17" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4fb810d30a7c1953f91334de7244731fc3f3c10d7fe163338a35b9f640960321" -dependencies = [ - "proc-macro2", - "quote", - "syn 1.0.109", -] - [[package]] name = "digest" version = "0.10.7" @@ -139,68 +64,9 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "9ed9a281f7bc9b7576e61468ba615a66a5c8cfdff42420a70aa82701a3b1e292" dependencies = [ "block-buffer", - "const-oid", "crypto-common", - "subtle", -] - -[[package]] -name = "ecdsa" -version = "0.16.9" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ee27f32b5c5292967d2d4a9d7f1e0b0aed2c15daded5a60300e4abb9d8020bca" -dependencies = [ - "der", - "digest", - "elliptic-curve", - "rfc6979", - "signature", - "spki", -] - -[[package]] -name = "elliptic-curve" -version = "0.13.8" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b5e6043086bf7973472e0c7dff2142ea0b680d30e18d9cc40f267efbf222bd47" -dependencies = [ - "base16ct", - "crypto-bigint", - "digest", - "ff", - "generic-array", - "group", - "pkcs8", - "rand_core", - "sec1", - "subtle", - "tap", - "zeroize", -] - -[[package]] -name = "equivalent" -version = "1.0.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5443807d6dff69373d433ab9ef5378ad8df50ca6298caf15de6e52e24aaf54d5" - -[[package]] -name = "ff" -version = "0.13.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ded41244b729663b1e574f1b4fb731469f69f79c17667b5d776b16cda0479449" -dependencies = [ - "bitvec", - "rand_core", - "subtle", ] -[[package]] -name = "funty" -version = "2.0.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e6d5a32815ae3f33302d95fdcb2ce17862f8c65363dcfd29360480ba1001fc9c" - [[package]] name = "generic-array" version = "0.14.7" @@ -209,7 +75,6 @@ checksum = "85649ca51fd72272d7821adaf274ad91c288277713d9c18820d8499a7ff69e9a" dependencies = [ "typenum", "version_check", - "zeroize", ] [[package]] @@ -223,29 +88,6 @@ dependencies = [ "wasi", ] -[[package]] -name = "group" -version = "0.13.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f0f9ef7462f7c099f518d754361858f86d8a07af53ba9af0fe635bbccb151a63" -dependencies = [ - "ff", - "rand_core", - "subtle", -] - -[[package]] -name = "hashbrown" -version = "0.14.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "290f1a1d9242c78d09ce40a5e87e7554ee637af1351968159f4952f028f75604" - -[[package]] -name = "hex" -version = "0.4.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7f24254aa9a54b5c858eaee2f5bccdb46aaf0e486a595ed5fd8f86ba55232a70" - [[package]] name = "hex-literal" version = "0.4.1" @@ -253,48 +95,10 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "6fe2267d4ed49bc07b63801559be28c718ea06c4738b7a03c94df7386d2cde46" [[package]] -name = "hmac" -version = "0.12.1" +name = "lazy_static" +version = "1.5.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6c49c37c09c17a53d937dfbb742eb3a961d65a994e6bcdcf37e7399d0cc8ab5e" -dependencies = [ - "digest", -] - -[[package]] -name = "impl-trait-for-tuples" -version = "0.2.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "11d7a9f6330b71fea57921c9b61c47ee6e84f72d394754eff6163ae67e7395eb" -dependencies = [ - "proc-macro2", - "quote", - "syn 1.0.109", -] - -[[package]] -name = "indexmap" -version = "2.2.6" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "168fb715dda47215e360912c096649d23d58bf392ac62f73919e831745e40f26" -dependencies = [ - "equivalent", - "hashbrown", -] - -[[package]] -name = "k256" -version = "0.13.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "956ff9b67e26e1a6a866cb758f12c6f8746208489e3e4a4b5580802f2f0a587b" -dependencies = [ - "cfg-if", - "ecdsa", - "elliptic-curve", - "once_cell", - "sha2", - "signature", -] +checksum = "bbd2bcb4c963f2ddae06a2efc7e9f3591312473c50c6685e1f298068316e66fe" [[package]] name = "libc" @@ -308,19 +112,12 @@ version = "0.2.8" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "4ec2a862134d2a7d32d7983ddcdd1c4923530833c9f2ea1a44fc5fa473989058" -[[package]] -name = "memchr" -version = "2.7.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6c8640c5d730cb13ebd907d8d04b52f55ac9a2eec55b440c8892f40d56c76c1d" - [[package]] name = "num" version = "0.4.3" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "35bd024e8b2ff75562e5f34e7f4905839deb4b22955ef5e73d2fea1b9813cb23" dependencies = [ - "num-bigint", "num-complex", "num-integer", "num-iter", @@ -328,16 +125,6 @@ dependencies = [ "num-traits", ] -[[package]] -name = "num-bigint" -version = "0.4.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c165a9ab64cf766f73521c0dd2cfdff64f488b8f0b3e621face3462d3db536d7" -dependencies = [ - "num-integer", - "num-traits", -] - [[package]] name = "num-complex" version = "0.4.6" @@ -373,7 +160,6 @@ version = "0.4.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "f83d14da390562dca69fc84082e73e548e1ad308d24accdedd2720017cb37824" dependencies = [ - "num-bigint", "num-integer", "num-traits", ] @@ -393,66 +179,12 @@ version = "1.19.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "3fdb12b2476b595f9358c5161aa467c2438859caa136dec86c26fdd2efe17b92" -[[package]] -name = "parity-scale-codec" -version = "3.6.9" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "881331e34fa842a2fb61cc2db9643a8fedc615e47cfcc52597d1af0db9a7e8fe" -dependencies = [ - "arrayvec", - "byte-slice-cast", - "impl-trait-for-tuples", - "parity-scale-codec-derive", -] - -[[package]] -name = "parity-scale-codec-derive" -version = "3.6.9" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "be30eaf4b0a9fba5336683b38de57bb86d179a35862ba6bfcf57625d006bde5b" -dependencies = [ - "proc-macro-crate 2.0.2", - "proc-macro2", - "quote", - "syn 1.0.109", -] - -[[package]] -name = "pkcs8" -version = "0.10.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f950b2377845cebe5cf8b5165cb3cc1a5e0fa5cfa3e1f7f55707d8fd82e0a7b7" -dependencies = [ - "der", - "spki", -] - [[package]] name = "ppv-lite86" version = "0.2.17" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "5b40af805b3121feab8a3c29f04d8ad262fa8e0561883e7653e024ae4479e6de" -[[package]] -name = "proc-macro-crate" -version = "1.3.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7f4c021e1093a56626774e81216a4ce732a735e5bad4868a03f3ed65ca0c3919" -dependencies = [ - "once_cell", - "toml_edit 0.19.15", -] - -[[package]] -name = "proc-macro-crate" -version = "2.0.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b00f26d3400549137f92511a46ac1cd8ce37cb5598a96d382381458b992a5d24" -dependencies = [ - "toml_datetime", - "toml_edit 0.20.2", -] - [[package]] name = "proc-macro2" version = "1.0.79" @@ -471,12 +203,6 @@ dependencies = [ "proc-macro2", ] -[[package]] -name = "radium" -version = "0.7.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "dc33ff2d4973d518d823d61aa239014831e521c75da58e3df4840d3f47749d09" - [[package]] name = "rand" version = "0.8.5" @@ -507,54 +233,6 @@ dependencies = [ "getrandom", ] -[[package]] -name = "rfc6979" -version = "0.4.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f8dd2a808d456c4a54e300a23e9f5a67e122c3024119acbfd73e3bf664491cb2" -dependencies = [ - "hmac", - "subtle", -] - -[[package]] -name = "scale-info" -version = "2.11.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7c453e59a955f81fb62ee5d596b450383d699f152d350e9d23a0db2adb78e4c0" -dependencies = [ - "cfg-if", - "derive_more", - "parity-scale-codec", - "scale-info-derive", -] - -[[package]] -name = "scale-info-derive" -version = "2.11.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "18cf6c6447f813ef19eb450e985bcce6705f9ce7660db221b59093d15c79c4b7" -dependencies = [ - "proc-macro-crate 1.3.1", - "proc-macro2", - "quote", - "syn 1.0.109", -] - -[[package]] -name = "sec1" -version = "0.7.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d3e97a565f76233a6003f9f5c54be1d9c5bdfa3eccfb189469f11ec4901c47dc" -dependencies = [ - "base16ct", - "der", - "generic-array", - "pkcs8", - "subtle", - "zeroize", -] - [[package]] name = "secp256k1-add-test" version = "0.1.0" @@ -581,7 +259,7 @@ checksum = "500cbc0ebeb6f46627f50f3f5811ccf6bf00643be300b4c3eabc0ef55dc5b5ba" dependencies = [ "proc-macro2", "quote", - "syn 2.0.57", + "syn", ] [[package]] @@ -596,39 +274,13 @@ dependencies = [ ] [[package]] -name = "signature" -version = "2.2.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "77549399552de45a898a580c1b41d445bf730df867cc44e6c0233bbc4b8329de" -dependencies = [ - "digest", - "rand_core", -] - -[[package]] -name = "snowbridge-amcl" -version = "1.0.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "460a9ed63cdf03c1b9847e8a12a5f5ba19c4efd5869e4a737e05be25d7c427e5" -dependencies = [ - "parity-scale-codec", - "scale-info", -] - -[[package]] -name = "sp1-precompiles" +name = "sp1-lib" version = "0.1.0" dependencies = [ "anyhow", "bincode", "cfg-if", - "getrandom", - "hex", - "k256", - "num", - "rand", "serde", - "snowbridge-amcl", ] [[package]] @@ -638,40 +290,13 @@ dependencies = [ "bincode", "cfg-if", "getrandom", - "k256", + "lazy_static", "libm", "once_cell", "rand", "serde", "sha2", - "sp1-precompiles", -] - -[[package]] -name = "spki" -version = "0.7.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d91ed6c858b01f942cd56b37a94b3e0a1798290327d1236e4d9cf4eaca44d29d" -dependencies = [ - "base64ct", - "der", -] - -[[package]] -name = "subtle" -version = "2.5.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "81cdd64d312baedb58e21336b31bc043b77e01cc99033ce76ef539f78e965ebc" - -[[package]] -name = "syn" -version = "1.0.109" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "72b64191b275b66ffe2469e8af2c1cfe3bafa67b529ead792a6d0160888b4237" -dependencies = [ - "proc-macro2", - "quote", - "unicode-ident", + "sp1-lib", ] [[package]] @@ -685,40 +310,6 @@ dependencies = [ "unicode-ident", ] -[[package]] -name = "tap" -version = "1.0.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "55937e1799185b12863d447f42597ed69d9928686b8d88a1df17376a097d8369" - -[[package]] -name = "toml_datetime" -version = "0.6.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7cda73e2f1397b1262d6dfdcef8aafae14d1de7748d66822d3bfeeb6d03e5e4b" - -[[package]] -name = "toml_edit" -version = "0.19.15" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1b5bb770da30e5cbfde35a2d7b9b8a2c4b8ef89548a7a6aeab5c9a576e3e7421" -dependencies = [ - "indexmap", - "toml_datetime", - "winnow", -] - -[[package]] -name = "toml_edit" -version = "0.20.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "396e4d48bbb2b7554c944bde63101b5ae446cff6ec4a24227428f15eb72ef338" -dependencies = [ - "indexmap", - "toml_datetime", - "winnow", -] - [[package]] name = "typenum" version = "1.17.0" @@ -742,27 +333,3 @@ name = "wasi" version = "0.11.0+wasi-snapshot-preview1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "9c8d87e72b64a3b4db28d11ce29237c246188f4f51057d65a7eab63b7987e423" - -[[package]] -name = "winnow" -version = "0.5.40" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f593a95398737aeed53e489c785df13f3618e41dbcd6718c6addbf1395aa6876" -dependencies = [ - "memchr", -] - -[[package]] -name = "wyz" -version = "0.5.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "05f360fc0b24296329c78fda852a1e9ae82de9cf7b27dae4b7f62f118f77b9ed" -dependencies = [ - "tap", -] - -[[package]] -name = "zeroize" -version = "1.7.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "525b4ec142c6b68a2d10f01f7bbf6755599ca3f81ea53b8431b7dd348f5fdb2d" diff --git a/tests/secp256k1-add/Cargo.toml b/tests/secp256k1-add/Cargo.toml index 49c0b03008..c1e56e3421 100644 --- a/tests/secp256k1-add/Cargo.toml +++ b/tests/secp256k1-add/Cargo.toml @@ -1,8 +1,9 @@ [workspace] [package] -version = "0.1.0" name = "secp256k1-add-test" +version = "1.0.0-rc.1" edition = "2021" +publish = false [dependencies] sp1-zkvm = { path = "../../zkvm/entrypoint" } diff --git a/tests/secp256k1-add/elf/riscv32im-succinct-zkvm-elf b/tests/secp256k1-add/elf/riscv32im-succinct-zkvm-elf index bf7a3db101..748073f46c 100755 Binary files a/tests/secp256k1-add/elf/riscv32im-succinct-zkvm-elf and b/tests/secp256k1-add/elf/riscv32im-succinct-zkvm-elf differ diff --git a/tests/secp256k1-add/src/main.rs b/tests/secp256k1-add/src/main.rs index 9640e4e8c7..a727f5950d 100644 --- a/tests/secp256k1-add/src/main.rs +++ b/tests/secp256k1-add/src/main.rs @@ -1,9 +1,8 @@ #![no_main] -sp1_zkvm::entrypoint!(main); -extern "C" { - fn syscall_secp256k1_add(p: *mut u32, q: *const u32); -} +use sp1_zkvm::syscalls::syscall_secp256k1_add; + +sp1_zkvm::entrypoint!(main); pub fn main() { for _ in 0..4 { @@ -27,9 +26,7 @@ pub fn main() { 163, 57, 195, 61, 166, 254, 104, 225, 26, ]; - unsafe { - syscall_secp256k1_add(a.as_mut_ptr() as *mut u32, b.as_ptr() as *const u32); - } + syscall_secp256k1_add(a.as_mut_ptr() as *mut u32, b.as_ptr() as *mut u32); // 3 * generator. // 112711660439710606056748659173929673102114977341539408544630613555209775888121 diff --git a/tests/secp256k1-decompress/Cargo.lock b/tests/secp256k1-decompress/Cargo.lock index bab9197817..5262a1066b 100644 --- a/tests/secp256k1-decompress/Cargo.lock +++ b/tests/secp256k1-decompress/Cargo.lock @@ -8,30 +8,6 @@ version = "1.0.86" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "b3d1d046238990b9cf5bcde22a3fb3584ee5cf65fb2765f454ed428c7a0063da" -[[package]] -name = "arrayvec" -version = "0.7.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "96d30a06541fbafbc7f82ed10c06164cfbd2c401138f6addd8404629c4b16711" - -[[package]] -name = "autocfg" -version = "1.2.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f1fdabc7756949593fe60f30ec81974b613357de856987752631dea1e3394c80" - -[[package]] -name = "base16ct" -version = "0.2.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4c7f02d4ea65f2c1853089ffd8d2787bdbc63de2f0d29dedbcf8ccdfa0ccd4cf" - -[[package]] -name = "base64ct" -version = "1.6.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8c3c1a368f70d6cf7302d78f8f7093da241fb8e8807c05cc9e51a125895a6d5b" - [[package]] name = "bincode" version = "1.3.3" @@ -41,18 +17,6 @@ dependencies = [ "serde", ] -[[package]] -name = "bitvec" -version = "1.0.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1bc2832c24239b0141d5674bb9174f9d68a8b5b3f2753311927c172ca46f7e9c" -dependencies = [ - "funty", - "radium", - "tap", - "wyz", -] - [[package]] name = "block-buffer" version = "0.10.4" @@ -62,24 +26,12 @@ dependencies = [ "generic-array", ] -[[package]] -name = "byte-slice-cast" -version = "1.2.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c3ac9f8b63eca6fd385229b3675f6cc0dc5c8a5c8a54a59d4f52ffd670d87b0c" - [[package]] name = "cfg-if" version = "1.0.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "baf1de4339761588bc0619e3cbc0120ee582ebb74b53b4efbf79117bd2da40fd" -[[package]] -name = "const-oid" -version = "0.9.6" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c2459377285ad874054d797f3ccebf984978aa39129f6eafde5cdc8315b612f8" - [[package]] name = "cpufeatures" version = "0.2.12" @@ -89,18 +41,6 @@ dependencies = [ "libc", ] -[[package]] -name = "crypto-bigint" -version = "0.5.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0dc92fb57ca44df6db8059111ab3af99a63d5d0f8375d9972e319a379c6bab76" -dependencies = [ - "generic-array", - "rand_core", - "subtle", - "zeroize", -] - [[package]] name = "crypto-common" version = "0.1.6" @@ -111,27 +51,6 @@ dependencies = [ "typenum", ] -[[package]] -name = "der" -version = "0.7.8" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "fffa369a668c8af7dbf8b5e56c9f744fbd399949ed171606040001947de40b1c" -dependencies = [ - "const-oid", - "zeroize", -] - -[[package]] -name = "derive_more" -version = "0.99.17" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4fb810d30a7c1953f91334de7244731fc3f3c10d7fe163338a35b9f640960321" -dependencies = [ - "proc-macro2", - "quote", - "syn 1.0.109", -] - [[package]] name = "digest" version = "0.10.7" @@ -139,68 +58,9 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "9ed9a281f7bc9b7576e61468ba615a66a5c8cfdff42420a70aa82701a3b1e292" dependencies = [ "block-buffer", - "const-oid", "crypto-common", - "subtle", -] - -[[package]] -name = "ecdsa" -version = "0.16.9" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ee27f32b5c5292967d2d4a9d7f1e0b0aed2c15daded5a60300e4abb9d8020bca" -dependencies = [ - "der", - "digest", - "elliptic-curve", - "rfc6979", - "signature", - "spki", -] - -[[package]] -name = "elliptic-curve" -version = "0.13.8" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b5e6043086bf7973472e0c7dff2142ea0b680d30e18d9cc40f267efbf222bd47" -dependencies = [ - "base16ct", - "crypto-bigint", - "digest", - "ff", - "generic-array", - "group", - "pkcs8", - "rand_core", - "sec1", - "subtle", - "tap", - "zeroize", -] - -[[package]] -name = "equivalent" -version = "1.0.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5443807d6dff69373d433ab9ef5378ad8df50ca6298caf15de6e52e24aaf54d5" - -[[package]] -name = "ff" -version = "0.13.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ded41244b729663b1e574f1b4fb731469f69f79c17667b5d776b16cda0479449" -dependencies = [ - "bitvec", - "rand_core", - "subtle", ] -[[package]] -name = "funty" -version = "2.0.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e6d5a32815ae3f33302d95fdcb2ce17862f8c65363dcfd29360480ba1001fc9c" - [[package]] name = "generic-array" version = "0.14.7" @@ -209,7 +69,6 @@ checksum = "85649ca51fd72272d7821adaf274ad91c288277713d9c18820d8499a7ff69e9a" dependencies = [ "typenum", "version_check", - "zeroize", ] [[package]] @@ -224,71 +83,10 @@ dependencies = [ ] [[package]] -name = "group" -version = "0.13.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f0f9ef7462f7c099f518d754361858f86d8a07af53ba9af0fe635bbccb151a63" -dependencies = [ - "ff", - "rand_core", - "subtle", -] - -[[package]] -name = "hashbrown" -version = "0.14.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "290f1a1d9242c78d09ce40a5e87e7554ee637af1351968159f4952f028f75604" - -[[package]] -name = "hex" -version = "0.4.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7f24254aa9a54b5c858eaee2f5bccdb46aaf0e486a595ed5fd8f86ba55232a70" - -[[package]] -name = "hmac" -version = "0.12.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6c49c37c09c17a53d937dfbb742eb3a961d65a994e6bcdcf37e7399d0cc8ab5e" -dependencies = [ - "digest", -] - -[[package]] -name = "impl-trait-for-tuples" -version = "0.2.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "11d7a9f6330b71fea57921c9b61c47ee6e84f72d394754eff6163ae67e7395eb" -dependencies = [ - "proc-macro2", - "quote", - "syn 1.0.109", -] - -[[package]] -name = "indexmap" -version = "2.2.6" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "168fb715dda47215e360912c096649d23d58bf392ac62f73919e831745e40f26" -dependencies = [ - "equivalent", - "hashbrown", -] - -[[package]] -name = "k256" -version = "0.13.3" +name = "lazy_static" +version = "1.5.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "956ff9b67e26e1a6a866cb758f12c6f8746208489e3e4a4b5580802f2f0a587b" -dependencies = [ - "cfg-if", - "ecdsa", - "elliptic-curve", - "once_cell", - "sha2", - "signature", -] +checksum = "bbd2bcb4c963f2ddae06a2efc7e9f3591312473c50c6685e1f298068316e66fe" [[package]] name = "libc" @@ -302,151 +100,18 @@ version = "0.2.8" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "4ec2a862134d2a7d32d7983ddcdd1c4923530833c9f2ea1a44fc5fa473989058" -[[package]] -name = "memchr" -version = "2.7.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6c8640c5d730cb13ebd907d8d04b52f55ac9a2eec55b440c8892f40d56c76c1d" - -[[package]] -name = "num" -version = "0.4.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "35bd024e8b2ff75562e5f34e7f4905839deb4b22955ef5e73d2fea1b9813cb23" -dependencies = [ - "num-bigint", - "num-complex", - "num-integer", - "num-iter", - "num-rational", - "num-traits", -] - -[[package]] -name = "num-bigint" -version = "0.4.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c165a9ab64cf766f73521c0dd2cfdff64f488b8f0b3e621face3462d3db536d7" -dependencies = [ - "num-integer", - "num-traits", -] - -[[package]] -name = "num-complex" -version = "0.4.6" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "73f88a1307638156682bada9d7604135552957b7818057dcef22705b4d509495" -dependencies = [ - "num-traits", -] - -[[package]] -name = "num-integer" -version = "0.1.46" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7969661fd2958a5cb096e56c8e1ad0444ac2bbcd0061bd28660485a44879858f" -dependencies = [ - "num-traits", -] - -[[package]] -name = "num-iter" -version = "0.1.45" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1429034a0490724d0075ebb2bc9e875d6503c3cf69e235a8941aa757d83ef5bf" -dependencies = [ - "autocfg", - "num-integer", - "num-traits", -] - -[[package]] -name = "num-rational" -version = "0.4.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f83d14da390562dca69fc84082e73e548e1ad308d24accdedd2720017cb37824" -dependencies = [ - "num-bigint", - "num-integer", - "num-traits", -] - -[[package]] -name = "num-traits" -version = "0.2.19" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "071dfc062690e90b734c0b2273ce72ad0ffa95f0c74596bc250dcfd960262841" -dependencies = [ - "autocfg", -] - [[package]] name = "once_cell" version = "1.19.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "3fdb12b2476b595f9358c5161aa467c2438859caa136dec86c26fdd2efe17b92" -[[package]] -name = "parity-scale-codec" -version = "3.6.9" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "881331e34fa842a2fb61cc2db9643a8fedc615e47cfcc52597d1af0db9a7e8fe" -dependencies = [ - "arrayvec", - "byte-slice-cast", - "impl-trait-for-tuples", - "parity-scale-codec-derive", -] - -[[package]] -name = "parity-scale-codec-derive" -version = "3.6.9" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "be30eaf4b0a9fba5336683b38de57bb86d179a35862ba6bfcf57625d006bde5b" -dependencies = [ - "proc-macro-crate 2.0.2", - "proc-macro2", - "quote", - "syn 1.0.109", -] - -[[package]] -name = "pkcs8" -version = "0.10.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f950b2377845cebe5cf8b5165cb3cc1a5e0fa5cfa3e1f7f55707d8fd82e0a7b7" -dependencies = [ - "der", - "spki", -] - [[package]] name = "ppv-lite86" version = "0.2.17" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "5b40af805b3121feab8a3c29f04d8ad262fa8e0561883e7653e024ae4479e6de" -[[package]] -name = "proc-macro-crate" -version = "1.3.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7f4c021e1093a56626774e81216a4ce732a735e5bad4868a03f3ed65ca0c3919" -dependencies = [ - "once_cell", - "toml_edit 0.19.15", -] - -[[package]] -name = "proc-macro-crate" -version = "2.0.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b00f26d3400549137f92511a46ac1cd8ce37cb5598a96d382381458b992a5d24" -dependencies = [ - "toml_datetime", - "toml_edit 0.20.2", -] - [[package]] name = "proc-macro2" version = "1.0.78" @@ -465,12 +130,6 @@ dependencies = [ "proc-macro2", ] -[[package]] -name = "radium" -version = "0.7.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "dc33ff2d4973d518d823d61aa239014831e521c75da58e3df4840d3f47749d09" - [[package]] name = "rand" version = "0.8.5" @@ -501,54 +160,6 @@ dependencies = [ "getrandom", ] -[[package]] -name = "rfc6979" -version = "0.4.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f8dd2a808d456c4a54e300a23e9f5a67e122c3024119acbfd73e3bf664491cb2" -dependencies = [ - "hmac", - "subtle", -] - -[[package]] -name = "scale-info" -version = "2.11.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7c453e59a955f81fb62ee5d596b450383d699f152d350e9d23a0db2adb78e4c0" -dependencies = [ - "cfg-if", - "derive_more", - "parity-scale-codec", - "scale-info-derive", -] - -[[package]] -name = "scale-info-derive" -version = "2.11.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "18cf6c6447f813ef19eb450e985bcce6705f9ce7660db221b59093d15c79c4b7" -dependencies = [ - "proc-macro-crate 1.3.1", - "proc-macro2", - "quote", - "syn 1.0.109", -] - -[[package]] -name = "sec1" -version = "0.7.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d3e97a565f76233a6003f9f5c54be1d9c5bdfa3eccfb189469f11ec4901c47dc" -dependencies = [ - "base16ct", - "der", - "generic-array", - "pkcs8", - "subtle", - "zeroize", -] - [[package]] name = "secp256k1-decompress-test" version = "0.1.0" @@ -573,7 +184,7 @@ checksum = "500cbc0ebeb6f46627f50f3f5811ccf6bf00643be300b4c3eabc0ef55dc5b5ba" dependencies = [ "proc-macro2", "quote", - "syn 2.0.48", + "syn", ] [[package]] @@ -588,39 +199,13 @@ dependencies = [ ] [[package]] -name = "signature" -version = "2.2.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "77549399552de45a898a580c1b41d445bf730df867cc44e6c0233bbc4b8329de" -dependencies = [ - "digest", - "rand_core", -] - -[[package]] -name = "snowbridge-amcl" -version = "1.0.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "460a9ed63cdf03c1b9847e8a12a5f5ba19c4efd5869e4a737e05be25d7c427e5" -dependencies = [ - "parity-scale-codec", - "scale-info", -] - -[[package]] -name = "sp1-precompiles" +name = "sp1-lib" version = "0.1.0" dependencies = [ "anyhow", "bincode", "cfg-if", - "getrandom", - "hex", - "k256", - "num", - "rand", "serde", - "snowbridge-amcl", ] [[package]] @@ -630,40 +215,13 @@ dependencies = [ "bincode", "cfg-if", "getrandom", - "k256", + "lazy_static", "libm", "once_cell", "rand", "serde", "sha2", - "sp1-precompiles", -] - -[[package]] -name = "spki" -version = "0.7.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d91ed6c858b01f942cd56b37a94b3e0a1798290327d1236e4d9cf4eaca44d29d" -dependencies = [ - "base64ct", - "der", -] - -[[package]] -name = "subtle" -version = "2.5.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "81cdd64d312baedb58e21336b31bc043b77e01cc99033ce76ef539f78e965ebc" - -[[package]] -name = "syn" -version = "1.0.109" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "72b64191b275b66ffe2469e8af2c1cfe3bafa67b529ead792a6d0160888b4237" -dependencies = [ - "proc-macro2", - "quote", - "unicode-ident", + "sp1-lib", ] [[package]] @@ -677,40 +235,6 @@ dependencies = [ "unicode-ident", ] -[[package]] -name = "tap" -version = "1.0.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "55937e1799185b12863d447f42597ed69d9928686b8d88a1df17376a097d8369" - -[[package]] -name = "toml_datetime" -version = "0.6.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7cda73e2f1397b1262d6dfdcef8aafae14d1de7748d66822d3bfeeb6d03e5e4b" - -[[package]] -name = "toml_edit" -version = "0.19.15" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1b5bb770da30e5cbfde35a2d7b9b8a2c4b8ef89548a7a6aeab5c9a576e3e7421" -dependencies = [ - "indexmap", - "toml_datetime", - "winnow", -] - -[[package]] -name = "toml_edit" -version = "0.20.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "396e4d48bbb2b7554c944bde63101b5ae446cff6ec4a24227428f15eb72ef338" -dependencies = [ - "indexmap", - "toml_datetime", - "winnow", -] - [[package]] name = "typenum" version = "1.17.0" @@ -734,27 +258,3 @@ name = "wasi" version = "0.11.0+wasi-snapshot-preview1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "9c8d87e72b64a3b4db28d11ce29237c246188f4f51057d65a7eab63b7987e423" - -[[package]] -name = "winnow" -version = "0.5.40" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f593a95398737aeed53e489c785df13f3618e41dbcd6718c6addbf1395aa6876" -dependencies = [ - "memchr", -] - -[[package]] -name = "wyz" -version = "0.5.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "05f360fc0b24296329c78fda852a1e9ae82de9cf7b27dae4b7f62f118f77b9ed" -dependencies = [ - "tap", -] - -[[package]] -name = "zeroize" -version = "1.7.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "525b4ec142c6b68a2d10f01f7bbf6755599ca3f81ea53b8431b7dd348f5fdb2d" diff --git a/tests/secp256k1-decompress/Cargo.toml b/tests/secp256k1-decompress/Cargo.toml index bd80d18ab3..5abf03a12b 100644 --- a/tests/secp256k1-decompress/Cargo.toml +++ b/tests/secp256k1-decompress/Cargo.toml @@ -1,8 +1,9 @@ [workspace] [package] -version = "0.1.0" name = "secp256k1-decompress-test" +version = "1.0.0-rc.1" edition = "2021" +publish = false [dependencies] sp1-zkvm = { path = "../../zkvm/entrypoint" } diff --git a/tests/secp256k1-decompress/elf/riscv32im-succinct-zkvm-elf b/tests/secp256k1-decompress/elf/riscv32im-succinct-zkvm-elf index 2fae11204b..81a022b875 100755 Binary files a/tests/secp256k1-decompress/elf/riscv32im-succinct-zkvm-elf and b/tests/secp256k1-decompress/elf/riscv32im-succinct-zkvm-elf differ diff --git a/tests/secp256k1-decompress/src/main.rs b/tests/secp256k1-decompress/src/main.rs index a603986e00..b00f871aca 100644 --- a/tests/secp256k1-decompress/src/main.rs +++ b/tests/secp256k1-decompress/src/main.rs @@ -1,9 +1,8 @@ #![no_main] -sp1_zkvm::entrypoint!(main); -extern "C" { - fn syscall_secp256k1_decompress(compressed_key: &mut [u8; 64], is_odd: bool); -} +use sp1_zkvm::syscalls::syscall_secp256k1_decompress; + +sp1_zkvm::entrypoint!(main); pub fn main() { let compressed_key: [u8; 33] = sp1_zkvm::io::read_vec().try_into().unwrap(); @@ -16,9 +15,7 @@ pub fn main() { 3 => true, _ => panic!("Invalid compressed key"), }; - unsafe { - syscall_secp256k1_decompress(&mut decompressed_key, is_odd); - } + syscall_secp256k1_decompress(&mut decompressed_key, is_odd); let mut result: [u8; 65] = [0; 65]; result[0] = 4; diff --git a/tests/secp256k1-double/Cargo.lock b/tests/secp256k1-double/Cargo.lock index b34dbf384c..494a5cf242 100644 --- a/tests/secp256k1-double/Cargo.lock +++ b/tests/secp256k1-double/Cargo.lock @@ -8,30 +8,12 @@ version = "1.0.86" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "b3d1d046238990b9cf5bcde22a3fb3584ee5cf65fb2765f454ed428c7a0063da" -[[package]] -name = "arrayvec" -version = "0.7.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "96d30a06541fbafbc7f82ed10c06164cfbd2c401138f6addd8404629c4b16711" - [[package]] name = "autocfg" version = "1.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "d468802bab17cbc0cc575e9b053f41e72aa36bfa6b7f55e3529ffa43161b97fa" -[[package]] -name = "base16ct" -version = "0.2.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4c7f02d4ea65f2c1853089ffd8d2787bdbc63de2f0d29dedbcf8ccdfa0ccd4cf" - -[[package]] -name = "base64ct" -version = "1.6.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8c3c1a368f70d6cf7302d78f8f7093da241fb8e8807c05cc9e51a125895a6d5b" - [[package]] name = "bincode" version = "1.3.3" @@ -41,18 +23,6 @@ dependencies = [ "serde", ] -[[package]] -name = "bitvec" -version = "1.0.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1bc2832c24239b0141d5674bb9174f9d68a8b5b3f2753311927c172ca46f7e9c" -dependencies = [ - "funty", - "radium", - "tap", - "wyz", -] - [[package]] name = "block-buffer" version = "0.10.4" @@ -62,24 +32,12 @@ dependencies = [ "generic-array", ] -[[package]] -name = "byte-slice-cast" -version = "1.2.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c3ac9f8b63eca6fd385229b3675f6cc0dc5c8a5c8a54a59d4f52ffd670d87b0c" - [[package]] name = "cfg-if" version = "1.0.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "baf1de4339761588bc0619e3cbc0120ee582ebb74b53b4efbf79117bd2da40fd" -[[package]] -name = "const-oid" -version = "0.9.6" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c2459377285ad874054d797f3ccebf984978aa39129f6eafde5cdc8315b612f8" - [[package]] name = "cpufeatures" version = "0.2.12" @@ -89,18 +47,6 @@ dependencies = [ "libc", ] -[[package]] -name = "crypto-bigint" -version = "0.5.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0dc92fb57ca44df6db8059111ab3af99a63d5d0f8375d9972e319a379c6bab76" -dependencies = [ - "generic-array", - "rand_core", - "subtle", - "zeroize", -] - [[package]] name = "crypto-common" version = "0.1.6" @@ -111,27 +57,6 @@ dependencies = [ "typenum", ] -[[package]] -name = "der" -version = "0.7.8" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "fffa369a668c8af7dbf8b5e56c9f744fbd399949ed171606040001947de40b1c" -dependencies = [ - "const-oid", - "zeroize", -] - -[[package]] -name = "derive_more" -version = "0.99.17" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4fb810d30a7c1953f91334de7244731fc3f3c10d7fe163338a35b9f640960321" -dependencies = [ - "proc-macro2", - "quote", - "syn 1.0.109", -] - [[package]] name = "digest" version = "0.10.7" @@ -139,68 +64,9 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "9ed9a281f7bc9b7576e61468ba615a66a5c8cfdff42420a70aa82701a3b1e292" dependencies = [ "block-buffer", - "const-oid", "crypto-common", - "subtle", -] - -[[package]] -name = "ecdsa" -version = "0.16.9" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ee27f32b5c5292967d2d4a9d7f1e0b0aed2c15daded5a60300e4abb9d8020bca" -dependencies = [ - "der", - "digest", - "elliptic-curve", - "rfc6979", - "signature", - "spki", -] - -[[package]] -name = "elliptic-curve" -version = "0.13.8" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b5e6043086bf7973472e0c7dff2142ea0b680d30e18d9cc40f267efbf222bd47" -dependencies = [ - "base16ct", - "crypto-bigint", - "digest", - "ff", - "generic-array", - "group", - "pkcs8", - "rand_core", - "sec1", - "subtle", - "tap", - "zeroize", -] - -[[package]] -name = "equivalent" -version = "1.0.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5443807d6dff69373d433ab9ef5378ad8df50ca6298caf15de6e52e24aaf54d5" - -[[package]] -name = "ff" -version = "0.13.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ded41244b729663b1e574f1b4fb731469f69f79c17667b5d776b16cda0479449" -dependencies = [ - "bitvec", - "rand_core", - "subtle", ] -[[package]] -name = "funty" -version = "2.0.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e6d5a32815ae3f33302d95fdcb2ce17862f8c65363dcfd29360480ba1001fc9c" - [[package]] name = "generic-array" version = "0.14.7" @@ -209,7 +75,6 @@ checksum = "85649ca51fd72272d7821adaf274ad91c288277713d9c18820d8499a7ff69e9a" dependencies = [ "typenum", "version_check", - "zeroize", ] [[package]] @@ -223,29 +88,6 @@ dependencies = [ "wasi", ] -[[package]] -name = "group" -version = "0.13.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f0f9ef7462f7c099f518d754361858f86d8a07af53ba9af0fe635bbccb151a63" -dependencies = [ - "ff", - "rand_core", - "subtle", -] - -[[package]] -name = "hashbrown" -version = "0.14.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "290f1a1d9242c78d09ce40a5e87e7554ee637af1351968159f4952f028f75604" - -[[package]] -name = "hex" -version = "0.4.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7f24254aa9a54b5c858eaee2f5bccdb46aaf0e486a595ed5fd8f86ba55232a70" - [[package]] name = "hex-literal" version = "0.4.1" @@ -253,48 +95,10 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "6fe2267d4ed49bc07b63801559be28c718ea06c4738b7a03c94df7386d2cde46" [[package]] -name = "hmac" -version = "0.12.1" +name = "lazy_static" +version = "1.5.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6c49c37c09c17a53d937dfbb742eb3a961d65a994e6bcdcf37e7399d0cc8ab5e" -dependencies = [ - "digest", -] - -[[package]] -name = "impl-trait-for-tuples" -version = "0.2.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "11d7a9f6330b71fea57921c9b61c47ee6e84f72d394754eff6163ae67e7395eb" -dependencies = [ - "proc-macro2", - "quote", - "syn 1.0.109", -] - -[[package]] -name = "indexmap" -version = "2.2.6" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "168fb715dda47215e360912c096649d23d58bf392ac62f73919e831745e40f26" -dependencies = [ - "equivalent", - "hashbrown", -] - -[[package]] -name = "k256" -version = "0.13.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "956ff9b67e26e1a6a866cb758f12c6f8746208489e3e4a4b5580802f2f0a587b" -dependencies = [ - "cfg-if", - "ecdsa", - "elliptic-curve", - "once_cell", - "sha2", - "signature", -] +checksum = "bbd2bcb4c963f2ddae06a2efc7e9f3591312473c50c6685e1f298068316e66fe" [[package]] name = "libc" @@ -308,19 +112,12 @@ version = "0.2.8" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "4ec2a862134d2a7d32d7983ddcdd1c4923530833c9f2ea1a44fc5fa473989058" -[[package]] -name = "memchr" -version = "2.7.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6c8640c5d730cb13ebd907d8d04b52f55ac9a2eec55b440c8892f40d56c76c1d" - [[package]] name = "num" version = "0.4.3" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "35bd024e8b2ff75562e5f34e7f4905839deb4b22955ef5e73d2fea1b9813cb23" dependencies = [ - "num-bigint", "num-complex", "num-integer", "num-iter", @@ -328,16 +125,6 @@ dependencies = [ "num-traits", ] -[[package]] -name = "num-bigint" -version = "0.4.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c165a9ab64cf766f73521c0dd2cfdff64f488b8f0b3e621face3462d3db536d7" -dependencies = [ - "num-integer", - "num-traits", -] - [[package]] name = "num-complex" version = "0.4.6" @@ -373,7 +160,6 @@ version = "0.4.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "f83d14da390562dca69fc84082e73e548e1ad308d24accdedd2720017cb37824" dependencies = [ - "num-bigint", "num-integer", "num-traits", ] @@ -393,66 +179,12 @@ version = "1.19.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "3fdb12b2476b595f9358c5161aa467c2438859caa136dec86c26fdd2efe17b92" -[[package]] -name = "parity-scale-codec" -version = "3.6.9" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "881331e34fa842a2fb61cc2db9643a8fedc615e47cfcc52597d1af0db9a7e8fe" -dependencies = [ - "arrayvec", - "byte-slice-cast", - "impl-trait-for-tuples", - "parity-scale-codec-derive", -] - -[[package]] -name = "parity-scale-codec-derive" -version = "3.6.9" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "be30eaf4b0a9fba5336683b38de57bb86d179a35862ba6bfcf57625d006bde5b" -dependencies = [ - "proc-macro-crate 2.0.2", - "proc-macro2", - "quote", - "syn 1.0.109", -] - -[[package]] -name = "pkcs8" -version = "0.10.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f950b2377845cebe5cf8b5165cb3cc1a5e0fa5cfa3e1f7f55707d8fd82e0a7b7" -dependencies = [ - "der", - "spki", -] - [[package]] name = "ppv-lite86" version = "0.2.17" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "5b40af805b3121feab8a3c29f04d8ad262fa8e0561883e7653e024ae4479e6de" -[[package]] -name = "proc-macro-crate" -version = "1.3.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7f4c021e1093a56626774e81216a4ce732a735e5bad4868a03f3ed65ca0c3919" -dependencies = [ - "once_cell", - "toml_edit 0.19.15", -] - -[[package]] -name = "proc-macro-crate" -version = "2.0.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b00f26d3400549137f92511a46ac1cd8ce37cb5598a96d382381458b992a5d24" -dependencies = [ - "toml_datetime", - "toml_edit 0.20.2", -] - [[package]] name = "proc-macro2" version = "1.0.79" @@ -471,12 +203,6 @@ dependencies = [ "proc-macro2", ] -[[package]] -name = "radium" -version = "0.7.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "dc33ff2d4973d518d823d61aa239014831e521c75da58e3df4840d3f47749d09" - [[package]] name = "rand" version = "0.8.5" @@ -507,54 +233,6 @@ dependencies = [ "getrandom", ] -[[package]] -name = "rfc6979" -version = "0.4.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f8dd2a808d456c4a54e300a23e9f5a67e122c3024119acbfd73e3bf664491cb2" -dependencies = [ - "hmac", - "subtle", -] - -[[package]] -name = "scale-info" -version = "2.11.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7c453e59a955f81fb62ee5d596b450383d699f152d350e9d23a0db2adb78e4c0" -dependencies = [ - "cfg-if", - "derive_more", - "parity-scale-codec", - "scale-info-derive", -] - -[[package]] -name = "scale-info-derive" -version = "2.11.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "18cf6c6447f813ef19eb450e985bcce6705f9ce7660db221b59093d15c79c4b7" -dependencies = [ - "proc-macro-crate 1.3.1", - "proc-macro2", - "quote", - "syn 1.0.109", -] - -[[package]] -name = "sec1" -version = "0.7.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d3e97a565f76233a6003f9f5c54be1d9c5bdfa3eccfb189469f11ec4901c47dc" -dependencies = [ - "base16ct", - "der", - "generic-array", - "pkcs8", - "subtle", - "zeroize", -] - [[package]] name = "secp256k1-double-test" version = "0.1.0" @@ -581,7 +259,7 @@ checksum = "500cbc0ebeb6f46627f50f3f5811ccf6bf00643be300b4c3eabc0ef55dc5b5ba" dependencies = [ "proc-macro2", "quote", - "syn 2.0.55", + "syn", ] [[package]] @@ -596,39 +274,13 @@ dependencies = [ ] [[package]] -name = "signature" -version = "2.2.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "77549399552de45a898a580c1b41d445bf730df867cc44e6c0233bbc4b8329de" -dependencies = [ - "digest", - "rand_core", -] - -[[package]] -name = "snowbridge-amcl" -version = "1.0.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "460a9ed63cdf03c1b9847e8a12a5f5ba19c4efd5869e4a737e05be25d7c427e5" -dependencies = [ - "parity-scale-codec", - "scale-info", -] - -[[package]] -name = "sp1-precompiles" +name = "sp1-lib" version = "0.1.0" dependencies = [ "anyhow", "bincode", "cfg-if", - "getrandom", - "hex", - "k256", - "num", - "rand", "serde", - "snowbridge-amcl", ] [[package]] @@ -638,40 +290,13 @@ dependencies = [ "bincode", "cfg-if", "getrandom", - "k256", + "lazy_static", "libm", "once_cell", "rand", "serde", "sha2", - "sp1-precompiles", -] - -[[package]] -name = "spki" -version = "0.7.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d91ed6c858b01f942cd56b37a94b3e0a1798290327d1236e4d9cf4eaca44d29d" -dependencies = [ - "base64ct", - "der", -] - -[[package]] -name = "subtle" -version = "2.5.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "81cdd64d312baedb58e21336b31bc043b77e01cc99033ce76ef539f78e965ebc" - -[[package]] -name = "syn" -version = "1.0.109" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "72b64191b275b66ffe2469e8af2c1cfe3bafa67b529ead792a6d0160888b4237" -dependencies = [ - "proc-macro2", - "quote", - "unicode-ident", + "sp1-lib", ] [[package]] @@ -685,40 +310,6 @@ dependencies = [ "unicode-ident", ] -[[package]] -name = "tap" -version = "1.0.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "55937e1799185b12863d447f42597ed69d9928686b8d88a1df17376a097d8369" - -[[package]] -name = "toml_datetime" -version = "0.6.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7cda73e2f1397b1262d6dfdcef8aafae14d1de7748d66822d3bfeeb6d03e5e4b" - -[[package]] -name = "toml_edit" -version = "0.19.15" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1b5bb770da30e5cbfde35a2d7b9b8a2c4b8ef89548a7a6aeab5c9a576e3e7421" -dependencies = [ - "indexmap", - "toml_datetime", - "winnow", -] - -[[package]] -name = "toml_edit" -version = "0.20.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "396e4d48bbb2b7554c944bde63101b5ae446cff6ec4a24227428f15eb72ef338" -dependencies = [ - "indexmap", - "toml_datetime", - "winnow", -] - [[package]] name = "typenum" version = "1.17.0" @@ -742,27 +333,3 @@ name = "wasi" version = "0.11.0+wasi-snapshot-preview1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "9c8d87e72b64a3b4db28d11ce29237c246188f4f51057d65a7eab63b7987e423" - -[[package]] -name = "winnow" -version = "0.5.40" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f593a95398737aeed53e489c785df13f3618e41dbcd6718c6addbf1395aa6876" -dependencies = [ - "memchr", -] - -[[package]] -name = "wyz" -version = "0.5.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "05f360fc0b24296329c78fda852a1e9ae82de9cf7b27dae4b7f62f118f77b9ed" -dependencies = [ - "tap", -] - -[[package]] -name = "zeroize" -version = "1.7.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "525b4ec142c6b68a2d10f01f7bbf6755599ca3f81ea53b8431b7dd348f5fdb2d" diff --git a/tests/secp256k1-double/Cargo.toml b/tests/secp256k1-double/Cargo.toml index dc8f3f3592..ab451635bd 100644 --- a/tests/secp256k1-double/Cargo.toml +++ b/tests/secp256k1-double/Cargo.toml @@ -1,8 +1,9 @@ [workspace] [package] -version = "0.1.0" name = "secp256k1-double-test" +version = "1.0.0-rc.1" edition = "2021" +publish = false [dependencies] sp1-zkvm = { path = "../../zkvm/entrypoint" } diff --git a/tests/secp256k1-double/elf/riscv32im-succinct-zkvm-elf b/tests/secp256k1-double/elf/riscv32im-succinct-zkvm-elf index 79a156fcab..30a869476d 100755 Binary files a/tests/secp256k1-double/elf/riscv32im-succinct-zkvm-elf and b/tests/secp256k1-double/elf/riscv32im-succinct-zkvm-elf differ diff --git a/tests/secp256k1-double/src/main.rs b/tests/secp256k1-double/src/main.rs index fda6ac1a5f..725a3ca8e7 100644 --- a/tests/secp256k1-double/src/main.rs +++ b/tests/secp256k1-double/src/main.rs @@ -1,9 +1,8 @@ #![no_main] -sp1_zkvm::entrypoint!(main); -extern "C" { - fn syscall_secp256k1_double(p: *mut u32); -} +use sp1_zkvm::syscalls::syscall_secp256k1_double; + +sp1_zkvm::entrypoint!(main); pub fn main() { for _ in 0..10i64.pow(3) { @@ -17,9 +16,7 @@ pub fn main() { 101, 196, 163, 38, 119, 218, 58, 72, ]; - unsafe { - syscall_secp256k1_double(a.as_mut_ptr() as *mut u32); - } + syscall_secp256k1_double(a.as_mut_ptr() as *mut u32); // 2 * generator. // 89565891926547004231252920425935692360644145829622209833684329913297188986597 diff --git a/tests/secp256k1-mul/Cargo.lock b/tests/secp256k1-mul/Cargo.lock index be7fc96741..03fa374c58 100644 --- a/tests/secp256k1-mul/Cargo.lock +++ b/tests/secp256k1-mul/Cargo.lock @@ -8,18 +8,6 @@ version = "1.0.86" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "b3d1d046238990b9cf5bcde22a3fb3584ee5cf65fb2765f454ed428c7a0063da" -[[package]] -name = "arrayvec" -version = "0.7.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "96d30a06541fbafbc7f82ed10c06164cfbd2c401138f6addd8404629c4b16711" - -[[package]] -name = "autocfg" -version = "1.2.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f1fdabc7756949593fe60f30ec81974b613357de856987752631dea1e3394c80" - [[package]] name = "base16ct" version = "0.2.0" @@ -62,12 +50,6 @@ dependencies = [ "generic-array", ] -[[package]] -name = "byte-slice-cast" -version = "1.2.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c3ac9f8b63eca6fd385229b3675f6cc0dc5c8a5c8a54a59d4f52ffd670d87b0c" - [[package]] name = "cfg-if" version = "1.0.0" @@ -113,25 +95,14 @@ dependencies = [ [[package]] name = "der" -version = "0.7.8" +version = "0.7.9" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "fffa369a668c8af7dbf8b5e56c9f744fbd399949ed171606040001947de40b1c" +checksum = "f55bf8e7b65898637379c1b74eb1551107c8294ed26d855ceb9fd1a09cfc9bc0" dependencies = [ "const-oid", "zeroize", ] -[[package]] -name = "derive_more" -version = "0.99.17" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4fb810d30a7c1953f91334de7244731fc3f3c10d7fe163338a35b9f640960321" -dependencies = [ - "proc-macro2", - "quote", - "syn 1.0.109", -] - [[package]] name = "digest" version = "0.10.7" @@ -178,12 +149,6 @@ dependencies = [ "zeroize", ] -[[package]] -name = "equivalent" -version = "1.0.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5443807d6dff69373d433ab9ef5378ad8df50ca6298caf15de6e52e24aaf54d5" - [[package]] name = "ff" version = "0.13.0" @@ -234,18 +199,6 @@ dependencies = [ "subtle", ] -[[package]] -name = "hashbrown" -version = "0.14.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "290f1a1d9242c78d09ce40a5e87e7554ee637af1351968159f4952f028f75604" - -[[package]] -name = "hex" -version = "0.4.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7f24254aa9a54b5c858eaee2f5bccdb46aaf0e486a595ed5fd8f86ba55232a70" - [[package]] name = "hmac" version = "0.12.1" @@ -255,27 +208,6 @@ dependencies = [ "digest", ] -[[package]] -name = "impl-trait-for-tuples" -version = "0.2.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "11d7a9f6330b71fea57921c9b61c47ee6e84f72d394754eff6163ae67e7395eb" -dependencies = [ - "proc-macro2", - "quote", - "syn 1.0.109", -] - -[[package]] -name = "indexmap" -version = "2.2.6" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "168fb715dda47215e360912c096649d23d58bf392ac62f73919e831745e40f26" -dependencies = [ - "equivalent", - "hashbrown", -] - [[package]] name = "k256" version = "0.13.3" @@ -290,6 +222,12 @@ dependencies = [ "signature", ] +[[package]] +name = "lazy_static" +version = "1.5.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "bbd2bcb4c963f2ddae06a2efc7e9f3591312473c50c6685e1f298068316e66fe" + [[package]] name = "libc" version = "0.2.155" @@ -302,115 +240,12 @@ version = "0.2.8" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "4ec2a862134d2a7d32d7983ddcdd1c4923530833c9f2ea1a44fc5fa473989058" -[[package]] -name = "memchr" -version = "2.7.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6c8640c5d730cb13ebd907d8d04b52f55ac9a2eec55b440c8892f40d56c76c1d" - -[[package]] -name = "num" -version = "0.4.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "35bd024e8b2ff75562e5f34e7f4905839deb4b22955ef5e73d2fea1b9813cb23" -dependencies = [ - "num-bigint", - "num-complex", - "num-integer", - "num-iter", - "num-rational", - "num-traits", -] - -[[package]] -name = "num-bigint" -version = "0.4.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c165a9ab64cf766f73521c0dd2cfdff64f488b8f0b3e621face3462d3db536d7" -dependencies = [ - "num-integer", - "num-traits", -] - -[[package]] -name = "num-complex" -version = "0.4.6" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "73f88a1307638156682bada9d7604135552957b7818057dcef22705b4d509495" -dependencies = [ - "num-traits", -] - -[[package]] -name = "num-integer" -version = "0.1.46" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7969661fd2958a5cb096e56c8e1ad0444ac2bbcd0061bd28660485a44879858f" -dependencies = [ - "num-traits", -] - -[[package]] -name = "num-iter" -version = "0.1.45" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1429034a0490724d0075ebb2bc9e875d6503c3cf69e235a8941aa757d83ef5bf" -dependencies = [ - "autocfg", - "num-integer", - "num-traits", -] - -[[package]] -name = "num-rational" -version = "0.4.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f83d14da390562dca69fc84082e73e548e1ad308d24accdedd2720017cb37824" -dependencies = [ - "num-bigint", - "num-integer", - "num-traits", -] - -[[package]] -name = "num-traits" -version = "0.2.19" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "071dfc062690e90b734c0b2273ce72ad0ffa95f0c74596bc250dcfd960262841" -dependencies = [ - "autocfg", -] - [[package]] name = "once_cell" version = "1.19.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "3fdb12b2476b595f9358c5161aa467c2438859caa136dec86c26fdd2efe17b92" -[[package]] -name = "parity-scale-codec" -version = "3.6.9" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "881331e34fa842a2fb61cc2db9643a8fedc615e47cfcc52597d1af0db9a7e8fe" -dependencies = [ - "arrayvec", - "byte-slice-cast", - "impl-trait-for-tuples", - "parity-scale-codec-derive", -] - -[[package]] -name = "parity-scale-codec-derive" -version = "3.6.9" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "be30eaf4b0a9fba5336683b38de57bb86d179a35862ba6bfcf57625d006bde5b" -dependencies = [ - "proc-macro-crate 2.0.2", - "proc-macro2", - "quote", - "syn 1.0.109", -] - [[package]] name = "pkcs8" version = "0.10.2" @@ -427,26 +262,6 @@ version = "0.2.17" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "5b40af805b3121feab8a3c29f04d8ad262fa8e0561883e7653e024ae4479e6de" -[[package]] -name = "proc-macro-crate" -version = "1.3.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7f4c021e1093a56626774e81216a4ce732a735e5bad4868a03f3ed65ca0c3919" -dependencies = [ - "once_cell", - "toml_edit 0.19.15", -] - -[[package]] -name = "proc-macro-crate" -version = "2.0.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b00f26d3400549137f92511a46ac1cd8ce37cb5598a96d382381458b992a5d24" -dependencies = [ - "toml_datetime", - "toml_edit 0.20.2", -] - [[package]] name = "proc-macro2" version = "1.0.79" @@ -511,30 +326,6 @@ dependencies = [ "subtle", ] -[[package]] -name = "scale-info" -version = "2.11.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7c453e59a955f81fb62ee5d596b450383d699f152d350e9d23a0db2adb78e4c0" -dependencies = [ - "cfg-if", - "derive_more", - "parity-scale-codec", - "scale-info-derive", -] - -[[package]] -name = "scale-info-derive" -version = "2.11.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "18cf6c6447f813ef19eb450e985bcce6705f9ce7660db221b59093d15c79c4b7" -dependencies = [ - "proc-macro-crate 1.3.1", - "proc-macro2", - "quote", - "syn 1.0.109", -] - [[package]] name = "sec1" version = "0.7.3" @@ -598,16 +389,6 @@ dependencies = [ "rand_core", ] -[[package]] -name = "snowbridge-amcl" -version = "1.0.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "460a9ed63cdf03c1b9847e8a12a5f5ba19c4efd5869e4a737e05be25d7c427e5" -dependencies = [ - "parity-scale-codec", - "scale-info", -] - [[package]] name = "sp1-derive" version = "0.1.0" @@ -618,19 +399,14 @@ dependencies = [ ] [[package]] -name = "sp1-precompiles" +name = "sp1-lib" version = "0.1.0" dependencies = [ "anyhow", "bincode", "cfg-if", - "getrandom", - "hex", "k256", - "num", - "rand", "serde", - "snowbridge-amcl", ] [[package]] @@ -640,13 +416,13 @@ dependencies = [ "bincode", "cfg-if", "getrandom", - "k256", + "lazy_static", "libm", "once_cell", "rand", "serde", "sha2", - "sp1-precompiles", + "sp1-lib", ] [[package]] @@ -661,9 +437,9 @@ dependencies = [ [[package]] name = "subtle" -version = "2.5.0" +version = "2.6.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "81cdd64d312baedb58e21336b31bc043b77e01cc99033ce76ef539f78e965ebc" +checksum = "13c2bddecc57b384dee18652358fb23172facb8a2c51ccc10d74c157bdea3292" [[package]] name = "syn" @@ -693,34 +469,6 @@ version = "1.0.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "55937e1799185b12863d447f42597ed69d9928686b8d88a1df17376a097d8369" -[[package]] -name = "toml_datetime" -version = "0.6.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7cda73e2f1397b1262d6dfdcef8aafae14d1de7748d66822d3bfeeb6d03e5e4b" - -[[package]] -name = "toml_edit" -version = "0.19.15" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1b5bb770da30e5cbfde35a2d7b9b8a2c4b8ef89548a7a6aeab5c9a576e3e7421" -dependencies = [ - "indexmap", - "toml_datetime", - "winnow", -] - -[[package]] -name = "toml_edit" -version = "0.20.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "396e4d48bbb2b7554c944bde63101b5ae446cff6ec4a24227428f15eb72ef338" -dependencies = [ - "indexmap", - "toml_datetime", - "winnow", -] - [[package]] name = "typenum" version = "1.17.0" @@ -745,15 +493,6 @@ version = "0.11.0+wasi-snapshot-preview1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "9c8d87e72b64a3b4db28d11ce29237c246188f4f51057d65a7eab63b7987e423" -[[package]] -name = "winnow" -version = "0.5.40" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f593a95398737aeed53e489c785df13f3618e41dbcd6718c6addbf1395aa6876" -dependencies = [ - "memchr", -] - [[package]] name = "wyz" version = "0.5.1" @@ -765,6 +504,6 @@ dependencies = [ [[package]] name = "zeroize" -version = "1.7.0" +version = "1.8.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "525b4ec142c6b68a2d10f01f7bbf6755599ca3f81ea53b8431b7dd348f5fdb2d" +checksum = "ced3678a2879b30306d323f4542626697a464a97c0a07c9aebf7ebca65cd4dde" diff --git a/tests/secp256k1-mul/Cargo.toml b/tests/secp256k1-mul/Cargo.toml index 79774d01f8..451cc9cdee 100644 --- a/tests/secp256k1-mul/Cargo.toml +++ b/tests/secp256k1-mul/Cargo.toml @@ -1,9 +1,10 @@ [workspace] [package] name = "secp256k1-mul-test" -version = "0.1.0" +version = "1.0.0-rc.1" edition = "2021" +publish = false [dependencies] -sp1-zkvm = { path = "../../zkvm/entrypoint" } +sp1-zkvm = { path = "../../zkvm/entrypoint", features = ["secp256k1"] } sp1-derive = { path = "../../derive" } diff --git a/tests/secp256k1-mul/elf/riscv32im-succinct-zkvm-elf b/tests/secp256k1-mul/elf/riscv32im-succinct-zkvm-elf index d3e17ead66..14bc9e609f 100755 Binary files a/tests/secp256k1-mul/elf/riscv32im-succinct-zkvm-elf and b/tests/secp256k1-mul/elf/riscv32im-succinct-zkvm-elf differ diff --git a/tests/secp256k1-mul/src/main.rs b/tests/secp256k1-mul/src/main.rs index a2fb6a3dd3..8b674aea34 100644 --- a/tests/secp256k1-mul/src/main.rs +++ b/tests/secp256k1-mul/src/main.rs @@ -1,8 +1,8 @@ #![no_main] sp1_zkvm::entrypoint!(main); -use sp1_zkvm::precompiles::secp256k1::Secp256k1Operations; -use sp1_zkvm::precompiles::utils::AffinePoint; +use sp1_zkvm::lib::secp256k1::Secp256k1Operations; +use sp1_zkvm::lib::utils::AffinePoint; #[sp1_derive::cycle_tracker] pub fn main() { diff --git a/tests/sha-compress/Cargo.lock b/tests/sha-compress/Cargo.lock index 074ddfec5b..b77e28709e 100644 --- a/tests/sha-compress/Cargo.lock +++ b/tests/sha-compress/Cargo.lock @@ -8,30 +8,6 @@ version = "1.0.86" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "b3d1d046238990b9cf5bcde22a3fb3584ee5cf65fb2765f454ed428c7a0063da" -[[package]] -name = "arrayvec" -version = "0.7.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "96d30a06541fbafbc7f82ed10c06164cfbd2c401138f6addd8404629c4b16711" - -[[package]] -name = "autocfg" -version = "1.2.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f1fdabc7756949593fe60f30ec81974b613357de856987752631dea1e3394c80" - -[[package]] -name = "base16ct" -version = "0.2.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4c7f02d4ea65f2c1853089ffd8d2787bdbc63de2f0d29dedbcf8ccdfa0ccd4cf" - -[[package]] -name = "base64ct" -version = "1.6.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8c3c1a368f70d6cf7302d78f8f7093da241fb8e8807c05cc9e51a125895a6d5b" - [[package]] name = "bincode" version = "1.3.3" @@ -41,18 +17,6 @@ dependencies = [ "serde", ] -[[package]] -name = "bitvec" -version = "1.0.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1bc2832c24239b0141d5674bb9174f9d68a8b5b3f2753311927c172ca46f7e9c" -dependencies = [ - "funty", - "radium", - "tap", - "wyz", -] - [[package]] name = "block-buffer" version = "0.10.4" @@ -62,24 +26,12 @@ dependencies = [ "generic-array", ] -[[package]] -name = "byte-slice-cast" -version = "1.2.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c3ac9f8b63eca6fd385229b3675f6cc0dc5c8a5c8a54a59d4f52ffd670d87b0c" - [[package]] name = "cfg-if" version = "1.0.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "baf1de4339761588bc0619e3cbc0120ee582ebb74b53b4efbf79117bd2da40fd" -[[package]] -name = "const-oid" -version = "0.9.6" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c2459377285ad874054d797f3ccebf984978aa39129f6eafde5cdc8315b612f8" - [[package]] name = "cpufeatures" version = "0.2.12" @@ -89,18 +41,6 @@ dependencies = [ "libc", ] -[[package]] -name = "crypto-bigint" -version = "0.5.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0dc92fb57ca44df6db8059111ab3af99a63d5d0f8375d9972e319a379c6bab76" -dependencies = [ - "generic-array", - "rand_core", - "subtle", - "zeroize", -] - [[package]] name = "crypto-common" version = "0.1.6" @@ -111,27 +51,6 @@ dependencies = [ "typenum", ] -[[package]] -name = "der" -version = "0.7.8" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "fffa369a668c8af7dbf8b5e56c9f744fbd399949ed171606040001947de40b1c" -dependencies = [ - "const-oid", - "zeroize", -] - -[[package]] -name = "derive_more" -version = "0.99.17" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4fb810d30a7c1953f91334de7244731fc3f3c10d7fe163338a35b9f640960321" -dependencies = [ - "proc-macro2", - "quote", - "syn 1.0.109", -] - [[package]] name = "digest" version = "0.10.7" @@ -139,68 +58,9 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "9ed9a281f7bc9b7576e61468ba615a66a5c8cfdff42420a70aa82701a3b1e292" dependencies = [ "block-buffer", - "const-oid", "crypto-common", - "subtle", -] - -[[package]] -name = "ecdsa" -version = "0.16.9" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ee27f32b5c5292967d2d4a9d7f1e0b0aed2c15daded5a60300e4abb9d8020bca" -dependencies = [ - "der", - "digest", - "elliptic-curve", - "rfc6979", - "signature", - "spki", -] - -[[package]] -name = "elliptic-curve" -version = "0.13.8" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b5e6043086bf7973472e0c7dff2142ea0b680d30e18d9cc40f267efbf222bd47" -dependencies = [ - "base16ct", - "crypto-bigint", - "digest", - "ff", - "generic-array", - "group", - "pkcs8", - "rand_core", - "sec1", - "subtle", - "tap", - "zeroize", -] - -[[package]] -name = "equivalent" -version = "1.0.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5443807d6dff69373d433ab9ef5378ad8df50ca6298caf15de6e52e24aaf54d5" - -[[package]] -name = "ff" -version = "0.13.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ded41244b729663b1e574f1b4fb731469f69f79c17667b5d776b16cda0479449" -dependencies = [ - "bitvec", - "rand_core", - "subtle", ] -[[package]] -name = "funty" -version = "2.0.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e6d5a32815ae3f33302d95fdcb2ce17862f8c65363dcfd29360480ba1001fc9c" - [[package]] name = "generic-array" version = "0.14.7" @@ -209,7 +69,6 @@ checksum = "85649ca51fd72272d7821adaf274ad91c288277713d9c18820d8499a7ff69e9a" dependencies = [ "typenum", "version_check", - "zeroize", ] [[package]] @@ -224,71 +83,10 @@ dependencies = [ ] [[package]] -name = "group" -version = "0.13.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f0f9ef7462f7c099f518d754361858f86d8a07af53ba9af0fe635bbccb151a63" -dependencies = [ - "ff", - "rand_core", - "subtle", -] - -[[package]] -name = "hashbrown" -version = "0.14.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "290f1a1d9242c78d09ce40a5e87e7554ee637af1351968159f4952f028f75604" - -[[package]] -name = "hex" -version = "0.4.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7f24254aa9a54b5c858eaee2f5bccdb46aaf0e486a595ed5fd8f86ba55232a70" - -[[package]] -name = "hmac" -version = "0.12.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6c49c37c09c17a53d937dfbb742eb3a961d65a994e6bcdcf37e7399d0cc8ab5e" -dependencies = [ - "digest", -] - -[[package]] -name = "impl-trait-for-tuples" -version = "0.2.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "11d7a9f6330b71fea57921c9b61c47ee6e84f72d394754eff6163ae67e7395eb" -dependencies = [ - "proc-macro2", - "quote", - "syn 1.0.109", -] - -[[package]] -name = "indexmap" -version = "2.2.6" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "168fb715dda47215e360912c096649d23d58bf392ac62f73919e831745e40f26" -dependencies = [ - "equivalent", - "hashbrown", -] - -[[package]] -name = "k256" -version = "0.13.3" +name = "lazy_static" +version = "1.5.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "956ff9b67e26e1a6a866cb758f12c6f8746208489e3e4a4b5580802f2f0a587b" -dependencies = [ - "cfg-if", - "ecdsa", - "elliptic-curve", - "once_cell", - "sha2", - "signature", -] +checksum = "bbd2bcb4c963f2ddae06a2efc7e9f3591312473c50c6685e1f298068316e66fe" [[package]] name = "libc" @@ -302,151 +100,18 @@ version = "0.2.8" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "4ec2a862134d2a7d32d7983ddcdd1c4923530833c9f2ea1a44fc5fa473989058" -[[package]] -name = "memchr" -version = "2.7.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6c8640c5d730cb13ebd907d8d04b52f55ac9a2eec55b440c8892f40d56c76c1d" - -[[package]] -name = "num" -version = "0.4.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "35bd024e8b2ff75562e5f34e7f4905839deb4b22955ef5e73d2fea1b9813cb23" -dependencies = [ - "num-bigint", - "num-complex", - "num-integer", - "num-iter", - "num-rational", - "num-traits", -] - -[[package]] -name = "num-bigint" -version = "0.4.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c165a9ab64cf766f73521c0dd2cfdff64f488b8f0b3e621face3462d3db536d7" -dependencies = [ - "num-integer", - "num-traits", -] - -[[package]] -name = "num-complex" -version = "0.4.6" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "73f88a1307638156682bada9d7604135552957b7818057dcef22705b4d509495" -dependencies = [ - "num-traits", -] - -[[package]] -name = "num-integer" -version = "0.1.46" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7969661fd2958a5cb096e56c8e1ad0444ac2bbcd0061bd28660485a44879858f" -dependencies = [ - "num-traits", -] - -[[package]] -name = "num-iter" -version = "0.1.45" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1429034a0490724d0075ebb2bc9e875d6503c3cf69e235a8941aa757d83ef5bf" -dependencies = [ - "autocfg", - "num-integer", - "num-traits", -] - -[[package]] -name = "num-rational" -version = "0.4.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f83d14da390562dca69fc84082e73e548e1ad308d24accdedd2720017cb37824" -dependencies = [ - "num-bigint", - "num-integer", - "num-traits", -] - -[[package]] -name = "num-traits" -version = "0.2.19" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "071dfc062690e90b734c0b2273ce72ad0ffa95f0c74596bc250dcfd960262841" -dependencies = [ - "autocfg", -] - [[package]] name = "once_cell" version = "1.19.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "3fdb12b2476b595f9358c5161aa467c2438859caa136dec86c26fdd2efe17b92" -[[package]] -name = "parity-scale-codec" -version = "3.6.9" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "881331e34fa842a2fb61cc2db9643a8fedc615e47cfcc52597d1af0db9a7e8fe" -dependencies = [ - "arrayvec", - "byte-slice-cast", - "impl-trait-for-tuples", - "parity-scale-codec-derive", -] - -[[package]] -name = "parity-scale-codec-derive" -version = "3.6.9" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "be30eaf4b0a9fba5336683b38de57bb86d179a35862ba6bfcf57625d006bde5b" -dependencies = [ - "proc-macro-crate 2.0.2", - "proc-macro2", - "quote", - "syn 1.0.109", -] - -[[package]] -name = "pkcs8" -version = "0.10.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f950b2377845cebe5cf8b5165cb3cc1a5e0fa5cfa3e1f7f55707d8fd82e0a7b7" -dependencies = [ - "der", - "spki", -] - [[package]] name = "ppv-lite86" version = "0.2.17" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "5b40af805b3121feab8a3c29f04d8ad262fa8e0561883e7653e024ae4479e6de" -[[package]] -name = "proc-macro-crate" -version = "1.3.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7f4c021e1093a56626774e81216a4ce732a735e5bad4868a03f3ed65ca0c3919" -dependencies = [ - "once_cell", - "toml_edit 0.19.15", -] - -[[package]] -name = "proc-macro-crate" -version = "2.0.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b00f26d3400549137f92511a46ac1cd8ce37cb5598a96d382381458b992a5d24" -dependencies = [ - "toml_datetime", - "toml_edit 0.20.2", -] - [[package]] name = "proc-macro2" version = "1.0.78" @@ -465,12 +130,6 @@ dependencies = [ "proc-macro2", ] -[[package]] -name = "radium" -version = "0.7.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "dc33ff2d4973d518d823d61aa239014831e521c75da58e3df4840d3f47749d09" - [[package]] name = "rand" version = "0.8.5" @@ -501,54 +160,6 @@ dependencies = [ "getrandom", ] -[[package]] -name = "rfc6979" -version = "0.4.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f8dd2a808d456c4a54e300a23e9f5a67e122c3024119acbfd73e3bf664491cb2" -dependencies = [ - "hmac", - "subtle", -] - -[[package]] -name = "scale-info" -version = "2.11.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7c453e59a955f81fb62ee5d596b450383d699f152d350e9d23a0db2adb78e4c0" -dependencies = [ - "cfg-if", - "derive_more", - "parity-scale-codec", - "scale-info-derive", -] - -[[package]] -name = "scale-info-derive" -version = "2.11.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "18cf6c6447f813ef19eb450e985bcce6705f9ce7660db221b59093d15c79c4b7" -dependencies = [ - "proc-macro-crate 1.3.1", - "proc-macro2", - "quote", - "syn 1.0.109", -] - -[[package]] -name = "sec1" -version = "0.7.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d3e97a565f76233a6003f9f5c54be1d9c5bdfa3eccfb189469f11ec4901c47dc" -dependencies = [ - "base16ct", - "der", - "generic-array", - "pkcs8", - "subtle", - "zeroize", -] - [[package]] name = "serde" version = "1.0.203" @@ -566,7 +177,7 @@ checksum = "500cbc0ebeb6f46627f50f3f5811ccf6bf00643be300b4c3eabc0ef55dc5b5ba" dependencies = [ "proc-macro2", "quote", - "syn 2.0.48", + "syn", ] [[package]] @@ -588,39 +199,13 @@ dependencies = [ ] [[package]] -name = "signature" -version = "2.2.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "77549399552de45a898a580c1b41d445bf730df867cc44e6c0233bbc4b8329de" -dependencies = [ - "digest", - "rand_core", -] - -[[package]] -name = "snowbridge-amcl" -version = "1.0.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "460a9ed63cdf03c1b9847e8a12a5f5ba19c4efd5869e4a737e05be25d7c427e5" -dependencies = [ - "parity-scale-codec", - "scale-info", -] - -[[package]] -name = "sp1-precompiles" +name = "sp1-lib" version = "0.1.0" dependencies = [ "anyhow", "bincode", "cfg-if", - "getrandom", - "hex", - "k256", - "num", - "rand", "serde", - "snowbridge-amcl", ] [[package]] @@ -630,40 +215,13 @@ dependencies = [ "bincode", "cfg-if", "getrandom", - "k256", + "lazy_static", "libm", "once_cell", "rand", "serde", "sha2", - "sp1-precompiles", -] - -[[package]] -name = "spki" -version = "0.7.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d91ed6c858b01f942cd56b37a94b3e0a1798290327d1236e4d9cf4eaca44d29d" -dependencies = [ - "base64ct", - "der", -] - -[[package]] -name = "subtle" -version = "2.5.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "81cdd64d312baedb58e21336b31bc043b77e01cc99033ce76ef539f78e965ebc" - -[[package]] -name = "syn" -version = "1.0.109" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "72b64191b275b66ffe2469e8af2c1cfe3bafa67b529ead792a6d0160888b4237" -dependencies = [ - "proc-macro2", - "quote", - "unicode-ident", + "sp1-lib", ] [[package]] @@ -677,40 +235,6 @@ dependencies = [ "unicode-ident", ] -[[package]] -name = "tap" -version = "1.0.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "55937e1799185b12863d447f42597ed69d9928686b8d88a1df17376a097d8369" - -[[package]] -name = "toml_datetime" -version = "0.6.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7cda73e2f1397b1262d6dfdcef8aafae14d1de7748d66822d3bfeeb6d03e5e4b" - -[[package]] -name = "toml_edit" -version = "0.19.15" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1b5bb770da30e5cbfde35a2d7b9b8a2c4b8ef89548a7a6aeab5c9a576e3e7421" -dependencies = [ - "indexmap", - "toml_datetime", - "winnow", -] - -[[package]] -name = "toml_edit" -version = "0.20.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "396e4d48bbb2b7554c944bde63101b5ae446cff6ec4a24227428f15eb72ef338" -dependencies = [ - "indexmap", - "toml_datetime", - "winnow", -] - [[package]] name = "typenum" version = "1.17.0" @@ -734,27 +258,3 @@ name = "wasi" version = "0.11.0+wasi-snapshot-preview1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "9c8d87e72b64a3b4db28d11ce29237c246188f4f51057d65a7eab63b7987e423" - -[[package]] -name = "winnow" -version = "0.5.40" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f593a95398737aeed53e489c785df13f3618e41dbcd6718c6addbf1395aa6876" -dependencies = [ - "memchr", -] - -[[package]] -name = "wyz" -version = "0.5.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "05f360fc0b24296329c78fda852a1e9ae82de9cf7b27dae4b7f62f118f77b9ed" -dependencies = [ - "tap", -] - -[[package]] -name = "zeroize" -version = "1.7.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "525b4ec142c6b68a2d10f01f7bbf6755599ca3f81ea53b8431b7dd348f5fdb2d" diff --git a/tests/sha-compress/Cargo.toml b/tests/sha-compress/Cargo.toml index 0e6422b80b..a7459e5e39 100644 --- a/tests/sha-compress/Cargo.toml +++ b/tests/sha-compress/Cargo.toml @@ -1,8 +1,9 @@ [workspace] [package] -version = "0.1.0" name = "sha-compress-test" +version = "1.0.0-rc.1" edition = "2021" +publish = false [dependencies] sp1-zkvm = { path = "../../zkvm/entrypoint" } diff --git a/tests/sha-compress/elf/riscv32im-succinct-zkvm-elf b/tests/sha-compress/elf/riscv32im-succinct-zkvm-elf index f10443e120..7c6e8810dc 100755 Binary files a/tests/sha-compress/elf/riscv32im-succinct-zkvm-elf and b/tests/sha-compress/elf/riscv32im-succinct-zkvm-elf differ diff --git a/tests/sha-extend/Cargo.lock b/tests/sha-extend/Cargo.lock index 89c5065f99..e1a18283e0 100644 --- a/tests/sha-extend/Cargo.lock +++ b/tests/sha-extend/Cargo.lock @@ -8,30 +8,6 @@ version = "1.0.86" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "b3d1d046238990b9cf5bcde22a3fb3584ee5cf65fb2765f454ed428c7a0063da" -[[package]] -name = "arrayvec" -version = "0.7.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "96d30a06541fbafbc7f82ed10c06164cfbd2c401138f6addd8404629c4b16711" - -[[package]] -name = "autocfg" -version = "1.2.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f1fdabc7756949593fe60f30ec81974b613357de856987752631dea1e3394c80" - -[[package]] -name = "base16ct" -version = "0.2.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4c7f02d4ea65f2c1853089ffd8d2787bdbc63de2f0d29dedbcf8ccdfa0ccd4cf" - -[[package]] -name = "base64ct" -version = "1.6.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8c3c1a368f70d6cf7302d78f8f7093da241fb8e8807c05cc9e51a125895a6d5b" - [[package]] name = "bincode" version = "1.3.3" @@ -41,18 +17,6 @@ dependencies = [ "serde", ] -[[package]] -name = "bitvec" -version = "1.0.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1bc2832c24239b0141d5674bb9174f9d68a8b5b3f2753311927c172ca46f7e9c" -dependencies = [ - "funty", - "radium", - "tap", - "wyz", -] - [[package]] name = "block-buffer" version = "0.10.4" @@ -62,24 +26,12 @@ dependencies = [ "generic-array", ] -[[package]] -name = "byte-slice-cast" -version = "1.2.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c3ac9f8b63eca6fd385229b3675f6cc0dc5c8a5c8a54a59d4f52ffd670d87b0c" - [[package]] name = "cfg-if" version = "1.0.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "baf1de4339761588bc0619e3cbc0120ee582ebb74b53b4efbf79117bd2da40fd" -[[package]] -name = "const-oid" -version = "0.9.6" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c2459377285ad874054d797f3ccebf984978aa39129f6eafde5cdc8315b612f8" - [[package]] name = "cpufeatures" version = "0.2.12" @@ -89,18 +41,6 @@ dependencies = [ "libc", ] -[[package]] -name = "crypto-bigint" -version = "0.5.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0dc92fb57ca44df6db8059111ab3af99a63d5d0f8375d9972e319a379c6bab76" -dependencies = [ - "generic-array", - "rand_core", - "subtle", - "zeroize", -] - [[package]] name = "crypto-common" version = "0.1.6" @@ -111,27 +51,6 @@ dependencies = [ "typenum", ] -[[package]] -name = "der" -version = "0.7.8" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "fffa369a668c8af7dbf8b5e56c9f744fbd399949ed171606040001947de40b1c" -dependencies = [ - "const-oid", - "zeroize", -] - -[[package]] -name = "derive_more" -version = "0.99.17" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4fb810d30a7c1953f91334de7244731fc3f3c10d7fe163338a35b9f640960321" -dependencies = [ - "proc-macro2", - "quote", - "syn 1.0.109", -] - [[package]] name = "digest" version = "0.10.7" @@ -139,68 +58,9 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "9ed9a281f7bc9b7576e61468ba615a66a5c8cfdff42420a70aa82701a3b1e292" dependencies = [ "block-buffer", - "const-oid", "crypto-common", - "subtle", -] - -[[package]] -name = "ecdsa" -version = "0.16.9" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ee27f32b5c5292967d2d4a9d7f1e0b0aed2c15daded5a60300e4abb9d8020bca" -dependencies = [ - "der", - "digest", - "elliptic-curve", - "rfc6979", - "signature", - "spki", -] - -[[package]] -name = "elliptic-curve" -version = "0.13.8" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b5e6043086bf7973472e0c7dff2142ea0b680d30e18d9cc40f267efbf222bd47" -dependencies = [ - "base16ct", - "crypto-bigint", - "digest", - "ff", - "generic-array", - "group", - "pkcs8", - "rand_core", - "sec1", - "subtle", - "tap", - "zeroize", -] - -[[package]] -name = "equivalent" -version = "1.0.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5443807d6dff69373d433ab9ef5378ad8df50ca6298caf15de6e52e24aaf54d5" - -[[package]] -name = "ff" -version = "0.13.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ded41244b729663b1e574f1b4fb731469f69f79c17667b5d776b16cda0479449" -dependencies = [ - "bitvec", - "rand_core", - "subtle", ] -[[package]] -name = "funty" -version = "2.0.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e6d5a32815ae3f33302d95fdcb2ce17862f8c65363dcfd29360480ba1001fc9c" - [[package]] name = "generic-array" version = "0.14.7" @@ -209,7 +69,6 @@ checksum = "85649ca51fd72272d7821adaf274ad91c288277713d9c18820d8499a7ff69e9a" dependencies = [ "typenum", "version_check", - "zeroize", ] [[package]] @@ -224,71 +83,10 @@ dependencies = [ ] [[package]] -name = "group" -version = "0.13.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f0f9ef7462f7c099f518d754361858f86d8a07af53ba9af0fe635bbccb151a63" -dependencies = [ - "ff", - "rand_core", - "subtle", -] - -[[package]] -name = "hashbrown" -version = "0.14.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "290f1a1d9242c78d09ce40a5e87e7554ee637af1351968159f4952f028f75604" - -[[package]] -name = "hex" -version = "0.4.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7f24254aa9a54b5c858eaee2f5bccdb46aaf0e486a595ed5fd8f86ba55232a70" - -[[package]] -name = "hmac" -version = "0.12.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6c49c37c09c17a53d937dfbb742eb3a961d65a994e6bcdcf37e7399d0cc8ab5e" -dependencies = [ - "digest", -] - -[[package]] -name = "impl-trait-for-tuples" -version = "0.2.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "11d7a9f6330b71fea57921c9b61c47ee6e84f72d394754eff6163ae67e7395eb" -dependencies = [ - "proc-macro2", - "quote", - "syn 1.0.109", -] - -[[package]] -name = "indexmap" -version = "2.2.6" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "168fb715dda47215e360912c096649d23d58bf392ac62f73919e831745e40f26" -dependencies = [ - "equivalent", - "hashbrown", -] - -[[package]] -name = "k256" -version = "0.13.3" +name = "lazy_static" +version = "1.5.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "956ff9b67e26e1a6a866cb758f12c6f8746208489e3e4a4b5580802f2f0a587b" -dependencies = [ - "cfg-if", - "ecdsa", - "elliptic-curve", - "once_cell", - "sha2", - "signature", -] +checksum = "bbd2bcb4c963f2ddae06a2efc7e9f3591312473c50c6685e1f298068316e66fe" [[package]] name = "libc" @@ -302,151 +100,18 @@ version = "0.2.8" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "4ec2a862134d2a7d32d7983ddcdd1c4923530833c9f2ea1a44fc5fa473989058" -[[package]] -name = "memchr" -version = "2.7.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6c8640c5d730cb13ebd907d8d04b52f55ac9a2eec55b440c8892f40d56c76c1d" - -[[package]] -name = "num" -version = "0.4.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "35bd024e8b2ff75562e5f34e7f4905839deb4b22955ef5e73d2fea1b9813cb23" -dependencies = [ - "num-bigint", - "num-complex", - "num-integer", - "num-iter", - "num-rational", - "num-traits", -] - -[[package]] -name = "num-bigint" -version = "0.4.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c165a9ab64cf766f73521c0dd2cfdff64f488b8f0b3e621face3462d3db536d7" -dependencies = [ - "num-integer", - "num-traits", -] - -[[package]] -name = "num-complex" -version = "0.4.6" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "73f88a1307638156682bada9d7604135552957b7818057dcef22705b4d509495" -dependencies = [ - "num-traits", -] - -[[package]] -name = "num-integer" -version = "0.1.46" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7969661fd2958a5cb096e56c8e1ad0444ac2bbcd0061bd28660485a44879858f" -dependencies = [ - "num-traits", -] - -[[package]] -name = "num-iter" -version = "0.1.45" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1429034a0490724d0075ebb2bc9e875d6503c3cf69e235a8941aa757d83ef5bf" -dependencies = [ - "autocfg", - "num-integer", - "num-traits", -] - -[[package]] -name = "num-rational" -version = "0.4.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f83d14da390562dca69fc84082e73e548e1ad308d24accdedd2720017cb37824" -dependencies = [ - "num-bigint", - "num-integer", - "num-traits", -] - -[[package]] -name = "num-traits" -version = "0.2.19" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "071dfc062690e90b734c0b2273ce72ad0ffa95f0c74596bc250dcfd960262841" -dependencies = [ - "autocfg", -] - [[package]] name = "once_cell" version = "1.19.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "3fdb12b2476b595f9358c5161aa467c2438859caa136dec86c26fdd2efe17b92" -[[package]] -name = "parity-scale-codec" -version = "3.6.9" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "881331e34fa842a2fb61cc2db9643a8fedc615e47cfcc52597d1af0db9a7e8fe" -dependencies = [ - "arrayvec", - "byte-slice-cast", - "impl-trait-for-tuples", - "parity-scale-codec-derive", -] - -[[package]] -name = "parity-scale-codec-derive" -version = "3.6.9" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "be30eaf4b0a9fba5336683b38de57bb86d179a35862ba6bfcf57625d006bde5b" -dependencies = [ - "proc-macro-crate 2.0.2", - "proc-macro2", - "quote", - "syn 1.0.109", -] - -[[package]] -name = "pkcs8" -version = "0.10.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f950b2377845cebe5cf8b5165cb3cc1a5e0fa5cfa3e1f7f55707d8fd82e0a7b7" -dependencies = [ - "der", - "spki", -] - [[package]] name = "ppv-lite86" version = "0.2.17" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "5b40af805b3121feab8a3c29f04d8ad262fa8e0561883e7653e024ae4479e6de" -[[package]] -name = "proc-macro-crate" -version = "1.3.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7f4c021e1093a56626774e81216a4ce732a735e5bad4868a03f3ed65ca0c3919" -dependencies = [ - "once_cell", - "toml_edit 0.19.15", -] - -[[package]] -name = "proc-macro-crate" -version = "2.0.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b00f26d3400549137f92511a46ac1cd8ce37cb5598a96d382381458b992a5d24" -dependencies = [ - "toml_datetime", - "toml_edit 0.20.2", -] - [[package]] name = "proc-macro2" version = "1.0.78" @@ -465,12 +130,6 @@ dependencies = [ "proc-macro2", ] -[[package]] -name = "radium" -version = "0.7.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "dc33ff2d4973d518d823d61aa239014831e521c75da58e3df4840d3f47749d09" - [[package]] name = "rand" version = "0.8.5" @@ -501,54 +160,6 @@ dependencies = [ "getrandom", ] -[[package]] -name = "rfc6979" -version = "0.4.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f8dd2a808d456c4a54e300a23e9f5a67e122c3024119acbfd73e3bf664491cb2" -dependencies = [ - "hmac", - "subtle", -] - -[[package]] -name = "scale-info" -version = "2.11.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7c453e59a955f81fb62ee5d596b450383d699f152d350e9d23a0db2adb78e4c0" -dependencies = [ - "cfg-if", - "derive_more", - "parity-scale-codec", - "scale-info-derive", -] - -[[package]] -name = "scale-info-derive" -version = "2.11.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "18cf6c6447f813ef19eb450e985bcce6705f9ce7660db221b59093d15c79c4b7" -dependencies = [ - "proc-macro-crate 1.3.1", - "proc-macro2", - "quote", - "syn 1.0.109", -] - -[[package]] -name = "sec1" -version = "0.7.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d3e97a565f76233a6003f9f5c54be1d9c5bdfa3eccfb189469f11ec4901c47dc" -dependencies = [ - "base16ct", - "der", - "generic-array", - "pkcs8", - "subtle", - "zeroize", -] - [[package]] name = "serde" version = "1.0.203" @@ -566,7 +177,7 @@ checksum = "500cbc0ebeb6f46627f50f3f5811ccf6bf00643be300b4c3eabc0ef55dc5b5ba" dependencies = [ "proc-macro2", "quote", - "syn 2.0.48", + "syn", ] [[package]] @@ -588,39 +199,13 @@ dependencies = [ ] [[package]] -name = "signature" -version = "2.2.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "77549399552de45a898a580c1b41d445bf730df867cc44e6c0233bbc4b8329de" -dependencies = [ - "digest", - "rand_core", -] - -[[package]] -name = "snowbridge-amcl" -version = "1.0.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "460a9ed63cdf03c1b9847e8a12a5f5ba19c4efd5869e4a737e05be25d7c427e5" -dependencies = [ - "parity-scale-codec", - "scale-info", -] - -[[package]] -name = "sp1-precompiles" +name = "sp1-lib" version = "0.1.0" dependencies = [ "anyhow", "bincode", "cfg-if", - "getrandom", - "hex", - "k256", - "num", - "rand", "serde", - "snowbridge-amcl", ] [[package]] @@ -630,40 +215,13 @@ dependencies = [ "bincode", "cfg-if", "getrandom", - "k256", + "lazy_static", "libm", "once_cell", "rand", "serde", "sha2", - "sp1-precompiles", -] - -[[package]] -name = "spki" -version = "0.7.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d91ed6c858b01f942cd56b37a94b3e0a1798290327d1236e4d9cf4eaca44d29d" -dependencies = [ - "base64ct", - "der", -] - -[[package]] -name = "subtle" -version = "2.5.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "81cdd64d312baedb58e21336b31bc043b77e01cc99033ce76ef539f78e965ebc" - -[[package]] -name = "syn" -version = "1.0.109" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "72b64191b275b66ffe2469e8af2c1cfe3bafa67b529ead792a6d0160888b4237" -dependencies = [ - "proc-macro2", - "quote", - "unicode-ident", + "sp1-lib", ] [[package]] @@ -677,40 +235,6 @@ dependencies = [ "unicode-ident", ] -[[package]] -name = "tap" -version = "1.0.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "55937e1799185b12863d447f42597ed69d9928686b8d88a1df17376a097d8369" - -[[package]] -name = "toml_datetime" -version = "0.6.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7cda73e2f1397b1262d6dfdcef8aafae14d1de7748d66822d3bfeeb6d03e5e4b" - -[[package]] -name = "toml_edit" -version = "0.19.15" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1b5bb770da30e5cbfde35a2d7b9b8a2c4b8ef89548a7a6aeab5c9a576e3e7421" -dependencies = [ - "indexmap", - "toml_datetime", - "winnow", -] - -[[package]] -name = "toml_edit" -version = "0.20.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "396e4d48bbb2b7554c944bde63101b5ae446cff6ec4a24227428f15eb72ef338" -dependencies = [ - "indexmap", - "toml_datetime", - "winnow", -] - [[package]] name = "typenum" version = "1.17.0" @@ -734,27 +258,3 @@ name = "wasi" version = "0.11.0+wasi-snapshot-preview1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "9c8d87e72b64a3b4db28d11ce29237c246188f4f51057d65a7eab63b7987e423" - -[[package]] -name = "winnow" -version = "0.5.40" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f593a95398737aeed53e489c785df13f3618e41dbcd6718c6addbf1395aa6876" -dependencies = [ - "memchr", -] - -[[package]] -name = "wyz" -version = "0.5.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "05f360fc0b24296329c78fda852a1e9ae82de9cf7b27dae4b7f62f118f77b9ed" -dependencies = [ - "tap", -] - -[[package]] -name = "zeroize" -version = "1.7.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "525b4ec142c6b68a2d10f01f7bbf6755599ca3f81ea53b8431b7dd348f5fdb2d" diff --git a/tests/sha-extend/Cargo.toml b/tests/sha-extend/Cargo.toml index 576dd8b680..ee2b76c606 100644 --- a/tests/sha-extend/Cargo.toml +++ b/tests/sha-extend/Cargo.toml @@ -1,8 +1,9 @@ [workspace] [package] -version = "0.1.0" name = "sha-extend-test" +version = "1.0.0-rc.1" edition = "2021" +publish = false [dependencies] sp1-zkvm = { path = "../../zkvm/entrypoint" } diff --git a/tests/sha-extend/elf/riscv32im-succinct-zkvm-elf b/tests/sha-extend/elf/riscv32im-succinct-zkvm-elf index d584e1c358..0a56930303 100755 Binary files a/tests/sha-extend/elf/riscv32im-succinct-zkvm-elf and b/tests/sha-extend/elf/riscv32im-succinct-zkvm-elf differ diff --git a/tests/sha2/Cargo.lock b/tests/sha2/Cargo.lock index 6e417a8fcb..f023d1127d 100644 --- a/tests/sha2/Cargo.lock +++ b/tests/sha2/Cargo.lock @@ -8,30 +8,6 @@ version = "1.0.86" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "b3d1d046238990b9cf5bcde22a3fb3584ee5cf65fb2765f454ed428c7a0063da" -[[package]] -name = "arrayvec" -version = "0.7.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "96d30a06541fbafbc7f82ed10c06164cfbd2c401138f6addd8404629c4b16711" - -[[package]] -name = "autocfg" -version = "1.2.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f1fdabc7756949593fe60f30ec81974b613357de856987752631dea1e3394c80" - -[[package]] -name = "base16ct" -version = "0.2.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4c7f02d4ea65f2c1853089ffd8d2787bdbc63de2f0d29dedbcf8ccdfa0ccd4cf" - -[[package]] -name = "base64ct" -version = "1.6.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8c3c1a368f70d6cf7302d78f8f7093da241fb8e8807c05cc9e51a125895a6d5b" - [[package]] name = "bincode" version = "1.3.3" @@ -41,18 +17,6 @@ dependencies = [ "serde", ] -[[package]] -name = "bitvec" -version = "1.0.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1bc2832c24239b0141d5674bb9174f9d68a8b5b3f2753311927c172ca46f7e9c" -dependencies = [ - "funty", - "radium", - "tap", - "wyz", -] - [[package]] name = "block-buffer" version = "0.10.4" @@ -62,24 +26,12 @@ dependencies = [ "generic-array", ] -[[package]] -name = "byte-slice-cast" -version = "1.2.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c3ac9f8b63eca6fd385229b3675f6cc0dc5c8a5c8a54a59d4f52ffd670d87b0c" - [[package]] name = "cfg-if" version = "1.0.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "baf1de4339761588bc0619e3cbc0120ee582ebb74b53b4efbf79117bd2da40fd" -[[package]] -name = "const-oid" -version = "0.9.6" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c2459377285ad874054d797f3ccebf984978aa39129f6eafde5cdc8315b612f8" - [[package]] name = "cpufeatures" version = "0.2.12" @@ -89,18 +41,6 @@ dependencies = [ "libc", ] -[[package]] -name = "crypto-bigint" -version = "0.5.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0dc92fb57ca44df6db8059111ab3af99a63d5d0f8375d9972e319a379c6bab76" -dependencies = [ - "generic-array", - "rand_core", - "subtle", - "zeroize", -] - [[package]] name = "crypto-common" version = "0.1.6" @@ -111,27 +51,6 @@ dependencies = [ "typenum", ] -[[package]] -name = "der" -version = "0.7.8" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "fffa369a668c8af7dbf8b5e56c9f744fbd399949ed171606040001947de40b1c" -dependencies = [ - "const-oid", - "zeroize", -] - -[[package]] -name = "derive_more" -version = "0.99.17" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4fb810d30a7c1953f91334de7244731fc3f3c10d7fe163338a35b9f640960321" -dependencies = [ - "proc-macro2", - "quote", - "syn 1.0.109", -] - [[package]] name = "digest" version = "0.10.7" @@ -139,68 +58,9 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "9ed9a281f7bc9b7576e61468ba615a66a5c8cfdff42420a70aa82701a3b1e292" dependencies = [ "block-buffer", - "const-oid", "crypto-common", - "subtle", -] - -[[package]] -name = "ecdsa" -version = "0.16.9" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ee27f32b5c5292967d2d4a9d7f1e0b0aed2c15daded5a60300e4abb9d8020bca" -dependencies = [ - "der", - "digest", - "elliptic-curve", - "rfc6979", - "signature", - "spki", -] - -[[package]] -name = "elliptic-curve" -version = "0.13.8" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b5e6043086bf7973472e0c7dff2142ea0b680d30e18d9cc40f267efbf222bd47" -dependencies = [ - "base16ct", - "crypto-bigint", - "digest", - "ff", - "generic-array", - "group", - "pkcs8", - "rand_core", - "sec1", - "subtle", - "tap", - "zeroize", -] - -[[package]] -name = "equivalent" -version = "1.0.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5443807d6dff69373d433ab9ef5378ad8df50ca6298caf15de6e52e24aaf54d5" - -[[package]] -name = "ff" -version = "0.13.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ded41244b729663b1e574f1b4fb731469f69f79c17667b5d776b16cda0479449" -dependencies = [ - "bitvec", - "rand_core", - "subtle", ] -[[package]] -name = "funty" -version = "2.0.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e6d5a32815ae3f33302d95fdcb2ce17862f8c65363dcfd29360480ba1001fc9c" - [[package]] name = "generic-array" version = "0.14.7" @@ -209,7 +69,6 @@ checksum = "85649ca51fd72272d7821adaf274ad91c288277713d9c18820d8499a7ff69e9a" dependencies = [ "typenum", "version_check", - "zeroize", ] [[package]] @@ -223,23 +82,6 @@ dependencies = [ "wasi", ] -[[package]] -name = "group" -version = "0.13.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f0f9ef7462f7c099f518d754361858f86d8a07af53ba9af0fe635bbccb151a63" -dependencies = [ - "ff", - "rand_core", - "subtle", -] - -[[package]] -name = "hashbrown" -version = "0.14.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "290f1a1d9242c78d09ce40a5e87e7554ee637af1351968159f4952f028f75604" - [[package]] name = "hex" version = "0.4.3" @@ -253,48 +95,10 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "6fe2267d4ed49bc07b63801559be28c718ea06c4738b7a03c94df7386d2cde46" [[package]] -name = "hmac" -version = "0.12.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6c49c37c09c17a53d937dfbb742eb3a961d65a994e6bcdcf37e7399d0cc8ab5e" -dependencies = [ - "digest", -] - -[[package]] -name = "impl-trait-for-tuples" -version = "0.2.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "11d7a9f6330b71fea57921c9b61c47ee6e84f72d394754eff6163ae67e7395eb" -dependencies = [ - "proc-macro2", - "quote", - "syn 1.0.109", -] - -[[package]] -name = "indexmap" -version = "2.2.6" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "168fb715dda47215e360912c096649d23d58bf392ac62f73919e831745e40f26" -dependencies = [ - "equivalent", - "hashbrown", -] - -[[package]] -name = "k256" -version = "0.13.3" +name = "lazy_static" +version = "1.5.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "956ff9b67e26e1a6a866cb758f12c6f8746208489e3e4a4b5580802f2f0a587b" -dependencies = [ - "cfg-if", - "ecdsa", - "elliptic-curve", - "once_cell", - "sha2 0.10.8", - "signature", -] +checksum = "bbd2bcb4c963f2ddae06a2efc7e9f3591312473c50c6685e1f298068316e66fe" [[package]] name = "libc" @@ -308,151 +112,18 @@ version = "0.2.8" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "4ec2a862134d2a7d32d7983ddcdd1c4923530833c9f2ea1a44fc5fa473989058" -[[package]] -name = "memchr" -version = "2.7.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6c8640c5d730cb13ebd907d8d04b52f55ac9a2eec55b440c8892f40d56c76c1d" - -[[package]] -name = "num" -version = "0.4.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "35bd024e8b2ff75562e5f34e7f4905839deb4b22955ef5e73d2fea1b9813cb23" -dependencies = [ - "num-bigint", - "num-complex", - "num-integer", - "num-iter", - "num-rational", - "num-traits", -] - -[[package]] -name = "num-bigint" -version = "0.4.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c165a9ab64cf766f73521c0dd2cfdff64f488b8f0b3e621face3462d3db536d7" -dependencies = [ - "num-integer", - "num-traits", -] - -[[package]] -name = "num-complex" -version = "0.4.6" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "73f88a1307638156682bada9d7604135552957b7818057dcef22705b4d509495" -dependencies = [ - "num-traits", -] - -[[package]] -name = "num-integer" -version = "0.1.46" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7969661fd2958a5cb096e56c8e1ad0444ac2bbcd0061bd28660485a44879858f" -dependencies = [ - "num-traits", -] - -[[package]] -name = "num-iter" -version = "0.1.45" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1429034a0490724d0075ebb2bc9e875d6503c3cf69e235a8941aa757d83ef5bf" -dependencies = [ - "autocfg", - "num-integer", - "num-traits", -] - -[[package]] -name = "num-rational" -version = "0.4.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f83d14da390562dca69fc84082e73e548e1ad308d24accdedd2720017cb37824" -dependencies = [ - "num-bigint", - "num-integer", - "num-traits", -] - -[[package]] -name = "num-traits" -version = "0.2.19" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "071dfc062690e90b734c0b2273ce72ad0ffa95f0c74596bc250dcfd960262841" -dependencies = [ - "autocfg", -] - [[package]] name = "once_cell" version = "1.19.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "3fdb12b2476b595f9358c5161aa467c2438859caa136dec86c26fdd2efe17b92" -[[package]] -name = "parity-scale-codec" -version = "3.6.9" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "881331e34fa842a2fb61cc2db9643a8fedc615e47cfcc52597d1af0db9a7e8fe" -dependencies = [ - "arrayvec", - "byte-slice-cast", - "impl-trait-for-tuples", - "parity-scale-codec-derive", -] - -[[package]] -name = "parity-scale-codec-derive" -version = "3.6.9" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "be30eaf4b0a9fba5336683b38de57bb86d179a35862ba6bfcf57625d006bde5b" -dependencies = [ - "proc-macro-crate 2.0.2", - "proc-macro2", - "quote", - "syn 1.0.109", -] - -[[package]] -name = "pkcs8" -version = "0.10.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f950b2377845cebe5cf8b5165cb3cc1a5e0fa5cfa3e1f7f55707d8fd82e0a7b7" -dependencies = [ - "der", - "spki", -] - [[package]] name = "ppv-lite86" version = "0.2.17" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "5b40af805b3121feab8a3c29f04d8ad262fa8e0561883e7653e024ae4479e6de" -[[package]] -name = "proc-macro-crate" -version = "1.3.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7f4c021e1093a56626774e81216a4ce732a735e5bad4868a03f3ed65ca0c3919" -dependencies = [ - "once_cell", - "toml_edit 0.19.15", -] - -[[package]] -name = "proc-macro-crate" -version = "2.0.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b00f26d3400549137f92511a46ac1cd8ce37cb5598a96d382381458b992a5d24" -dependencies = [ - "toml_datetime", - "toml_edit 0.20.2", -] - [[package]] name = "proc-macro2" version = "1.0.78" @@ -471,12 +142,6 @@ dependencies = [ "proc-macro2", ] -[[package]] -name = "radium" -version = "0.7.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "dc33ff2d4973d518d823d61aa239014831e521c75da58e3df4840d3f47749d09" - [[package]] name = "rand" version = "0.8.5" @@ -507,54 +172,6 @@ dependencies = [ "getrandom", ] -[[package]] -name = "rfc6979" -version = "0.4.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f8dd2a808d456c4a54e300a23e9f5a67e122c3024119acbfd73e3bf664491cb2" -dependencies = [ - "hmac", - "subtle", -] - -[[package]] -name = "scale-info" -version = "2.11.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7c453e59a955f81fb62ee5d596b450383d699f152d350e9d23a0db2adb78e4c0" -dependencies = [ - "cfg-if", - "derive_more", - "parity-scale-codec", - "scale-info-derive", -] - -[[package]] -name = "scale-info-derive" -version = "2.11.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "18cf6c6447f813ef19eb450e985bcce6705f9ce7660db221b59093d15c79c4b7" -dependencies = [ - "proc-macro-crate 1.3.1", - "proc-macro2", - "quote", - "syn 1.0.109", -] - -[[package]] -name = "sec1" -version = "0.7.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d3e97a565f76233a6003f9f5c54be1d9c5bdfa3eccfb189469f11ec4901c47dc" -dependencies = [ - "base16ct", - "der", - "generic-array", - "pkcs8", - "subtle", - "zeroize", -] - [[package]] name = "serde" version = "1.0.203" @@ -572,7 +189,7 @@ checksum = "500cbc0ebeb6f46627f50f3f5811ccf6bf00643be300b4c3eabc0ef55dc5b5ba" dependencies = [ "proc-macro2", "quote", - "syn 2.0.48", + "syn", ] [[package]] @@ -607,39 +224,13 @@ dependencies = [ ] [[package]] -name = "signature" -version = "2.2.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "77549399552de45a898a580c1b41d445bf730df867cc44e6c0233bbc4b8329de" -dependencies = [ - "digest", - "rand_core", -] - -[[package]] -name = "snowbridge-amcl" -version = "1.0.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "460a9ed63cdf03c1b9847e8a12a5f5ba19c4efd5869e4a737e05be25d7c427e5" -dependencies = [ - "parity-scale-codec", - "scale-info", -] - -[[package]] -name = "sp1-precompiles" +name = "sp1-lib" version = "0.1.0" dependencies = [ "anyhow", "bincode", "cfg-if", - "getrandom", - "hex", - "k256", - "num", - "rand", "serde", - "snowbridge-amcl", ] [[package]] @@ -649,40 +240,13 @@ dependencies = [ "bincode", "cfg-if", "getrandom", - "k256", + "lazy_static", "libm", "once_cell", "rand", "serde", "sha2 0.10.8", - "sp1-precompiles", -] - -[[package]] -name = "spki" -version = "0.7.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d91ed6c858b01f942cd56b37a94b3e0a1798290327d1236e4d9cf4eaca44d29d" -dependencies = [ - "base64ct", - "der", -] - -[[package]] -name = "subtle" -version = "2.5.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "81cdd64d312baedb58e21336b31bc043b77e01cc99033ce76ef539f78e965ebc" - -[[package]] -name = "syn" -version = "1.0.109" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "72b64191b275b66ffe2469e8af2c1cfe3bafa67b529ead792a6d0160888b4237" -dependencies = [ - "proc-macro2", - "quote", - "unicode-ident", + "sp1-lib", ] [[package]] @@ -696,40 +260,6 @@ dependencies = [ "unicode-ident", ] -[[package]] -name = "tap" -version = "1.0.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "55937e1799185b12863d447f42597ed69d9928686b8d88a1df17376a097d8369" - -[[package]] -name = "toml_datetime" -version = "0.6.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7cda73e2f1397b1262d6dfdcef8aafae14d1de7748d66822d3bfeeb6d03e5e4b" - -[[package]] -name = "toml_edit" -version = "0.19.15" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1b5bb770da30e5cbfde35a2d7b9b8a2c4b8ef89548a7a6aeab5c9a576e3e7421" -dependencies = [ - "indexmap", - "toml_datetime", - "winnow", -] - -[[package]] -name = "toml_edit" -version = "0.20.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "396e4d48bbb2b7554c944bde63101b5ae446cff6ec4a24227428f15eb72ef338" -dependencies = [ - "indexmap", - "toml_datetime", - "winnow", -] - [[package]] name = "typenum" version = "1.17.0" @@ -753,27 +283,3 @@ name = "wasi" version = "0.11.0+wasi-snapshot-preview1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "9c8d87e72b64a3b4db28d11ce29237c246188f4f51057d65a7eab63b7987e423" - -[[package]] -name = "winnow" -version = "0.5.40" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f593a95398737aeed53e489c785df13f3618e41dbcd6718c6addbf1395aa6876" -dependencies = [ - "memchr", -] - -[[package]] -name = "wyz" -version = "0.5.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "05f360fc0b24296329c78fda852a1e9ae82de9cf7b27dae4b7f62f118f77b9ed" -dependencies = [ - "tap", -] - -[[package]] -name = "zeroize" -version = "1.7.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "525b4ec142c6b68a2d10f01f7bbf6755599ca3f81ea53b8431b7dd348f5fdb2d" diff --git a/tests/sha2/Cargo.toml b/tests/sha2/Cargo.toml index 0db676e24a..d58f48b4a2 100644 --- a/tests/sha2/Cargo.toml +++ b/tests/sha2/Cargo.toml @@ -1,8 +1,9 @@ [workspace] [package] -version = "0.1.0" name = "sha2-test" +version = "1.0.0-rc.1" edition = "2021" +publish = false [dependencies] sp1-zkvm = { path = "../../zkvm/entrypoint" } diff --git a/tests/sha2/elf/riscv32im-succinct-zkvm-elf b/tests/sha2/elf/riscv32im-succinct-zkvm-elf index 2c63e6648b..0a1c7f5597 100755 Binary files a/tests/sha2/elf/riscv32im-succinct-zkvm-elf and b/tests/sha2/elf/riscv32im-succinct-zkvm-elf differ diff --git a/tests/tendermint-benchmark/Cargo.lock b/tests/tendermint-benchmark/Cargo.lock index a7fff84f09..22038fcd7d 100644 --- a/tests/tendermint-benchmark/Cargo.lock +++ b/tests/tendermint-benchmark/Cargo.lock @@ -8,24 +8,12 @@ version = "1.0.86" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "b3d1d046238990b9cf5bcde22a3fb3584ee5cf65fb2765f454ed428c7a0063da" -[[package]] -name = "arrayvec" -version = "0.7.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "96d30a06541fbafbc7f82ed10c06164cfbd2c401138f6addd8404629c4b16711" - [[package]] name = "autocfg" version = "1.2.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "f1fdabc7756949593fe60f30ec81974b613357de856987752631dea1e3394c80" -[[package]] -name = "base16ct" -version = "0.2.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4c7f02d4ea65f2c1853089ffd8d2787bdbc63de2f0d29dedbcf8ccdfa0ccd4cf" - [[package]] name = "base64ct" version = "1.6.0" @@ -41,18 +29,6 @@ dependencies = [ "serde", ] -[[package]] -name = "bitvec" -version = "1.0.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1bc2832c24239b0141d5674bb9174f9d68a8b5b3f2753311927c172ca46f7e9c" -dependencies = [ - "funty", - "radium", - "tap", - "wyz", -] - [[package]] name = "block-buffer" version = "0.9.0" @@ -71,12 +47,6 @@ dependencies = [ "generic-array", ] -[[package]] -name = "byte-slice-cast" -version = "1.2.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c3ac9f8b63eca6fd385229b3675f6cc0dc5c8a5c8a54a59d4f52ffd670d87b0c" - [[package]] name = "byteorder" version = "1.5.0" @@ -113,18 +83,6 @@ dependencies = [ "libc", ] -[[package]] -name = "crypto-bigint" -version = "0.5.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0dc92fb57ca44df6db8059111ab3af99a63d5d0f8375d9972e319a379c6bab76" -dependencies = [ - "generic-array", - "rand_core", - "subtle", - "zeroize", -] - [[package]] name = "crypto-common" version = "0.1.6" @@ -193,23 +151,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "9ed9a281f7bc9b7576e61468ba615a66a5c8cfdff42420a70aa82701a3b1e292" dependencies = [ "block-buffer 0.10.4", - "const-oid", "crypto-common", - "subtle", -] - -[[package]] -name = "ecdsa" -version = "0.16.9" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ee27f32b5c5292967d2d4a9d7f1e0b0aed2c15daded5a60300e4abb9d8020bca" -dependencies = [ - "der", - "digest 0.10.7", - "elliptic-curve", - "rfc6979", - "signature", - "spki", ] [[package]] @@ -240,43 +182,6 @@ version = "1.11.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "a47c1c47d2f5964e29c61246e81db715514cd532db6b5116a25ea3c03d6780a2" -[[package]] -name = "elliptic-curve" -version = "0.13.8" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b5e6043086bf7973472e0c7dff2142ea0b680d30e18d9cc40f267efbf222bd47" -dependencies = [ - "base16ct", - "crypto-bigint", - "digest 0.10.7", - "ff", - "generic-array", - "group", - "pkcs8", - "rand_core", - "sec1", - "subtle", - "tap", - "zeroize", -] - -[[package]] -name = "equivalent" -version = "1.0.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5443807d6dff69373d433ab9ef5378ad8df50ca6298caf15de6e52e24aaf54d5" - -[[package]] -name = "ff" -version = "0.13.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ded41244b729663b1e574f1b4fb731469f69f79c17667b5d776b16cda0479449" -dependencies = [ - "bitvec", - "rand_core", - "subtle", -] - [[package]] name = "flex-error" version = "0.4.4" @@ -286,12 +191,6 @@ dependencies = [ "paste", ] -[[package]] -name = "funty" -version = "2.0.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e6d5a32815ae3f33302d95fdcb2ce17862f8c65363dcfd29360480ba1001fc9c" - [[package]] name = "futures" version = "0.3.30" @@ -361,7 +260,6 @@ checksum = "85649ca51fd72272d7821adaf274ad91c288277713d9c18820d8499a7ff69e9a" dependencies = [ "typenum", "version_check", - "zeroize", ] [[package]] @@ -375,59 +273,12 @@ dependencies = [ "wasi", ] -[[package]] -name = "group" -version = "0.13.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f0f9ef7462f7c099f518d754361858f86d8a07af53ba9af0fe635bbccb151a63" -dependencies = [ - "ff", - "rand_core", - "subtle", -] - -[[package]] -name = "hashbrown" -version = "0.14.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "290f1a1d9242c78d09ce40a5e87e7554ee637af1351968159f4952f028f75604" - [[package]] name = "hex" version = "0.4.3" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "7f24254aa9a54b5c858eaee2f5bccdb46aaf0e486a595ed5fd8f86ba55232a70" -[[package]] -name = "hmac" -version = "0.12.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6c49c37c09c17a53d937dfbb742eb3a961d65a994e6bcdcf37e7399d0cc8ab5e" -dependencies = [ - "digest 0.10.7", -] - -[[package]] -name = "impl-trait-for-tuples" -version = "0.2.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "11d7a9f6330b71fea57921c9b61c47ee6e84f72d394754eff6163ae67e7395eb" -dependencies = [ - "proc-macro2", - "quote", - "syn 1.0.109", -] - -[[package]] -name = "indexmap" -version = "2.2.6" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "168fb715dda47215e360912c096649d23d58bf392ac62f73919e831745e40f26" -dependencies = [ - "equivalent", - "hashbrown", -] - [[package]] name = "itertools" version = "0.12.1" @@ -443,25 +294,11 @@ version = "1.0.11" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "49f1f14873335454500d59611f1cf4a4b0f786f9ac11f4312a78e4cf2566695b" -[[package]] -name = "k256" -version = "0.13.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "956ff9b67e26e1a6a866cb758f12c6f8746208489e3e4a4b5580802f2f0a587b" -dependencies = [ - "cfg-if", - "ecdsa", - "elliptic-curve", - "once_cell", - "sha2 0.10.8", - "signature", -] - [[package]] name = "lazy_static" -version = "1.4.0" +version = "1.5.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e2abad23fbc42b3700f2f279844dc832adb2b2eb069b2df918f455c4e18cc646" +checksum = "bbd2bcb4c963f2ddae06a2efc7e9f3591312473c50c6685e1f298068316e66fe" [[package]] name = "libc" @@ -475,45 +312,6 @@ version = "0.2.8" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "4ec2a862134d2a7d32d7983ddcdd1c4923530833c9f2ea1a44fc5fa473989058" -[[package]] -name = "memchr" -version = "2.7.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6c8640c5d730cb13ebd907d8d04b52f55ac9a2eec55b440c8892f40d56c76c1d" - -[[package]] -name = "num" -version = "0.4.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "35bd024e8b2ff75562e5f34e7f4905839deb4b22955ef5e73d2fea1b9813cb23" -dependencies = [ - "num-bigint", - "num-complex", - "num-integer", - "num-iter", - "num-rational", - "num-traits", -] - -[[package]] -name = "num-bigint" -version = "0.4.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c165a9ab64cf766f73521c0dd2cfdff64f488b8f0b3e621face3462d3db536d7" -dependencies = [ - "num-integer", - "num-traits", -] - -[[package]] -name = "num-complex" -version = "0.4.6" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "73f88a1307638156682bada9d7604135552957b7818057dcef22705b4d509495" -dependencies = [ - "num-traits", -] - [[package]] name = "num-conv" version = "0.1.0" @@ -531,37 +329,6 @@ dependencies = [ "syn 1.0.109", ] -[[package]] -name = "num-integer" -version = "0.1.46" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7969661fd2958a5cb096e56c8e1ad0444ac2bbcd0061bd28660485a44879858f" -dependencies = [ - "num-traits", -] - -[[package]] -name = "num-iter" -version = "0.1.45" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1429034a0490724d0075ebb2bc9e875d6503c3cf69e235a8941aa757d83ef5bf" -dependencies = [ - "autocfg", - "num-integer", - "num-traits", -] - -[[package]] -name = "num-rational" -version = "0.4.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f83d14da390562dca69fc84082e73e548e1ad308d24accdedd2720017cb37824" -dependencies = [ - "num-bigint", - "num-integer", - "num-traits", -] - [[package]] name = "num-traits" version = "0.2.19" @@ -583,30 +350,6 @@ version = "0.3.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "c08d65885ee38876c4f86fa503fb49d7b507c2b62552df7c70b2fce627e06381" -[[package]] -name = "parity-scale-codec" -version = "3.6.9" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "881331e34fa842a2fb61cc2db9643a8fedc615e47cfcc52597d1af0db9a7e8fe" -dependencies = [ - "arrayvec", - "byte-slice-cast", - "impl-trait-for-tuples", - "parity-scale-codec-derive", -] - -[[package]] -name = "parity-scale-codec-derive" -version = "3.6.9" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "be30eaf4b0a9fba5336683b38de57bb86d179a35862ba6bfcf57625d006bde5b" -dependencies = [ - "proc-macro-crate 2.0.2", - "proc-macro2", - "quote", - "syn 1.0.109", -] - [[package]] name = "paste" version = "1.0.14" @@ -647,26 +390,6 @@ version = "0.2.17" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "5b40af805b3121feab8a3c29f04d8ad262fa8e0561883e7653e024ae4479e6de" -[[package]] -name = "proc-macro-crate" -version = "1.3.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7f4c021e1093a56626774e81216a4ce732a735e5bad4868a03f3ed65ca0c3919" -dependencies = [ - "once_cell", - "toml_edit 0.19.15", -] - -[[package]] -name = "proc-macro-crate" -version = "2.0.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b00f26d3400549137f92511a46ac1cd8ce37cb5598a96d382381458b992a5d24" -dependencies = [ - "toml_datetime", - "toml_edit 0.20.2", -] - [[package]] name = "proc-macro2" version = "1.0.81" @@ -717,12 +440,6 @@ dependencies = [ "proc-macro2", ] -[[package]] -name = "radium" -version = "0.7.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "dc33ff2d4973d518d823d61aa239014831e521c75da58e3df4840d3f47749d09" - [[package]] name = "rand" version = "0.8.5" @@ -753,60 +470,12 @@ dependencies = [ "getrandom", ] -[[package]] -name = "rfc6979" -version = "0.4.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f8dd2a808d456c4a54e300a23e9f5a67e122c3024119acbfd73e3bf664491cb2" -dependencies = [ - "hmac", - "subtle", -] - [[package]] name = "ryu" version = "1.0.17" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "e86697c916019a8588c99b5fac3cead74ec0b4b819707a682fd4d23fa0ce1ba1" -[[package]] -name = "scale-info" -version = "2.11.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7c453e59a955f81fb62ee5d596b450383d699f152d350e9d23a0db2adb78e4c0" -dependencies = [ - "cfg-if", - "derive_more", - "parity-scale-codec", - "scale-info-derive", -] - -[[package]] -name = "scale-info-derive" -version = "2.11.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "18cf6c6447f813ef19eb450e985bcce6705f9ce7660db221b59093d15c79c4b7" -dependencies = [ - "proc-macro-crate 1.3.1", - "proc-macro2", - "quote", - "syn 1.0.109", -] - -[[package]] -name = "sec1" -version = "0.7.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d3e97a565f76233a6003f9f5c54be1d9c5bdfa3eccfb189469f11ec4901c47dc" -dependencies = [ - "base16ct", - "der", - "generic-array", - "pkcs8", - "subtle", - "zeroize", -] - [[package]] name = "serde" version = "1.0.203" @@ -886,35 +555,15 @@ name = "signature" version = "2.2.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "77549399552de45a898a580c1b41d445bf730df867cc44e6c0233bbc4b8329de" -dependencies = [ - "digest 0.10.7", - "rand_core", -] [[package]] -name = "snowbridge-amcl" -version = "1.0.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "460a9ed63cdf03c1b9847e8a12a5f5ba19c4efd5869e4a737e05be25d7c427e5" -dependencies = [ - "parity-scale-codec", - "scale-info", -] - -[[package]] -name = "sp1-precompiles" +name = "sp1-lib" version = "0.1.0" dependencies = [ "anyhow", "bincode", "cfg-if", - "getrandom", - "hex", - "k256", - "num", - "rand", "serde", - "snowbridge-amcl", ] [[package]] @@ -924,14 +573,13 @@ dependencies = [ "bincode", "cfg-if", "getrandom", - "k256", "lazy_static", "libm", "once_cell", "rand", "serde", "sha2 0.10.8", - "sp1-precompiles", + "sp1-lib", ] [[package]] @@ -987,12 +635,6 @@ dependencies = [ "unicode-ident", ] -[[package]] -name = "tap" -version = "1.0.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "55937e1799185b12863d447f42597ed69d9928686b8d88a1df17376a097d8369" - [[package]] name = "tendermint" version = "0.34.1" @@ -1093,34 +735,6 @@ dependencies = [ "time-core", ] -[[package]] -name = "toml_datetime" -version = "0.6.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7cda73e2f1397b1262d6dfdcef8aafae14d1de7748d66822d3bfeeb6d03e5e4b" - -[[package]] -name = "toml_edit" -version = "0.19.15" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1b5bb770da30e5cbfde35a2d7b9b8a2c4b8ef89548a7a6aeab5c9a576e3e7421" -dependencies = [ - "indexmap", - "toml_datetime", - "winnow", -] - -[[package]] -name = "toml_edit" -version = "0.20.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "396e4d48bbb2b7554c944bde63101b5ae446cff6ec4a24227428f15eb72ef338" -dependencies = [ - "indexmap", - "toml_datetime", - "winnow", -] - [[package]] name = "typenum" version = "1.17.0" @@ -1145,24 +759,6 @@ version = "0.11.0+wasi-snapshot-preview1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "9c8d87e72b64a3b4db28d11ce29237c246188f4f51057d65a7eab63b7987e423" -[[package]] -name = "winnow" -version = "0.5.40" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f593a95398737aeed53e489c785df13f3618e41dbcd6718c6addbf1395aa6876" -dependencies = [ - "memchr", -] - -[[package]] -name = "wyz" -version = "0.5.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "05f360fc0b24296329c78fda852a1e9ae82de9cf7b27dae4b7f62f118f77b9ed" -dependencies = [ - "tap", -] - [[package]] name = "zeroize" version = "1.7.0" diff --git a/tests/tendermint-benchmark/Cargo.toml b/tests/tendermint-benchmark/Cargo.toml index 944d94bbd3..2f4871e764 100644 --- a/tests/tendermint-benchmark/Cargo.toml +++ b/tests/tendermint-benchmark/Cargo.toml @@ -1,8 +1,9 @@ [workspace] [package] -version = "0.1.0" name = "tendermint-benchmark-program" +version = "1.0.0-rc.1" edition = "2021" +publish = false [dependencies] sp1-zkvm = { path = "../../zkvm/entrypoint" } diff --git a/tests/tendermint-benchmark/elf/riscv32im-succinct-zkvm-elf b/tests/tendermint-benchmark/elf/riscv32im-succinct-zkvm-elf index 526fc2f836..4f56f31eba 100755 Binary files a/tests/tendermint-benchmark/elf/riscv32im-succinct-zkvm-elf and b/tests/tendermint-benchmark/elf/riscv32im-succinct-zkvm-elf differ diff --git a/tests/uint256-arith/Cargo.lock b/tests/uint256-arith/Cargo.lock index 47e177abcc..af7c4a551d 100644 --- a/tests/uint256-arith/Cargo.lock +++ b/tests/uint256-arith/Cargo.lock @@ -8,29 +8,11 @@ version = "1.0.86" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "b3d1d046238990b9cf5bcde22a3fb3584ee5cf65fb2765f454ed428c7a0063da" -[[package]] -name = "arrayvec" -version = "0.7.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "96d30a06541fbafbc7f82ed10c06164cfbd2c401138f6addd8404629c4b16711" - [[package]] name = "autocfg" -version = "1.2.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f1fdabc7756949593fe60f30ec81974b613357de856987752631dea1e3394c80" - -[[package]] -name = "base16ct" -version = "0.2.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4c7f02d4ea65f2c1853089ffd8d2787bdbc63de2f0d29dedbcf8ccdfa0ccd4cf" - -[[package]] -name = "base64ct" -version = "1.6.0" +version = "1.3.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8c3c1a368f70d6cf7302d78f8f7093da241fb8e8807c05cc9e51a125895a6d5b" +checksum = "0c4b4d0bd25bd0b74681c0ad21497610ce1b7c91b1022cd21c80c6fbdd9476b0" [[package]] name = "bincode" @@ -41,18 +23,6 @@ dependencies = [ "serde", ] -[[package]] -name = "bitvec" -version = "1.0.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1bc2832c24239b0141d5674bb9174f9d68a8b5b3f2753311927c172ca46f7e9c" -dependencies = [ - "funty", - "radium", - "tap", - "wyz", -] - [[package]] name = "block-buffer" version = "0.10.4" @@ -62,24 +32,12 @@ dependencies = [ "generic-array", ] -[[package]] -name = "byte-slice-cast" -version = "1.2.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c3ac9f8b63eca6fd385229b3675f6cc0dc5c8a5c8a54a59d4f52ffd670d87b0c" - [[package]] name = "cfg-if" version = "1.0.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "baf1de4339761588bc0619e3cbc0120ee582ebb74b53b4efbf79117bd2da40fd" -[[package]] -name = "const-oid" -version = "0.9.6" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c2459377285ad874054d797f3ccebf984978aa39129f6eafde5cdc8315b612f8" - [[package]] name = "cpufeatures" version = "0.2.12" @@ -91,21 +49,9 @@ dependencies = [ [[package]] name = "crypto-bigint" -version = "0.5.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0dc92fb57ca44df6db8059111ab3af99a63d5d0f8375d9972e319a379c6bab76" -dependencies = [ - "generic-array", - "rand_core", - "subtle", - "zeroize", -] - -[[package]] -name = "crypto-bigint" -version = "0.6.0-pre.12" +version = "0.6.0-rc.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1943d7beadd9ce2b25f3bae73b9e9336fccc1edf38bdec1ed58d3aa183989e11" +checksum = "cf4d6fbc60a5516ff886af2c5994fb2bdfa6fbe2168468100bd87e6c09caf08c" dependencies = [ "num-traits", "rand_core", @@ -122,27 +68,6 @@ dependencies = [ "typenum", ] -[[package]] -name = "der" -version = "0.7.9" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f55bf8e7b65898637379c1b74eb1551107c8294ed26d855ceb9fd1a09cfc9bc0" -dependencies = [ - "const-oid", - "zeroize", -] - -[[package]] -name = "derive_more" -version = "0.99.17" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4fb810d30a7c1953f91334de7244731fc3f3c10d7fe163338a35b9f640960321" -dependencies = [ - "proc-macro2", - "quote", - "syn 1.0.109", -] - [[package]] name = "digest" version = "0.10.7" @@ -150,68 +75,9 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "9ed9a281f7bc9b7576e61468ba615a66a5c8cfdff42420a70aa82701a3b1e292" dependencies = [ "block-buffer", - "const-oid", "crypto-common", - "subtle", -] - -[[package]] -name = "ecdsa" -version = "0.16.9" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ee27f32b5c5292967d2d4a9d7f1e0b0aed2c15daded5a60300e4abb9d8020bca" -dependencies = [ - "der", - "digest", - "elliptic-curve", - "rfc6979", - "signature", - "spki", -] - -[[package]] -name = "elliptic-curve" -version = "0.13.8" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b5e6043086bf7973472e0c7dff2142ea0b680d30e18d9cc40f267efbf222bd47" -dependencies = [ - "base16ct", - "crypto-bigint 0.5.5", - "digest", - "ff", - "generic-array", - "group", - "pkcs8", - "rand_core", - "sec1", - "subtle", - "tap", - "zeroize", -] - -[[package]] -name = "equivalent" -version = "1.0.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5443807d6dff69373d433ab9ef5378ad8df50ca6298caf15de6e52e24aaf54d5" - -[[package]] -name = "ff" -version = "0.13.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ded41244b729663b1e574f1b4fb731469f69f79c17667b5d776b16cda0479449" -dependencies = [ - "bitvec", - "rand_core", - "subtle", ] -[[package]] -name = "funty" -version = "2.0.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e6d5a32815ae3f33302d95fdcb2ce17862f8c65363dcfd29360480ba1001fc9c" - [[package]] name = "generic-array" version = "0.14.7" @@ -220,14 +86,13 @@ checksum = "85649ca51fd72272d7821adaf274ad91c288277713d9c18820d8499a7ff69e9a" dependencies = [ "typenum", "version_check", - "zeroize", ] [[package]] name = "getrandom" -version = "0.2.14" +version = "0.2.15" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "94b22e06ecb0110981051723910cbf0b5f5e09a2062dd7663334ee79a9d1286c" +checksum = "c4567c8db10ae91089c99af84c68c38da3ec2f087c3f82960bcdbf3656b6f4d7" dependencies = [ "cfg-if", "libc", @@ -235,77 +100,16 @@ dependencies = [ ] [[package]] -name = "group" -version = "0.13.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f0f9ef7462f7c099f518d754361858f86d8a07af53ba9af0fe635bbccb151a63" -dependencies = [ - "ff", - "rand_core", - "subtle", -] - -[[package]] -name = "hashbrown" -version = "0.14.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "290f1a1d9242c78d09ce40a5e87e7554ee637af1351968159f4952f028f75604" - -[[package]] -name = "hex" -version = "0.4.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7f24254aa9a54b5c858eaee2f5bccdb46aaf0e486a595ed5fd8f86ba55232a70" - -[[package]] -name = "hmac" -version = "0.12.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6c49c37c09c17a53d937dfbb742eb3a961d65a994e6bcdcf37e7399d0cc8ab5e" -dependencies = [ - "digest", -] - -[[package]] -name = "impl-trait-for-tuples" -version = "0.2.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "11d7a9f6330b71fea57921c9b61c47ee6e84f72d394754eff6163ae67e7395eb" -dependencies = [ - "proc-macro2", - "quote", - "syn 1.0.109", -] - -[[package]] -name = "indexmap" -version = "2.2.6" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "168fb715dda47215e360912c096649d23d58bf392ac62f73919e831745e40f26" -dependencies = [ - "equivalent", - "hashbrown", -] - -[[package]] -name = "k256" -version = "0.13.3" +name = "lazy_static" +version = "1.5.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "956ff9b67e26e1a6a866cb758f12c6f8746208489e3e4a4b5580802f2f0a587b" -dependencies = [ - "cfg-if", - "ecdsa", - "elliptic-curve", - "once_cell", - "sha2", - "signature", -] +checksum = "bbd2bcb4c963f2ddae06a2efc7e9f3591312473c50c6685e1f298068316e66fe" [[package]] name = "libc" -version = "0.2.153" +version = "0.2.155" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9c198f91728a82281a64e1f4f9eeb25d82cb32a5de251c6bd1b5154d63a8e7bd" +checksum = "97b3888a4aecf77e811145cadf6eef5901f4782c53886191b2f693f24761847c" [[package]] name = "libm" @@ -313,76 +117,6 @@ version = "0.2.8" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "4ec2a862134d2a7d32d7983ddcdd1c4923530833c9f2ea1a44fc5fa473989058" -[[package]] -name = "memchr" -version = "2.7.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6c8640c5d730cb13ebd907d8d04b52f55ac9a2eec55b440c8892f40d56c76c1d" - -[[package]] -name = "num" -version = "0.4.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "35bd024e8b2ff75562e5f34e7f4905839deb4b22955ef5e73d2fea1b9813cb23" -dependencies = [ - "num-bigint", - "num-complex", - "num-integer", - "num-iter", - "num-rational", - "num-traits", -] - -[[package]] -name = "num-bigint" -version = "0.4.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c165a9ab64cf766f73521c0dd2cfdff64f488b8f0b3e621face3462d3db536d7" -dependencies = [ - "num-integer", - "num-traits", -] - -[[package]] -name = "num-complex" -version = "0.4.6" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "73f88a1307638156682bada9d7604135552957b7818057dcef22705b4d509495" -dependencies = [ - "num-traits", -] - -[[package]] -name = "num-integer" -version = "0.1.46" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7969661fd2958a5cb096e56c8e1ad0444ac2bbcd0061bd28660485a44879858f" -dependencies = [ - "num-traits", -] - -[[package]] -name = "num-iter" -version = "0.1.45" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1429034a0490724d0075ebb2bc9e875d6503c3cf69e235a8941aa757d83ef5bf" -dependencies = [ - "autocfg", - "num-integer", - "num-traits", -] - -[[package]] -name = "num-rational" -version = "0.4.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f83d14da390562dca69fc84082e73e548e1ad308d24accdedd2720017cb37824" -dependencies = [ - "num-bigint", - "num-integer", - "num-traits", -] - [[package]] name = "num-traits" version = "0.2.19" @@ -398,71 +132,17 @@ version = "1.19.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "3fdb12b2476b595f9358c5161aa467c2438859caa136dec86c26fdd2efe17b92" -[[package]] -name = "parity-scale-codec" -version = "3.6.9" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "881331e34fa842a2fb61cc2db9643a8fedc615e47cfcc52597d1af0db9a7e8fe" -dependencies = [ - "arrayvec", - "byte-slice-cast", - "impl-trait-for-tuples", - "parity-scale-codec-derive", -] - -[[package]] -name = "parity-scale-codec-derive" -version = "3.6.9" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "be30eaf4b0a9fba5336683b38de57bb86d179a35862ba6bfcf57625d006bde5b" -dependencies = [ - "proc-macro-crate 2.0.2", - "proc-macro2", - "quote", - "syn 1.0.109", -] - -[[package]] -name = "pkcs8" -version = "0.10.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f950b2377845cebe5cf8b5165cb3cc1a5e0fa5cfa3e1f7f55707d8fd82e0a7b7" -dependencies = [ - "der", - "spki", -] - [[package]] name = "ppv-lite86" version = "0.2.17" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "5b40af805b3121feab8a3c29f04d8ad262fa8e0561883e7653e024ae4479e6de" -[[package]] -name = "proc-macro-crate" -version = "1.3.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7f4c021e1093a56626774e81216a4ce732a735e5bad4868a03f3ed65ca0c3919" -dependencies = [ - "once_cell", - "toml_edit 0.19.15", -] - -[[package]] -name = "proc-macro-crate" -version = "2.0.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b00f26d3400549137f92511a46ac1cd8ce37cb5598a96d382381458b992a5d24" -dependencies = [ - "toml_datetime", - "toml_edit 0.20.2", -] - [[package]] name = "proc-macro2" -version = "1.0.81" +version = "1.0.86" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3d1597b0c024618f09a9c3b8655b7e430397a36d23fdafec26d6965e9eec3eba" +checksum = "5e719e8df665df0d1c8fbfd238015744736151d4445ec0836b8e628aae103b77" dependencies = [ "unicode-ident", ] @@ -476,12 +156,6 @@ dependencies = [ "proc-macro2", ] -[[package]] -name = "radium" -version = "0.7.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "dc33ff2d4973d518d823d61aa239014831e521c75da58e3df4840d3f47749d09" - [[package]] name = "rand" version = "0.8.5" @@ -512,72 +186,24 @@ dependencies = [ "getrandom", ] -[[package]] -name = "rfc6979" -version = "0.4.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f8dd2a808d456c4a54e300a23e9f5a67e122c3024119acbfd73e3bf664491cb2" -dependencies = [ - "hmac", - "subtle", -] - -[[package]] -name = "scale-info" -version = "2.11.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7c453e59a955f81fb62ee5d596b450383d699f152d350e9d23a0db2adb78e4c0" -dependencies = [ - "cfg-if", - "derive_more", - "parity-scale-codec", - "scale-info-derive", -] - -[[package]] -name = "scale-info-derive" -version = "2.11.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "18cf6c6447f813ef19eb450e985bcce6705f9ce7660db221b59093d15c79c4b7" -dependencies = [ - "proc-macro-crate 1.3.1", - "proc-macro2", - "quote", - "syn 1.0.109", -] - -[[package]] -name = "sec1" -version = "0.7.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d3e97a565f76233a6003f9f5c54be1d9c5bdfa3eccfb189469f11ec4901c47dc" -dependencies = [ - "base16ct", - "der", - "generic-array", - "pkcs8", - "subtle", - "zeroize", -] - [[package]] name = "serde" -version = "1.0.203" +version = "1.0.204" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7253ab4de971e72fb7be983802300c30b5a7f0c2e56fab8abfc6a214307c0094" +checksum = "bc76f558e0cbb2a839d37354c575f1dc3fdc6546b5be373ba43d95f231bf7c12" dependencies = [ "serde_derive", ] [[package]] name = "serde_derive" -version = "1.0.203" +version = "1.0.204" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "500cbc0ebeb6f46627f50f3f5811ccf6bf00643be300b4c3eabc0ef55dc5b5ba" +checksum = "e0cd7e117be63d3c3678776753929474f3b04a43a080c744d6b0ae2a8c28e222" dependencies = [ "proc-macro2", "quote", - "syn 2.0.60", + "syn 2.0.69", ] [[package]] @@ -591,30 +217,9 @@ dependencies = [ "digest", ] -[[package]] -name = "signature" -version = "2.2.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "77549399552de45a898a580c1b41d445bf730df867cc44e6c0233bbc4b8329de" -dependencies = [ - "digest", - "rand_core", -] - -[[package]] -name = "snowbridge-amcl" -version = "1.0.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "460a9ed63cdf03c1b9847e8a12a5f5ba19c4efd5869e4a737e05be25d7c427e5" -dependencies = [ - "parity-scale-codec", - "scale-info", -] - [[package]] name = "sp1-derive" version = "0.1.0" -source = "git+https://github.com/succinctlabs/sp1.git#7ce13033a0557f964cd349393d367aa1bcf8fbe7" dependencies = [ "proc-macro2", "quote", @@ -622,19 +227,13 @@ dependencies = [ ] [[package]] -name = "sp1-precompiles" +name = "sp1-lib" version = "0.1.0" dependencies = [ "anyhow", "bincode", "cfg-if", - "getrandom", - "hex", - "k256", - "num", - "rand", "serde", - "snowbridge-amcl", ] [[package]] @@ -644,30 +243,20 @@ dependencies = [ "bincode", "cfg-if", "getrandom", - "k256", + "lazy_static", "libm", "once_cell", "rand", "serde", "sha2", - "sp1-precompiles", -] - -[[package]] -name = "spki" -version = "0.7.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d91ed6c858b01f942cd56b37a94b3e0a1798290327d1236e4d9cf4eaca44d29d" -dependencies = [ - "base64ct", - "der", + "sp1-lib", ] [[package]] name = "subtle" -version = "2.5.0" +version = "2.6.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "81cdd64d312baedb58e21336b31bc043b77e01cc99033ce76ef539f78e965ebc" +checksum = "13c2bddecc57b384dee18652358fb23172facb8a2c51ccc10d74c157bdea3292" [[package]] name = "syn" @@ -682,49 +271,15 @@ dependencies = [ [[package]] name = "syn" -version = "2.0.60" +version = "2.0.69" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "909518bc7b1c9b779f1bbf07f2929d35af9f0f37e47c6e9ef7f9dddc1e1821f3" +checksum = "201fcda3845c23e8212cd466bfebf0bd20694490fc0356ae8e428e0824a915a6" dependencies = [ "proc-macro2", "quote", "unicode-ident", ] -[[package]] -name = "tap" -version = "1.0.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "55937e1799185b12863d447f42597ed69d9928686b8d88a1df17376a097d8369" - -[[package]] -name = "toml_datetime" -version = "0.6.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7cda73e2f1397b1262d6dfdcef8aafae14d1de7748d66822d3bfeeb6d03e5e4b" - -[[package]] -name = "toml_edit" -version = "0.19.15" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1b5bb770da30e5cbfde35a2d7b9b8a2c4b8ef89548a7a6aeab5c9a576e3e7421" -dependencies = [ - "indexmap", - "toml_datetime", - "winnow", -] - -[[package]] -name = "toml_edit" -version = "0.20.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "396e4d48bbb2b7554c944bde63101b5ae446cff6ec4a24227428f15eb72ef338" -dependencies = [ - "indexmap", - "toml_datetime", - "winnow", -] - [[package]] name = "typenum" version = "1.17.0" @@ -735,7 +290,7 @@ checksum = "42ff0bf0c66b8238c6f3b578df37d0b7848e55df8577b3f74f92a69acceeb825" name = "uint256-arith-program" version = "0.1.0" dependencies = [ - "crypto-bigint 0.6.0-pre.12", + "crypto-bigint", "sp1-derive", "sp1-zkvm", ] @@ -757,27 +312,3 @@ name = "wasi" version = "0.11.0+wasi-snapshot-preview1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "9c8d87e72b64a3b4db28d11ce29237c246188f4f51057d65a7eab63b7987e423" - -[[package]] -name = "winnow" -version = "0.5.40" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f593a95398737aeed53e489c785df13f3618e41dbcd6718c6addbf1395aa6876" -dependencies = [ - "memchr", -] - -[[package]] -name = "wyz" -version = "0.5.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "05f360fc0b24296329c78fda852a1e9ae82de9cf7b27dae4b7f62f118f77b9ed" -dependencies = [ - "tap", -] - -[[package]] -name = "zeroize" -version = "1.7.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "525b4ec142c6b68a2d10f01f7bbf6755599ca3f81ea53b8431b7dd348f5fdb2d" diff --git a/tests/uint256-arith/Cargo.toml b/tests/uint256-arith/Cargo.toml index 54cca58f13..566e0326a3 100644 --- a/tests/uint256-arith/Cargo.toml +++ b/tests/uint256-arith/Cargo.toml @@ -1,10 +1,11 @@ [workspace] [package] -version = "0.1.0" name = "uint256-arith-program" +version = "1.0.0-rc.1" edition = "2021" +publish = false [dependencies] sp1-zkvm = { path = "../../zkvm/entrypoint" } -sp1-derive = { git = "https://github.com/succinctlabs/sp1.git" } +sp1-derive = { path = "../../derive" } crypto-bigint = "0.6.0-pre.12" diff --git a/tests/uint256-arith/elf/riscv32im-succinct-zkvm-elf b/tests/uint256-arith/elf/riscv32im-succinct-zkvm-elf index a80353d4f2..fa251d3011 100755 Binary files a/tests/uint256-arith/elf/riscv32im-succinct-zkvm-elf and b/tests/uint256-arith/elf/riscv32im-succinct-zkvm-elf differ diff --git a/tests/uint256-mul/Cargo.lock b/tests/uint256-mul/Cargo.lock index d5ede11404..298f5d8d10 100644 --- a/tests/uint256-mul/Cargo.lock +++ b/tests/uint256-mul/Cargo.lock @@ -8,29 +8,11 @@ version = "1.0.86" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "b3d1d046238990b9cf5bcde22a3fb3584ee5cf65fb2765f454ed428c7a0063da" -[[package]] -name = "arrayvec" -version = "0.7.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "96d30a06541fbafbc7f82ed10c06164cfbd2c401138f6addd8404629c4b16711" - [[package]] name = "autocfg" -version = "1.2.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f1fdabc7756949593fe60f30ec81974b613357de856987752631dea1e3394c80" - -[[package]] -name = "base16ct" -version = "0.2.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4c7f02d4ea65f2c1853089ffd8d2787bdbc63de2f0d29dedbcf8ccdfa0ccd4cf" - -[[package]] -name = "base64ct" -version = "1.6.0" +version = "1.3.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8c3c1a368f70d6cf7302d78f8f7093da241fb8e8807c05cc9e51a125895a6d5b" +checksum = "0c4b4d0bd25bd0b74681c0ad21497610ce1b7c91b1022cd21c80c6fbdd9476b0" [[package]] name = "biguint-mul-test" @@ -52,18 +34,6 @@ dependencies = [ "serde", ] -[[package]] -name = "bitvec" -version = "1.0.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1bc2832c24239b0141d5674bb9174f9d68a8b5b3f2753311927c172ca46f7e9c" -dependencies = [ - "funty", - "radium", - "tap", - "wyz", -] - [[package]] name = "block-buffer" version = "0.10.4" @@ -73,17 +43,11 @@ dependencies = [ "generic-array", ] -[[package]] -name = "byte-slice-cast" -version = "1.2.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c3ac9f8b63eca6fd385229b3675f6cc0dc5c8a5c8a54a59d4f52ffd670d87b0c" - [[package]] name = "bytemuck" -version = "1.15.0" +version = "1.16.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5d6d68c57235a3a081186990eca2867354726650f42f7516ca50c28d6281fd15" +checksum = "b236fc92302c97ed75b38da1f4917b5cdda4984745740f153a5d3059e48d725e" [[package]] name = "cfg-if" @@ -91,12 +55,6 @@ version = "1.0.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "baf1de4339761588bc0619e3cbc0120ee582ebb74b53b4efbf79117bd2da40fd" -[[package]] -name = "const-oid" -version = "0.9.6" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c2459377285ad874054d797f3ccebf984978aa39129f6eafde5cdc8315b612f8" - [[package]] name = "cpufeatures" version = "0.2.12" @@ -106,18 +64,6 @@ dependencies = [ "libc", ] -[[package]] -name = "crypto-bigint" -version = "0.5.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0dc92fb57ca44df6db8059111ab3af99a63d5d0f8375d9972e319a379c6bab76" -dependencies = [ - "generic-array", - "rand_core", - "subtle", - "zeroize", -] - [[package]] name = "crypto-common" version = "0.1.6" @@ -128,27 +74,6 @@ dependencies = [ "typenum", ] -[[package]] -name = "der" -version = "0.7.8" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "fffa369a668c8af7dbf8b5e56c9f744fbd399949ed171606040001947de40b1c" -dependencies = [ - "const-oid", - "zeroize", -] - -[[package]] -name = "derive_more" -version = "0.99.17" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4fb810d30a7c1953f91334de7244731fc3f3c10d7fe163338a35b9f640960321" -dependencies = [ - "proc-macro2", - "quote", - "syn 1.0.109", -] - [[package]] name = "digest" version = "0.10.7" @@ -156,68 +81,9 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "9ed9a281f7bc9b7576e61468ba615a66a5c8cfdff42420a70aa82701a3b1e292" dependencies = [ "block-buffer", - "const-oid", "crypto-common", - "subtle", ] -[[package]] -name = "ecdsa" -version = "0.16.9" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ee27f32b5c5292967d2d4a9d7f1e0b0aed2c15daded5a60300e4abb9d8020bca" -dependencies = [ - "der", - "digest", - "elliptic-curve", - "rfc6979", - "signature", - "spki", -] - -[[package]] -name = "elliptic-curve" -version = "0.13.8" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b5e6043086bf7973472e0c7dff2142ea0b680d30e18d9cc40f267efbf222bd47" -dependencies = [ - "base16ct", - "crypto-bigint", - "digest", - "ff", - "generic-array", - "group", - "pkcs8", - "rand_core", - "sec1", - "subtle", - "tap", - "zeroize", -] - -[[package]] -name = "equivalent" -version = "1.0.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5443807d6dff69373d433ab9ef5378ad8df50ca6298caf15de6e52e24aaf54d5" - -[[package]] -name = "ff" -version = "0.13.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ded41244b729663b1e574f1b4fb731469f69f79c17667b5d776b16cda0479449" -dependencies = [ - "bitvec", - "rand_core", - "subtle", -] - -[[package]] -name = "funty" -version = "2.0.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e6d5a32815ae3f33302d95fdcb2ce17862f8c65363dcfd29360480ba1001fc9c" - [[package]] name = "generic-array" version = "0.14.7" @@ -226,7 +92,6 @@ checksum = "85649ca51fd72272d7821adaf274ad91c288277713d9c18820d8499a7ff69e9a" dependencies = [ "typenum", "version_check", - "zeroize", ] [[package]] @@ -241,71 +106,10 @@ dependencies = [ ] [[package]] -name = "group" -version = "0.13.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f0f9ef7462f7c099f518d754361858f86d8a07af53ba9af0fe635bbccb151a63" -dependencies = [ - "ff", - "rand_core", - "subtle", -] - -[[package]] -name = "hashbrown" -version = "0.14.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "290f1a1d9242c78d09ce40a5e87e7554ee637af1351968159f4952f028f75604" - -[[package]] -name = "hex" -version = "0.4.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7f24254aa9a54b5c858eaee2f5bccdb46aaf0e486a595ed5fd8f86ba55232a70" - -[[package]] -name = "hmac" -version = "0.12.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6c49c37c09c17a53d937dfbb742eb3a961d65a994e6bcdcf37e7399d0cc8ab5e" -dependencies = [ - "digest", -] - -[[package]] -name = "impl-trait-for-tuples" -version = "0.2.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "11d7a9f6330b71fea57921c9b61c47ee6e84f72d394754eff6163ae67e7395eb" -dependencies = [ - "proc-macro2", - "quote", - "syn 1.0.109", -] - -[[package]] -name = "indexmap" -version = "2.2.6" +name = "lazy_static" +version = "1.5.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "168fb715dda47215e360912c096649d23d58bf392ac62f73919e831745e40f26" -dependencies = [ - "equivalent", - "hashbrown", -] - -[[package]] -name = "k256" -version = "0.13.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "956ff9b67e26e1a6a866cb758f12c6f8746208489e3e4a4b5580802f2f0a587b" -dependencies = [ - "cfg-if", - "ecdsa", - "elliptic-curve", - "once_cell", - "sha2", - "signature", -] +checksum = "bbd2bcb4c963f2ddae06a2efc7e9f3591312473c50c6685e1f298068316e66fe" [[package]] name = "libc" @@ -319,12 +123,6 @@ version = "0.2.8" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "4ec2a862134d2a7d32d7983ddcdd1c4923530833c9f2ea1a44fc5fa473989058" -[[package]] -name = "memchr" -version = "2.7.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6c8640c5d730cb13ebd907d8d04b52f55ac9a2eec55b440c8892f40d56c76c1d" - [[package]] name = "num" version = "0.4.3" @@ -341,9 +139,9 @@ dependencies = [ [[package]] name = "num-bigint" -version = "0.4.5" +version = "0.4.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c165a9ab64cf766f73521c0dd2cfdff64f488b8f0b3e621face3462d3db536d7" +checksum = "a5e44f723f1133c9deac646763579fdb3ac745e418f2a7af9cd0c431da1f20b9" dependencies = [ "num-integer", "num-traits", @@ -404,90 +202,30 @@ version = "1.19.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "3fdb12b2476b595f9358c5161aa467c2438859caa136dec86c26fdd2efe17b92" -[[package]] -name = "parity-scale-codec" -version = "3.6.9" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "881331e34fa842a2fb61cc2db9643a8fedc615e47cfcc52597d1af0db9a7e8fe" -dependencies = [ - "arrayvec", - "byte-slice-cast", - "impl-trait-for-tuples", - "parity-scale-codec-derive", -] - -[[package]] -name = "parity-scale-codec-derive" -version = "3.6.9" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "be30eaf4b0a9fba5336683b38de57bb86d179a35862ba6bfcf57625d006bde5b" -dependencies = [ - "proc-macro-crate 2.0.2", - "proc-macro2", - "quote", - "syn 1.0.109", -] - -[[package]] -name = "pkcs8" -version = "0.10.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f950b2377845cebe5cf8b5165cb3cc1a5e0fa5cfa3e1f7f55707d8fd82e0a7b7" -dependencies = [ - "der", - "spki", -] - [[package]] name = "ppv-lite86" version = "0.2.17" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "5b40af805b3121feab8a3c29f04d8ad262fa8e0561883e7653e024ae4479e6de" -[[package]] -name = "proc-macro-crate" -version = "1.3.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7f4c021e1093a56626774e81216a4ce732a735e5bad4868a03f3ed65ca0c3919" -dependencies = [ - "once_cell", - "toml_edit 0.19.15", -] - -[[package]] -name = "proc-macro-crate" -version = "2.0.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b00f26d3400549137f92511a46ac1cd8ce37cb5598a96d382381458b992a5d24" -dependencies = [ - "toml_datetime", - "toml_edit 0.20.2", -] - [[package]] name = "proc-macro2" -version = "1.0.79" +version = "1.0.86" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e835ff2298f5721608eb1a980ecaee1aef2c132bf95ecc026a11b7bf3c01c02e" +checksum = "5e719e8df665df0d1c8fbfd238015744736151d4445ec0836b8e628aae103b77" dependencies = [ "unicode-ident", ] [[package]] name = "quote" -version = "1.0.35" +version = "1.0.36" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "291ec9ab5efd934aaf503a6466c5d5251535d108ee747472c3977cc5acc868ef" +checksum = "0fa76aaf39101c457836aec0ce2316dbdc3ab723cdda1c6bd4e6ad4208acaca7" dependencies = [ "proc-macro2", ] -[[package]] -name = "radium" -version = "0.7.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "dc33ff2d4973d518d823d61aa239014831e521c75da58e3df4840d3f47749d09" - [[package]] name = "rand" version = "0.8.5" @@ -518,72 +256,24 @@ dependencies = [ "getrandom", ] -[[package]] -name = "rfc6979" -version = "0.4.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f8dd2a808d456c4a54e300a23e9f5a67e122c3024119acbfd73e3bf664491cb2" -dependencies = [ - "hmac", - "subtle", -] - -[[package]] -name = "scale-info" -version = "2.11.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7c453e59a955f81fb62ee5d596b450383d699f152d350e9d23a0db2adb78e4c0" -dependencies = [ - "cfg-if", - "derive_more", - "parity-scale-codec", - "scale-info-derive", -] - -[[package]] -name = "scale-info-derive" -version = "2.11.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "18cf6c6447f813ef19eb450e985bcce6705f9ce7660db221b59093d15c79c4b7" -dependencies = [ - "proc-macro-crate 1.3.1", - "proc-macro2", - "quote", - "syn 1.0.109", -] - -[[package]] -name = "sec1" -version = "0.7.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d3e97a565f76233a6003f9f5c54be1d9c5bdfa3eccfb189469f11ec4901c47dc" -dependencies = [ - "base16ct", - "der", - "generic-array", - "pkcs8", - "subtle", - "zeroize", -] - [[package]] name = "serde" -version = "1.0.203" +version = "1.0.204" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7253ab4de971e72fb7be983802300c30b5a7f0c2e56fab8abfc6a214307c0094" +checksum = "bc76f558e0cbb2a839d37354c575f1dc3fdc6546b5be373ba43d95f231bf7c12" dependencies = [ "serde_derive", ] [[package]] name = "serde_derive" -version = "1.0.203" +version = "1.0.204" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "500cbc0ebeb6f46627f50f3f5811ccf6bf00643be300b4c3eabc0ef55dc5b5ba" +checksum = "e0cd7e117be63d3c3678776753929474f3b04a43a080c744d6b0ae2a8c28e222" dependencies = [ "proc-macro2", "quote", - "syn 2.0.55", + "syn 2.0.69", ] [[package]] @@ -597,26 +287,6 @@ dependencies = [ "digest", ] -[[package]] -name = "signature" -version = "2.2.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "77549399552de45a898a580c1b41d445bf730df867cc44e6c0233bbc4b8329de" -dependencies = [ - "digest", - "rand_core", -] - -[[package]] -name = "snowbridge-amcl" -version = "1.0.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "460a9ed63cdf03c1b9847e8a12a5f5ba19c4efd5869e4a737e05be25d7c427e5" -dependencies = [ - "parity-scale-codec", - "scale-info", -] - [[package]] name = "sp1-derive" version = "0.1.0" @@ -627,19 +297,13 @@ dependencies = [ ] [[package]] -name = "sp1-precompiles" +name = "sp1-lib" version = "0.1.0" dependencies = [ "anyhow", "bincode", "cfg-if", - "getrandom", - "hex", - "k256", - "num", - "rand", "serde", - "snowbridge-amcl", ] [[package]] @@ -649,31 +313,15 @@ dependencies = [ "bincode", "cfg-if", "getrandom", - "k256", + "lazy_static", "libm", "once_cell", "rand", "serde", "sha2", - "sp1-precompiles", + "sp1-lib", ] -[[package]] -name = "spki" -version = "0.7.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d91ed6c858b01f942cd56b37a94b3e0a1798290327d1236e4d9cf4eaca44d29d" -dependencies = [ - "base64ct", - "der", -] - -[[package]] -name = "subtle" -version = "2.5.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "81cdd64d312baedb58e21336b31bc043b77e01cc99033ce76ef539f78e965ebc" - [[package]] name = "syn" version = "1.0.109" @@ -687,49 +335,15 @@ dependencies = [ [[package]] name = "syn" -version = "2.0.55" +version = "2.0.69" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "002a1b3dbf967edfafc32655d0f377ab0bb7b994aa1d32c8cc7e9b8bf3ebb8f0" +checksum = "201fcda3845c23e8212cd466bfebf0bd20694490fc0356ae8e428e0824a915a6" dependencies = [ "proc-macro2", "quote", "unicode-ident", ] -[[package]] -name = "tap" -version = "1.0.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "55937e1799185b12863d447f42597ed69d9928686b8d88a1df17376a097d8369" - -[[package]] -name = "toml_datetime" -version = "0.6.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7cda73e2f1397b1262d6dfdcef8aafae14d1de7748d66822d3bfeeb6d03e5e4b" - -[[package]] -name = "toml_edit" -version = "0.19.15" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1b5bb770da30e5cbfde35a2d7b9b8a2c4b8ef89548a7a6aeab5c9a576e3e7421" -dependencies = [ - "indexmap", - "toml_datetime", - "winnow", -] - -[[package]] -name = "toml_edit" -version = "0.20.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "396e4d48bbb2b7554c944bde63101b5ae446cff6ec4a24227428f15eb72ef338" -dependencies = [ - "indexmap", - "toml_datetime", - "winnow", -] - [[package]] name = "typenum" version = "1.17.0" @@ -753,27 +367,3 @@ name = "wasi" version = "0.11.0+wasi-snapshot-preview1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "9c8d87e72b64a3b4db28d11ce29237c246188f4f51057d65a7eab63b7987e423" - -[[package]] -name = "winnow" -version = "0.5.40" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f593a95398737aeed53e489c785df13f3618e41dbcd6718c6addbf1395aa6876" -dependencies = [ - "memchr", -] - -[[package]] -name = "wyz" -version = "0.5.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "05f360fc0b24296329c78fda852a1e9ae82de9cf7b27dae4b7f62f118f77b9ed" -dependencies = [ - "tap", -] - -[[package]] -name = "zeroize" -version = "1.7.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "525b4ec142c6b68a2d10f01f7bbf6755599ca3f81ea53b8431b7dd348f5fdb2d" diff --git a/tests/uint256-mul/Cargo.toml b/tests/uint256-mul/Cargo.toml index e793321d9d..b566692a4d 100644 --- a/tests/uint256-mul/Cargo.toml +++ b/tests/uint256-mul/Cargo.toml @@ -1,8 +1,9 @@ [workspace] [package] name = "biguint-mul-test" -version = "0.1.0" +version = "1.0.0-rc.1" edition = "2021" +publish = false [dependencies] rand = "0.8" diff --git a/tests/uint256-mul/elf/riscv32im-succinct-zkvm-elf b/tests/uint256-mul/elf/riscv32im-succinct-zkvm-elf index 2ab53b56d0..dcf3474c24 100755 Binary files a/tests/uint256-mul/elf/riscv32im-succinct-zkvm-elf and b/tests/uint256-mul/elf/riscv32im-succinct-zkvm-elf differ diff --git a/tests/uint256-mul/src/main.rs b/tests/uint256-mul/src/main.rs index 14d40e5b82..d7201115af 100644 --- a/tests/uint256-mul/src/main.rs +++ b/tests/uint256-mul/src/main.rs @@ -3,7 +3,7 @@ sp1_zkvm::entrypoint!(main); use num::{BigUint, One}; use rand::Rng; -use sp1_zkvm::precompiles::bigint_mulmod::sys_bigint; +use sp1_zkvm::syscalls::sys_bigint; fn uint256_mul(x: &[u8; 32], y: &[u8; 32], modulus: &[u8; 32]) -> [u8; 32] { println!("cycle-tracker-start: uint256_mul"); diff --git a/tests/verify-proof/Cargo.lock b/tests/verify-proof/Cargo.lock index 059b6fad62..88bd3863e6 100644 --- a/tests/verify-proof/Cargo.lock +++ b/tests/verify-proof/Cargo.lock @@ -8,30 +8,12 @@ version = "1.0.86" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "b3d1d046238990b9cf5bcde22a3fb3584ee5cf65fb2765f454ed428c7a0063da" -[[package]] -name = "arrayvec" -version = "0.7.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "96d30a06541fbafbc7f82ed10c06164cfbd2c401138f6addd8404629c4b16711" - [[package]] name = "autocfg" version = "1.2.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "f1fdabc7756949593fe60f30ec81974b613357de856987752631dea1e3394c80" -[[package]] -name = "base16ct" -version = "0.2.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4c7f02d4ea65f2c1853089ffd8d2787bdbc63de2f0d29dedbcf8ccdfa0ccd4cf" - -[[package]] -name = "base64ct" -version = "1.6.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8c3c1a368f70d6cf7302d78f8f7093da241fb8e8807c05cc9e51a125895a6d5b" - [[package]] name = "bincode" version = "1.3.3" @@ -41,18 +23,6 @@ dependencies = [ "serde", ] -[[package]] -name = "bitvec" -version = "1.0.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1bc2832c24239b0141d5674bb9174f9d68a8b5b3f2753311927c172ca46f7e9c" -dependencies = [ - "funty", - "radium", - "tap", - "wyz", -] - [[package]] name = "block-buffer" version = "0.10.4" @@ -62,24 +32,12 @@ dependencies = [ "generic-array", ] -[[package]] -name = "byte-slice-cast" -version = "1.2.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c3ac9f8b63eca6fd385229b3675f6cc0dc5c8a5c8a54a59d4f52ffd670d87b0c" - [[package]] name = "cfg-if" version = "1.0.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "baf1de4339761588bc0619e3cbc0120ee582ebb74b53b4efbf79117bd2da40fd" -[[package]] -name = "const-oid" -version = "0.9.6" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c2459377285ad874054d797f3ccebf984978aa39129f6eafde5cdc8315b612f8" - [[package]] name = "cpufeatures" version = "0.2.12" @@ -89,18 +47,6 @@ dependencies = [ "libc", ] -[[package]] -name = "crypto-bigint" -version = "0.5.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0dc92fb57ca44df6db8059111ab3af99a63d5d0f8375d9972e319a379c6bab76" -dependencies = [ - "generic-array", - "rand_core", - "subtle", - "zeroize", -] - [[package]] name = "crypto-common" version = "0.1.6" @@ -111,27 +57,6 @@ dependencies = [ "typenum", ] -[[package]] -name = "der" -version = "0.7.9" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f55bf8e7b65898637379c1b74eb1551107c8294ed26d855ceb9fd1a09cfc9bc0" -dependencies = [ - "const-oid", - "zeroize", -] - -[[package]] -name = "derive_more" -version = "0.99.17" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4fb810d30a7c1953f91334de7244731fc3f3c10d7fe163338a35b9f640960321" -dependencies = [ - "proc-macro2", - "quote", - "syn 1.0.109", -] - [[package]] name = "digest" version = "0.10.7" @@ -139,23 +64,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "9ed9a281f7bc9b7576e61468ba615a66a5c8cfdff42420a70aa82701a3b1e292" dependencies = [ "block-buffer", - "const-oid", "crypto-common", - "subtle", -] - -[[package]] -name = "ecdsa" -version = "0.16.9" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ee27f32b5c5292967d2d4a9d7f1e0b0aed2c15daded5a60300e4abb9d8020bca" -dependencies = [ - "der", - "digest", - "elliptic-curve", - "rfc6979", - "signature", - "spki", ] [[package]] @@ -164,49 +73,6 @@ version = "1.11.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "a47c1c47d2f5964e29c61246e81db715514cd532db6b5116a25ea3c03d6780a2" -[[package]] -name = "elliptic-curve" -version = "0.13.8" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b5e6043086bf7973472e0c7dff2142ea0b680d30e18d9cc40f267efbf222bd47" -dependencies = [ - "base16ct", - "crypto-bigint", - "digest", - "ff", - "generic-array", - "group", - "pkcs8", - "rand_core", - "sec1", - "subtle", - "tap", - "zeroize", -] - -[[package]] -name = "equivalent" -version = "1.0.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5443807d6dff69373d433ab9ef5378ad8df50ca6298caf15de6e52e24aaf54d5" - -[[package]] -name = "ff" -version = "0.13.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ded41244b729663b1e574f1b4fb731469f69f79c17667b5d776b16cda0479449" -dependencies = [ - "bitvec", - "rand_core", - "subtle", -] - -[[package]] -name = "funty" -version = "2.0.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e6d5a32815ae3f33302d95fdcb2ce17862f8c65363dcfd29360480ba1001fc9c" - [[package]] name = "gcd" version = "2.3.0" @@ -221,7 +87,6 @@ checksum = "85649ca51fd72272d7821adaf274ad91c288277713d9c18820d8499a7ff69e9a" dependencies = [ "typenum", "version_check", - "zeroize", ] [[package]] @@ -235,23 +100,6 @@ dependencies = [ "wasi", ] -[[package]] -name = "group" -version = "0.13.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f0f9ef7462f7c099f518d754361858f86d8a07af53ba9af0fe635bbccb151a63" -dependencies = [ - "ff", - "rand_core", - "subtle", -] - -[[package]] -name = "hashbrown" -version = "0.14.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "290f1a1d9242c78d09ce40a5e87e7554ee637af1351968159f4952f028f75604" - [[package]] name = "hex" version = "0.4.3" @@ -264,36 +112,6 @@ version = "0.4.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "6fe2267d4ed49bc07b63801559be28c718ea06c4738b7a03c94df7386d2cde46" -[[package]] -name = "hmac" -version = "0.12.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6c49c37c09c17a53d937dfbb742eb3a961d65a994e6bcdcf37e7399d0cc8ab5e" -dependencies = [ - "digest", -] - -[[package]] -name = "impl-trait-for-tuples" -version = "0.2.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "11d7a9f6330b71fea57921c9b61c47ee6e84f72d394754eff6163ae67e7395eb" -dependencies = [ - "proc-macro2", - "quote", - "syn 1.0.109", -] - -[[package]] -name = "indexmap" -version = "2.2.6" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "168fb715dda47215e360912c096649d23d58bf392ac62f73919e831745e40f26" -dependencies = [ - "equivalent", - "hashbrown", -] - [[package]] name = "itertools" version = "0.12.1" @@ -304,24 +122,19 @@ dependencies = [ ] [[package]] -name = "k256" -version = "0.13.3" +name = "itertools" +version = "0.13.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "956ff9b67e26e1a6a866cb758f12c6f8746208489e3e4a4b5580802f2f0a587b" +checksum = "413ee7dfc52ee1a4949ceeb7dbc8a33f2d6c088194d9f922fb8318faf1f01186" dependencies = [ - "cfg-if", - "ecdsa", - "elliptic-curve", - "once_cell", - "sha2", - "signature", + "either", ] [[package]] name = "lazy_static" -version = "1.4.0" +version = "1.5.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e2abad23fbc42b3700f2f279844dc832adb2b2eb069b2df918f455c4e18cc646" +checksum = "bbd2bcb4c963f2ddae06a2efc7e9f3591312473c50c6685e1f298068316e66fe" [[package]] name = "libc" @@ -335,26 +148,6 @@ version = "0.2.8" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "4ec2a862134d2a7d32d7983ddcdd1c4923530833c9f2ea1a44fc5fa473989058" -[[package]] -name = "memchr" -version = "2.7.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6c8640c5d730cb13ebd907d8d04b52f55ac9a2eec55b440c8892f40d56c76c1d" - -[[package]] -name = "num" -version = "0.4.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "35bd024e8b2ff75562e5f34e7f4905839deb4b22955ef5e73d2fea1b9813cb23" -dependencies = [ - "num-bigint", - "num-complex", - "num-integer", - "num-iter", - "num-rational", - "num-traits", -] - [[package]] name = "num-bigint" version = "0.4.5" @@ -365,15 +158,6 @@ dependencies = [ "num-traits", ] -[[package]] -name = "num-complex" -version = "0.4.6" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "73f88a1307638156682bada9d7604135552957b7818057dcef22705b4d509495" -dependencies = [ - "num-traits", -] - [[package]] name = "num-integer" version = "0.1.46" @@ -383,28 +167,6 @@ dependencies = [ "num-traits", ] -[[package]] -name = "num-iter" -version = "0.1.45" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1429034a0490724d0075ebb2bc9e875d6503c3cf69e235a8941aa757d83ef5bf" -dependencies = [ - "autocfg", - "num-integer", - "num-traits", -] - -[[package]] -name = "num-rational" -version = "0.4.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f83d14da390562dca69fc84082e73e548e1ad308d24accdedd2720017cb37824" -dependencies = [ - "num-bigint", - "num-integer", - "num-traits", -] - [[package]] name = "num-traits" version = "0.2.19" @@ -423,7 +185,7 @@ checksum = "3fdb12b2476b595f9358c5161aa467c2438859caa136dec86c26fdd2efe17b92" [[package]] name = "p3-baby-bear" version = "0.1.0" -source = "git+https://github.com/Plonky3/Plonky3.git?rev=3b5265f9d5af36534a46caebf0617595cfb42c5a#3b5265f9d5af36534a46caebf0617595cfb42c5a" +source = "git+https://github.com/Plonky3/Plonky3.git?rev=cab1182070a2dfb238fd1020e6113c5e36636f2f#cab1182070a2dfb238fd1020e6113c5e36636f2f" dependencies = [ "num-bigint", "p3-field", @@ -437,7 +199,7 @@ dependencies = [ [[package]] name = "p3-dft" version = "0.1.0" -source = "git+https://github.com/Plonky3/Plonky3.git?rev=3b5265f9d5af36534a46caebf0617595cfb42c5a#3b5265f9d5af36534a46caebf0617595cfb42c5a" +source = "git+https://github.com/Plonky3/Plonky3.git?rev=cab1182070a2dfb238fd1020e6113c5e36636f2f#cab1182070a2dfb238fd1020e6113c5e36636f2f" dependencies = [ "p3-field", "p3-matrix", @@ -449,9 +211,9 @@ dependencies = [ [[package]] name = "p3-field" version = "0.1.0" -source = "git+https://github.com/Plonky3/Plonky3.git?rev=3b5265f9d5af36534a46caebf0617595cfb42c5a#3b5265f9d5af36534a46caebf0617595cfb42c5a" +source = "git+https://github.com/Plonky3/Plonky3.git?rev=cab1182070a2dfb238fd1020e6113c5e36636f2f#cab1182070a2dfb238fd1020e6113c5e36636f2f" dependencies = [ - "itertools", + "itertools 0.12.1", "num-bigint", "num-traits", "p3-util", @@ -462,9 +224,9 @@ dependencies = [ [[package]] name = "p3-matrix" version = "0.1.0" -source = "git+https://github.com/Plonky3/Plonky3.git?rev=3b5265f9d5af36534a46caebf0617595cfb42c5a#3b5265f9d5af36534a46caebf0617595cfb42c5a" +source = "git+https://github.com/Plonky3/Plonky3.git?rev=cab1182070a2dfb238fd1020e6113c5e36636f2f#cab1182070a2dfb238fd1020e6113c5e36636f2f" dependencies = [ - "itertools", + "itertools 0.12.1", "p3-field", "p3-maybe-rayon", "p3-util", @@ -476,14 +238,14 @@ dependencies = [ [[package]] name = "p3-maybe-rayon" version = "0.1.0" -source = "git+https://github.com/Plonky3/Plonky3.git?rev=3b5265f9d5af36534a46caebf0617595cfb42c5a#3b5265f9d5af36534a46caebf0617595cfb42c5a" +source = "git+https://github.com/Plonky3/Plonky3.git?rev=cab1182070a2dfb238fd1020e6113c5e36636f2f#cab1182070a2dfb238fd1020e6113c5e36636f2f" [[package]] name = "p3-mds" version = "0.1.0" -source = "git+https://github.com/Plonky3/Plonky3.git?rev=3b5265f9d5af36534a46caebf0617595cfb42c5a#3b5265f9d5af36534a46caebf0617595cfb42c5a" +source = "git+https://github.com/Plonky3/Plonky3.git?rev=cab1182070a2dfb238fd1020e6113c5e36636f2f#cab1182070a2dfb238fd1020e6113c5e36636f2f" dependencies = [ - "itertools", + "itertools 0.12.1", "p3-dft", "p3-field", "p3-matrix", @@ -495,7 +257,7 @@ dependencies = [ [[package]] name = "p3-poseidon2" version = "0.1.0" -source = "git+https://github.com/Plonky3/Plonky3.git?rev=3b5265f9d5af36534a46caebf0617595cfb42c5a#3b5265f9d5af36534a46caebf0617595cfb42c5a" +source = "git+https://github.com/Plonky3/Plonky3.git?rev=cab1182070a2dfb238fd1020e6113c5e36636f2f#cab1182070a2dfb238fd1020e6113c5e36636f2f" dependencies = [ "gcd", "p3-field", @@ -507,9 +269,9 @@ dependencies = [ [[package]] name = "p3-symmetric" version = "0.1.0" -source = "git+https://github.com/Plonky3/Plonky3.git?rev=3b5265f9d5af36534a46caebf0617595cfb42c5a#3b5265f9d5af36534a46caebf0617595cfb42c5a" +source = "git+https://github.com/Plonky3/Plonky3.git?rev=cab1182070a2dfb238fd1020e6113c5e36636f2f#cab1182070a2dfb238fd1020e6113c5e36636f2f" dependencies = [ - "itertools", + "itertools 0.12.1", "p3-field", "serde", ] @@ -517,77 +279,23 @@ dependencies = [ [[package]] name = "p3-util" version = "0.1.0" -source = "git+https://github.com/Plonky3/Plonky3.git?rev=3b5265f9d5af36534a46caebf0617595cfb42c5a#3b5265f9d5af36534a46caebf0617595cfb42c5a" +source = "git+https://github.com/Plonky3/Plonky3.git?rev=cab1182070a2dfb238fd1020e6113c5e36636f2f#cab1182070a2dfb238fd1020e6113c5e36636f2f" dependencies = [ "serde", ] -[[package]] -name = "parity-scale-codec" -version = "3.6.9" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "881331e34fa842a2fb61cc2db9643a8fedc615e47cfcc52597d1af0db9a7e8fe" -dependencies = [ - "arrayvec", - "byte-slice-cast", - "impl-trait-for-tuples", - "parity-scale-codec-derive", -] - -[[package]] -name = "parity-scale-codec-derive" -version = "3.6.9" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "be30eaf4b0a9fba5336683b38de57bb86d179a35862ba6bfcf57625d006bde5b" -dependencies = [ - "proc-macro-crate 2.0.2", - "proc-macro2", - "quote", - "syn 1.0.109", -] - [[package]] name = "pin-project-lite" version = "0.2.14" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "bda66fc9667c18cb2758a2ac84d1167245054bcf85d5d1aaa6923f45801bdd02" -[[package]] -name = "pkcs8" -version = "0.10.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f950b2377845cebe5cf8b5165cb3cc1a5e0fa5cfa3e1f7f55707d8fd82e0a7b7" -dependencies = [ - "der", - "spki", -] - [[package]] name = "ppv-lite86" version = "0.2.17" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "5b40af805b3121feab8a3c29f04d8ad262fa8e0561883e7653e024ae4479e6de" -[[package]] -name = "proc-macro-crate" -version = "1.3.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7f4c021e1093a56626774e81216a4ce732a735e5bad4868a03f3ed65ca0c3919" -dependencies = [ - "once_cell", - "toml_edit 0.19.15", -] - -[[package]] -name = "proc-macro-crate" -version = "2.0.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b00f26d3400549137f92511a46ac1cd8ce37cb5598a96d382381458b992a5d24" -dependencies = [ - "toml_datetime", - "toml_edit 0.20.2", -] - [[package]] name = "proc-macro2" version = "1.0.81" @@ -606,12 +314,6 @@ dependencies = [ "proc-macro2", ] -[[package]] -name = "radium" -version = "0.7.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "dc33ff2d4973d518d823d61aa239014831e521c75da58e3df4840d3f47749d09" - [[package]] name = "rand" version = "0.8.5" @@ -642,54 +344,6 @@ dependencies = [ "getrandom", ] -[[package]] -name = "rfc6979" -version = "0.4.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f8dd2a808d456c4a54e300a23e9f5a67e122c3024119acbfd73e3bf664491cb2" -dependencies = [ - "hmac", - "subtle", -] - -[[package]] -name = "scale-info" -version = "2.11.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7c453e59a955f81fb62ee5d596b450383d699f152d350e9d23a0db2adb78e4c0" -dependencies = [ - "cfg-if", - "derive_more", - "parity-scale-codec", - "scale-info-derive", -] - -[[package]] -name = "scale-info-derive" -version = "2.11.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "18cf6c6447f813ef19eb450e985bcce6705f9ce7660db221b59093d15c79c4b7" -dependencies = [ - "proc-macro-crate 1.3.1", - "proc-macro2", - "quote", - "syn 1.0.109", -] - -[[package]] -name = "sec1" -version = "0.7.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d3e97a565f76233a6003f9f5c54be1d9c5bdfa3eccfb189469f11ec4901c47dc" -dependencies = [ - "base16ct", - "der", - "generic-array", - "pkcs8", - "subtle", - "zeroize", -] - [[package]] name = "serde" version = "1.0.203" @@ -707,7 +361,7 @@ checksum = "500cbc0ebeb6f46627f50f3f5811ccf6bf00643be300b4c3eabc0ef55dc5b5ba" dependencies = [ "proc-macro2", "quote", - "syn 2.0.60", + "syn", ] [[package]] @@ -722,46 +376,20 @@ dependencies = [ ] [[package]] -name = "signature" -version = "2.2.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "77549399552de45a898a580c1b41d445bf730df867cc44e6c0233bbc4b8329de" -dependencies = [ - "digest", - "rand_core", -] - -[[package]] -name = "snowbridge-amcl" -version = "1.0.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "460a9ed63cdf03c1b9847e8a12a5f5ba19c4efd5869e4a737e05be25d7c427e5" -dependencies = [ - "parity-scale-codec", - "scale-info", -] - -[[package]] -name = "sp1-precompiles" +name = "sp1-lib" version = "0.1.0" dependencies = [ "anyhow", "bincode", "cfg-if", - "getrandom", - "hex", - "k256", - "num", - "rand", "serde", - "snowbridge-amcl", ] [[package]] name = "sp1-primitives" version = "0.1.0" dependencies = [ - "itertools", + "itertools 0.13.0", "lazy_static", "p3-baby-bear", "p3-field", @@ -776,7 +404,7 @@ dependencies = [ "bincode", "cfg-if", "getrandom", - "k256", + "lazy_static", "libm", "once_cell", "p3-baby-bear", @@ -784,37 +412,10 @@ dependencies = [ "rand", "serde", "sha2", - "sp1-precompiles", + "sp1-lib", "sp1-primitives", ] -[[package]] -name = "spki" -version = "0.7.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d91ed6c858b01f942cd56b37a94b3e0a1798290327d1236e4d9cf4eaca44d29d" -dependencies = [ - "base64ct", - "der", -] - -[[package]] -name = "subtle" -version = "2.5.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "81cdd64d312baedb58e21336b31bc043b77e01cc99033ce76ef539f78e965ebc" - -[[package]] -name = "syn" -version = "1.0.109" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "72b64191b275b66ffe2469e8af2c1cfe3bafa67b529ead792a6d0160888b4237" -dependencies = [ - "proc-macro2", - "quote", - "unicode-ident", -] - [[package]] name = "syn" version = "2.0.60" @@ -826,40 +427,6 @@ dependencies = [ "unicode-ident", ] -[[package]] -name = "tap" -version = "1.0.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "55937e1799185b12863d447f42597ed69d9928686b8d88a1df17376a097d8369" - -[[package]] -name = "toml_datetime" -version = "0.6.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7cda73e2f1397b1262d6dfdcef8aafae14d1de7748d66822d3bfeeb6d03e5e4b" - -[[package]] -name = "toml_edit" -version = "0.19.15" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1b5bb770da30e5cbfde35a2d7b9b8a2c4b8ef89548a7a6aeab5c9a576e3e7421" -dependencies = [ - "indexmap", - "toml_datetime", - "winnow", -] - -[[package]] -name = "toml_edit" -version = "0.20.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "396e4d48bbb2b7554c944bde63101b5ae446cff6ec4a24227428f15eb72ef338" -dependencies = [ - "indexmap", - "toml_datetime", - "winnow", -] - [[package]] name = "tracing" version = "0.1.40" @@ -879,7 +446,7 @@ checksum = "34704c8d6ebcbc939824180af020566b01a7c01f80641264eba0999f6c2b6be7" dependencies = [ "proc-macro2", "quote", - "syn 2.0.60", + "syn", ] [[package]] @@ -924,27 +491,3 @@ name = "wasi" version = "0.11.0+wasi-snapshot-preview1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "9c8d87e72b64a3b4db28d11ce29237c246188f4f51057d65a7eab63b7987e423" - -[[package]] -name = "winnow" -version = "0.5.40" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f593a95398737aeed53e489c785df13f3618e41dbcd6718c6addbf1395aa6876" -dependencies = [ - "memchr", -] - -[[package]] -name = "wyz" -version = "0.5.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "05f360fc0b24296329c78fda852a1e9ae82de9cf7b27dae4b7f62f118f77b9ed" -dependencies = [ - "tap", -] - -[[package]] -name = "zeroize" -version = "1.7.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "525b4ec142c6b68a2d10f01f7bbf6755599ca3f81ea53b8431b7dd348f5fdb2d" diff --git a/tests/verify-proof/Cargo.toml b/tests/verify-proof/Cargo.toml index 5ae785a7bc..aafde1fe9a 100644 --- a/tests/verify-proof/Cargo.toml +++ b/tests/verify-proof/Cargo.toml @@ -1,8 +1,9 @@ [workspace] [package] -version = "0.1.0" name = "verify-proof" +version = "1.0.0-rc.1" edition = "2021" +publish = false [dependencies] sp1-zkvm = { path = "../../zkvm/entrypoint", features = ["verify"] } diff --git a/tests/verify-proof/elf/riscv32im-succinct-zkvm-elf b/tests/verify-proof/elf/riscv32im-succinct-zkvm-elf index 93c15811cb..044250fe03 100755 Binary files a/tests/verify-proof/elf/riscv32im-succinct-zkvm-elf and b/tests/verify-proof/elf/riscv32im-succinct-zkvm-elf differ diff --git a/tests/verify-proof/src/main.rs b/tests/verify-proof/src/main.rs index 396155340e..2e4cba64e4 100644 --- a/tests/verify-proof/src/main.rs +++ b/tests/verify-proof/src/main.rs @@ -5,7 +5,7 @@ sp1_zkvm::entrypoint!(main); use sha2::{Digest, Sha256}; -use sp1_zkvm::precompiles::verify::verify_sp1_proof; +use sp1_zkvm::lib::verify::verify_sp1_proof; fn words_to_bytes(words: &[u32; 8]) -> [u8; 32] { let mut bytes = [0u8; 32]; diff --git a/zkvm/entrypoint/CHANGELOG.md b/zkvm/entrypoint/CHANGELOG.md new file mode 100644 index 0000000000..3334a3e874 --- /dev/null +++ b/zkvm/entrypoint/CHANGELOG.md @@ -0,0 +1,81 @@ +# Changelog + +All notable changes to this project will be documented in this file. + +The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/), +and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html). + +## [Unreleased] + +## [1.0.0-rc.1](https://github.com/succinctlabs/sp1/compare/sp1-zkvm-v1.0.0-rc.1...sp1-zkvm-v1.0.0-rc.1) - 2024-07-19 + +### Added + +- publish sp1 to crates.io ([#1052](https://github.com/succinctlabs/sp1/pull/1052)) +- `mulmod` uint256 precompile ([#642](https://github.com/succinctlabs/sp1/pull/642)) +- aggregation fixes ([#649](https://github.com/succinctlabs/sp1/pull/649)) +- complete reduce program ([#565](https://github.com/succinctlabs/sp1/pull/565)) +- feat(precompile) bls12-381 add and double precompile ([#448](https://github.com/succinctlabs/sp1/pull/448)) +- _(precompile)_ add biguint arithmetic precompiles ([#378](https://github.com/succinctlabs/sp1/pull/378)) +- weierstrass decompress precompile ([#440](https://github.com/succinctlabs/sp1/pull/440)) +- nested sp1 proof verification ([#494](https://github.com/succinctlabs/sp1/pull/494)) +- setup recursion prover crate ([#475](https://github.com/succinctlabs/sp1/pull/475)) +- public values ([#455](https://github.com/succinctlabs/sp1/pull/455)) +- one cycle input ([#451](https://github.com/succinctlabs/sp1/pull/451)) +- _(precompile)_ add bn254 precompile ([#384](https://github.com/succinctlabs/sp1/pull/384)) +- Connect CPU to ECALL tables ([#364](https://github.com/succinctlabs/sp1/pull/364)) +- Many small features and chores ([#347](https://github.com/succinctlabs/sp1/pull/347)) +- program build script ([#296](https://github.com/succinctlabs/sp1/pull/296)) +- add musl-libc memcpy ([#279](https://github.com/succinctlabs/sp1/pull/279)) +- new README img ([#226](https://github.com/succinctlabs/sp1/pull/226)) +- readme updates ([#205](https://github.com/succinctlabs/sp1/pull/205)) +- more final touches ([#194](https://github.com/succinctlabs/sp1/pull/194)) +- curtaup + release system + cargo prove CLI updates ([#178](https://github.com/succinctlabs/sp1/pull/178)) +- (perf) updates from Plonky3 and verifier refactor ([#156](https://github.com/succinctlabs/sp1/pull/156)) +- developer experience improvements ([#145](https://github.com/succinctlabs/sp1/pull/145)) +- toolchain build from source & install ([#113](https://github.com/succinctlabs/sp1/pull/113)) +- io::read io::write ([#126](https://github.com/succinctlabs/sp1/pull/126)) +- tracing, profiling, benchmarking ([#99](https://github.com/succinctlabs/sp1/pull/99)) + +### Fixed + +- memory limit ([#1123](https://github.com/succinctlabs/sp1/pull/1123)) +- BLS381 decompress ([#1121](https://github.com/succinctlabs/sp1/pull/1121)) +- uint256 fixes ([#990](https://github.com/succinctlabs/sp1/pull/990)) +- no mangle +- replace `jal` with `call` in entrypoint ([#898](https://github.com/succinctlabs/sp1/pull/898)) +- sys_bigint duplicate symbol ([#880](https://github.com/succinctlabs/sp1/pull/880)) +- `getrandom` version ([#753](https://github.com/succinctlabs/sp1/pull/753)) +- _(zkvm)_ libm math intrinsics ([#287](https://github.com/succinctlabs/sp1/pull/287)) +- memcpy & memset ([#282](https://github.com/succinctlabs/sp1/pull/282)) +- zkvm crate refactor bug ([#276](https://github.com/succinctlabs/sp1/pull/276)) + +### Other + +- use global workspace version ([#1102](https://github.com/succinctlabs/sp1/pull/1102)) +- fix release-plz ([#1088](https://github.com/succinctlabs/sp1/pull/1088)) +- add release-plz ([#1086](https://github.com/succinctlabs/sp1/pull/1086)) +- _(deps)_ bump serde from 1.0.203 to 1.0.204 ([#1063](https://github.com/succinctlabs/sp1/pull/1063)) +- clenaup zkvm +- hm +- cleanup zkvm/lib +- _(deps)_ bump lazy_static from 1.4.0 to 1.5.0 +- fix sys rand ([#919](https://github.com/succinctlabs/sp1/pull/919)) +- runtime gets printed out 3 times +- hm +- sys rand szn +- Make some functions const ([#774](https://github.com/succinctlabs/sp1/pull/774)) +- Clean up TOML files ([#796](https://github.com/succinctlabs/sp1/pull/796)) +- update all dependencies ([#689](https://github.com/succinctlabs/sp1/pull/689)) +- sdk improvements ([#580](https://github.com/succinctlabs/sp1/pull/580)) +- prover tweaks ([#610](https://github.com/succinctlabs/sp1/pull/610)) +- sha cleanup + constraints ([#425](https://github.com/succinctlabs/sp1/pull/425)) +- split zkvm crate into entrypoint and precompiles ([#275](https://github.com/succinctlabs/sp1/pull/275)) +- final touches for public release ([#239](https://github.com/succinctlabs/sp1/pull/239)) +- update docs with slight nits ([#224](https://github.com/succinctlabs/sp1/pull/224)) +- sp1 rename ([#212](https://github.com/succinctlabs/sp1/pull/212)) +- enshrine AlignedBorrow macro ([#209](https://github.com/succinctlabs/sp1/pull/209)) +- readme cleanup ([#196](https://github.com/succinctlabs/sp1/pull/196)) +- rename succinct to curta ([#192](https://github.com/succinctlabs/sp1/pull/192)) +- better curta graphic ([#184](https://github.com/succinctlabs/sp1/pull/184)) +- Initial commit diff --git a/zkvm/entrypoint/Cargo.toml b/zkvm/entrypoint/Cargo.toml index 5cdea96798..d51bccbf6a 100644 --- a/zkvm/entrypoint/Cargo.toml +++ b/zkvm/entrypoint/Cargo.toml @@ -1,30 +1,41 @@ [package] name = "sp1-zkvm" -version = "0.1.0" -edition = "2021" +description = "SP1 is a performant, 100% open-source, contributor-friendly zkVM." +readme = "../../README.md" +version = { workspace = true } +edition = { workspace = true } +license = { workspace = true } +repository = { workspace = true } +keywords = { workspace = true } +categories = { workspace = true } [dependencies] -sp1-precompiles = { path = "../precompiles" } -sp1-primitives = { path = "../../primitives", optional = true } -p3-baby-bear = { workspace = true, optional = true } -p3-field = { workspace = true, optional = true } bincode = "1.3.3" cfg-if = "1.0.0" getrandom = { version = "0.2.14", features = ["custom"] } -k256 = { version = "0.13.3", features = ["ecdsa", "std", "bits"] } once_cell = "1.19.0" rand = "0.8.5" -serde = { version = "1.0.201", features = ["derive"] } +serde = { version = "1.0.204", features = ["derive"] } libm = { version = "0.2.8", optional = true } sha2 = { version = "0.10.8" } -lazy_static = "1.4.0" +lazy_static = "1.5.0" + +# optional +sp1-lib = { workspace = true, optional = true } +sp1-primitives = { workspace = true, optional = true } +p3-baby-bear = { workspace = true, optional = true } +p3-field = { workspace = true, optional = true } [features] -default = ["libm"] +default = ["libm", "lib"] libm = ["dep:libm"] +lib = ["dep:sp1-lib"] verify = [ "dep:sp1-primitives", "dep:p3-baby-bear", "dep:p3-field", - "sp1-precompiles/verify", + "sp1-lib/verify", ] +bn254 = ["sp1-lib/bn254"] +secp256k1 = ["sp1-lib/secp256k1"] +bls12381 = ["sp1-lib/bls12381"] diff --git a/zkvm/entrypoint/src/lib.rs b/zkvm/entrypoint/src/lib.rs index 51cf158a3d..eb8c5b7264 100644 --- a/zkvm/entrypoint/src/lib.rs +++ b/zkvm/entrypoint/src/lib.rs @@ -1,14 +1,17 @@ +extern crate alloc; + pub mod heap; pub mod syscalls; + +#[cfg(feature = "lib")] pub mod io { - pub use sp1_precompiles::io::*; + pub use sp1_lib::io::*; } -pub mod precompiles { - pub use sp1_precompiles::*; +#[cfg(feature = "lib")] +pub mod lib { + pub use sp1_lib::*; } -extern crate alloc; - #[macro_export] macro_rules! entrypoint { ($path:path) => { diff --git a/zkvm/entrypoint/src/memory.rs b/zkvm/entrypoint/src/memory.rs deleted file mode 100644 index b4c967ea1b..0000000000 --- a/zkvm/entrypoint/src/memory.rs +++ /dev/null @@ -1,51 +0,0 @@ -// Copyright 2023 RISC Zero, Inc. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -const SYSTEM_START: usize = 0x0C00_0000; - -#[allow(clippy::missing_safety_doc)] -#[no_mangle] -pub unsafe extern "C" fn sys_alloc_aligned(bytes: usize, align: usize) -> *mut u8 { - extern "C" { - // https://lld.llvm.org/ELF/linker_script.html#sections-command - static _end: u8; - } - - // Pointer to next heap address to use, or 0 if the heap has not yet been - // initialized. - static mut HEAP_POS: usize = 0; - - // SAFETY: Single threaded, so nothing else can touch this while we're working. - let mut heap_pos = unsafe { HEAP_POS }; - - if heap_pos == 0 { - heap_pos = unsafe { (&_end) as *const u8 as usize }; - } - - let offset = heap_pos & (align - 1); - if offset != 0 { - heap_pos += align - offset; - } - - let ptr = heap_pos as *mut u8; - heap_pos += bytes; - - // Check to make sure heap doesn't collide with SYSTEM memory. - if SYSTEM_START < heap_pos { - panic!(); - } - - unsafe { HEAP_POS = heap_pos }; - ptr -} diff --git a/zkvm/entrypoint/src/syscalls/bigint.rs b/zkvm/entrypoint/src/syscalls/bigint.rs index ee05211be2..85db9c7929 100644 --- a/zkvm/entrypoint/src/syscalls/bigint.rs +++ b/zkvm/entrypoint/src/syscalls/bigint.rs @@ -1,7 +1,7 @@ -use sp1_precompiles::BIGINT_WIDTH_WORDS; - use super::syscall_uint256_mulmod; +pub const BIGINT_WIDTH_WORDS: usize = 8; + /// Sets result to be (x op y) % modulus. Currently only multiplication is supported. If modulus is /// zero, the modulus applied is 2^256. #[allow(unused_variables)] diff --git a/zkvm/entrypoint/src/syscalls/bls12381.rs b/zkvm/entrypoint/src/syscalls/bls12381.rs index 929a861b57..e4c34d5828 100644 --- a/zkvm/entrypoint/src/syscalls/bls12381.rs +++ b/zkvm/entrypoint/src/syscalls/bls12381.rs @@ -44,7 +44,7 @@ pub extern "C" fn syscall_bls12381_double(p: *mut u32) { /// The second half of the input array will be overwritten with the Y coordinate. #[allow(unused_variables)] #[no_mangle] -pub extern "C" fn syscall_bls12381_decompress(point: &mut [u8; 96], is_odd: bool) { +pub extern "C" fn syscall_bls12381_decompress(point: &mut [u8; 96], sign_bit: bool) { #[cfg(target_os = "zkvm")] { // Memory system/FpOps are little endian so we'll just flip the whole array before/after @@ -55,7 +55,7 @@ pub extern "C" fn syscall_bls12381_decompress(point: &mut [u8; 96], is_odd: bool "ecall", in("t0") crate::syscalls::BLS12381_DECOMPRESS, in("a0") p, - in("a1") is_odd as u8, + in("a1") sign_bit as u8, ); } point.reverse(); diff --git a/zkvm/entrypoint/src/syscalls/halt.rs b/zkvm/entrypoint/src/syscalls/halt.rs index caaf55d9ac..930685b588 100644 --- a/zkvm/entrypoint/src/syscalls/halt.rs +++ b/zkvm/entrypoint/src/syscalls/halt.rs @@ -26,33 +26,22 @@ pub extern "C" fn syscall_halt(exit_code: u8) -> ! { .unwrap() .finalize(); - // Convert the digest bytes into words, since we will be calling COMMIT ecall with - // the words as a parameter. - let pv_digest_words: [u32; PV_DIGEST_NUM_WORDS] = pv_digest_bytes - .as_slice() - .chunks_exact(4) - .map(|chunk| u32::from_le_bytes(chunk.try_into().unwrap())) - .collect::>() - .try_into() - .unwrap(); - // For each digest word, call COMMIT ecall. In the runtime, this will store the digest words // into the runtime's execution record's public values digest. In the AIR, it will be used // to verify that the provided public values digest matches the one computed by the program. for i in 0..PV_DIGEST_NUM_WORDS { - asm!("ecall", in("t0") crate::syscalls::COMMIT, in("a0") i, in("a1") pv_digest_words[i]); + // Convert the digest bytes into words, since we will call COMMIT one word at a time. + let word = u32::from_le_bytes(pv_digest_bytes[i * 4..(i + 1) * 4].try_into().unwrap()); + asm!("ecall", in("t0") crate::syscalls::COMMIT, in("a0") i, in("a1") word); } cfg_if! { if #[cfg(feature = "verify")] { let deferred_proofs_digest = zkvm::DEFERRED_PROOFS_DIGEST.as_mut().unwrap(); - let deferred_proofs_digest_words = deferred_proofs_digest - .iter() - .map(|baby_bear| baby_bear.as_canonical_u32()) - .collect::>(); for i in 0..POSEIDON_NUM_WORDS { - asm!("ecall", in("t0") crate::syscalls::COMMIT_DEFERRED_PROOFS, in("a0") i, in("a1") deferred_proofs_digest_words[i]); + let word = deferred_proofs_digest[i].as_canonical_u32(); + asm!("ecall", in("t0") crate::syscalls::COMMIT_DEFERRED_PROOFS, in("a0") i, in("a1") word); } } else { for i in 0..POSEIDON_NUM_WORDS { diff --git a/zkvm/entrypoint/src/syscalls/io.rs b/zkvm/entrypoint/src/syscalls/io.rs index 35c9f0b447..6ba7c62ddd 100644 --- a/zkvm/entrypoint/src/syscalls/io.rs +++ b/zkvm/entrypoint/src/syscalls/io.rs @@ -3,7 +3,6 @@ cfg_if::cfg_if! { use core::arch::asm; use crate::zkvm; use sha2::digest::Update; - use sp1_precompiles::io::FD_PUBLIC_VALUES; } } @@ -13,6 +12,7 @@ cfg_if::cfg_if! { pub extern "C" fn syscall_write(fd: u32, write_buf: *const u8, nbytes: usize) { cfg_if::cfg_if! { if #[cfg(target_os = "zkvm")] { + const FD_PUBLIC_VALUES: u32 = 3; unsafe { asm!( "ecall", diff --git a/zkvm/entrypoint/src/syscalls/memory.rs b/zkvm/entrypoint/src/syscalls/memory.rs index b4c967ea1b..28d22e22d6 100644 --- a/zkvm/entrypoint/src/syscalls/memory.rs +++ b/zkvm/entrypoint/src/syscalls/memory.rs @@ -12,7 +12,8 @@ // See the License for the specific language governing permissions and // limitations under the License. -const SYSTEM_START: usize = 0x0C00_0000; +// Memory addresses must be lower than BabyBear prime. +const MAX_MEMORY: usize = 0x78000000; #[allow(clippy::missing_safety_doc)] #[no_mangle] @@ -39,11 +40,10 @@ pub unsafe extern "C" fn sys_alloc_aligned(bytes: usize, align: usize) -> *mut u } let ptr = heap_pos as *mut u8; - heap_pos += bytes; + let (heap_pos, overflowed) = heap_pos.overflowing_add(bytes); - // Check to make sure heap doesn't collide with SYSTEM memory. - if SYSTEM_START < heap_pos { - panic!(); + if overflowed || MAX_MEMORY < heap_pos { + panic!("Memory limit exceeded (0x78000000)"); } unsafe { HEAP_POS = heap_pos }; diff --git a/zkvm/entrypoint/src/syscalls/mod.rs b/zkvm/entrypoint/src/syscalls/mod.rs index 50be5d7b04..2e28c51df7 100644 --- a/zkvm/entrypoint/src/syscalls/mod.rs +++ b/zkvm/entrypoint/src/syscalls/mod.rs @@ -15,6 +15,7 @@ mod unconstrained; #[cfg(feature = "verify")] mod verify; +pub use bigint::*; pub use bls12381::*; pub use bn254::*; pub use ed25519::*; @@ -95,7 +96,7 @@ pub const HINT_READ: u32 = 0x00_00_00_F1; pub const BLS12381_DECOMPRESS: u32 = 0x00_00_01_1C; /// Executes the `UINT256_MUL` precompile. -pub const UINT256_MUL: u32 = 0x00_00_01_1D; +pub const UINT256_MUL: u32 = 0x00_01_01_1D; /// Executes the `BLS12381_ADD` precompile. pub const BLS12381_ADD: u32 = 0x00_01_01_1E; diff --git a/zkvm/lib/CHANGELOG.md b/zkvm/lib/CHANGELOG.md new file mode 100644 index 0000000000..036dc4895a --- /dev/null +++ b/zkvm/lib/CHANGELOG.md @@ -0,0 +1,46 @@ +# Changelog + +All notable changes to this project will be documented in this file. + +The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/), +and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html). + +## [Unreleased] + +## [1.0.0-rc.1](https://github.com/succinctlabs/sp1/compare/sp1-lib-v1.0.0-rc.1...sp1-lib-v1.0.0-rc.1) - 2024-07-19 + +### Added + +- publish sp1 to crates.io ([#1052](https://github.com/succinctlabs/sp1/pull/1052)) +- new README img ([#226](https://github.com/succinctlabs/sp1/pull/226)) +- readme updates ([#205](https://github.com/succinctlabs/sp1/pull/205)) +- more final touches ([#194](https://github.com/succinctlabs/sp1/pull/194)) +- curtaup + release system + cargo prove CLI updates ([#178](https://github.com/succinctlabs/sp1/pull/178)) +- (perf) updates from Plonky3 and verifier refactor ([#156](https://github.com/succinctlabs/sp1/pull/156)) +- developer experience improvements ([#145](https://github.com/succinctlabs/sp1/pull/145)) +- toolchain build from source & install ([#113](https://github.com/succinctlabs/sp1/pull/113)) +- io::read io::write ([#126](https://github.com/succinctlabs/sp1/pull/126)) +- tracing, profiling, benchmarking ([#99](https://github.com/succinctlabs/sp1/pull/99)) + +### Fixed + +- BLS381 decompress ([#1121](https://github.com/succinctlabs/sp1/pull/1121)) +- handle mul_assign scalar zero ([#1077](https://github.com/succinctlabs/sp1/pull/1077)) + +### Other + +- use global workspace version ([#1102](https://github.com/succinctlabs/sp1/pull/1102)) +- fix release-plz ([#1088](https://github.com/succinctlabs/sp1/pull/1088)) +- add release-plz ([#1086](https://github.com/succinctlabs/sp1/pull/1086)) +- _(deps)_ bump serde from 1.0.203 to 1.0.204 ([#1063](https://github.com/succinctlabs/sp1/pull/1063)) +- hm +- ignore +- cleanup zkvm/lib +- final touches for public release ([#239](https://github.com/succinctlabs/sp1/pull/239)) +- update docs with slight nits ([#224](https://github.com/succinctlabs/sp1/pull/224)) +- sp1 rename ([#212](https://github.com/succinctlabs/sp1/pull/212)) +- enshrine AlignedBorrow macro ([#209](https://github.com/succinctlabs/sp1/pull/209)) +- readme cleanup ([#196](https://github.com/succinctlabs/sp1/pull/196)) +- rename succinct to curta ([#192](https://github.com/succinctlabs/sp1/pull/192)) +- better curta graphic ([#184](https://github.com/succinctlabs/sp1/pull/184)) +- Initial commits diff --git a/zkvm/lib/Cargo.toml b/zkvm/lib/Cargo.toml new file mode 100644 index 0000000000..c7030d1b53 --- /dev/null +++ b/zkvm/lib/Cargo.toml @@ -0,0 +1,36 @@ +[package] +name = "sp1-lib" +description = "SP1 is a performant, 100% open-source, contributor-friendly zkVM." +readme = "../../README.md" +version = { workspace = true } +edition = { workspace = true } +license = { workspace = true } +repository = { workspace = true } +keywords = { workspace = true } +categories = { workspace = true } + +[dependencies] +anyhow = "1.0.83" +bincode = "1.3.3" +cfg-if = "1.0.0" +serde = { version = "1.0.204", features = ["derive"] } + +# bls12-381 +amcl = { package = "snowbridge-amcl", version = "1.0.2", default-features = false, features = [ + "bls381", +], optional = true } +hex = { version = "0.4.3", optional = true } + +# k256 +k256 = { version = "0.13.3", features = [ + "ecdsa", + "std", + "bits", +], optional = true } + +[features] +default = [] +verify = [] +bn254 = [] +secp256k1 = ["dep:k256"] +bls12381 = ["dep:amcl", "dep:hex"] diff --git a/zkvm/precompiles/src/bls12381.rs b/zkvm/lib/src/bls12381.rs similarity index 87% rename from zkvm/precompiles/src/bls12381.rs rename to zkvm/lib/src/bls12381.rs index 8f77ff132b..ebf39876ca 100644 --- a/zkvm/precompiles/src/bls12381.rs +++ b/zkvm/lib/src/bls12381.rs @@ -11,8 +11,9 @@ pub struct Bls12381; const NUM_WORDS: usize = 24; impl CurveOperations for Bls12381 { - // The generator has been taken from py_ecc python library by Ethereum Foundation. - // https://github.com/ethereum/py_ecc/blob/7b9e1b3/py_ecc/bls12_381/bls12_381_curve.py#L38-L45 + /// The generator has been taken from py_ecc python library by the Ethereum Foundation: + /// + /// https://github.com/ethereum/py_ecc/blob/7b9e1b3/py_ecc/bls12_381/bls12_381_curve.py#L38-L45 const GENERATOR: [u32; NUM_WORDS] = [ 3676489403, 4214943754, 4185529071, 1817569343, 387689560, 2706258495, 2541009157, 3278408783, 1336519695, 647324556, 832034708, 401724327, 1187375073, 212476713, 2726857444, @@ -39,10 +40,11 @@ pub fn decompress_pubkey(compressed_key: &[u8; 48]) -> Result<[u8; 96]> { if #[cfg(all(target_os = "zkvm", target_vendor = "succinct"))] { let mut decompressed_key = [0u8; 96]; decompressed_key[..48].copy_from_slice(compressed_key); - let is_odd = (decompressed_key[0] & 0b_0010_0000) >> 5 == 0; + + let sign_bit = ((decompressed_key[0] & 0b_0010_0000) >> 5) == 1; decompressed_key[0] &= 0b_0001_1111; unsafe { - syscall_bls12381_decompress(&mut decompressed_key, is_odd); + syscall_bls12381_decompress(&mut decompressed_key, sign_bit); } Ok(decompressed_key) diff --git a/zkvm/precompiles/src/bn254.rs b/zkvm/lib/src/bn254.rs similarity index 75% rename from zkvm/precompiles/src/bn254.rs rename to zkvm/lib/src/bn254.rs index 358ea8c9bb..86a4cf94f1 100644 --- a/zkvm/precompiles/src/bn254.rs +++ b/zkvm/lib/src/bn254.rs @@ -7,8 +7,9 @@ pub struct Bn254; const NUM_WORDS: usize = 16; impl CurveOperations for Bn254 { - // The values has been taken from py_ecc python library by Ethereum Foundation. - // https://github.com/ethereum/py_pairing/blob/5f609da/py_ecc/bn128/bn128_field_elements.py + /// The generator has been taken from py_pairing python library by the Ethereum Foundation: + /// + /// https://github.com/ethereum/py_pairing/blob/5f609da/py_ecc/bn128/bn128_field_elements.py const GENERATOR: [u32; NUM_WORDS] = [1, 0, 0, 0, 0, 0, 0, 0, 2, 0, 0, 0, 0, 0, 0, 0]; fn add_assign(limbs: &mut [u32; NUM_WORDS], other: &[u32; NUM_WORDS]) { diff --git a/zkvm/precompiles/src/io.rs b/zkvm/lib/src/io.rs similarity index 54% rename from zkvm/precompiles/src/io.rs rename to zkvm/lib/src/io.rs index cc1be96ed8..3845981f38 100644 --- a/zkvm/precompiles/src/io.rs +++ b/zkvm/lib/src/io.rs @@ -4,20 +4,25 @@ use crate::{syscall_hint_len, syscall_hint_read}; use serde::de::DeserializeOwned; use serde::Serialize; use std::alloc::Layout; +use std::io::Result; use std::io::Write; -const FD_HINT: u32 = 4; +/// The file descriptor for public values. pub const FD_PUBLIC_VALUES: u32 = 3; -// Runtime hook file descriptors. Make sure these match the FDs in the HookRegistry. -// The default hooks can be found in `core/src/runtime/hooks.rs`. + +/// The file descriptor for hints. +pub const FD_HINT: u32 = 4; + +/// The file descriptor for the `ecreover` hook. pub const FD_ECRECOVER_HOOK: u32 = 5; -pub struct SyscallWriter { +/// A writer that writes to a file descriptor inside the zkVM. +struct SyscallWriter { fd: u32, } -impl std::io::Write for SyscallWriter { - fn write(&mut self, buf: &[u8]) -> std::io::Result { +impl Write for SyscallWriter { + fn write(&mut self, buf: &[u8]) -> Result { let nbytes = buf.len(); let write_buf = buf.as_ptr(); unsafe { @@ -26,19 +31,26 @@ impl std::io::Write for SyscallWriter { Ok(nbytes) } - fn flush(&mut self) -> std::io::Result<()> { + fn flush(&mut self) -> Result<()> { Ok(()) } } +/// Read a buffer from the input stream. +/// +/// ### Examples +/// ```ignore +/// let data: Vec = sp1_zkvm::io::read_vec(); +/// ``` pub fn read_vec() -> Vec { - let len = unsafe { syscall_hint_len() }; // Round up to the nearest multiple of 4 so that the memory allocated is in whole words + let len = unsafe { syscall_hint_len() }; let capacity = (len + 3) / 4 * 4; // Allocate a buffer of the required length that is 4 byte aligned let layout = Layout::from_size_align(capacity, 4).expect("vec is too large"); let ptr = unsafe { std::alloc::alloc(layout) }; + // SAFETY: // 1. `ptr` was allocated using alloc // 2. We assuume that the VM global allocator doesn't dealloc @@ -46,6 +58,7 @@ pub fn read_vec() -> Vec { // 4/5. Length is 0 // 7. Layout::from_size_align already checks this let mut vec = unsafe { Vec::from_raw_parts(ptr, 0, capacity) }; + // Read the vec into uninitialized memory. The syscall assumes the memory is uninitialized, // which should be true because the allocator does not dealloc, so a new alloc should be fresh. unsafe { @@ -55,11 +68,43 @@ pub fn read_vec() -> Vec { vec } +/// Read a deserializable object from the input stream. +/// +/// ### Examples +/// ```ignore +/// use serde::{Deserialize, Serialize}; +/// +/// #[derive(Serialize, Deserialize)] +/// struct MyStruct { +/// a: u32, +/// b: u32, +/// } +/// +/// let data: MyStruct = sp1_zkvm::io::read(); +/// ``` pub fn read() -> T { let vec = read_vec(); bincode::deserialize(&vec).expect("deserialization failed") } +/// Commit a serializable object to the public values stream. +/// +/// ### Examples +/// ```ignore +/// use serde::{Deserialize, Serialize}; +/// +/// #[derive(Serialize, Deserialize)] +/// struct MyStruct { +/// a: u32, +/// b: u32, +/// } +/// +/// let data = MyStruct { +/// a: 1, +/// b: 2, +/// }; +/// sp1_zkvm::io::commit(&data); +/// ``` pub fn commit(value: &T) { let writer = SyscallWriter { fd: FD_PUBLIC_VALUES, @@ -67,6 +112,13 @@ pub fn commit(value: &T) { bincode::serialize_into(writer, value).expect("serialization failed"); } +/// Commit bytes to the public values stream. +/// +/// ### Examples +/// ```ignore +/// let data = vec![1, 2, 3, 4]; +/// sp1_zkvm::io::commit_slice(&data); +/// ``` pub fn commit_slice(buf: &[u8]) { let mut my_writer = SyscallWriter { fd: FD_PUBLIC_VALUES, @@ -74,17 +126,48 @@ pub fn commit_slice(buf: &[u8]) { my_writer.write_all(buf).unwrap(); } +/// Hint a serializable object to the hint stream. +/// +/// ### Examples +/// ```ignore +/// use serde::{Deserialize, Serialize}; +/// +/// #[derive(Serialize, Deserialize)] +/// struct MyStruct { +/// a: u32, +/// b: u32, +/// } +/// +/// let data = MyStruct { +/// a: 1, +/// b: 2, +/// }; +/// sp1_zkvm::io::hint(&data); +/// ``` pub fn hint(value: &T) { let writer = SyscallWriter { fd: FD_HINT }; bincode::serialize_into(writer, value).expect("serialization failed"); } +/// Hint bytes to the hint stream. +/// +/// ### Examples +/// ```ignore +/// let data = vec![1, 2, 3, 4]; +/// sp1_zkvm::io::hint_slice(&data); +/// ``` pub fn hint_slice(buf: &[u8]) { let mut my_reader = SyscallWriter { fd: FD_HINT }; my_reader.write_all(buf).unwrap(); } -/// Write the data `buf` to the file descriptor `fd` using `Write::write_all` . +/// Write the data `buf` to the file descriptor `fd`. +/// +/// ### Examples +/// ```ignore +/// let data = vec![1, 2, 3, 4]; +/// sp1_zkvm::io::write(3, &data); +/// ``` pub fn write(fd: u32, buf: &[u8]) { SyscallWriter { fd }.write_all(buf).unwrap(); } diff --git a/zkvm/lib/src/lib.rs b/zkvm/lib/src/lib.rs new file mode 100644 index 0000000000..6f12a36807 --- /dev/null +++ b/zkvm/lib/src/lib.rs @@ -0,0 +1,93 @@ +//! System calls for the SP1 zkVM. + +#[cfg(feature = "bls12381")] +pub mod bls12381; +#[cfg(feature = "bn254")] +pub mod bn254; +pub mod io; +#[cfg(feature = "secp256k1")] +pub mod secp256k1; +pub mod unconstrained; +pub mod utils; +#[cfg(feature = "verify")] +pub mod verify; + +extern "C" { + /// Halts the program with the given exit code. + pub fn syscall_halt(exit_code: u8) -> !; + + /// Writes the bytes in the given buffer to the given file descriptor. + pub fn syscall_write(fd: u32, write_buf: *const u8, nbytes: usize); + + /// Reads the bytes from the given file descriptor into the given buffer. + pub fn syscall_read(fd: u32, read_buf: *mut u8, nbytes: usize); + + /// Executes the SHA-256 extend operation on the given word array. + pub fn syscall_sha256_extend(w: *mut u32); + + /// Executes the SHA-256 compress operation on the given word array and a given state. + pub fn syscall_sha256_compress(w: *mut u32, state: *mut u32); + + /// Executes an Ed25519 curve addition on the given points. + pub fn syscall_ed_add(p: *mut u32, q: *mut u32); + + /// Executes an Ed25519 curve decompression on the given point. + pub fn syscall_ed_decompress(point: &mut [u8; 64]); + + /// Executes an Sepc256k1 curve addition on the given points. + pub fn syscall_secp256k1_add(p: *mut u32, q: *const u32); + + /// Executes an Secp256k1 curve doubling on the given point. + pub fn syscall_secp256k1_double(p: *mut u32); + + /// Executes an Secp256k1 curve decompression on the given point. + pub fn syscall_secp256k1_decompress(point: &mut [u8; 64], is_odd: bool); + + /// Executes a Bn254 curve addition on the given points. + pub fn syscall_bn254_add(p: *mut u32, q: *const u32); + + /// Executes a Bn254 curve doubling on the given point. + pub fn syscall_bn254_double(p: *mut u32); + + /// Executes a BLS12-381 curve addition on the given points. + pub fn syscall_bls12381_add(p: *mut u32, q: *const u32); + + /// Executes a BLS12-381 curve doubling on the given point. + pub fn syscall_bls12381_double(p: *mut u32); + + /// Executes the Keccak-256 permutation on the given state. + pub fn syscall_keccak_permute(state: *mut u64); + + /// Executes an uint256 multiplication on the given inputs. + pub fn syscall_uint256_mulmod(x: *mut u32, y: *const u32); + + /// Enters unconstrained mode. + pub fn syscall_enter_unconstrained() -> bool; + + /// Exits unconstrained mode. + pub fn syscall_exit_unconstrained(); + + /// Defers the verification of a valid SP1 zkVM proof. + pub fn syscall_verify_sp1_proof(vkey: &[u32; 8], pv_digest: &[u8; 32]); + + /// Returns the length of the next element in the hint stream. + pub fn syscall_hint_len() -> usize; + + /// Reads the next element in the hint stream into the given buffer. + pub fn syscall_hint_read(ptr: *mut u8, len: usize); + + /// Allocates a buffer aligned to the given alignment. + pub fn sys_alloc_aligned(bytes: usize, align: usize) -> *mut u8; + + /// Decompresses a BLS12-381 point. + pub fn syscall_bls12381_decompress(point: &mut [u8; 96], is_odd: bool); + + /// Computes a big integer operation with a modulus. + pub fn sys_bigint( + result: *mut [u32; 8], + op: u32, + x: *const [u32; 8], + y: *const [u32; 8], + modulus: *const [u32; 8], + ); +} diff --git a/zkvm/precompiles/src/secp256k1.rs b/zkvm/lib/src/secp256k1.rs similarity index 100% rename from zkvm/precompiles/src/secp256k1.rs rename to zkvm/lib/src/secp256k1.rs index 46ccf91f0b..973985bca1 100644 --- a/zkvm/precompiles/src/secp256k1.rs +++ b/zkvm/lib/src/secp256k1.rs @@ -1,7 +1,10 @@ #![allow(unused)] +use crate::io::{self, FD_ECRECOVER_HOOK}; +use crate::unconstrained; use crate::utils::{AffinePoint, CurveOperations}; use crate::{syscall_secp256k1_add, syscall_secp256k1_decompress, syscall_secp256k1_double}; + use anyhow::Context; use anyhow::{anyhow, Result}; use core::convert::TryInto; @@ -14,9 +17,6 @@ use k256::elliptic_curve::sec1::ToEncodedPoint; use k256::elliptic_curve::PrimeField; use k256::{PublicKey, Scalar, Secp256k1}; -use crate::io::{self, FD_ECRECOVER_HOOK}; -use crate::unconstrained; - const NUM_WORDS: usize = 16; #[derive(Copy, Clone)] diff --git a/zkvm/precompiles/src/unconstrained.rs b/zkvm/lib/src/unconstrained.rs similarity index 100% rename from zkvm/precompiles/src/unconstrained.rs rename to zkvm/lib/src/unconstrained.rs diff --git a/zkvm/precompiles/src/utils.rs b/zkvm/lib/src/utils.rs similarity index 91% rename from zkvm/precompiles/src/utils.rs rename to zkvm/lib/src/utils.rs index c2cf1a0d7e..34cc3db02e 100644 --- a/zkvm/precompiles/src/utils.rs +++ b/zkvm/lib/src/utils.rs @@ -11,6 +11,11 @@ pub struct AffinePoint, const NUM_WORDS: usize> { _marker: std::marker::PhantomData, } +#[derive(Debug)] +pub enum MulAssignError { + ZeroScalar, +} + impl + Copy, const NUM_WORDS: usize> AffinePoint { const GENERATOR: [u32; NUM_WORDS] = C::GENERATOR; @@ -53,12 +58,17 @@ impl + Copy, const NUM_WORDS: usize> AffinePoint Result<(), MulAssignError> { debug_assert!(scalar.len() == NUM_WORDS / 2); let mut res: Option = None; let mut temp = *self; + let scalar_is_zero = scalar.iter().all(|&words| words == 0); + if scalar_is_zero { + return Err(MulAssignError::ZeroScalar); + } + for &words in scalar.iter() { for i in 0..32 { if (words >> i) & 1 == 1 { @@ -73,6 +83,7 @@ impl + Copy, const NUM_WORDS: usize> AffinePoint Self { diff --git a/zkvm/precompiles/src/verify.rs b/zkvm/lib/src/verify.rs similarity index 100% rename from zkvm/precompiles/src/verify.rs rename to zkvm/lib/src/verify.rs diff --git a/zkvm/precompiles/Cargo.toml b/zkvm/precompiles/Cargo.toml deleted file mode 100644 index 5b1fbd73ff..0000000000 --- a/zkvm/precompiles/Cargo.toml +++ /dev/null @@ -1,21 +0,0 @@ -[package] -name = "sp1-precompiles" -version = "0.1.0" -edition = "2021" - -[dependencies] -amcl = { package = "snowbridge-amcl", version = "1.0.2", default-features = false, features = [ - "bls381", -] } -anyhow = "1.0.83" -bincode = "1.3.3" -cfg-if = "1.0.0" -getrandom = { version = "0.2.14", features = ["custom"] } -hex = "0.4.3" -k256 = { version = "0.13.3", features = ["ecdsa", "std", "bits"] } -rand = "0.8.5" -serde = { version = "1.0.201", features = ["derive"] } -num = { version = "0.4.3" } - -[features] -verify = [] diff --git a/zkvm/precompiles/src/lib.rs b/zkvm/precompiles/src/lib.rs deleted file mode 100644 index 4733de84d6..0000000000 --- a/zkvm/precompiles/src/lib.rs +++ /dev/null @@ -1,50 +0,0 @@ -//! Precompiles for SP1 zkVM. -//! -//! Specifically, this crate contains user-friendly functions that call SP1 syscalls. Syscalls are -//! also declared here for convenience. In order to avoid duplicate symbol errors, the syscall -//! function impls must live in sp1-zkvm, which is only imported into the end user program crate. -//! In contrast, sp1-precompiles can be imported into any crate in the dependency tree. - -pub mod bls12381; -pub mod bn254; -pub mod io; -pub mod secp256k1; -pub mod unconstrained; -pub mod utils; -#[cfg(feature = "verify")] -pub mod verify; - -pub const BIGINT_WIDTH_WORDS: usize = 8; - -extern "C" { - pub fn syscall_halt(exit_code: u8) -> !; - pub fn syscall_write(fd: u32, write_buf: *const u8, nbytes: usize); - pub fn syscall_read(fd: u32, read_buf: *mut u8, nbytes: usize); - pub fn syscall_sha256_extend(w: *mut u32); - pub fn syscall_sha256_compress(w: *mut u32, state: *mut u32); - pub fn syscall_ed_add(p: *mut u32, q: *mut u32); - pub fn syscall_ed_decompress(point: &mut [u8; 64]); - pub fn syscall_secp256k1_add(p: *mut u32, q: *const u32); - pub fn syscall_secp256k1_double(p: *mut u32); - pub fn syscall_secp256k1_decompress(point: &mut [u8; 64], is_odd: bool); - pub fn syscall_bn254_add(p: *mut u32, q: *const u32); - pub fn syscall_bn254_double(p: *mut u32); - pub fn syscall_bls12381_add(p: *mut u32, q: *const u32); - pub fn syscall_bls12381_double(p: *mut u32); - pub fn syscall_keccak_permute(state: *mut u64); - pub fn syscall_uint256_mulmod(x: *mut u32, y: *const u32); - pub fn syscall_enter_unconstrained() -> bool; - pub fn syscall_exit_unconstrained(); - pub fn syscall_verify_sp1_proof(vkey: &[u32; 8], pv_digest: &[u8; 32]); - pub fn syscall_hint_len() -> usize; - pub fn syscall_hint_read(ptr: *mut u8, len: usize); - pub fn sys_alloc_aligned(bytes: usize, align: usize) -> *mut u8; - pub fn syscall_bls12381_decompress(point: &mut [u8; 96], is_odd: bool); - pub fn sys_bigint( - result: *mut [u32; BIGINT_WIDTH_WORDS], - op: u32, - x: *const [u32; BIGINT_WIDTH_WORDS], - y: *const [u32; BIGINT_WIDTH_WORDS], - modulus: *const [u32; BIGINT_WIDTH_WORDS], - ); -}