Skip to content

Small Powers of Tau Rust code wrapper to be used in browsers for participants' contributions

License

Notifications You must be signed in to change notification settings

zkparty/wrapper-small-pot

Repository files navigation

wrapper-small-pot

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.

 

Rust

Check

To check that the wrapper code is written properly, run:

cargo check --target x86_64-unknown-linux-gnu

Build

To build the wrapper code, run:

cargo build --target x86_64-unknown-linux-gnu

Run

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

Test

To build and run tests, run:

cargo test

 

Wasm

Build

To get the files for integrating the code into Javascript, you can run:

wasm-pack build --target web -d wasm/pkg

Test

To test that the wasm is called correctly in a web setting, you need to:

  1. Have a initialContribution.json file in the /wasm directory. Check an example here

  2. Run a HTTP server: cd wasm && python3 server.py

  3. 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.

Docker

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/.

Building the WASM package

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

Build the Docker image

To rebuild the Docker image after code changes: docker build . -t zkparty/wasm-pack-wrapper.

About

Small Powers of Tau Rust code wrapper to be used in browsers for participants' contributions

Resources

License

Stars

Watchers

Forks

Packages

No packages published