Avoid validating ECDSA signatures for addresses with code in SignatureChecker (#4951)
Co-authored-by: ernestognw <ernestognw@gmail.com>
This commit is contained in:
5
.changeset/yellow-moles-hammer.md
Normal file
5
.changeset/yellow-moles-hammer.md
Normal file
@ -0,0 +1,5 @@
|
|||||||
|
---
|
||||||
|
'openzeppelin-solidity': minor
|
||||||
|
---
|
||||||
|
|
||||||
|
`SignatureChecker`: refactor `isValidSignatureNow` to avoid validating ECDSA signatures if there is code deployed at the signer's address.
|
||||||
@ -20,10 +20,12 @@ library SignatureChecker {
|
|||||||
* change through time. It could return true at block N and false at block N+1 (or the opposite).
|
* change through time. It could return true at block N and false at block N+1 (or the opposite).
|
||||||
*/
|
*/
|
||||||
function isValidSignatureNow(address signer, bytes32 hash, bytes memory signature) internal view returns (bool) {
|
function isValidSignatureNow(address signer, bytes32 hash, bytes memory signature) internal view returns (bool) {
|
||||||
(address recovered, ECDSA.RecoverError error, ) = ECDSA.tryRecover(hash, signature);
|
if (signer.code.length == 0) {
|
||||||
return
|
(address recovered, ECDSA.RecoverError err, ) = ECDSA.tryRecover(hash, signature);
|
||||||
(error == ECDSA.RecoverError.NoError && recovered == signer) ||
|
return err == ECDSA.RecoverError.NoError && recovered == signer;
|
||||||
isValidERC1271SignatureNow(signer, hash, signature);
|
} else {
|
||||||
|
return isValidERC1271SignatureNow(signer, hash, signature);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
Reference in New Issue
Block a user