简体   繁体   中英

How to convert ethereum addres to public key

I need to convert ethereum address like this

0xB34080739D5B656D76089f9f21b374BA5dafA373

to public key like this

e2d3a3a43e71eb541e12504cee22ed74024969b46b9e68ea7f9e5384fe96fc04

I got the address this way

from web3 import Web3

w3 = Web3(Web3.HTTPProvider('https://sokol.poa.network'))

addr = w3.toHex(w3.sha3(text=public_key)[12:])

Maybe there is a library for that? help pls

This is not possible.

An ethereum address (for an externally owner account, which is an account linked to a private key) is the last 20 bytes of keccak256(public_key) . Since keccak256 is a hash function, and thus a one-way function, there is no way to recover the public key from the address.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM