npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

export-ton-verifier

v3.0.0

Published

Tool for generating Groth16 and PLONK verifier code for the TON blockchain from SnarkJS .zkey or verification key JSON files.

Readme

Export TON Verifier

Export TON Verifier is a CLI tool and JavaScript library for generating Groth16 and PLONK (experimental, Circom) smart contract verifiers for the TON blockchain from .zkey, .bin, or .json verification key files.

It integrates with the snarkjs library and supports circuits built with Circom, Noname, Gnark, and Arkworks. The protocol (Groth16 or PLONK) is auto-detected from .zkey and snarkjs-compatible verification_key.json inputs. Groth16 BLS12-381 verification keys are also supported natively from gnark JSON (verification_key_gnark.json), gnark binary (verification_key.bin), and arkworks compressed JSON/bundle files (groth16_artifacts.json or VK-only JSON with curve and vk/verification_key/verifying_key). TON verifier templates use TVM BLS12-381 opcodes, so generated on-chain verifiers require BLS12-381 verification keys. Native gnark and arkworks loaders accept BLS12-381 artifacts only, and snarkjs-compatible inputs are rejected before rendering when their curve is not BLS12-381.

Verifier code can be generated for FunC and Tolk for both Groth16 and PLONK. Tact generation is available for Groth16. Tolk is the default for both Groth16 and PLONK verifier generation; pass --func explicitly when you need FunC output, or --tact for the Tact Groth16 template. TypeScript wrapper templates are selected by language and protocol for import-wrapper and --wrapper-dest.

By default, the Tolk Groth16 template is generated as a flat contract without a verifier receiver struct. If you pass --contract-name <name>, the template switches to struct mode, normalizes names like secondVerifier to SecondVerifier, and emits the getter as verify_<Name>.

Installation

npm install export-ton-verifier

# Help
npx export-ton-verifier --help

Import as a library

import {
  dictFromInputList,
  groth16CompressProof,
  generateVerifier,
  zkeyExportPlonkVerificationKey,
  exportPlonkFuncCalldata,
  exportPlonkTolkCalldata,
  calldataToTupleItems,
  inspectVerifierInput,
  proofToMessageBoc,
  MAX_PLONK_PUBLIC_INPUTS,
} from "export-ton-verifier";

exportPlonkFuncCalldata returns the legacy Func-compatible calldata where public inputs are a dictionary cell. exportPlonkTolkCalldata returns the Tolk getter-compatible calldata where public inputs are already a tuple. inspectVerifierInput powers the doctor command and reports format, protocol, curve, public input count, template availability, and TVM limit checks. proofToMessageBoc converts proof/public-signal JSON into a base64 or hex BOC internal message body for supported generated verifier templates. PLONK verifier generation supports at most MAX_PLONK_PUBLIC_INPUTS public inputs because the TVM Keccak transcript helper is limited to 255 tuple items.

Generated Groth16 verifiers reject non-canonical public inputs outside the BLS12-381 scalar field. Verification keys are checked for valid BLS12-381 points and subgroup membership before generation; core Groth16 key points must also be non-identity.

Internal proof-verification messages for generated FunC, Tolk, and Tact contracts must attach at least 0.05 TON. Getters are unchanged. Both Tolk and FunC PLONK templates support internal verification messages through proofToMessageBoc.

Usage CLI

# From .zkey, Tolk by default for Groth16 and PLONK:
npx export-ton-verifier ./circuits/verifier.zkey ./verifier.tolk

# From verification_key.json (auto-detected by .json):
npx export-ton-verifier ./circuits/verification_key.json ./verifier.tolk

# From native BLS12-381 gnark JSON:
npx export-ton-verifier ./circuits/verification_key_gnark.json ./verifier.tolk

# From native BLS12-381 gnark binary:
npx export-ton-verifier ./circuits/verification_key.bin ./verifier.tolk

# From native BLS12-381 arkworks compressed bundle/VK JSON:
npx export-ton-verifier ./circuits/groth16_artifacts.json ./verifier.tolk

# Generate FunC verifier (requires --func):
npx export-ton-verifier ./circuits/verifier.zkey ./verifier.fc --func

# Generate Tact verifier:
npx export-ton-verifier ./circuits/verifier.zkey ./verifier.tact --tact

# Generate and also drop the TypeScript wrapper:
npx export-ton-verifier ./circuits/verification_key.json ./verifier.tolk --wrapper-dest ./wrappers/ --force

# Generate a named Tolk verifier receiver:
npx export-ton-verifier ./circuits/verifier.zkey ./second-verifier.tolk --contract-name secondVerifier

# Diagnose whether an artifact can be generated for a language:
npx export-ton-verifier doctor ./circuits/verification_key.json --tolk
npx export-ton-verifier doctor ./circuits/verification_key.json --json

# Convert proof/public JSON into an internal message body BOC:
npx export-ton-verifier proof-to-message ./circuits/proof.json ./circuits/public.json --groth16 --tolk
npx export-ton-verifier proof-to-message ./circuits/proof.json ./circuits/public.json --plonk --tolk --format hex --output ./body.hex
npx export-ton-verifier proof-to-message ./circuits/proof.json ./circuits/public.json --plonk --func

# Only copy the TypeScript wrapper (protocol required; Tolk/default selection when language is omitted):
npx export-ton-verifier import-wrapper ./wrappers/ --groth16 --force
npx export-ton-verifier import-wrapper ./wrappers/ --groth16 --func --force
npx export-ton-verifier import-wrapper ./wrappers/ --plonk --force
npx export-ton-verifier import-wrapper ./wrappers/ --plonk --func --force

# Copy both PLONK wrappers without overwriting each other:
npx export-ton-verifier import-wrapper ./wrappers/Verifier_tolk_plonk.ts --plonk --tolk --force
npx export-ton-verifier import-wrapper ./wrappers/Verifier_func_plonk.ts --plonk --func --force

License

GNU GPL v3.0 or later.

This package depends on and includes code derived from snarkJS, which is licensed under GPL-3.0.

References