Skip to main content

Session creation


High level flow of the SDK

  • Setup the websocket client to connect and communicate with the cloud node
  • Setup the storage client to store mobile keyshare
  • Start a new mpc session
  • Perform MPC actions

Start a new session


main.dart
import 'dart:io';
import 'package:silent_shard_sdk/silent_shard_sdk.dart' as sdk;

Future<sdk.EcdsaSession> setup(
[String cloudVerifyingKeyHex = 'SERVER_PUBLIC_KEY_HEX']) async {
/// The port number is the port number of the cloud node.
const port = 8080;

/// The nodeUri is the URI of the cloud node. It is the IP address of the cloud node.
/// Localhost url used for Android and iOS is shown below.
/// 10.0.2.2 is the IP address of the Android emulator.
/// 0.0.0.0 is the IP address of the iOS simulator.
final nodeUri = Platform.isAndroid ? '10.0.2.2:$port' : '0.0.0.0:$port';

final cloudClient = sdk.CloudClient(
baseUri: nodeUri,
isSecure: false,
);

final session = sdk.createTrioEcdsaSession(
cloudClient: cloudClient,
cloudVerifyingKeyHex: cloudVerifyingKeyHex,
storageClient: sdk.SimpleStorageClient(),);

return session;
}
  • Initialize an ECDSA session with the EcdsaSession class.

  • CloudClient: is a class that handles the WebSocket communication with the cloud node.

  • EcdsaSession is the class that facilitates all actions for ECDSA wallets.

  • CLOUD_NODE_URI is the URI of the cloud node.

  • cloudVerifyingKey is the Hex encoded cloud verifying key (Ed25519 public key).

    • This public key is used to verify the server's signature on each message
    • See example here
  • protocol is the protocol to use for the session. Protocol.trio is the used for Trio.

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