preSign

abstract suspend fun preSign(keyId: String): Result<ByteArray>

Generates a pre-signature for instant signing later with preSignFinal.

Pre-compute expensive MPC operations before knowing the message. Ideal for high-frequency trading where sub-100ms signing is critical.

Example: Instant Trading

// Generate pre-signature in advance
val preSig = session.preSign(keyshare).getOrThrow()

// Later, when you have the trade details:
val tradeHash = hashTrade(symbol = "ETH/USD", amount = "1.5", price = "3500")

// Instant signature (<100ms)
val signature = session.preSignFinal(
preSign = preSig,
message = tradeHash.toHexString(),
derivationPath = "m/44'/60'/0'/0/0"
).getOrThrow()

// Submit signed trade
exchange.submitOrder(trade.withSignature(signature))

Important: Each pre-signature is single-use only. Generate new ones after use.

Return

Result containing the pre-signature as ByteArray

Parameters

keyId

Hex-encoded keyId of the keyshare to precompute against. The SDK looks up the current keyshare via the owned StorageClient.

See also

to finalize with message