Skip to content

AttestedSigner.getSignPayload

Computes the digest a program key signs for an attested signature over the context digest payload: keccak256("tempo:attested-signature" ‖ payload ‖ keccak256(rlp([policyId, userTag, slot, programKey, validUntil]))).

payload is the transaction sign payload, the key authorization sign payload, the configurable account owner approval payload, or the hash a contract verifies. The program key signs the result with ECDSA over P256, with no further hashing and a low s.

TIP-1160

Imports

Named
import { AttestedSigner } from 'ox/tempo'

Examples

import { P256 } from 'ox'
import { AttestedSigner, SignatureEnvelope } from 'ox/tempo'
 
const { privateKey, publicKey } = P256.createKeyPair()
 
const attested = {
  policyId: `0x${'aa'.repeat(32)}`,
  programKey: publicKey,
  slot: 0,
  userTag: `0x${'bb'.repeat(32)}`,
  validUntil: 1_800_000_600
} as const
 
const payload = AttestedSigner.getSignPayload({
  ...attested,
  payload: '0xdeadbeef'
})
 
const envelope = SignatureEnvelope.from({
  ...attested,
  signature: P256.sign({ payload, privateKey })
})

Definition

function getSignPayload(
  options: getSignPayload.Options,
): Hex.Hex

Source: src/tempo/AttestedSigner.ts

Parameters

options

  • Type: getSignPayload.Options

The context digest and the signature's fields.

options.payload

  • Type: 0x${string} | Uint8Array

Context digest the attested signature authorizes.

options.policyId

  • Type: 0x${string}

Attested Key Registry policy ID.

options.programKey

  • Type: { prefix: number; x: bigint; y: bigint; }

Uncompressed P256 program key that signs.

options.slot

  • Type: number

Key slot that holds the program key.

options.userTag

  • Type: 0x${string}

Tag of the user whose address the signature signs for.

options.validUntil

  • Type: number | bigint

Last block timestamp, in seconds, at which the signature is valid.

Return Type

The digest the program key signs.

Hex.Hex