Function encodePrivateKeyWif

  • Encode a private key using Wallet Import Format (WIF).

    WIF encodes the 32-byte private key, a 4-byte checksum, and a type indicating the intended usage for the private key. See WalletImportFormatType for details.

    Remarks

    WIF-encoding uses the Base58Address format with version wif (128/0x80) or wifTestnet (239/0xef), respectively.

    To indicate that the private key is intended for use in a P2PKH address using the compressed form of its derived public key, a 0x01 is appended to the payload prior to encoding. For the uncompressed construction, the extra byte is omitted.

    Parameters

    • privateKey: Uint8Array

      a 32-byte Secp256k1 ECDSA private key

    • type: WalletImportFormatType

      the intended usage of the private key (e.g. mainnet or testnet)

    • sha256: {
          hash: ((input: Uint8Array) => Uint8Array);
      } = internalSha256

      an implementation of sha256

      • hash: ((input: Uint8Array) => Uint8Array)
          • (input: Uint8Array): Uint8Array
          • Returns the sha256 hash of the provided input.

            To incrementally construct a sha256 hash (e.g. for streaming), use init, update, and final.

            Parameters

            • input: Uint8Array

              a Uint8Array to be hashed using sha256

            Returns Uint8Array

    Returns string

Generated using TypeDoc