Classes

PublicKey

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

Constructors

new PublicKey()

new PublicKey(`bytes`): [PublicKey](PublicKey)

Creates a new public key from a byte array.

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

ParameterType
FirstUint8Array
Returns
PublicKey

Properties

serializedSize

`readonly` serializedSize: `number`

SIZE

`readonly` `static` SIZE: `number`

Methods

__getClassname()

\_\_getClassname(): `string`

compare()

compare(`other`): `number`

Compares this public key to the other public key.

Returns -1 if this public key is smaller than the other public key, 0 if they are equal, and 1 if this public key is larger than the other public key.

ParameterType
FirstPublicKey

equals()

equals(`other`): `boolean`

Returns if this public key is equal to the other public key.

ParameterType
FirstPublicKey

free()

free(): `void`

serialize()

serialize(): `Uint8Array`

Serializes the public key to a byte array.


toAddress()

toAddress(): [Address](Address)

Gets the public key's address.

Returns
Address

toHex()

toHex(): `string`

Formats the public key into a hex string.


verify()

verify(`signature`, `data`): `boolean`

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

ParameterType
FirstUint8Array

derive()

`static` derive(`private_key`): [PublicKey](PublicKey)

Derives a public key from an existing private key.

ParameterType
FirstPrivateKey
Returns
PublicKey

deserialize()

`static` deserialize(`bytes`): [PublicKey](PublicKey)

Deserializes a public key from a byte array.

Throws when the byte array contains less than 32 bytes.

ParameterType
FirstUint8Array
Returns
PublicKey

fromAny()

`static` fromAny(`addr`): [PublicKey](PublicKey)

Parses a public key from a PublicKey instance, a hex string representation, or a byte array.

Throws when an PublicKey cannot be parsed from the argument.

ParameterType
Firststring | Uint8Array | PublicKey
Returns
PublicKey

fromHex()

`static` fromHex(`hex`): [PublicKey](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.

ParameterType
Firststring
Returns
PublicKey

fromRaw()

`static` fromRaw(`raw_bytes`): [PublicKey](PublicKey)

Deserializes a public key from its raw representation.

ParameterType
FirstUint8Array
Returns
PublicKey

fromSpki()

`static` fromSpki(`spki_bytes`): [PublicKey](PublicKey)

Deserializes a public key from its SPKI representation.

ParameterType
FirstUint8Array
Returns
PublicKey

On this page