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.

    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) & ((input) => Uint8Array);
      } = internalSha256

      an implementation of sha256

      • hash: ((input) => Uint8Array) & ((input) => Uint8Array)

    Returns string

    Remarks

    WIF-encoding uses the Base58Address format with version Base58AddressFormatVersion.wif (128/0x80) or Base58AddressFormatVersion.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.

    For the reverse, see decodePrivateKeyWif.

Generated using TypeDoc