ES256PublicKey
The non-secret (public) part of an ES256 asymmetric key pair that is typically used to digitally verify or encrypt data.
Constructors
new ES256PublicKey()
Creates a new public key from a byte array.
Compatible with the -7 COSE algorithm identifier.
Example
| Parameter | Type |
|---|---|
| First | Uint8Array |
| Returns |
|---|
| ES256PublicKey |
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 | ES256PublicKey |
equals()
Returns if this public key is equal to the other public key.
| Parameter | Type |
|---|---|
| First | ES256PublicKey |
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 |
deserialize()
Deserializes a public key from a byte array.
Throws when the byte array contains less than 33 bytes.
| Parameter | Type |
|---|---|
| First | Uint8Array |
| Returns |
|---|
| ES256PublicKey |
fromHex()
Parses a public key from its hex representation.
Throws when the string is not valid hex format or when it represents less than 33 bytes.
| Parameter | Type |
|---|---|
| First | string |
| Returns |
|---|
| ES256PublicKey |
fromRaw()
Deserializes a public key from its raw representation.
| Parameter | Type |
|---|---|
| First | Uint8Array |
| Returns |
|---|
| ES256PublicKey |
fromSpki()
Deserializes a public key from its SPKI representation.
| Parameter | Type |
|---|---|
| First | Uint8Array |
| Returns |
|---|
| ES256PublicKey |