25

I'm creating an ethereum wallet and I'm a bit confused with the concept of public key vs address. I understand that the Address is a hashed version of the public key, but when I'm generating a new wallet, I have 3 data fields: private key (used to sign a transaction), Address (used to receive a transaction), Public Key (???)

What is the practical use of the public key?

4 Answers 4

16

When you are creating a new wallet, what you are doing is creating an account. Every account has a private key and a public key, and are indexed by an address that is where you send the transaction.

The address is the last 20 bytes of the hash of the public key.

According to the documentation:

Every account is defined by a pair of keys, a private key and public key. Accounts are indexed by their address which is derived from the public key by taking the last 20 bytes. Every private key/address pair is encoded in a keyfile.

http://ethdocs.org/en/latest/account-management.html?highlight=address#keyfiles

You can find this post useful:

https://kobl.one/blog/create-full-ethereum-keypair-and-address/

Hope this helps.

4
  • "The address is the last 20 bytes of the public key." - you mean a hash of tha last 20 bytes, right?
    – sigmaxf
    Commented Dec 12, 2017 at 13:17
  • 4
    @raphadko I believe it's actually the last 20 bytes of a hash of the full public key.
    – user19510
    Commented Dec 12, 2017 at 14:04
  • Yes you are right @raphadko is the last 20 bytes of the hash I going to update the answer Commented Dec 12, 2017 at 15:04
  • AFAICS this doesn't answer the question about what is the practical use of the public key. Commented Jul 12, 2021 at 16:03
14

No specific usecase of public key, As usually one can ask for public key(address) that means informally we sometimes say public key despite of address.

An Ethereum address represents an account. For external owned accounts, the address is derived as the last 20 bytes of the public key controlling the account, e.g., cd2a3d9f938e13cd947ec0i8um67fe734df8d8861. This is a hexadecimal format (base 16 notation), which is often indicated explicitly by prepending 0x to the address. Since each byte of the address is represented by 2 hex characters, a prefixed address is 42 characters long.

Read more: Accounts, Addresses, Public And Private Keys, And Tokens

1
  • 4
    Well, transactions are signed by that user's private key, so the miners need to have access to the matching public key to be able to verify the transaction signatures. There's your use case :)
    – Xenonite
    Commented Feb 15, 2021 at 11:55
11

Ethereum security model relies on elliptic curve cryptography (ECC) to sign and validate transactions.

In ECC public and private key are used to sign and verify. It has no concept of addresses. When signing and verifying transactions you do not need addresses.

The original bitcoin paper do not mention addresses at all. They appear later in an effort to make them easier to remember (compressed public key are 32 bytes vs address 20 bytes).

Now you can completely hide public key from the user interaction and only have private key and addresses. But internaly ethereum keeps using them to validate transactions.

6

I believe there is no practical use of the public key. Because of this, in most account creation tools, the public key is never even displayed to the user.

(You could use the public key to encrypt a message such that only the private key holder can decrypt it, but this isn't typically done in Ethereum.)

4
  • ecdsa isn't really used for encryption / decryption but is meant for signing and verifying. Rather something more like ECIES is. Commented Apr 26, 2018 at 23:17
  • I agree with you, but I'm not sure what the relevance of your comment is. My answer didn't mention ECDSA.
    – user19510
    Commented Apr 26, 2018 at 23:35
  • Are ethereum keys not ECDSA? Commented May 1, 2018 at 1:06
  • 3
    Ethereum keys are elliptic curve cryptography keys. ECDSA and ECIES are algorithms that make use of such keys.
    – user19510
    Commented May 1, 2018 at 1:37

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.