@hashgraph/sdk
    Preparing search index...

    Class PrivateKeyNamespace

    proto

    Hierarchy (View Summary)

    Index

    Properties

    _key: PrivateKey

    Accessors

    • get chainCode(): null | Uint8Array<ArrayBufferLike>

      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<ArrayBufferLike>

    • 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

    • deprecated - This method is deprecated and will be removed in future versions. Use the signTransaction method with the legacy=false flag or don't pass it all for the modern approach.

      Parameters

      Returns Uint8Array<ArrayBufferLike> | Uint8Array<ArrayBufferLike>[]

    • 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>

      If this key does not support derivation.

    • Recover the recovery ID used in the signature for the given message.

      Note: This method only works for ECDSA secp256k1 keys.

      Parameters

      • r: Uint8Array<ArrayBufferLike>

        32-byte r component of the signature

      • s: Uint8Array<ArrayBufferLike>

        32-byte s component of the signature

      • message: Uint8Array<ArrayBufferLike>

        The original (unhashed) message

      Returns number

      Recovery ID (0–3), or -1 if not found or not applicable

    • 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<ArrayBufferLike>

      Returns Uint8Array<ArrayBufferLike>

      • The signature bytes without the message
    • Returns Uint8Array<ArrayBufferLike>

    • Returns Uint8Array<ArrayBufferLike>

    • Returns Uint8Array<ArrayBufferLike>

    • 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

      • Optionalpassphrase: string = ""

      Returns Promise<Uint8Array<ArrayBufferLike>>

    • Construct a private key from bytes. Requires DER header.

      Parameters

      • data: Uint8Array<ArrayBufferLike>

      Returns PrivateKey

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

      This key will not support child key derivation.

      Parameters

      • data: Uint8Array<ArrayBufferLike>
      • Optionalpassphrase: string = ""

      Returns Promise<PrivateKey>

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

    • Parameters

      • mnemonic: string | Mnemonic
      • Optionalpassphrase: string = ""

      Returns Promise<PrivateKey>

      • 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
      • Optionalpassphrase: string = ""

      Returns Promise<PrivateKey>

    • Construct a Ed25519 private key from a Uint8Array seed.

      Parameters

      • seed: Uint8Array<ArrayBufferLike>

      Returns Promise<PrivateKey>

    • Construct a Ed25519 private key from a Uint8Array seed.

      Parameters

      • seed: Uint8Array<ArrayBufferLike>

      Returns Promise<PrivateKey>

    • Parameters

      • text: string

      Returns PrivateKey

      • Use fromStringECDSA() or fromStringED2551() on a HEX-encoded string and fromStringDer() on a HEX-encoded string with DER prefix instead. Construct a private key from a hex-encoded string. Requires DER header.
    • Parameters

      • privateKey: string

      Returns "ed25519" | "ecdsa"