* #890: Add ECDSA#toEthSignedMessage for bytes type * refactor * add test, refactor * select overloaded function explicitly * use short test message string * add changelog entry Co-authored-by: Francisco Giordano <frangio.1@gmail.com> Co-authored-by: Hadrien Croubois <hadrien.croubois@gmail.com>
This commit is contained in:
@ -2,6 +2,8 @@
|
||||
|
||||
pragma solidity ^0.8.0;
|
||||
|
||||
import "../Strings.sol";
|
||||
|
||||
/**
|
||||
* @dev Elliptic Curve Digital Signature Algorithm (ECDSA) operations.
|
||||
*
|
||||
@ -204,6 +206,18 @@ library ECDSA {
|
||||
return keccak256(abi.encodePacked("\x19Ethereum Signed Message:\n32", hash));
|
||||
}
|
||||
|
||||
/**
|
||||
* @dev Returns an Ethereum Signed Message, created from `s`. This
|
||||
* produces hash corresponding to the one signed with the
|
||||
* https://eth.wiki/json-rpc/API#eth_sign[`eth_sign`]
|
||||
* JSON-RPC method as part of EIP-191.
|
||||
*
|
||||
* See {recover}.
|
||||
*/
|
||||
function toEthSignedMessageHash(bytes memory s) internal pure returns (bytes32) {
|
||||
return keccak256(abi.encodePacked("\x19Ethereum Signed Message:\n", Strings.toString(s.length), s));
|
||||
}
|
||||
|
||||
/**
|
||||
* @dev Returns an Ethereum Signed Typed Data, created from a
|
||||
* `domainSeparator` and a `structHash`. This produces hash corresponding
|
||||
|
||||
Reference in New Issue
Block a user