Skip to main content

Quick Start

info

If you don't have have access to the docker image or don't have NPM token, please contact us at info@silencelaboratories.com.

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

info

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.

  • 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 packages

Now you can install the Silent Shard SDK packages.

npm install @silencelaboratories/silent-shard-sdk @silencelaboratories/dkls-sdk @silencelaboratories/schnorr-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,
createEcdsaTrioSession,
} from "@silencelaboratories/silent-shard-sdk";

// 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

Add the following code to your App.tsx.

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

export default function App() {
React.useEffect(() => {
// We will MPC functions here
const mpcTest = async () => {
// Create a session
const cloudClient = new CloudWebSocketClient(
"trio-server.demo.silencelaboratories.com",
false // Use true for secure connection, otherwise use false for local server
);
const session = await createEcdsaTrioSession({
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);
};
mpcTest();
}, []);

return null;
}

Run your application!

Run your application in a classic way.

info

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!