[[ ":$PATH:" != *":$HOME/.bky:"* ]] && export PATH="$PATH:$HOME/.bky"
ln -sf "$HOME/.bky/bky-as-v0.1.0-beta.13" "$HOME/.bky/bky-as"

## Overview

Blocky AS enables secure and verifiable execution of
[WebAssembly (WASM)](https://webassembly.org/) functions. While there exist many
tools for compiling your preferred language (e.g., Go, Rust, C/C++,
Python, JavaScript) down to WASM, our compilation tool does so in a way that
is *reproducible*. Meaning, the same source code will always produce the same
WASM binary. Reproducibility is essential for the TEE attestation and
verification process. Without reproducible builds, we cannot definitively
prove that the application running on a TEE was built with our source code.

## Compile a WASM Function

Follow the steps below to reproducibly compile a Go program with the
[Blocky Compiler](https://github.com/blocky/compiler).

1. Clone the Blocky AS
[examples repository](https://github.com/blocky/attestation-service-examples/tree/release/v0.1.0-beta.13)
and navigate to the `attest_fn_call` directory:
git clone --branch main git@github.com:blocky/attestation-service-examples.git
cd attestation-service-examples/attest_fn_call
2. Here we have a simple Go program, [main.go](https://github.com/blocky/attestation-service-examples/tree/release/v0.1.0-beta.13/attest_fn_call/main.go),
that contains a `helloWorld` function:

3. Compile
[main.go](https://github.com/blocky/attestation-service-examples/tree/release/v0.1.0-beta.13/attest_fn_call/main.go)
to WASM:
bky-c build --reproducible . ./main.wasm
4. Take a "measurement" (i.e., a hash) of the WASM binary:
openssl dgst -sha3-512 ./main.wasm
5. Repeat steps 3 and 4, and you should get the same hash value. This
indicates that our wasm binary is bit-for-bit the same across compilations.


## Next Steps

You have now successfully compiled a Go program to WASM. Continue on to the
next section where we demonstrate how to run your program with the Blocky AS CLI
tool.

rm -rf attestation-service-examples