Zk proof verification

From Nethereum/Nethereum · View interactive version

Zk proof verification is an AI agent skill from the GitHub repository Nethereum/Nethereum. Help users verify Groth16 zero-knowledge proofs from Circom/snarkjs circuits using Nethereum.ZkProofsVerifier (.NET). Use this skill whenever the user mentions ZK proofs, Groth16, snarkjs, Circom, zero-knowledge verification, BN128 pairing, proof.json, verification_key.json, or public.json in a C#/.

How to use this skill

Skill file

ZK Proof Verification — Nethereum.ZkProofsVerifier

When to Use This

Use this skill when a user wants to:

Required Packages

dotnet add package Nethereum.ZkProofsVerifier

Core Concept

Groth16 is the most widely used ZK proof system in Ethereum. Nethereum.ZkProofsVerifier verifies proofs natively in .NET by checking a BN128 elliptic curve pairing equation. It directly consumes the three JSON files that snarkjs produces after proving a Circom circuit.

The recommended entry point is CircomGroth16Adapter.Verify() — a single static method that parses all three JSON files and returns a result. This hides all cryptographic internals (curve points, field extensions, BouncyCastle types) behind a clean API.

One-Liner Verification (Recommended)

using Nethereum.ZkProofsVerifier.Circom;

var proofJson = File.ReadAllText("proof.json");
var vkJson = File.ReadAllText("verification_key.json");
var publicJson = File.ReadAllText("public.json");

var result = CircomGroth16Adapter.Verify(proofJson, vkJson, publicJson);

if (result.IsValid)
    Console.WriteLine("Proof verified!");
else
    Console.WriteLine($"Failed: {result.Error}");

Tamper Detection

Verification rejects any modification to proof, inputs, or VK:

// Wrong public inputs — verification fails
var tamperedPublicJson = "[\"999\"]";
var result = CircomGroth16Adapter.Verify(proofJson, vkJson, tamperedPublicJson);
// result.IsValid == false

Error Messages

| Error | Meaning |

|-------|---------|

| "Proof is null" | Null proof passed |

| "Verification key is null" | Null VK passed |

| "Public inputs array is null" | Null inputs passed |

| "Verification key IC array is empty" | VK has no IC points |

| "Expected N public inputs but got M" | IC length doesn't match inputs + 1 |

| "Pairing check failed" | Proof is invalid (tampered or wrong inputs) |

Key Types

| Type | Purpose |

|------|---------|

| CircomGroth16Adapter | One-liner verification from JSON strings |

| ZkVerificationResult | Result with IsValid and Error properties |

All parsing and cryptographic types (curve points, field extensions, verifier internals) are internal — consumers only interact with CircomGroth16Adapter and ZkVerificationResult.

Supported Formats

Only snarkjs JSON output is supported:

For full documentation, see: https://docs.nethereum.com/docs/consensus-and-cryptography/guide-zk-proof-verification

Use this skill with your AI agent: Open on Skill Issue to copy, download, or add to your library. Works with Claude, ChatGPT, Gemini, Cursor, Windsurf and more.