Skip to content

PublicKey.assert

Asserts that a PublicKey.PublicKey is valid.

Imports

Named
import { PublicKey } from 'ox'

Examples

import { PublicKey } from 'ox'
 
PublicKey.assert({
  prefix: 4,
  y: 49782753348462494199823712700004552394425719014458918871452329774910450607807n,
})
PublicKey.InvalidError: Value \`{"y":"1"}\` is not a valid public key.
Public key must contain:
- an `x` and `prefix` value (compressed)
- an `x`, `y`, and `prefix` value (uncompressed)

Definition

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

Source: src/PublicKey.ts

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.