Update docs
This commit is contained in:
@ -1,5 +1,5 @@
|
||||
// SPDX-License-Identifier: MIT
|
||||
// OpenZeppelin Contracts (last updated v5.1.0) (utils/cryptography/MessageHashUtils.sol)
|
||||
// OpenZeppelin Contracts (last updated v5.3.0) (utils/cryptography/MessageHashUtils.sol)
|
||||
|
||||
pragma solidity ^0.8.20;
|
||||
|
||||
@ -19,7 +19,7 @@ library MessageHashUtils {
|
||||
*
|
||||
* The digest is calculated by prefixing a bytes32 `messageHash` with
|
||||
* `"\x19Ethereum Signed Message:\n32"` and hashing the result. It corresponds with the
|
||||
* hash signed when using the https://eth.wiki/json-rpc/API#eth_sign[`eth_sign`] JSON-RPC method.
|
||||
* hash signed when using the https://ethereum.org/en/developers/docs/apis/json-rpc/#eth_sign[`eth_sign`] JSON-RPC method.
|
||||
*
|
||||
* NOTE: The `messageHash` parameter is intended to be the result of hashing a raw message with
|
||||
* keccak256, although any bytes32 value can be safely used because the final digest will
|
||||
@ -41,7 +41,7 @@ library MessageHashUtils {
|
||||
*
|
||||
* The digest is calculated by prefixing an arbitrary `message` with
|
||||
* `"\x19Ethereum Signed Message:\n" + len(message)` and hashing the result. It corresponds with the
|
||||
* hash signed when using the https://eth.wiki/json-rpc/API#eth_sign[`eth_sign`] JSON-RPC method.
|
||||
* hash signed when using the https://ethereum.org/en/developers/docs/apis/json-rpc/#eth_sign[`eth_sign`] JSON-RPC method.
|
||||
*
|
||||
* See {ECDSA-recover}.
|
||||
*/
|
||||
@ -63,6 +63,21 @@ library MessageHashUtils {
|
||||
return keccak256(abi.encodePacked(hex"19_00", validator, data));
|
||||
}
|
||||
|
||||
/**
|
||||
* @dev Variant of {toDataWithIntendedValidatorHash-address-bytes} optimized for cases where `data` is a bytes32.
|
||||
*/
|
||||
function toDataWithIntendedValidatorHash(
|
||||
address validator,
|
||||
bytes32 messageHash
|
||||
) internal pure returns (bytes32 digest) {
|
||||
assembly ("memory-safe") {
|
||||
mstore(0x00, hex"19_00")
|
||||
mstore(0x02, shl(96, validator))
|
||||
mstore(0x16, messageHash)
|
||||
digest := keccak256(0x00, 0x36)
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @dev Returns the keccak256 digest of an EIP-712 typed data (ERC-191 version `0x01`).
|
||||
*
|
||||
|
||||
Reference in New Issue
Block a user