Class: KeyPair
A keypair represents a private key and its respective public key. It is used for signing data, usually transactions.
Constructors
new KeyPair()
new KeyPair(
private_key
,public_key
):KeyPair
Parameters
• private_key: PrivateKey
• public_key: PublicKey
Returns
Defined in
@nimiq/core/types/wasm/web.d.ts:1282
Properties
privateKey
readonly
privateKey:PrivateKey
Gets the keypair's private key.
Defined in
@nimiq/core/types/wasm/web.d.ts:1312
publicKey
readonly
publicKey:PublicKey
Gets the keypair's public key.
Defined in
@nimiq/core/types/wasm/web.d.ts:1316
Methods
free()
free():
void
Returns
void
Defined in
@nimiq/core/types/wasm/web.d.ts:1250
serialize()
serialize():
Uint8Array
Serializes the keypair to a byte array.
Returns
Uint8Array
Defined in
@nimiq/core/types/wasm/web.d.ts:1287
sign()
sign(
data
):Signature
Signs arbitrary data, returns a signature object.
Parameters
• data: Uint8Array
Returns
Defined in
@nimiq/core/types/wasm/web.d.ts:1293
signTransaction()
signTransaction(
transaction
):void
Signs a transaction and sets the signature proof on the transaction object.
Parameters
• transaction: Transaction
Returns
void
Defined in
@nimiq/core/types/wasm/web.d.ts:1298
toAddress()
toAddress():
Address
Gets the keypair's address.
Returns
Defined in
@nimiq/core/types/wasm/web.d.ts:1303
toHex()
toHex():
string
Formats the keypair into a hex string.
Returns
string
Defined in
@nimiq/core/types/wasm/web.d.ts:1308
derive()
static
derive(private_key
):KeyPair
Derives a keypair from an existing private key.
Parameters
• private_key: PrivateKey
Returns
Defined in
@nimiq/core/types/wasm/web.d.ts:1261
fromHex()
static
fromHex(hex
):KeyPair
Parses a keypair from its hex representation.
Throws when the string is not valid hex format or when it represents less than 64 bytes.
Parameters
• hex: string
Returns
Defined in
@nimiq/core/types/wasm/web.d.ts:1269
generate()
static
generate():KeyPair
Generates a new keypair from secure randomness.
Returns
Defined in
@nimiq/core/types/wasm/web.d.ts:1255
unserialize()
static
unserialize(bytes
):KeyPair
Deserializes a keypair from a byte array.
Throws when the byte array contains less than 64 bytes.
Parameters
• bytes: Uint8Array
Returns
Defined in
@nimiq/core/types/wasm/web.d.ts:1277