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

feat: add toDataWithIntendedValidatorHash() with messageHash #5081

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions .changeset/quiet-shrimps-kiss.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"openzeppelin-solidity": patch
---

feat: add `toDataWithIntendedValidatorHash()` with `messageHash`
13 changes: 13 additions & 0 deletions contracts/utils/cryptography/MessageHashUtils.sol
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,19 @@ library MessageHashUtils {
return keccak256(abi.encodePacked(hex"19_00", validator, data));
}

/**
* @dev Returns the keccak256 digest of an ERC-191 signed data with version
* `0x00` (data with intended validator).
*
* The digest is calculated by prefixing a bytes32 `messageHash` with `"\x19\x00"` and the intended
* `validator` address. Then hashing the result.
*
* See {ECDSA-recover}.
*/
function toDataWithIntendedValidatorHash(address validator, bytes32 messageHash) internal pure returns (bytes32) {
return toDataWithIntendedValidatorHash(validator, abi.encodePacked(messageHash));
}

/**
* @dev Returns the keccak256 digest of an EIP-712 typed data (ERC-191 version `0x01`).
*
Expand Down
Loading