use hashed keys + dont require issuer to be claim signer
This commit is contained in:
parent
1c375daeb0
commit
8bf51bc488
|
@ -17,7 +17,7 @@ contract Identity is ERC725, ERC735 {
|
||||||
|
|
||||||
uint256 nonce;
|
uint256 nonce;
|
||||||
address recoveryContract;
|
address recoveryContract;
|
||||||
address recoveryManager;
|
bytes32 recoveryManager;
|
||||||
|
|
||||||
struct Transaction {
|
struct Transaction {
|
||||||
bool valid;
|
bool valid;
|
||||||
|
@ -31,7 +31,7 @@ contract Identity is ERC725, ERC735 {
|
||||||
|
|
||||||
modifier managerOnly {
|
modifier managerOnly {
|
||||||
require(
|
require(
|
||||||
isKeyPurpose(bytes32(msg.sender), MANAGEMENT_KEY)
|
isKeyPurpose(keccak256(msg.sender), MANAGEMENT_KEY)
|
||||||
);
|
);
|
||||||
_;
|
_;
|
||||||
}
|
}
|
||||||
|
@ -40,7 +40,7 @@ contract Identity is ERC725, ERC735 {
|
||||||
if(msg.sender == address(this)) {
|
if(msg.sender == address(this)) {
|
||||||
_;
|
_;
|
||||||
} else {
|
} else {
|
||||||
require(isKeyPurpose(bytes32(msg.sender), MANAGEMENT_KEY));
|
require(isKeyPurpose(keccak256(msg.sender), MANAGEMENT_KEY));
|
||||||
if (purposeThreshold[MANAGEMENT_KEY] == 1) {
|
if (purposeThreshold[MANAGEMENT_KEY] == 1) {
|
||||||
_;
|
_;
|
||||||
} else {
|
} else {
|
||||||
|
@ -51,7 +51,7 @@ contract Identity is ERC725, ERC735 {
|
||||||
modifier recoveryOnly {
|
modifier recoveryOnly {
|
||||||
require(
|
require(
|
||||||
recoveryContract != address(0) &&
|
recoveryContract != address(0) &&
|
||||||
msg.sender == address(recoveryContract)
|
msg.sender == recoveryContract
|
||||||
);
|
);
|
||||||
_;
|
_;
|
||||||
}
|
}
|
||||||
|
@ -78,19 +78,21 @@ contract Identity is ERC725, ERC735 {
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
require(
|
require(
|
||||||
address(_key) == ecrecover(
|
_key == keccak256(
|
||||||
|
ecrecover(
|
||||||
keccak256("\x19Ethereum Signed Message:\n32", _signHash),
|
keccak256("\x19Ethereum Signed Message:\n32", _signHash),
|
||||||
_v,
|
_v,
|
||||||
_r,
|
_r,
|
||||||
_s
|
_s
|
||||||
)
|
)
|
||||||
|
)
|
||||||
);
|
);
|
||||||
require(keys[_key].purpose != 0);
|
require(keys[_key].purpose != 0);
|
||||||
_;
|
_;
|
||||||
}
|
}
|
||||||
|
|
||||||
function Identity() public {
|
constructor() public {
|
||||||
_constructIdentity(msg.sender);
|
_constructIdentity(keccak256(msg.sender));
|
||||||
}
|
}
|
||||||
|
|
||||||
function ()
|
function ()
|
||||||
|
@ -100,21 +102,21 @@ contract Identity is ERC725, ERC735 {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
function managerReset(address _newKey)
|
function managerReset(bytes32 _newKey)
|
||||||
public
|
public
|
||||||
recoveryOnly
|
recoveryOnly
|
||||||
{
|
{
|
||||||
recoveryManager = _newKey;
|
recoveryManager = _newKey;
|
||||||
_addKey(bytes32(recoveryManager), MANAGEMENT_KEY, 0);
|
_addKey(keccak256(recoveryManager), MANAGEMENT_KEY, 0);
|
||||||
purposeThreshold[MANAGEMENT_KEY] = keysByPurpose[MANAGEMENT_KEY].length;
|
purposeThreshold[MANAGEMENT_KEY] = keysByPurpose[MANAGEMENT_KEY].length;
|
||||||
}
|
}
|
||||||
|
|
||||||
function processManagerReset(uint256 _limit)
|
function processManagerReset(uint256 _limit)
|
||||||
public
|
public
|
||||||
{
|
{
|
||||||
require(recoveryManager != address(0));
|
require(recoveryManager != 0);
|
||||||
uint256 limit = _limit;
|
uint256 limit = _limit;
|
||||||
bytes32 newKey = bytes32(recoveryManager);
|
bytes32 newKey = recoveryManager;
|
||||||
bytes32[] memory managers = keysByPurpose[MANAGEMENT_KEY];
|
bytes32[] memory managers = keysByPurpose[MANAGEMENT_KEY];
|
||||||
uint256 totalManagers = managers.length;
|
uint256 totalManagers = managers.length;
|
||||||
|
|
||||||
|
@ -132,7 +134,7 @@ contract Identity is ERC725, ERC735 {
|
||||||
}
|
}
|
||||||
|
|
||||||
if (totalManagers == 1) {
|
if (totalManagers == 1) {
|
||||||
recoveryManager = address(0);
|
delete recoveryManager;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -188,7 +190,7 @@ contract Identity is ERC725, ERC735 {
|
||||||
if (purposeThreshold[requiredKey] == 1) {
|
if (purposeThreshold[requiredKey] == 1) {
|
||||||
executionId = nonce; //(?) useless in this case
|
executionId = nonce; //(?) useless in this case
|
||||||
nonce++; //(?) should increment
|
nonce++; //(?) should increment
|
||||||
require(isKeyPurpose(bytes32(msg.sender), requiredKey));
|
require(isKeyPurpose(keccak256(msg.sender), requiredKey));
|
||||||
_to.call.value(_value)(_data); //(?) success not used
|
_to.call.value(_value)(_data); //(?) success not used
|
||||||
emit Executed(executionId, _to, _value, _data); //no information on success
|
emit Executed(executionId, _to, _value, _data); //no information on success
|
||||||
} else {
|
} else {
|
||||||
|
@ -200,10 +202,9 @@ contract Identity is ERC725, ERC735 {
|
||||||
|
|
||||||
function approve(uint256 _id, bool _approval)
|
function approve(uint256 _id, bool _approval)
|
||||||
public
|
public
|
||||||
managerOrActor(bytes32(msg.sender))
|
|
||||||
returns (bool success)
|
returns (bool success)
|
||||||
{
|
{
|
||||||
return _approve(bytes32(msg.sender), _id, _approval);
|
return _approve(keccak256(msg.sender), _id, _approval);
|
||||||
}
|
}
|
||||||
|
|
||||||
function setMinimumApprovalsByKeyType(
|
function setMinimumApprovalsByKeyType(
|
||||||
|
@ -238,8 +239,7 @@ contract Identity is ERC725, ERC735 {
|
||||||
_includeClaim(claimHash, _claimType, _scheme, _issuer, _signature, _data, _uri);
|
_includeClaim(claimHash, _claimType, _scheme, _issuer, _signature, _data, _uri);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
require(_issuer == msg.sender);
|
require(isKeyPurpose(keccak256(msg.sender), CLAIM_SIGNER_KEY));
|
||||||
require(isKeyPurpose(bytes32(msg.sender), CLAIM_SIGNER_KEY));
|
|
||||||
_execute(address(this), 0, msg.data);
|
_execute(address(this), 0, msg.data);
|
||||||
emit ClaimRequested(
|
emit ClaimRequested(
|
||||||
claimHash,
|
claimHash,
|
||||||
|
@ -434,13 +434,13 @@ contract Identity is ERC725, ERC735 {
|
||||||
recoveryContract = _recoveryContract;
|
recoveryContract = _recoveryContract;
|
||||||
}
|
}
|
||||||
|
|
||||||
function _constructIdentity(address _manager)
|
function _constructIdentity(bytes32 _managerKey)
|
||||||
internal
|
internal
|
||||||
{
|
{
|
||||||
require(keysByPurpose[MANAGEMENT_KEY].length == 0);
|
require(keysByPurpose[MANAGEMENT_KEY].length == 0);
|
||||||
require(purposeThreshold[MANAGEMENT_KEY] == 0);
|
require(purposeThreshold[MANAGEMENT_KEY] == 0);
|
||||||
_addKey(bytes32(_manager), MANAGEMENT_KEY, 0);
|
_addKey(_managerKey, MANAGEMENT_KEY, 0);
|
||||||
_addKey(bytes32(_manager), ACTION_KEY, 0);
|
_addKey(_managerKey, ACTION_KEY, 0);
|
||||||
|
|
||||||
purposeThreshold[MANAGEMENT_KEY] = 1;
|
purposeThreshold[MANAGEMENT_KEY] = 1;
|
||||||
purposeThreshold[ACTION_KEY] = 1;
|
purposeThreshold[ACTION_KEY] = 1;
|
||||||
|
|
Loading…
Reference in New Issue