Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Adjust README and clean script #6

Open
wants to merge 3 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 8 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,19 +1,24 @@
# zkWasm-C
## About C template for ZKWASM:
This is a project template for constructing wasm program for ZKWASM using C language.
This is a project template for constructing wasm programs for a ZKWASM environment using the C language.
It contains two directories which are **./sdk** and **./proejct**.
1. sdk directory: Contains basic built-in c libraries and head files.
2. project directory: Contains an example project that can be compiled into a wasm output.

## Usage:
You can modify the code in ./project directory and use **make** to compile the project into output.wasm.

## Building Requirement:
You need clang (better with version 15) to compile and link C code into wasm.
## Building Requirements:
You need [clang](https://github.com/llvm/llvm-project) to compile and link C code into wasm. Recommend version 15 which includes `wasm-ld`.


## Run the output:
The output.wasm file is a standard web assembly image that can be run using any wasm interpreter which provides necessary host functions.
Currently, there are three main scenarios:
1. run the wasm image in a web environment for web games and generates instances for proof generation. (An example can be found at https://github.com/ZhenXunGe/g1024).
2. run the wasm image in a backend environment with zkWASM virtual machine and generate proofs for on-chain verification. (See https://github.com/DelphinusLab/zkWasm for the command line usage of zkWASM virtual machine)
3. run the wasm image in LAYER-TWO that supports zkWASM (currently ZKCross) and let ZCcross do the tedious work of synchronizing and settlement in a cross-chain manner.


## Not necessary but included in make:
`wasm2wat` which can be obtrained [here](https://github.com/WebAssembly/wabt). During `make` from within /sdk/scripts, will output `.wat` files for each ./sdk/c/ subdirectory.
26 changes: 21 additions & 5 deletions sdk/scripts/clean.sh
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,24 @@ TOP_PATH=$SCRIPT_PATH/..

MAKEFILE=$SCRIPT_PATH/Makefile

make clean -C $TOP_PATH/c/sdk/lib -f $MAKEFILE
make clean -C $TOP_PATH/c/rlp/lib -f $MAKEFILE
make clean -C $TOP_PATH/c/hash/lib -f $MAKEFILE
make clean -C $TOP_PATH/c/ecc/lib -f $MAKEFILE
make clean -C $TOP_PATH/c/kvpair/lib -f $MAKEFILE
DIR_SDK_LIB="$TOP_PATH/c/sdk/lib"
DIR_RLP_LIB="$TOP_PATH/c/rlp/lib"
DIR_HASH_LIB="$TOP_PATH/c/hash/lib"
DIR_ECC_LIB="$TOP_PATH/c/ecc/lib"
DIR_KVPAIR_LIB="$TOP_PATH/c/kvpair/lib"

if [ -d "$DIR_SDK_LIB" ]; then
make clean -C $TOP_PATH/c/sdk/lib -f $MAKEFILE
fi
if [ -d "$DIR_RLP_LIB" ]; then
make clean -C $TOP_PATH/c/rlp/lib -f $MAKEFILE
fi
if [ -d "$DIR_HASH_LIB" ]; then
make clean -C $TOP_PATH/c/hash/lib -f $MAKEFILE
fi
if [ -d "$DIR_ECC_LIB" ]; then
make clean -C $TOP_PATH/c/ecc/lib -f $MAKEFILE
fi
if [ -d "$DIR_KVPAIR_LIB" ]; then
make clean -C $TOP_PATH/c/kvpair/lib -f $MAKEFILE
fi