Session creation
High level flow of DuoSession
- Configure/Implement transport layer DuoNetworkClient
- Configure/Implement storage layer BaseStorageClient
- Configure/Implement MessageSigner
- Create DuoSession
- Perform MPC actions
DuoSession is the main object which will be used to perform all of the MPC operations supported. To create DuoSession please follow the steps below.
Step 1 : Add library to your Project
-
Create new xcode project if you haven't.
-
Add SilentShard-Duo SDK using the instructions from the Installation Guide
Step 2 : Create new session
- Import module - duoinitiator.
- We can Create DuoSession by calling SilentShard.ECDSA.createDuoSession() or SilentShard.EdDSA.createDuoSession() (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 NetworkClient i.e. DuoNetworkClient.
- Providing custom NetworkClient overriding(extending) DuoNetworkClient 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 BaseStorageClient).
- Provide message signer. (You need to implement the protocol MessageSigner).
Example
- ECDSA
- EdDSA
Example.swift
import SwiftUI
import duoinitiator
struct ContentView: View {
var body: some View {
VStack {
let CLOUD_NODE_URI = "wss://demo-server.silencelaboratories.com"
//Other party verifying-key/public-key
let cloudVerifyingKey = "01829099948d222f9731323900bc42bd3cc6f4e692f920705a9959b3e52378f188"
//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 messageSigner instance to sign message. For simplicity we are using
//test message signer; Do not use TestMessageSinger in production.
//Instead create instance of your own implementation of MessageSigner.
//Just like below.
//let messageSigner = CustomMessageSigner()
//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.createDuoSession(
//Do not use TestMessageSinger in production
messageSigner: TestECDSAMessageSigner(),
cloudVerifyingKey: String(
cloudVerifyingKey
),
websocketConfig: websocketConfig,
storageClient: storageClient)
//or using custom network client
let duoSession = SilentShard.ECDSA.createDuoSession(
//Do not use TestMessageSinger in production
messageSigner: TestECDSAMessageSigner(),
cloudVerifyingKey: String(
cloudVerifyingKey
),
networkClient: CustomNetworkClient(),
storageClient: storageClient)
}
.padding()
}
}
#Preview {
ContentView()
}
Example.swift
import SwiftUI
import duoinitiator
struct ContentView: View {
var body: some View {
VStack {
let CLOUD_NODE_URI = "wss://demo-server.silencelaboratories.com"
//Other party verifying-key/public-key
let cloudVerifyingKey = "01829099948d222f9731323900bc42bd3cc6f4e692f920705a9959b3e52378f188"
//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 messageSigner instance to sign message. For simplicity we are using
//test message signer; Do not use TestMessageSinger in production.
//Instead create instance of your own implementation of MessageSigner.
//Just like below.
//let messageSigner = CustomMessageSigner()
//Create duoSession
/*
We only have to pass websocketConfig which contains the server config and
communication will be handled by internal websocketClient*/
let duoSession = SilentShard.EdDSA.createDuoSession(
//Do not use TestMessageSinger in production
messageSigner: TestEdDSAMessageSigner(),
cloudVerifyingKey: String(
cloudVerifyingKey
),
websocketConfig: websocketConfig,
storageClient: storageClient)
//or using custom network client
let duoSession = SilentShard.EdDSA.createDuoSession(
//Do not use TestMessageSinger in production
messageSigner: TestEdDSAMessageSigner(),
cloudVerifyingKey: String(
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 DuoSession (Two-Party) using ECDSA algorithm.
- ECDSA Provides factory methods for creating MPC session using ECDSA algorithm.
- DuoSession 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! 🎉