Nethereum.ZkProofs
7.1.0
Prefix Reserved
dotnet add package Nethereum.ZkProofs --version 7.1.0
NuGet\Install-Package Nethereum.ZkProofs -Version 7.1.0
<PackageReference Include="Nethereum.ZkProofs" Version="7.1.0" />
<PackageVersion Include="Nethereum.ZkProofs" Version="7.1.0" />
<PackageReference Include="Nethereum.ZkProofs" />
paket add Nethereum.ZkProofs --version 7.1.0
#r "nuget: Nethereum.ZkProofs, 7.1.0"
#:package Nethereum.ZkProofs@7.1.0
#addin nuget:?package=Nethereum.ZkProofs&version=7.1.0
#tool nuget:?package=Nethereum.ZkProofs&version=7.1.0
Nethereum.ZkProofs
Provider-agnostic interfaces and models for zero-knowledge proof generation and verification in .NET. This package defines the core abstractions that all Nethereum ZK proof providers implement.
Installation
dotnet add package Nethereum.ZkProofs
Core Interfaces
IZkProofProvider
The central abstraction for proof generation. All providers (browser-based, native, HTTP) implement this interface:
IZkProofProvider provider = ...; // SnarkjsBlazorProvider, RapidSnarkProofProvider, HttpZkProofProvider
var result = await provider.FullProveAsync(new ZkProofRequest
{
CircuitWasm = wasmBytes,
CircuitZkey = zkeyBytes,
InputJson = "{\"nullifier\": \"12345\", \"secret\": \"67890\"}"
});
Console.WriteLine($"Proof: {result.ProofJson}");
Console.WriteLine($"Public signals: {string.Join(", ", result.PublicSignals)}");
ICircuitArtifactSource
Abstracts how circuit artifacts (WASM binaries, proving keys) are loaded:
// From filesystem
ICircuitArtifactSource source = new FileCircuitArtifactSource("./circuits");
byte[] wasm = await source.GetWasmAsync("commitment");
byte[] zkey = await source.GetZkeyAsync("commitment");
// From memory (pre-loaded bytes)
ICircuitArtifactSource embedded = new EmbeddedCircuitArtifactSource(wasmBytes, zkeyBytes);
// From embedded resources (e.g., Nethereum.PrivacyPools.Circuits)
var privacyPools = new PrivacyPoolCircuitSource();
byte[] wasm = await privacyPools.GetWasmAsync("commitment");
ICircuitGraphSource
For native witness generation, circuits can be compiled to a graph format (.graph.bin) instead of WASM:
ICircuitGraphSource graphSource = ...;
if (graphSource.HasGraph("commitment"))
{
byte[] graphData = graphSource.GetGraphData("commitment");
// Pass to WitnessCalculator.CalculateWitness(graphData, inputJson)
}
Models
ZkProofRequest
Input model for proof generation:
| Property | Type | Description |
|---|---|---|
CircuitWasm |
byte[] |
WebAssembly circuit binary |
CircuitZkey |
byte[] |
Proving key (zkey) binary |
InputJson |
string |
JSON-serialized circuit inputs |
WitnessBytes |
byte[] |
Pre-computed witness (.wtns) for native providers |
CircuitGraph |
byte[] |
Circuit graph data for native witness generation |
CircuitName |
string |
Circuit identifier |
Scheme |
ZkProofScheme |
Proof scheme (default: Groth16) |
ZkProofResult
Output model with parsed proof data:
ZkProofResult result = await provider.FullProveAsync(request);
// JSON representations
string proofJson = result.ProofJson; // {"pi_a": [...], "pi_b": [...], "pi_c": [...]}
string signalsJson = result.PublicSignalsJson; // ["12345", "67890", ...]
// Parsed public signals as BigInteger[]
BigInteger commitmentHash = result.PublicSignals[0];
BigInteger nullifierHash = result.PublicSignals[1];
Factory method for creating results from JSON:
var result = ZkProofResult.BuildFromJson(ZkProofScheme.Groth16, proofJson, publicSignalsJson);
ZkProofScheme
public enum ZkProofScheme
{
Unknown = 0,
Groth16 = 1,
Plonk = 2,
Fflonk = 3,
Stark = 4
}
Providers
Built-in: HttpZkProofProvider
Delegates proof generation to a remote HTTP endpoint:
var httpClient = new HttpClient();
var provider = new HttpZkProofProvider(httpClient, "https://prover.example.com/prove");
var result = await provider.FullProveAsync(new ZkProofRequest
{
CircuitWasm = wasmBytes,
CircuitZkey = zkeyBytes,
InputJson = inputJson
});
External Providers
| Package | Provider | Platform | Description |
|---|---|---|---|
Nethereum.ZkProofs.Snarkjs.Blazor |
SnarkjsBlazorProvider |
Browser (Blazor WASM) | JS interop with snarkjs |
Nethereum.ZkProofs.RapidSnark |
RapidSnarkProofProvider |
Desktop/Server | Native C++ via P/Invoke |
Nethereum.ZkProofsVerifier |
N/A (verification only) | All platforms | Pure C# BN128 Groth16 verifier |
Groth16 Utilities
Convert proof JSON to Solidity-compatible format for on-chain verification:
using Nethereum.ZkProofs.Groth16;
var proof = Groth16ProofConverter.ParseProofJson(result.ProofJson);
var (pA, pB, pC) = Groth16ProofConverter.ToSolidityProof(proof);
// pA, pB, pC are ready for Solidity Groth16Verifier.verifyProof(pA, pB, pC, publicSignals)
Circuit Artifact Locator
Resolves filesystem paths following the standard circuit directory layout:
var locator = new CircuitArtifactLocator("./circuits");
string wasmPath = locator.GetWasmPath("commitment"); // ./circuits/commitment/commitment.wasm
string zkeyPath = locator.GetZkeyPath("commitment"); // ./circuits/commitment/commitment.zkey
string vkPath = locator.GetVkPath("commitment"); // ./circuits/commitment/commitment_vk.json
if (locator.HasArtifacts("commitment"))
{
// Both WASM and zkey exist
}
Supported Frameworks
net451, net461, netstandard2.0, net6.0, net8.0, net9.0, net10.0
| Product | Versions Compatible and additional computed target framework versions. |
|---|---|
| .NET | net5.0 was computed. net5.0-windows was computed. 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. |
| .NET Core | netcoreapp2.0 was computed. netcoreapp2.1 was computed. netcoreapp2.2 was computed. netcoreapp3.0 was computed. netcoreapp3.1 was computed. |
| .NET Standard | netstandard2.0 is compatible. netstandard2.1 was computed. |
| .NET Framework | net451 is compatible. net452 was computed. net46 was computed. net461 is compatible. net462 was computed. net463 was computed. net47 was computed. net471 was computed. net472 was computed. net48 was computed. net481 was computed. |
| MonoAndroid | monoandroid was computed. |
| MonoMac | monomac was computed. |
| MonoTouch | monotouch was computed. |
| Tizen | tizen40 was computed. tizen60 was computed. |
| Xamarin.iOS | xamarinios was computed. |
| Xamarin.Mac | xamarinmac was computed. |
| Xamarin.TVOS | xamarintvos was computed. |
| Xamarin.WatchOS | xamarinwatchos was computed. |
-
.NETFramework 4.5.1
- Newtonsoft.Json (>= 13.0.4 && < 14.0.0)
- System.ValueTuple (>= 4.5.0)
-
.NETFramework 4.6.1
- Newtonsoft.Json (>= 13.0.4 && < 14.0.0)
- System.ValueTuple (>= 4.5.0)
-
.NETStandard 2.0
- NETStandard.Library (>= 2.0.3)
- Newtonsoft.Json (>= 13.0.4 && < 14.0.0)
-
net10.0
- Newtonsoft.Json (>= 13.0.4 && < 14.0.0)
-
net6.0
- Newtonsoft.Json (>= 13.0.4 && < 14.0.0)
-
net8.0
- Newtonsoft.Json (>= 13.0.4 && < 14.0.0)
-
net9.0
- Newtonsoft.Json (>= 13.0.4 && < 14.0.0)
NuGet packages (5)
Showing the top 5 NuGet packages that depend on Nethereum.ZkProofs:
| Package | Downloads |
|---|---|
|
Nethereum.ZkProofs.RapidSnark
Nethereum RapidSnark - Native Groth16 proof generation via rapidsnark C library (P/Invoke) |
|
|
Nethereum.PrivacyPools
Nethereum PrivacyPools - 0xbow Privacy Pools protocol SDK with Poseidon commitments, LeanIMT, and Groth16 proof verification |
|
|
Nethereum.PrivacyPools.Circuits
Nethereum PrivacyPools Circuits - Embedded circuit artifacts (wasm, zkey, vk) for Privacy Pools commitment and withdrawal proofs |
|
|
Nethereum.ZkProofs.Snarkjs.Blazor
Nethereum ZkProofs Snarkjs Blazor - Browser-based snarkjs proof generation via JS interop |
|
|
Nethereum.ZkProofs.Snarkjs
Nethereum ZkProofs Snarkjs - Local snarkjs proof provider for desktop/server/CLI (Node.js process or native interop) |
GitHub repositories
This package is not used by any popular GitHub repositories.