Sr25519
@sodot/sodot-node-sdk • Docs
@sodot/sodot-node-sdk / Sr25519
Class: Sr25519
Class providing the functionality for the Sr25519 protocol the implementing FROST MPC protocol.
Example
// Your server side creates a room for 3 parties using its API_KEY
// Creating a room uuid should always happen on the server side using your API_KEY
const N = 3;
const T = 2;
const sr25519 = new Sr25519();
const API_KEY = 'MY_API_KEY';
const keygenRoomUuid = await sr25519.createRoom(N, API_KEY);
// All parties call initKeygen to get an Sr25519InitKeygenResult, that contains a keygenId
const keygenInitResult = await sr25519.initKeygen();
// All parties receive the keygenIds from all other parties
const keygenIds = [keygenId1, keygenId2];
// All parties join the keygen room
const keygenResult = await sr25519.keygen(keygenRoomUuid, N, T, keygenInitResult, keygenIds);
// Pick the derivation path of the public key you want to sign for
const derivationPath = ["my", "3", "derivation"];
// Get the public key for the derivation path
const pubkey = await sr25519.derivePubkey(keygenResult, derivationPath);
// To sign a message, create a signing room on the server side, using your API_KEY
const signingRoomUuid = await sr25519.createRoom(T, API_KEY);
// your message in hex
const message = 'deadbeef';
// 2 parties join the signing room
const signature = await sr25519.sign(signingRoomUuid, keygenResult, message, derivationPath);
// This signature can now be verified against pubkey
// Refreshing the secret key material
// Your server creates a room for 3 parties
const refreshRoomUuid = await sr25519.createRoom(N, API_KEY);
// All parties join the refresh room
const refreshResult = await sr25519.refresh(refreshRoomUuid, keygenResult);
// Note: refreshResult.pubkey == keygenResult.pubkey
// Signing using the new secret key material
// The room is again created by the server
const signingRoomUuid2 = await sr25519.createRoom(T, API_KEY);
const message2 = 'deadbeefcafebabe';
const signature2 = await sr25519.sign(signingRoomUuid2, refreshResult, message2, derivationPath);
// This signature can now be verified against pubkey
Extends
Constructors
new Sr25519()
new Sr25519(
hostUrl?):Sr25519
Constructs a new Sr25519 instance.
Parameters
• hostUrl?: string
Returns
Overrides
Sr25519Internal.constructor