This wrapper create helper functions to integrate the KZG sequencer crypto library with a web implementation to contribute into the KZG Ceremony.
It previously used Small Powers of Tau but we decided to on with the same code base as the sequencer.
To check that the wrapper code is written properly, run:
cargo check --target x86_64-unknown-linux-gnu
To build the wrapper code, run:
cargo build --target x86_64-unknown-linux-gnu
To build and run the wrapper code and test it using the code inside the main.rs
file, run:
cargo run --release --target x86_64-unknown-linux-gnu
Note: In Ubuntu/Linux you can use target x86_64-unknown-linux-gnu
, in Windows you can use x86_64-pc-windows-msvc
To build and run tests, run:
cargo test
To get the files for integrating the code into Javascript, you can run:
wasm-pack build --target web -d wasm/pkg
To test that the wasm is called correctly in a web setting, you need to:
-
Have a
initialContribution.json
file in the/wasm
directory. Check an example here -
Run a HTTP server:
cd wasm
&&python3 server.py
-
Go to http://localhost:8000/ and input some entropy. Open the devTools to check everything is ok.
In some cases, the wasm-worker.js
might not run and not throw any error. This issue could be caused because the functions in wasm.rs
where not binded correctly.
A Docker image is available, providing an environment in which to build this code.
The image, named zkparty/wasm-pack-wrapper
, can be found in the hub at https://hub.docker.com/.
The WASM package can, of course, be built in your local environment providing you the required Rust toolkit along with wasm-pack
. The Docker image provides the necessary environment, and can be helpful in obtaining a reproducible build.
To make the WASM package folder accessible, you need to map a volume from your local environment to /root/wasm
.
Build the WASM package using a command similar to this: docker run -it --rm -v "</local/path/to/wasm/output/>:/root/wasm/" zkparty/wasm-pack-wrapper
To rebuild the Docker image after code changes:
docker build . -t zkparty/wasm-pack-wrapper
.