https://github.com/argumentcomputer/sphinx-contracts
Solidity contracts for Sphinx (contact: @storojs72)
https://github.com/argumentcomputer/sphinx-contracts
Last synced: 2 months ago
JSON representation
Solidity contracts for Sphinx (contact: @storojs72)
- Host: GitHub
- URL: https://github.com/argumentcomputer/sphinx-contracts
- Owner: argumentcomputer
- Created: 2024-06-19T19:12:22.000Z (almost 2 years ago)
- Default Branch: main
- Last Pushed: 2024-10-29T13:19:15.000Z (over 1 year ago)
- Last Synced: 2024-10-29T15:21:13.260Z (over 1 year ago)
- Language: Solidity
- Homepage:
- Size: 111 KB
- Stars: 0
- Watchers: 6
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# Smart contracts for Sphinx
This repository contains smart contracts required for on-chain verification of [Sphinx](https://github.com/lurk-lab/sphinx) proofs.
To install Solidity contracts in your Foundry project:
```
forge install argumentcomputer/sphinx-contracts@main --no-commit
```
To install Move contracts, add following dependency to your Move.toml file:
```
plonk-core = { git = "https://github.com/argumentcomputer/sphinx-contracts.git", rev = "main", subdir = "move" }
```
and also use `plonk_verifier_addr`
# Updating the contracts
To update the Solidity contracts, just download Sphinx artifacts using specific version and copy *.sol files into `contracts/src`:
```
wget https://sphinx-plonk-params.s3.amazonaws.com/.tar.gz
cp ~/.sp1/circuits/plonk_bn254//*.sol contracts/src/
```
The Move contracts need to be updated manually, by looking at actual Solidity diff.
Usually contracts update is actually a changing of the constants' values.
In order to test the new version of contracts, copy the newly compiled ELF file from [fibonacci integration](https://github.com/argumentcomputer/sphinx/tree/dev/tests/fibonacci/elf)
test to the `sphinx-proof/fibonacci-elf` path of this repository and generate proof using new correspondent sphinx version:
```
RUST_LOG=info cargo run --package sphinx-proof --release
```
then copy-paste output to the relevant places in Move / Solidity tests.
You also need to update manually the version tag in `VERSION()` function and the value of the hash in the `VERIFIER_HASH()` function
from `solidity/src/SphinxVerifier.sol`. In Move contracts the verifier hash is stored in `VERSION_1082_TESTNET` constant from `move/sources/utilities.move` source file.
The first value can be taken directly from [Sphinx](https://github.com/argumentcomputer/sphinx/blob/dev/core/src/lib.rs#L33),
while the second is printed while running `sphinx-proof` program.
Finally, to test updated Solidity contracts:
```
cd solidity
forge test
```
and Move contracts:
```
aptos move compile --named-addresses plonk_verifier_addr=testnet
aptos move test --named-addresses plonk_verifier_addr=testnet
```
Additionally, it is necessary to publish (deploy) Move contract in order to re-use it as a dependency in higher-level project (in Aptos testnet):
```
aptos move publish --named-addresses plonk_verifier_addr=testnet --profile testnet --assume-yes
```