# P256.randomPrivateKey

Generates a random P256 ECDSA private key.

## Imports

:::code-group
```ts [Named]
import { P256 } from 'ox'
```

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

## Examples

```ts twoslash
import { P256 } from 'ox'

const privateKey = P256.randomPrivateKey()
```

## Definition

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

**Source:** [src/core/P256.ts](https://github.com/wevm/ox/blob/main/src/core/P256.ts#L416)

## 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>`
