Skip to content

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

KeyPair

Defined in

web.d.ts:1256

Properties

privateKey

readonly privateKey: PrivateKey

Gets the keypair's private key.

Defined in

web.d.ts:1286


publicKey

readonly publicKey: PublicKey

Gets the keypair's public key.

Defined in

web.d.ts:1290

Methods

free()

free(): void

Returns

void

Defined in

web.d.ts:1224


serialize()

serialize(): Uint8Array

Serializes the keypair to a byte array.

Returns

Uint8Array

Defined in

web.d.ts:1261


sign()

sign(data): Signature

Signs arbitrary data, returns a signature object.

Parameters

data: Uint8Array

Returns

Signature

Defined in

web.d.ts:1267


signTransaction()

signTransaction(transaction): void

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

Parameters

transaction: Transaction

Returns

void

Defined in

web.d.ts:1272


toAddress()

toAddress(): Address

Gets the keypair's address.

Returns

Address

Defined in

web.d.ts:1277


toHex()

toHex(): string

Formats the keypair into a hex string.

Returns

string

Defined in

web.d.ts:1282


derive()

static derive(private_key): KeyPair

Derives a keypair from an existing private key.

Parameters

private_key: PrivateKey

Returns

KeyPair

Defined in

web.d.ts:1235


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

KeyPair

Defined in

web.d.ts:1243


generate()

static generate(): KeyPair

Generates a new keypair from secure randomness.

Returns

KeyPair

Defined in

web.d.ts:1229


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

KeyPair

Defined in

web.d.ts:1251