Skip to content

Class: PublicKey

The non-secret (public) part of an asymmetric key pair that is typically used to digitally verify or encrypt data.

Table of contents

Constructors

Methods

Constructors

constructor

new PublicKey(bytes): PublicKey

Creates a new public key from a byte array.

Throws when the byte array is not exactly 32 bytes long.

Parameters

NameType
bytesUint8Array

Returns

PublicKey

Defined in

web.d.ts:1477

Methods

free

free(): void

Returns

void

Defined in

web.d.ts:1449


serialize

serialize(): Uint8Array

Serializes the public key to a byte array.

Returns

Uint8Array

Defined in

web.d.ts:1482


toAddress

toAddress(): Address

Gets the public key's address.

Returns

Address

Defined in

web.d.ts:1500


toHex

toHex(): string

Formats the public key into a hex string.

Returns

string

Defined in

web.d.ts:1495


verify

verify(signature, data): boolean

Verifies that a signature is valid for this public key and the provided data.

Parameters

NameType
signatureSignature
dataUint8Array

Returns

boolean

Defined in

web.d.ts:1462


derive

derive(private_key): PublicKey

Derives a public key from an existing private key.

Parameters

NameType
private_keyPrivateKey

Returns

PublicKey

Defined in

web.d.ts:1455


fromHex

fromHex(hex): PublicKey

Parses a public key from its hex representation.

Throws when the string is not valid hex format or when it represents less than 32 bytes.

Parameters

NameType
hexstring

Returns

PublicKey

Defined in

web.d.ts:1490


unserialize

unserialize(bytes): PublicKey

Deserializes a public key from a byte array.

Throws when the byte array contains less than 32 bytes.

Parameters

NameType
bytesUint8Array

Returns

PublicKey

Defined in

web.d.ts:1470