# Secp256k1.fromMnemonic

Derives a valid secp256k1 private key from a BIP-39 mnemonic.

This is equivalent to [`Mnemonic.toPrivateKey`](/wasm/crypto/Mnemonic/toPrivateKey), and derives the private key at `m/44'/60'/0'/0/0` by default.

## Imports

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

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

## Examples

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

const privateKey = Secp256k1.fromMnemonic(
  'test test test test test test test test test test test junk'
)
```

## Definition

```ts
function fromMnemonic<as>(
  mnemonic: string,
  options?: fromMnemonic.Options<as>,
): fromMnemonic.ReturnType<as>
```

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

## Parameters

### mnemonic

* **Type:** `string`

BIP-39 mnemonic phrase.

### options

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

Options.

#### options.as

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

Format of the returned private key.

#### options.passphrase

* **Type:** `string`
* **Optional**

Optional BIP-39 passphrase.

#### options.path

* **Type:** `string`
* **Optional**

Derivation path.

## Return Type

A valid secp256k1 private key.

`fromMnemonic.ReturnType<as>`
