The Blocky AS CLI allows you to send WebAssembly (WASM) functions for execution on a TEE in a serverless compute model. The Blocky AS TEE server returns an attestation document, which can be used to verify the correct execution of your function and its output.
Follow the steps below to run the program you compiled from the previous section.
The
bky-as attest-fn-callcommand expects a JSON object as input. This object must contain the location of the WASM binary and the name of the function to invoke. An example of this can be seen in fn-call.json:{ "code_file": "main.wasm", "function": "helloWorld" }Run our
helloWorldfunction and save the resulting output toout.json:cat fn-call.json | bky-as attest-fn-call > out.jsonThere are several objects returned by the Blocky AS server, but for now we are only going to look at those related to the inputs and outputs of our function:
which outputsjq -r '.transitive_attested_function_call.claims' out.json{ "hash_of_code": "9f644e9815fd94b44a0376718563353376b99feafd8fafe8ba1f59e746e073ea16388afb9be633566158dc62bc472ab8eaa39e44d4e0702797be34bc04f61fec", "function": "helloWorld", "hash_of_input": "a69f73cca23a9ac5c8b567dc185a756e97c982164fe25859e0d1dcc1475c80a615b2123af1f5f94c11e3e9402c3ac558f500199d95b6d3e301758586281dcd26", "output": "SGVsbG8sIFdvcmxkIQ==", "hash_of_secrets": "a69f73cca23a9ac5c8b567dc185a756e97c982164fe25859e0d1dcc1475c80a615b2123af1f5f94c11e3e9402c3ac558f500199d95b6d3e301758586281dcd26" }Notice that
hash_of_codematches the hash value we calculated for our WASM binary in the previous section! Thus, we know the Blocky AS server ran our WASM binary exactly as we compiled it. Additionally, there are hash values for identifying any inputs and secrets provided to the function, which we can use to confirm that our inputs and secrets were unmodified. If no input or secret is passed, then a hash of an empty array is used instead.Extract and decode our function's output:
which outputsjq -r '.transitive_attested_function_call.claims.output | @base64d' out.jsonHello, World!
At this point, you can now reproducibly build and run WASM functions on TEEs! Continue to the next section to learn about verifying your function output with the attestation information returned by the Blocky AS.