Skip to content

KeyAuthorization

Tempo key authorization utilities for provisioning and signing access keys.

Access keys allow a root key (e.g., a passkey) to delegate transaction signing to secondary keys with customizable permissions including expiry timestamps and per-TIP-20 token spending limits. This enables a user to sign transactions without repeated passkey prompts.

Access Keys Specification

Examples

import { KeyAuthorization, SignatureEnvelope } from 'ox/tempo'
import { Address, Secp256k1, WebCryptoP256, Value } from 'ox'
 
const keyPair = await WebCryptoP256.createKeyPair()
const address = Address.fromPublicKey(keyPair.publicKey)
 
const authorization = KeyAuthorization.from({
  address,
  expiry: 1234567890,
  type: 'p256',
  limits: [{
    token: '0x20c0000000000000000000000000000000000001',
    limit: Value.from('10', 6),
  }],
})
 
const privateKey = '0x...'
const payload = KeyAuthorization.getSignPayload(authorization)
const signature = SignatureEnvelope.from(
  Secp256k1.sign({ payload, privateKey }),
)
 
KeyAuthorization.from(authorization, { signature })

Functions

NameDescription
KeyAuthorization.fromConverts a Key Authorization object into a typed KeyAuthorization.KeyAuthorization.
KeyAuthorization.fromRpcConverts an AuthorizationTempo.Rpc to an AuthorizationTempo.AuthorizationTempo.
KeyAuthorization.fromTupleConverts an KeyAuthorization.Tuple to an KeyAuthorization.KeyAuthorization.
KeyAuthorization.getSignPayloadComputes the sign payload for an KeyAuthorization.KeyAuthorization.
KeyAuthorization.hashComputes the hash for an KeyAuthorization.KeyAuthorization.
KeyAuthorization.toRpcConverts an KeyAuthorization.KeyAuthorization to an KeyAuthorization.Rpc.
KeyAuthorization.toTupleConverts an KeyAuthorization.KeyAuthorization to an KeyAuthorization.Tuple.

Types

NameDescription
KeyAuthorization.KeyAuthorizationKey authorization for provisioning access keys.
KeyAuthorization.RpcRPC representation of an KeyAuthorization.KeyAuthorization.
KeyAuthorization.SignedSigned representation of a Key Authorization.
KeyAuthorization.TokenLimitToken spending limit for access keys.
KeyAuthorization.TupleTuple representation of a Key Authorization.