AnonSwap
Remove the fluff, I know what I'm doing, take me to the swap page!

How to Generate and Verify a Zero-Knowledge Proof Locally

• 9 min read • by Kelvin Jones

Conceptual illustration of private arithmetic inputs producing a local proof artifact that a verifier can check without receiving those inputs.

How to Generate and Verify a Zero-Knowledge Proof Locally

A zero-knowledge proof lets a prover convince a verifier that a defined statement is true without disclosing the secret information used to establish it. That is a useful privacy tool, but it is not a general-purpose shield: the statement's public inputs, the application around the proof, and any public blockchain data remain separate questions.

This beginner walkthrough uses the official Circom and snarkjs multiplier example to create and check a deliberately small, local demonstration. You will see which values go into a witness, what the verifier receives, and why a successful check is not a claim that a real crypto workflow is private. This month's Monday article on lattice-based zero-knowledge research covers the research and regulatory context. Wednesday's privacy-engineering article explains why encryption and privacy-enhancing technologies need clear system boundaries.

What you need

  • A computer with a terminal, Node.js 24 LTS, npm, Rust and Cargo installed.
  • Circom 2.2.3 and snarkjs 0.7.6, installed from their official projects.
  • A new working folder and enough disk space for generated ceremony and proof files.
  • Only the sample numbers below. Do not enter a wallet seed, private key, password, identity document, or financial data.

The versions and commands were checked on November 27, 2026, against the Circom 2.2.3 release, the Circom installation and compilation documentation, the snarkjs 0.7.6 release and guide, and Node.js 24.22.3 LTS release notes. Circom is distributed as a Rust compiler; snarkjs requires a recent LTS Node.js and supports Node.js 18 or later. These steps use the documented demo commands with a toy circuit and a demo-only setup.

Why a local proof matters

The privacy benefit is specific. A verifier can check a statement without being sent every secret value behind it. NIST describes a zero-knowledge proof as a way to prove a mathematical statement without revealing information used to establish it. In this example, the inputs stay in the local witness-generation step; the proof and public output are separate files.

That boundary is not the whole system. The machine producing the witness can read the inputs. A verifier receives the proof and public output. An application can also log identifiers or requests, and a public ledger can reveal activity according to the asset's protocol. A proof does not erase those records.

Illustrative diagram: a local learning workflow, not an assurance rating.

Illustrative five-part workflow: define a toy circuit, compile it, generate a local proof, verify it, and review the public output and privacy boundaries.

Generate and verify a toy proof in six steps

1. Create a clean working directory

Open a terminal and make a new folder for this exercise. Keep its artifacts separate from wallet files, project secrets, and real application data.

mkdir snarkjs_example
cd snarkjs_example

These are the directory commands in the snarkjs guide. Check that the compiler and CLI versions are the ones intended before continuing:

circom --version
node -v

Do not continue if a tool is missing or reports an unexpected version. Install Circom using the official instructions; install the pinned snarkjs release with npm install -g snarkjs@0.7.6. That version is pinned by the install command; avoid running commands from a copied, unofficial proof tutorial.

2. Write the example circuit and compile it

The official snarkjs guide uses this arithmetic circuit. Its two inputs are private to the proof, while c is an output. It repeatedly applies the recurrence in the loop; it is a learning example and does not encode a wallet, identity, balance, or compliance condition.

cat <<EOT > circuit.circom
pragma circom 2.0.0;

template Multiplier(n) {
    signal input a;
    signal input b;
    signal output c;

    signal int[n];

    int[0] <== a*a + b;
    for (var i=1; i<n; i++) {
        int[i] <== int[i-1]*int[i-1] + b;
    }

    c <== int[n-1];
}

component main = Multiplier(1000);
EOT

circom --r1cs --wasm --c --sym --inspect circuit.circom
snarkjs r1cs info circuit.r1cs

The compiler emits the constraint system, WebAssembly witness calculator, and symbol data. r1cs info reports the public and private input counts and constraints. The official example has two private inputs and one output. Reading that summary is a useful check that the compiled circuit matches what you intended; it is not a security audit.

3. Prepare the demo-only common parameters

Groth16 requires setup parameters. For this isolated demonstration, run the small Powers of Tau walkthrough shown in snarkjs's own guide. The example beacon value below is published demonstration data: the commands are for learning only and are not secure setup instructions for a real circuit.

snarkjs powersoftau new bn128 14 pot14_0000.ptau -v
snarkjs powersoftau contribute pot14_0000.ptau pot14_0001.ptau --name="Demo contribution" -v
snarkjs powersoftau beacon pot14_0001.ptau pot14_beacon.ptau 0102030405060708090a0b0c0d0e0f101112131415161718191a1b1c1d1e1f 10 -n="Demo beacon"
snarkjs powersoftau prepare phase2 pot14_beacon.ptau pot14_final.ptau -v
snarkjs powersoftau verify pot14_final.ptau

The contribution command prompts for text to add entropy; use only this disposable demo. The final verify checks the transcript. A successful result only means the files passed that tool's checks. It does not turn a single-person classroom example into a trustworthy production ceremony.

4. Create and check a circuit-specific key

Create the initial proving key, make the tutorial's required contribution, add the tutorial beacon, and verify that the final key matches the circuit and common parameters.

snarkjs groth16 setup circuit.r1cs pot14_final.ptau circuit_0000.zkey
snarkjs zkey contribute circuit_0000.zkey circuit_0001.zkey --name="Demo contributor" -v
snarkjs zkey beacon circuit_0001.zkey circuit_final.zkey 0102030405060708090a0b0c0d0e0f101112131415161718191a1b1c1d1e1f 10 -n="Demo final beacon"
snarkjs zkey verify circuit.r1cs pot14_final.ptau circuit_final.zkey
snarkjs zkey export verificationkey circuit_final.zkey verification_key.json

The initial key is not a final proving key. snarkjs explicitly warns not to use it in production. The contribution and beacon here are part of the published demonstration only; don't reuse any generated files or interpret the procedure as guidance for production setup.

5. Generate a witness and proof from sample inputs

Create the sample input file, calculate the witness locally, and ask snarkjs to create the proof and public output. The example uses small, non-sensitive numbers from the official guide.

cat <<EOT > input.json
{"a": "3", "b": "11"}
EOT

snarkjs wtns calculate circuit_js/circuit.wasm input.json witness.wtns
snarkjs wtns check circuit.r1cs witness.wtns
snarkjs groth16 prove circuit_final.zkey witness.wtns proof.json public.json

input.json is the input, witness.wtns contains the circuit's calculated signals, proof.json contains the proof, and public.json contains the public inputs and output. In this sample, the witness is local to the command you run; it is not uploaded by these documented commands. Do not publish the witness or replace the sample with a real secret.

6. Verify the proof and interpret the result

Use the exported verification key and the public output file to check the proof:

snarkjs groth16 verify verification_key.json public.json proof.json

The guide says a successful check prints OK. That confirms only that this proof verifies for this circuit, key, and public output. It does not certify the circuit's design, prove that a real application handled data safely, or make unrelated blockchain transactions private.

Conceptual diagram: the proof's disclosure boundary. The verifier receives public output; network, service, and ledger exposure are outside this isolated command-line test.

Conceptual comparison of private witness data, public proof output, application and network metadata, and public-ledger visibility beyond the proof's scope.

Common mistakes and privacy leaks

  • Treating a valid proof as a complete privacy guarantee. The verifier sees public inputs and outputs, and other system layers may keep records.
  • Using tutorial setup for real value. The demonstration beacon and single-user setup do not establish suitable production parameters or trustworthy ceremony participation.
  • Putting secrets into test files. The witness files and inputs are sensitive to their owner; keep them local and never share seed phrases, private keys, or passwords.
  • Trusting circuit names instead of constraints. A title such as “private balance check” proves nothing unless the circuit correctly constrains the intended statement and is independently reviewed.
  • Confusing network privacy with proof privacy. Tor Browser or onion services affect how a connection is reached; neither changes the circuit's public output or hides public ledger data.

For production work, use a purpose-built, reviewed circuit and an appropriately documented setup, and obtain independent cryptographic review. This walkthrough deliberately does not claim that a toy circuit can establish identity, ownership, solvency, legal status, or a transaction's anonymity.

How AnonSwap fits into the workflow

AnonSwap's published materials describe its swaps as non-custodial and say an account is not required. Those product facts concern asset control and registration; they do not mean AnonSwap generates or verifies the proof in this tutorial. Nor do they imply that a swap conceals public-ledger activity or guarantees anonymity.

If you are evaluating non-custodial swaps as part of a broader crypto privacy plan, separate custody from proof verification and data disclosure. Routing partners, the asset, volume, and local law can affect what a swap requires. A zero-knowledge proof cannot override legal duties, and this educational example should never be used to infer anything about a real swap route.

Your Privacy Checklist for This Week

  • Use only the sample arithmetic values in the local demonstration.
  • Check the Circom, snarkjs, and Node.js versions before running the commands.
  • Confirm which values are private witness data and which are public outputs.
  • Keep generated witness and setup files out of chats, support requests, and public repositories.
  • Treat proof validity as one check—not proof of anonymity, compliance, or application security.

Sources: Circom 2.2.3 release, Circom installation guide, Circom compilation options, snarkjs 0.7.6 release and official tutorial, NIST, Zero-Knowledge Proof, Node.js 24.22.3 LTS release notes, and AnonSwap FAQ. Software versions and official instructions checked November 27, 2026. This article is for informational purposes only and is not legal or financial advice.


Published November 27, 2026. Last updated November 27, 2026.

Frequently asked questions

What does this local zero-knowledge proof demonstrate?

It uses a toy Circom multiplier circuit and snarkjs to generate and verify a proof that a defined arithmetic computation is valid. It is an educational example, not a financial or production circuit.

Does a zero-knowledge proof hide every input and transaction?

No. A proof only protects information not included in its public statement, and it does not hide network metadata, application records, or public-ledger activity.

Which versions were checked for this workflow?

The workflow was checked on November 27, 2026, against Circom 2.2.3, snarkjs 0.7.6, and the Node.js 24 LTS line (24.22.3).

Can I use the demo setup for a real crypto application?

No. The example circuit and local setup are for learning only. Production cryptography requires a correctly designed and audited circuit and an appropriate, independently verifiable setup.