Skip to main content

Session creation


High level flow of the SDK

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

Create a new React Native project


Skip this section if you already have a React Native project.

Terminal
npx react-native init SilentMPC

After the project is created, install @silencelaboratories/silent-shard-sdk using the instructions from the Installation Guide

Our package heavily encode and decode the string using Buffer package, so let's add to the project.

Terminal
yarn add buffer

Start a new session


App.tsx
import { CloudWebSocketClient, EcdsaSession, MpcProtocols } from '@silencelaboratories/silent-shard-sdk';
import { Buffer } from 'buffer';

global.Buffer = Buffer;

const CLOUD_NODE_URI = 'localhost:8080';
const cloudVerifyingKey = 'SERVER_PUBLIC_KEY_HEX';
const cloudClient = new CloudWebSocketClient(CLOUD_NODE_URI, false);
const config = {
client: cloudClient,
cloudVerifyingKey: cloudVerifyingKey,
protocol: MpcProtocols.trio,
};

const session = new EcdsaSession(config);

console.log('Session created successfully');

export { session };
  • CloudWebSocketClient: is a class that handles the WebSocket communication with the cloud node.

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

  • EddsaSession: is the class that facilitates all actions for EDDSA wallets.

  • SessionConfig: is a configuration object that contains the necessary information for the session.

  • CLOUD_NODE_URI is the URI of the cloud node.

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

    • This public key is used to verify the server's signature on each message
    • This key is logged on the server on startup. See example here

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