did:cow, a proposal for an ID resolution method with most of the convenience of did:plc/did:web and the robustness of a public blockchain
3
fork

Configure Feed

Select the types of activity you want to include in your feed.

tweak gas estimation stuff

+163 -43
+27 -15
.gas-snapshot
··· 1 - CowRegistryUpdateTest:test_updateController_plc1() (gas: 76855) 2 - CowRegistryUpdateTest:test_updateController_plc2() (gas: 76898) 3 - CowRegistryUpdateTest:test_updateController_rejectsNonController() (gas: 71387) 4 - CowRegistryUpdateTest:test_updateController_web_long() (gas: 126007) 5 - CowRegistryUpdateTest:test_updateController_web_medium() (gas: 76874) 6 - CowRegistryUpdateTest:test_updateController_web_short() (gas: 76836) 7 - CowRegistryUpdateTest:test_updateController_web_verylong() (gas: 150794) 8 - CowRegistryUpdateTest:test_updateWrappedDID_plc1_to_plc2() (gas: 80575) 9 - CowRegistryUpdateTest:test_updateWrappedDID_plc2_to_plc1() (gas: 80530) 10 - CowRegistryUpdateTest:test_updateWrappedDID_rejectsAfterDeactivation() (gas: 57084) 11 - CowRegistryUpdateTest:test_updateWrappedDID_rejectsNonController() (gas: 74148) 12 - CowRegistryUpdateTest:test_updateWrappedDID_web_long() (gas: 130099) 13 - CowRegistryUpdateTest:test_updateWrappedDID_web_medium() (gas: 80508) 14 - CowRegistryUpdateTest:test_updateWrappedDID_web_short() (gas: 80554) 15 - CowRegistryUpdateTest:test_updateWrappedDID_web_verylong() (gas: 155057) 1 + CowRegistryUpdateTest:test_on_first_update_updateController_plc1() (gas: 75394) 2 + CowRegistryUpdateTest:test_on_first_update_updateController_plc2() (gas: 75416) 3 + CowRegistryUpdateTest:test_on_first_update_updateController_web_long() (gas: 125198) 4 + CowRegistryUpdateTest:test_on_first_update_updateController_web_medium() (gas: 75326) 5 + CowRegistryUpdateTest:test_on_first_update_updateController_web_short() (gas: 75356) 6 + CowRegistryUpdateTest:test_on_first_update_updateController_web_verylong() (gas: 150184) 7 + CowRegistryUpdateTest:test_on_first_update_updateWrappedDID_plc1_to_plc2() (gas: 78994) 8 + CowRegistryUpdateTest:test_on_first_update_updateWrappedDID_plc2_to_plc1() (gas: 78974) 9 + CowRegistryUpdateTest:test_on_first_update_updateWrappedDID_web_long() (gas: 128604) 10 + CowRegistryUpdateTest:test_on_first_update_updateWrappedDID_web_medium() (gas: 79060) 11 + CowRegistryUpdateTest:test_on_first_update_updateWrappedDID_web_short() (gas: 79062) 12 + CowRegistryUpdateTest:test_on_first_update_updateWrappedDID_web_verylong() (gas: 153513) 13 + CowRegistryUpdateTest:test_preregistered_updateController_plc1() (gas: 76899) 14 + CowRegistryUpdateTest:test_preregistered_updateController_plc2() (gas: 76834) 15 + CowRegistryUpdateTest:test_preregistered_updateController_web_long() (gas: 126051) 16 + CowRegistryUpdateTest:test_preregistered_updateController_web_medium() (gas: 76830) 17 + CowRegistryUpdateTest:test_preregistered_updateController_web_short() (gas: 76814) 18 + CowRegistryUpdateTest:test_preregistered_updateController_web_verylong() (gas: 150837) 19 + CowRegistryUpdateTest:test_preregistered_updateWrappedDID_plc1_to_plc2() (gas: 80598) 20 + CowRegistryUpdateTest:test_preregistered_updateWrappedDID_plc2_to_plc1() (gas: 80553) 21 + CowRegistryUpdateTest:test_preregistered_updateWrappedDID_web_long() (gas: 130145) 22 + CowRegistryUpdateTest:test_preregistered_updateWrappedDID_web_medium() (gas: 80553) 23 + CowRegistryUpdateTest:test_preregistered_updateWrappedDID_web_short() (gas: 80508) 24 + CowRegistryUpdateTest:test_preregistered_updateWrappedDID_web_verylong() (gas: 155123) 25 + CowRegistryUpdateTest:test_updateController_rejectsNonController() (gas: 71409) 26 + CowRegistryUpdateTest:test_updateWrappedDID_rejectsAfterDeactivation() (gas: 57067) 27 + CowRegistryUpdateTest:test_updateWrappedDID_rejectsNonController() (gas: 74170)
+136 -28
test/CowRegistry.t.sol
··· 29 29 return registry.calculateCowHash(ctrl, did); 30 30 } 31 31 32 - // ------------------------------------------------------------------------- 33 - // updateWrappedDID — did:plc 34 - // ------------------------------------------------------------------------- 32 + // ========================================================================= 33 + // updateWrappedDID — pre-registered (initializeCow already called) 34 + // ========================================================================= 35 35 36 - function test_updateWrappedDID_plc1_to_plc2() public { 36 + function test_preregistered_updateWrappedDID_plc1_to_plc2() public { 37 37 bytes32 cowHash = _init(controller1, plcDID1); 38 38 39 39 vm.prank(controller1); ··· 43 43 assertEq(did, plcDID2); 44 44 } 45 45 46 - function test_updateWrappedDID_plc2_to_plc1() public { 46 + function test_preregistered_updateWrappedDID_plc2_to_plc1() public { 47 47 bytes32 cowHash = _init(controller2, plcDID2); 48 48 49 49 vm.prank(controller2); ··· 53 53 assertEq(did, plcDID1); 54 54 } 55 55 56 - // ------------------------------------------------------------------------- 57 - // updateWrappedDID — did:web varying lengths 58 - // ------------------------------------------------------------------------- 59 - 60 - function test_updateWrappedDID_web_short() public { 56 + function test_preregistered_updateWrappedDID_web_short() public { 61 57 bytes32 cowHash = _init(controller1, plcDID1); 62 58 63 59 vm.prank(controller1); ··· 67 63 assertEq(did, webDIDShort); 68 64 } 69 65 70 - function test_updateWrappedDID_web_medium() public { 66 + function test_preregistered_updateWrappedDID_web_medium() public { 71 67 bytes32 cowHash = _init(controller1, plcDID1); 72 68 73 69 vm.prank(controller1); ··· 77 73 assertEq(did, webDIDMedium); 78 74 } 79 75 80 - function test_updateWrappedDID_web_long() public { 76 + function test_preregistered_updateWrappedDID_web_long() public { 81 77 bytes32 cowHash = _init(controller1, plcDID1); 82 78 83 79 vm.prank(controller1); ··· 87 83 assertEq(did, webDIDLong); 88 84 } 89 85 90 - function test_updateWrappedDID_web_verylong() public { 86 + function test_preregistered_updateWrappedDID_web_verylong() public { 91 87 bytes32 cowHash = _init(controller1, plcDID1); 92 88 93 89 vm.prank(controller1); ··· 97 93 assertEq(did, webDIDVeryLong); 98 94 } 99 95 100 - // ------------------------------------------------------------------------- 101 - // updateController — did:plc 102 - // ------------------------------------------------------------------------- 96 + // ========================================================================= 97 + // updateController — pre-registered 98 + // ========================================================================= 103 99 104 - function test_updateController_plc1() public { 100 + function test_preregistered_updateController_plc1() public { 105 101 bytes32 cowHash = _init(controller1, plcDID1); 106 102 107 103 vm.prank(controller1); ··· 111 107 assertEq(ctrl, controller2); 112 108 } 113 109 114 - function test_updateController_plc2() public { 110 + function test_preregistered_updateController_plc2() public { 115 111 bytes32 cowHash = _init(controller2, plcDID2); 116 112 117 113 vm.prank(controller2); ··· 121 117 assertEq(ctrl, controller1); 122 118 } 123 119 124 - // ------------------------------------------------------------------------- 125 - // updateController — did:web varying lengths 126 - // ------------------------------------------------------------------------- 127 - 128 - function test_updateController_web_short() public { 120 + function test_preregistered_updateController_web_short() public { 129 121 bytes32 cowHash = _init(controller1, webDIDShort); 130 122 131 123 vm.prank(controller1); ··· 135 127 assertEq(ctrl, controller2); 136 128 } 137 129 138 - function test_updateController_web_medium() public { 130 + function test_preregistered_updateController_web_medium() public { 139 131 bytes32 cowHash = _init(controller1, webDIDMedium); 140 132 141 133 vm.prank(controller1); ··· 145 137 assertEq(ctrl, controller2); 146 138 } 147 139 148 - function test_updateController_web_long() public { 140 + function test_preregistered_updateController_web_long() public { 149 141 bytes32 cowHash = _init(controller1, webDIDLong); 150 142 151 143 vm.prank(controller1); ··· 155 147 assertEq(ctrl, controller2); 156 148 } 157 149 158 - function test_updateController_web_verylong() public { 150 + function test_preregistered_updateController_web_verylong() public { 159 151 bytes32 cowHash = _init(controller1, webDIDVeryLong); 160 152 161 153 vm.prank(controller1); ··· 165 157 assertEq(ctrl, controller2); 166 158 } 167 159 168 - // ------------------------------------------------------------------------- 160 + // ========================================================================= 161 + // updateWrappedDID — on first update (registration + update in one tx) 162 + // ========================================================================= 163 + 164 + function test_on_first_update_updateWrappedDID_plc1_to_plc2() public { 165 + vm.prank(controller1); 166 + registry.updateWrappedDID(controller1, plcDID1, plcDID2); 167 + 168 + bytes32 cowHash = registry.calculateCowHash(controller1, plcDID1); 169 + (, string memory did) = registry.cows(cowHash); 170 + assertEq(did, plcDID2); 171 + } 172 + 173 + function test_on_first_update_updateWrappedDID_plc2_to_plc1() public { 174 + vm.prank(controller2); 175 + registry.updateWrappedDID(controller2, plcDID2, plcDID1); 176 + 177 + bytes32 cowHash = registry.calculateCowHash(controller2, plcDID2); 178 + (, string memory did) = registry.cows(cowHash); 179 + assertEq(did, plcDID1); 180 + } 181 + 182 + function test_on_first_update_updateWrappedDID_web_short() public { 183 + vm.prank(controller1); 184 + registry.updateWrappedDID(controller1, plcDID1, webDIDShort); 185 + 186 + bytes32 cowHash = registry.calculateCowHash(controller1, plcDID1); 187 + (, string memory did) = registry.cows(cowHash); 188 + assertEq(did, webDIDShort); 189 + } 190 + 191 + function test_on_first_update_updateWrappedDID_web_medium() public { 192 + vm.prank(controller1); 193 + registry.updateWrappedDID(controller1, plcDID1, webDIDMedium); 194 + 195 + bytes32 cowHash = registry.calculateCowHash(controller1, plcDID1); 196 + (, string memory did) = registry.cows(cowHash); 197 + assertEq(did, webDIDMedium); 198 + } 199 + 200 + function test_on_first_update_updateWrappedDID_web_long() public { 201 + vm.prank(controller1); 202 + registry.updateWrappedDID(controller1, plcDID1, webDIDLong); 203 + 204 + bytes32 cowHash = registry.calculateCowHash(controller1, plcDID1); 205 + (, string memory did) = registry.cows(cowHash); 206 + assertEq(did, webDIDLong); 207 + } 208 + 209 + function test_on_first_update_updateWrappedDID_web_verylong() public { 210 + vm.prank(controller1); 211 + registry.updateWrappedDID(controller1, plcDID1, webDIDVeryLong); 212 + 213 + bytes32 cowHash = registry.calculateCowHash(controller1, plcDID1); 214 + (, string memory did) = registry.cows(cowHash); 215 + assertEq(did, webDIDVeryLong); 216 + } 217 + 218 + // ========================================================================= 219 + // updateController — on first update 220 + // ========================================================================= 221 + 222 + function test_on_first_update_updateController_plc1() public { 223 + vm.prank(controller1); 224 + registry.updateController(controller1, plcDID1, controller2); 225 + 226 + bytes32 cowHash = registry.calculateCowHash(controller1, plcDID1); 227 + (address ctrl, ) = registry.cows(cowHash); 228 + assertEq(ctrl, controller2); 229 + } 230 + 231 + function test_on_first_update_updateController_plc2() public { 232 + vm.prank(controller2); 233 + registry.updateController(controller2, plcDID2, controller1); 234 + 235 + bytes32 cowHash = registry.calculateCowHash(controller2, plcDID2); 236 + (address ctrl, ) = registry.cows(cowHash); 237 + assertEq(ctrl, controller1); 238 + } 239 + 240 + function test_on_first_update_updateController_web_short() public { 241 + vm.prank(controller1); 242 + registry.updateController(controller1, webDIDShort, controller2); 243 + 244 + bytes32 cowHash = registry.calculateCowHash(controller1, webDIDShort); 245 + (address ctrl, ) = registry.cows(cowHash); 246 + assertEq(ctrl, controller2); 247 + } 248 + 249 + function test_on_first_update_updateController_web_medium() public { 250 + vm.prank(controller1); 251 + registry.updateController(controller1, webDIDMedium, controller2); 252 + 253 + bytes32 cowHash = registry.calculateCowHash(controller1, webDIDMedium); 254 + (address ctrl, ) = registry.cows(cowHash); 255 + assertEq(ctrl, controller2); 256 + } 257 + 258 + function test_on_first_update_updateController_web_long() public { 259 + vm.prank(controller1); 260 + registry.updateController(controller1, webDIDLong, controller2); 261 + 262 + bytes32 cowHash = registry.calculateCowHash(controller1, webDIDLong); 263 + (address ctrl, ) = registry.cows(cowHash); 264 + assertEq(ctrl, controller2); 265 + } 266 + 267 + function test_on_first_update_updateController_web_verylong() public { 268 + vm.prank(controller1); 269 + registry.updateController(controller1, webDIDVeryLong, controller2); 270 + 271 + bytes32 cowHash = registry.calculateCowHash(controller1, webDIDVeryLong); 272 + (address ctrl, ) = registry.cows(cowHash); 273 + assertEq(ctrl, controller2); 274 + } 275 + 276 + // ========================================================================= 169 277 // Auth checks 170 - // ------------------------------------------------------------------------- 278 + // ========================================================================= 171 279 172 280 function test_updateWrappedDID_rejectsNonController() public { 173 281 bytes32 cowHash = _init(controller1, plcDID1);