Public key is described as follows in yellow paper. This will print private key in hex which is var privateKey=Buffer.alloc(32, 0) privateKey=1 console.log("PK::"+privateKey.toString('hex')) Ethereum requires private key to be 256 bit long.
For this exercise we will take “1” as private key which is an acceptable private key because it lies in specified range mentioned above. A good library generate a private key with taking sufficient randomness into account. On EC ecp256k1, any number between 1 to 2²⁵⁶-1 is a valid private key.
In this article, just for demonstration, I will use elliptical curve Javascript libaray to perform elliptical curve operations. There are standard libraries to generate Ethereum key pair in much safer way. Eliptical curve (EC) is intense mathematics, and there are a lot of great articles on internet covering deep details of elliptical curve. To make this easier for beginners, I am trying to explain the technical concept with an example.Įthereum key generation is based on elliptical curve ecp256k1. Before we get deeper into the concept of Ethereum Blockchain, it is important to understand how Public Key, Private Key and Address are generated.