We suppose that I have a private key I used to sign my data with it before the comming of ethereum. is't possible to create an ethereum address based on my existent public key ?
3 Answers
Can we create an ethereum address with a public key of my choice?
Yes, but...
An Ethereum private key is just 256 random bits. You can generate those 256 bits in any way you like, including seeding it from an existing key (which is just a source of entropy).
If the key you already have isn't a 256-bit number, you'll either need to create a 256-bit representation of it (using a hash function), or find another way to deterministically map your existing key to those 256 bits. (e.g. If the key is greater than 256 bits, just truncate it to 256 bits, etc.)
Note that in your question title you said public key. If you're using your existing public key to seed your new Ethereum private key, you'd better ensure that your mapping from public key -> 256-bit seed is difficult for an attacker to work out. (Because your existing public key is public... )
(If what you're actually asking is "I have an existing key pair, can I use it in Ethereum?", then the answer is probably not. Unless it uses the exact same hashing functions and elliptic curve.)
You can then feed the resulting key into a (Ethereum-based) tool of your choice to create a public key (via ECDSA) and address (the last 20 bytes of a keccak256()
hash of the X/Y coordinates of the public key).
- See: How are ethereum addresses generated?
- See: Graphical Ethereum Address (though it seems not to be HTTPS anymore... )
You can create a private key and can create ethereum address using that. For more details, refer: https://docs.ethers.io/ethers.js/html/api-wallet.html
Hope it helps!
Address is the last 20 bytes of the hash of your public key.
In Ethereum, Your private key and public key are used to sign and verify.
In interactions you are only using your private key and address but internally Ethereum keeps using them to validate transactions.