Session creation
High level flow of TrioSession
- Configure/Implement transport layer TrioNetworkClient
- Configure/Implement storage layer StorageClient
- Configure/Implement MessageSigner
- 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 - trio
- We can Create TrioSession by calling SilentShard.ECDSA.trioInitiator() or SilentShard.EdDSA.trioInitiator() (whichever applies) by providing the following parameters
- Provide websocket client by using any of the below options :
- Providing WebsocketConfig object to let SDK use default WebsocketClient i.e. TrioNetworkClient.
- Providing custom TrioNetworkClient overriding(extending) TrioNetworkClient to override existing connect, read or write, etc. methods to add your own logic/configuration or additional process.
- Provide cloud/server public key.
- Provide storage client. (You need to implement the protocol StorageClient).
- Provide message signer. (You need to implement the protocol MessageSigner).
Example
- ECDSA
- EdDSA
Example.swift
import SwiftUI
import trio
struct ContentView: View {
var body: some View {
VStack {
// The demo server, over TLS.
let CLOUD_NODE_URI = "trio-server.demo.silencelaboratories.com"
// Other party verifying-key/public-key. Replace with your own Verifying Key.
let cloudVerifyingKey = "9c4c79e942bbc3ff1d6ace7256404d701498056978cc4638c35832acdf821b1e"
// Create websocketConfig to let SilentShard use the default WebsocketClient.
let websocketConfig = WebsocketConfig(url: CLOUD_NODE_URI, port: 443, isSecure: true)
// Create a storageClient to persist keyshares. The SDK owns keyshare
// storage and addresses every share by its keyId.
let storageClient = CustomStorageClient()
// Create a messageSigner to authenticate protocol messages. For quick-start
// we use the test signer; do not use TestECDSAMessageSigner in production.
// Provide your own MessageSigner backed by the Secure Enclave instead:
// let messageSigner = CustomMessageSigner()
// Create a TrioSession
let trioSession = SilentShard.ECDSA.trioInitiator(
// Do not use TestECDSAMessageSigner in production
messageSigner: TestECDSAMessageSigner(),
cloudVerifyingKey: cloudVerifyingKey,
websocketConfig: websocketConfig,
storageClient: storageClient
)
// or using a custom network client
// let trioSession = SilentShard.ECDSA.trioInitiator(
// messageSigner: TestECDSAMessageSigner(),
// cloudVerifyingKey: cloudVerifyingKey,
// networkClient: CustomNetworkClient(),
// storageClient: storageClient
// )
}
.padding()
}
}
#Preview {
ContentView()
}
Example.swift
import SwiftUI
import trio
struct ContentView: View {
var body: some View {
VStack {
// The demo server, over TLS.
let CLOUD_NODE_URI = "trio-server.demo.silencelaboratories.com"
// Other party verifying-key/public-key. Replace with your own Verifying Key.
let cloudVerifyingKey = "9c4c79e942bbc3ff1d6ace7256404d701498056978cc4638c35832acdf821b1e"
// Create websocketConfig to let SilentShard use the default WebsocketClient.
let websocketConfig = WebsocketConfig(url: CLOUD_NODE_URI, port: 443, isSecure: true)
// Create a storageClient to persist keyshares. The SDK owns keyshare
// storage and addresses every share by its keyId.
let storageClient = CustomStorageClient()
// Create a messageSigner to authenticate protocol messages. For quick-start
// we use the test signer; do not use TestEdDSAMessageSigner in production.
// Provide your own MessageSigner backed by the Secure Enclave instead:
// let messageSigner = CustomMessageSigner()
// Create a TrioSession
let trioSession = SilentShard.EdDSA.trioInitiator(
// Do not use TestEdDSAMessageSigner in production
messageSigner: TestEdDSAMessageSigner(),
cloudVerifyingKey: cloudVerifyingKey,
websocketConfig: websocketConfig,
storageClient: storageClient
)
// or using a custom network client
// let trioSession = SilentShard.EdDSA.trioInitiator(
// messageSigner: TestEdDSAMessageSigner(),
// cloudVerifyingKey: cloudVerifyingKey,
// networkClient: CustomNetworkClient(),
// storageClient: storageClient
// )
}
.padding()
}
}
#Preview {
ContentView()
}
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! 🎉