MpcService

@ObjCName(swiftName = "MpcService")
class MpcService

Flutter submodule for MPC operations over pluggable hardware transports.

Responsibilities:

  • Transport-agnostic connection lifecycle (scan, connect, disconnect)

  • MPC protocol operations (identity exchange, DKG, presign) via orchestrator

  • Internal storage management (Flutter never accesses storage directly)

  • Exposes the active HwTransport for BlockchainSdkService.signWithHw()

  • Progress tracking via shared MpcProgressTracker

  • Reactive connection state stream for Flutter UI

All transports (BLE, USB) are pre-registered. The consumer chooses which transport to use at scan/connect time via TransportType.

This service does NOT handle transaction signing or compilation. Transaction-aware signing lives in BlockchainSdkService.signWithHw().

Types

Link copied to clipboard
object Companion

Properties

Link copied to clipboard

Reactive connection state stream. Emits ConnectionInfo with current state, transport type, and device info.

Functions

Link copied to clipboard
suspend fun connect(deviceId: String, transportType: TransportType): Result<DeviceInfo>

Connect to a specific device by ID (e.g. from QR code on AC device).

Link copied to clipboard
suspend fun disconnect(): Result<Boolean>

Disconnect from the currently connected device.

Link copied to clipboard

Get the current MPC protocol state for UI progress tracking. Returns IDLE state if no tracker is configured.

Link copied to clipboard
suspend fun performDkg(groupId: String): Result<DkgResult>

Perform Distributed Key Generation with the AC device. One-time operation per MPC group — produces keyshares stored permanently.

Link copied to clipboard

Perform identity exchange with the AC device and server. One-time operation per MPC group — establishes P-256 identity keys for all 3 parties.

Link copied to clipboard
suspend fun performPresign(groupId: String): Result<PresignResult>

Perform presign with the AC device. Can be done ahead of time — stores presign material for fast signing later.

Link copied to clipboard
fun scan(transportType: TransportType? = null): Flow<DeviceInfo>

Stream discovered devices across all transports, or filter by type. Cancel collection to stop scanning.

Link copied to clipboard
suspend fun scanAndConnect(transportType: TransportType? = null): Result<DeviceInfo>

Convenience: scan + connect to first matching device.