Skip to main content

Session creation

High level flow of the TrioSession

TrioSession is the main object which will be used to perform all of the MPC operations supported. To create TrioSession please follow the steps below.

Step 1 : Add library to your Project


Step 2 : Create new session


Example


MainActivity.kt
import com.silencelaboratories.silentshard.trio.SilentShard
import com.silencelaboratories.silentshard.trio.TrioSession
import com.silencelaboratories.network.websocket.WebsocketConfig

object Constants {
const val CLOUD_NODE_URI = "192.168.1.16"
const val PORT = "8080"
}

//Other party verifying-key/public-key
val cloudPublicKey = "---------Hex---------"

//Create websocketConfig to let SilentShard use default WebsocketClient.
val websocketConfig = SilentShard.buildWebsocketConfig {
withBaseUrl(CLOUD_NODE_URI)
usingPort(PORT)
isSecureProtocol(false)
}

//Create storageClient instance to manage keyshare states
val storageClient = CustomStorageClient()

//Create trioSession

/*Option: 1 : Using Default WebsocketClient.
We only have to pass websocketConfig which contains the server config and
communication will be handled by internal websocketClient*/
val trioSession: TrioSession = SilentShard.ECDSA.createTrioSession(
cloudPublicKey, websocketConfig, storageClient
)

/*Option: 2 : Using Customised SilentShardWebsocketClient.
ExtendedSilentShardWebsocketClient(example name and You implement) extends SilentShardWebsocketClient(Internally extends WebsocketClient)
from SilentShard. You can
override connect, read, write, etc. according to your configuration.*/
val trioSession: TrioSession = SilentShard.ECDSA.createTrioSession(
cloudPublicKey, ExtendedSilentShardWebsocketClient(), storageClient
)

/*Option: 3 : Using Custom (Your Implementation) WebsocketClient.
CustomWebsocketClient(example name) extends WebsocketClient from SilentShard.
It will have your own httpClient and other customization. In other words, If you wish to write
your own websocket client from scratch.*/
val trioSession: TrioSession = SilentShard.ECDSA.createTrioSession(
cloudPublicKey, CustomWebsocketClient(), storageClient
)
  • CLOUD_NODE_URI is the URI of the cloud node.
  • cloudPublicKey is the cloud verifying key (Ed25519 public key).
    • This public key is used to verify the server's signature on each message
    • See example here
  • SilentShard Provides API for creating MPC TrioSession (Three-Party) using ECDSA algorithm.
  • ECDSA Provides factory methods for creating MPC session using ECDSA algorithm.
  • TrioSession Represents a two-party computation session that lets you perform MPC operations using SilentShard protocol.

You have now successfully set up the session and are ready to start performing MPC actions! 🎉