PublicKey
The non-secret (public) part of an asymmetric key pair that is typically used to digitally verify or encrypt data.
Constructors
new PublicKey()
Creates a new public key from a byte array.
Throws when the byte array is not exactly 32 bytes long.
Parameter | Type |
---|---|
First | Uint8Array |
Returns |
---|
PublicKey |
Properties
serializedSize
SIZE
Methods
__getClassname()
compare()
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.
Parameter | Type |
---|---|
First | PublicKey |
equals()
Returns if this public key is equal to the other public key.
Parameter | Type |
---|---|
First | PublicKey |
free()
serialize()
Serializes the public key to a byte array.
toAddress()
Gets the public key's address.
Returns |
---|
Address |
toHex()
Formats the public key into a hex string.
verify()
Verifies that a signature is valid for this public key and the provided data.
Parameter | Type |
---|---|
First | Uint8Array |
derive()
Derives a public key from an existing private key.
Parameter | Type |
---|---|
First | PrivateKey |
Returns |
---|
PublicKey |
deserialize()
Deserializes a public key from a byte array.
Throws when the byte array contains less than 32 bytes.
Parameter | Type |
---|---|
First | Uint8Array |
Returns |
---|
PublicKey |
fromAny()
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.
Parameter | Type |
---|---|
First | string | Uint8Array | PublicKey |
Returns |
---|
PublicKey |
fromHex()
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.
Parameter | Type |
---|---|
First | string |
Returns |
---|
PublicKey |
fromRaw()
Deserializes a public key from its raw representation.
Parameter | Type |
---|---|
First | Uint8Array |
Returns |
---|
PublicKey |
fromSpki()
Deserializes a public key from its SPKI representation.
Parameter | Type |
---|---|
First | Uint8Array |
Returns |
---|
PublicKey |