Pre-signature
Pre-signatures let you precompute the expensive multi-round MPC computation (between mobile and first server) before the transaction is ready. When the user submits a transaction, preSignatureFinal returns the signature instantly — no MPC round-trip at that point.
For the SDK contract see Pre-signature (Kotlin) and Pre-signature (Swift).
How the example does it
Step 1: Generate the pre-signature (expensive, do this in advance)
- Android
- iOS / macOS
suspend fun preSignature(keyId: String): ByteArray {
val dao = readDao(keyId)
val keyshare = dao.currentKeyshare
?: throw Exception("No active keyshare found for keyId: $keyId")
return sessionFor(dao.keyType).preSignature(keyshare).getOrThrow()
}
func preSignature(keyId: String) async throws -> Data {
let record = try loadRecord(keyId: keyId)
let keyshare = try requireActiveKeyshare(record)
return try await sessionForKeyType(record.keyType)
.preSignature(keyshare: keyshare).get()
}
Step 2: Finalize when the transaction is ready (instant)
- Android
- iOS / macOS
suspend fun preSignatureFinal(
keyId: String,
preSignature: ByteArray,
message: ByteArray,
derivationPath: String,
): ByteArray {
val keyType = readDao(keyId).keyType
return sessionFor(keyType)
.preSignatureFinal(
preSignature = preSignature,
message = message.toHex(),
derivationPath = derivationPath,
).getOrThrow()
}
func preSignatureFinal(preSignature: Data, keyId: String,
message: Data, derivationPath: String) async throws -> Data {
let keyType = try loadRecord(keyId: keyId).keyType
let messageHex = message.map { String(format: "%02x", $0) }.joined()
return try await sessionForKeyType(keyType).preSignatureFinal(
preSignature: preSignature, message: messageHex, chainPath: derivationPath
).get()
}
Single-use
Each pre-signature can only be finalized once. Consuming it via preSignatureFinal invalidates it — the example resets the UI state so the user generates a fresh one for the next transaction. The pre-signature is held in memory (not persisted to disk), so it's also lost if the app is killed before finalization.
The example wires this up under the Pre-Signature screen, available from the dashboard for ECDSA (Ethereum) tokens only.