Classes

PrivateKey

The secret (private) part of an asymmetric key pair that is typically used to digitally sign or decrypt data.

Constructors

new PrivateKey()

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

Creates a new private key from a byte array.

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

ParameterType
FirstUint8Array
Returns
PrivateKey

Properties

serializedSize

`readonly` serializedSize: `number`

PURPOSE_ID

`readonly` `static` PURPOSE\_ID: `number`

SIZE

`readonly` `static` SIZE: `number`

Methods

equals()

equals(`other`): `boolean`

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

ParameterType
FirstPrivateKey

free()

free(): `void`

serialize()

serialize(): `Uint8Array`

Serializes the private key to a byte array.


toHex()

toHex(): `string`

Formats the private key into a hex string.


deserialize()

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

Deserializes a private key from a byte array.

Throws when the byte array contains less than 32 bytes.

ParameterType
FirstUint8Array
Returns
PrivateKey

fromHex()

`static` fromHex(`hex`): [PrivateKey](PrivateKey)

Parses a private 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
PrivateKey

generate()

`static` generate(): [PrivateKey](PrivateKey)

Generates a new private key from secure randomness.

Returns
PrivateKey

On this page