Precompute sign
Please refer to the Session creation section to learn how to create a new session.
Full example
- ECDSA
- EdDSA
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);
};
Not supported yet...
Pre sign flows two steps
- Precompute the signature of the message to be signed using the
preSignmethod.
- The
preSignmethod takes a EcdsaPreSignConfig object as an argument.keyshareis of type Keyshare and represents the client's share of the MPC wallet.
- The
preSignatureis the precomputed signature(Hex string) of the message to be signed.
- Finish the signature using the
finishPresignmethod.
- The
finishPresignmethod takes a EcdsaFinishPreSignConfig object as an argument.preSignHexis the precomputed signature from thepreSignmethod.messageHashis the hash of the message to be signed as a hex string.
- The
signatureis the ECDSA(EdDSA) signature (hex string) ofmessageHash, corresponding to the public key (or address) of the wallet.