# SignaturePreAuthorized.wrap

Serializes a [TIP-1165](https://tips.sh/1165) pre-authorized signature: `rlp([keychain_signature, signed_key_authorization]) ‖ magic`.

The signature must be a V2 keychain signature whose inner signature is secp256k1, P256, or WebAuthn.

## Imports

:::code-group
```ts [Named]
import { SignaturePreAuthorized } from 'ox/tempo'
```

```ts [Entrypoint]
import * as SignaturePreAuthorized from 'ox/tempo/SignaturePreAuthorized'
```
:::

## Examples

```ts twoslash
import { Hash, Hex, Secp256k1 } from 'ox'
import {
  KeyAuthorization,
  SignatureEnvelope,
  SignaturePreAuthorized
} from 'ox/tempo'

const account = '0xf39fd6e51aad88f6f4ce6ab8827279cfffb92266'
const accessKey = Secp256k1.randomPrivateKey()
const rootKey = Secp256k1.randomPrivateKey()

const authorization = KeyAuthorization.from({
  address: '0x70997970c51812dc3a010c7d01b50e0d17dc79c8',
  chainId: 4217n,
  type: 'secp256k1'
})
const keyAuthorization = KeyAuthorization.from(
  authorization,
  {
    signature: SignatureEnvelope.from(
      Secp256k1.sign({
        payload:
          KeyAuthorization.getSignPayload(authorization),
        privateKey: rootKey
      })
    )
  }
)

const hash = Hash.keccak256(Hex.fromString('hello'))
const signature = SignatureEnvelope.from({
  inner: SignatureEnvelope.from(
    Secp256k1.sign({
      payload: Hash.keccak256(
        Hex.concat('0x04', hash, account)
      ),
      privateKey: accessKey
    })
  ),
  userAddress: account
})

const wrapped = SignaturePreAuthorized.wrap({
  // [!code focus]
  keyAuthorization, // [!code focus]
  signature // [!code focus]
}) // [!code focus]
```

## Definition

```ts
function wrap(
  value: Unwrapped,
): Wrapped
```

**Source:** [src/tempo/SignaturePreAuthorized.ts](https://github.com/wevm/ox/blob/main/src/tempo/SignaturePreAuthorized.ts#L263)

## Parameters

### value

* **Type:** `Unwrapped`

Unwrapped pre-authorized signature.

#### value.keyAuthorization

* **Type:** `Signed`

Root key's signed authorization of the access key.

#### value.signature

* **Type:** `Keychain`

V2 keychain signature by the access key.

## Return Type

Wrapped pre-authorized signature.

`Wrapped`
