ethereum / eth-keys

A common API for Ethereum key operations.
MIT License
159 stars 64 forks source link

TypeError: 'property' object is not callable #38

Closed Netherdrake closed 6 years ago

Netherdrake commented 6 years ago
pip install -U web3
...
Successfully installed eth-keys-0.1.0b4 eth-utils-0.8.1

What was wrong?

Signature class won't initialize. It fails with error:

TypeError: 'property' object is not callable
pipermerriam commented 6 years ago

Please provide full stack trace as well as the code that causes the error.

Netherdrake commented 6 years ago
def recover_address(data: Union[str, bytes], signature: str) -> str:
    signature = binascii.unhexlify(remove_0x_prefix(signature))
    if type(data) == str:
        data = keccak(text=data)

    # web3js outputs in rsv order
    vrs = (
        ord(signature[64:65]) - 27,
        big_endian_to_int(signature[0:32]),
        big_endian_to_int(signature[32:64]),
    )
    sig = KeyAPI.Signature(vrs=vrs)
    return sig.recover_public_key_from_msg(data).to_address()

This works fine in eth-keys-0.2.0b3.

However in current web3 pypi package, I get:

data = b'A\xb1\xa0d\x97R\xaf\x1b(\xb3\xdc)\xa1Un\xeex\x1eJL:\x1f\x7fS\xf9\x0f\xa84\xde\t\x8cM'
signature = b'B\x0f5Qu\xb5\xc2\xa9h-\xde\x10r\xa9X\xfb\x19;\xdc\xef\x84\x9c\x02\xf0\x90\x00\x19I)\x08\x86B\x17\x81\\\x1ej\xa2\x84\xfa\x83Y\xbc\x02\x06@\xf2tiR\x1e,\xd5\x89\xee\x86\xa6\xb4\x18!\xf1\xc2T\xd3\x1b'

    def recover_address(data: Union[str, bytes], signature: str) -> str:
        signature = binascii.unhexlify(remove_0x_prefix(signature))
        if type(data) == str:
            data = keccak(data)

        # web3js outputs in rsv order
        vrs = (
            ord(signature[64:65]) - 27,
            big_endian_to_int(signature[0:32]),
            big_endian_to_int(signature[32:64]),
        )
>       sig = KeyAPI.Signature(vrs=vrs)
E       TypeError: 'property' object is not callable

../../src/core/eth.py:52: TypeError
pipermerriam commented 6 years ago

You should go look up the API in the README.md. You are trying to use the KeyAPI class directly however it needs to be instantiated (at least in the older versions of the library).

See docs here: https://github.com/ethereum/eth-keys#keyapibackendnone