David Rusu 632ef6f643 fix: host -fPIC Linux archives from the fork instead of building from source
Building rapidsnark from source in build.rs required cmake/nasm/gmp on every
runner, which the self-hosted CI hosts lack. Instead, host pre-built -fPIC
static archives as a fork GitHub release and download them like before.

- build.rs: reverted to the download-based approach (the PIC archives are built
  on glibc 2.35 so they carry no __isoc23 references; no compat shim needed).
- download_rapidsnark.sh: Linux x86_64/arm64 now download the -fPIC rebuilds
  from this fork's `rapidsnark-pic-*` release; macOS/iOS/Android keep using the
  upstream iden3 archives (which work fine).
- Add .github/workflows/build-pic-archives.yml: builds the -fPIC archives
  (rapidsnark + GMP) inside a glibc-2.35 container and publishes/updates the
  release. Trigger by pushing a `rapidsnark-pic-*` tag or via workflow_dispatch.

Verified locally (glibc-2.35 container): the produced archives link into a
-shared cdylib with rust-lld.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
2026-06-07 11:00:45 -04:00
..
2026-06-05 23:36:59 +02:00
2026-06-05 23:36:59 +02:00

Rust Rapidsnark

Crates.io

This project provides a Rust adapter for compiling and linking 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.

Requirements

Rust toolchain

cargo 1.89.0 (c24e10642 2025-06-23)

Usage

Include the crate in your Cargo.toml:

[dependencies]
rust-rapidsnark = "0.1"

[build-dependencies]
rust-rapidsnark = "0.1"

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:

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 or snarkjs.

let zkey_path = "./test-vectors/multiplier2_final.zkey";
let proof = rust_rapidsnark::groth16_prover_zkey_file_wrapper(zkey_path, wtns_buffer).unwrap();

You can also prove from an in-memory zkey buffer:

let zkey_buffer = std::fs::read("./test-vectors/multiplier2_final.zkey")?;
let proof = rust_rapidsnark::groth16_prover_zkey_buffer_wrapper(&zkey_buffer, &wtns_buffer)?;

Verify the proof

Verify the proof by using the groth16_verify_wrapper function.

let vkey = std::fs::read_to_string("./test-vectors/keccak256_256_test.vkey.json")?;
let valid = rust_rapidsnark::groth16_verify_wrapper(
    &proof.proof,
    &proof.public_signals,
    &vkey,
)?;

Supported platforms

Linux

  • x86_64 linux
  • arm64 linux

MacOS

  • aarch64-apple-darwin
  • x86_64-apple-darwin

iOS

  • aarch64-apple-ios
  • aarch64-apple-ios-sim
  • x86_64-apple-ios

Android

  • aarch64-linux-android
  • x86_64-linux-android

Community

Acknowledgements

  • The project is sponsored by PSE.