diff --git a/README.md b/README.md index f3287ca7..7c266466 100644 --- a/README.md +++ b/README.md @@ -6,6 +6,21 @@ [![Continuous Integration - proof verification tests](https://github.com/HerodotusDev/cairo-verifier/actions/workflows/proof_verification_tests.yml/badge.svg)](https://github.com/HerodotusDev/cairo-verifier/actions/workflows/proof_verification_tests.yml) +## Table of contents + +- [Prerequisites](#prerequisites) +- [Using Verifier contracts on Starknet](#using-verifier-contracts-on-starknet) +- [Running locally](#running-locally) +- [Creating a Proof](#creating-a-proof) +- [Deployment](#deployment) +- [Split Verifier Architecture](#split-verifier-architecture) + +## Prerequisites + +To use the verifier with contracts deployed on Starknet, you need to have [Rust](https://www.rust-lang.org/tools/install) and [Starknet Foundry](https://foundry-rs.github.io/starknet-foundry/getting-started/installation.html) installed. Also make sure to update [snfoundry.toml](./snfoundry.toml) file with appropriate `account` name and RPC `url`. + +For running locally and development, you will need [scarb](https://docs.swmansion.com/scarb/) (we recommend using [asdf](https://asdf-vm.com/) version manager). + ### Getting example proofs Because of large size of proofs, we don't store example proofs directly in this repository, but rather in [Large File Storage](https://git-lfs.com/), so you need to have it installed and then run `git lfs pull` to get all example proofs. @@ -21,17 +36,15 @@ There are two ways of serializing proof into calldata: monolith and split proof. Calldata for monolith proof can be generated with the following command: ```bash -cargo run --release --bin proof_serializer < examples/proofs/recursive/cairo0_example_proof.json > examples/calldata +cargo run --release --bin proof_serializer < examples/proofs/recursive/cairo0_stone5_keccak_160_lsb_example_proof.json > examples/calldata ``` -Then make sure that you have `sncast` installed and `snfoundry.toml` is configured correctly. - After that, you can use `verify-on-starknet.sh` script to send the transaction to FactRegistry contract. Remember to select appropriate settings for your proof. For more information on supported settings, see [Configure Verifier](#configure-verifier). For example, run: ```bash -./verify-on-starknet.sh 0x7a5340bf1a500d94185cde6fc9cdc4b32c1159d1db5c056841d21bfb0d9c2bd examples/calldata recursive keccak_248_lsb stone5 cairo0 +./verify-on-starknet.sh 0x1c74507b566047b76c625f75d6ea7987fb1e3b3f225c7dd7836bd7381f6ef44 examples/calldata recursive keccak_248_lsb stone5 cairo0 ``` This bash script internally calls `verify_proof_full_and_register_fact` function on FactRegistry contract. @@ -113,6 +126,32 @@ How to prove [Cairo0](https://github.com/starkware-libs/stone-prover?tab=readme- How to prove [Cairo1](https://github.com/starkware-libs/stone-prover?tab=readme-ov-file#creating-and-verifying-a-proof-of-a-cairo-program) program with Stone Prover. +## Deployment + +If you want to deploy the verifier yourself, please follow these steps: + +1. Deploy FactRegistry contract + +```bash +bash deployment/fact_registry/deploy.sh +``` + +2. (optional) Deploy Proxy contract + +```bash +bash deployment/proxy/deploy.sh +bash deployment/proxy/set_fact_registry.sh +``` + +3. Deploy and register Verifier contracts + +Make sure to replace `` and `` with appropriate names. + +```bash +sncast multicall run --fee-token eth --path deployment/verifiers///deploy.toml +bash deployment/verifiers///register.sh +``` + ## Split Verifier Architecture ### Background information diff --git a/deployed_contracts.md b/deployed_contracts.md index 1d7bb25f..c343cef4 100644 --- a/deployed_contracts.md +++ b/deployed_contracts.md @@ -1,11 +1,11 @@ -fact registry: `0x7a5340bf1a500d94185cde6fc9cdc4b32c1159d1db5c056841d21bfb0d9c2bd` -recursive,keccak: `0x0102a5157199bc7929c9f9502aac08b897606bac4e69ba45ecf088b6430e4d6d` -recursive,blake2s: `0x035de2969a164e20bc3872502ff546f7ee190da1c7edf346b4221f869f48128e` -recursive_with_poseidon,keccak: `0x04351acfba77d94cd97bbed2276391ec0e7ffea39ccadb24d1cfd37695b7ab12` -recursive_with_poseidon,blake2s: `0x076eaf28eb342e438ddc80edbdd7ff0624aa5fb0f8068b4386e729d220b2420c` -small,keccak: `0x0453bf62aa81da89b46959a9caf6a9ce4d21bf6c274b6619f1e5ecb769c50762` -small,blake2s: `0x7a624c9c3d7d000d4a8574a7d10478c992e68bab71a731956184a06dd49e2e` -dex,keccak: `0x020800E4129bfCe98C6f7368D23935CB04Cd32BE5a0eD9AE00fAED2952ce961d` -dex,blake2s: `0x027Af71c94C68c8a433ccE0a9BB77fA9e66e9bcCFC009cC01DA7500621609f45` -starknet,keccak: `0x03df89310954C1dD19c941816f99dc96230479B6E16E16479F2C190fb5d57279` (temporary registered as starknet4) -starknet,blake2s: `0x00e0d8c4ccCD8892205fcfA6F0C62F572612e9E1ee68F366B35b05cEbE533cf1` +## Main contracts + +FactRegistry: [0x5e419037d00bc53273574e5e98cdd1c9be025a974ab08382d3052f419756cd8](https://sepolia.voyager.online/contract/0x5e419037d00bc53273574e5e98cdd1c9be025a974ab08382d3052f419756cd8#readContract) + +Proxy: [0x1c74507b566047b76c625f75d6ea7987fb1e3b3f225c7dd7836bd7381f6ef44](https://sepolia.voyager.online/contract/0x1c74507b566047b76c625f75d6ea7987fb1e3b3f225c7dd7836bd7381f6ef44#readContract) + +## Verifiers + +| layout | hasher | address | +| --------- | ------ | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | +| recursive | keccak | [0x05ab958fbb0ee6bdb22bbcdd2f14310332af8b4ae1df6670e6b27f85a164dea9](https://sepolia.voyager.online/contract/0x05ab958fbb0ee6bdb22bbcdd2f14310332af8b4ae1df6670e6b27f85a164dea9#writeContract) | diff --git a/deployment/fact_registry/deploy.sh b/deployment/fact_registry/deploy.sh index 343c9a84..8c2776cd 100644 --- a/deployment/fact_registry/deploy.sh +++ b/deployment/fact_registry/deploy.sh @@ -1,7 +1,7 @@ echo -n "Owner account address: " read OWNER -CLASSHASH=0x5d4c3018e4c829a93bd4ae6c433399172ec33b41d55c61c3c16d708b05fcee9 +CLASSHASH=0x4012cfd3e1d5d7d10bf28ff0865a45572e4016734642adc39d87d5b653f2467 sncast \ deploy \ diff --git a/deployment/proxy/deploy.sh b/deployment/proxy/deploy.sh index a35c9a56..d6c0563c 100644 --- a/deployment/proxy/deploy.sh +++ b/deployment/proxy/deploy.sh @@ -1,7 +1,7 @@ echo -n "Owner account address: " read OWNER -CLASSHASH=0x023158aadc7e83eb968f41d9c747cf1a70bbc22e03244715e4f75855dc2224e8 +CLASSHASH=0x5f5c798412f0f0e9760440a83f86ef5ff08f8de87a7f9de279edc09faa2e8dd sncast \ deploy \