This project provides a Rust adapter for compiling and linking [Rapidsnark](https://github.com/iden3/rapidsnark) into a native library for target platforms (e.g., mobile devices). It includes macros and functions to facilitate the integration of proof generation into Rust codebases.
## Usage
Include the crate in your `Cargo.toml`:
```toml
[dependencies]
rust-rapidsnark = "0.1.0"
[build-dependencies]
rust-rapidsnark = "0.1.0"
```
It doesn't include the witness generation functions, you need to use one of the following crates to generate the witness:
For example, building witness with `witnesscalc-adapter`:
```rust
witnesscalc_adapter::witness!(multiplier2);
let json_input_string = "{\"a\": [\"2\"], \"b\": [\"3\"]}";;
let wtns_buffer = multiplier2_witness(json_input_string).unwrap();
```
### Calculate the proof
Calculate the proof by using the `groth16_prover_zkey_file_wrapper` function.
It will take a `wtns` bytes array like the output of [witnesscalc](https://github.com/0xPolygonID/witnesscalc) or [snarkjs](https://github.com/iden3/snarkjs).
```rust
let zkey_path = "./test-vectors/multiplier2_final.zkey".to_string();
let proof = rust_rapidsnark::groth16_prover_zkey_file_wrapper(&zkey_path, wtns_buffer).unwrap();
```
### Verify the proof
Verify the proof by using the `groth16_verifier_zkey_file_wrapper` function.
```rust
let vkey = std::fs::read_to_string("./test-vectors/keccak256_256_test.vkey.json")?;
let valid = rust_rapidsnark::groth16_verify_wrapper(