vkobel/ethereum-generate-wallet

REST API : Return Address and Private Key

Closed this issue · 2 comments

Thanks for the reference. I am trying to generate the address and the private key through a REST API Call using your code. But the address is showing the same as the input. can you please review my code. is that correct?

from ecdsa import SigningKey, SECP256k1
import sha3

PRIVATE_KEY = 'private_key'
PUBLIC_KEY = 'public_key'
ADDRESS = 'address'

def generate_user_burn_address(request_args):
    addr_str = request_args['addr_str'];
    keccak = sha3.keccak_256()
    out = ''
    addr = addr_str.lower().replace('0x', '')
    keccak.update(addr.encode('ascii'))
    hash_addr = keccak.hexdigest()
    for i, c in enumerate(addr):
        if int(hash_addr[i], 16) >= 8:
            out += c.upper()
        else:
            out += c
    address = '0x' + out
    priv = SigningKey.generate(curve=SECP256k1)
    pub = priv.get_verifying_key().to_string()
    private_key = priv.to_string().hex()
    public_key = pub.hex()
    return {PRIVATE_KEY: private_key, ADDRESS: address}

Thanks,
Raja K

This isn't an issue

this is expected, the address returned by the checksum function is the same, it will just change an address' case to match what has been defined in EIP55