What is Synthesizer?

Synthesizer is a compiler that processes an Ethereum transaction and returns a wire map. This wire map serves as preprocessed input for Tokamak zk-SNARK.

Input and output of Synthesizer

Input and output of Synthesizer

The prover and verifier of Tokamak zk-SNARK require a zk circuit to initiate an argument. In general, zk circuits translate general programs into a ZKP-compatible language. In our context, Synthesizer translates Ethereum transactions into transaction-specific zk circuits (referred to simply as circuits).

Suppose a predefined library of subcircuits is provided. A circuit is then constructed by placing copies of these subcircuits and connecting their input and output wires. The wire map generated by Synthesizer is in the form of a permutation map, describing the wire connections between these placements. A more rigorous definition of Synthesizer is provided in the paper.

Figure from the paper

Figure from the paper

Figure from the paper

Figure from the paper

We anticipate that the subcircuits in our prepared library are sufficient to represent all signal processing performed within the EVM, with the exception of the Keccak function. As a result, the resulting circuit—constructed as a combination of these subcircuits—is expected to handle all kinds of Ethereum transactions.

If we encounter an unexpected transaction that cannot be represented using our current library, new subcircuits can be added as needed by us or external contributors. For instance, this was the case with the EXP instruction, which will be explained later.

However, we have chosen not to implement a Keccak circuit due to efficiency concerns (see the section “Arithmetic, comparison, and bitwise logic operations” for further details).

Where can I get the input?

You can retrieve Ethereum transactions from Etherscan.io. Simply copy a transaction’s bytecode and provide it to Synthesizer.

In the future, we plan to enhance the user experience by allowing users to fetch bytecodes directly from Etherscan’s API using only the transaction ID.

We offer a Git repository containing a library of basic subcircuits. These subcircuits support EVM arithmetic and logical operations for 256-bit words. The subcircuits can be compiled into the R1CS format using Circom, making them compatible with Synthesizer. You don’t need to be familiar with Circom. Simply ensure that Circom is installed on your system and run the following shell script:

circom-ethereum-opcodes/scripts/compile.sh

This script generates the files subcircuit0.wasm through subcircuit29.wasm, as well as globalWireList.ts, and subcircuitInfo.ts. These files are then used as input for Synthesizer.

Where does the output go?

Synthesizer behaves as a front-end compiler for Tokamak zk-EVM. The diagrams below illustrate the overall signal flow of Tokamak zk-SNARK: