Classes
PrivateKey
The secret (private) part of an asymmetric key pair that is typically used to digitally sign or decrypt data.
Constructors
new PrivateKey()
Creates a new private key from a byte array.
Throws when the byte array is not exactly 32 bytes long.
Parameter | Type |
---|---|
First | Uint8Array |
Returns |
---|
PrivateKey |
Properties
serializedSize
PURPOSE_ID
SIZE
Methods
equals()
Returns if this private key is equal to the other private key.
Parameter | Type |
---|---|
First | PrivateKey |
free()
serialize()
Serializes the private key to a byte array.
toHex()
Formats the private key into a hex string.
deserialize()
Deserializes a private key from a byte array.
Throws when the byte array contains less than 32 bytes.
Parameter | Type |
---|---|
First | Uint8Array |
Returns |
---|
PrivateKey |
fromHex()
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.
Parameter | Type |
---|---|
First | string |
Returns |
---|
PrivateKey |
generate()
Generates a new private key from secure randomness.
Returns |
---|
PrivateKey |