zkmopro / mopro

Making client-side proving on mobile simple.
https://zkmopro.org
Apache License 2.0
131 stars 35 forks source link

Halo2 Early Support Implementation #149

Closed ElusAegis closed 5 months ago

ElusAegis commented 6 months ago

Halo2 configuration

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:

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

ElusAegis commented 5 months ago

@vivianjeng thank you for the review and finding the issues. I have resolved them - ready to have another look

ElusAegis commented 5 months ago

@oskarth the changes to other files out of the scope come due to rebasing to main with MSM PR. Likely as I have merged using IDE rebase vs GitHub built-in rebase they are shown in the preview (https://github.com/orgs/community/discussions/51948), however, if you look into the commit history, they will be shown to have been made by other PRs.

oskarth commented 5 months ago

Right, it just requires a rebase to get a cleaner diff. If you just do it with normal git tools it shouldn't show up in any diff.

I already reviewed and approved PR. Let's wait for @vivianjeng if she had any other comments before merging.

vivianjeng commented 5 months ago

@ElusAegis it still shows

This branch cannot be rebased due to conflicts

maybe some branch got merged again