> **Can't find what you're looking for?** Use `search_docs` on the docs MCP server at `https://v3.viem.sh/api/mcp` to find what you need.

# Secp256k1.recoverPublicKey

:::info
`Secp256k1.recoverPublicKey` is a re-export of ox's [`Secp256k1.recoverPublicKey`](https://oxlib.sh/api/Secp256k1/recoverPublicKey). Refer to the ox documentation for the full reference.
:::

Recovers the signing public key from the signed payload and signature.

## Imports

```ts
import { Secp256k1 } from 'viem/utils'
```

## Examples

```ts twoslash
// @noErrors
import { Secp256k1 } from 'viem/utils'

const signature = Secp256k1.sign({
  payload: '0xdeadbeef',
  privateKey: '0x...'
})

const publicKey = Secp256k1.recoverPublicKey({
  // [!code focus]
  payload: '0xdeadbeef', // [!code focus]
  signature // [!code focus]
}) // [!code focus]
```

## Definition

```ts
function recoverPublicKey<as>(
  options: recoverPublicKey.Options<as>,
): recoverPublicKey.ReturnType<as>
```

## Parameters

### options

* **Type:** `recoverPublicKey.Options<as>`

The recovery options.

#### options.as

* **Type:** `"Object" | "Bytes" | "Hex" | as`
* **Optional**

Format of the returned public key.

#### options.payload

* **Type:** `0x${string} | Uint8Array`

Payload that was signed.

#### options.signature

* **Type:** `0x${string} | Uint8Array | { r: 0x${string}; s: 0x${string}; yParity: number; }`

Signature of the payload.

Accepts a structured [`Signature.Signature`](/docs/utilities/signature/types#signature), a serialized hex
string, or a `Uint8Array` (65-byte recovered).

## Return Type

The recovered public key.

`recoverPublicKey.ReturnType<as>`
