Class: 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() 
new ES256PublicKey(
bytes):ES256PublicKey
Creates a new public key from a byte array.
Compatible with the -7 COSE algorithm identifier.
Example 
// Create/register a credential with the Webauthn API:
const cred = await navigator.credentials.create({
    publicKey: {
        pubKeyCredParams: [{
            type: "public-key",
            alg: -7, // ES256 = ECDSA over P-256 with SHA-256
       }],
       // ...
    },
});
// Then create an instance of ES256PublicKey from the credential response:
const publicKey = new Nimiq.ES256PublicKey(new Uint8Array(cred.response.getPublicKey()));Parameters 
• bytes: Uint8Array
Returns 
Defined in 
web.d.ts:1084
Methods 
__getClassname() 
__getClassname():
string
Returns 
string
Defined in 
web.d.ts:1032
free() 
free():
void
Returns 
void
Defined in 
web.d.ts:1028
serialize() 
serialize():
Uint8Array
Serializes the public key to a byte array.
Returns 
Uint8Array
Defined in 
web.d.ts:1089
toAddress() 
toAddress():
Address
Gets the public key's address.
Returns 
Defined in 
web.d.ts:1107
toHex() 
toHex():
string
Formats the public key into a hex string.
Returns 
string
Defined in 
web.d.ts:1102
verify() 
verify(
signature,data):boolean
Verifies that a signature is valid for this public key and the provided data.
Parameters 
• signature: ES256Signature
• data: Uint8Array
Returns 
boolean
Defined in 
web.d.ts:1039
fromHex() 
staticfromHex(hex):ES256PublicKey
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.
Parameters 
• hex: string
Returns 
Defined in 
web.d.ts:1097
fromRaw() 
staticfromRaw(raw_bytes):ES256PublicKey
Deserializes a public key from its raw representation.
Parameters 
• raw_bytes: Uint8Array
Returns 
Defined in 
web.d.ts:1059
fromSpki() 
staticfromSpki(spki_bytes):ES256PublicKey
Deserializes a public key from its SPKI representation.
Parameters 
• spki_bytes: Uint8Array
Returns 
Defined in 
web.d.ts:1053
unserialize() 
staticunserialize(bytes):ES256PublicKey
Deserializes a public key from a byte array.
Throws when the byte array contains less than 33 bytes.
Parameters 
• bytes: Uint8Array
Returns 
Defined in 
web.d.ts:1047