Client-side API
The Valida client-side API enables creating and verifying Valida proofs of execution within the browser. This enables use cases which require proofs to run on the client side in web apps.
To use the Valida client-side API, you can start by copying the example project which is located in the installed toolchain at /valida-toolchain/examples/wasm/client-side-example
.
You will need to embed your guest program (the one whose execution you wish to prove) in your client-side code. You can do this by taking the compiled guest program, base64 encoding it, and ingesting it using Webpack. The compiled guest program is located in target/valida-unknown-baremetal-gnu
. For example, after you run cargo +valida build --release
on your guest program called program
, the compiled guest program is located at target/valida-unknown-baremetal-gnu/release/program
.
Supposing the compiled program is located at ./program
, to base64 encode it, you could run the following command: base64 program >program.base64
.
The example project illustrates how to ingest the compiled, base64-encoded program into a client-side app. This is accomplished using the following rule in webpack.config.js
:
With this rule in place, the base64-encoded program can be imported as simply as:
To import the Valida prover, use a line like:
For this to work, valida-basic-api-wasm
will need to be included in your package.json
. Once you have done this, valida
is an object containing methods with the following type signatures:
Last updated