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

@tokamak-zk-evm/qap-compiler

v0.0.2

Published

Library subcircuits for Tokamak zk-EVM

Readme

Tokamak-zk-EVM/qap-compiler

Overview

You can convert your Ethereum transactions into zero-knowledge proofs (zkp) even if you don't know zkp.

This repository provides a library of subcircuits for EVM's basic operations. Combined with Synthesizer in synthesizer package, you can build a zkp circuit specialized for each Ethereum transaction. The transaction specific-circuit will be used as preprocessed input for Tokamak zk-SNARK.

Features

  • Preliminary work for zero-knowledge proof generation and verification
  • Compatible with Ethereum's EVM, which is based on 256-bit words.
  • Combined with Synthesizer, almost any type of transaction can be circuited.

Version

  • In the current version, the subcircuit library is a set of subcircuits for all arithmetic and logical operations in the EVM instruction set.
    • However, we found that the current set is not a minimal basis, since some elements can be expressed as combinations of other elements by Synthesizer.
  • In the next version, we will reduce and optimize the library, which will further accelerates the backend.

Installation

This package requires Circom and nodeJs.

To obtain the latest version, simply require the project using npm:

npm install

Usage

  1. Configure the number of inputs and outputs in buffer subcircuits by changing the variable $N$ in this code (default: $N = 256$).
    • There is no limit to $N$. However, the larger they are, the more time it takes to generate a zkp proof.
    • If $N$ is insufficient, fewer types of Ethereum transactions can be circuited, and the Synthesizer may throw errors for more complicated transactions.
  2. Run the script below in terminal. Windows users will need to use GitBash as their terminal.
./scripts/compile.sh
  1. Check your output library subcircuits

Composition of the subcircuit library

circuits
├── templates
│   ├── 128bit
│   │   ├── adder.circom
│   │   ├── divider.circom
│   │   ├── exp.circom
│   │   └── multiplier.circom
│   ├── arithmetic_func.circom
│   ├── bit_extractor.circom
│   ├── comparators.circom
│   ├── divider.circom
│   └── two_to_the_power_of_n.circom
├── add.circom
├── addmod.circom
├── and.circom
├── buffer.circom
├── byte.circom
├── div.circom
├── eq.circom
├── exp.circom
├── gt.circom
├── iszero.circom
├── load.circom
├── lt.circom
├── mod.circom
├── mul.circom
├── mulmod.circom
├── not.circom
├── or.circom
├── sar.circom
├── sdiv.circom
├── sgt.circom
├── sha3.circom
├── shl.circom
├── shr.circom
├── signextend.circom
├── slt.circom
├── smod.circom
├── sub.circom
├── subexp.circom
└── xor.circom
  • All subcircuits are written Circom language (for details, visit Circom official document.
  • templates: The set of modules and functions frequently used by the sub-circuits. The circuits under 128bit assume to take 128-bit length values.
  • The list of subcircuits does not explicitly mean the compatibility with EVM. Synthesizer will combine these subcircuits to represent all signal processing performed within the EVM. Thus, the EVM-compatiblity depends on Synthesizer, and additions and changes to the subcircuits will be determined based on the needs of the Synthesizer.

Subcircuits design

  • All subcircuits are compatible with the EVM's basic operations on 256-bit words.

    • Due to the nature of finite fields for pairing-friendly elliptic curves (e.g., BN128), Circom supports 254-bit words.
    • So, each input and output of target operations will be split (by Synthesizer) into two 128-bit length values before being applied to the subcircuits.
    • As the result, the subcircuits have twice as many inputs and outputs as target operations.
  • KECCAK256

    • Implementing Keccak hashing directly in a circuit, such as Keccak256-circom, is computationally inefficient, resulting in approximately 151k constraints. Thus, we have chosen not to implement a Keccak circuit. Instead, Synthesizer will buffer subcircuits to emit the KECCAK256 input values from the circuit and reintroduce the KECCAK256 output values back into the circuit. Outside the circuit, the Keccak hash computation can be run by the verifier of the Tokamak-zk SNARK. Find details from Synthesizer Doc.
  • Number of constraints

| Subcircuit name | # of constraints | |-------------|---------------------| | 0x01 ADD | 256 | | 0x02 MUL | 522 | | 0x03 SUB | 256 | | 0x04 DIV | 1054 | | 0x05 SDIV | 4155 | | 0x06 MOD | 1054 | | 0x07 SMOD | 4155 | | 0x08 ADDMOD | 1445 | | 0x09 MULMOD | 2239 | | 0x0A EXP | 7982 | | 0x0B SIGNEXTEND | 2823 | | 0x12 SLT | 520 | | 0x13 SGT | 520 | | 0x1A BYTE | 308 | | 0x1B SHL | 326 | | 0x1C SHR | 325 | | 0x1D SAR | 1063 |

Contributing

We welcome contributions! Please see our Contributing Guidelines for details.

References

Original contribution

  • JehyukJang: Subcircuits planning and consulting
  • pleiadex: Initial subcircuits design and implementation. Script development.
  • jdhyun09: Improvement of EVM-compatability. Constraints optimization.

License

[MPL-2.0]