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?

2 Answers 2

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.

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.
0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.