W3bstream significantly enhances scalability and trust for dApps where the token economy depends on verifiable processing of real-world data. By providing a decentralized infrastructure to process raw data and generate custom Zero-Knowledge (ZK) Proofs, W3bstream ensures data authenticity and reliability in dApps' token economies.
Dapps looking to utilize W3bstream capabilities should:
A W3bstream project primarily includes the binary code of the a ZK Prover and the destination contract for dispatching proofs. The steps involve first compiling a zk circuit into a prover using one of the supported ZK frameworks, and then generating a W3bstream project file using ioctl command line client.
Start by cloning the W3bstream repository:
git clone https://github.com/machinefi/sprout.git
cd sprout
For more details on creating Halo2 circuits see the Halo2 README.
Install wasm-pack
curl https://rustwasm.github.io/wasm-pack/installer/init.sh -sSf | sh
Write your own circuit following the halo2 development documentation, place it in src/circuits
, adapt the code corresponding to TODO
lines in src/lib.rs
and build the wasm prover with:
cd examples/halo2-circuits/
wasm-pack build --target nodejs --out-dir pkg
The halo2_wasm_bg.wasm
will be located under the pkg
folder.
Generate the W3bstream project file:
# Customize the output project file name "$ID" with a unique number
ioctl ws code convert -t "halo2" -i "halo2_wasm_bg.wasm" -o "path/$ID"
Create the blockchain verifier (Solidity)
target/release/halo2-circuit solidity -f path/filename.sol
For more details on zkWASM circuits see the zkWASM README.
Ensure you have AssemblyScript installed:
npm install -g assemblyscript
Build the circuit:
cd examples/zkwasm-circuits/
asc src/add.ts -O --noAssert -o zkwasm_demo.wasm
Create the verifier
# Work in progress
Generate the W3bstream project:
# Customize the output project file name "$ID" with a unique number
ioctl ws code convert -t "zkwasm" -i "zkwasm_demo.wasm" -o "path/ID"`
More details and options for Risc0 circuit
are given in its README.
Make sure you have cargo 1.7.0 or higher
cargo version
# Update with: rustup update
Install the rustzero toolchain
cargo install cargo-risczero
cargo risczero install
Build the circuit
cd examples/risc0-circuits/
cargo build --release
The path of methods.rs
will be printed to the console, like in the output example below:
warning: methods_path is: "sprout/examples/risc0-circuits/target/release/build/risc0-circuits-5efc4ff59af940ab/out/methods.rs"
Generate the W3bstream Project
ioctl ws code convert -t "risc0" -i "methods.rs" -o "path/filename.json" -e "{\"image_id\":\"RANGE_ID\", \"elf\":\"RANGE_ELF\"}
The values of image_id
and elf
are variable names, and will be found in the methods.rs
file.
Once you have generated a W3bstream project file that includes a custom prover for your dApp, you might want to test it.
Please refer to the OPERATOR GUIDE for instructions on how to:
- Run a W3bstream node locally.
- Copy the W3bstream project file into the node's project directory (default location is ./test/project).
- Run the node and send your test messages.
To allow W3bstream node operators to download your project and compute ZK proofs for your dApp, you must register your W3bstream project on the IoTeX blockchain:
Register your project here → This is still WIP
The projects registration contract address on IoTeX is:
- Mainnet:
To be determined
- Testnet:
To be determined
- ABI:
To be determined