# Bls.sign

Signs the payload with the provided private key.

## Imports

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

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

## Examples

```ts twoslash
import { Bls, Hex } from 'ox'

const signature = Bls.sign({
  // [!code focus]
  payload: Hex.random(32), // [!code focus]
  privateKey: '0x...' // [!code focus]
}) // [!code focus]
```

### Serializing

Signatures can be serialized to hex or bytes using [`BlsPoint.toHex`](/api/BlsPoint/toHex) or [`BlsPoint.toBytes`](/api/BlsPoint/toBytes):

```ts twoslash
import { Bls, BlsPoint, Hex } from 'ox'

const signature = Bls.sign({
  payload: Hex.random(32),
  privateKey: '0x...'
})

const signatureHex = BlsPoint.toHex(signature)
//    ^?

const signatureBytes = BlsPoint.toBytes(signature)
//    ^?
```

They can also be deserialized from hex or bytes using [`BlsPoint.fromHex`](/api/BlsPoint/fromHex) or [`BlsPoint.fromBytes`](/api/BlsPoint/fromBytes):

```ts twoslash
import { Bls, BlsPoint } from 'ox'

const signatureHex = '0x...'

const signature = BlsPoint.fromHex(signatureHex, 'G2')
//    ^?
```

## Definition

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

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

## Parameters

### options

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

The signing options.

#### options.as

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

Format of the returned signature.

#### options.payload

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

Payload to sign.

#### options.privateKey

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

BLS private key.

#### options.size

* **Type:** `Size | size`
* **Optional**

Size of the signature to compute.

* `'long-key:short-sig'`: 48 bytes
* `'short-key:long-sig'`: 96 bytes

#### options.suite

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

Ciphersuite to use for signing. Defaults to "Basic".

## Return Type

BLS Point.

`sign.ReturnType<as, size>`
