Skip to content

Instantly share code, notes, and snippets.

@VictorNS69
Last active March 18, 2025 05:15
Show Gist options
  • Save VictorNS69/3708d6c20a66dcf9eec235d46e02bc76 to your computer and use it in GitHub Desktop.
Save VictorNS69/3708d6c20a66dcf9eec235d46e02bc76 to your computer and use it in GitHub Desktop.

Revisions

  1. VictorNS69 revised this gist Mar 10, 2020. No changes.
  2. VictorNS69 renamed this gist Jan 16, 2020. 1 changed file with 0 additions and 0 deletions.
    File renamed without changes.
  3. VictorNS69 created this gist Jan 16, 2020.
    23 changes: 23 additions & 0 deletions get_addres_from_pubk.py
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,23 @@
    #!/usr/bin/env python3

    """
    You will need to install the pycryptodome package.
    You can do it with:
    pip3 install pycryptodome
    Note: To install pip3, run the following command
    sudo apt install python3-pip
    """

    import codecs
    from Crypto.Hash import keccak

    # An example of public key is: a33e56a80b9dc83a4456265d877c0765cea76146e625572fc679804f8867222ca3c816433a9b6e6690b0b8e919ffa874982706e812314aae09d85fc62fc4fa3c
    public_key_bytes = codecs.decode("your public key here", "hex")
    keccak_hash = keccak.new(digest_bits=256)
    keccak_hash.update(public_key_bytes)
    keccak_digest = keccak_hash.hexdigest()
    wallet_len = 40
    wallet = "0x" + keccak_digest[-wallet_len:]

    print("address", wallet)