The Cryptonomics™
  • Home
  • Blockchain
  • Bitcoin
  • Ethereum
  • NFTS
  • Altcoin
  • Mining
  • Consulting
Reading: cryptography – Learn how to convert non-public key to ethereum tackle utilizing python
Share
Please enter CoinGecko Free Api Key to get this plugin works.
The Cryptonomics™The Cryptonomics™
Font ResizerAa
Search
  • Home
  • Blockchain
  • Bitcoin
  • Ethereum
  • NFTS
  • Altcoin
  • Mining
  • Consulting
Follow US
  • About Us
  • Advertising Solutions
  • Privacy
  • Terms
  • Advertise
Copyright © MetaMedia™ Capital Inc, All right reserved
The Cryptonomics™ > Bitcoin > cryptography – Learn how to convert non-public key to ethereum tackle utilizing python
Bitcoin

cryptography – Learn how to convert non-public key to ethereum tackle utilizing python

admin
Last updated: May 24, 2024 8:47 am
admin Published May 24, 2024
Share
cryptography – Learn how to convert non-public key to ethereum tackle utilizing python


That is my code:

from eth_keys import keys
from eth_utils import decode_hex, encode_hex, keccak

def private_key_to_address(private_key_hex):
    # Make sure the non-public key's a legitimate hex string
    if private_key_hex.startswith('0x'):
        private_key_hex = private_key_hex[2:]
    
    # Convert the hex non-public key to bytes
    private_key_bytes = bytes.fromhex(private_key_hex)
    
    # Create a PrivateKey object
    private_key = keys.PrivateKey(private_key_bytes)
    
    # Derive the general public key from the non-public key
    public_key = private_key.public_key
    
    # Get the general public key bytes and skip the primary byte (which is 0x04)
    public_key_bytes = public_key.to_bytes()[1:]
    
    # Compute the Keccak-256 hash of the general public key bytes
    keccak_hash = keccak(public_key_bytes)
    
    # The Ethereum tackle is the final 20 bytes of this hash
    address_bytes = keccak_hash[-20:]
    
    # Convert the tackle bytes to a hexadecimal string and prepend '0x'
    tackle="0x" + address_bytes.hex()
    return tackle

# Instance utilization
private_key_hex = '0x0000000000000000000000000000000000000000000000000000000000000001'
eth_address = private_key_to_address(private_key_hex)
print("Ethereum Deal with:", eth_address)

I’m going to transform 0x0000000000000000000000000000000000000000000000000000000000000001 to Ethereum Deal with. So, desired output is

0x7E5F4552091A69125d5DfCb7b8C2659029395Bdf

However getting

0x6579c588be2026d866231cccc364881cc1219c56

The place is the incorrect in my code?

You Might Also Like

Shopping for Gold Bars With Crypto Results in Arrest

Bitcoin slides under $79K on macro fears: Can fixed-income outflows put it aside?

AVA is obtainable for buying and selling!

bitcoin core – What’s the precise course of for importing bitcoincore descriptor pockets to Sparrow Pockets

Multicoin Capital Sends Total AAVE Stack to Coinbase Prime After $40M Loss Deepens

Share This Article
Facebook Twitter Email Copy Link Print
Previous Article Hong Kong streaming agency to purchase 0M of crypto, Worldcoin sanctioned: Asia Specific Hong Kong streaming agency to purchase $100M of crypto, Worldcoin sanctioned: Asia Specific
Next Article Crypto icon Kabosu, the Doge meme canine, passes away at 17 Crypto icon Kabosu, the Doge meme canine, passes away at 17
Leave a comment

Leave a Reply Cancel reply

Your email address will not be published. Required fields are marked *

Subscribe to our newslettern

Get Newest Articles Instantly!

- Advertisement -
Ad imageAd image
Popular News
Grayscale, VanEck Amend BNB ETF Purposes
Grayscale, VanEck Amend BNB ETF Purposes
The journey to a mature asset administration system
The journey to a mature asset administration system
High 3 Meme Coin Gems Price Shopping for Earlier than Could 2024 – PEPE, WIF, and DOGEVERSE
High 3 Meme Coin Gems Price Shopping for Earlier than Could 2024 – PEPE, WIF, and DOGEVERSE

Follow Us on Socials

We use social media to react to breaking news, update supporters and share information

Facebook Instagram Linkedin Pinterest Tiktok Twitter Youtube
The Cryptonomics™

Cryptonomics Magazine is your premier digital source for blockchain insights, offering cutting-edge research, news, interviews, and ICO updates for everyone from entrepreneurs to institutions. We drive blockchain knowledge and growth.

Subscribe to our newsletter

Always Stay Up to Date

Subscribe to our newsletter to get our newest articles instantly!

Grayscale, VanEck Amend BNB ETF Purposes
May 18, 2026
Sandvik Floor Help inks deal to determine native US manufacturing JV
May 18, 2026
Shopping for Gold Bars With Crypto Results in Arrest
May 18, 2026
MMD, Magna showcase high-capacity, digitalised cell crushing options
May 17, 2026
SBI, Rakuten, Nomura Getting ready to Launch Crypto Funding Trusts in Japan
May 17, 2026
Copyright © The Cryptonomics™ , All right reserved
  • About Us
  • Advertising Solutions
  • Privacy
  • Terms
  • Advertise
Join Us!

Subscribe & Stay Ahead of the Curve with Cryptonomics !

Zero spam, Unsubscribe at any time.
Welcome Back!

Sign in to your account

Lost your password?