[Ethereum] How to derive address from private key?

private-keypublic-key

I want to give users a private key so they can Easily get address..

Why? So a single series of digits enables them to have both public address and private key.

Of course this is for temporary use not for holding ether.

So the question is: how does one derive public address from private key?

Best Answer

assuming you are using some sort of JavaScript in your endeavor,

consider using the useful ethereumjs-util API.

Simply import it with: require('ethereumjs-util');

Specifically, you will want to use the function privateToAddress(privateKey).

It's all open source so you can browse through their code. Although you will find that all the Elliptic Curve operations are done using another library called secp256k1.

Hope this will help you achieve your goal.

Cheers, Simon