[Tutorial] Make your own Ethereum Address From Scratch

Get a wallet, the mathematical way:


  • Install Geth (for verification)
  • Install keccak256, depends on your system. Check this. If you are having a hard time you can use this online generator.

Some amazing mathematics underlies a lot of the special abilities that are now possible to do with the world of Web3. Although you don’t need to understand it to be able to use it, the reason I am including this here is that it’s imperative to intuit how it all works without central servers managing the addresses. And because learning is awesome!

For ethereum, you are using the features of beautiful graph:

to generate a public/private key pair. A keypair allows you to share secret messages with people online and also to prove that you intended to sign digital files. This lies at the heart of decentralized tech and we want to be sure that you don’t miss out on understanding it. Ethereum’s addresses are derived by taking a hash of the public key. A hash is a function that creates a unique fixed length string from various inputs.

To generate your own ethereum address by generating your own public/private key pair and hashing your public key, you can follow this tutorial and find the code here.

Important note, I made a mistake saying that keccak is related to the elliptic curve cryptography during our call today. It’s not, it’s actually based on sponge functions.

If you’re looking for step by step code you can cut/paste into your terminal, check this out:

# Generate the private and public keys
openssl ecparam -name secp256k1 -genkey -noout |   openssl ec -text -noout > Key

# Extract the public key and remove the EC prefix 0x04
cat Key | grep pub -A 5 | tail -n +2 |  tr -d '\n[:space:]:' | sed 's/^04//' > pub

# Extract the private key and remove the leading zero byte
cat Key | grep priv -A 3 | tail -n +2 | tr -d '\n[:space:]:' | sed 's/^00//' > priv

# Generate the hash and take the address part
cat pub | keccak-256sum -x -l | tr -d ' -' | tail -c 41 > address

# (Optional) import the private key to geth
geth account import priv

If you’d like to nerd out a little more on how you can create a one way function from the elliptic curve above, read this amazing break down. It is also where I shared the step by step RSA example.


Thanks for the detailed instructions, I tried to download Geth using the link and it didn’t work.

So I am using this link: https://geth.ethereum.org/downloads/

Commands to generate public/private key
$ openssl ecparam -name secp256k1 -genkey -noout
$ openssl ecparam -name secp256k1 -genkey -noout | openssl ec -text -noout
$ openssl ecparam -name secp256k1 -genkey -noout | openssl ec -text -noout > Key
$ cat Key | grep pub -A 5 | tail -n +2 | tr -d ‘\n[:space:]:’ | sed ‘s/^7-04//’ > pub
$ cat Key | grep priv -A 3 | tail -n +2 | tr -d ‘\n[:space:]:’ | sed ‘s/^3-00//’ > priv
$ cat pub | keccak-256sum -x -l | tr -d ’ -’ | tail -c 41 > address
HELP: keccak-256sum: file is malformated


I already happened to have geth…but had trouble with https://github.com/ethereum/eth-hash (keccak-256sum) install, so I found https://github.com/maandree/sha3sum, cloned the repo, ran make, and then I had access to keccak-256sum binary!

After that, I got it to work.


when i am trying to install linkeccak then it’s giving me below error cna you please tell how you sort out this issue. and i am installing it on Mac os Mojave.

cc -shared -Wl,-soname,libkeccak.so.1 -o libkeccak.so digest.o libkeccak_behex_lower.o libkeccak_behex_upper.o libkeccak_degeneralise_spec.o libkeccak_generalised_sum_fd.o libkeccak_hmac_copy.o libkeccak_hmac_digest.o libkeccak_hmac_fast_digest.o libkeccak_hmac_fast_update.o libkeccak_hmac_set_key.o libkeccak_hmac_unmarshal.o libkeccak_hmac_update.o libkeccak_hmac_wipe.o libkeccak_state_copy.o libkeccak_state_initialise.o libkeccak_state_marshal.o libkeccak_state_unmarshal.o libkeccak_state_wipe.o libkeccak_state_wipe_message.o libkeccak_state_wipe_sponge.o libkeccak_unhex.o -s
ld: warning: option -s is obsolete and being ignored
ld: unknown option: -soname
clang: error: linker command failed with exit code 1 (use -v to see invocation)
make: *** [libkeccak.so] Error 1

1 Like

Thank you Bilal for heads up. First I tried doing it on my own but finally I had to take your help. I did it on a Windows machine (You can call me a rookie). So now if anyone needs help generating wallet on a Windows machine, feel free to ping me.


Just if anyone ended up to this post, you can download geth from here for different OS

It’s stuck at linking keccak’s object files and getting out the executable. You can use the online generator instead for now :wink: … and ahh! please share with us the source where you tried to install keccak manually

I have installed keccak manually, if I recall correctly I got it from here: https://github.com/maandree/sha3sum

Are people still having issues with keccak?

Very interesting, can you check the values of the Key and pub / priv files? Are they actually getting created?

Yeah i cloned that library when i try to install then its giving the linkeccak library issue. But i i try to install linkeccak library it gives me lot of error. Earlier i mentioned the errors above in the topic.

Hi Tintin, I am using windows 10 unsuccessfully. I would appreciate if you give me a hand crating address and keys under this OS.
Best regards

I’m on Linux (Ubuntu 18.04) and these steps have worked for me :

  1. git clone https://github.com/maandree/libkeccak
  2. cd libkeccak
  3. make
  4. sudo make install

If the installation is ok then do these steps :

  1. git clone https://github.com/maandree/sha3sum
  2. cd sha3sum
  3. make

Best regards

1 Like

Maybe something useful, use sudo make install PREFIX=/usr (for the step 4 of libkeccak installation) to avoid shared library errors when you want to use sha3sum.

1 Like

Hey Albnar! Following are the steps:

  1. Install openssl from here
  2. Install geth from https://geth.ethereum.org/downloads/
  3. Generate key pair using “openssl ecparam -name secp256k1 -genkey -noout | openssl ec -text -noout > Key”. The result will look like this:

Private-Key: (256 bit)
ASN1 OID: secp256k1

  1. Use “type Key” to check your keys
  2. Copy your public key and paste it in notepad. Remove all the spaces, colons ( : ) and newline characters. Also remove the 04 in the beginning of the string. Your key should look like this:

Save the file as ‘pub’.

  1. I used this calculator to generate keccak256 hash. Please refer image for the settings.

  2. Repeat step 5 for your private key. There is one difference; remove the leading ‘00’ if there is and save the file as ‘priv’

  3. Create Ethereum account using “geth account import priv” command. After entering the password, an address will be generated. Compare it with the last 40 characters of your keccak256 hash. If they are same, everything worked fine else repeat the process.

I followed the tutorial suggested by Bilal with a few tweaks. I hope it works for you. All the best.


Hi Nitin,

thank you very much for your help.

Everything run well but the last step. The generated Address from geth is totally different as the Keccak256 hash. I repeated the procedure tree times with the same results. I followed your instruction regarding the calculator settings. I used Notepad++ for edition. Public Key is 128char long and Privat 64Char long.

The only difference is the version of both programs. I installed openssl_win64 and geth for 64bit too. Should I install 32bit versions instead?

Many thanks in advance

Hi Nitin,
I am terribly sorry. I am a fool. I compared the first 40 char not the last ones :flushed:
best regards

1 Like

Don’t be so tough on yourself bro. Let’s get back to work and finish the last part of assignment. I am still clueless about where to start. May be you can help me with that.

Awesome work you guys! This aha moment of finding the last 40 vs the first 40 chars is a strong learning moment, you wont forget it and also now you know where the addresses come from.
Any idea why the random chopping of bytes?

This is awesome and should be it’s own post in the https://community.elk.cc/c/bc-iot-bootcamp/bc-week-1-theory-background subcategory :)!

Hi tintin,
I shared my public key, as indicated by Bilal.
Now I will try to send a message. If I succeed I will share it with you. Is it OK.