Namespace: KeyStore

KeyStore~KeyStore

The instance returned by module:KeyStore.

Source:

Methods

(async) addKey(id, key)

Adds a private key to the keystore.

Parameters:
Name Type Description
id string

An id of the Identity to whom the key belongs to.

key Uint8Array

The private key to store.

Source:

(async) clear()

Clears the KeyStore's underlying storage.

Source:

(async) close()

Closes the KeyStore's underlying storage.

Source:

(async) createKey(id)

Creates a key pair and stores it to the keystore.

Parameters:
Name Type Description
id string

An id of the Identity to generate the key pair for.

Source:
Throws:

id needed to create a key if no id is specified.

(async) getKey(id) → {Uint8Array}

Gets a key from keystore.

Parameters:
Name Type Description
id string

An id of the Identity whose key to retrieve.

Source:
Throws:

id needed to get a key if no id is specified.

Returns:

The key specified by id.

Type
Uint8Array

(async) getPublic(keys, options) → {Uint8Array|String}

Gets the serialized public key from a key pair.

Parameters:
Name Type Description
keys *

A key pair.

options Object

One or more options.

Properties
Name Type Attributes Default Description
format Object <optional>
hex

The format the public key should be returned in.

Source:
Throws:

Supported formats are hex and buffer if an invalid format is passed in options.

Returns:

The public key.

Type
Uint8Array | String

(async) hasKey(id) → {boolean}

Checks if a key exists in the key store .

Parameters:
Name Type Description
id string

The id of an Identity to check the key for.

Source:
Throws:

id needed to check a key if no id is specified.

Returns:

True if the key exists, false otherwise.

Type
boolean