Skip to main content

Quick Start

info

If you don't have have access to the docker image or don't have <silence-dart-token> for registry dart-pkg.silencelaboratories.com, 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 Flutter mobile application interacts with two servers making it a Trio setup. We are providing a demo server endpoint for your convenience.

Prerequisites

info

For quick testing, the demo trio 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 (Flutter)

Create a new Flutter project

flutter create silent_mpc

Configure your dart pub client

  • Obtain a Pub token from Silence Laboratories team.

  • Add token to dart pub client using the command:

Terminal
dart pub token add https://dart-pkg.silencelaboratories.com
Enter secret token: <silence-dart-token>

Dependency Installation

  • Add silent_shard_sdk from the https://dart-pkg.silencelaboratories.com registry. In terminal from root of the flutter project, run
Terminal
dart pub add 'silent_shard_sdk:{"hosted":"https://dart-pkg.silencelaboratories.com"}'

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 'package:silent_shard_sdk/silent_shard_sdk.dart' as sdk;

final cloudClient = sdk.CloudClient(
baseUri: "trio-server.demo.silencelaboratories.com",
isSecure: true,
);

final sessionConfig = sdk.SessionConfig(
cloudClient: cloudClient,
cloudVerifyingKeyHex: "019c4c79e942bbc3ff1d6ace7256404d701498056978cc4638c35832acdf821b1e",
storageClient: sdk.SimpleStorageClient(),
protocol: sdk.Protocol.trio,
);

final session = sdk.EcdsaSession(sessionConfig);

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.

final keyshare = await session.keygen();
print('Client Public Key: ${await keyshare.publicKeyHex}');

Signature Generation

Sign a message using the sign method.

final signature = await session.sign(
keyId: keyshare.keyId,
// Keccak256 Hash("Trusted Third Parties are Security Holes")
messageHash: "53c48e76b32d4fb862249a81f0fc95da2d3b16bf53771cc03fd512ef5d4e6ed9",
derivationPath: 'm',
);
print('Generated signature: $signature');

Complete Code Example

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

void main() {
runApp(const MyApp());
}

class MyApp extends StatelessWidget {
const MyApp({super.key});

Future<void> _testMpcOperations() async {
final cloudClient = sdk.CloudClient(baseUri: 'trio-server.demo.silencelaboratories.com', isSecure: true);

final session = await sdk.createTrioEcdsaSession(
cloudClient: cloudClient,
cloudVerifyingKeyHex: '019c4c79e942bbc3ff1d6ace7256404d701498056978cc4638c35832acdf821b1e',
storageClient: sdk.SimpleStorageClient(),
);

final keyshare = await session.keygen();

print('Client Public Key: ${keyshare.publicKeyHex}');

final signature = await session.sign(
keyId: keyshare.keyId,
// Keccak256 Hash("Trusted Third Parties are Security Holes")
messageHash: "53c48e76b32d4fb862249a81f0fc95da2d3b16bf53771cc03fd512ef5d4e6ed9",
derivationPath: 'm',
);
print('Generated signature: $signature');
}

// This widget is the root of your application.

Widget build(BuildContext context) {
return MaterialApp(
home: Scaffold(
appBar: AppBar(title: Text('Silent MPC Demo')),
body: Center(
child: ElevatedButton(
onPressed: () async {
await _testMpcOperations();
},
child: Text('Test MPC operations'),
),
),
),
);
}
}

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