Skip to main content

Quick Start

Here is how you can setup the Mobile SDK and perform MPC operations in less than a minute.

You will create a working MPC three-party setup, where the first party, a React Native mobile application interacts with Trio Servers as a second party, and third party.

Prerequisites

Before you start, make sure you have:

  • Node.js (LTS) and a package manager (npm or Yarn).
  • An NPM token from Silence Laboratories to install the SDK from our private registry. Don't have one? Email [email protected].
  • A running iOS Simulator (Xcode) or Android emulator (Android Studio) to launch the app on.

For quick testing, the demo server is already deployed at trio-server.demo.silencelaboratories.com. We are using this server for the quickstart guide.

The Cloud Verifying Key for the demo server is 019c4c79e942bbc3ff1d6ace7256404d701498056978cc4638c35832acdf821b1e.

The Cloud Node Endpoint for the demo server is trio-server.demo.silencelaboratories.com.

Setup the Mobile SDK (React Native)

Create a new React Native project

npx create-expo-app@latest SilentMPC --template blank-typescript

Configure Your Package Manager

Configure your package manager with a private token provided by us to access the private registry.

If you don't have NPM token, please contact us at [email protected].

Use a consistent install workflow throughout (either npm install or yarn add). Note that .npmrc configuration applies to both npm and Yarn v1, while Yarn v2+ uses .yarnrc.yml.

  • Create a .yarnrc.yml file in the root of your project and add the following line:
npmScopes:
"silencelaboratories":
npmAlwaysAuth: true
npmRegistryServer: "https://registry.npmjs.org"
npmAuthToken: ${NPM_TOKEN}
  • Add the npm token as an environment variable, e.g., in a terminal session run:
export NPM_TOKEN=your-npm-token

Install the core library

npm install @silencelaboratories/silent-shard-sdk

Install the native SDK(s) for your wallet types

You only need the native SDKs for the wallet families your app actually supports — installing extras only adds bundle size.

Wallet familyAlgorithmNative package
EVM, Bitcoin, etc.ECDSA@silencelaboratories/dkls-sdk
Solana, etc.EdDSA@silencelaboratories/schnorr-sdk
npm install @silencelaboratories/dkls-sdk

Project setup

Run the following command to generate the native code for your project:

npx expo prebuild

Session Creation

The Session object is the main entry point to interact with the Silent Shard SDK. It manages the lifecycle of the MPC operations.

import { CloudWebSocketClient } from "@silencelaboratories/silent-shard-sdk";
import { createEcdsaTrioSession } from "@silencelaboratories/silent-shard-sdk/ecdsa";

// Create a session
const cloudClient = new CloudWebSocketClient(
"trio-server.demo.silencelaboratories.com",
true // Use true for secure connection, otherwise use false for local server
);

const session = await createEcdsaTrioSession({
cloudVerifyingKey: "019c4c79e942bbc3ff1d6ace7256404d701498056978cc4638c35832acdf821b1e",
client: cloudClient,
});

Run the MPC operations

After creating the session, you can perform MPC operations.

Key Generation

Generate MPC keyshares and return the client keyshare with keygen method.

const clientKeyshare = await session.keygen();
console.log("Client Public Key:", clientKeyshare.publicKeyHex);

Signature Generation

Sign a message using the sign method.

const signature = await session.sign({
keyshare: clientKeyshare,
// Keccak256 Hash("Trusted Third Parties are Security Holes")
messageHash:
"53c48e76b32d4fb862249a81f0fc95da2d3b16bf53771cc03fd512ef5d4e6ed9",
derivationPath: "m",
});
console.log("Generated signature: ", signature);

Complete Code Example

This is the complete App.tsx — it puts together every step above, so it replaces the earlier snippets rather than being added alongside them.

App.tsx
import * as React from 'react';
import { CloudWebSocketClient } from '@silencelaboratories/silent-shard-sdk';
import { createEcdsaTrioSession } from '@silencelaboratories/silent-shard-sdk/ecdsa';

export default function App() {
React.useEffect(() => {
// We will MPC functions here
const mpcTest = async () => {
try {
// Create a session.
// 1st arg: the Cloud Node Endpoint (Trio Servers host). The single demo host
// fronts both Trio servers. 2nd arg: secure flag — true => wss:// (TLS), false => ws://.
const cloudClient = new CloudWebSocketClient('trio-server.demo.silencelaboratories.com', true);
const session = await createEcdsaTrioSession({
// The servers' public signing key, used to verify messages from the server parties.
cloudVerifyingKey: '019c4c79e942bbc3ff1d6ace7256404d701498056978cc4638c35832acdf821b1e',
client: cloudClient,
});

// Key generation
const clientKeyshare = await session.keygen();

// Get public key of newly generated wallet
console.log('Client Public Key:', clientKeyshare.publicKeyHex);

// Signature generation
const signature = await session.sign({
keyshare: clientKeyshare,
// Keccak256 Hash("Trusted Third Parties are Security Holes")
messageHash: '53c48e76b32d4fb862249a81f0fc95da2d3b16bf53771cc03fd512ef5d4e6ed9',
derivationPath: 'm',
});

console.log('Generated signature: ', signature);
} catch (err) {
console.error('MPC test failed:', err);
}
};
mpcTest();
}, []);

return null;
}

Run your application!

Run your application in a classic way.

Expo Go support is coming soon too!

npm run android

or

npm run ios

Once the application is running, check your console log to see the key generation and signing process updates in real-time.

Happy signing!