├── .env.example ├── .github └── workflows │ ├── foundry-test.yml │ └── prove.yml ├── .gitignore ├── .gitmodules ├── .vscode └── settings.json ├── Cargo.lock ├── Cargo.toml ├── LICENSE-MIT ├── README.md ├── contracts ├── .gitignore ├── README.md ├── foundry.toml ├── remappings.txt ├── src │ ├── Fibonacci.sol │ └── fixtures │ │ ├── groth16-fixture.json │ │ └── plonk-fixture.json └── test │ └── Fibonacci.t.sol ├── lib ├── Cargo.toml └── src │ └── lib.rs ├── program ├── Cargo.lock ├── Cargo.toml └── src │ └── main.rs ├── rust-toolchain └── script ├── Cargo.lock ├── Cargo.toml ├── build.rs └── src └── bin ├── evm.rs ├── main.rs └── vkey.rs /.env.example: -------------------------------------------------------------------------------- 1 | # Proof modes are `mock`, `cpu`, `cuda` and `network`. 2 | # `mock` is for generating mock proofs locally. 3 | # `cpu` is for generating proofs locally using the CPU. 4 | # `cuda` is for generating proofs locally using the GPU. 5 | # `network` is for generating proofs using the Succinct Prover Network. 6 | SP1_PROVER=cpu 7 | 8 | # To use the Succinct Prover Network, set the private key of the account you want to use for requesting proofs. 9 | # Set up a new account here: https://docs.succinct.xyz/docs/network/developers/key-setup. 10 | NETWORK_PRIVATE_KEY= -------------------------------------------------------------------------------- /.github/workflows/foundry-test.yml: -------------------------------------------------------------------------------- 1 | name: Foundry Test 2 | 3 | on: 4 | workflow_dispatch: 5 | push: 6 | branches: [ main ] 7 | pull_request: 8 | 9 | env: 10 | FOUNDRY_PROFILE: ci 11 | 12 | jobs: 13 | check: 14 | strategy: 15 | fail-fast: true 16 | 17 | name: Foundry project 18 | runs-on: 19 | - runs-on 20 | - runner=1cpu-linux-x64 21 | - run-id=${{ github.run_id }} 22 | steps: 23 | - uses: actions/checkout@v4 24 | with: 25 | submodules: recursive 26 | 27 | - name: Install Foundry 28 | uses: foundry-rs/foundry-toolchain@v1 29 | with: 30 | version: nightly 31 | 32 | - name: Run Forge build 33 | run: | 34 | cd contracts 35 | forge --version 36 | forge build --sizes 37 | id: build 38 | 39 | - name: Run Forge tests 40 | run: | 41 | cd contracts 42 | forge test -vvv 43 | id: test 44 | -------------------------------------------------------------------------------- /.github/workflows/prove.yml: -------------------------------------------------------------------------------- 1 | name: Build Program 2 | 3 | on: 4 | workflow_dispatch: 5 | push: 6 | branches: [main] 7 | pull_request: 8 | 9 | env: 10 | FOUNDRY_PROFILE: ci 11 | 12 | jobs: 13 | check: 14 | strategy: 15 | fail-fast: true 16 | 17 | name: Build and Execute 18 | runs-on: 19 | - runs-on 20 | - runner=16cpu-linux-x64 21 | - run-id=${{ github.run_id }} 22 | steps: 23 | - uses: actions/checkout@v4 24 | with: 25 | submodules: recursive 26 | 27 | - name: Install rust toolchain 28 | uses: actions-rs/toolchain@v1 29 | with: 30 | profile: minimal 31 | toolchain: 1.85.0 32 | 33 | - name: Install SP1 toolchain 34 | run: | 35 | curl -L https://sp1.succinct.xyz | bash 36 | ~/.sp1/bin/sp1up 37 | ~/.sp1/bin/cargo-prove prove --version 38 | 39 | - name: Build SP1 program 40 | run: | 41 | cd program 42 | ~/.sp1/bin/cargo-prove prove build 43 | 44 | - name: Execute SP1 program 45 | run: | 46 | cargo run --release -- --execute 47 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | # Cargo build 2 | **/target 3 | 4 | # Cargo config 5 | .cargo 6 | 7 | # Profile-guided optimization 8 | /tmp 9 | pgo-data.profdata 10 | 11 | # MacOS nuisances 12 | .DS_Store 13 | 14 | # Proofs 15 | **/proof-with-pis.json 16 | **/proof-with-io.json 17 | 18 | # Env 19 | .env -------------------------------------------------------------------------------- /.gitmodules: -------------------------------------------------------------------------------- 1 | [submodule "contracts/lib/forge-std"] 2 | path = contracts/lib/forge-std 3 | url = https://github.com/foundry-rs/forge-std 4 | tag = v1.8.2 5 | [submodule "contracts/lib/sp1-contracts"] 6 | path = contracts/lib/sp1-contracts 7 | url = https://github.com/succinctlabs/sp1-contracts 8 | tag = v3.0.0 9 | -------------------------------------------------------------------------------- /.vscode/settings.json: -------------------------------------------------------------------------------- 1 | { 2 | "rust-analyzer.linkedProjects": [ 3 | "program/Cargo.toml", 4 | "script/Cargo.toml" 5 | ], 6 | "rust-analyzer.check.overrideCommand": [ 7 | "cargo", 8 | "clippy", 9 | "--workspace", 10 | "--message-format=json", 11 | "--all-features", 12 | "--all-targets", 13 | "--", 14 | "-A", 15 | "incomplete-features" 16 | ], 17 | "rust-analyzer.runnables.extraEnv": { 18 | "RUST_LOG": "debug", 19 | "RUSTFLAGS": "-Ctarget-cpu=native" 20 | }, 21 | "rust-analyzer.runnables.extraArgs": [ 22 | "--release", 23 | "+nightly" 24 | ], 25 | "rust-analyzer.diagnostics.disabled": [ 26 | "unresolved-proc-macro" 27 | ], 28 | "editor.rulers": [ 29 | 100 30 | ], 31 | "editor.inlineSuggest.enabled": true, 32 | "[rust]": { 33 | "editor.defaultFormatter": "rust-lang.rust-analyzer", 34 | "editor.formatOnSave": true, 35 | "editor.hover.enabled": true 36 | }, 37 | } -------------------------------------------------------------------------------- /Cargo.toml: -------------------------------------------------------------------------------- 1 | [workspace] 2 | members = [ 3 | "lib", 4 | "program", 5 | "script", 6 | ] 7 | resolver = "2" 8 | 9 | [workspace.dependencies] 10 | alloy-sol-types = "1.0" -------------------------------------------------------------------------------- /LICENSE-MIT: -------------------------------------------------------------------------------- 1 | The MIT License (MIT) 2 | 3 | Copyright (c) 2024 Succinct Labs 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in 13 | all copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 21 | THE SOFTWARE. -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # SP1 Project Template 2 | 3 | This is a template for creating an end-to-end [SP1](https://github.com/succinctlabs/sp1) project 4 | that can generate a proof of any RISC-V program. 5 | 6 | ## Requirements 7 | 8 | - [Rust](https://rustup.rs/) 9 | - [SP1](https://docs.succinct.xyz/docs/sp1/getting-started/install) 10 | 11 | ## Running the Project 12 | 13 | There are 3 main ways to run this project: execute a program, generate a core proof, and 14 | generate an EVM-compatible proof. 15 | 16 | ### Build the Program 17 | 18 | The program is automatically built through `script/build.rs` when the script is built. 19 | 20 | ### Execute the Program 21 | 22 | To run the program without generating a proof: 23 | 24 | ```sh 25 | cd script 26 | cargo run --release -- --execute 27 | ``` 28 | 29 | This will execute the program and display the output. 30 | 31 | ### Generate an SP1 Core Proof 32 | 33 | To generate an SP1 [core proof](https://docs.succinct.xyz/docs/sp1/generating-proofs/proof-types#core-default) for your program: 34 | 35 | ```sh 36 | cd script 37 | cargo run --release -- --prove 38 | ``` 39 | 40 | ### Generate an EVM-Compatible Proof 41 | 42 | > [!WARNING] 43 | > You will need at least 16GB RAM to generate a Groth16 or PLONK proof. View the [SP1 docs](https://docs.succinct.xyz/docs/sp1/getting-started/hardware-requirements#local-proving) for more information. 44 | 45 | Generating a proof that is cheap to verify on the EVM (e.g. Groth16 or PLONK) is more intensive than generating a core proof. 46 | 47 | To generate a Groth16 proof: 48 | 49 | ```sh 50 | cd script 51 | cargo run --release --bin evm -- --system groth16 52 | ``` 53 | 54 | To generate a PLONK proof: 55 | 56 | ```sh 57 | cargo run --release --bin evm -- --system plonk 58 | ``` 59 | 60 | These commands will also generate fixtures that can be used to test the verification of SP1 proofs 61 | inside Solidity. 62 | 63 | ### Retrieve the Verification Key 64 | 65 | To retrieve your `programVKey` for your on-chain contract, run the following command in `script`: 66 | 67 | ```sh 68 | cargo run --release --bin vkey 69 | ``` 70 | 71 | ## Using the Prover Network 72 | 73 | We highly recommend using the [Succinct Prover Network](https://docs.succinct.xyz/docs/network/introduction) for any non-trivial programs or benchmarking purposes. For more information, see the [key setup guide](https://docs.succinct.xyz/docs/network/developers/key-setup) to get started. 74 | 75 | To get started, copy the example environment file: 76 | 77 | ```sh 78 | cp .env.example .env 79 | ``` 80 | 81 | Then, set the `SP1_PROVER` environment variable to `network` and set the `NETWORK_PRIVATE_KEY` 82 | environment variable to your whitelisted private key. 83 | 84 | For example, to generate an EVM-compatible proof using the prover network, run the following 85 | command: 86 | 87 | ```sh 88 | SP1_PROVER=network NETWORK_PRIVATE_KEY=... cargo run --release --bin evm 89 | ``` 90 | -------------------------------------------------------------------------------- /contracts/.gitignore: -------------------------------------------------------------------------------- 1 | # Compiler files 2 | cache/ 3 | out/ 4 | 5 | # Ignores development broadcast logs 6 | /broadcast 7 | /broadcast/*/11155111/ 8 | /broadcast/*/31337/ 9 | /broadcast/**/dry-run/ 10 | 11 | # Docs 12 | docs/ 13 | 14 | # Dotenv file 15 | .env 16 | -------------------------------------------------------------------------------- /contracts/README.md: -------------------------------------------------------------------------------- 1 | # SP1 Project Template Contracts 2 | 3 | This is a template for writing a contract that uses verification of [SP1](https://github.com/succinctlabs/sp1) PlonK proofs onchain using the [SP1VerifierGateway](https://github.com/succinctlabs/sp1-contracts/blob/main/contracts/src/SP1VerifierGateway.sol). 4 | 5 | ## Requirements 6 | 7 | - [Foundry](https://book.getfoundry.sh/getting-started/installation) 8 | 9 | ## Test 10 | 11 | ```sh 12 | forge test -v 13 | ``` 14 | 15 | ## Deployment 16 | 17 | #### Step 1: Set the `VERIFIER` environment variable 18 | 19 | Find the address of the `verifier` to use from the [deployments](https://github.com/succinctlabs/sp1-contracts/tree/main/contracts/deployments) list for the chain you are deploying to. Set it to the `VERIFIER` environment variable, for example: 20 | 21 | ```sh 22 | VERIFIER=0x3B6041173B80E77f038f3F2C0f9744f04837185e 23 | ``` 24 | 25 | Note: you can use either the [SP1VerifierGateway](https://github.com/succinctlabs/sp1-contracts/blob/main/contracts/src/SP1VerifierGateway.sol) or a specific version, but it is highly recommended to use the gateway as this will allow you to use different versions of SP1. 26 | 27 | #### Step 2: Set the `PROGRAM_VKEY` environment variable 28 | 29 | Find your program verification key by going into the `../script` directory and running `RUST_LOG=info cargo run --package fibonacci-script --bin vkey --release`, which will print an output like: 30 | 31 | > Program Verification Key: 0x00620892344c310c32a74bf0807a5c043964264e4f37c96a10ad12b5c9214e0e 32 | 33 | Then set the `PROGRAM_VKEY` environment variable to the output of that command, for example: 34 | 35 | ```sh 36 | PROGRAM_VKEY=0x00620892344c310c32a74bf0807a5c043964264e4f37c96a10ad12b5c9214e0e 37 | ``` 38 | 39 | #### Step 3: Deploy the contract 40 | 41 | Fill out the rest of the details needed for deployment: 42 | 43 | ```sh 44 | RPC_URL=... 45 | ``` 46 | 47 | ```sh 48 | PRIVATE_KEY=... 49 | ``` 50 | 51 | Then deploy the contract to the chain: 52 | 53 | ```sh 54 | forge create src/Fibonacci.sol:Fibonacci --rpc-url $RPC_URL --private-key $PRIVATE_KEY --constructor-args $VERIFIER $PROGRAM_VKEY 55 | ``` 56 | 57 | It can also be a good idea to verify the contract when you deploy, in which case you would also need to set `ETHERSCAN_API_KEY`: 58 | 59 | ```sh 60 | forge create src/Fibonacci.sol:Fibonacci --rpc-url $RPC_URL --private-key $PRIVATE_KEY --constructor-args $VERIFIER $PROGRAM_VKEY --verify --verifier etherscan --etherscan-api-key $ETHERSCAN_API_KEY 61 | ``` 62 | -------------------------------------------------------------------------------- /contracts/foundry.toml: -------------------------------------------------------------------------------- 1 | [profile.default] 2 | src = "src" 3 | out = "out" 4 | libs = ["lib"] 5 | fs_permissions = [{ access = "read-write", path = "./" }] 6 | 7 | # See more config options https://github.com/foundry-rs/foundry/blob/master/crates/config/README.md#all-options 8 | -------------------------------------------------------------------------------- /contracts/remappings.txt: -------------------------------------------------------------------------------- 1 | @sp1-contracts/=./lib/sp1-contracts/contracts/src/ -------------------------------------------------------------------------------- /contracts/src/Fibonacci.sol: -------------------------------------------------------------------------------- 1 | // SPDX-License-Identifier: MIT 2 | pragma solidity ^0.8.20; 3 | 4 | import {ISP1Verifier} from "@sp1-contracts/ISP1Verifier.sol"; 5 | 6 | struct PublicValuesStruct { 7 | uint32 n; 8 | uint32 a; 9 | uint32 b; 10 | } 11 | 12 | /// @title Fibonacci. 13 | /// @author Succinct Labs 14 | /// @notice This contract implements a simple example of verifying the proof of a computing a 15 | /// fibonacci number. 16 | contract Fibonacci { 17 | /// @notice The address of the SP1 verifier contract. 18 | /// @dev This can either be a specific SP1Verifier for a specific version, or the 19 | /// SP1VerifierGateway which can be used to verify proofs for any version of SP1. 20 | /// For the list of supported verifiers on each chain, see: 21 | /// https://github.com/succinctlabs/sp1-contracts/tree/main/contracts/deployments 22 | address public verifier; 23 | 24 | /// @notice The verification key for the fibonacci program. 25 | bytes32 public fibonacciProgramVKey; 26 | 27 | constructor(address _verifier, bytes32 _fibonacciProgramVKey) { 28 | verifier = _verifier; 29 | fibonacciProgramVKey = _fibonacciProgramVKey; 30 | } 31 | 32 | /// @notice The entrypoint for verifying the proof of a fibonacci number. 33 | /// @param _proofBytes The encoded proof. 34 | /// @param _publicValues The encoded public values. 35 | function verifyFibonacciProof(bytes calldata _publicValues, bytes calldata _proofBytes) 36 | public 37 | view 38 | returns (uint32, uint32, uint32) 39 | { 40 | ISP1Verifier(verifier).verifyProof(fibonacciProgramVKey, _publicValues, _proofBytes); 41 | PublicValuesStruct memory publicValues = abi.decode(_publicValues, (PublicValuesStruct)); 42 | return (publicValues.n, publicValues.a, publicValues.b); 43 | } 44 | } 45 | -------------------------------------------------------------------------------- /contracts/src/fixtures/groth16-fixture.json: -------------------------------------------------------------------------------- 1 | { 2 | "a": 6765, 3 | "b": 10946, 4 | "n": 20, 5 | "vkey": "0x00b51cef3572d1a49ae7f4a332221cab31cdb72b131dbf28fb6ab26e15458fe2", 6 | "publicValues": "0x00000000000000000000000000000000000000000000000000000000000000140000000000000000000000000000000000000000000000000000000000001a6d0000000000000000000000000000000000000000000000000000000000002ac2", 7 | "proof": "0x11b6a09d07727e8889e440a3a4fe6b3cc7e438d232daa177c762d3267ada247e165b06ca1beaf42fbaaa7676caf3dd978af6c1b7b64968f67f41e3d356790a09337566d81122aa6904fd105ff2a499c1f3264a3f55e740cda6521be1877225f4073f7a4a22fe10987f12d67a145738de4e301bb8e37347556bead5bb003ce32653ffae5a281be092e26c9d16eb569b3592eb766b0197fe05d359952a05958b2596239f061333369ab1d6576f80e965d0e3d8f1d3a74722e794e72199c3dee91bff8f3a5e087ac3fac78f5372befa133b94764b43c4c88ee4f3fc0495e52c74ad5a6d2c18008e6740d0aad32976971c95db159fb37d4f8428d7c5abe658a58d516acd664c" 8 | } -------------------------------------------------------------------------------- /contracts/src/fixtures/plonk-fixture.json: -------------------------------------------------------------------------------- 1 | { 2 | "a": 6765, 3 | "b": 10946, 4 | "n": 20, 5 | "vkey": "0x005aa1cbc05f992604b4f375159054d79b76501cf214b1fec6724ea14eceaf78", 6 | "publicValues": "0x00000000000000000000000000000000000000000000000000000000000000140000000000000000000000000000000000000000000000000000000000001a6d0000000000000000000000000000000000000000000000000000000000002ac2", 7 | "proof": "0x1b34fe110b653a5bb2e727aacca6d4c9de41249fbd7586b9aa02af98399a3b3fd1666cec0c8473bae000e399aecaab29ecd01dcf66e08e638a7a7bae517ef9ed22be23df12c942a19b734fba23b60c1bbd9abca4f98c56dc118a0fc872ae921b54438e25185909e44fd21ab07cebba1de255741b72e8bad0620f05aebad4f765b1cbba112b4379c851beaac58afb53b98ff31dc9292c0163fdac2068608f197ff0be1c050857edec30d56a0373109031afc35e54b0b6383ee7944c8e3f1d08040fc0f5721fb16d8af362b7aff5855d2f6c4a843003a7b8020728114de8e4ef6dedbd532b1f7e65dbf48e8cc592cf8163f5de468e24e904d67b7ae3f58f7edc14fc38a60317b175cd23772ca939ffd13e9d7390cb4c811384d746fa874d4a84117c25c3ab2e124b51764997fefd97605bdfcf60f634bd0d3f47efb8d68ac077b8cac612bb15e2d52dc1662680acd46432e3415dbc936673a0060164f80d2a55d6e6a0eec709f763b91500f52ae86229b6f155aa7aa4a6350373b459027d959fbc8eeabc2d04a1e18f91b62d4094a6279def15868b9f01ed81be16b65e607f7eeb938c1018276c666be3300a1de112fbf3e3ebdf49c9daffab4711a11fecca183830639bbb1bfc81381e005f2c1d7702b2cc579719a32a2e8b8144cded8f19edb24ad709a01a49867454a0e9fe6253dbb04b4fd9484b2a2fa10fa974ff327b93ccf6f71a61061c2fd03794cb3badac3326b32467122480cf2810135832b89f8891248ff1c8035256d4e18515e1986d0995e6d945b02e88cace743fe19b86e7ac366c8448fb1dee3630fb6f57be5abded070ed4f04af597886e4d8f5188bcfb1d9fbca9f45b2223d5821917f386acf5ce74098e52f971257b5ad06039311e85f2bf4d3f6a7f300548634ba8c77666ad320f998cf42e6efa3fb84571959d055b394a7b9ede590ce87fda92632f6ece014fb9bd9b3ea3a919fc7139bc59003fa9f33a4342f46e2ca3d09e3d10af3d06906af1fea935bb06143d7525daa6a0cd5352d098d9af7c196d44286c029bf773f5dd8bcee23b60c44c2f7632224b880d4b856a9aaa0e832e2be26a5eb31a4f3697fdac727722eb76da934054937d29f44a01959fd571332a58e27cc753247c57817b338e30397fecff0fe609f6dae12cd54aae72a55ce60d46b7bb14ceba9b0e69f35be38547f7a3f71dbaea85459449daa1353f338fcf" 8 | } -------------------------------------------------------------------------------- /contracts/test/Fibonacci.t.sol: -------------------------------------------------------------------------------- 1 | // SPDX-License-Identifier: MIT 2 | pragma solidity ^0.8.20; 3 | 4 | import {Test, console} from "forge-std/Test.sol"; 5 | import {stdJson} from "forge-std/StdJson.sol"; 6 | import {Fibonacci} from "../src/Fibonacci.sol"; 7 | import {SP1VerifierGateway} from "@sp1-contracts/SP1VerifierGateway.sol"; 8 | 9 | struct SP1ProofFixtureJson { 10 | uint32 a; 11 | uint32 b; 12 | uint32 n; 13 | bytes proof; 14 | bytes publicValues; 15 | bytes32 vkey; 16 | } 17 | 18 | contract FibonacciGroth16Test is Test { 19 | using stdJson for string; 20 | 21 | address verifier; 22 | Fibonacci public fibonacci; 23 | 24 | function loadFixture() public view returns (SP1ProofFixtureJson memory) { 25 | string memory root = vm.projectRoot(); 26 | string memory path = string.concat(root, "/src/fixtures/groth16-fixture.json"); 27 | string memory json = vm.readFile(path); 28 | bytes memory jsonBytes = json.parseRaw("."); 29 | return abi.decode(jsonBytes, (SP1ProofFixtureJson)); 30 | } 31 | 32 | function setUp() public { 33 | SP1ProofFixtureJson memory fixture = loadFixture(); 34 | 35 | verifier = address(new SP1VerifierGateway(address(1))); 36 | fibonacci = new Fibonacci(verifier, fixture.vkey); 37 | } 38 | 39 | function test_ValidFibonacciProof() public { 40 | SP1ProofFixtureJson memory fixture = loadFixture(); 41 | 42 | vm.mockCall(verifier, abi.encodeWithSelector(SP1VerifierGateway.verifyProof.selector), abi.encode(true)); 43 | 44 | (uint32 n, uint32 a, uint32 b) = fibonacci.verifyFibonacciProof(fixture.publicValues, fixture.proof); 45 | assert(n == fixture.n); 46 | assert(a == fixture.a); 47 | assert(b == fixture.b); 48 | } 49 | 50 | function testRevert_InvalidFibonacciProof() public { 51 | vm.expectRevert(); 52 | 53 | SP1ProofFixtureJson memory fixture = loadFixture(); 54 | 55 | // Create a fake proof. 56 | bytes memory fakeProof = new bytes(fixture.proof.length); 57 | 58 | fibonacci.verifyFibonacciProof(fixture.publicValues, fakeProof); 59 | } 60 | } 61 | 62 | 63 | contract FibonacciPlonkTest is Test { 64 | using stdJson for string; 65 | 66 | address verifier; 67 | Fibonacci public fibonacci; 68 | 69 | function loadFixture() public view returns (SP1ProofFixtureJson memory) { 70 | string memory root = vm.projectRoot(); 71 | string memory path = string.concat(root, "/src/fixtures/plonk-fixture.json"); 72 | string memory json = vm.readFile(path); 73 | bytes memory jsonBytes = json.parseRaw("."); 74 | return abi.decode(jsonBytes, (SP1ProofFixtureJson)); 75 | } 76 | 77 | function setUp() public { 78 | SP1ProofFixtureJson memory fixture = loadFixture(); 79 | 80 | verifier = address(new SP1VerifierGateway(address(1))); 81 | fibonacci = new Fibonacci(verifier, fixture.vkey); 82 | } 83 | 84 | function test_ValidFibonacciProof() public { 85 | SP1ProofFixtureJson memory fixture = loadFixture(); 86 | 87 | vm.mockCall(verifier, abi.encodeWithSelector(SP1VerifierGateway.verifyProof.selector), abi.encode(true)); 88 | 89 | (uint32 n, uint32 a, uint32 b) = fibonacci.verifyFibonacciProof(fixture.publicValues, fixture.proof); 90 | assert(n == fixture.n); 91 | assert(a == fixture.a); 92 | assert(b == fixture.b); 93 | } 94 | 95 | function testRevert_InvalidFibonacciProof() public { 96 | vm.expectRevert(); 97 | 98 | SP1ProofFixtureJson memory fixture = loadFixture(); 99 | 100 | // Create a fake proof. 101 | bytes memory fakeProof = new bytes(fixture.proof.length); 102 | 103 | fibonacci.verifyFibonacciProof(fixture.publicValues, fakeProof); 104 | } 105 | } 106 | -------------------------------------------------------------------------------- /lib/Cargo.toml: -------------------------------------------------------------------------------- 1 | [package] 2 | name = "fibonacci-lib" 3 | version = "0.1.0" 4 | edition = "2021" 5 | 6 | [dependencies] 7 | alloy-sol-types = { workspace = true } 8 | -------------------------------------------------------------------------------- /lib/src/lib.rs: -------------------------------------------------------------------------------- 1 | use alloy_sol_types::sol; 2 | 3 | sol! { 4 | /// The public values encoded as a struct that can be easily deserialized inside Solidity. 5 | struct PublicValuesStruct { 6 | uint32 n; 7 | uint32 a; 8 | uint32 b; 9 | } 10 | } 11 | 12 | /// Compute the n'th fibonacci number (wrapping around on overflows), using normal Rust code. 13 | pub fn fibonacci(n: u32) -> (u32, u32) { 14 | let mut a = 0u32; 15 | let mut b = 1u32; 16 | for _ in 0..n { 17 | let c = a.wrapping_add(b); 18 | a = b; 19 | b = c; 20 | } 21 | (a, b) 22 | } 23 | -------------------------------------------------------------------------------- /program/Cargo.lock: -------------------------------------------------------------------------------- 1 | # This file is automatically @generated by Cargo. 2 | # It is not intended for manual editing. 3 | version = 3 4 | 5 | [[package]] 6 | name = "alloy-primitives" 7 | version = "0.7.7" 8 | source = "registry+https://github.com/rust-lang/crates.io-index" 9 | checksum = "ccb3ead547f4532bc8af961649942f0b9c16ee9226e26caa3f38420651cc0bf4" 10 | dependencies = [ 11 | "alloy-rlp", 12 | "bytes", 13 | "cfg-if", 14 | "const-hex", 15 | "derive_more", 16 | "hex-literal", 17 | "itoa", 18 | "k256", 19 | "keccak-asm", 20 | "proptest", 21 | "rand", 22 | "ruint", 23 | "serde", 24 | "tiny-keccak", 25 | ] 26 | 27 | [[package]] 28 | name = "alloy-rlp" 29 | version = "0.3.7" 30 | source = "registry+https://github.com/rust-lang/crates.io-index" 31 | checksum = "a43b18702501396fa9bcdeecd533bc85fac75150d308fc0f6800a01e6234a003" 32 | dependencies = [ 33 | "arrayvec", 34 | "bytes", 35 | ] 36 | 37 | [[package]] 38 | name = "alloy-sol-macro" 39 | version = "0.7.7" 40 | source = "registry+https://github.com/rust-lang/crates.io-index" 41 | checksum = "2b40397ddcdcc266f59f959770f601ce1280e699a91fc1862f29cef91707cd09" 42 | dependencies = [ 43 | "alloy-sol-macro-expander", 44 | "alloy-sol-macro-input", 45 | "proc-macro-error", 46 | "proc-macro2", 47 | "quote", 48 | "syn 2.0.72", 49 | ] 50 | 51 | [[package]] 52 | name = "alloy-sol-macro-expander" 53 | version = "0.7.7" 54 | source = "registry+https://github.com/rust-lang/crates.io-index" 55 | checksum = "867a5469d61480fea08c7333ffeca52d5b621f5ca2e44f271b117ec1fc9a0525" 56 | dependencies = [ 57 | "alloy-sol-macro-input", 58 | "const-hex", 59 | "heck", 60 | "indexmap", 61 | "proc-macro-error", 62 | "proc-macro2", 63 | "quote", 64 | "syn 2.0.72", 65 | "syn-solidity", 66 | "tiny-keccak", 67 | ] 68 | 69 | [[package]] 70 | name = "alloy-sol-macro-input" 71 | version = "0.7.7" 72 | source = "registry+https://github.com/rust-lang/crates.io-index" 73 | checksum = "2e482dc33a32b6fadbc0f599adea520bd3aaa585c141a80b404d0a3e3fa72528" 74 | dependencies = [ 75 | "const-hex", 76 | "dunce", 77 | "heck", 78 | "proc-macro2", 79 | "quote", 80 | "syn 2.0.72", 81 | "syn-solidity", 82 | ] 83 | 84 | [[package]] 85 | name = "alloy-sol-types" 86 | version = "0.7.7" 87 | source = "registry+https://github.com/rust-lang/crates.io-index" 88 | checksum = "a91ca40fa20793ae9c3841b83e74569d1cc9af29a2f5237314fd3452d51e38c7" 89 | dependencies = [ 90 | "alloy-primitives", 91 | "alloy-sol-macro", 92 | "const-hex", 93 | "serde", 94 | ] 95 | 96 | [[package]] 97 | name = "anyhow" 98 | version = "1.0.86" 99 | source = "registry+https://github.com/rust-lang/crates.io-index" 100 | checksum = "b3d1d046238990b9cf5bcde22a3fb3584ee5cf65fb2765f454ed428c7a0063da" 101 | 102 | [[package]] 103 | name = "ark-ff" 104 | version = "0.3.0" 105 | source = "registry+https://github.com/rust-lang/crates.io-index" 106 | checksum = "6b3235cc41ee7a12aaaf2c575a2ad7b46713a8a50bda2fc3b003a04845c05dd6" 107 | dependencies = [ 108 | "ark-ff-asm 0.3.0", 109 | "ark-ff-macros 0.3.0", 110 | "ark-serialize 0.3.0", 111 | "ark-std 0.3.0", 112 | "derivative", 113 | "num-bigint", 114 | "num-traits", 115 | "paste", 116 | "rustc_version 0.3.3", 117 | "zeroize", 118 | ] 119 | 120 | [[package]] 121 | name = "ark-ff" 122 | version = "0.4.2" 123 | source = "registry+https://github.com/rust-lang/crates.io-index" 124 | checksum = "ec847af850f44ad29048935519032c33da8aa03340876d351dfab5660d2966ba" 125 | dependencies = [ 126 | "ark-ff-asm 0.4.2", 127 | "ark-ff-macros 0.4.2", 128 | "ark-serialize 0.4.2", 129 | "ark-std 0.4.0", 130 | "derivative", 131 | "digest 0.10.7", 132 | "itertools", 133 | "num-bigint", 134 | "num-traits", 135 | "paste", 136 | "rustc_version 0.4.0", 137 | "zeroize", 138 | ] 139 | 140 | [[package]] 141 | name = "ark-ff-asm" 142 | version = "0.3.0" 143 | source = "registry+https://github.com/rust-lang/crates.io-index" 144 | checksum = "db02d390bf6643fb404d3d22d31aee1c4bc4459600aef9113833d17e786c6e44" 145 | dependencies = [ 146 | "quote", 147 | "syn 1.0.109", 148 | ] 149 | 150 | [[package]] 151 | name = "ark-ff-asm" 152 | version = "0.4.2" 153 | source = "registry+https://github.com/rust-lang/crates.io-index" 154 | checksum = "3ed4aa4fe255d0bc6d79373f7e31d2ea147bcf486cba1be5ba7ea85abdb92348" 155 | dependencies = [ 156 | "quote", 157 | "syn 1.0.109", 158 | ] 159 | 160 | [[package]] 161 | name = "ark-ff-macros" 162 | version = "0.3.0" 163 | source = "registry+https://github.com/rust-lang/crates.io-index" 164 | checksum = "db2fd794a08ccb318058009eefdf15bcaaaaf6f8161eb3345f907222bac38b20" 165 | dependencies = [ 166 | "num-bigint", 167 | "num-traits", 168 | "quote", 169 | "syn 1.0.109", 170 | ] 171 | 172 | [[package]] 173 | name = "ark-ff-macros" 174 | version = "0.4.2" 175 | source = "registry+https://github.com/rust-lang/crates.io-index" 176 | checksum = "7abe79b0e4288889c4574159ab790824d0033b9fdcb2a112a3182fac2e514565" 177 | dependencies = [ 178 | "num-bigint", 179 | "num-traits", 180 | "proc-macro2", 181 | "quote", 182 | "syn 1.0.109", 183 | ] 184 | 185 | [[package]] 186 | name = "ark-serialize" 187 | version = "0.3.0" 188 | source = "registry+https://github.com/rust-lang/crates.io-index" 189 | checksum = "1d6c2b318ee6e10f8c2853e73a83adc0ccb88995aa978d8a3408d492ab2ee671" 190 | dependencies = [ 191 | "ark-std 0.3.0", 192 | "digest 0.9.0", 193 | ] 194 | 195 | [[package]] 196 | name = "ark-serialize" 197 | version = "0.4.2" 198 | source = "registry+https://github.com/rust-lang/crates.io-index" 199 | checksum = "adb7b85a02b83d2f22f89bd5cac66c9c89474240cb6207cb1efc16d098e822a5" 200 | dependencies = [ 201 | "ark-std 0.4.0", 202 | "digest 0.10.7", 203 | "num-bigint", 204 | ] 205 | 206 | [[package]] 207 | name = "ark-std" 208 | version = "0.3.0" 209 | source = "registry+https://github.com/rust-lang/crates.io-index" 210 | checksum = "1df2c09229cbc5a028b1d70e00fdb2acee28b1055dfb5ca73eea49c5a25c4e7c" 211 | dependencies = [ 212 | "num-traits", 213 | "rand", 214 | ] 215 | 216 | [[package]] 217 | name = "ark-std" 218 | version = "0.4.0" 219 | source = "registry+https://github.com/rust-lang/crates.io-index" 220 | checksum = "94893f1e0c6eeab764ade8dc4c0db24caf4fe7cbbaafc0eba0a9030f447b5185" 221 | dependencies = [ 222 | "num-traits", 223 | "rand", 224 | ] 225 | 226 | [[package]] 227 | name = "arrayvec" 228 | version = "0.7.4" 229 | source = "registry+https://github.com/rust-lang/crates.io-index" 230 | checksum = "96d30a06541fbafbc7f82ed10c06164cfbd2c401138f6addd8404629c4b16711" 231 | 232 | [[package]] 233 | name = "auto_impl" 234 | version = "1.2.0" 235 | source = "registry+https://github.com/rust-lang/crates.io-index" 236 | checksum = "3c87f3f15e7794432337fc718554eaa4dc8f04c9677a950ffe366f20a162ae42" 237 | dependencies = [ 238 | "proc-macro2", 239 | "quote", 240 | "syn 2.0.72", 241 | ] 242 | 243 | [[package]] 244 | name = "autocfg" 245 | version = "1.3.0" 246 | source = "registry+https://github.com/rust-lang/crates.io-index" 247 | checksum = "0c4b4d0bd25bd0b74681c0ad21497610ce1b7c91b1022cd21c80c6fbdd9476b0" 248 | 249 | [[package]] 250 | name = "base16ct" 251 | version = "0.2.0" 252 | source = "registry+https://github.com/rust-lang/crates.io-index" 253 | checksum = "4c7f02d4ea65f2c1853089ffd8d2787bdbc63de2f0d29dedbcf8ccdfa0ccd4cf" 254 | 255 | [[package]] 256 | name = "base64ct" 257 | version = "1.6.0" 258 | source = "registry+https://github.com/rust-lang/crates.io-index" 259 | checksum = "8c3c1a368f70d6cf7302d78f8f7093da241fb8e8807c05cc9e51a125895a6d5b" 260 | 261 | [[package]] 262 | name = "bincode" 263 | version = "1.3.3" 264 | source = "registry+https://github.com/rust-lang/crates.io-index" 265 | checksum = "b1f45e9417d87227c7a56d22e471c6206462cba514c7590c09aff4cf6d1ddcad" 266 | dependencies = [ 267 | "serde", 268 | ] 269 | 270 | [[package]] 271 | name = "bit-set" 272 | version = "0.5.3" 273 | source = "registry+https://github.com/rust-lang/crates.io-index" 274 | checksum = "0700ddab506f33b20a03b13996eccd309a48e5ff77d0d95926aa0210fb4e95f1" 275 | dependencies = [ 276 | "bit-vec", 277 | ] 278 | 279 | [[package]] 280 | name = "bit-vec" 281 | version = "0.6.3" 282 | source = "registry+https://github.com/rust-lang/crates.io-index" 283 | checksum = "349f9b6a179ed607305526ca489b34ad0a41aed5f7980fa90eb03160b69598fb" 284 | 285 | [[package]] 286 | name = "bitflags" 287 | version = "2.6.0" 288 | source = "registry+https://github.com/rust-lang/crates.io-index" 289 | checksum = "b048fb63fd8b5923fc5aa7b340d8e156aec7ec02f0c78fa8a6ddc2613f6f71de" 290 | 291 | [[package]] 292 | name = "bitvec" 293 | version = "1.0.1" 294 | source = "registry+https://github.com/rust-lang/crates.io-index" 295 | checksum = "1bc2832c24239b0141d5674bb9174f9d68a8b5b3f2753311927c172ca46f7e9c" 296 | dependencies = [ 297 | "funty", 298 | "radium", 299 | "tap", 300 | "wyz", 301 | ] 302 | 303 | [[package]] 304 | name = "block-buffer" 305 | version = "0.10.4" 306 | source = "registry+https://github.com/rust-lang/crates.io-index" 307 | checksum = "3078c7629b62d3f0439517fa394996acacc5cbc91c5a20d8c658e77abd503a71" 308 | dependencies = [ 309 | "generic-array", 310 | ] 311 | 312 | [[package]] 313 | name = "byte-slice-cast" 314 | version = "1.2.2" 315 | source = "registry+https://github.com/rust-lang/crates.io-index" 316 | checksum = "c3ac9f8b63eca6fd385229b3675f6cc0dc5c8a5c8a54a59d4f52ffd670d87b0c" 317 | 318 | [[package]] 319 | name = "byteorder" 320 | version = "1.5.0" 321 | source = "registry+https://github.com/rust-lang/crates.io-index" 322 | checksum = "1fd0f2584146f6f2ef48085050886acf353beff7305ebd1ae69500e27c67f64b" 323 | 324 | [[package]] 325 | name = "bytes" 326 | version = "1.6.1" 327 | source = "registry+https://github.com/rust-lang/crates.io-index" 328 | checksum = "a12916984aab3fa6e39d655a33e09c0071eb36d6ab3aea5c2d78551f1df6d952" 329 | 330 | [[package]] 331 | name = "cc" 332 | version = "1.1.6" 333 | source = "registry+https://github.com/rust-lang/crates.io-index" 334 | checksum = "2aba8f4e9906c7ce3c73463f62a7f0c65183ada1a2d47e397cc8810827f9694f" 335 | 336 | [[package]] 337 | name = "cfg-if" 338 | version = "1.0.0" 339 | source = "registry+https://github.com/rust-lang/crates.io-index" 340 | checksum = "baf1de4339761588bc0619e3cbc0120ee582ebb74b53b4efbf79117bd2da40fd" 341 | 342 | [[package]] 343 | name = "const-hex" 344 | version = "1.12.0" 345 | source = "registry+https://github.com/rust-lang/crates.io-index" 346 | checksum = "94fb8a24a26d37e1ffd45343323dc9fe6654ceea44c12f2fcb3d7ac29e610bc6" 347 | dependencies = [ 348 | "cfg-if", 349 | "cpufeatures", 350 | "hex", 351 | "proptest", 352 | "serde", 353 | ] 354 | 355 | [[package]] 356 | name = "const-oid" 357 | version = "0.9.6" 358 | source = "registry+https://github.com/rust-lang/crates.io-index" 359 | checksum = "c2459377285ad874054d797f3ccebf984978aa39129f6eafde5cdc8315b612f8" 360 | 361 | [[package]] 362 | name = "convert_case" 363 | version = "0.4.0" 364 | source = "registry+https://github.com/rust-lang/crates.io-index" 365 | checksum = "6245d59a3e82a7fc217c5828a6692dbc6dfb63a0c8c90495621f7b9d79704a0e" 366 | 367 | [[package]] 368 | name = "cpufeatures" 369 | version = "0.2.12" 370 | source = "registry+https://github.com/rust-lang/crates.io-index" 371 | checksum = "53fe5e26ff1b7aef8bca9c6080520cfb8d9333c7568e1829cef191a9723e5504" 372 | dependencies = [ 373 | "libc", 374 | ] 375 | 376 | [[package]] 377 | name = "crunchy" 378 | version = "0.2.2" 379 | source = "registry+https://github.com/rust-lang/crates.io-index" 380 | checksum = "7a81dae078cea95a014a339291cec439d2f232ebe854a9d672b796c6afafa9b7" 381 | 382 | [[package]] 383 | name = "crypto-bigint" 384 | version = "0.5.5" 385 | source = "registry+https://github.com/rust-lang/crates.io-index" 386 | checksum = "0dc92fb57ca44df6db8059111ab3af99a63d5d0f8375d9972e319a379c6bab76" 387 | dependencies = [ 388 | "generic-array", 389 | "rand_core", 390 | "subtle", 391 | "zeroize", 392 | ] 393 | 394 | [[package]] 395 | name = "crypto-common" 396 | version = "0.1.6" 397 | source = "registry+https://github.com/rust-lang/crates.io-index" 398 | checksum = "1bfb12502f3fc46cca1bb51ac28df9d618d813cdc3d2f25b9fe775a34af26bb3" 399 | dependencies = [ 400 | "generic-array", 401 | "typenum", 402 | ] 403 | 404 | [[package]] 405 | name = "der" 406 | version = "0.7.9" 407 | source = "registry+https://github.com/rust-lang/crates.io-index" 408 | checksum = "f55bf8e7b65898637379c1b74eb1551107c8294ed26d855ceb9fd1a09cfc9bc0" 409 | dependencies = [ 410 | "const-oid", 411 | "zeroize", 412 | ] 413 | 414 | [[package]] 415 | name = "derivative" 416 | version = "2.2.0" 417 | source = "registry+https://github.com/rust-lang/crates.io-index" 418 | checksum = "fcc3dd5e9e9c0b295d6e1e4d811fb6f157d5ffd784b8d202fc62eac8035a770b" 419 | dependencies = [ 420 | "proc-macro2", 421 | "quote", 422 | "syn 1.0.109", 423 | ] 424 | 425 | [[package]] 426 | name = "derive_more" 427 | version = "0.99.18" 428 | source = "registry+https://github.com/rust-lang/crates.io-index" 429 | checksum = "5f33878137e4dafd7fa914ad4e259e18a4e8e532b9617a2d0150262bf53abfce" 430 | dependencies = [ 431 | "convert_case", 432 | "proc-macro2", 433 | "quote", 434 | "rustc_version 0.4.0", 435 | "syn 2.0.72", 436 | ] 437 | 438 | [[package]] 439 | name = "digest" 440 | version = "0.9.0" 441 | source = "registry+https://github.com/rust-lang/crates.io-index" 442 | checksum = "d3dd60d1080a57a05ab032377049e0591415d2b31afd7028356dbf3cc6dcb066" 443 | dependencies = [ 444 | "generic-array", 445 | ] 446 | 447 | [[package]] 448 | name = "digest" 449 | version = "0.10.7" 450 | source = "registry+https://github.com/rust-lang/crates.io-index" 451 | checksum = "9ed9a281f7bc9b7576e61468ba615a66a5c8cfdff42420a70aa82701a3b1e292" 452 | dependencies = [ 453 | "block-buffer", 454 | "const-oid", 455 | "crypto-common", 456 | "subtle", 457 | ] 458 | 459 | [[package]] 460 | name = "dunce" 461 | version = "1.0.4" 462 | source = "registry+https://github.com/rust-lang/crates.io-index" 463 | checksum = "56ce8c6da7551ec6c462cbaf3bfbc75131ebbfa1c944aeaa9dab51ca1c5f0c3b" 464 | 465 | [[package]] 466 | name = "ecdsa" 467 | version = "0.16.9" 468 | source = "registry+https://github.com/rust-lang/crates.io-index" 469 | checksum = "ee27f32b5c5292967d2d4a9d7f1e0b0aed2c15daded5a60300e4abb9d8020bca" 470 | dependencies = [ 471 | "der", 472 | "digest 0.10.7", 473 | "elliptic-curve", 474 | "rfc6979", 475 | "signature", 476 | "spki", 477 | ] 478 | 479 | [[package]] 480 | name = "either" 481 | version = "1.13.0" 482 | source = "registry+https://github.com/rust-lang/crates.io-index" 483 | checksum = "60b1af1c220855b6ceac025d3f6ecdd2b7c4894bfe9cd9bda4fbb4bc7c0d4cf0" 484 | 485 | [[package]] 486 | name = "elliptic-curve" 487 | version = "0.13.8" 488 | source = "registry+https://github.com/rust-lang/crates.io-index" 489 | checksum = "b5e6043086bf7973472e0c7dff2142ea0b680d30e18d9cc40f267efbf222bd47" 490 | dependencies = [ 491 | "base16ct", 492 | "crypto-bigint", 493 | "digest 0.10.7", 494 | "ff", 495 | "generic-array", 496 | "group", 497 | "pkcs8", 498 | "rand_core", 499 | "sec1", 500 | "subtle", 501 | "zeroize", 502 | ] 503 | 504 | [[package]] 505 | name = "equivalent" 506 | version = "1.0.1" 507 | source = "registry+https://github.com/rust-lang/crates.io-index" 508 | checksum = "5443807d6dff69373d433ab9ef5378ad8df50ca6298caf15de6e52e24aaf54d5" 509 | 510 | [[package]] 511 | name = "errno" 512 | version = "0.3.9" 513 | source = "registry+https://github.com/rust-lang/crates.io-index" 514 | checksum = "534c5cf6194dfab3db3242765c03bbe257cf92f22b38f6bc0c58d59108a820ba" 515 | dependencies = [ 516 | "libc", 517 | "windows-sys", 518 | ] 519 | 520 | [[package]] 521 | name = "fastrand" 522 | version = "2.1.0" 523 | source = "registry+https://github.com/rust-lang/crates.io-index" 524 | checksum = "9fc0510504f03c51ada170672ac806f1f105a88aa97a5281117e1ddc3368e51a" 525 | 526 | [[package]] 527 | name = "fastrlp" 528 | version = "0.3.1" 529 | source = "registry+https://github.com/rust-lang/crates.io-index" 530 | checksum = "139834ddba373bbdd213dffe02c8d110508dcf1726c2be27e8d1f7d7e1856418" 531 | dependencies = [ 532 | "arrayvec", 533 | "auto_impl", 534 | "bytes", 535 | ] 536 | 537 | [[package]] 538 | name = "ff" 539 | version = "0.13.0" 540 | source = "registry+https://github.com/rust-lang/crates.io-index" 541 | checksum = "ded41244b729663b1e574f1b4fb731469f69f79c17667b5d776b16cda0479449" 542 | dependencies = [ 543 | "rand_core", 544 | "subtle", 545 | ] 546 | 547 | [[package]] 548 | name = "fibonacci-program" 549 | version = "0.1.0" 550 | dependencies = [ 551 | "alloy-sol-types", 552 | "sp1-zkvm", 553 | ] 554 | 555 | [[package]] 556 | name = "fixed-hash" 557 | version = "0.8.0" 558 | source = "registry+https://github.com/rust-lang/crates.io-index" 559 | checksum = "835c052cb0c08c1acf6ffd71c022172e18723949c8282f2b9f27efbc51e64534" 560 | dependencies = [ 561 | "byteorder", 562 | "rand", 563 | "rustc-hex", 564 | "static_assertions", 565 | ] 566 | 567 | [[package]] 568 | name = "fnv" 569 | version = "1.0.7" 570 | source = "registry+https://github.com/rust-lang/crates.io-index" 571 | checksum = "3f9eec918d3f24069decb9af1554cad7c880e2da24a9afd88aca000531ab82c1" 572 | 573 | [[package]] 574 | name = "funty" 575 | version = "2.0.0" 576 | source = "registry+https://github.com/rust-lang/crates.io-index" 577 | checksum = "e6d5a32815ae3f33302d95fdcb2ce17862f8c65363dcfd29360480ba1001fc9c" 578 | 579 | [[package]] 580 | name = "generic-array" 581 | version = "0.14.7" 582 | source = "registry+https://github.com/rust-lang/crates.io-index" 583 | checksum = "85649ca51fd72272d7821adaf274ad91c288277713d9c18820d8499a7ff69e9a" 584 | dependencies = [ 585 | "typenum", 586 | "version_check", 587 | "zeroize", 588 | ] 589 | 590 | [[package]] 591 | name = "getrandom" 592 | version = "0.2.15" 593 | source = "registry+https://github.com/rust-lang/crates.io-index" 594 | checksum = "c4567c8db10ae91089c99af84c68c38da3ec2f087c3f82960bcdbf3656b6f4d7" 595 | dependencies = [ 596 | "cfg-if", 597 | "libc", 598 | "wasi", 599 | ] 600 | 601 | [[package]] 602 | name = "group" 603 | version = "0.13.0" 604 | source = "registry+https://github.com/rust-lang/crates.io-index" 605 | checksum = "f0f9ef7462f7c099f518d754361858f86d8a07af53ba9af0fe635bbccb151a63" 606 | dependencies = [ 607 | "ff", 608 | "rand_core", 609 | "subtle", 610 | ] 611 | 612 | [[package]] 613 | name = "hashbrown" 614 | version = "0.14.5" 615 | source = "registry+https://github.com/rust-lang/crates.io-index" 616 | checksum = "e5274423e17b7c9fc20b6e7e208532f9b19825d82dfd615708b70edd83df41f1" 617 | 618 | [[package]] 619 | name = "heck" 620 | version = "0.5.0" 621 | source = "registry+https://github.com/rust-lang/crates.io-index" 622 | checksum = "2304e00983f87ffb38b55b444b5e3b60a884b5d30c0fca7d82fe33449bbe55ea" 623 | 624 | [[package]] 625 | name = "hex" 626 | version = "0.4.3" 627 | source = "registry+https://github.com/rust-lang/crates.io-index" 628 | checksum = "7f24254aa9a54b5c858eaee2f5bccdb46aaf0e486a595ed5fd8f86ba55232a70" 629 | 630 | [[package]] 631 | name = "hex-literal" 632 | version = "0.4.1" 633 | source = "registry+https://github.com/rust-lang/crates.io-index" 634 | checksum = "6fe2267d4ed49bc07b63801559be28c718ea06c4738b7a03c94df7386d2cde46" 635 | 636 | [[package]] 637 | name = "hmac" 638 | version = "0.12.1" 639 | source = "registry+https://github.com/rust-lang/crates.io-index" 640 | checksum = "6c49c37c09c17a53d937dfbb742eb3a961d65a994e6bcdcf37e7399d0cc8ab5e" 641 | dependencies = [ 642 | "digest 0.10.7", 643 | ] 644 | 645 | [[package]] 646 | name = "impl-codec" 647 | version = "0.6.0" 648 | source = "registry+https://github.com/rust-lang/crates.io-index" 649 | checksum = "ba6a270039626615617f3f36d15fc827041df3b78c439da2cadfa47455a77f2f" 650 | dependencies = [ 651 | "parity-scale-codec", 652 | ] 653 | 654 | [[package]] 655 | name = "impl-trait-for-tuples" 656 | version = "0.2.2" 657 | source = "registry+https://github.com/rust-lang/crates.io-index" 658 | checksum = "11d7a9f6330b71fea57921c9b61c47ee6e84f72d394754eff6163ae67e7395eb" 659 | dependencies = [ 660 | "proc-macro2", 661 | "quote", 662 | "syn 1.0.109", 663 | ] 664 | 665 | [[package]] 666 | name = "indexmap" 667 | version = "2.2.6" 668 | source = "registry+https://github.com/rust-lang/crates.io-index" 669 | checksum = "168fb715dda47215e360912c096649d23d58bf392ac62f73919e831745e40f26" 670 | dependencies = [ 671 | "equivalent", 672 | "hashbrown", 673 | ] 674 | 675 | [[package]] 676 | name = "itertools" 677 | version = "0.10.5" 678 | source = "registry+https://github.com/rust-lang/crates.io-index" 679 | checksum = "b0fd2260e829bddf4cb6ea802289de2f86d6a7a690192fbe91b3f46e0f2c8473" 680 | dependencies = [ 681 | "either", 682 | ] 683 | 684 | [[package]] 685 | name = "itoa" 686 | version = "1.0.11" 687 | source = "registry+https://github.com/rust-lang/crates.io-index" 688 | checksum = "49f1f14873335454500d59611f1cf4a4b0f786f9ac11f4312a78e4cf2566695b" 689 | 690 | [[package]] 691 | name = "k256" 692 | version = "0.13.3" 693 | source = "registry+https://github.com/rust-lang/crates.io-index" 694 | checksum = "956ff9b67e26e1a6a866cb758f12c6f8746208489e3e4a4b5580802f2f0a587b" 695 | dependencies = [ 696 | "cfg-if", 697 | "ecdsa", 698 | "elliptic-curve", 699 | "once_cell", 700 | "sha2", 701 | ] 702 | 703 | [[package]] 704 | name = "keccak-asm" 705 | version = "0.1.1" 706 | source = "registry+https://github.com/rust-lang/crates.io-index" 707 | checksum = "47a3633291834c4fbebf8673acbc1b04ec9d151418ff9b8e26dcd79129928758" 708 | dependencies = [ 709 | "digest 0.10.7", 710 | "sha3-asm", 711 | ] 712 | 713 | [[package]] 714 | name = "lazy_static" 715 | version = "1.5.0" 716 | source = "registry+https://github.com/rust-lang/crates.io-index" 717 | checksum = "bbd2bcb4c963f2ddae06a2efc7e9f3591312473c50c6685e1f298068316e66fe" 718 | 719 | [[package]] 720 | name = "libc" 721 | version = "0.2.155" 722 | source = "registry+https://github.com/rust-lang/crates.io-index" 723 | checksum = "97b3888a4aecf77e811145cadf6eef5901f4782c53886191b2f693f24761847c" 724 | 725 | [[package]] 726 | name = "libm" 727 | version = "0.2.8" 728 | source = "registry+https://github.com/rust-lang/crates.io-index" 729 | checksum = "4ec2a862134d2a7d32d7983ddcdd1c4923530833c9f2ea1a44fc5fa473989058" 730 | 731 | [[package]] 732 | name = "linux-raw-sys" 733 | version = "0.4.14" 734 | source = "registry+https://github.com/rust-lang/crates.io-index" 735 | checksum = "78b3ae25bc7c8c38cec158d1f2757ee79e9b3740fbc7ccf0e59e4b08d793fa89" 736 | 737 | [[package]] 738 | name = "memchr" 739 | version = "2.7.4" 740 | source = "registry+https://github.com/rust-lang/crates.io-index" 741 | checksum = "78ca9ab1a0babb1e7d5695e3530886289c18cf2f87ec19a575a0abdce112e3a3" 742 | 743 | [[package]] 744 | name = "num-bigint" 745 | version = "0.4.6" 746 | source = "registry+https://github.com/rust-lang/crates.io-index" 747 | checksum = "a5e44f723f1133c9deac646763579fdb3ac745e418f2a7af9cd0c431da1f20b9" 748 | dependencies = [ 749 | "num-integer", 750 | "num-traits", 751 | ] 752 | 753 | [[package]] 754 | name = "num-integer" 755 | version = "0.1.46" 756 | source = "registry+https://github.com/rust-lang/crates.io-index" 757 | checksum = "7969661fd2958a5cb096e56c8e1ad0444ac2bbcd0061bd28660485a44879858f" 758 | dependencies = [ 759 | "num-traits", 760 | ] 761 | 762 | [[package]] 763 | name = "num-traits" 764 | version = "0.2.19" 765 | source = "registry+https://github.com/rust-lang/crates.io-index" 766 | checksum = "071dfc062690e90b734c0b2273ce72ad0ffa95f0c74596bc250dcfd960262841" 767 | dependencies = [ 768 | "autocfg", 769 | "libm", 770 | ] 771 | 772 | [[package]] 773 | name = "once_cell" 774 | version = "1.19.0" 775 | source = "registry+https://github.com/rust-lang/crates.io-index" 776 | checksum = "3fdb12b2476b595f9358c5161aa467c2438859caa136dec86c26fdd2efe17b92" 777 | 778 | [[package]] 779 | name = "parity-scale-codec" 780 | version = "3.6.12" 781 | source = "registry+https://github.com/rust-lang/crates.io-index" 782 | checksum = "306800abfa29c7f16596b5970a588435e3d5b3149683d00c12b699cc19f895ee" 783 | dependencies = [ 784 | "arrayvec", 785 | "bitvec", 786 | "byte-slice-cast", 787 | "impl-trait-for-tuples", 788 | "parity-scale-codec-derive", 789 | "serde", 790 | ] 791 | 792 | [[package]] 793 | name = "parity-scale-codec-derive" 794 | version = "3.6.12" 795 | source = "registry+https://github.com/rust-lang/crates.io-index" 796 | checksum = "d830939c76d294956402033aee57a6da7b438f2294eb94864c37b0569053a42c" 797 | dependencies = [ 798 | "proc-macro-crate", 799 | "proc-macro2", 800 | "quote", 801 | "syn 1.0.109", 802 | ] 803 | 804 | [[package]] 805 | name = "paste" 806 | version = "1.0.15" 807 | source = "registry+https://github.com/rust-lang/crates.io-index" 808 | checksum = "57c0d7b74b563b49d38dae00a0c37d4d6de9b432382b2892f0574ddcae73fd0a" 809 | 810 | [[package]] 811 | name = "pest" 812 | version = "2.7.11" 813 | source = "registry+https://github.com/rust-lang/crates.io-index" 814 | checksum = "cd53dff83f26735fdc1ca837098ccf133605d794cdae66acfc2bfac3ec809d95" 815 | dependencies = [ 816 | "memchr", 817 | "thiserror", 818 | "ucd-trie", 819 | ] 820 | 821 | [[package]] 822 | name = "pkcs8" 823 | version = "0.10.2" 824 | source = "registry+https://github.com/rust-lang/crates.io-index" 825 | checksum = "f950b2377845cebe5cf8b5165cb3cc1a5e0fa5cfa3e1f7f55707d8fd82e0a7b7" 826 | dependencies = [ 827 | "der", 828 | "spki", 829 | ] 830 | 831 | [[package]] 832 | name = "ppv-lite86" 833 | version = "0.2.17" 834 | source = "registry+https://github.com/rust-lang/crates.io-index" 835 | checksum = "5b40af805b3121feab8a3c29f04d8ad262fa8e0561883e7653e024ae4479e6de" 836 | 837 | [[package]] 838 | name = "primitive-types" 839 | version = "0.12.2" 840 | source = "registry+https://github.com/rust-lang/crates.io-index" 841 | checksum = "0b34d9fd68ae0b74a41b21c03c2f62847aa0ffea044eee893b4c140b37e244e2" 842 | dependencies = [ 843 | "fixed-hash", 844 | "impl-codec", 845 | "uint", 846 | ] 847 | 848 | [[package]] 849 | name = "proc-macro-crate" 850 | version = "3.1.0" 851 | source = "registry+https://github.com/rust-lang/crates.io-index" 852 | checksum = "6d37c51ca738a55da99dc0c4a34860fd675453b8b36209178c2249bb13651284" 853 | dependencies = [ 854 | "toml_edit", 855 | ] 856 | 857 | [[package]] 858 | name = "proc-macro-error" 859 | version = "1.0.4" 860 | source = "registry+https://github.com/rust-lang/crates.io-index" 861 | checksum = "da25490ff9892aab3fcf7c36f08cfb902dd3e71ca0f9f9517bea02a73a5ce38c" 862 | dependencies = [ 863 | "proc-macro-error-attr", 864 | "proc-macro2", 865 | "quote", 866 | "syn 1.0.109", 867 | "version_check", 868 | ] 869 | 870 | [[package]] 871 | name = "proc-macro-error-attr" 872 | version = "1.0.4" 873 | source = "registry+https://github.com/rust-lang/crates.io-index" 874 | checksum = "a1be40180e52ecc98ad80b184934baf3d0d29f979574e439af5a55274b35f869" 875 | dependencies = [ 876 | "proc-macro2", 877 | "quote", 878 | "version_check", 879 | ] 880 | 881 | [[package]] 882 | name = "proc-macro2" 883 | version = "1.0.86" 884 | source = "registry+https://github.com/rust-lang/crates.io-index" 885 | checksum = "5e719e8df665df0d1c8fbfd238015744736151d4445ec0836b8e628aae103b77" 886 | dependencies = [ 887 | "unicode-ident", 888 | ] 889 | 890 | [[package]] 891 | name = "proptest" 892 | version = "1.5.0" 893 | source = "registry+https://github.com/rust-lang/crates.io-index" 894 | checksum = "b4c2511913b88df1637da85cc8d96ec8e43a3f8bb8ccb71ee1ac240d6f3df58d" 895 | dependencies = [ 896 | "bit-set", 897 | "bit-vec", 898 | "bitflags", 899 | "lazy_static", 900 | "num-traits", 901 | "rand", 902 | "rand_chacha", 903 | "rand_xorshift", 904 | "regex-syntax", 905 | "rusty-fork", 906 | "tempfile", 907 | "unarray", 908 | ] 909 | 910 | [[package]] 911 | name = "quick-error" 912 | version = "1.2.3" 913 | source = "registry+https://github.com/rust-lang/crates.io-index" 914 | checksum = "a1d01941d82fa2ab50be1e79e6714289dd7cde78eba4c074bc5a4374f650dfe0" 915 | 916 | [[package]] 917 | name = "quote" 918 | version = "1.0.36" 919 | source = "registry+https://github.com/rust-lang/crates.io-index" 920 | checksum = "0fa76aaf39101c457836aec0ce2316dbdc3ab723cdda1c6bd4e6ad4208acaca7" 921 | dependencies = [ 922 | "proc-macro2", 923 | ] 924 | 925 | [[package]] 926 | name = "radium" 927 | version = "0.7.0" 928 | source = "registry+https://github.com/rust-lang/crates.io-index" 929 | checksum = "dc33ff2d4973d518d823d61aa239014831e521c75da58e3df4840d3f47749d09" 930 | 931 | [[package]] 932 | name = "rand" 933 | version = "0.8.5" 934 | source = "registry+https://github.com/rust-lang/crates.io-index" 935 | checksum = "34af8d1a0e25924bc5b7c43c079c942339d8f0a8b57c39049bef581b46327404" 936 | dependencies = [ 937 | "libc", 938 | "rand_chacha", 939 | "rand_core", 940 | ] 941 | 942 | [[package]] 943 | name = "rand_chacha" 944 | version = "0.3.1" 945 | source = "registry+https://github.com/rust-lang/crates.io-index" 946 | checksum = "e6c10a63a0fa32252be49d21e7709d4d4baf8d231c2dbce1eaa8141b9b127d88" 947 | dependencies = [ 948 | "ppv-lite86", 949 | "rand_core", 950 | ] 951 | 952 | [[package]] 953 | name = "rand_core" 954 | version = "0.6.4" 955 | source = "registry+https://github.com/rust-lang/crates.io-index" 956 | checksum = "ec0be4795e2f6a28069bec0b5ff3e2ac9bafc99e6a9a7dc3547996c5c816922c" 957 | dependencies = [ 958 | "getrandom", 959 | ] 960 | 961 | [[package]] 962 | name = "rand_xorshift" 963 | version = "0.3.0" 964 | source = "registry+https://github.com/rust-lang/crates.io-index" 965 | checksum = "d25bf25ec5ae4a3f1b92f929810509a2f53d7dca2f50b794ff57e3face536c8f" 966 | dependencies = [ 967 | "rand_core", 968 | ] 969 | 970 | [[package]] 971 | name = "regex-syntax" 972 | version = "0.8.4" 973 | source = "registry+https://github.com/rust-lang/crates.io-index" 974 | checksum = "7a66a03ae7c801facd77a29370b4faec201768915ac14a721ba36f20bc9c209b" 975 | 976 | [[package]] 977 | name = "rfc6979" 978 | version = "0.4.0" 979 | source = "registry+https://github.com/rust-lang/crates.io-index" 980 | checksum = "f8dd2a808d456c4a54e300a23e9f5a67e122c3024119acbfd73e3bf664491cb2" 981 | dependencies = [ 982 | "hmac", 983 | "subtle", 984 | ] 985 | 986 | [[package]] 987 | name = "rlp" 988 | version = "0.5.2" 989 | source = "registry+https://github.com/rust-lang/crates.io-index" 990 | checksum = "bb919243f34364b6bd2fc10ef797edbfa75f33c252e7998527479c6d6b47e1ec" 991 | dependencies = [ 992 | "bytes", 993 | "rustc-hex", 994 | ] 995 | 996 | [[package]] 997 | name = "ruint" 998 | version = "1.12.3" 999 | source = "registry+https://github.com/rust-lang/crates.io-index" 1000 | checksum = "2c3cc4c2511671f327125da14133d0c5c5d137f006a1017a16f557bc85b16286" 1001 | dependencies = [ 1002 | "alloy-rlp", 1003 | "ark-ff 0.3.0", 1004 | "ark-ff 0.4.2", 1005 | "bytes", 1006 | "fastrlp", 1007 | "num-bigint", 1008 | "num-traits", 1009 | "parity-scale-codec", 1010 | "primitive-types", 1011 | "proptest", 1012 | "rand", 1013 | "rlp", 1014 | "ruint-macro", 1015 | "serde", 1016 | "valuable", 1017 | "zeroize", 1018 | ] 1019 | 1020 | [[package]] 1021 | name = "ruint-macro" 1022 | version = "1.2.1" 1023 | source = "registry+https://github.com/rust-lang/crates.io-index" 1024 | checksum = "48fd7bd8a6377e15ad9d42a8ec25371b94ddc67abe7c8b9127bec79bebaaae18" 1025 | 1026 | [[package]] 1027 | name = "rustc-hex" 1028 | version = "2.1.0" 1029 | source = "registry+https://github.com/rust-lang/crates.io-index" 1030 | checksum = "3e75f6a532d0fd9f7f13144f392b6ad56a32696bfcd9c78f797f16bbb6f072d6" 1031 | 1032 | [[package]] 1033 | name = "rustc_version" 1034 | version = "0.3.3" 1035 | source = "registry+https://github.com/rust-lang/crates.io-index" 1036 | checksum = "f0dfe2087c51c460008730de8b57e6a320782fbfb312e1f4d520e6c6fae155ee" 1037 | dependencies = [ 1038 | "semver 0.11.0", 1039 | ] 1040 | 1041 | [[package]] 1042 | name = "rustc_version" 1043 | version = "0.4.0" 1044 | source = "registry+https://github.com/rust-lang/crates.io-index" 1045 | checksum = "bfa0f585226d2e68097d4f95d113b15b83a82e819ab25717ec0590d9584ef366" 1046 | dependencies = [ 1047 | "semver 1.0.23", 1048 | ] 1049 | 1050 | [[package]] 1051 | name = "rustix" 1052 | version = "0.38.34" 1053 | source = "registry+https://github.com/rust-lang/crates.io-index" 1054 | checksum = "70dc5ec042f7a43c4a73241207cecc9873a06d45debb38b329f8541d85c2730f" 1055 | dependencies = [ 1056 | "bitflags", 1057 | "errno", 1058 | "libc", 1059 | "linux-raw-sys", 1060 | "windows-sys", 1061 | ] 1062 | 1063 | [[package]] 1064 | name = "rusty-fork" 1065 | version = "0.3.0" 1066 | source = "registry+https://github.com/rust-lang/crates.io-index" 1067 | checksum = "cb3dcc6e454c328bb824492db107ab7c0ae8fcffe4ad210136ef014458c1bc4f" 1068 | dependencies = [ 1069 | "fnv", 1070 | "quick-error", 1071 | "tempfile", 1072 | "wait-timeout", 1073 | ] 1074 | 1075 | [[package]] 1076 | name = "sec1" 1077 | version = "0.7.3" 1078 | source = "registry+https://github.com/rust-lang/crates.io-index" 1079 | checksum = "d3e97a565f76233a6003f9f5c54be1d9c5bdfa3eccfb189469f11ec4901c47dc" 1080 | dependencies = [ 1081 | "base16ct", 1082 | "der", 1083 | "generic-array", 1084 | "pkcs8", 1085 | "subtle", 1086 | "zeroize", 1087 | ] 1088 | 1089 | [[package]] 1090 | name = "semver" 1091 | version = "0.11.0" 1092 | source = "registry+https://github.com/rust-lang/crates.io-index" 1093 | checksum = "f301af10236f6df4160f7c3f04eec6dbc70ace82d23326abad5edee88801c6b6" 1094 | dependencies = [ 1095 | "semver-parser", 1096 | ] 1097 | 1098 | [[package]] 1099 | name = "semver" 1100 | version = "1.0.23" 1101 | source = "registry+https://github.com/rust-lang/crates.io-index" 1102 | checksum = "61697e0a1c7e512e84a621326239844a24d8207b4669b41bc18b32ea5cbf988b" 1103 | 1104 | [[package]] 1105 | name = "semver-parser" 1106 | version = "0.10.2" 1107 | source = "registry+https://github.com/rust-lang/crates.io-index" 1108 | checksum = "00b0bef5b7f9e0df16536d3961cfb6e84331c065b4066afb39768d0e319411f7" 1109 | dependencies = [ 1110 | "pest", 1111 | ] 1112 | 1113 | [[package]] 1114 | name = "serde" 1115 | version = "1.0.204" 1116 | source = "registry+https://github.com/rust-lang/crates.io-index" 1117 | checksum = "bc76f558e0cbb2a839d37354c575f1dc3fdc6546b5be373ba43d95f231bf7c12" 1118 | dependencies = [ 1119 | "serde_derive", 1120 | ] 1121 | 1122 | [[package]] 1123 | name = "serde_derive" 1124 | version = "1.0.204" 1125 | source = "registry+https://github.com/rust-lang/crates.io-index" 1126 | checksum = "e0cd7e117be63d3c3678776753929474f3b04a43a080c744d6b0ae2a8c28e222" 1127 | dependencies = [ 1128 | "proc-macro2", 1129 | "quote", 1130 | "syn 2.0.72", 1131 | ] 1132 | 1133 | [[package]] 1134 | name = "sha2" 1135 | version = "0.10.8" 1136 | source = "registry+https://github.com/rust-lang/crates.io-index" 1137 | checksum = "793db75ad2bcafc3ffa7c68b215fee268f537982cd901d132f89c6343f3a3dc8" 1138 | dependencies = [ 1139 | "cfg-if", 1140 | "cpufeatures", 1141 | "digest 0.10.7", 1142 | ] 1143 | 1144 | [[package]] 1145 | name = "sha3-asm" 1146 | version = "0.1.1" 1147 | source = "registry+https://github.com/rust-lang/crates.io-index" 1148 | checksum = "a9b57fd861253bff08bb1919e995f90ba8f4889de2726091c8876f3a4e823b40" 1149 | dependencies = [ 1150 | "cc", 1151 | "cfg-if", 1152 | ] 1153 | 1154 | [[package]] 1155 | name = "signature" 1156 | version = "2.2.0" 1157 | source = "registry+https://github.com/rust-lang/crates.io-index" 1158 | checksum = "77549399552de45a898a580c1b41d445bf730df867cc44e6c0233bbc4b8329de" 1159 | dependencies = [ 1160 | "digest 0.10.7", 1161 | "rand_core", 1162 | ] 1163 | 1164 | [[package]] 1165 | name = "sp1-lib" 1166 | version = "1.1.0" 1167 | source = "registry+https://github.com/rust-lang/crates.io-index" 1168 | checksum = "de4c2cc40e1019faac8cdbe61172c7be09960cfe240c712be46df3795c53fce8" 1169 | dependencies = [ 1170 | "anyhow", 1171 | "bincode", 1172 | "cfg-if", 1173 | "serde", 1174 | ] 1175 | 1176 | [[package]] 1177 | name = "sp1-zkvm" 1178 | version = "1.1.0" 1179 | source = "registry+https://github.com/rust-lang/crates.io-index" 1180 | checksum = "2b4490136e03f6fe931dc49559574bb6dbf5e6a86cae1f60dc3842d2b79905ed" 1181 | dependencies = [ 1182 | "bincode", 1183 | "cfg-if", 1184 | "getrandom", 1185 | "lazy_static", 1186 | "libm", 1187 | "once_cell", 1188 | "rand", 1189 | "serde", 1190 | "sha2", 1191 | "sp1-lib", 1192 | ] 1193 | 1194 | [[package]] 1195 | name = "spki" 1196 | version = "0.7.3" 1197 | source = "registry+https://github.com/rust-lang/crates.io-index" 1198 | checksum = "d91ed6c858b01f942cd56b37a94b3e0a1798290327d1236e4d9cf4eaca44d29d" 1199 | dependencies = [ 1200 | "base64ct", 1201 | "der", 1202 | ] 1203 | 1204 | [[package]] 1205 | name = "static_assertions" 1206 | version = "1.1.0" 1207 | source = "registry+https://github.com/rust-lang/crates.io-index" 1208 | checksum = "a2eb9349b6444b326872e140eb1cf5e7c522154d69e7a0ffb0fb81c06b37543f" 1209 | 1210 | [[package]] 1211 | name = "subtle" 1212 | version = "2.6.1" 1213 | source = "registry+https://github.com/rust-lang/crates.io-index" 1214 | checksum = "13c2bddecc57b384dee18652358fb23172facb8a2c51ccc10d74c157bdea3292" 1215 | 1216 | [[package]] 1217 | name = "syn" 1218 | version = "1.0.109" 1219 | source = "registry+https://github.com/rust-lang/crates.io-index" 1220 | checksum = "72b64191b275b66ffe2469e8af2c1cfe3bafa67b529ead792a6d0160888b4237" 1221 | dependencies = [ 1222 | "proc-macro2", 1223 | "quote", 1224 | "unicode-ident", 1225 | ] 1226 | 1227 | [[package]] 1228 | name = "syn" 1229 | version = "2.0.72" 1230 | source = "registry+https://github.com/rust-lang/crates.io-index" 1231 | checksum = "dc4b9b9bf2add8093d3f2c0204471e951b2285580335de42f9d2534f3ae7a8af" 1232 | dependencies = [ 1233 | "proc-macro2", 1234 | "quote", 1235 | "unicode-ident", 1236 | ] 1237 | 1238 | [[package]] 1239 | name = "syn-solidity" 1240 | version = "0.7.7" 1241 | source = "registry+https://github.com/rust-lang/crates.io-index" 1242 | checksum = "c837dc8852cb7074e46b444afb81783140dab12c58867b49fb3898fbafedf7ea" 1243 | dependencies = [ 1244 | "paste", 1245 | "proc-macro2", 1246 | "quote", 1247 | "syn 2.0.72", 1248 | ] 1249 | 1250 | [[package]] 1251 | name = "tap" 1252 | version = "1.0.1" 1253 | source = "registry+https://github.com/rust-lang/crates.io-index" 1254 | checksum = "55937e1799185b12863d447f42597ed69d9928686b8d88a1df17376a097d8369" 1255 | 1256 | [[package]] 1257 | name = "tempfile" 1258 | version = "3.10.1" 1259 | source = "registry+https://github.com/rust-lang/crates.io-index" 1260 | checksum = "85b77fafb263dd9d05cbeac119526425676db3784113aa9295c88498cbf8bff1" 1261 | dependencies = [ 1262 | "cfg-if", 1263 | "fastrand", 1264 | "rustix", 1265 | "windows-sys", 1266 | ] 1267 | 1268 | [[package]] 1269 | name = "thiserror" 1270 | version = "1.0.63" 1271 | source = "registry+https://github.com/rust-lang/crates.io-index" 1272 | checksum = "c0342370b38b6a11b6cc11d6a805569958d54cfa061a29969c3b5ce2ea405724" 1273 | dependencies = [ 1274 | "thiserror-impl", 1275 | ] 1276 | 1277 | [[package]] 1278 | name = "thiserror-impl" 1279 | version = "1.0.63" 1280 | source = "registry+https://github.com/rust-lang/crates.io-index" 1281 | checksum = "a4558b58466b9ad7ca0f102865eccc95938dca1a74a856f2b57b6629050da261" 1282 | dependencies = [ 1283 | "proc-macro2", 1284 | "quote", 1285 | "syn 2.0.72", 1286 | ] 1287 | 1288 | [[package]] 1289 | name = "tiny-keccak" 1290 | version = "2.0.2" 1291 | source = "registry+https://github.com/rust-lang/crates.io-index" 1292 | checksum = "2c9d3793400a45f954c52e73d068316d76b6f4e36977e3fcebb13a2721e80237" 1293 | dependencies = [ 1294 | "crunchy", 1295 | ] 1296 | 1297 | [[package]] 1298 | name = "toml_datetime" 1299 | version = "0.6.6" 1300 | source = "registry+https://github.com/rust-lang/crates.io-index" 1301 | checksum = "4badfd56924ae69bcc9039335b2e017639ce3f9b001c393c1b2d1ef846ce2cbf" 1302 | 1303 | [[package]] 1304 | name = "toml_edit" 1305 | version = "0.21.1" 1306 | source = "registry+https://github.com/rust-lang/crates.io-index" 1307 | checksum = "6a8534fd7f78b5405e860340ad6575217ce99f38d4d5c8f2442cb5ecb50090e1" 1308 | dependencies = [ 1309 | "indexmap", 1310 | "toml_datetime", 1311 | "winnow", 1312 | ] 1313 | 1314 | [[package]] 1315 | name = "typenum" 1316 | version = "1.17.0" 1317 | source = "registry+https://github.com/rust-lang/crates.io-index" 1318 | checksum = "42ff0bf0c66b8238c6f3b578df37d0b7848e55df8577b3f74f92a69acceeb825" 1319 | 1320 | [[package]] 1321 | name = "ucd-trie" 1322 | version = "0.1.6" 1323 | source = "registry+https://github.com/rust-lang/crates.io-index" 1324 | checksum = "ed646292ffc8188ef8ea4d1e0e0150fb15a5c2e12ad9b8fc191ae7a8a7f3c4b9" 1325 | 1326 | [[package]] 1327 | name = "uint" 1328 | version = "0.9.5" 1329 | source = "registry+https://github.com/rust-lang/crates.io-index" 1330 | checksum = "76f64bba2c53b04fcab63c01a7d7427eadc821e3bc48c34dc9ba29c501164b52" 1331 | dependencies = [ 1332 | "byteorder", 1333 | "crunchy", 1334 | "hex", 1335 | "static_assertions", 1336 | ] 1337 | 1338 | [[package]] 1339 | name = "unarray" 1340 | version = "0.1.4" 1341 | source = "registry+https://github.com/rust-lang/crates.io-index" 1342 | checksum = "eaea85b334db583fe3274d12b4cd1880032beab409c0d774be044d4480ab9a94" 1343 | 1344 | [[package]] 1345 | name = "unicode-ident" 1346 | version = "1.0.12" 1347 | source = "registry+https://github.com/rust-lang/crates.io-index" 1348 | checksum = "3354b9ac3fae1ff6755cb6db53683adb661634f67557942dea4facebec0fee4b" 1349 | 1350 | [[package]] 1351 | name = "valuable" 1352 | version = "0.1.0" 1353 | source = "registry+https://github.com/rust-lang/crates.io-index" 1354 | checksum = "830b7e5d4d90034032940e4ace0d9a9a057e7a45cd94e6c007832e39edb82f6d" 1355 | 1356 | [[package]] 1357 | name = "version_check" 1358 | version = "0.9.4" 1359 | source = "registry+https://github.com/rust-lang/crates.io-index" 1360 | checksum = "49874b5167b65d7193b8aba1567f5c7d93d001cafc34600cee003eda787e483f" 1361 | 1362 | [[package]] 1363 | name = "wait-timeout" 1364 | version = "0.2.0" 1365 | source = "registry+https://github.com/rust-lang/crates.io-index" 1366 | checksum = "9f200f5b12eb75f8c1ed65abd4b2db8a6e1b138a20de009dacee265a2498f3f6" 1367 | dependencies = [ 1368 | "libc", 1369 | ] 1370 | 1371 | [[package]] 1372 | name = "wasi" 1373 | version = "0.11.0+wasi-snapshot-preview1" 1374 | source = "registry+https://github.com/rust-lang/crates.io-index" 1375 | checksum = "9c8d87e72b64a3b4db28d11ce29237c246188f4f51057d65a7eab63b7987e423" 1376 | 1377 | [[package]] 1378 | name = "windows-sys" 1379 | version = "0.52.0" 1380 | source = "registry+https://github.com/rust-lang/crates.io-index" 1381 | checksum = "282be5f36a8ce781fad8c8ae18fa3f9beff57ec1b52cb3de0789201425d9a33d" 1382 | dependencies = [ 1383 | "windows-targets", 1384 | ] 1385 | 1386 | [[package]] 1387 | name = "windows-targets" 1388 | version = "0.52.6" 1389 | source = "registry+https://github.com/rust-lang/crates.io-index" 1390 | checksum = "9b724f72796e036ab90c1021d4780d4d3d648aca59e491e6b98e725b84e99973" 1391 | dependencies = [ 1392 | "windows_aarch64_gnullvm", 1393 | "windows_aarch64_msvc", 1394 | "windows_i686_gnu", 1395 | "windows_i686_gnullvm", 1396 | "windows_i686_msvc", 1397 | "windows_x86_64_gnu", 1398 | "windows_x86_64_gnullvm", 1399 | "windows_x86_64_msvc", 1400 | ] 1401 | 1402 | [[package]] 1403 | name = "windows_aarch64_gnullvm" 1404 | version = "0.52.6" 1405 | source = "registry+https://github.com/rust-lang/crates.io-index" 1406 | checksum = "32a4622180e7a0ec044bb555404c800bc9fd9ec262ec147edd5989ccd0c02cd3" 1407 | 1408 | [[package]] 1409 | name = "windows_aarch64_msvc" 1410 | version = "0.52.6" 1411 | source = "registry+https://github.com/rust-lang/crates.io-index" 1412 | checksum = "09ec2a7bb152e2252b53fa7803150007879548bc709c039df7627cabbd05d469" 1413 | 1414 | [[package]] 1415 | name = "windows_i686_gnu" 1416 | version = "0.52.6" 1417 | source = "registry+https://github.com/rust-lang/crates.io-index" 1418 | checksum = "8e9b5ad5ab802e97eb8e295ac6720e509ee4c243f69d781394014ebfe8bbfa0b" 1419 | 1420 | [[package]] 1421 | name = "windows_i686_gnullvm" 1422 | version = "0.52.6" 1423 | source = "registry+https://github.com/rust-lang/crates.io-index" 1424 | checksum = "0eee52d38c090b3caa76c563b86c3a4bd71ef1a819287c19d586d7334ae8ed66" 1425 | 1426 | [[package]] 1427 | name = "windows_i686_msvc" 1428 | version = "0.52.6" 1429 | source = "registry+https://github.com/rust-lang/crates.io-index" 1430 | checksum = "240948bc05c5e7c6dabba28bf89d89ffce3e303022809e73deaefe4f6ec56c66" 1431 | 1432 | [[package]] 1433 | name = "windows_x86_64_gnu" 1434 | version = "0.52.6" 1435 | source = "registry+https://github.com/rust-lang/crates.io-index" 1436 | checksum = "147a5c80aabfbf0c7d901cb5895d1de30ef2907eb21fbbab29ca94c5b08b1a78" 1437 | 1438 | [[package]] 1439 | name = "windows_x86_64_gnullvm" 1440 | version = "0.52.6" 1441 | source = "registry+https://github.com/rust-lang/crates.io-index" 1442 | checksum = "24d5b23dc417412679681396f2b49f3de8c1473deb516bd34410872eff51ed0d" 1443 | 1444 | [[package]] 1445 | name = "windows_x86_64_msvc" 1446 | version = "0.52.6" 1447 | source = "registry+https://github.com/rust-lang/crates.io-index" 1448 | checksum = "589f6da84c646204747d1270a2a5661ea66ed1cced2631d546fdfb155959f9ec" 1449 | 1450 | [[package]] 1451 | name = "winnow" 1452 | version = "0.5.40" 1453 | source = "registry+https://github.com/rust-lang/crates.io-index" 1454 | checksum = "f593a95398737aeed53e489c785df13f3618e41dbcd6718c6addbf1395aa6876" 1455 | dependencies = [ 1456 | "memchr", 1457 | ] 1458 | 1459 | [[package]] 1460 | name = "wyz" 1461 | version = "0.5.1" 1462 | source = "registry+https://github.com/rust-lang/crates.io-index" 1463 | checksum = "05f360fc0b24296329c78fda852a1e9ae82de9cf7b27dae4b7f62f118f77b9ed" 1464 | dependencies = [ 1465 | "tap", 1466 | ] 1467 | 1468 | [[package]] 1469 | name = "zeroize" 1470 | version = "1.8.1" 1471 | source = "registry+https://github.com/rust-lang/crates.io-index" 1472 | checksum = "ced3678a2879b30306d323f4542626697a464a97c0a07c9aebf7ebca65cd4dde" 1473 | dependencies = [ 1474 | "zeroize_derive", 1475 | ] 1476 | 1477 | [[package]] 1478 | name = "zeroize_derive" 1479 | version = "1.4.2" 1480 | source = "registry+https://github.com/rust-lang/crates.io-index" 1481 | checksum = "ce36e65b0d2999d2aafac989fb249189a141aee1f53c612c1f37d72631959f69" 1482 | dependencies = [ 1483 | "proc-macro2", 1484 | "quote", 1485 | "syn 2.0.72", 1486 | ] 1487 | -------------------------------------------------------------------------------- /program/Cargo.toml: -------------------------------------------------------------------------------- 1 | [package] 2 | version = "0.1.0" 3 | name = "fibonacci-program" 4 | edition = "2021" 5 | 6 | [dependencies] 7 | alloy-sol-types = { workspace = true } 8 | sp1-zkvm = "5.0.0" 9 | fibonacci-lib = { path = "../lib" } 10 | -------------------------------------------------------------------------------- /program/src/main.rs: -------------------------------------------------------------------------------- 1 | //! A simple program that takes a number `n` as input, and writes the `n-1`th and `n`th fibonacci 2 | //! number as an output. 3 | 4 | // These two lines are necessary for the program to properly compile. 5 | // 6 | // Under the hood, we wrap your main function with some extra code so that it behaves properly 7 | // inside the zkVM. 8 | #![no_main] 9 | sp1_zkvm::entrypoint!(main); 10 | 11 | use alloy_sol_types::SolType; 12 | use fibonacci_lib::{fibonacci, PublicValuesStruct}; 13 | 14 | pub fn main() { 15 | // Read an input to the program. 16 | // 17 | // Behind the scenes, this compiles down to a custom system call which handles reading inputs 18 | // from the prover. 19 | let n = sp1_zkvm::io::read::(); 20 | 21 | // Compute the n'th fibonacci number using a function from the workspace lib crate. 22 | let (a, b) = fibonacci(n); 23 | 24 | // Encode the public values of the program. 25 | let bytes = PublicValuesStruct::abi_encode(&PublicValuesStruct { n, a, b }); 26 | 27 | // Commit to the public values of the program. The final proof will have a commitment to all the 28 | // bytes that were committed to. 29 | sp1_zkvm::io::commit_slice(&bytes); 30 | } 31 | -------------------------------------------------------------------------------- /rust-toolchain: -------------------------------------------------------------------------------- 1 | [toolchain] 2 | channel = "stable" 3 | components = ["llvm-tools", "rustc-dev"] -------------------------------------------------------------------------------- /script/Cargo.toml: -------------------------------------------------------------------------------- 1 | [package] 2 | version = "0.1.0" 3 | name = "fibonacci-script" 4 | edition = "2021" 5 | default-run = "fibonacci" 6 | 7 | [[bin]] 8 | name = "fibonacci" 9 | path = "src/bin/main.rs" 10 | 11 | [[bin]] 12 | name = "evm" 13 | path = "src/bin/evm.rs" 14 | 15 | [[bin]] 16 | name = "vkey" 17 | path = "src/bin/vkey.rs" 18 | 19 | [dependencies] 20 | sp1-sdk = "5.0.0" 21 | serde_json = { version = "1.0", default-features = false, features = ["alloc"] } 22 | serde = { version = "1.0.200", default-features = false, features = ["derive"] } 23 | clap = { version = "4.0", features = ["derive", "env"] } 24 | tracing = "0.1.40" 25 | hex = "0.4.3" 26 | alloy-sol-types = { workspace = true } 27 | fibonacci-lib = { path = "../lib" } 28 | dotenv = "0.15.0" 29 | 30 | [build-dependencies] 31 | sp1-build = "5.0.0" 32 | -------------------------------------------------------------------------------- /script/build.rs: -------------------------------------------------------------------------------- 1 | use sp1_build::build_program_with_args; 2 | 3 | fn main() { 4 | build_program_with_args("../program", Default::default()) 5 | } 6 | -------------------------------------------------------------------------------- /script/src/bin/evm.rs: -------------------------------------------------------------------------------- 1 | //! An end-to-end example of using the SP1 SDK to generate a proof of a program that can have an 2 | //! EVM-Compatible proof generated which can be verified on-chain. 3 | //! 4 | //! You can run this script using the following command: 5 | //! ```shell 6 | //! RUST_LOG=info cargo run --release --bin evm -- --system groth16 7 | //! ``` 8 | //! or 9 | //! ```shell 10 | //! RUST_LOG=info cargo run --release --bin evm -- --system plonk 11 | //! ``` 12 | 13 | use alloy_sol_types::SolType; 14 | use clap::{Parser, ValueEnum}; 15 | use fibonacci_lib::PublicValuesStruct; 16 | use serde::{Deserialize, Serialize}; 17 | use sp1_sdk::{ 18 | include_elf, HashableKey, ProverClient, SP1ProofWithPublicValues, SP1Stdin, SP1VerifyingKey, 19 | }; 20 | use std::path::PathBuf; 21 | 22 | /// The ELF (executable and linkable format) file for the Succinct RISC-V zkVM. 23 | pub const FIBONACCI_ELF: &[u8] = include_elf!("fibonacci-program"); 24 | 25 | /// The arguments for the EVM command. 26 | #[derive(Parser, Debug)] 27 | #[command(author, version, about, long_about = None)] 28 | struct EVMArgs { 29 | #[arg(long, default_value = "20")] 30 | n: u32, 31 | #[arg(long, value_enum, default_value = "groth16")] 32 | system: ProofSystem, 33 | } 34 | 35 | /// Enum representing the available proof systems 36 | #[derive(Copy, Clone, PartialEq, Eq, PartialOrd, Ord, ValueEnum, Debug)] 37 | enum ProofSystem { 38 | Plonk, 39 | Groth16, 40 | } 41 | 42 | /// A fixture that can be used to test the verification of SP1 zkVM proofs inside Solidity. 43 | #[derive(Debug, Clone, Serialize, Deserialize)] 44 | #[serde(rename_all = "camelCase")] 45 | struct SP1FibonacciProofFixture { 46 | a: u32, 47 | b: u32, 48 | n: u32, 49 | vkey: String, 50 | public_values: String, 51 | proof: String, 52 | } 53 | 54 | fn main() { 55 | // Setup the logger. 56 | sp1_sdk::utils::setup_logger(); 57 | 58 | // Parse the command line arguments. 59 | let args = EVMArgs::parse(); 60 | 61 | // Setup the prover client. 62 | let client = ProverClient::from_env(); 63 | 64 | // Setup the program. 65 | let (pk, vk) = client.setup(FIBONACCI_ELF); 66 | 67 | // Setup the inputs. 68 | let mut stdin = SP1Stdin::new(); 69 | stdin.write(&args.n); 70 | 71 | println!("n: {}", args.n); 72 | println!("Proof System: {:?}", args.system); 73 | 74 | // Generate the proof based on the selected proof system. 75 | let proof = match args.system { 76 | ProofSystem::Plonk => client.prove(&pk, &stdin).plonk().run(), 77 | ProofSystem::Groth16 => client.prove(&pk, &stdin).groth16().run(), 78 | } 79 | .expect("failed to generate proof"); 80 | 81 | create_proof_fixture(&proof, &vk, args.system); 82 | } 83 | 84 | /// Create a fixture for the given proof. 85 | fn create_proof_fixture( 86 | proof: &SP1ProofWithPublicValues, 87 | vk: &SP1VerifyingKey, 88 | system: ProofSystem, 89 | ) { 90 | // Deserialize the public values. 91 | let bytes = proof.public_values.as_slice(); 92 | let PublicValuesStruct { n, a, b } = PublicValuesStruct::abi_decode(bytes).unwrap(); 93 | 94 | // Create the testing fixture so we can test things end-to-end. 95 | let fixture = SP1FibonacciProofFixture { 96 | a, 97 | b, 98 | n, 99 | vkey: vk.bytes32().to_string(), 100 | public_values: format!("0x{}", hex::encode(bytes)), 101 | proof: format!("0x{}", hex::encode(proof.bytes())), 102 | }; 103 | 104 | // The verification key is used to verify that the proof corresponds to the execution of the 105 | // program on the given input. 106 | // 107 | // Note that the verification key stays the same regardless of the input. 108 | println!("Verification Key: {}", fixture.vkey); 109 | 110 | // The public values are the values which are publicly committed to by the zkVM. 111 | // 112 | // If you need to expose the inputs or outputs of your program, you should commit them in 113 | // the public values. 114 | println!("Public Values: {}", fixture.public_values); 115 | 116 | // The proof proves to the verifier that the program was executed with some inputs that led to 117 | // the give public values. 118 | println!("Proof Bytes: {}", fixture.proof); 119 | 120 | // Save the fixture to a file. 121 | let fixture_path = PathBuf::from(env!("CARGO_MANIFEST_DIR")).join("../contracts/src/fixtures"); 122 | std::fs::create_dir_all(&fixture_path).expect("failed to create fixture path"); 123 | std::fs::write( 124 | fixture_path.join(format!("{:?}-fixture.json", system).to_lowercase()), 125 | serde_json::to_string_pretty(&fixture).unwrap(), 126 | ) 127 | .expect("failed to write fixture"); 128 | } 129 | -------------------------------------------------------------------------------- /script/src/bin/main.rs: -------------------------------------------------------------------------------- 1 | //! An end-to-end example of using the SP1 SDK to generate a proof of a program that can be executed 2 | //! or have a core proof generated. 3 | //! 4 | //! You can run this script using the following command: 5 | //! ```shell 6 | //! RUST_LOG=info cargo run --release -- --execute 7 | //! ``` 8 | //! or 9 | //! ```shell 10 | //! RUST_LOG=info cargo run --release -- --prove 11 | //! ``` 12 | 13 | use alloy_sol_types::SolType; 14 | use clap::Parser; 15 | use fibonacci_lib::PublicValuesStruct; 16 | use sp1_sdk::{include_elf, ProverClient, SP1Stdin}; 17 | 18 | /// The ELF (executable and linkable format) file for the Succinct RISC-V zkVM. 19 | pub const FIBONACCI_ELF: &[u8] = include_elf!("fibonacci-program"); 20 | 21 | /// The arguments for the command. 22 | #[derive(Parser, Debug)] 23 | #[command(author, version, about, long_about = None)] 24 | struct Args { 25 | #[arg(long)] 26 | execute: bool, 27 | 28 | #[arg(long)] 29 | prove: bool, 30 | 31 | #[arg(long, default_value = "20")] 32 | n: u32, 33 | } 34 | 35 | fn main() { 36 | // Setup the logger. 37 | sp1_sdk::utils::setup_logger(); 38 | dotenv::dotenv().ok(); 39 | 40 | // Parse the command line arguments. 41 | let args = Args::parse(); 42 | 43 | if args.execute == args.prove { 44 | eprintln!("Error: You must specify either --execute or --prove"); 45 | std::process::exit(1); 46 | } 47 | 48 | // Setup the prover client. 49 | let client = ProverClient::from_env(); 50 | 51 | // Setup the inputs. 52 | let mut stdin = SP1Stdin::new(); 53 | stdin.write(&args.n); 54 | 55 | println!("n: {}", args.n); 56 | 57 | if args.execute { 58 | // Execute the program 59 | let (output, report) = client.execute(FIBONACCI_ELF, &stdin).run().unwrap(); 60 | println!("Program executed successfully."); 61 | 62 | // Read the output. 63 | let decoded = PublicValuesStruct::abi_decode(output.as_slice()).unwrap(); 64 | let PublicValuesStruct { n, a, b } = decoded; 65 | println!("n: {}", n); 66 | println!("a: {}", a); 67 | println!("b: {}", b); 68 | 69 | let (expected_a, expected_b) = fibonacci_lib::fibonacci(n); 70 | assert_eq!(a, expected_a); 71 | assert_eq!(b, expected_b); 72 | println!("Values are correct!"); 73 | 74 | // Record the number of cycles executed. 75 | println!("Number of cycles: {}", report.total_instruction_count()); 76 | } else { 77 | // Setup the program for proving. 78 | let (pk, vk) = client.setup(FIBONACCI_ELF); 79 | 80 | // Generate the proof 81 | let proof = client 82 | .prove(&pk, &stdin) 83 | .run() 84 | .expect("failed to generate proof"); 85 | 86 | println!("Successfully generated proof!"); 87 | 88 | // Verify the proof. 89 | client.verify(&proof, &vk).expect("failed to verify proof"); 90 | println!("Successfully verified proof!"); 91 | } 92 | } 93 | -------------------------------------------------------------------------------- /script/src/bin/vkey.rs: -------------------------------------------------------------------------------- 1 | use sp1_sdk::{include_elf, HashableKey, Prover, ProverClient}; 2 | 3 | /// The ELF (executable and linkable format) file for the Succinct RISC-V zkVM. 4 | pub const FIBONACCI_ELF: &[u8] = include_elf!("fibonacci-program"); 5 | 6 | fn main() { 7 | let prover = ProverClient::builder().cpu().build(); 8 | let (_, vk) = prover.setup(FIBONACCI_ELF); 9 | println!("{}", vk.bytes32()); 10 | } --------------------------------------------------------------------------------