Skip to content

Commit

Permalink
verifyProof function as view as it does not modify storage (#20)
Browse files Browse the repository at this point in the history
* fix: verifyProof function as view as it does not modify storage

* added instructions to run examples and tests, noted cargo version issue

* fix: add rust-toolchain configuration file to specify rust toolchain version to be used

* ci: install [email protected] for rust 1.77.0 compatibility
  • Loading branch information
dibi91 authored Oct 1, 2024
1 parent f0626be commit 9e99730
Show file tree
Hide file tree
Showing 4 changed files with 29 additions and 2 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ jobs:
cache-on-failure: true

- name: Install solc
run: (hash svm 2>/dev/null || cargo install svm-rs) && svm install 0.8.21 && solc --version
run: (hash svm 2>/dev/null || cargo install svm-rs@0.5.4) && svm install 0.8.21 && solc --version

- name: Run test
run: cargo test --workspace --all-features --all-targets -- --nocapture
Expand Down
25 changes: 25 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,17 @@ let (verifier_solidity, vk_solidity) = generator.render_separately().unwrap();

Check [`examples/separately.rs`](./examples/separately.rs) for more details.

> [!NOTE]
> Currently example run only with rust `1.77.0` version due to a `cargo` update ([rust-lang/rust#123285](https://github.com/rust-lang/rust/issues/123285)).
>
> The `rust` toolchain version is specified in [rust-toolchain.toml](./rust-toolchain.toml) file.
Run example with the following command:

```bash
cargo run --all-features --example separately
```

### Generate verifier and verifying key in a single solidity contract

```rust
Expand All @@ -32,6 +43,20 @@ let calldata = encode_calldata(vk_address, &proof, &instances);

Note that function selector is already included.

## Test

To run tests, use the following command:

```bash
cargo test --workspace --all-features --all-targets -- --nocapture
```

> [!NOTE]
> Currently tests run only with rust `1.77.0` version due to a `cargo` update ([rust-lang/rust#123285](https://github.com/rust-lang/rust/issues/123285)).
>
> The `rust` toolchain version is specified in [rust-toolchain.toml](./rust-toolchain.toml) file.

## Limitations & Caveats

- It only allows circuit with **less or equal than 1 instance column** and **no rotated query to this instance column**.
Expand Down
2 changes: 2 additions & 0 deletions rust-toolchain.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
[toolchain]
channel = "1.77.0"
2 changes: 1 addition & 1 deletion templates/Halo2Verifier.sol
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ contract Halo2Verifier {
{%- endmatch %}
bytes calldata proof,
uint256[] calldata instances
) public returns (bool) {
) public view returns (bool) {
assembly {
// Read EC point (x, y) at (proof_cptr, proof_cptr + 0x20),
// and check if the point is on affine plane,
Expand Down

0 comments on commit 9e99730

Please sign in to comment.