|
@@ -22,10 +22,10 @@ import "../ECRecovery.sol";
|
|
|
* `onlyValidSignatureAndData` can be used to restrict access to only a given method
|
|
|
* or a given method with given parameters respectively.
|
|
|
* See the tests Bouncer.test.js for specific usage examples.
|
|
|
- * @notice A method that uses the `onlyValidSignatureAndData` modifier must make the _sig
|
|
|
+ * @notice A method that uses the `onlyValidSignatureAndData` modifier must make the _signature
|
|
|
* parameter the "last" parameter. You cannot sign a message that has its own
|
|
|
* signature in it so the last 128 bytes of msg.data (which represents the
|
|
|
- * length of the _sig data and the _sig data itself) is ignored when validating.
|
|
|
+ * length of the _signature data and the _signaature data itself) is ignored when validating.
|
|
|
* Also non fixed sized parameters make constructing the data in the signature
|
|
|
* much more complex. See https://ethereum.stackexchange.com/a/50616 for more details.
|
|
|
*/
|
|
@@ -40,27 +40,27 @@ contract SignatureBouncer is Ownable, RBAC {
|
|
|
/**
|
|
|
* @dev requires that a valid signature of a bouncer was provided
|
|
|
*/
|
|
|
- modifier onlyValidSignature(bytes _sig)
|
|
|
+ modifier onlyValidSignature(bytes _signature)
|
|
|
{
|
|
|
- require(isValidSignature(msg.sender, _sig));
|
|
|
+ require(isValidSignature(msg.sender, _signature));
|
|
|
_;
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
* @dev requires that a valid signature with a specifed method of a bouncer was provided
|
|
|
*/
|
|
|
- modifier onlyValidSignatureAndMethod(bytes _sig)
|
|
|
+ modifier onlyValidSignatureAndMethod(bytes _signature)
|
|
|
{
|
|
|
- require(isValidSignatureAndMethod(msg.sender, _sig));
|
|
|
+ require(isValidSignatureAndMethod(msg.sender, _signature));
|
|
|
_;
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
* @dev requires that a valid signature with a specifed method and params of a bouncer was provided
|
|
|
*/
|
|
|
- modifier onlyValidSignatureAndData(bytes _sig)
|
|
|
+ modifier onlyValidSignatureAndData(bytes _signature)
|
|
|
{
|
|
|
- require(isValidSignatureAndData(msg.sender, _sig));
|
|
|
+ require(isValidSignatureAndData(msg.sender, _signature));
|
|
|
_;
|
|
|
}
|
|
|
|
|
@@ -90,14 +90,14 @@ contract SignatureBouncer is Ownable, RBAC {
|
|
|
* @dev is the signature of `this + sender` from a bouncer?
|
|
|
* @return bool
|
|
|
*/
|
|
|
- function isValidSignature(address _address, bytes _sig)
|
|
|
+ function isValidSignature(address _address, bytes _signature)
|
|
|
internal
|
|
|
view
|
|
|
returns (bool)
|
|
|
{
|
|
|
return isValidDataHash(
|
|
|
keccak256(abi.encodePacked(address(this), _address)),
|
|
|
- _sig
|
|
|
+ _signature
|
|
|
);
|
|
|
}
|
|
|
|
|
@@ -105,7 +105,7 @@ contract SignatureBouncer is Ownable, RBAC {
|
|
|
* @dev is the signature of `this + sender + methodId` from a bouncer?
|
|
|
* @return bool
|
|
|
*/
|
|
|
- function isValidSignatureAndMethod(address _address, bytes _sig)
|
|
|
+ function isValidSignatureAndMethod(address _address, bytes _signature)
|
|
|
internal
|
|
|
view
|
|
|
returns (bool)
|
|
@@ -116,16 +116,16 @@ contract SignatureBouncer is Ownable, RBAC {
|
|
|
}
|
|
|
return isValidDataHash(
|
|
|
keccak256(abi.encodePacked(address(this), _address, data)),
|
|
|
- _sig
|
|
|
+ _signature
|
|
|
);
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
* @dev is the signature of `this + sender + methodId + params(s)` from a bouncer?
|
|
|
- * @notice the _sig parameter of the method being validated must be the "last" parameter
|
|
|
+ * @notice the _signature parameter of the method being validated must be the "last" parameter
|
|
|
* @return bool
|
|
|
*/
|
|
|
- function isValidSignatureAndData(address _address, bytes _sig)
|
|
|
+ function isValidSignatureAndData(address _address, bytes _signature)
|
|
|
internal
|
|
|
view
|
|
|
returns (bool)
|
|
@@ -137,7 +137,7 @@ contract SignatureBouncer is Ownable, RBAC {
|
|
|
}
|
|
|
return isValidDataHash(
|
|
|
keccak256(abi.encodePacked(address(this), _address, data)),
|
|
|
- _sig
|
|
|
+ _signature
|
|
|
);
|
|
|
}
|
|
|
|
|
@@ -146,14 +146,14 @@ contract SignatureBouncer is Ownable, RBAC {
|
|
|
* and then recover the signature and check it against the bouncer role
|
|
|
* @return bool
|
|
|
*/
|
|
|
- function isValidDataHash(bytes32 _hash, bytes _sig)
|
|
|
+ function isValidDataHash(bytes32 _hash, bytes _signature)
|
|
|
internal
|
|
|
view
|
|
|
returns (bool)
|
|
|
{
|
|
|
address signer = _hash
|
|
|
.toEthSignedMessageHash()
|
|
|
- .recover(_sig);
|
|
|
+ .recover(_signature);
|
|
|
return hasRole(signer, ROLE_BOUNCER);
|
|
|
}
|
|
|
}
|