ExportableEd25519

class ExportableEd25519(hostUrl: String = SODOT_RELAY_URL) : Scheme

ExportableEd25519 scheme implementation providing functionality for a variant of the FROST MPC protocol.

This class handles cryptographic operations using Ed25519 keys with enhanced exportability features, including:

  • Key generation via multi-party computation (MPC)

  • Distributed signing of messages

  • Secret share refreshing

  • Key resharing

  • Key import/export

Unlike the regular Ed25519 implementation, ExportableEd25519 provides functions specifically designed for exportability scenarios, with two distinct methods for key generation: sampleKey for the party initiating the key generation, and receiveKey for parties receiving the key.

Example Usage

// Server side creates a room for 3 parties using API_KEY
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")

// The party initiating the key generation calls sampleKey
val keygenResultInitiator = sampleKey(
keygenRoomUuid,
numParties,
threshold,
keygenInitResult.keygenSecret,
keygenIds
)

// Other parties call receiveKey
val keygenResultReceiver = receiveKey(
keygenRoomUuid,
numParties,
threshold,
keygenInitResult.keygenSecret,
keygenIds
)

// To sign a message, create a signing room on the server side
val signingRoomUuid = createRoom(threshold, apiKey)
val message = "Hello, world!".toByteArray()

// Threshold parties join the signing room
val signature = sign(signingRoomUuid, keygenResult.secretShare, message)

Constructors

Link copied to clipboard
constructor(hostUrl: String = SODOT_RELAY_URL)

Functions

Link copied to clipboard
suspend fun createRoom(numParties: Int, apiKey: String): RoomUUID

Creates a room for multi-party computation.

Link copied to clipboard
suspend fun exportFullPrivateKey(roomUuid: RoomUUID, secretShare: ExportableEd25519SecretShare, toExportID: String): ByteArray?

Exports a full exportable Ed25519 private key.

Link copied to clipboard

Gets an export ID from an exportable Ed25519 secret share.

Link copied to clipboard

Gets the public key from an exportable Ed25519 secret share.

Link copied to clipboard
suspend fun importPrivateKeyImporter(roomUuid: RoomUUID, threshold: Int, privateKey: PrivateKey, keygenInitKeypair: KeygenPrivateKey, keygenIds: Array<KeygenID>): Pair<Ed25519PublicKey, ExportableEd25519SecretShare>

Imports an exportable Ed25519 private key (importer).

Link copied to clipboard
suspend fun importPrivateKeyRecipient(roomUuid: RoomUUID, threshold: Int, keygenInitKeypair: KeygenPrivateKey, keygenIds: Array<KeygenID>): Pair<Ed25519PublicKey, ExportableEd25519SecretShare>

Imports an exportable Ed25519 private key (recipient).

Link copied to clipboard

Initializes key generation for MPC protocols.

Link copied to clipboard
suspend fun keygen(roomUuid: RoomUUID, numParties: Int, threshold: Int, keygenInitKeypair: KeygenPrivateKey, keygenIds: Array<KeygenID>): Pair<Ed25519PublicKey, ExportableEd25519SecretShare>

This is the main key generation function used in the Scheme interface. For ExportableEd25519, it's recommended to use sampleKey and receiveKey directly instead, as they better represent the asymmetric nature of the protocol.

Link copied to clipboard

Exports a full exportable Ed25519 private key offline.

Link copied to clipboard
suspend fun receiveKey(roomUuid: RoomUUID, numParties: Int, threshold: Int, keygenInitKeypair: KeygenPrivateKey, keygenIds: Array<KeygenID>): Pair<Ed25519PublicKey, ExportableEd25519SecretShare>

Generates exportable Ed25519 keys using multi-party computation (for key receivers).

Link copied to clipboard

Refreshes the exportable Ed25519 secret share.

Link copied to clipboard
suspend fun reshareNewParty(roomUuid: RoomUUID, oldThreshold: Int, newThreshold: Int, keygenInitKeypair: KeygenPrivateKey, keygenIds: Array<KeygenID>): Pair<Ed25519PublicKey, ExportableEd25519SecretShare>

Reshares an exportable Ed25519 key for a new party.

Link copied to clipboard

Reshares an exportable Ed25519 key for a remaining party.

Link copied to clipboard
suspend fun sampleKey(roomUuid: RoomUUID, numParties: Int, threshold: Int, keygenInitKeypair: KeygenPrivateKey, keygenIds: Array<KeygenID>): Pair<Ed25519PublicKey, ExportableEd25519SecretShare>

Generates exportable Ed25519 keys using multi-party computation (for key initiator).

Link copied to clipboard
suspend fun sign(roomUuid: RoomUUID, secretShare: ExportableEd25519SecretShare, msg: ByteArray): Ed25519Signature

Signs a message using exportable Ed25519 and multi-party computation.