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

China Leverages Crypto Management Over Trump Household Wealth

Asserting the acquisition of Capitalise.ai, bringing no-code buying and selling automation to Kraken Professional

bitcoin core – why is pockets UX nonetheless so rubbish in 2025?

Loaded Lions Evolves From An Iconic NFT Drop To A International Model

Sharps Expertise Targets Largest Solana Treasury in $400 Million Personal Providing

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
Why 2.2 million verified identities might reshape who income most in Lido ETH staking
Why 2.2 million verified identities might reshape who income most in Lido ETH staking
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!

Why 2.2 million verified identities might reshape who income most in Lido ETH staking
August 27, 2025
Swarm Community Raised $13M to Facilitate Decentralized AI
August 27, 2025
What made his one‑in‑a‑million win potential
August 27, 2025
China Leverages Crypto Management Over Trump Household Wealth
August 27, 2025
Ethereum Longs at Threat? Analyst Warns of Recurring Weekly Liquidation Sample
August 27, 2025
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?