Browser Nodes (wasm)

An MPC node is usually run as a containerized server in Docker or Kubernetes. In the previous sections, we assumed that the MPC nodes were running as servers.

However, it is also possible to embed an MPC node and its SDK in a browser using WebAssembly (WASM).

You can download the Builder Vault WASM SDK, which contains an embedded MPC node, like this:

curl -u ${NEXUS_USERNAME}:${NEXUS_PASSWORD} \
	--output sdkv2wasm.tar.gz \
	https://nexus.sepior.net/repository/libtsmclient/sdkv2wasm-73.0.0.tar.gz
tar xf sdkv2wasm.tar.gz

This requires that you have credentials to our Nexus repository. Contact Blockdaemon support to get access.

Once unpacked, you will see something like this:

sdkv2.wasm		
wasm_exec.js
wasm_exec_browser.js
wasm_exec_deno.js
tests:
  aes.test.js
  authentication.test.js
  embeddednode.test.js
  ...

You can see how to run with an embedded node in the test embeddednode.test.js:

let TSM = await LoadTSM('./sdkv2.wasm')
const config = Deno.readTextFileSync('./mpc_node_config.toml');
let embeddedClient = await new TSM.EmbeddedClient(config, "");
📘

Running an MPC Node Securely in a Browser

When running an MPC node embedded in a browser, it's important to protect the sensitive parts of the MPC node configuration, such as the master encryption password. Consider encrypting these values using for example PassKey.