Session creation
High level flow of TrioSession
- Configure/Implement transport layer (WebSocketClient)
- Configure/Implement storage layer (StorageClient)
- Create TrioSession
- Perform MPC actions
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
-
Create new xcode project if you haven't.
-
Add SilentShard-Trio SDK using the instructions from the Installation Guide
Step 2 : Create new session
- Import module - silentshardtrio
- Provide websocket client by using any of the below options :
- Providing WebsocketConfig object to let SDK use default WebsocketClient i.e. SilentShardWebsocketClient.
- Providing custom WebsocketClient overriding(extending) SilentShardWebsocketClient to override existing connect, read or write, etc. methods to add your own logic/configuration or additional process.
- Providing custom WebsocketClient (Your Custom WebsocketClient Implementation) by extending WebsocketClient
- Provide cloud/server public key.
- Provide storage client. (You need to implement the interface StorageClient).
Example
- ECDSA
- EdDSA
Example.swift
import silentshardtrio
let CLOUD_NODE_URI = "192.168.1.4"
let PORT = "8080"
//Other party verifying-key/public-key
let cloudPublicKey = "---------Hex---------"
//Create websocketConfig to let SilentShard use default WebsocketClient.
let websocketConfig: silentshardtrio.WebsocketConfig =
WebsocketConfigBuilder()
.withBaseUrl(CLOUD_NODE_URI)
.withPort(PORT)
.withSecure(false)
//If applies
.withAuthenticationToken("")
.build()
//Create storageClient : CustomStorageClient - You implement it by extending StorageClient protocol
let 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*/
let trioSession = SilentShard.ECDSA.createTrioSession(
cloudVerifyingKey: String(cloudVerifyingKey),
websocketConfig: websocketConfig,
storageClient : 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.*/
let trioSession = SilentShard.ECDSA.createTrioSession(
cloudVerifyingKey: String(cloudVerifyingKey),
// `ExtendedSilentShardWebsocketClient` is a example name
websocketClient: ExtendedSilentShardWebsocketClient(),
storageClient : 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.*/
let trioSession = SilentShard.ECDSA.createTrioSession(
cloudVerifyingKey: String(cloudVerifyingKey),
// `CustomWebsocketClient` is a example name
websocketClient: CustomWebsocketClient(),
storageClient : storageClient)
Example.swift
import silentshardtrio
let CLOUD_NODE_URI = "192.168.1.4"
let PORT = "8080"
//Other party verifying-key/public-key
let cloudPublicKey = "---------Hex---------"
//Create websocketConfig to let SilentShard use default WebsocketClient.
let websocketConfig: silentshardtrio.WebsocketConfig =
WebsocketConfigBuilder()
.withBaseUrl(CLOUD_NODE_URI)
.withPort(PORT)
.withSecure(false)
//If applies
.withAuthenticationToken("")
.build()
//Create storageClient : CustomStorageClient - You implement it by extending StorageClient protocol
let 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*/
let trioSession = SilentShard.EdDSA.createTrioSession(
cloudVerifyingKey: String(cloudVerifyingKey),
websocketConfig: websocketConfig,
storageClient : 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.*/
let trioSession = SilentShard.EdDSA.createTrioSession(
cloudVerifyingKey: String(cloudVerifyingKey),
// `ExtendedSilentShardWebsocketClient` is a example name
websocketClient: ExtendedSilentShardWebsocketClient(),
storageClient : 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.*/
let trioSession = SilentShard.EdDSA.createTrioSession(
cloudVerifyingKey: String(cloudVerifyingKey),
// `CustomWebsocketClient` is a example name
websocketClient: CustomWebsocketClient(),
storageClient : storageClient)
CLOUD_NODE_URIis the URI of the cloud node.cloudPublicKeyis 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 (Two-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! 🎉