Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: light (offchain) DIDs #408

Merged
merged 36 commits into from
Sep 7, 2021
Merged

feat: light (offchain) DIDs #408

merged 36 commits into from
Sep 7, 2021

Conversation

ntn-x2
Copy link
Member

@ntn-x2 ntn-x2 commented Sep 2, 2021

fixes KILTProtocol/ticket#1531

This PR adds support for light (or off-chain) DIDs. The new class of DIDs are still compliant with the same IDidDetails interface, so they are completely transparent to the users. A light DID is created by specifying an authentication key (which can be ed25519, sr25519, or ecdsa), and optionally an encryption key and some service endpoints. The latter two, if present, are CBOR serialised and Base64 encoded and are added as part of the DID string itself.

This PR also changes the structure of DIDs in general, as support for versioning has been added. An example of a full DID is the following: did:kilt:v1:4r1WkS3t8rbCb11H8t3tJvGVCynwDXSUBiuGB6sLRHzCLCjs, while a light DID that only specifies an authentication key would have the following structure: did:kilt:light:v1:004r1WkS3t8rbCb11H8t3tJvGVCynwDXSUBiuGB6sLRHzCLCjs. The first two 00 in the identifier represent the type of the authentication key that has been encoded to be the DID identifier.

EDIT AFTER PR REVIEW

DID version 1 skip the v1 bit in the URI, so a full DID v1 is did:kilt:4r1WkS3t8rbCb11H8t3tJvGVCynwDXSUBiuGB6sLRHzCLCjs while a light DID v1 is did:kilt:light:004r1WkS3t8rbCb11H8t3tJvGVCynwDXSUBiuGB6sLRHzCLCjs.

How to test:

Run yarn test. All unit tests and integration tests are passing (for Node 14). I did not add much coverage to the existing test cases as I think that is out of the scope for this PR. Next PR could include updating the getting-started guides and examples with the latest version (that uses DIDs everywhere).

Checklist:

  • I have verified that the code works
  • I have verified that the code is easy to understand
    • If not, I have left a well-balanced amount of inline comments
  • I have left the code in a better state
  • I have documented the changes (where applicable)

ntn-x2 added 29 commits August 26, 2021 14:54
@ntn-x2 ntn-x2 self-assigned this Sep 2, 2021
@ntn-x2 ntn-x2 added the ✨ new feature feature: new feature label Sep 2, 2021
@ntn-x2 ntn-x2 marked this pull request as ready for review September 2, 2021 14:38
@ntn-x2 ntn-x2 requested a review from tjwelde September 2, 2021 14:38
@ntn-x2
Copy link
Member Author

ntn-x2 commented Sep 2, 2021

@tjwelde I think this PR could be reviewed now. The getting started and examples are clearly still failing (probably the scope of another PR). Tests on Node 14 are failing because of the lack of extensive coverage. For Node 16 it seems to be the very same problem that has been going on for a while. Integration tests with master are obviously failing, while the ones with develop have mostly gone through, with some timeout errors for some balance-specific stuff which I do not think is to be taken into consideration.

Copy link
Contributor

@tjwelde tjwelde left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks pretty good I must say ;)

S: I would leave the v1 part out for the first version, just because it looks nicer ;)

did = did.concat(':', encodedDetails)
}

super(
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

really like the abstraction with the DIDDetails parent class

@ntn-x2 ntn-x2 requested a review from tjwelde September 7, 2021 07:48
Copy link
Contributor

@tjwelde tjwelde left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@ntn-x2 ntn-x2 merged commit 7f0343c into develop Sep 7, 2021
@ntn-x2 ntn-x2 deleted the aa-offchain-did branch September 7, 2021 14:07
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
✨ new feature feature: new feature
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants