5

I understand that in Bitcoin, addresses are hashed public keys. However, I've also heard that compressed public keys are just as short as hashes while maintaining their 1:1 relationship.

Does Ethereum use hashed public keys, or compressed public keys, for addresses?

Akhil F
  • 1,928
  • 3
  • 19
  • 29

2 Answers2

6

The Public Key is hashed with SHA-3 to produce a 256-bit output. The upper 96 bits are discarded, and the lower 160 bits become the Address.

Source

Thus, addresses do not seem to preserve all of the information in the public key.

Tjaden Hess
  • 37,046
  • 10
  • 91
  • 118
5

Ethereum uses hashed public keys. It does not use compressed public keys.

Important note is that Ethereum uses Keccak-256 instead of the SHA-3 standard.

Sample Python code:

def privtoaddr(x):
    if len(x) > 32:
        x = decode_hex(x)
    return sha3(bitcoin.privtopub(x)[1:])[12:]  # sha3 here is Keccak-256
  1. The public key is computed from the private key
  2. Public key is hashed with Keccak-256
  3. The upper 12 bytes (96 bits) of the Keccak-256 output is discarded.
eth
  • 85,679
  • 53
  • 285
  • 406