# Secp256k1.sign

Signs the payload with the provided private key.

## Imports

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

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

## Examples

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

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

## Definition

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

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

## Parameters

### options

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

The signing options.

#### options.as

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

Format of the returned signature.

#### options.extraEntropy

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

Extra entropy to add to the signing process. Setting to `true` enables hedged
(RFC 6979 + extra randomness) signing.

#### options.hash

* **Type:** `boolean`
* **Optional**

If set to `true`, the payload will be hashed (sha256) before being signed.

#### options.payload

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

Payload to sign.

#### options.privateKey

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

ECDSA private key.

## Return Type

The ECDSA [`Signature.Signature`](/api/Signature/types#signature).

`sign.ReturnType<as>`
