---
# System prepended metadata

title: zkwasm-host-keccak256

---


## rust keccak256，total guest instructions used 12924
```
安装wasm pack
    cargo install wasm-pack
    cargo install wasm-pack --locked
zkwasm 编译
    git clone -b host-ops-1.6 https://github.com/ethstorage/zkWasm.git
    cd zkWasm
    git submodule update --init	
rust-keccak256 编译
    git clone https://github.com/JustXxx/rust-keccak256
    cd rust-keccak256
    wasm-pack build --release --out-name rust-sdk-test.wasm --out-dir pkg
    cd ..
zkwasm 验证
    cd zkWasm
    cargo run --release -- --function zkmain --output ./output --param ./param --host default --wasm ../rust-keccak256/pkg/rust-sdk-test.wasm dry-run
    cd ..

```
![image](https://hackmd.io/_uploads/ry7zb8RPp.png)


## rust host keccak256，total guest instructions used 8233
```
host-rust-keccak256编译
    git clone https://github.com/JustXxx/rust-host-keccak256.git
    cd rust-host-keccak256
    wasm-pack build --release --out-name rust-sdk-test.wasm --out-dir pkg
    cd ..
zkwasm 验证
    cd zkWasm
    cargo run -- --function zkmain --output ./output --param ./param --host host --wasm ../rust-host-keccak256/pkg/rust-sdk-test.wasm dry-run
    cd ..
```
![image](https://hackmd.io/_uploads/rkWYbIADa.png)

## go keccak256， total guest instructions used 67775184
```
host-rust-keccak256编译
    git clone https://github.com/JustXxx/go-keccak256.git
    cd go-host-keccak256
    sh ./run.sh
    cd ..
zkwasm 验证
    cd zkWasm
    cargo run -- --function zkmain --output ./output --param ./param --host host --wasm ../go-keccak256/keccak256.wasm dry-run
    cd ..
```
![image](https://hackmd.io/_uploads/SkhXS50vT.png)

## go host keccak256， total guest instructions used 67746743
```
host-rust-keccak256编译
    git clone https://github.com/JustXxx/go-host-keccak256.git
    cd go-host-keccak256
    sh ./run.sh
    cd ..
zkwasm 验证
    cd zkWasm
    cargo run -- --function zkmain --output ./output --param ./param --host host --wasm ../go-host-keccak256/keccak256.wasm dry-run
    cd ..
```
![image](https://hackmd.io/_uploads/HJOGGLADT.png)



## optimism host keccak256验证 (由于zkWasm-host-circuits不支持 U8长度非8整除的，所以这里验证未通过)
```
op-program编译
    git clone -b keccak https://github.com/JustXxx/optimism.git
    cd optimism/op-program/
    make op-program-host
    make op-program-client-smoke-test
    make op-program-client
    cd ../..
zkgo编译
    go version
    //输出 go version go1.19.13 linux/amd64
    go clean -cache
    git clone -b wasi https://github.com/ethstorage/go
    cd go/src
    ./all.bash

    cd ../..
go path设置
    unlink  /usr/local/go
    ln -s /XXXXX/go/go /usr/local/go
    go version
    //输出 go version go1.21.0 linux/amd64
op-program wasm
    git clone https://github.com/ethstorage/EthStorage-Grant.git
    cd optimism/op-program/
    cp ../../EthStorage-Grant/preimages-test.bin bin
    make op-program-client-wasm-smoke-test
    make op-program-client-wasm
    
    // 由于已经引入了host的keccak相关函数，函数内容在node中没有，下面步骤无法验证通过
    node ./zkWasm-emulator/wasi/wasi_exec_node.js ./bin/op-program-client-test.wasm ./bin/preimages-test.bin
    cd ../..
编译zkwasm
    git clone -b keccak256_for_op https://github.com/JustXxx/zkWasm.git keccak256_for_op_zkWasm
    cd keccak256_for_op_zkWasm
    git submodule update --init
    cargo build --release
    
    // 由于zkWasm-host-circuits实现和crypto.Keccak256Hash不一致，下面验证不通过
    cargo run --release  -- --function zkmain --output ./output --wasm ../optimism/op-program/bin/op-program-client-test.wasm dry-run --private_file ../optimism/op-program/bin/preimages-test.bin
```