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

Initial Halo2 support #145

Closed
oskarth opened this issue May 23, 2024 · 3 comments
Closed

Initial Halo2 support #145

oskarth opened this issue May 23, 2024 · 3 comments

Comments

@oskarth
Copy link
Collaborator

oskarth commented May 23, 2024

Problem

Some client-side ZK applications use Halo2. We want to support this.

Details

Most likely Halo2 (KZG) since this is more widely used in the ZK app space.

Should be a new adapter (currently: middleware) with bindings to iOS (e.g.).

@ElusAegis is working on this.

Also see #15

Acceptance criteria

  • Initial Halo2 support through example app
  • Follow up issues cut up
@oskarth oskarth changed the title Initial Halo 2 support Initial Halo2 support May 23, 2024
@oskarth
Copy link
Collaborator Author

oskarth commented May 23, 2024

Feel free to add more details here @ElusAegis

@ElusAegis
Copy link
Contributor

The current state of things:

Situation

As Halo2 is a library, there is no single way how projects can implement their circuits, as opposed to Circom, which fixes the structure.

This implies that either the solution should accept any Rust Halo2 Circuit implementation, which might be infeasible, or limit and provide a structure that must be implemented by the Rust Halo2 Circuit crate.

Current Approach

So far, we have decided to provide a structure on how such Rust Halo2 crates should look, and ask developers to follow the structure, by exposing the 3 required components, while not limiting how exactly they are implemented.

This should be versatile enough to not be limited to any particular implementation, as well as be rigid enough to go well with the current mopro structure.

Halo2 PR (#149)

We currently support Halo2 circuits in an experimental stage. To use Halo2, you need to set the kind to halo2 in the mopro-config.toml file.

[circuit]
kind = "halo2" # Options: circom, halo2
dir = "mopro-core/examples/halo2/halo2-fibonacci" # Directory of the circuit
name = "fibonacci"                # Name of the circuit

The dir should point to the directory where the Halo2 circuit is located. The name should be the name of the circuit.

Note that currently the Halo2 circuit must be a cargo crate, with the package name hardcoded to halo2-circuit. This is due to us swapping out the default implementation of the halo2-ciurcuit crate with the user's circuit during the build process.
This is done using the build.rs script in the mopro-core crate, which changes the path to the default examples/halo2/halo2-fibonacci to $dir. This also requires the name of the package to be halo2-circuit for the substitution to work.

Additionally, the halo2-circuit crate must implement and expose three items, which you can see in the mopro-core/examples/halo2/halo2-fibonacci/src/lib.rs:

  • Circuit - the struct that represents the circuit
  • prove - the function that generates the proof
  • verify - the function that verifies the proof

This is then used by the mopro-core crate to generate the proof and verify it.

@ElusAegis
Copy link
Contributor

@vimwitch should we close this?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants