Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Autogenerated script #154

Merged
merged 26 commits into from
Sep 23, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[workspace]
resolver = "2"
members = ["runner", "benches", "examples/starknet"]
members = ["runner", "benches", "serializer"]

[workspace.package]
edition = "2021"
Expand Down
28 changes: 28 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,32 @@

## Using Verifier contracts on Starknet

Integrity verifier is deployed on Starknet and can be used for verifying proofs onchain. The intended way of using the verifier is through FactRegistry contract, which besides running the verification process, also stores data for all verified proofs. (For more information see [FactRegistry and Proxy contract](#factregistry-and-proxy-contract))

There are two ways of serializing proof into calldata: monolith and split proof. The former should be used if possible, because it's easier and more efficient. The latter should only be used if monolith proof did not fit in a single transaction, either because of calldata limit or steps limit.

### Monolith 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
```

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 [Verifier settings](TODO).

For example, run:

```bash
./verify-on-starknet.sh 0x7a5340bf1a500d94185cde6fc9cdc4b32c1159d1db5c056841d21bfb0d9c2bd examples/calldata recursive keccak_248_lsb stone5 cairo0
```

### Split proof

TODO: check if below is valid

To use the Verifier for verifying proofs on starknet, you need to generate calldata for your proof. The easiest way to do that is to use [Calldata Generator](https://github.com/HerodotusDev/integrity-calldata-generator). It also provides script for automatic transaction sending (proof verification is split into multiple transactions, for more information see [Split Verifier Architecture](#split-verifier-architecture)).

## Running locally
Expand Down Expand Up @@ -91,3 +117,5 @@ After proof is verified, `FactRegistered` event is emitted which contains `fact_
- `get_all_verifications_for_fact_hash(fact_hash)` - returns list of all verification hashes, security bits and settings for given `fact_hash`. This method is useful for checking if given program has been verified by someone with secure enough proof.

FactRegistry contract is trustless which means that owner of the contract can't override or change any existing behavior, they can only add new verifiers. Proxy contract on the other hand is upgradable, so every function can be changed or removed. It has the advantage of having all future updates of the verifier logic without having to replace the address of FactRegistry contract.

TODO: how to read FactRegistered event
25 changes: 11 additions & 14 deletions deployed_contracts.md
Original file line number Diff line number Diff line change
@@ -1,14 +1,11 @@
| Contract Address | Network | Layout |
|-----------------------------------------------------------------------------------------------------|-----------------------|--------------------------------|
| | **Mainnet** | **dex** |
|[0x030b6af9526e7ff98bb926f1537c2898060071df91eb7992961a891194c74fce](https://starkscan.co/contract/0x030b6af9526e7ff98bb926f1537c2898060071df91eb7992961a891194c74fce) | **Mainnet** | **recursive** |
| | **Mainnet** | **recursive_with_poseidon** |
| | **Mainnet** | **small** |
| | **Mainnet** | **starknet** |
| | **Mainnet** | **starknet_with_keccak** |
| | **Sepolia Testnet** | **dex** |
|[0x274d8165a19590bdeaa94d1dd427e2034462d7611754ab3e15714a908c60df7](https://sepolia.starkscan.co/contract/0x274d8165a19590bdeaa94d1dd427e2034462d7611754ab3e15714a908c60df7) | **Sepolia Testnet** | **recursive** |
| | **Sepolia Testnet** | **recursive_with_poseidon** |
| | **Sepolia Testnet** | **small** |
| | **Sepolia Testnet** | **starknet** |
| | **Sepolia Testnet** | **starknet_with_keccak** |
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`
3 changes: 0 additions & 3 deletions examples/starknet/.gitignore

This file was deleted.

28 changes: 0 additions & 28 deletions examples/starknet/1-verify-proof.sh

This file was deleted.

13 changes: 0 additions & 13 deletions examples/starknet/Scarb.toml

This file was deleted.

4 changes: 0 additions & 4 deletions examples/starknet/snfoundry.toml

This file was deleted.

2 changes: 1 addition & 1 deletion multicall/fact_registry/deploy.sh
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
echo -n "Owner account address: "
read OWNER

CLASSHASH=0x00b80ebfe09f5400d6e7fe49526d088b45f8bb0831c7262901f4d66c6aa03cf4
CLASSHASH=0x5d4c3018e4c829a93bd4ae6c433399172ec33b41d55c61c3c16d708b05fcee9

sncast \
deploy \
Expand Down
13 changes: 13 additions & 0 deletions multicall/verifiers/dex/blake2s/deploy.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
[[call]]
call_type = "deploy"
class_hash = "0x222a0fb4bf5695fe80975e37add33aa0d52d21f71b802ebb3e2a3f9d968c1b1"
inputs = []
id = "contract_oods"
unique = false

[[call]]
call_type = "deploy"
class_hash = "0x48e1e2ad0709e4d82bca3aca0f69a73d9e00c00fdc00d6bb46d40bf45fba9f7"
inputs = ["0", "contract_oods"]
id = "cairo_verifier"
unique = false
Original file line number Diff line number Diff line change
Expand Up @@ -9,4 +9,4 @@ sncast \
--fee-token eth \
--contract-address $FACT_REGISTRY \
--function "register_verifier" \
--calldata "0x726563757273697665 0x6b656363616b5f3136305f6c7362 0x73746f6e6535 $VERIFIER"
--calldata "0x646578 0x626c616b653273 $VERIFIER"
13 changes: 13 additions & 0 deletions multicall/verifiers/dex/keccak/deploy.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
[[call]]
call_type = "deploy"
class_hash = "0x0222a0fb4bf5695fe80975e37add33aa0d52d21f71b802ebb3e2a3f9d968c1b1"
inputs = []
id = "contract_oods"
unique = false

[[call]]
call_type = "deploy"
class_hash = "0x39c69f3b9aeeed25ee23a137a308e6a91dc0816afba87d485d8f38f9292cfc8"
inputs = ["0", "contract_oods"]
id = "cairo_verifier"
unique = false
Original file line number Diff line number Diff line change
Expand Up @@ -9,4 +9,4 @@ sncast \
--fee-token eth \
--contract-address $FACT_REGISTRY \
--function "register_verifier" \
--calldata "0x726563757273697665 0x626c616b6532735f3136305f6c7362 0x73746f6e6535 $VERIFIER"
--calldata "0x646578 0x6b656363616b $VERIFIER"
6 changes: 6 additions & 0 deletions multicall/verifiers/recursive/blake2s/deploy.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
[[call]]
call_type = "deploy"
class_hash = "0x31630a16a1c09228401fd6189a6e221000fd9ef24fb6311d05c7b30a061e0e1"
inputs = ["0", "0"]
id = "cairo_verifier"
unique = false
12 changes: 12 additions & 0 deletions multicall/verifiers/recursive/blake2s/register.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
echo -n "FactRegistry address: "
read FACT_REGISTRY

echo -n "Verifier address: "
read VERIFIER

sncast \
invoke \
--fee-token eth \
--contract-address $FACT_REGISTRY \
--function "register_verifier" \
--calldata "0x726563757273697665 0x626c616b653273 $VERIFIER"
20 changes: 0 additions & 20 deletions multicall/verifiers/recursive/blake2s_160_lsb/deploy.toml

This file was deleted.

6 changes: 6 additions & 0 deletions multicall/verifiers/recursive/keccak/deploy.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
[[call]]
call_type = "deploy"
class_hash = "0x3396605da48067a08a338c05c6df08a8dca55fdc8317f4c904b8a212b46880d"
inputs = ["0", "0"]
id = "cairo_verifier"
unique = false
12 changes: 12 additions & 0 deletions multicall/verifiers/recursive/keccak/register.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
echo -n "FactRegistry address: "
read FACT_REGISTRY

echo -n "Verifier address: "
read VERIFIER

sncast \
invoke \
--fee-token eth \
--contract-address $FACT_REGISTRY \
--function "register_verifier" \
--calldata "0x726563757273697665 0x6b656363616b $VERIFIER"
20 changes: 0 additions & 20 deletions multicall/verifiers/recursive/keccak_160_lsb/deploy.toml

This file was deleted.

13 changes: 13 additions & 0 deletions multicall/verifiers/recursive_with_poseidon/blake2s/deploy.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
[[call]]
call_type = "deploy"
class_hash = "0x5cae9f970c8da62a83193d7faefdeac3b419ff698badd4f5d502d5b11beb74f"
inputs = []
id = "contract_oods"
unique = false

[[call]]
call_type = "deploy"
class_hash = "0x25f00f5bbba6f1acba0bbd447b3c6c5fc170aac4cdb0dc9aa5072b0f4ae12df"
inputs = ["0", "contract_oods"]
id = "cairo_verifier"
unique = false
12 changes: 12 additions & 0 deletions multicall/verifiers/recursive_with_poseidon/blake2s/register.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
echo -n "FactRegistry address: "
read FACT_REGISTRY

echo -n "Verifier address: "
read VERIFIER

sncast \
invoke \
--fee-token eth \
--contract-address $FACT_REGISTRY \
--function "register_verifier" \
--calldata "0x7265637572736976655f776974685f706f736569646f6e 0x626c616b653273 $VERIFIER"
13 changes: 13 additions & 0 deletions multicall/verifiers/recursive_with_poseidon/keccak/deploy.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
[[call]]
call_type = "deploy"
class_hash = "0x05cae9f970c8da62a83193d7faefdeac3b419ff698badd4f5d502d5b11beb74f"
inputs = []
id = "contract_oods"
unique = false

[[call]]
call_type = "deploy"
class_hash = "0x8c8f78c23dc076ed1e2211724e7742f6c9e4282d105050d93c4c94c2e9dec7"
inputs = ["0", "contract_oods"]
id = "cairo_verifier"
unique = false
12 changes: 12 additions & 0 deletions multicall/verifiers/recursive_with_poseidon/keccak/register.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
echo -n "FactRegistry address: "
read FACT_REGISTRY

echo -n "Verifier address: "
read VERIFIER

sncast \
invoke \
--fee-token eth \
--contract-address $FACT_REGISTRY \
--function "register_verifier" \
--calldata "0x7265637572736976655f776974685f706f736569646f6e 0x6b656363616b $VERIFIER"
13 changes: 13 additions & 0 deletions multicall/verifiers/small/blake2s/deploy.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
[[call]]
call_type = "deploy"
class_hash = "0x6df5e737f0bd804425b50206f073b5677e236c5e705847c8bbda03eae9824d1"
inputs = []
id = "contract_oods"
unique = false

[[call]]
call_type = "deploy"
class_hash = "0x118a94aa61d589d56c3c9663f0099b8f026e17003257231c833edeb3b44379"
inputs = ["0", "contract_oods"]
id = "cairo_verifier"
unique = false
12 changes: 12 additions & 0 deletions multicall/verifiers/small/blake2s/register.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
echo -n "FactRegistry address: "
read FACT_REGISTRY

echo -n "Verifier address: "
read VERIFIER

sncast \
invoke \
--fee-token eth \
--contract-address $FACT_REGISTRY \
--function "register_verifier" \
--calldata "0x736d616c6c 0x626c616b653273 $VERIFIER"
13 changes: 13 additions & 0 deletions multicall/verifiers/small/keccak/deploy.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
[[call]]
call_type = "deploy"
class_hash = "0x06df5e737f0bd804425b50206f073b5677e236c5e705847c8bbda03eae9824d1"
inputs = []
id = "contract_oods"
unique = false

[[call]]
call_type = "deploy"
class_hash = "0x2625a3ff36886d04eb41cc4d43119adefd2f8c4770c1c7c6ddb9385a788e82f"
inputs = ["0", "contract_oods"]
id = "cairo_verifier"
unique = false
12 changes: 12 additions & 0 deletions multicall/verifiers/small/keccak/register.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
echo -n "FactRegistry address: "
read FACT_REGISTRY

echo -n "Verifier address: "
read VERIFIER

sncast \
invoke \
--fee-token eth \
--contract-address $FACT_REGISTRY \
--function "register_verifier" \
--calldata "0x736d616c6c 0x6b656363616b $VERIFIER"
13 changes: 13 additions & 0 deletions multicall/verifiers/starknet/blake2s/deploy.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
[[call]]
call_type = "deploy"
class_hash = "0x06c41c76977bf08e33624ed3c01e2cc79922671c120af74795b5e2f8633d7a99"
inputs = []
id = "contract_composition"
unique = false

[[call]]
call_type = "deploy"
class_hash = "0x1a7cb266115b32c99acc1d503b104de1ca7ff721cdb56f2f3068dc0cd05a6af"
inputs = ["contract_composition", "0"]
id = "cairo_verifier"
unique = false
Loading
Loading