11

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?

11

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

10

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.

  • "The address is the last 20 bytes of the public key." - you mean a hash of tha last 20 bytes, right? – raphadko Dec 12 '17 at 13:17
  • 2
    @raphadko I believe it's actually the last 20 bytes of a hash of the full public key. – smarx Dec 12 '17 at 14:04
  • Yes you are right @raphadko is the last 20 bytes of the hash I going to update the answer – Olivers De Abreu Dec 12 '17 at 15:04
6

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.

5

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

  • ecdsa isn't really used for encryption / decryption but is meant for signing and verifying. Rather something more like ECIES is. – adam-m-hanna Apr 26 '18 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. – smarx Apr 26 '18 at 23:35
  • Are ethereum keys not ECDSA? – adam-m-hanna May 1 '18 at 1:06
  • 1
    Ethereum keys are elliptic curve cryptography keys. ECDSA and ECIES are algorithms that make use of such keys. – smarx May 1 '18 at 1:37

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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