Class PrivateKeyNamespace

proto

Hierarchy

  • Key
    • PrivateKey

Properties

_key: default

Accessors

  • get chainCode(): null | Uint8Array
  • Get the public key associated with this private key.

    The public key can be freely given and used by other parties to verify the signatures generated by this private key.

    Returns null | Uint8Array

  • get publicKey(): PublicKey
  • Get the public key associated with this private key.

    The public key can be freely given and used by other parties to verify the signatures generated by this private key.

    Returns PublicKey

Methods

  • Derive a new private key at the given wallet index.

    Only currently supported for keys created with fromMnemonic(); other keys will throw an error.

    You can check if a key supports derivation with .supportsDerivation()

    Parameters

    • index: number

    Returns Promise<PrivateKey>

    Throws

    If this key does not support derivation.

  • Check if derive can be called on this private key.

    This is only the case if the key was created from a mnemonic.

    Returns boolean

  • Sign a message with this private key.

    Parameters

    • bytes: Uint8Array

    Returns Uint8Array

    • The signature bytes without the message
  • Create a keystore with a given passphrase.

    The key can be recovered later with fromKeystore().

    Note that this will not retain the ancillary data used for deriving child keys, thus .derive() on the restored key will throw even if this instance supports derivation.

    Parameters

    • Optional passphrase: string = ""

    Returns Promise<Uint8Array>

  • Recover a private key from a keystore, previously created by .toKeystore().

    This key will not support child key derivation.

    Parameters

    • data: Uint8Array
    • Optional passphrase: string = ""

    Returns Promise<PrivateKey>

    Throws

    If the passphrase is incorrect or the hash fails to validate.

  • Parameters

    • mnemonic: string | default | Mnemonic
    • Optional passphrase: string = ""

    Returns Promise<PrivateKey>

    Deprecated

    • Use Mnemonic.from[Words|String]().to[Ed25519|Ecdsa]PrivateKey() instead

    Recover a private key from a mnemonic phrase (and optionally a password).

  • Recover a private key from a pem string; the private key may be encrypted.

    This method assumes the .pem file has been converted to a string already.

    If passphrase is not null or empty, this looks for the first ENCRYPTED PRIVATE KEY section and uses passphrase to decrypt it; otherwise, it looks for the first PRIVATE KEY section and decodes that as a DER-encoded private key.

    Parameters

    • data: string
    • Optional passphrase: string = ""

    Returns Promise<PrivateKey>

Generated using TypeDoc