Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

zero-pad signature bytes of messages, return r & s as integers #477

Merged
merged 2 commits into from
Dec 1, 2017

Conversation

carver
Copy link
Collaborator

@carver carver commented Nov 30, 2017

What was wrong?

#466 signature bytes were not 0-padded on message signatures

How was it fixed?

  • 0-pad them r and s in signature bytes
  • return r and s as integers
  • r and s in transactions remain not 0-padded

Cute Animal Picture

Cute animal picture

Copy link
Member

@pipermerriam pipermerriam left a comment

Choose a reason for hiding this comment

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

I'm thinking that a hypothesis test for this might be a good thing since we have some reasonably strong properties that we can assert about signatures and signed transactions and that type of test likely would have caught this bug.

  • A signed transaction's signature recovers to the expected sender address
  • The raw transaction can be rlp decoded into a transaction object
  • An rlp decoded transaction object's v,r,s match the v,r,s from the signature.
  • The signature bytes are 65 bytes in length

Those are the ones that come to mind.

eth_signature_bytes = b''.join(map(to_bytes, (r, s, v)))
(v_raw, r, s) = signature.vrs
v = to_eth_v(v_raw)
(r_bytes, s_bytes) = map(to_bytes32, (r, s))
Copy link
Member

Choose a reason for hiding this comment

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

r_bytes, s_bytes = to_bytes32(r), to_bytes32(s)
# or
r_bytes = to_bytes32(r)
s_bytes = to_bytes32(s)

Minor readability improvements?

@carver carver merged commit 9d2005b into master Dec 1, 2017
@carver carver deleted the carver/padded-signature-vals branch December 1, 2017 01:45
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.

None yet

2 participants