Classes

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](KeyPair)
ParameterType
FirstPublicKey
Returns
KeyPair

Properties

privateKey

`readonly` privateKey: [PrivateKey](PrivateKey)

Gets the keypair's private key.


publicKey

`readonly` publicKey: [PublicKey](PublicKey)

Gets the keypair's public key.

Methods

free()

free(): `void`

serialize()

serialize(): `Uint8Array`

Serializes the keypair to a byte array.


sign()

sign(`data`): [Signature](Signature)

Signs arbitrary data, returns a signature object.

ParameterType
FirstUint8Array
Returns
Signature

signTransaction()

signTransaction(`transaction`): `void`

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

ParameterType
FirstTransaction

toAddress()

toAddress(): [Address](Address)

Gets the keypair's address.

Returns
Address

toHex()

toHex(): `string`

Formats the keypair into a hex string.


derive()

`static` derive(`private_key`): [KeyPair](KeyPair)

Derives a keypair from an existing private key.

ParameterType
FirstPrivateKey
Returns
KeyPair

deserialize()

`static` deserialize(`bytes`): [KeyPair](KeyPair)

Deserializes a keypair from a byte array.

Throws when the byte array contains less than 64 bytes.

ParameterType
FirstUint8Array
Returns
KeyPair

fromHex()

`static` fromHex(`hex`): [KeyPair](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.

ParameterType
Firststring
Returns
KeyPair

generate()

`static` generate(): [KeyPair](KeyPair)

Generates a new keypair from secure randomness.

Returns
KeyPair

On this page