# Bls.getPublicKey

Computes the BLS12-381 public key from a provided private key.

Public Keys can be derived as a point on one of the BLS12-381 groups:

* G1 Point (Default): - short (48 bytes) - computes longer G2 Signatures (96 bytes) - G2 Point: - long (96 bytes) - computes short G1 Signatures (48 bytes)

## Imports

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

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

## Examples

### Short G1 Public Keys (Default)

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

const publicKey = Bls.getPublicKey({ privateKey: '0x...' })
//    ^?
```

### Long G2 Public Keys

A G2 Public Key can be derived as a G2 point (96 bytes) using `size: 'long-key:short-sig'`.

This will allow you to compute G1 Signatures (48 bytes) with [`Bls.sign`](/api/Bls/sign).

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

const publicKey = Bls.getPublicKey({
  privateKey: '0x...',
  size: 'long-key:short-sig'
})

publicKey
// ^?
```

### Serializing

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

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

const publicKey = Bls.getPublicKey({ privateKey: '0x...' })

const publicKeyHex = BlsPoint.toHex(publicKey)
//    ^?

const publicKeyBytes = BlsPoint.toBytes(publicKey)
//    ^?
```

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 publicKeyHex = '0x...'

const publicKey = BlsPoint.fromHex(publicKeyHex, 'G1')
//    ^?
```

## Definition

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

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

## Parameters

### options

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

The options to compute the public key.

#### options.as

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

Format of the returned public key.

#### options.privateKey

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

Private key to compute the public key from.

#### options.size

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

Size of the public key to compute.

* `'short-key:long-sig'`: 48 bytes; computes long signatures (96 bytes)
* `'long-key:short-sig'`: 96 bytes; computes short signatures (48 bytes)

## Return Type

The computed public key.

`getPublicKey.ReturnType<as, size>`
