-
Notifications
You must be signed in to change notification settings - Fork 50
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* v0.1.0-alpha * v0.1.0-alpha.2 * circom-prover v0.1.0 * v0.1.1-alpha.0 * fix: fix dependencies * chore: import circom-prover from path * v0.1.1
- Loading branch information
1 parent
f18249d
commit 55a0790
Showing
8 changed files
with
172 additions
and
74 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,87 @@ | ||
# Circom Prover | ||
|
||
Circom prover is a Rust library for generating and verifying proofs for [Circom](https://github.com/iden3/circom) circuits. | ||
It is designed to be used in cross-platform applications, and is compatible with the [Mopro](https://github.com/zkmopro/mopro) library. | ||
|
||
## Usage | ||
|
||
Depends on the witness generation method, build the rust witness function first. | ||
For example, if you use the [Rust Witness](https://github.com/chancehudson/rust-witness), please refer to the [Rust Witness](https://github.com/chancehudson/rust-witness) for more details. | ||
|
||
### Proof Generation | ||
|
||
```rust | ||
use std::collections::HashMap; | ||
rust_witness::witness!(multiplier2); | ||
use circom_prover::{prover::ProofLib, witness::WitnessFn, CircomProver}; | ||
|
||
// Prepare inputs | ||
let mut inputs = HashMap::new(); | ||
inputs.insert("a".to_string(), vec!["1".to_string()]); | ||
inputs.insert("b".to_string(), vec!["2".to_string()]); | ||
|
||
// Prepare zkey path | ||
let zkey_path = "./test-vectors/multiplier2_final.zkey".to_string(); | ||
|
||
// Generate proof | ||
let result = CircomProver::prove( | ||
ProofLib::Arkworks, | ||
WitnessFn::RustWitness(multiplier2_witness), | ||
inputs, | ||
zkey_path, | ||
).unwrap(); | ||
``` | ||
|
||
### Proof Verification | ||
|
||
```rust | ||
// Verify proof | ||
let valid = CircomProver::verify( | ||
ProofLib::Arkworks, | ||
result.proof, | ||
result.pub_inputs, | ||
zkey_path, | ||
).unwrap(); | ||
``` | ||
|
||
### Proof Deserialization | ||
|
||
```rust | ||
use ark_bn254::Bn254; | ||
use circom_prover::{ | ||
prover::{ | ||
serialization::{deserialize_inputs, deserialize_proof}, | ||
}, | ||
}; | ||
let deserialized_proof = deserialize_proof::<Bn254>(result.proof); | ||
let deserialized_pub_inputs = deserialize_inputs::<Bn254>(result.pub_inputs); | ||
``` | ||
|
||
## Adapters | ||
|
||
## Witness Generation | ||
|
||
- [x] [Rust Witness](https://github.com/chancehudson/rust-witness) | ||
- [ ] [Witnesscalc adapter](https://github.com/zkmopro/witnesscalc_adapter) | ||
- [ ] [circom witnesscalc](https://github.com/iden3/circom-witnesscalc) | ||
|
||
## Proof Generation | ||
|
||
- [x] [Arkworks](https://github.com/arkworks-rs) | ||
- [ ] [Rust rapidsnark](https://github.com/zkmopro/rust-rapidsnark) | ||
|
||
## Performance | ||
|
||
It speeds up circom proof by ~100x comparing to [arkworks-rs/circom-compat](https://github.com/arkworks-rs/circom-compat) in keccak256 circuits. | ||
We will provide more benchmarks with different adapters in the future. | ||
And you can also check the [Mopro documentation](https://zkmopro.org/docs/performance) for more benchmarks. | ||
|
||
## Community | ||
|
||
- X account: <a href="https://twitter.com/zkmopro"><img src="https://img.shields.io/twitter/follow/zkmopro?style=flat-square&logo=x&label=zkmopro"></a> | ||
- Telegram group: <a href="https://t.me/zkmopro"><img src="https://img.shields.io/badge/telegram-@zkmopro-blue.svg?style=flat-square&logo=telegram"></a> | ||
- Mopro Documentation: https://zkmopro.org | ||
|
||
## Acknowledgements | ||
|
||
This work is sponsored by [PSE](https://pse.dev/). |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,47 +1,47 @@ | ||
# mopro-ffi | ||
# Mopro FFI | ||
|
||
Mopro is a toolkit for ZK app development on mobile. Mopro makes client-side proving on mobile simple. | ||
`mopro-ffi` is a tool designed to assist programmable cryptography application or rust application developers in efficiently creating bindings for client-side targets. | ||
|
||
## Getting started | ||
Key features include: | ||
|
||
- Make sure you've installed the [prerequisites](https://zkmopro.org/docs/prerequisites). | ||
- Getting started with this [tutorial](https://zkmopro.org/docs/getting-started). | ||
- **Function Serialization and Export:** Enables serialization and export of functions within each proving system. To generate FFI bindings for different targets, inputs and outputs must conform to the specific types defined in [uniffi](https://mozilla.github.io/uniffi-rs/latest/udl/builtin_types.html). | ||
- Supported proving systems: `circom`, `halo2`. | ||
- **Executable Binaries:** Provides pre-built binaries, allowing developers to generate bindings for various targets effortlessly. | ||
- Supported targets: `swift`, `kotlin`. | ||
- **Customize Exported Functions:** Supports the ability to customize the exported functions. Users can define the functions in the `src/mopro.udl` file. | ||
|
||
## Run tests | ||
## Usage | ||
|
||
- circom | ||
```sh | ||
cargo test --features circom | ||
``` | ||
- halo2 | ||
```sh | ||
cargo test --features halo2 | ||
``` | ||
- Please check the [Manual Setup for Android/iOS Bindings](https://zkmopro.org/docs/setup/rust-setup) for integrating `mopro-ffi` into your project. | ||
|
||
## Bindings | ||
## Usage for general Rust application | ||
|
||
- `SwiftBindings` | ||
- `KotlinBindings` | ||
- Integrate the `mopro-ffi` like the above tutorial. | ||
- Update the `src/mopro.udl` file to add the functions you want to export. Check out how to define the functions in UDL file: [UniFFI: The UDL file](https://mozilla.github.io/uniffi-rs/0.28/udl_file_spec.html) | ||
|
||
The uniffi bindings are precompiled and committed here for a specifically named crate. This avoids the complexity of building/invoking the uniffi cli by dependent packages. Note that dependent crates _must_ have the library name `mopro_bindings`, or rebuild the binding themselves. | ||
- E.g. | ||
export Rust function like | ||
```rust | ||
pub fn hello_world() -> String { | ||
"Hello World!".to_string() | ||
} | ||
``` | ||
and define the function in the UDL file like: | ||
```udl | ||
namespace mopro { | ||
// ... | ||
string hello_world(); | ||
} | ||
``` | ||
|
||
## Modules | ||
|
||
The root module exports functions for generating proofs. It also exports a macro that can be used to setup uniffi from our provided udl file. User modification to the UDL file is not supported at this time. | ||
|
||
### `circom` | ||
|
||
Includes all proving and serialization logic for circom proofs. Does _not_ include logic for witness generation. | ||
|
||
### `halo2` | ||
|
||
Includes all proving logic for halo2. | ||
- Run `cargo run --bin ios` or `cargo run --bin android` again. | ||
|
||
## Community | ||
|
||
- X account: <a href="https://twitter.com/zkmopro"><img src="https://img.shields.io/twitter/follow/zkmopro?style=flat-square&logo=x&label=zkmopro"></a> | ||
- Telegram group: <a href="https://t.me/zkmopro"><img src="https://img.shields.io/badge/telegram-@zkmopro-blue.svg?style=flat-square&logo=telegram"></a> | ||
- X account: <a href="https://twitter.com/zkmopro"><img src="https://img.shields.io/twitter/follow/zkmopro?style=flat-square&logo=x&label=zkmopro"></a> | ||
- Telegram group: <a href="https://t.me/zkmopro"><img src="https://img.shields.io/badge/telegram-@zkmopro-blue.svg?style=flat-square&logo=telegram"></a> | ||
- Mopro Documentation: https://zkmopro.org | ||
|
||
## Acknowledgements | ||
|
||
This work was initially sponsored by a joint grant from [PSE](https://pse.dev/) and [0xPARC](https://0xparc.org/). It is currently incubated by PSE. | ||
This work was initially sponsored by a joint grant from [PSE](https://pse.dev/) and [0xPARC](https://0xparc.org/). It is currently incubated by PSE. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.