Sr25519
Sr25519 scheme implementation providing functionality for the FROST MPC protocol.
This class handles cryptographic operations using Sr25519 keys, including:
Key generation via multi-party computation (MPC)
Distributed signing of messages
Secret share refreshing
Key resharing
Key import/export
Key derivation
Example Usage
/// Server side creates a room for 3 parties using API_KEY
/// Creating a room UUID should always happen on the server side
val numParties = 3
val threshold = 2
val apiKey = "MY_API_KEY"
val keygenRoomUuid = createRoom(numParties, apiKey)
/// All parties call initKeygen to get key generation IDs
val keygenInitResult = initKeygen()
/// All parties receive keygenIds from other parties
val keygenIds = listOf("keygenId1", "keygenId2")
/// All parties join the keygen room
val keygenResult = keygen(
keygenRoomUuid,
numParties,
threshold,
keygenInitResult.keygenSecret,
keygenIds
)
/// Pick the derivation path for the public key you want to sign for
val derivationPath = arrayOf("this", "is", "a", "derivation", "path")
/// Option 1: Derive public key using the secret share from keygenResult
val pubkey = derivePubkey(keygenResult.secretShare, derivationPath)
/// Option 2: Derive public key using Spub for more flexibility
val pubKey = getPubkey(keygenResult.secretShare)
val derivedPubkey = derivePubkeyFromPubkey(pubKey, derivationPath)
/// To sign a message, create a signing room on the server side
val signingRoomUuid = createRoom(threshold, apiKey)
/// Your message in hex
val message = "deadbeef"
/// Threshold parties join the signing room
val signature = sign(signingRoomUuid, keygenResult.secretShare, message, derivationPath)
/// This signature can now be verified against pubkey
/// Refreshing the secret key material
val refreshRoomUuid = createRoom(numParties, apiKey)
/// All parties join the refresh room
val refreshResult = refresh(refreshRoomUuid, keygenResult.secretShare)
/// Note: refreshResult.pubkey == keygenResult.pubkey
/// Signing using the new secret key material
val signingRoomUuid2 = createRoom(threshold, apiKey)
val message2 = "deadbeefcafebabe"
val signature2 = sign(signingRoomUuid2, refreshResult.secretShare, message2, derivationPath)
/// This signature can now be verified against pubkeyFunctions
Creates a room for multi-party computation.
Derives a private key from a private key.
Derives a public key from an Sr25519 secret share.
Derives a public key from a public key.
Exports a full Sr25519 private key.
Gets an export ID from an Sr25519 secret share.
Gets a public key from an Sr25519 secret share.
Imports an Sr25519 private key (importer).
Imports an Sr25519 private key (recipient).
Initializes key generation for MPC protocols.
Generates Sr25519 keys using multi-party computation.
Exports a full Sr25519 private key offline.
Refreshes the Sr25519 secret share.
Reshares an Sr25519 key for a new party.
Reshares an Sr25519 key for a remaining party.
Signs a message using Sr25519 and multi-party computation.