Skip to main content
Platform

Keygen

Generate a new MPC wallet. The app and the Duo Server run distributed key generation, and each ends up with its own keyshare. The resulting public key is the wallet address. No seed phrase is ever created.

Please refer to the Session creation section to learn how to create a new session.

Full example

App.tsx
import { type EcdsaSession } from '@silencelaboratories/silent-shard-sdk/ecdsa';

export const keygen = async (session: EcdsaSession) => {
const keyshare = await session.keygen();
console.log('Created new keyshare with public key: ', keyshare.publicKeyHex);
};
  • When session.keygen() is called, the app and the server exchange messages to generate a new MPC wallet.
  • Two new "shares" are generated: one for the client and one for the server. Both shares together form the MPC wallet.
  • keyshare is of type Keyshare and represents the client's "share" of the MPC wallet.
  • The keyshare.publicKeyHex property is the public key of the MPC wallet in hex format.

Handling the operation

This is an MPC operation, so it takes a few seconds (the app and the Duo Server exchange several messages). Show a non-blocking loading state while it runs, confirm on success, and offer a retry on failure. When something goes wrong, the SDK surfaces the error for you to handle:

ErrorWhat it meansHow to handle
Keyshares not in sync, run reconcileA previous operation didn't finish cleanly (for example the app was force-closed mid-operation)Run reconcile, then retry
Server errorThe server ended the session unexpectedlyShow the error and offer a retry
Connection / transport errorThe server was unreachable or the connection droppedShow the error and offer a retry

All of these operations are safe to retry from the start.