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

Integrate witnesscalc/rapidsnark stack #284

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

Integrate witnesscalc/rapidsnark stack #284

vivianjeng opened this issue Jan 3, 2025 · 0 comments

Comments

@vivianjeng
Copy link
Collaborator

Problem

The latest rapidsnark works much faster than the current mopro stack (rust-witness + ark-works)

See: iden3/rapidsnark#27
It improves the loading zkey time in groth16prove

The benchmark is listed here: https://zkmopro.org/docs/performance/
We should spend more time explore this solution in mopro
to make it easier for developers to integrate witnesscalc, rapidsnark in their apps

Details

witnesscalc

rapidsnark

Steps

  1. Try to integrate in mopro with tools like https://github.com/dtolnay/cxx
    • pros:
      • we can easily switch adapter with different feature flag (e.g. circom-ark-works, circom-rapidsnark)
      • it can be called in other projects if written in Rust (e.g. it can be imported like rapidsnark = "0.1.0" in .toml)
  2. (If we cannot integrate in Rust) Try to use mopro CLI to generate bindings for iOS and Android
    1. Read user specified circuit (the .cpp output and .dat file)
    2. We need to change the CMakeLists.txt to specify the circuit
      e.g. for circuit called cncircuit
      # cncircuit
      set(CNUB_SOURCES ${LIB_SOURCES}
        cncircuit.cpp
        witnesscalc_cncircuit.h
        witnesscalc_cncircuit.cpp
       )
                
       add_library(witnesscalc_cncircuit SHARED ${CNUB_SOURCES})
       add_library(witnesscalc_cncircuitStatic STATIC ${CNUB_SOURCES})
       set_target_properties(witnesscalc_cncircuitStatic PROPERTIES OUTPUT_NAME witnesscalc_cncircuit)
    3. build the library and xcframework (i-iii will be used in mopro build)
      See build_witnesscalc.sh file
    4. build template for witnesscalc/rapidsnark stack (will be used in mopro create)
      See https://github.com/zkmopro/android-benchmark-app
  3. Update documentation
    • Current witnesscalc/rapidsnark stack is not trivial for developers to integrate in iOS/Android
    • We should document this steps or record in a video and shard on YouTube

Acceptance criteria

It can be in several PRs

  1. A script to build witnesscalc frameworks with custom circuits (e.g. multiplier2, keccak256)
  2. Tests to call the witnesscalc and rapidsnark in Rust (mopro-ffi)
  3. If it can be called in Rust, try to build bindings with current mopro e.g.cargo run --bin ios in test-e2e
  4. Add new adapter for mopro build commend (e.g.rapidsnark)
  5. Add new platform for mopro create commend (e.g. rapidsnark)
  6. Update documentation: in setup/rapidsnark setup

Next steps (optional)

If it works well we can remove the ark-works stack

@vivianjeng vivianjeng moved this to In progress in Mopro Kanban Jan 7, 2025
@KimiWu123 KimiWu123 added this to the Milestone1, 6-12 weeks milestone 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: In progress
Development

No branches or pull requests

2 participants