diff --git a/src/DidRegistry.sol b/src/DidRegistry.sol index b264694..526ebb8 100644 --- a/src/DidRegistry.sol +++ b/src/DidRegistry.sol @@ -132,15 +132,15 @@ contract DIDRegistry is IDidRegistry { VerificationMethod storage vm = didState.verificationMethods[i]; - // If trying to change the OWNERSHIP PROOF or PROTECTED flags the keyData must match the message sender - bool isUpdatingOwnershipFlag = _hasFlag(vm.flags, VerificationMethodFlagBitMask.OWNERSHIP_PROOF) != _hasFlag(flags,VerificationMethodFlagBitMask.OWNERSHIP_PROOF); - bool isUpdatingProtectedFlag = _hasFlag(vm.flags, VerificationMethodFlagBitMask.PROTECTED)!= _hasFlag(flags,VerificationMethodFlagBitMask.PROTECTED); - - if(isUpdatingOwnershipFlag || isUpdatingProtectedFlag) { - require(address(bytes20(vm.keyData)) == msg.sender, "Only the verification method authority key can set the ownership proof or protected flags"); - } - if(_stringCompare(vm.fragment, fragment)) { + // If trying to change the OWNERSHIP PROOF or PROTECTED flags the keyData must match the message sender + bool isUpdatingOwnershipFlag = _hasFlag(vm.flags, VerificationMethodFlagBitMask.OWNERSHIP_PROOF) != _hasFlag(flags,VerificationMethodFlagBitMask.OWNERSHIP_PROOF); + bool isUpdatingProtectedFlag = _hasFlag(vm.flags, VerificationMethodFlagBitMask.PROTECTED)!= _hasFlag(flags,VerificationMethodFlagBitMask.PROTECTED); + + if(isUpdatingOwnershipFlag || isUpdatingProtectedFlag) { + require(address(bytes20(vm.keyData)) == msg.sender, "Only the verification method authority key can set the ownership proof or protected flags"); + } + uint16 oldFlags = didState.verificationMethods[i].flags; didState.verificationMethods[i].flags = flags; diff --git a/test/DidRegistryVerificationMethodTest.sol b/test/DidRegistryVerificationMethodTest.sol index 8bbd9ef..43d6d42 100644 --- a/test/DidRegistryVerificationMethodTest.sol +++ b/test/DidRegistryVerificationMethodTest.sol @@ -174,7 +174,7 @@ contract DidRegistryVerificationMethodTest is DidRegistryTest { vm.expectRevert("Only the verification method authority key can set the ownership proof or protected flags"); - bool result = didRegistry.updateVerificationMethodFlags(userTwo, newVm.fragment, newFlags); + bool result = didRegistry.updateVerificationMethodFlags(userTwo, 'default', newFlags); } function test_revert_only_authorized_key_can_update_protected_flag_on_verification_methods() public { @@ -202,7 +202,7 @@ contract DidRegistryVerificationMethodTest is DidRegistryTest { vm.expectRevert("Only the verification method authority key can set the ownership proof or protected flags"); - bool result = didRegistry.updateVerificationMethodFlags(userTwo, newVm.fragment, newFlags); + bool result = didRegistry.updateVerificationMethodFlags(userTwo, 'default', newFlags); } function test_revert_should_not_be_able_to_remove_verification_method_that_does_not_exist() public {