Skip to main content

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

const messageHash = 'e2a159d17b7bb714aed7675d7c7d394dec8d2e4337842848104694bf89c71c03';

export const preSign = 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,
};
const preSignature = await session.preSign(signConfig);

console.log('Pre computed signature:', preSignature);

// The signature is a Hex encoded string.
const preSignConfig = {
preSignHex: preSignature,
messageHash,
};
const signature = await session.finishPresign(preSignConfig);

console.log('Final Signature:', signature);
};

Pre sign flows two steps

  1. Precompute the signature of the message to be signed using the preSign method.
  • The preSign method takes a EcdsaPreSignConfig object as an argument.
    • keyshare is of type Keyshare and represents the client's share of the MPC wallet.
  • The preSignature is the precomputed signature(Hex string) of the message to be signed.
  1. Finish the signature using the finishPresign method.
  • The finishPresign method takes a EcdsaFinishPreSignConfig object as an argument.
    • preSignHex is the precomputed signature from the preSign method.
    • messageHash is the hash of the message to be signed as a hex string.
  • The signature is the ECDSA(EdDSA) signature (hex string) of messageHash, corresponding to the public key (or address) of the wallet.