DEV Community


Posted on • Originally published at on

Private Keys, Public Keys, and Addresses

This post was originally published on my blog!

Welcome back! You’ve likely heard of private keys, public keys, and addresses, but what are they, and how do they work together? Today, we’re going to explore the relationship between these cryptographic values and discover how they interact with each other.

This article contains references to secp256k1, which is the elliptic curve used in both Bitcoin and Ethereum. I will be covering this in a later blog post.

Private Keys: Your Digital Secret

At the core of your Ethereum account is a private key, a 256-bit random number that serves as your digital secret. It is used to sign transactions and messages, proving that you are the owner of the account. If someone else has access to your private key, they can sign transactions on your behalf, effectively taking control of your account.

More specifically, a private key is a randomly generated number between the values 0x01 and0xFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFEBAAEDCE6AF48A03BBFD25E8CD0364140. This range is known as the secp256k1 curve order, which is the order of the elliptic curve used in Ethereum’s cryptography.

It is important that the private key is generated using a cryptographically secure random number generator. Do not generate it using a programming language's standard library!

Public Keys: Sharing Your Digital Identity

Derived from the private key, a public key is a cryptographic value that serves as your digital identity on the Ethereum network. Unlike the private key, the public key can be shared freely without compromising the security of your assets. It is used to verify digital signatures and encrypt messages intended for you.

Because of the nature of how cryptography works, your public key can be used to verify that you are the sender of a transaction or message. However, it cannot be used to derive your private key or forge a signature.

To get a public key from a private key, we use a process called elliptic curve cryptography. This process involves multiplying the private key by a special value called the generator point, resulting in a public key. The generator point is a constant value that is defined by the secp256k1 curve.

Addresses: Your User-Friendly Identifier

An Ethereum address is a 160-bit (40 character HEX) value that is derived from the public key. It is used to identify your account on the Ethereum network. Addresses are a shorter, more user-friendly representation of public keys, which are long and difficult to remember (not that you could memorize 40 characters, anyway).

To derive an address from a public key, we get the last 20 bytes (40 chars) of the KECCAK-256 hash of the public key.

Security Best Practices

To ensure the security of your Ethereum holdings, it is crucial to follow these best practices:

  • Protect Your Private Key : Keep your private key secure and never share it with anyone. Store it in a secure offline environment, such as a hardware wallet or a secure digital storage medium. Treat your private key as cash of equal value as your cryptocurrencies!

  • Use Hardware Wallets : Consider using a hardware wallet, a physical device specifically designed for storing private keys securely. Hardware wallets provide an extra layer of protection against online threats.

  • Backup Your Private Key : Make backups of your private key and store them in multiple secure locations. This ensures that you can recover your assets in case of hardware failure or loss.

  • Be Cautious Online : Beware of phishing attempts and malicious websites that may try to trick you into revealing your private key or personal information. Always verify the authenticity of the websites and applications you use to interact with Ethereum.


While private keys, public keys, and addresses are low-level concepts, they are crucial to understanding how Ethereum works. They are the foundation of your Ethereum account and are used to sign transactions and messages. By following security best practices, you can ensure that your assets are safe and secure.

Top comments (0)