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

Updated Message Hashing with Cairo's hash_state #49

Merged
merged 2 commits into from
Nov 9, 2021

Conversation

andrew-fleming
Copy link
Collaborator

Updated Message Hashing with Cairo's hash_state

Summary

This PR includes the Account contract's custom hash_message and hash_calldata functions refactored to include Cairo's hash_state as referenced in #37 . The hash_message() function first invokes hash_calldata() and saves the reference locally before utilizing hash_state_ptr to iterate through the rest of the message.

Cairo's hash_state.py provides compute_hash_on_elements() to greatly simplify testing. The Signer.py module is updated with this function accordingly.

Implementation

  • Removed all hash2() functions from Account.cairo and Signer.py
  • Utilized Cairo's hash_state in both hash_message() and hash_calldata()
  • Implemented compute_hash_on_elements() appropriately in the Signer.py module

Future

  • Perhaps, we can further distill the process and remove hash_calldata() from the Account contract altogether

Copy link
Contributor

@martriay martriay left a comment

Choose a reason for hiding this comment

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

Very nice.

@martriay martriay merged commit 8177d11 into OpenZeppelin:main Nov 9, 2021
@andrew-fleming andrew-fleming deleted the hash-state branch November 18, 2021 04:51
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