@@ -2,6 +2,8 @@ pragma solidity ^0.6.12;
2
2
pragma experimental ABIEncoderV2;
3
3
4
4
import "@openzeppelin/contracts/math/SafeMath.sol " ;
5
+ import "@openzeppelin/contracts/cryptography/ECDSA.sol " ;
6
+
5
7
import "../governance/Managed.sol " ;
6
8
7
9
/*
@@ -717,7 +719,11 @@ contract DisputeManager is Managed {
717
719
718
720
// Obtain the signer of the fully-encoded EIP-712 message hash
719
721
// NOTE: The signer of the attestation is the indexer that served the request
720
- return _recover (messageHash, _attestation.v, _attestation.r, _attestation.s);
722
+ return
723
+ ECDSA.recover (
724
+ messageHash,
725
+ abi.encodePacked (_attestation.r, _attestation.s, _attestation.v)
726
+ );
721
727
}
722
728
723
729
/**
@@ -755,41 +761,6 @@ contract DisputeManager is Managed {
755
761
return Attestation (requestCID, responseCID, subgraphDeploymentID, v, r, s);
756
762
}
757
763
758
- /**
759
- * @dev Returns the address that signed a hashed message (`hash`) with
760
- * signature `v`, `r', `s`. This address can then be used for verification purposes.
761
- * @return The address recovered from the hash and signature.
762
- */
763
- function _recover (
764
- bytes32 _hash ,
765
- uint8 _v ,
766
- bytes32 _r ,
767
- bytes32 _s
768
- ) internal pure returns (address ) {
769
- // EIP-2 still allows signature malleability for ecrecover(). Remove this possibility and make the signature
770
- // unique. Appendix F in the Ethereum Yellow paper (https://ethereum.github.io/yellowpaper/paper.pdf), defines
771
- // the valid range for s in (281): 0 < s < secp256k1n ÷ 2 + 1, and for v in (282): v ∈ {27, 28}. Most
772
- // signatures from current libraries generate a unique signature with an s-value in the lower half order.
773
- //
774
- // If your library generates malleable signatures, such as s-values in the upper range, calculate a new s-value
775
- // with 0xFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFEBAAEDCE6AF48A03BBFD25E8CD0364141 - s1 and flip v from 27 to 28 or
776
- // vice versa. If your library also generates signatures with 0/1 for v instead 27/28, add 27 to v to accept
777
- // these malleable signatures as well.
778
- if (uint256 (_s) > 0x7FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF5D576E7357A4501DDFE92F46681B20A0 ) {
779
- revert ("ECDSA: invalid signature 's' value " );
780
- }
781
-
782
- if (_v != 27 && _v != 28 ) {
783
- revert ("ECDSA: invalid signature 'v' value " );
784
- }
785
-
786
- // If the signature is valid (and not malleable), return the signer address
787
- address signer = ecrecover (_hash, _v, _r, _s);
788
- require (signer != address (0 ), "ECDSA: invalid signature " );
789
-
790
- return signer;
791
- }
792
-
793
764
/**
794
765
* @dev Parse a uint8 from `_bytes` starting at offset `_start`.
795
766
* @return uint8 value
0 commit comments