zkWASM

Prerequisites

NodeJS

-> Ensure you have NodeJS installed.

AssemblyScript

Ensure you have AssemblyScript installed:

npm install -g assemblyscript

Build the prover

Clone the W3bstream repository

Start by cloning the W3bstream repository, where you can start from a template example:

git clone https://github.com/iotexproject/w3bstream.git

Open the folder in a code editor and make the required modifications based on your actual data message and prover logic.

Build the Circuit

Enter the zkWASM circuit folder

cd examples/zkwasm-circuit/circuit

Build the prover with:

asc src/add.ts -O --noAssert -o zkwasm_demo.wasm

The prover binary will be saved in zkwasm_demo.wasm.

Verify a Proof Locally

Using Docker

→ Check out the Getting Started to learn how to generate a local proof inside a local W3bstream node

  1. Execute the docker run command for local verification. Note that the directory where the proof is located needs to be mounted into the image. It's simple, just input the proof file. You can also use the help command to check how to use it.

docker run -v /host/zkwasm-proof.json:/zkwasm-proof.json iotexdev/zkverifier /verifier/zkwasm-circuit verify -p /zkwasm-proof.json

Using the binary

Because a dependency of zkwasm-circuit is still under development and not yet ready for public release, it is recommended to use the Docker image method above for local verification.

Build the Verifier

Run the following command to build the verifier:

cargo build --release

After the command is successful, a zkwasm-circuit executable file will be generated in the target/release directory.

Verify

You can execute the binary file in the target/release directory. To verify a proof, simply provide the proof file as an argument. For more details on usage, you can use the help command.

target/release/zkwasm-circuit verify -p zkwasm-proof.json

zkwasm currently supports single proof verification only.

Last updated

Logo

This documentation portal is currently undergoing updates to align with the IoTeX 2.0 Whitepaper release. Information provided here may be incomplete, or out-of-date. Please use this portal for preliminary reference only, and check out the official IoTeX 2.0 Whitepaper for updated information.

.

2024 | IoTeX