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

circom-prover spec #299

Open
vivianjeng opened this issue Jan 16, 2025 · 0 comments
Open

circom-prover spec #299

vivianjeng opened this issue Jan 16, 2025 · 0 comments

Comments

@vivianjeng
Copy link
Collaborator

Problem

Related to #224

  1. Current mopro depends on ark-circom version but we need to patch it to get the correct version: zkmopro/circom-compat
    • we replace wasmer with rust-witness. So we remove whole wasmer dependencies in zkmopro/circom-compat
    • There are a lot of problems with wasmer in mobile. Checkout issues
    • See: Circom Comparison for more details
  2. We only use a few functions in mopro and we write prove in mopro with ark-groth16
    • What we use in mopro
      use ark_circom::{
      read_proving_key, read_zkey, CircomReduction, FieldSerialization, ZkeyHeaderReader,
      };
    • how we prove in circom
      let ark_proof = Groth16::<T, CircomReduction>::create_proof_with_reduction_and_matrices(
      &pkey,
      r,
      s,
      &matrices,
      matrices.num_instance_variables,
      matrices.num_constraints,
      witness_fr.as_slice(),
      );
    • We can maintain our own circom-prover to perform these functions.
  3. We have several adapters (now or in the future). We need to easily switch between adapters

We can maintain our own circom-prover for cross-platform solution, and we can publish our packages.
In the future, we can encourage ZK applications (e.g. Semaphore) to use the crate circom-prover instead of circom-compat for cross-platform proving.

Details

Similar to circom-compat
It maintains the functions we need in mopro-ffi

use ark_circom::{
read_proving_key, read_zkey, CircomReduction, FieldSerialization, ZkeyHeaderReader,
};

use ark_circom::ethereum;

It can also export functions called prove, verify
like it does in mopro-ffi
let ark_proof = Groth16::<T, CircomReduction>::create_proof_with_reduction_and_matrices(
&pkey,
r,
s,
&matrices,
matrices.num_instance_variables,
matrices.num_constraints,
witness_fr.as_slice(),
);

let verified = Groth16::<T, CircomReduction>::verify_with_processed_vk(
&pvk,
&public_inputs_fr,
&proof_parsed.0,
)?;

so we can remove duplicated dependencies e.g. ark_groth16, ark_ec in mopro-ffi

Acceptance criteria

  • Create a repo in zkmopro called circom-prover (or other name)
  • replace the ark-circom dependency in mopro-ffi with circom-prover

Next steps (optional)

Publish the crate so we can close #224

@KimiWu123 KimiWu123 moved this to Backlog in Mopro Kanban Jan 17, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Status: Current Milestone
Development

No branches or pull requests

1 participant