> **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.createKeyPair

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

Creates a new secp256k1 ECDSA key pair consisting of a private key and its corresponding public key.

## Imports

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

## Examples

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

const { privateKey, publicKey } = Secp256k1.createKeyPair()
```

## Definition

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

## Parameters

### options

* **Type:** `createKeyPair.Options<as>`
* **Optional**

The options to generate the key pair.

#### options.as

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

Format of the returned private key.

## Return Type

The generated key pair containing both private and public keys.

`createKeyPair.ReturnType<as>`
