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

# P256.randomPrivateKey

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

Generates a random P256 ECDSA private key.

## Imports

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

## Examples

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

const privateKey = P256.randomPrivateKey()
```

## Definition

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

## Parameters

### options

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

The options to generate the private key.

#### options.as

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

Format of the returned private key.

## Return Type

The generated private key.

`randomPrivateKey.ReturnType<as>`
