Class: 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
Creates a new private key from a byte array.
Throws when the byte array is not exactly 32 bytes long.
Parameters
• bytes: Uint8Array
Returns
Defined in
@nimiq/core/types/wasm/web.d.ts:1724
Properties
serializedSize
readonly
serializedSize:number
Defined in
@nimiq/core/types/wasm/web.d.ts:1751
PURPOSE_ID
readonly
static
PURPOSE_ID:number
Defined in
@nimiq/core/types/wasm/web.d.ts:1749
SIZE
readonly
static
SIZE:number
Defined in
@nimiq/core/types/wasm/web.d.ts:1750
Methods
equals()
equals(
other
):boolean
Returns if this private key is equal to the other private key.
Parameters
• other: PrivateKey
Returns
boolean
Defined in
@nimiq/core/types/wasm/web.d.ts:1748
free()
free():
void
Returns
void
Defined in
@nimiq/core/types/wasm/web.d.ts:1704
serialize()
serialize():
Uint8Array
Serializes the private key to a byte array.
Returns
Uint8Array
Defined in
@nimiq/core/types/wasm/web.d.ts:1729
toHex()
toHex():
string
Formats the private key into a hex string.
Returns
string
Defined in
@nimiq/core/types/wasm/web.d.ts:1742
deserialize()
static
deserialize(bytes
):PrivateKey
Deserializes a private key from a byte array.
Throws when the byte array contains less than 32 bytes.
Parameters
• bytes: Uint8Array
Returns
Defined in
@nimiq/core/types/wasm/web.d.ts:1717
fromHex()
static
fromHex(hex
):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.
Parameters
• hex: string
Returns
Defined in
@nimiq/core/types/wasm/web.d.ts:1737
generate()
static
generate():PrivateKey
Generates a new private key from secure randomness.
Returns
Defined in
@nimiq/core/types/wasm/web.d.ts:1709