From fb1c1f80ec58be74a2f46510a0bbc0be40f320a8 Mon Sep 17 00:00:00 2001 From: Paul Chen Date: Fri, 2 Feb 2024 17:04:37 +0800 Subject: [PATCH] docs: ADR-024: Decentralized identifiers resolver (#1289) ## Description Closes: #XXXX This PR writes the documentation of how to integrate DIDs registry to Desmos. --- ### Author Checklist *All items are required. Please add a note to the item if the item is not applicable and please add links to any relevant follow up issues.* I have... - [ ] included the correct [type prefix](https://github.com/commitizen/conventional-commit-types/blob/v3.0.0/index.json) in the PR title - [ ] added `!` to the type prefix if API or client breaking change - [ ] targeted the correct branch (see [PR Targeting](https://github.com/desmos-labs/desmos/blob/master/CONTRIBUTING.md#pr-targeting)) - [ ] provided a link to the relevant issue or specification - [ ] followed the guidelines for [building modules](https://docs.cosmos.network/v0.44/building-modules/intro.html) - [ ] included the necessary unit and integration [tests](https://github.com/desmos-labs/desmos/blob/master/CONTRIBUTING.md#testing) - [ ] added a changelog entry to `CHANGELOG.md` - [ ] included comments for [documenting Go code](https://blog.golang.org/godoc) - [ ] updated the relevant documentation or specification - [ ] reviewed "Files changed" and left comments if necessary - [ ] confirmed all CI checks have passed ### Reviewers Checklist *All items are required. Please add a note if the item is not applicable and please add your handle next to the items reviewed if you only reviewed selected items.* I have... - [ ] confirmed the correct [type prefix](https://github.com/commitizen/conventional-commit-types/blob/v3.0.0/index.json) in the PR title - [ ] confirmed `!` in the type prefix if API or client breaking change - [ ] confirmed all author checklist items have been addressed - [ ] reviewed state machine logic - [ ] reviewed API design and naming - [ ] reviewed documentation is accurate - [ ] reviewed tests and test coverage - [ ] manually tested (if applicable) ## Summary by CodeRabbit - **New Features** - Integrated Decentralized Identifiers (DIDs) into Desmos, enhancing identity management with the addition of a `DidDoc` query method for resolving Desmos Profiles into DID documents. --------- Co-authored-by: Riccardo Co-authored-by: coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com> --- ...-024-decentralized-identifiers-resolver.md | 144 ++++++++++++++++++ 1 file changed, 144 insertions(+) create mode 100644 docs/architecture/adr-024-decentralized-identifiers-resolver.md diff --git a/docs/architecture/adr-024-decentralized-identifiers-resolver.md b/docs/architecture/adr-024-decentralized-identifiers-resolver.md new file mode 100644 index 0000000000..3ebdae7507 --- /dev/null +++ b/docs/architecture/adr-024-decentralized-identifiers-resolver.md @@ -0,0 +1,144 @@ +# ADR 024: Decentralized Identifiers resolver + +## Changelog + +- Jan 16th, 2024: First draft; +- Jan 23th, 2024: First review; + +## Status + +ACCEPTED Not Implemented + +## Abstract + +This ADR proposes the integration of a new functionality into Desmos to resolve Desmos Profiles into DID documents, incorporating Decentralized Identifiers (DIDs) for enhanced digital identity verification. + +## Context + +Decentralized identifiers (DIDs) are a new type of identifier that enables verifiable, decentralized digital identity. Via verifiable credential, DID enables individuals to assert control over their personal information, aligning with principles of privacy, and user empowerment. Furthermore, as DIDs emerge as a universal standard, they are poised to play a pivotal role in identity authentication across various applications. Desmos serves as a decentralized social platform infrastructure, DID would contribute to an improved user experience in identity management. + +## Decision + +We will implement a query method `DidDoc` within the Desmos Profiles module to resolve Desmos Profiles into DID documents. In addition, A DID that uses this method MUST begin with the following prefix: `did:desmos`. + +The example of the resolver's response would be like as follows: + +```json +{ + "context": [ + "https://www.w3.org/ns/did/v1", + "https://w3id.org/security/suites/secp256k1-2019/v1" + ], + "id": "did:desmos:", + "alsoKnownAs": [ + "dtag:", /* Desmos Dtag */ + "application::", /* application link */ + "blockchain::", /* chain link */ + ], + "verificationMethod": [ + { + "id": "did:desmos:#DESMOS-KEY-1", + "type": "EcdsaSecp256k1VerificationKey2019", + "publicKeyMultibase": "" + } + ], + "authentication": [ + "did:desmos:#DESMOS-KEY-1" + ], + "assertionMethod": [ + "did:desmos:#DESMOS-KEY-1" + ], +} +``` + +### `Query` service + +```protobuf +service Query{ + // DidDoc queries for a single DID document. + rpc DidDoc(QueryDidDocRequest) returns(QueryDidDocResponse) { + option (google.http.get) = "/desmos/profiles/v3/did/{id}"; + }; +} + +// QueryDidDocRequest is the request type for the Query/DidDoc RPC method +message QueryDidDocRequest { + string id = 1; +} + +// QueryDidDocResponse is the response type for the Query/DidDoc RPC method +message QueryDidDocResponse { + // URIs used to identify the context of DID document. + // Default: ["https://www.w3.org/ns/did/v1", "https://w3id.org/security/suites/secp256k1-2019/v1"] + repeated string context = 1; + + // The unique identifier in DID syntax of DID document. + // Example: did:desmos: + string id = 2; + + // The assertion that resources refer to the DID. + // In Desmos, it shows chain links and application links linked to profile. + // Documentation: https://www.w3.org/TR/did-core/#also-known-as + string also_known_as = 3; + + // Keys of verification methods for verifying digital signature. + // In Desmos, it must be the public key(s) that associated to the profile owner. + repeated VerificationMethod verification_methods = 4; + + // Id of keys for authentication within verification methods. + // Documentation: https://www.w3.org/TR/did-core/#authentication + repeated string authentication = 5; + + // Id of keys for assertion method within verification methods. + // Documentation: https://www.w3.org/TR/did-core/#assertion + repeated string assertion_method = 6; +} + +// VerificationMethod represents the cryptographic public keys, which can be used to authenticate interaction. +// Documentation: https://www.w3.org/TR/did-core/#verification-methods +message VerificationMethod { + // Unique identifier in DID URL syntax. + // Example: did:desmos:#DESMOS-KEY-1 + string id = 1; + + // Type of the verification method. + // Example: "EcdsaSecp256k1VerificationKey2019" + string type = 2; + + // Hex-encoded of the public key in the multibase format. + // Documentation: https://w3c-ccg.github.io/multibase + string public_key_multibase = 3; +} +``` + +### Limitation + +Due to the necessity of public key(s) being directly controlled by the profile owner, any profile owner lacking public keys, such as those associated with a contract, cannot be resolved into a DID. +Future versions may explore alternative methods to accommodate profiles without direct public key control, enhancing inclusivity. + +## Consequences + +### Backwards Compatibility + +The solution outlined above is fully backward compatible since we are just adding a new query method. + +### Positive + +- Enable the usage of Desmos in applications that support DID. + +### Negative + +(none known) + +### Neutral + +(none known) + +## Further Discussions + +To be compatible to DID universal resolver, we SHOULD implement resolver driver for Desmos in the future. + +## References + +- [W3C Decentralized Identifiers (DIDs) v1.0](https://www.w3.org/TR/did-core/) +- [DID universal resolver](https://github.com/decentralized-identity/universal-resolver) \ No newline at end of file