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';
// 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);
};
App.tsx
import { type EddsaSession } from '@silencelaboratories/silent-shard-sdk';
const messageHash = 'e2a159d17b7bb714aed7675d7c7d394dec8d2e4337842848104694bf89c71c03';
export const signGen = async (session: EddsaSession) => {
// 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
signmethod takes a EcdsaSignConfig object as an argument. keyshare(Keyshare) is the client's "share" of the MPC wallet.messageHashis 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. signatureis the ECDSA signature (hex string) ofmessageHash, corresponding to the public key (or address) of the wallet.