Nethereum.ZkProofs.RapidSnark 6.1.0

Prefix Reserved
dotnet add package Nethereum.ZkProofs.RapidSnark --version 6.1.0
                    
NuGet\Install-Package Nethereum.ZkProofs.RapidSnark -Version 6.1.0
                    
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="Nethereum.ZkProofs.RapidSnark" Version="6.1.0" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="Nethereum.ZkProofs.RapidSnark" Version="6.1.0" />
                    
Directory.Packages.props
<PackageReference Include="Nethereum.ZkProofs.RapidSnark" />
                    
Project file
For projects that support Central Package Management (CPM), copy this XML node into the solution Directory.Packages.props file to version the package.
paket add Nethereum.ZkProofs.RapidSnark --version 6.1.0
                    
#r "nuget: Nethereum.ZkProofs.RapidSnark, 6.1.0"
                    
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
#:package Nethereum.ZkProofs.RapidSnark@6.1.0
                    
#:package directive can be used in C# file-based apps starting in .NET 10 preview 4. Copy this into a .cs file before any lines of code to reference the package.
#addin nuget:?package=Nethereum.ZkProofs.RapidSnark&version=6.1.0
                    
Install as a Cake Addin
#tool nuget:?package=Nethereum.ZkProofs.RapidSnark&version=6.1.0
                    
Install as a Cake Tool

Nethereum.ZkProofs.RapidSnark

Native Groth16 proof generation for .NET using iden3/rapidsnark. Significantly faster than snarkjs — no Node.js dependency.

Pair with Nethereum.CircomWitnessCalc for a fully native ZK proof pipeline (witness generation + proving, zero JavaScript).

How It Works

RapidSnark is a fast C++ Groth16 prover. It takes a proving key (.zkey) and a witness (.wtns) and outputs a proof. It does NOT generate witnesses — that's handled by Nethereum.CircomWitnessCalc.

This package provides three levels of API:

Class What it does When to use
NativeProofProvider Full pipeline: witness + proof (implements IZkProofProvider) Drop-in replacement for SnarkjsProofProvider
RapidSnarkProofProvider Proof from pre-computed witness (implements IZkProofProvider) When you generate witnesses separately
RapidSnarkProver Low-level P/Invoke prover with reusable zkey Maximum performance, batch proving

Usage

Drop-in replacement for SnarkjsProofProvider. Handles witness generation (via CircomWitnessCalc) and proof generation (via RapidSnark) in one call.

var provider = new NativeProofProvider();

var result = await provider.FullProveAsync(new ZkProofRequest
{
    CircuitZkey = File.ReadAllBytes("circuit.zkey"),
    CircuitGraph = File.ReadAllBytes("circuit.graph.bin"),  // from build-circuit --O1
    InputJson = """{"nullifier":"123","secret":"456","value":"1000","label":"1"}""",
});

Console.WriteLine(result.ProofJson);
Console.WriteLine(result.PublicSignalsJson);

With embedded circuit artifacts

When your circuit source provides both ICircuitArtifactSource and ICircuitGraphSource (e.g. PrivacyPoolCircuitSource), the proof provider automatically uses the graph for native witness generation:

var circuitSource = new PrivacyPoolCircuitSource(); // embeds .zkey + .graph.bin
var proofProvider = new PrivacyPoolProofProvider(new NativeProofProvider(), circuitSource);

// Fully native — no Node.js, no JavaScript
var result = await proofProvider.GenerateRagequitProofAsync(witnessInput);

RapidSnarkProofProvider (pre-computed witness)

When you already have the witness bytes (e.g. from an external witness generator):

var provider = new RapidSnarkProofProvider();

var result = await provider.FullProveAsync(new ZkProofRequest
{
    CircuitZkey = zkeyBytes,
    WitnessBytes = witnessBytes,  // .wtns binary
});

RapidSnarkProver (low-level, reusable zkey)

For batch proving — load the zkey once, prove many times:

using var prover = new RapidSnarkProver();
prover.LoadZkey(zkeyBytes);

var (proof1, public1) = prover.ProveWithLoadedZkey(witness1);
var (proof2, public2) = prover.ProveWithLoadedZkey(witness2);
var (proof3, public3) = prover.ProveWithLoadedZkey(witness3);

Native verification

bool valid = RapidSnarkVerifier.Verify(proofJson, publicSignalsJson, verificationKeyJson);

Supported Platforms

Pre-built native binaries included (from Nethereum/rapidsnark CI and iden3/rapidsnark releases v0.0.8):

Platform Architecture File Size
Windows x64 rapidsnark.dll 3.9 MB
Linux x64 librapidsnark.so 970 KB
Linux arm64 librapidsnark.so 780 KB
macOS x64 librapidsnark.dylib 684 KB
macOS arm64 (Apple Silicon) librapidsnark.dylib 620 KB
Android arm64 librapidsnark.so 2.2 MB

Performance

Measured on Windows x64 with a Groth16 circuit (~3,800 constraints):

Provider Time Notes
SnarkjsProofProvider (Node.js) ~1,638ms Witness + proof via Node.js
NativeProofProvider ~128ms Witness (circom-witnesscalc) + proof (rapidsnark)
RapidSnarkProver (zkey pre-loaded) ~96-105ms Proof only, zkey cached

Both providers produce identical public signals and both proofs verify via Groth16 BN128 pairing check.

Updating Native Binaries

Native binaries are built by the CI workflow at Nethereum/rapidsnark (the windows-support branch adds Windows builds to the upstream CI):

# Download all artifacts from a CI run
gh run download <run-id> -R Nethereum/rapidsnark

# Copy to package runtimes
cp rapidsnark-windows-x86_64/lib/librapidsnark.dll  runtimes/win-x64/native/rapidsnark.dll
cp rapidsnark-linux-x86_64/lib/librapidsnark.so     runtimes/linux-x64/native/
cp rapidsnark-linux-arm64/lib/librapidsnark.so       runtimes/linux-arm64/native/
cp rapidsnark-macOS-arm64/lib/librapidsnark.dylib    runtimes/osx-arm64/native/
cp rapidsnark-macOS-x86_64/lib/librapidsnark.dylib   runtimes/osx-x64/native/
cp rapidsnark-Android/lib/librapidsnark.so            runtimes/android-arm64/native/

Building from Source

All platforms (CI)

The Nethereum/rapidsnark fork (windows-support branch) has a GitHub Actions workflow that builds for Windows, Linux (x64/arm64), macOS (x64/arm64), Android, and iOS. See WINDOWS_BUILD.md in that repo for full details.

Windows (MSYS2/MinGW64)

# Install MSYS2
winget install MSYS2.MSYS2

# In MSYS2 MinGW64 shell:
pacman -S --noconfirm mingw-w64-x86_64-gcc mingw-w64-x86_64-cmake make m4 diffutils tar xz curl

# Clone and build
git clone --recursive https://github.com/Nethereum/rapidsnark.git
cd rapidsnark
git checkout windows-support
./build_gmp.sh windows
make windows_x86_64
# Output: package_windows_x86_64/lib/librapidsnark.dll

Linux / macOS

git clone --recursive https://github.com/iden3/rapidsnark.git
cd rapidsnark
bash build_gmp.sh host        # or macos_arm64, macos_x86_64
make host                     # or macos_arm64, macos_x86_64

Package Relationship

Nethereum.CircomWitnessCalc          Nethereum.ZkProofs.RapidSnark (this)
  |                                    |
  |  graph + inputs --> witness        |  zkey + witness --> proof
  |  (circom-witnesscalc native)       |  (rapidsnark native)
  |                                    |
  +-------- NativeProofProvider -------+
            (combines both into IZkProofProvider)
Package Source Role
Nethereum.CircomWitnessCalc iden3/circom-witnesscalc Native witness generation
Nethereum.ZkProofs.RapidSnark (this) iden3/rapidsnark Native proof generation
Nethereum.ZkProofs IZkProofProvider interface + ZkProofRequest/ZkProofResult

Credits

Product Compatible and additional computed target framework versions.
.NET net6.0 is compatible.  net6.0-android was computed.  net6.0-ios was computed.  net6.0-maccatalyst was computed.  net6.0-macos was computed.  net6.0-tvos was computed.  net6.0-windows was computed.  net7.0 was computed.  net7.0-android was computed.  net7.0-ios was computed.  net7.0-maccatalyst was computed.  net7.0-macos was computed.  net7.0-tvos was computed.  net7.0-windows was computed.  net8.0 is compatible.  net8.0-android was computed.  net8.0-browser was computed.  net8.0-ios was computed.  net8.0-maccatalyst was computed.  net8.0-macos was computed.  net8.0-tvos was computed.  net8.0-windows was computed.  net9.0 is compatible.  net9.0-android was computed.  net9.0-browser was computed.  net9.0-ios was computed.  net9.0-maccatalyst was computed.  net9.0-macos was computed.  net9.0-tvos was computed.  net9.0-windows was computed.  net10.0 is compatible.  net10.0-android was computed.  net10.0-browser was computed.  net10.0-ios was computed.  net10.0-maccatalyst was computed.  net10.0-macos was computed.  net10.0-tvos was computed.  net10.0-windows was computed. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.

NuGet packages

This package is not used by any NuGet packages.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last Updated
6.1.0 120 3/25/2026