KeyManager

KeyManager

Create, import, and export Topl Bifrost keys. Also allows for signing of transactions.
Author:
  • James Aman (j.aman@topl.me)
  • Raul Aragonez (r.aragonez@topl.me)
Source:

Classes

KeyManager

Members

address

Getter for private property #address
Source:

address

Setter for private property #address
Source:

isLocked

Getter for private property #isLocked
Source:

isLocked

Setter for private property #isLocked
Source:

networkPrefix

Getter for private property #networkPrefix
Source:

networkPrefix

Setter for private property #isLocked
Source:

pk

Getter for private property #pk
Source:

pk

Setter for private property #pk
Source:

Methods

(static) GetKeyStorage() → {object}

Getter function to retrieve key storage in the Bifrost compatible format
Source:
Returns:
Type:
object
returns value of private var keyStorage

(static) importKeyFile(keyFile:, password:) → {object}

Static wrapper of importing the key pair via a constructor. Generates a new instance of a keyManager with the imported keyFile and password.
Source:
Parameters:
Name Type Description
keyFile: object The JS object representing the encrypted keyfile
password: string The password to unlock the keyfile
Returns:
Type:
object
returns the keyStorage used in the KeyManager

(static) importKeyFileFromDisk(keyFilePath:, password:) → {object}

Static wrapper of importing the key file from disk via the constructor. Generates a new instance of a keyManager with the imported keyFile and password.
Source:
Parameters:
Name Type Description
keyFilePath: string The JS object representing the encrypted keyfile
password: string The password to unlock the keyfile
Returns:
Type:
object
returns the keyStorage used in the KeyManager

(static) setKeyStorage(keyStorage, password) → {object}

Setter function to input keyStorage in the Bifrost compatible format
Source:
Parameters:
Name Type Description
keyStorage object The keyStorage object that the keyManager will use to store the keys for a particular address.
password string for encrypting (decrypting) the keyfile
Returns:
Type:
object
returns a key storage object

(static) Verify(publicKey, message, signature) → {function}

Check whether a private key was used to generate the signature for a message. This method is static so that it may be used without generating a keyfile
Source:
Parameters:
Name Type Description
publicKey Buffer | string A public key (if string, must be bs58 encoded)
message string Message to sign (utf-8 encoded)
signature Buffer | string Signature to verify (if string, must be bs58 encoded)
Returns:
Type:
function
returns function Verify

exportToFile(_keyPathopt) → {string}

Export formatted JSON to keystore file.
Source:
Parameters:
Name Type Attributes Description
_keyPath string <optional>
Path to keystore folder (default: ".keyfiles")
Returns:
Type:
string
JSON filename

lockKey() → {void}

Set the key manager to locked so that the private key may not be decrypted
Source:
Returns:
Type:
void

sign(message) → {Uint8Array}

Generate the signature of a message using the provided private key
Source:
Parameters:
Name Type Description
message string Message to sign (utf-8 encoded)
Returns:
Type:
Uint8Array
signature

unlockKey(password) → {void}

Unlock the key manager to be used in transactions
Source:
Parameters:
Name Type Description
password string encryption password for accessing the keystorage object
Returns:
Type:
void