# Generate Ethereum Address From Private Key Python

Please take some time to understand this for your ethereium safety. Your ethereum private key can be found by hacker! You and only you are respons. Generating the EC private key. First of all we use OpenSSL ecparam command to generate an elliptic curve private key. Ethereum standard is to use the secp256k1 curve. The same curve is used by Bitcoin. This command will print the private key in PEM format (using the wonderful ASN.1 key structure) on stdout.

- Generate Ethereum Address From Private Key Python Online
- Generate Ethereum Address From Private Key Python 3
- Generate Ethereum Address From Private Key Python Code

## Generate Ethereum Address From Private Key Python Online

If you are using Node.js, you can use the package called **“ethereumjs-wallet”** to generate Ethereum private keys and addresses. This is an official package provided and maintained by the Ethereum JavaScript community.

To generate Ethereum addresses, follow these steps:

## Step 1: Create Node project

To create a new Node project, create a new folder and initialize the project using the following command.

## Step 2: Install Node dependency

Install the dependency using the following command.

## Generate Ethereum Address From Private Key Python 3

## Step 3: Generate Addresses

Here is a code to generate 1000 Ethereum Addresses.

for(let index=0; index <1000; index++){

let addressData = ethWallet.generate();

console.log(`Private key =, ${addressData.getPrivateKeyString()}`);

console.log(`Address =, ${addressData.getAddressString()}`);

}

It’s as simple as this.

However, this is not a production approach. You don’t wanna generate a private key on a random basis. If you want to generate addresses from the raw private key you can use this method.

console.log(`Private key =, ${addressData.getPrivateKeyString()}`);

console.log(`Address =, ${addressData.getAddressString()}`);

If you want to generate using the extended private key or xprv which is the most used approach, you can use this code:

console.log(`Private key =, ${addressData.getPrivateKeyString()}`);

console.log(`Address =, ${addressData.getAddressString()}`);

Check out the complete documentation for more detailed information.

Before we get deeper into the concept of Ethereum Blockchain, it is important to understand how Public Key, Private Key and Address are generated. To make this easier for beginners, I am trying to explain the technical concept with an example.

Ethereum key generation is based on elliptical curve ecp256k1. Eliptical curve (EC) is intense mathematics, and there are a lot of great articles on internet covering deep details of elliptical curve. There are standard libraries to generate Ethereum key pair in much safer way. In this article, just for demonstration, I will use elliptical curve Javascript libaray to perform elliptical curve operations.

On EC ecp256k1 , any number between **1 to 2^256-1** is a valid private key. A good library generate a private key with taking sufficient randomness into account. For this exercise we will take '1' as private key which is an acceptable private key because it lies in specified range mentioned above. Ethereum requires private key to be 256 bit long. Here is the sample code for nodejs.

This will print private key in hex which is

PK::0000000000000000000000000000000000000000000000000000000000000001

Public key is described as follows in yellow paper.

Where pu is the public key, assumed to be a byte array of size 64 (formed from the concatenation of two positive integers each < 2256) and pr is the private key, a byte array of size 32 (or a single positive integer in the aforementioned range).

This is done using group operation of EC cryptography. To derive public key, private key is multiplied by G.Multiplication used to derive public is EC multiplication which is entirely different from normal multiplication for which I am going to use JS library . G is called generator point which is one of the domain parameters of EC cryptography. G has fixed value for ecp256k1, which is recommended by experts. you can read more here.

Ethereum address is described as follows in yellow paper

## Generate Ethereum Address From Private Key Python Code

For a given private key, pr, the Ethereum address A(pr) (a 160-bit value) to which it corresponds is defined as the right most 160-bits of the Keccak hash of the corresponding ECDSA public key.

To generate Ethereum address, take Keccak-256 hash of public key. Right most 20 bytes is your Ethereum address.

PK::0000000000000000000000000000000000000000000000000000000000000001

Ethereum Address:::0x7e5f4552091a69125d5dfcb7b8c2659029395bdf

This is just an example to understand the concept. Please do not use it to generate real wallet to hold ETH.

If you find this article helpful, you may show your appreciation by sharing it. Also, you may reach me at [email protected] with your comments, questions or suggestions of any other topic that you would want to be covered at EtherWorld.co.

## Read more articles by B0-at-10.57.18-AM.png)](/2019/01/30/dksvp2p-wire-protocol-kademlia-distri06-at-5.49.05-PM.png)](/2019/02/06/reading-ethereum-geth-database-leveldb/)

EtherWorld's collection of Good Read on Blockchain & Cryptocurrency.

Also try our latest Digital Asset Calculator (DAC) and email your feedback at [email protected]

____________________________________________________________________________________________________

For more updates, technical blogs and general discussion on Blockchain Technology, please Subscribe and follow us at Twitter, Facebook, Google+ and Medium. You can also reach us at [email protected]