Skip to main content

privateKeyToPublicKey

Callable

  • privateKeyToPublicKey(privateKey: Bytes, isCompressed: boolean): string

  • Get the public key from a private key

    @example
    web3.eth.accounts.privateKeyToPublicKey("0x1e046a882bb38236b646c9f135cf90ad90a140810f439875f2a6dd8e50fa261f", true)

    > "0x42beb65f179720abaa3ec9a70a539629cbbc5ec65bb57e7fc78977796837e537662dd17042e6449dc843c281067a4d6d8d1a1775a13c41901670d5de7ee6503a" // uncompressed public key

    Parameters

    • privateKey: Bytes

      String or Uint8Array of 32 bytes

    • isCompressed: boolean

      if true, will generate a 33 byte compressed public key instead of a 65 byte public key

    Returns string

    The public key