Skip to content

Class: KeyPair

A keypair represents a private key and its respective public key. It is used for signing data, usually transactions.

Table of contents

Constructors

Properties

Methods

Constructors

constructor

new KeyPair(private_key, public_key): KeyPair

Parameters

NameType
private_keyPrivateKey
public_keyPublicKey

Returns

KeyPair

Defined in

web.d.ts:1059

Properties

privateKey

Readonly privateKey: PrivateKey

Gets the keypair's private key.

Defined in

web.d.ts:1089


publicKey

Readonly publicKey: PublicKey

Gets the keypair's public key.

Defined in

web.d.ts:1093

Methods

free

free(): void

Returns

void

Defined in

web.d.ts:1027


serialize

serialize(): Uint8Array

Serializes the keypair to a byte array.

Returns

Uint8Array

Defined in

web.d.ts:1064


sign

sign(data): Signature

Signs arbitrary data, returns a signature object.

Parameters

NameType
dataUint8Array

Returns

Signature

Defined in

web.d.ts:1070


signTransaction

signTransaction(transaction): void

Signs a transaction and sets the signature proof on the transaction object.

Parameters

NameType
transactionTransaction

Returns

void

Defined in

web.d.ts:1075


toAddress

toAddress(): Address

Gets the keypair's address.

Returns

Address

Defined in

web.d.ts:1080


toHex

toHex(): string

Formats the keypair into a hex string.

Returns

string

Defined in

web.d.ts:1085


derive

derive(private_key): KeyPair

Derives a keypair from an existing private key.

Parameters

NameType
private_keyPrivateKey

Returns

KeyPair

Defined in

web.d.ts:1038


fromHex

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

NameType
hexstring

Returns

KeyPair

Defined in

web.d.ts:1046


generate

generate(): KeyPair

Generates a new keypair from secure randomness.

Returns

KeyPair

Defined in

web.d.ts:1032


unserialize

unserialize(bytes): KeyPair

Deserializes a keypair from a byte array.

Throws when the byte array contains less than 64 bytes.

Parameters

NameType
bytesUint8Array

Returns

KeyPair

Defined in

web.d.ts:1054