git clone https://github.com/machinefi/sprout.git
cd sprout
- Install
wasm-pack
curl https://rustwasm.github.io/wasm-pack/installer/init.sh -sSf | sh
- Build wasm
cd examples/halo2-circuits/
wasm-pack build --target nodejs --out-dir pkg
you will find halo2_wasm_bg.wasm
under the pkg
folder.
- (Optional) You can also write your circuit according to the halo2 development documentation, and put the circuit file in
src/circuits
; replace theTODO
insrc/lib.rs
and build wasm withwasm-pack build --target nodejs --out-dir pkg
.
More details and options for Halo2 circuit
are given in its README.
- Build
cd examples/risc0-circuits/
cargo build --release
The path of methods.rs
will be printed to the console, like this
warning: methods_path is: "sprout/examples/risc0-circuits/target/release/build/risc0-circuits-5efc4ff59af940ab/out/methods.rs"
More details and options for Risc0 circuit
are given in its README.
- Build
cd examples/zkwasm-circuits/
asc src/add.ts -O --noAssert -o zkwasm_demo.wasm
More details and options for zkWasm circuit
are given in its README.
wsctl code convert -t "halo2" -i "halo2_wasm_bg.wasm"
This command will generate a file named halo2-config.json
in the current folder.
Or you can run wsctl code convert -t "halo2" -i "halo2_wasm_bg.wasm" -o "path/filename.json"
wsctl code convert -t "risc0" -i "methods.rs" -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
.
This command will generate a file named risc0-config.json
in the current folder.
Or you can run wsctl code convert -t "risc0" -i "methods.rs" -o "path/filename.json" -e "{\"image_id\":\"RANGE_ID\", \"elf\":\"RANGE_ELF\"}
wsctl code convert -t "zkwasm" -i "zkwasm_demo.wasm"
This command will generate a file named zkwasm-config.json
in the current folder.
Or you can run wsctl code convert -t "zkwasm" -i "zkwasm_demo.wasm" -o "path/filename.json"