11

According to this post regarding how to derive the Ethereum address from a public key:

Take the last 40 characters / 20 bytes of this public key (Keccak-256). Or, in other words, drop the first 24 characters / 12 bytes. These 40 characters / 20 bytes are the address. When prefixed with 0x it becomes 42 characters long.

My question is why the last 20 bytes (as opposed to something other than 20), is it an arbitrary decision or is there an underlying mathematical purpose to it?

1 Answer 1

7

Full public keys aren't really that useful in Ethereum*, as they don't serve any practical use. Taking the last 20 bytes is a:

  1. Heuristic aimed to simplify the management of the key; that is, copy and pasting, checksums or confirmations over the phone in large transfers.

  2. Pre-empting security mechanism. Hashing functions are broken every other decade or so, hence cutting the full public key is a great extra layer of defense. Satoshi did the same in Bitcoin, as the address is hashed twice: SHA-256 and RIPEMD-160 (if one gets broken, you still have the other one as a shield).

*You could use Ethereum for sending messages, but why would you? It's expensive and you could use PGP.

6
  • 2
    For the note "You could use Ethereum for sending messages, but why would you? It's expensive and you could use PGP": One useful scenario is to communicate with the key holder outside Ethereum, ensuring only he/she can decode the message. For further discussion please see ethresear.ch/t/from-ethereum-keys-to-pgp-communications/1947/3 Commented Aug 8, 2018 at 11:46
  • @PaulRBerg That's insightful, I forgot that Satoshi did something similar with Bitcoin addresses
    – thanos
    Commented Aug 8, 2018 at 20:09
  • So, can we cut the address to ... say 16 bytes? It could save space on the blockchain now that it is approaching to terabyte in size. Or maybe even less? What about 12 bytes ? Can we manage security just by checking the real public key in case a collision happens and then dissallow this account from being created in the StateDB?
    – Nulik
    Commented Jan 30, 2021 at 22:41
  • 10 bytes would do it I guess, and the blockchain size would be cut by 50%!!!!!
    – Nulik
    Commented Jan 30, 2021 at 22:44
  • SHA256 is broken as of 2019 so... its only a temporary thing that some cryptographic funciton is safe to use, the aren't safe any of them, no matter how many bits they are
    – Nulik
    Commented Jan 30, 2021 at 23:01

Your Answer

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

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