Skip to content

PublicKey.toBytes

Serializes a PublicKey.PublicKey to Bytes.Bytes.

Imports

Named
import { PublicKey } from 'ox'

Examples

import { PublicKey } from 'ox'
 
const publicKey = PublicKey.from({
  prefix: 4,
  x: 59295962801117472859457908919941473389380284132224861839820747729565200149877n,
  y: 24099691209996290925259367678540227198235484593389470330605641003500238088869n,
})
 
const bytes = PublicKey.toBytes(publicKey)
Uint8Array [128, 3, 131, ...]

Definition

function toBytes(
  publicKey: PublicKey<boolean>,
  options?: toBytes.Options,
): Bytes.Bytes

Source: src/PublicKey.ts

Parameters

publicKey

  • Type: PublicKey<boolean>

The public key to serialize.

publicKey.prefix

  • Type: numberType

publicKey.x

  • Type: bigintType

publicKey.y

  • Type: bigintType

options

  • Type: toBytes.Options
  • Optional

options.includePrefix

  • Type: boolean
  • Optional

Whether to include the prefix in the serialized public key.

Return Type

The serialized public key.

Bytes.Bytes

Error Type

PublicKey.toBytes.ErrorType