How Ethereum Addresses Are Generated

·

Ethereum and Bitcoin share similarities in address generation, following the sequence: private key -> public key -> address. However, Ethereum simplifies the process from public key to address.

Key Components of Ethereum Address Generation

  1. Secp256k1 Elliptic Curve:
    Ethereum uses the same elliptic curve algorithm as Bitcoin to derive private and public keys.
  2. Keccak-256 Hashing:
    The public key undergoes Keccak-256 hashing, and the last 40 hexadecimal characters form the Ethereum address.
  3. Offline Generation:
    Like Bitcoin, Ethereum addresses can be generated without an internet connection.

Python Code to Generate an Ethereum Address

Prerequisites

Install these libraries:

pip install ecdsa pysha3

Code Implementation

import binascii
import sha3
from ecdsa import SigningKey, SECP256k1

# Generate private key
priv = SigningKey.generate(curve=SECP256k1)  

# Derive public key
pub = priv.get_verifying_key()  

# Keccak-256 hashing
keccak = sha3.keccak_256()
keccak.update(pub.to_string())  
address = "0x" + keccak.hexdigest()[24:]  

# Output keys and address
priv_key = binascii.hexlify(priv.to_string())
pub_key = binascii.hexlify(pub.to_string())
print("Private key: " + priv_key.decode())
print("Public key: " + pub_key.decode())
print("Address: " + address)
# Example Output: Address: 0xd38d3c226d0a86ce9932608edac39163fcbc550e

Cross-Chain Private Key Management

A single private key can manage both Bitcoin and Ethereum addresses. Here’s how:

  1. Shared Algorithm:
    Both networks use Secp256k1, allowing interoperability of keys.
  2. Example:
    Using an uncompressed Bitcoin public key (remove leading 04):

    _openssl_pub_key = "04d061e9c5891f579fd548cfd22ff29f5c642714cc7e7a9215f0071ef5a5723f691757b28e31be71f09f24673eed52348e58d53bcfd26f4d96ec6bf1489eab429d"
    _pub_key = _openssl_pub_key[2:]
  3. Generated Address:
    The code above yields 0x9156a7cdab767ffe161ed21a0cb0b688b545b01f, linked to the same private key as the Bitcoin address 14xfJr1DArtYR156XBs28FoYk6sQqirT2s.

    👉 Explore multi-chain wallet security tips


Risks and Considerations


FAQ

1. Can I use the same private key for other cryptocurrencies?

Yes, if they support Secp256k1 (e.g., Litecoin). Always verify the curve requirements.

2. How does Keccak-256 differ from SHA-256?

Keccak-256 is Ethereum’s preferred hashing algorithm, while Bitcoin uses SHA-256.

3. Are uncompressed public keys still usable?

Ethereum requires stripping the 04 prefix. Modern systems prefer compressed keys for efficiency.

4. What tools can generate Ethereum addresses offline?

Libraries like web3.js, ethers.js, or Python’s ecdsa support offline generation.

5. How can I recover funds if a private key is lost?

Without backups, recovery is impossible. Always store keys securely.


References

👉 Learn advanced wallet management strategies