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
Name | Type |
---|---|
bytes | Uint8Array |
Returns
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
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
Name | Type |
---|---|
signature | Signature |
data | Uint8Array |
Returns
boolean
Defined in
web.d.ts:1462
derive
▸ derive(private_key
): PublicKey
Derives a public key from an existing private key.
Parameters
Name | Type |
---|---|
private_key | PrivateKey |
Returns
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
Name | Type |
---|---|
hex | string |
Returns
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
Name | Type |
---|---|
bytes | Uint8Array |
Returns
Defined in
web.d.ts:1470