> **Can't find what you're looking for?** Use `search_docs` on the docs MCP server at `https://v3.viem.sh/api/mcp` to find what you need.

# PublicKey Errors

:::info
`PublicKey` is a re-export of ox's [`PublicKey`](https://oxlib.sh/api/PublicKey/errors). Refer to the ox documentation for the full reference.
:::

## `PublicKey.InvalidCompressedPrefixError`

Thrown when the public key has an invalid prefix for a compressed public key.

## `PublicKey.InvalidError`

Thrown when a public key is invalid.

### Examples

```ts twoslash
// @noErrors
import { PublicKey } from 'viem/utils'

PublicKey.assert({ y: '0x01' })
// @error: PublicKey.InvalidError: Value `{"y":"0x01"}` 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)
```

## `PublicKey.InvalidPrefixError`

Thrown when a public key has an invalid prefix.

## `PublicKey.InvalidSerializedSizeError`

Thrown when the public key has an invalid serialized size.

## `PublicKey.InvalidUncompressedPrefixError`

Thrown when the public key has an invalid prefix for an uncompressed public key.
