diff --git a/contracts/protocol/core/UniqueIdentity.sol b/contracts/protocol/core/UniqueIdentity.sol index 73201c2..0be4e2b 100644 --- a/contracts/protocol/core/UniqueIdentity.sol +++ b/contracts/protocol/core/UniqueIdentity.sol @@ -47,10 +47,7 @@ contract UniqueIdentity is BaseUpgradeablePausable, IUniqueIdentity { bytes32 ethSignedMessage = keccak256(abi.encodePacked("\x19Ethereum Signed Message:\n32", h)); address recovered = tryRecover(ethSignedMessage, signature); require(hasRole(SIGNER_ROLE, recovered), "Invalid signer"); - _; - } - modifier incrementNonce(address account) { nonces[account] += 1; _; } @@ -84,7 +81,7 @@ contract UniqueIdentity is BaseUpgradeablePausable, IUniqueIdentity { uint256 id, uint256 expiresAt, bytes calldata signature - ) public override onlySigner(_msgSender(), id, expiresAt, signature) incrementNonce(_msgSender()) { + ) public override onlySigner(_msgSender(), id, expiresAt, signature) { require(supportedUIDTypes[id] == true, "Token id not supported"); require(expiration[_msgSender()][id] == 0, "Expiration before must be 0"); require(expiresAt > block.timestamp, "Expiration must be bigger than current timestamp"); @@ -97,7 +94,7 @@ contract UniqueIdentity is BaseUpgradeablePausable, IUniqueIdentity { uint256 id, uint256 expiresAt, bytes calldata signature - ) public override onlySigner(account, id, expiresAt, signature) incrementNonce(account) { + ) public override onlySigner(account, id, expiresAt, signature) { require(expiresAt > block.timestamp, "Expiration must be bigger than current time"); require(supportedUIDTypes[id] == true, "Token id not supported"); @@ -122,16 +119,6 @@ contract UniqueIdentity is BaseUpgradeablePausable, IUniqueIdentity { expiration[account][id] = expiresAt; } - function tryRecover( - bytes32 hash, - bytes32 r, - bytes32 vs - ) internal pure returns (address) { - bytes32 s = vs & bytes32(0x7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff); - uint8 v = uint8((uint256(vs) >> 255) + 27); - return tryRecover(hash, v, r, s); - } - function tryRecover( bytes32 hash, uint8 v, @@ -173,16 +160,6 @@ contract UniqueIdentity is BaseUpgradeablePausable, IUniqueIdentity { v := byte(0, mload(add(signature, 0x60))) } return tryRecover(hash, v, r, s); - } else if (signature.length == 64) { - bytes32 r; - bytes32 vs; - // ecrecover takes the signature parameters, and the only way to get them - // currently is to use assembly. - assembly { - r := mload(add(signature, 0x20)) - vs := mload(add(signature, 0x40)) - } - return tryRecover(hash, r, vs); } else { revert("InvalidSignatureLength"); } diff --git a/contracts/test/TestUniqueIdentity.sol b/contracts/test/TestUniqueIdentity.sol index 382228f..c5ef252 100644 --- a/contracts/test/TestUniqueIdentity.sol +++ b/contracts/test/TestUniqueIdentity.sol @@ -10,7 +10,8 @@ contract TestUniqueIdentity is UniqueIdentity { uint256 id, uint256 expiresAt, bytes memory data - ) public onlyAdmin incrementNonce(to) { + ) public onlyAdmin { + nonces[to] += 1; _updateExpiration(to, id, expiresAt); } }