Skip to main content

Session creation

High level flow of 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


  1. Provide websocket client by using any of the below options :
  2. Provide cloud/server public key.
  3. Provide storage client. (You need to implement the protocol StorageClient).
  4. Provide message signer. (You need to implement the protocol MessageSigner).

Example


Example.swift
```swift showLineNumbers title="Example.swift"
import SwiftUI
import trioinitiator
import Combine

struct ContentView: View {

var body: some View {
VStack {

let CLOUD_NODE_URI = "wss://trio-server.demo.silencelaboratories.com"

//Other party verifying-key/public-key
let cloudVerifyingKey = "9c4c79e942bbc3ff1d6ace7256404d701498056978cc4638c35832acdf821b1e"

//Create websocketConfig to let SilentShard use default WebsocketClient.
let websocketConfig = WebsocketConfig(
url: CLOUD_NODE_URI,
)

//Create storage client instance to manage keyshare state
let storageClient = CustomStorageClient()

//Create duoSession

/*
We only have to pass websocketConfig which contains the server config and
communication will be handled by internal websocketClient*/
let duoSession = SilentShard.ECDSA.createTrioSession(
messageSigner: TestECDSAMessageSigner(),
cloudVerifyingKey: String(
cloudVerifyingKey
),
websocketConfig: websocketConfig,
storageClient: storageClient
)
/*
//or for EdDSA algorithm
let duoSession = SilentShard.EdDSA.createDuoSession(
messageSigner: TestECDSAMessageSigner(),
cloudVerifyingKey: String(cloudVerifyingKey),
websocketConfig: websocketConfig,
storageClient: storageClient)
*/

}
.padding()
}
}

#Preview {
ContentView()
}
  • 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 (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! 🎉