decentralized-identity / ethr-did-resolver

DID resolver for Ethereum Addresses with support for key management
Apache License 2.0
212 stars 77 forks source link

Consistent Encoding of `attrValue` on `createRevokeAttributeHash` (in line with `createSetAttributeHash`) #200

Closed radleylewis closed 5 months ago

radleylewis commented 6 months ago

Overview When invoking createSetAttributeHash the present implementation checks for a hex encoded key or for a utf8 type and will encode the attrValue accordingly. The behaviour between createSetAttributeHash and createRevokeAttributeHash should be consistent, however, the case of the former there is no check on the attrValue type. This results in a bad_signature error in the case where a hex encoded attrValue is provided.

Fix The proposed changes perform the same check on the attrValue in the createRevokeAttributeHash as is performed in the createSetAttributeHash making them consistent.

radleylewis commented 6 months ago

This looks good, can you please add one or more tests that validate the 2 types of values being encoded?

Thanks @mirceanis. I have added tests (both for createSetAttributeHash and createRevokeAttributeHash) checking for both the hex string attrValue (e.g. public key) case and also the string (e.g. service endpoint) case.