# PublicKey.assert

Asserts that a [`PublicKey.PublicKey`](/api/PublicKey/types#publickey) is valid.

## Imports

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

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

## Examples

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

PublicKey.assert({
  prefix: 4,
  y: '0x6e1c1f59ee1cf25b75a8d57b3c89e7e6b3b1da823df8b3b89497f30c1f000000'
})
// @error: PublicKey.InvalidError: Value \`{"y":"0x..."}\` is not a valid public key.
// @error: Public key must contain:
// @error: - an `x` and `prefix` value (compressed)
// @error: - an `x`, `y`, and `prefix` value (uncompressed)
```

## Definition

```ts
function assert(
  publicKey: ExactPartial<PublicKey>,
  options?: assert.Options,
): asserts publicKey is PublicKey
```

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

## Parameters

### publicKey

* **Type:** `ExactPartial<PublicKey>`

The public key object to assert.

### options

* **Type:** `assert.Options`
* **Optional**

#### options.compressed

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

Whether or not the public key should be compressed.
