buildPayload

fun buildPayload(rootPublicKey: ByteArray, accessPublicKey: ByteArray, scope: AuthorizationScope, timestampMs: Long, expiryMs: Long = NO_EXPIRY): ByteArray

Builds the authorization payload that will be signed by the passkey.

The payload is deterministic for the same inputs — important for verification.

Format (binary):

  • Magic bytes: "KUIRA-AUTH-V1" (13 bytes)

  • Root public key: compressed P-256 (33 bytes)

  • Access public key: compressed secp256k1 (33 bytes)

  • Scope flags: 4 bytes (big-endian uint32)

  • Timestamp: 8 bytes (big-endian int64, epoch millis)

  • Expiry: 8 bytes (big-endian int64, epoch millis, 0 = no expiry)

Total: 99 bytes fixed