Mobile Nodes (iOS and Android)

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 run MPC nodes on mobile devices. For iOS and Android, Blockdaemon provides libraries that embed both the TSM SDK and the MPC node itself. This allows you to easily run an MPC node on iOS or Android.

Getting the iOS and Android Libraries

For Android, you will need the library:

https://nexus.sepior.net/repository/libtsmclient/libtsmclientv2-68.0.0.aar

and for iOS:

https://nexus.sepior.net/repository/libtsmclient/libtsmclientv2-68.0.0.framework.tar.gz

This fetches the TSM v68.0.0 libraries. You can see all the versions available here.

Contact our support team for the credentials needed to fetch these libraries.

Usage

Creating an SDK with an embedded MPC node can be done as follows:

let node = TsmNewEmbeddedClient(embeddedNodeConf, embeddedNodeLogConf, &err)
Client node = Tsm.newEmbeddedClient(embeddedNodeConf, embeddedNodeLogConf);

The embeddedNodeConf and embeddedNodeLogConf in the example above contains the configuration for the embedded MPC node. This is very similar to the configuration needed for standard containerized MPC nodes. See this section for more about configuring embedded MPC nodes.

Once the SDK is instantiated, you can do the usual operations on the resulting node, for example:

let sessionConfig = TsmNewSessionConfig(sessionID, TsmNewInt32Array()?.add(0)?.add(1)?.add(2), TsmNewIntBytesMap()?.set(0, v: self.node0PublicKey))                
let keyID = node.ecdsa()?.generateKey(sessionConfig, threshold: 2, curveName: curveName, desiredKeyID: "", error: &err)
SessionConfig sessionConfig = Tsm.newSessionConfig(sessionID, Tsm.newInt32Array().add(0).add(1).add(2), Tsm.newIntBytesMap().set(0, node0PublicKey));
node.ecdsa().generateKey(sessionConfig, threshold, curveName, "")

In this example, the session configuration consists of a sessionID , the public key of Node 0 (the node embedded in the mobile device), and the session includes Node 0, Node 1, and Node2. The MPC session generates a key with a given curveName and threshold.

A Working Example

You can see a working example by checking out the following project:

git clone https://gitlab.com/Blockdaemon/tsm-demo.git

The demo consists of a Builder Vault TSM with three MPC nodes. Node 1 and Node 2 run as backend servers in docker containers. Node 0 runs embedded on either Android or iOS. There is also a backend Go server that is contacted by the mobile device and used to start the backend nodes.

To get started, follow the instructions in the folder tsm-demo/mobile.

Once running, you can step through the functions in the app (seen in the figure to the left). The interactions can be observed through the mobile emulator log, within the node log on the app, and the logs of the builder vault nodes with "docker logs".

The project demonstrates both how an MPC node can run embedded in a library on a mobile device (iOS, Android) and how the MPC node running on the mobile device can be dynamically configured. Thus, your application can have many mobile devices, each with its own key and secret shared among the mobile device and the two server nodes.

See also our mobile node Getting started tutorial.