Skip to main content

Sign

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';

// This could be a hash digest of any message you want to sign.
// For example, for the Ethereum transaction signing, you would use the keccak256 hash of the transaction data.
const messageHash = 'e2a159d17b7bb714aed7675d7c7d394dec8d2e4337842848104694bf89c71c03';

export const signGen = async (session: EcdsaSession) => {
// Creating a new keyshare for demo purpose. In real application, you can use an existing keyshare.
const keyshare = await session.keygen();

const signConfig = {
keyshare,
messageHash,
};
const signature = await session.sign(signConfig);

console.log('Signature:', signature);
};
  • The sign method takes a EcdsaSignConfig object as an argument.
  • keyshare(Keyshare) is the client's "share" of the MPC wallet.
  • messageHash is the hash of the message to be signed as a hex string.
  • When session.sign() is called, the app and the server exchange messages to generate an ECDSA signature.
  • signature is the ECDSA signature (hex string) of messageHash, corresponding to the public key (or address) of the wallet.