Skip to content

Conversation

@lennrt
Copy link

@lennrt lennrt commented Feb 9, 2018

Addresses #22

Copy link
Owner

@NickChapman NickChapman left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Some minor things but overall looks pretty good

Returns the keccak-256 hash of message, prefixed with the header used by the eth_sign RPC call
ethereumjs-util equivalent: https://github.com/ethereumjs/ethereumjs-util/blob/master/docs/index.md#hashpersonalmessage
'''
if type(message) != bytes:
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You should use isinstance instead of type

def keccak(bytes) -> str:
return sha3.keccak_256(bytes).digest()

def message_hash(message) -> str:
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

All method names should be camel case instead of snake case.

ECDSA public key recovery from signature
ethereumjs-util equivalent: https://github.com/ethereumjs/ethereumjs-util/blob/master/docs/index.md#ecrecover
'''
assert len(hash) == 32
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

For all of these asserts it would be nice if you could provide a description of why they are wrong so that people have an easier time debugging.

xc = r * r * r + 7
return pow(xc, (SECP256K1P - 1) // 2, SECP256K1P) == 1

def ecrecover_to_pub(hash, signature, chaincode = 27) -> str:
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you add types to all of your function params (for all functions not just this one)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants