diff --git a/README.md b/README.md index b0dbfcd..81c2359 100644 --- a/README.md +++ b/README.md @@ -1,11 +1,11 @@ -# hid-node -**hid-node** is a blockchain built using Cosmos SDK and Tendermint and created with [Starport](https://starport.com). +# Hypersign Identity Network +The Hypersign Identity Network is a permissionless blockchain network to manage digital identity and access rights. It aims to empower humans to gain control of their data and access on the internet by providing scalable, interoperable and secure verifiable data registry (VDR) to implement use cases on Self Sovereign Identity (SSI) principles. The Hypersign Identity Network is built using Cosmos-SDK and is fully compatible with W3C DID specification. ## Prerequisite Following are the prerequisites that needs to be installed: -- golang (Installation Guide: https://go.dev/doc/install) +- golang (Installation Guide: https://go.dev/doc/install) (version: 1.17.2) - starport (Installation Guide: https://docs.starport.network/guide/install.html) ## Get started @@ -17,7 +17,7 @@ $ git clone https://github.com/hypersign-protocol/hid-node.git $ cd hid-node ``` -Run the following command to build the binary file and start the `hid-node` blockchain: +Run the following command to build the binary file and start the blockchain: ``` starport chain serve ``` @@ -28,24 +28,6 @@ The binary `hid-noded` will be generated in `$GO_PATH/bin` directory. To explore To stop the blockchain, navigate to the terminal window where the blockchain is running, and hit `Ctrl+C`. -## Module Creation - -Once we have scaffolded the chain using `starport`, a default module is always created if we scaffolded the chain without the `--no-module` flag. In our case, it will be `x/hidnode`. We can delete this module and its dependent files and folders, since it's not necessary. - -Creating the module `did` is as follows: - -``` -$ starport scaffold module did -``` - -Now, to scaffold any structures such as `messages`, `types`, `list` etc., following needs to run: - -``` -$ starport scaffold message createDID did didDocString createdAt --module did -``` -Notice the `--module` flag. This is required to specify the module for which we are scaffolding the structure - - ## Register DID ```sh @@ -72,7 +54,9 @@ hid-noded tx ssi create-did '{ ``` Note: While performing a CLI transaction, it is required to pass chain-id as `--chain-id hidnode` , as the default chain id set is `hid-node` which will cause the transaction to fail. -## Update DID +## Operations + +### Update DID After the DIDDoc is created from running the above command, making changes to it happens through the following CLI command: @@ -97,10 +81,41 @@ hid-noded tx ssi update-did '{ "authentication": [ "did:hs:0f49341a-20ef-43d1-bc93-de30993e6c51#zEYJrMxWigf9boyeJMTRN4Ern8DJMoCXaLK77pzQmxVjf" ] -}' did:hs:0f49341a-20ef-43d1-bc93-de30993e6c51#zEYJrMxWigf9boyeJMTRN4Ern8DJMoCXaLK77pzQmxVjf --ver-key oVtY1xceDZQjkfwlbCEC2vgeADcxpgd27vtYasBhcM/JLR6PnPoD9jvjSJrMsMJwS7faPy5OlFCdj/kgLVZMEg== --from alice --chain-id hidnode +}' did:hs:0f49341a-20ef-43d1-bc93-de30993e6c51#zEYJrMxWigf9boyeJMTRN4Ern8DJMoCXaLK77pzQmxVjf --ver-key oVtY1xceDZQjkfwlbCEC2vgeADcxpgd27vtYasBhcM/JLR6PnPoD9jvjSJrMsMJwS7faPy5OlFCdj/kgLVZMEg== --from alice --chain-id hidnode ``` + +The second param `` should be the version-id of the latest DID Doc. + The `context` field of the DIDDoc is now updated with a new entry: `"https://some.domain"` +### Deactivate DID + +Run the following to deactivate the DID Document: + +```sh +hid-noded tx ssi deactivate-did '{ +"context": [ +"https://www.w3.org/ns/did/v1", +"https://w3id.org/security/v1", +"https://schema.org" +], +"id": "did:hs:0f49341a-20ef-43d1-bc93-de30993e6c52", +"controller": ["did:hs:0f49341a-20ef-43d1-bc93-de30993e6c52"], +"alsoKnownAs": ["did:hs:1f49341a-de30993e6c52"], +"verificationMethod": [ +{ +"id": "did:hs:0f49341a-20ef-43d1-bc93-de30993e6c52#z8BXg2zjwBRTrjPs7uCnkFBKrL9bPD14HxEJMENxm3CJ4", +"type": "Ed25519VerificationKey2020", +"controller": "did:hs:0f49341a-20ef-43d1-bc93-de30993e6c52", +"publicKeyMultibase": "z8BXg2zjwBRTrjPs7uCnkFBKrL9bPD14HxEJMENxm3CJ4" +} +], +"authentication": [ +"did:hs:0f49341a-20ef-43d1-bc93-de30993e6c52#z8BXg2zjwBRTrjPs7uCnkFBKrL9bPD14HxEJMENxm3CJ4" +] +}' did:hs:0f49341a-20ef-43d1-bc93-de30993e6c52#z8BXg2zjwBRTrjPs7uCnkFBKrL9bPD14HxEJMENxm3CJ4 --ver-key bZBUkLGChnJujYHUZ4L8PECoN2Odv6adWGXc1qVWCRVqtEx0o/FmtFZnd5pT3laR518P58TRUGY5q5KSrToSmQ== --from alice --chain-id hidnode --yes +``` + ## Resolve DID There are two ways to resolve DID: @@ -110,9 +125,17 @@ There are two ways to resolve DID: **API**: + +1. Retrieve a did Document by providing a Did ID: ```sh -curl -X GET "http://localhost:1318/hypersign-protocol/hidnode/ssi/did/queryDidDocById/did%3Ahs%3A0f49341a-20ef-43d1-bc93-de30993e6c51%3A" -H "accept: application/json" +curl -X GET "http://localhost:1318/hypersign-protocol/hidnode/ssi/did/did:hs:0f49341a-20ef-43d1-bc93-de30993e6c52:" -H "accept: application/json" ``` + +2. Retrieve the count and list of did Documents: +```sh +curl -X GET "http://localhost:1318/hypersign-protocol/hidnode/ssi/did" -H "accept: application/json" +``` + Note: The above curl command was taken from the Swagger UI of Blockchain API, where the `did` input parameter was entered along with an extra semicolon appended, because gRPC server has issues parsing the regular DID string. **CLI**: diff --git a/docs/ssi/walkthrough.md b/docs/ssi/walkthrough.md new file mode 100644 index 0000000..cbc27dd --- /dev/null +++ b/docs/ssi/walkthrough.md @@ -0,0 +1,413 @@ +# SSI Module Walkthrough + +## Features + +- Transaction Based: + - Registering a DID Document + - Updating a DID Document + - Deactivating a DID Document +- Querying Based: + - Resolve a DID Document based on an input DID Id + - Get the count and list of DID Documents registered on chain + +## CLI Signature + +### Register DID + +``` +Usage: + hid-noded tx ssi create-did [did-doc-string] [verification-method-id] [flags] + +Params: + - did-doc-string : Did Doc String received from hs-ssi-sdk + - verification-method-id : Verification Method ID + +Flags: + - ver-key : Private Key of the Signer +``` + +### Update DID + +``` +Usage: + hid-noded tx ssi update-did [did-doc-string] [version-id] [verification-method-id] [flags] + +Params: + - did-doc-string : Did Doc String received from hs-ssi-sdk + - version-id : Version ID of the DID Document to be updated. It is expected that version ID should of the latest DID Document + - verification-method-id : Verification Method ID + +Flags: + - --ver-key : Private Key of the Signer +``` + +### Deactivate DID + +``` +Usage: + hid-noded tx ssi deactivate-did [did-doc-string] [version-id] [verification-method-id] [flags] + +Params: + - did-doc-string : Did Doc String received from hs-ssi-sdk + - version-id : Version ID of the DID Document to be updated. It is expected that version ID should of the latest DID Document + - verification-method-id : Verification Method ID + +Flags: + - --ver-key : Private Key of the Signer +``` + +## Usage + +The usage of CLI is explained through scenarios: + +### Register DID + +Registering a DID Document in `hid-node`. User 2 is registering a DID Document with id: `did:hs:0f49341a-20ef-43d1-bc93-de30993e6c52` + +```sh +hid-noded tx ssi create-did '{ +"context": [ +"https://www.w3.org/ns/did/v1", +"https://w3id.org/security/v1", +"https://schema.org" +], +"id": "did:hs:0f49341a-20ef-43d1-bc93-de30993e6c52", +"controller": ["did:hs:0f49341a-20ef-43d1-bc93-de30993e6c52"], +"alsoKnownAs": ["did:hs:1f49341a-de30993e6c52"], +"verificationMethod": [ +{ +"id": "did:hs:0f49341a-20ef-43d1-bc93-de30993e6c52#z8BXg2zjwBRTrjPs7uCnkFBKrL9bPD14HxEJMENxm3CJ4", +"type": "Ed25519VerificationKey2020", +"controller": "did:hs:0f49341a-20ef-43d1-bc93-de30993e6c52", +"publicKeyMultibase": "z8BXg2zjwBRTrjPs7uCnkFBKrL9bPD14HxEJMENxm3CJ4" +} +], +"service": [{ +"id":"did:hs:0f49341a-20ef-43d1-bc93-de30993e6c52#vcs", +"type": "LinkedDomains", +"serviceEndpoint": "https://example.com/vc" +}, +{ +"id":"did:hs:0f49341a-20ef-43d1-bc93-de30993e6c51#file", +"type": "LinkedDomains", +"serviceEndpoint": "https://example.in/somefile" +} +], +"authentication": [ +"did:hs:0f49341a-20ef-43d1-bc93-de30993e6c52#z8BXg2zjwBRTrjPs7uCnkFBKrL9bPD14HxEJMENxm3CJ4" +] +}' did:hs:0f49341a-20ef-43d1-bc93-de30993e6c52#z8BXg2zjwBRTrjPs7uCnkFBKrL9bPD14HxEJMENxm3CJ4 --ver-key --from alice --chain-id hidnode --yes +``` + +### Update DID + +User 2 (`did:hs:0f49341a-20ef-43d1-bc93-de30993e6c52`) is trying to update it’s DID by adding User 1’s ID (`did:hs:0f49341a-20ef-43d1-bc93-de30993e6c51`) to the controller group. It is assumed that User 1’s ID (`did:hs:0f49341a-20ef-43d1-bc93-de30993e6c51`) is already registered on blockchain. + +```sh +hid-noded tx ssi update-did '{ +"context": [ +"https://www.w3.org/ns/did/v1", +"https://w3id.org/security/v1", +"https://schema.org" +], +"id": "did:hs:0f49341a-20ef-43d1-bc93-de30993e6c52", +"controller": ["did:hs:0f49341a-20ef-43d1-bc93-de30993e6c52","did:hs:0f49341a-20ef-43d1-bc93-de30993e6c51"], +"alsoKnownAs": ["did:hs:1f49341a-de30993e6c52"], +"verificationMethod": [ +{ +"id": "did:hs:0f49341a-20ef-43d1-bc93-de30993e6c52#z8BXg2zjwBRTrjPs7uCnkFBKrL9bPD14HxEJMENxm3CJ4", +"type": "Ed25519VerificationKey2020", +"controller": "did:hs:0f49341a-20ef-43d1-bc93-de30993e6c52", +"publicKeyMultibase": "z8BXg2zjwBRTrjPs7uCnkFBKrL9bPD14HxEJMENxm3CJ4" +} +], +"authentication": [ +"did:hs:0f49341a-20ef-43d1-bc93-de30993e6c52#z8BXg2zjwBRTrjPs7uCnkFBKrL9bPD14HxEJMENxm3CJ4" +] +}' "${VERSION_ID}" did:hs:0f49341a-20ef-43d1-bc93-de30993e6c52#z8BXg2zjwBRTrjPs7uCnkFBKrL9bPD14HxEJMENxm3CJ4 --ver-key --from alice --chain-id hidnode --yes +``` + +Here, the `${VERSION_ID}` should have the version id of the latest DID of User 2 (`did:hs:0f49341a-20ef-43d1-bc93-de30993e6c52`) + +### Deactivate DID + +User 2 (`did:hs:0f49341a-20ef-43d1-bc93-de30993e6c52`) is trying to deactivate it’s DID + +```sh +hid-noded tx ssi deactivate-did '{ +"context": [ +"https://www.w3.org/ns/did/v1", +"https://w3id.org/security/v1", +"https://schema.org" +], +"id": "did:hs:0f49341a-20ef-43d1-bc93-de30993e6c52", +"controller": ["did:hs:0f49341a-20ef-43d1-bc93-de30993e6c52"], +"alsoKnownAs": ["did:hs:1f49341a-de30993e6c52"], +"verificationMethod": [ +{ +"id": "did:hs:0f49341a-20ef-43d1-bc93-de30993e6c52#z8BXg2zjwBRTrjPs7uCnkFBKrL9bPD14HxEJMENxm3CJ4", +"type": "Ed25519VerificationKey2020", +"controller": "did:hs:0f49341a-20ef-43d1-bc93-de30993e6c52", +"publicKeyMultibase": "z8BXg2zjwBRTrjPs7uCnkFBKrL9bPD14HxEJMENxm3CJ4" +} +], +"authentication": [ +"did:hs:0f49341a-20ef-43d1-bc93-de30993e6c52#z8BXg2zjwBRTrjPs7uCnkFBKrL9bPD14HxEJMENxm3CJ4" +] +}' "${VERSION_ID}" did:hs:0f49341a-20ef-43d1-bc93-de30993e6c52#z8BXg2zjwBRTrjPs7uCnkFBKrL9bPD14HxEJMENxm3CJ4 --ver-key --from alice --chain-id hidnode --yes +``` + +### Resolving DID + +1) Get the list of Registered DID Documents + +URL: `http://localhost:1318/hypersign-protocol/hidnode/ssi/did` + +Output: + +```json +{ + "totalDidCount":"2", + "didDocList":[ + { + "_at_context":"", + "didDocument":{ + "context":[ + "https://www.w3.org/ns/did/v1", + "https://w3id.org/security/v1", + "https://schema.org" + ], + "id":"did:hs:0f49341a-20ef-43d1-bc93-de30993e6c51", + "controller":[ + + ], + "alsoKnownAs":[ + "did:hs:1f49341a-de30993e6c51" + ], + "verificationMethod":[ + { + "id":"did:hs:0f49341a-20ef-43d1-bc93-de30993e6c51#zEYJrMxWigf9boyeJMTRN4Ern8DJMoCXaLK77pzQmxVjf", + "type":"Ed25519VerificationKey2020", + "controller":"did:hs:0f49341a-20ef-43d1-bc93-de30993e6c51", + "publicKeyMultibase":"zEYJrMxWigf9boyeJMTRN4Ern8DJMoCXaLK77pzQmxVjf" + } + ], + "authentication":[ + "did:hs:0f49341a-20ef-43d1-bc93-de30993e6c51#zEYJrMxWigf9boyeJMTRN4Ern8DJMoCXaLK77pzQmxVjf" + ], + "assertionMethod":[ + + ], + "keyAgreement":[ + + ], + "capabilityInvocation":[ + + ], + "capabilityDelegation":[ + + ], + "service":[ + + ] + }, + "didDocumentMetadata":{ + "created":"2022-02-25T09:20:15Z", + "updated":"2022-02-25T09:20:15Z", + "deactivated":false, + "versionId":"GkAO5TuRaFWnMD3IgoKaaBMKEIByYWIi9h/W9LvLk+Q=" + }, + "didResolutionMetadata":{ + "retrieved":"2022-02-25T09:20:19Z", + "error":"" + } + }, + { + "_at_context":"", + "didDocument":{ + "context":[ + "https://www.w3.org/ns/did/v1", + "https://w3id.org/security/v1", + "https://schema.org" + ], + "id":"did:hs:0f49341a-20ef-43d1-bc93-de30993e6c52", + "controller":[ + "did:hs:0f49341a-20ef-43d1-bc93-de30993e6c52" + ], + "alsoKnownAs":[ + "did:hs:1f49341a-de30993e6c52" + ], + "verificationMethod":[ + { + "id":"did:hs:0f49341a-20ef-43d1-bc93-de30993e6c52#z8BXg2zjwBRTrjPs7uCnkFBKrL9bPD14HxEJMENxm3CJ4", + "type":"Ed25519VerificationKey2020", + "controller":"did:hs:0f49341a-20ef-43d1-bc93-de30993e6c52", + "publicKeyMultibase":"z8BXg2zjwBRTrjPs7uCnkFBKrL9bPD14HxEJMENxm3CJ4" + } + ], + "authentication":[ + "did:hs:0f49341a-20ef-43d1-bc93-de30993e6c52#z8BXg2zjwBRTrjPs7uCnkFBKrL9bPD14HxEJMENxm3CJ4" + ], + "assertionMethod":[ + + ], + "keyAgreement":[ + + ], + "capabilityInvocation":[ + + ], + "capabilityDelegation":[ + + ], + "service":[ + { + "id":"did:hs:0f49341a-20ef-43d1-bc93-de30993e6c52#vcs", + "type":"LinkedDomains", + "serviceEndpoint":"https://example.com/vc" + }, + { + "id":"did:hs:0f49341a-20ef-43d1-bc93-de30993e6c51#file", + "type":"LinkedDomains", + "serviceEndpoint":"https://example.in/somefile" + } + ] + }, + "didDocumentMetadata":{ + "created":"2022-02-25T09:20:11Z", + "updated":"2022-02-25T09:20:11Z", + "deactivated":false, + "versionId":"ClUei1OW9mDtFQuFdhgmfzPZT1gWa7hGwfRI9DP2mMs=" + }, + "didResolutionMetadata":{ + "retrieved":"2022-02-25T09:20:19Z", + "error":"" + } + } + ] +} +``` + +2) Get the list of Registered DID Documents with pagination limit + +URL: `http://localhost:1318/hypersign-protocol/hidnode/ssi/did?pagination.limit=1` + +Output: + +```json +{ + "totalDidCount": "2", + "didDocList": [ + { + "_at_context": "", + "didDocument": { + "context": [ + "https://www.w3.org/ns/did/v1", + "https://w3id.org/security/v1", + "https://schema.org" + ], + "id": "did:hs:0f49341a-20ef-43d1-bc93-de30993e6c51", + "controller": [], + "alsoKnownAs": [ + "did:hs:1f49341a-de30993e6c51" + ], + "verificationMethod": [ + { + "id": "did:hs:0f49341a-20ef-43d1-bc93-de30993e6c51#zEYJrMxWigf9boyeJMTRN4Ern8DJMoCXaLK77pzQmxVjf", + "type": "Ed25519VerificationKey2020", + "controller": "did:hs:0f49341a-20ef-43d1-bc93-de30993e6c51", + "publicKeyMultibase": "zEYJrMxWigf9boyeJMTRN4Ern8DJMoCXaLK77pzQmxVjf" + } + ], + "authentication": [ + "did:hs:0f49341a-20ef-43d1-bc93-de30993e6c51#zEYJrMxWigf9boyeJMTRN4Ern8DJMoCXaLK77pzQmxVjf" + ], + "assertionMethod": [], + "keyAgreement": [], + "capabilityInvocation": [], + "capabilityDelegation": [], + "service": [] + }, + "didDocumentMetadata": { + "created": "2022-02-25T15:18:59Z", + "updated": "2022-02-25T15:18:59Z", + "deactivated": false, + "versionId": "OwpjbfvZn5mBdf1gJWrpYFKrI2yLCQAjVhgHCqq6WOo=" + }, + "didResolutionMetadata": { + "retrieved": "2022-02-25T15:19:05Z", + "error": "" + } + } + ] +} +``` + +3) Query the DID Document for a given DID Id + +URL: `http://localhost:1318/hypersign-protocol/hidnode/ssi/did/did:hs:0f49341a-20ef-43d1-bc93-de30993e6c52:` + +
+ +```Note the colon(:) at the end of URL. It has been appended because of limitations of gRPC Server in parsing the DID Id. Workaround for this is being upon``` + +
+ +Output: + +```json +{ + "_at_context": "", + "didDocument": { + "context": [ + "https://www.w3.org/ns/did/v1", + "https://w3id.org/security/v1", + "https://schema.org" + ], + "id": "did:hs:0f49341a-20ef-43d1-bc93-de30993e6c52", + "controller": [ + "did:hs:0f49341a-20ef-43d1-bc93-de30993e6c52" + ], + "alsoKnownAs": [ + "did:hs:1f49341a-de30993e6c52" + ], + "verificationMethod": [ + { + "id": "did:hs:0f49341a-20ef-43d1-bc93-de30993e6c52#z8BXg2zjwBRTrjPs7uCnkFBKrL9bPD14HxEJMENxm3CJ4", + "type": "Ed25519VerificationKey2020", + "controller": "did:hs:0f49341a-20ef-43d1-bc93-de30993e6c52", + "publicKeyMultibase": "z8BXg2zjwBRTrjPs7uCnkFBKrL9bPD14HxEJMENxm3CJ4" + } + ], + "authentication": [ + "did:hs:0f49341a-20ef-43d1-bc93-de30993e6c52#z8BXg2zjwBRTrjPs7uCnkFBKrL9bPD14HxEJMENxm3CJ4" + ], + "assertionMethod": [], + "keyAgreement": [], + "capabilityInvocation": [], + "capabilityDelegation": [], + "service": [ + { + "id": "did:hs:0f49341a-20ef-43d1-bc93-de30993e6c52#vcs", + "type": "LinkedDomains", + "serviceEndpoint": "https://example.com/vc" + }, + { + "id": "did:hs:0f49341a-20ef-43d1-bc93-de30993e6c51#file", + "type": "LinkedDomains", + "serviceEndpoint": "https://example.in/somefile" + } + ] + }, + "didDocumentMetadata": { + "created": "2022-02-25T09:20:11Z", + "updated": "2022-02-25T09:20:11Z", + "deactivated": false, + "versionId": "ClUei1OW9mDtFQuFdhgmfzPZT1gWa7hGwfRI9DP2mMs=" + }, + "didResolutionMetadata": { + "retrieved": "2022-02-25T09:24:43Z", + "error": "" + } +} +``` \ No newline at end of file diff --git a/docs/static/openapi.yml b/docs/static/openapi.yml index 5dc98cb..6757b9b 100644 --- a/docs/static/openapi.yml +++ b/docs/static/openapi.yml @@ -11842,19 +11842,105 @@ paths: type: boolean tags: - Query - /hypersign-protocol/hidnode/ssi/did/count: + /hypersign-protocol/hidnode/ssi/did: get: - summary: Queries a list of DidDocCount items. - operationId: HypersignprotocolHidnodeSsiDidDocCount + summary: Did Param + operationId: HypersignprotocolHidnodeSsiDidParam responses: '200': description: A successful response. schema: type: object properties: - count: + totalDidCount: type: string format: uint64 + didDocList: + type: array + items: + type: object + properties: + AtContext: + type: string + didDocument: + type: object + properties: + context: + type: array + items: + type: string + id: + type: string + controller: + type: array + items: + type: string + alsoKnownAs: + type: array + items: + type: string + verificationMethod: + type: array + items: + type: object + properties: + id: + type: string + type: + type: string + controller: + type: string + publicKeyMultibase: + type: string + authentication: + type: array + items: + type: string + assertionMethod: + type: array + items: + type: string + keyAgreement: + type: array + items: + type: string + capabilityInvocation: + type: array + items: + type: string + capabilityDelegation: + type: array + items: + type: string + service: + type: array + items: + type: object + properties: + id: + type: string + type: + type: string + serviceEndpoint: + type: string + didDocumentMetadata: + type: object + properties: + created: + type: string + updated: + type: string + deactivated: + type: boolean + versionId: + type: string + didResolutionMetadata: + type: object + properties: + retrieved: + type: string + error: + type: string default: description: An unexpected error response. schema: @@ -11873,19 +11959,82 @@ paths: '@type': type: string additionalProperties: {} + parameters: + - name: count + in: query + required: false + type: boolean + - name: pagination.key + description: |- + key is a value returned in PageResponse.next_key to begin + querying the next page most efficiently. Only one of offset or key + should be set. + in: query + required: false + type: string + format: byte + - name: pagination.offset + description: >- + offset is a numeric offset that can be used when key is unavailable. + + It is less efficient than using key. Only one of offset or key + should + + be set. + in: query + required: false + type: string + format: uint64 + - name: pagination.limit + description: >- + limit is the total number of results to be returned in the result + page. + + If left empty it will default to a value to be set by each app. + in: query + required: false + type: string + format: uint64 + - name: pagination.countTotal + description: >- + count_total is set to true to indicate that the result set should + include + + a count of the total number of items available for pagination in + UIs. + + count_total is only respected when offset is used. It is ignored + when key + + is set. + in: query + required: false + type: boolean + - name: pagination.reverse + description: >- + reverse is set to true if results are to be returned in the + descending order. + + + Since: cosmos-sdk 0.43 + in: query + required: false + type: boolean tags: - Query - '/hypersign-protocol/hidnode/ssi/did/queryDidDocById/{didDocId}': + '/hypersign-protocol/hidnode/ssi/did/{didId}': get: - summary: Queries a list of GetDidDocById items. - operationId: HypersignprotocolHidnodeSsiGetDidDocById + summary: Resolve DID + operationId: HypersignprotocolHidnodeSsiResolveDid responses: '200': description: A successful response. schema: type: object properties: - didDoc: + AtContext: + type: string + didDocument: type: object properties: context: @@ -11946,10 +12095,24 @@ paths: type: string serviceEndpoint: type: string + didDocumentMetadata: + type: object + properties: created: type: string updated: type: string + deactivated: + type: boolean + versionId: + type: string + didResolutionMetadata: + type: object + properties: + retrieved: + type: string + error: + type: string default: description: An unexpected error response. schema: @@ -11969,10 +12132,14 @@ paths: type: string additionalProperties: {} parameters: - - name: didDocId + - name: didId in: path required: true type: string + - name: versionId + in: query + required: false + type: string tags: - Query /hypersign-protocol/hidnode/ssi/schema/count: @@ -20237,10 +20404,108 @@ definitions: type: string serviceEndpoint: type: string + hypersignprotocol.hidnode.ssi.DidResolutionResponse: + type: object + properties: + AtContext: + type: string + didDocument: + type: object + properties: + context: + type: array + items: + type: string + id: + type: string + controller: + type: array + items: + type: string + alsoKnownAs: + type: array + items: + type: string + verificationMethod: + type: array + items: + type: object + properties: + id: + type: string + type: + type: string + controller: + type: string + publicKeyMultibase: + type: string + authentication: + type: array + items: + type: string + assertionMethod: + type: array + items: + type: string + keyAgreement: + type: array + items: + type: string + capabilityInvocation: + type: array + items: + type: string + capabilityDelegation: + type: array + items: + type: string + service: + type: array + items: + type: object + properties: + id: + type: string + type: + type: string + serviceEndpoint: + type: string + didDocumentMetadata: + type: object + properties: + created: + type: string + updated: + type: string + deactivated: + type: boolean + versionId: + type: string + didResolutionMetadata: + type: object + properties: + retrieved: + type: string + error: + type: string + hypersignprotocol.hidnode.ssi.DidResolveMeta: + type: object + properties: + retrieved: + type: string + error: + type: string + hypersignprotocol.hidnode.ssi.Metadata: + type: object + properties: created: type: string updated: type: string + deactivated: + type: boolean + versionId: + type: string hypersignprotocol.hidnode.ssi.MsgCreateDIDResponse: type: object properties: @@ -20253,6 +20518,12 @@ definitions: id: type: string format: uint64 + hypersignprotocol.hidnode.ssi.MsgDeactivateDIDResponse: + type: object + properties: + id: + type: string + format: uint64 hypersignprotocol.hidnode.ssi.MsgUpdateDIDResponse: type: object properties: @@ -20261,16 +20532,104 @@ definitions: hypersignprotocol.hidnode.ssi.Params: type: object description: Params defines the parameters for the module. - hypersignprotocol.hidnode.ssi.QueryDidDocCountResponse: + hypersignprotocol.hidnode.ssi.QueryDidParamResponse: type: object properties: - count: + totalDidCount: type: string format: uint64 + didDocList: + type: array + items: + type: object + properties: + AtContext: + type: string + didDocument: + type: object + properties: + context: + type: array + items: + type: string + id: + type: string + controller: + type: array + items: + type: string + alsoKnownAs: + type: array + items: + type: string + verificationMethod: + type: array + items: + type: object + properties: + id: + type: string + type: + type: string + controller: + type: string + publicKeyMultibase: + type: string + authentication: + type: array + items: + type: string + assertionMethod: + type: array + items: + type: string + keyAgreement: + type: array + items: + type: string + capabilityInvocation: + type: array + items: + type: string + capabilityDelegation: + type: array + items: + type: string + service: + type: array + items: + type: object + properties: + id: + type: string + type: + type: string + serviceEndpoint: + type: string + didDocumentMetadata: + type: object + properties: + created: + type: string + updated: + type: string + deactivated: + type: boolean + versionId: + type: string + didResolutionMetadata: + type: object + properties: + retrieved: + type: string + error: + type: string hypersignprotocol.hidnode.ssi.QueryGetDidDocByIdResponse: type: object properties: - didDoc: + AtContext: + type: string + didDocument: type: object properties: context: @@ -20331,10 +20690,24 @@ definitions: type: string serviceEndpoint: type: string + didDocumentMetadata: + type: object + properties: created: type: string updated: type: string + deactivated: + type: boolean + versionId: + type: string + didResolutionMetadata: + type: object + properties: + retrieved: + type: string + error: + type: string hypersignprotocol.hidnode.ssi.QueryGetSchemaResponse: type: object properties: diff --git a/proto/ssi/v1/did.proto b/proto/ssi/v1/did.proto index ea29044..621911b 100644 --- a/proto/ssi/v1/did.proto +++ b/proto/ssi/v1/did.proto @@ -1,5 +1,6 @@ syntax = "proto3"; package hypersignprotocol.hidnode.ssi; + option go_package = "github.com/hypersign-protocol/hid-node/x/ssi/types"; message Did { @@ -14,8 +15,18 @@ message Did { repeated string capabilityInvocation = 9; repeated string capabilityDelegation = 10; repeated Service service = 11; - string created = 12; - string updated = 13; +} + +message Metadata { + string created = 1; + string updated = 2; + bool deactivated = 3; + string versionId = 4; +} + +message DidResolveMeta { + string retrieved = 2; + string error = 3; } message VerificationMethod { @@ -34,4 +45,9 @@ message Service { message SignInfo { string verification_method_id = 1; string signature = 2; +} + +message DidDocument { + Did did = 1; + Metadata metadata = 2; } \ No newline at end of file diff --git a/proto/ssi/v1/query.proto b/proto/ssi/v1/query.proto index e2595c8..07453c2 100644 --- a/proto/ssi/v1/query.proto +++ b/proto/ssi/v1/query.proto @@ -33,15 +33,15 @@ service Query { option (google.api.http).get = "/hypersign-protocol/hidnode/ssi/schema/count"; } -// Queries a list of GetDidDocById items. - rpc GetDidDocById(QueryGetDidDocByIdRequest) returns (QueryGetDidDocByIdResponse) { - option (google.api.http).get = "/hypersign-protocol/hidnode/ssi/did/queryDidDocById/{didDocId}"; +// Resolve DID + rpc ResolveDid(QueryGetDidDocByIdRequest) returns (QueryGetDidDocByIdResponse) { + option (google.api.http).get = "/hypersign-protocol/hidnode/ssi/did/{didId}"; } -// Queries a list of DidDocCount items. - rpc DidDocCount(QueryDidDocCountRequest) returns (QueryDidDocCountResponse) { - option (google.api.http).get = "/hypersign-protocol/hidnode/ssi/did/count"; - } +// Did Param + rpc DidParam(QueryDidParamRequest) returns (QueryDidParamResponse) { + option (google.api.http).get = "/hypersign-protocol/hidnode/ssi/did"; + } // this line is used by starport scaffolding # 2 } @@ -80,18 +80,33 @@ message QuerySchemaCountResponse { } message QueryGetDidDocByIdRequest { - string didDocId = 1; + string didId = 1; + string versionId = 2; } message QueryGetDidDocByIdResponse { - Did didDoc = 1; + string _at_context = 1; + Did didDocument = 2; + Metadata didDocumentMetadata = 3; + DidResolveMeta didResolutionMetadata = 4; +} + + +message QueryDidParamRequest { + bool count = 1; + cosmos.base.query.v1beta1.PageRequest pagination = 2; } -message QueryDidDocCountRequest { +message QueryDidParamResponse { + uint64 totalDidCount = 1; + repeated DidResolutionResponse didDocList = 2; } -message QueryDidDocCountResponse { - uint64 count = 1; +message DidResolutionResponse { + string _at_context = 1; + Did didDocument = 2; + Metadata didDocumentMetadata = 3; + DidResolveMeta didResolutionMetadata = 4; } // this line is used by starport scaffolding # 3 diff --git a/proto/ssi/v1/tx.proto b/proto/ssi/v1/tx.proto index 9ef2acd..2313f0c 100644 --- a/proto/ssi/v1/tx.proto +++ b/proto/ssi/v1/tx.proto @@ -13,6 +13,7 @@ service Msg { rpc CreateDID(MsgCreateDID) returns (MsgCreateDIDResponse); rpc UpdateDID(MsgUpdateDID) returns (MsgUpdateDIDResponse); rpc CreateSchema(MsgCreateSchema) returns (MsgCreateSchemaResponse); + rpc DeactivateDID(MsgDeactivateDID) returns (MsgDeactivateDIDResponse); // this line is used by starport scaffolding # proto/tx/rpc } @@ -28,8 +29,9 @@ message MsgCreateDIDResponse { message MsgUpdateDID { Did didDocString = 1; - repeated SignInfo signatures = 2; - string creator = 3; + string version_id = 2; + repeated SignInfo signatures = 3; + string creator = 4; } message MsgUpdateDIDResponse { @@ -46,4 +48,15 @@ message MsgCreateSchemaResponse { uint64 id = 1; } +message MsgDeactivateDID { + string creator = 1; + Did didDocString = 2; + string version_id = 3; + repeated SignInfo signatures = 4; +} + +message MsgDeactivateDIDResponse { + uint64 id = 1; +} + // this line is used by starport scaffolding # proto/tx/message \ No newline at end of file diff --git a/tests/README.md b/tests/README.md index 5811064..e514440 100644 --- a/tests/README.md +++ b/tests/README.md @@ -3,8 +3,12 @@ ### DIDDoc - Run `create-users.sh` to create three users -- Run `tests/didDoc/test_did.sh` to run the tests for DIDdoc. Following are the scenarios being tested +- Run `tests/didDoc/test_update_did.sh` to run the tests for DIDdoc Update. Following are the scenarios being tested - Adding User-1's DID to User-2's `controller` - Making changes in User-2's DIDDoc with User-1's verification key. (Adding a new element in `context` field) - User-3 trying to add it's DID in User-2's DIDDoc using its verification key - - Adding User-3's DID to User-2's DIDDoc using User-2's verification key \ No newline at end of file + - Adding User-3's DID to User-2's DIDDoc using User-2's verification key +- Run `tests/didDoc/test_deactivate_did.sh` to run the tests for DIDdoc Deactivate. Following are the scenarios being tested + - User-1 (non-controller) trying to deactivate User-2. (It should FAIL) + - User-2 trying to deactivate to DID using it's own verification key. + - User-2 attempting to update the DID which is already deactivated. (It should FAIL) \ No newline at end of file diff --git a/tests/create_users.sh b/tests/create_users.sh index cd482fe..dc6d256 100755 --- a/tests/create_users.sh +++ b/tests/create_users.sh @@ -88,4 +88,4 @@ echo "\n -----------User 3 has been created ----------- " hid-noded query ssi did did:hs:0f49341a-20ef-43d1-bc93-de30993e6c53 -echo "--------------- x ----------- " \ No newline at end of file +echo "--------------- x ----------- " diff --git a/tests/didDoc/test_deactivate_did.sh b/tests/didDoc/test_deactivate_did.sh new file mode 100644 index 0000000..295e33c --- /dev/null +++ b/tests/didDoc/test_deactivate_did.sh @@ -0,0 +1,92 @@ +#!bin/sh + +first_test_case () { + echo "----------------Test case 1: A non-controller DID (User-1) trying to deactivate User-2's DID----------------" + echo "----------------It should throw an Error----------------" + VERSION_ID=$(hid-noded query ssi did did:hs:0f49341a-20ef-43d1-bc93-de30993e6c52 --output json | jq -r '.didDoc.metadata.versionId') + hid-noded tx ssi deactivate-did '{ +"context": [ +"https://www.w3.org/ns/did/v1", +"https://w3id.org/security/v1", +"https://schema.org" +], +"id": "did:hs:0f49341a-20ef-43d1-bc93-de30993e6c52", +"controller": ["did:hs:0f49341a-20ef-43d1-bc93-de30993e6c52"], +"alsoKnownAs": ["did:hs:1f49341a-de30993e6c52"], +"verificationMethod": [ +{ +"id": "did:hs:0f49341a-20ef-43d1-bc93-de30993e6c52#z8BXg2zjwBRTrjPs7uCnkFBKrL9bPD14HxEJMENxm3CJ4", +"type": "Ed25519VerificationKey2020", +"controller": "did:hs:0f49341a-20ef-43d1-bc93-de30993e6c52", +"publicKeyMultibase": "z8BXg2zjwBRTrjPs7uCnkFBKrL9bPD14HxEJMENxm3CJ4" +} +], +"authentication": [ +"did:hs:0f49341a-20ef-43d1-bc93-de30993e6c52#z8BXg2zjwBRTrjPs7uCnkFBKrL9bPD14HxEJMENxm3CJ4" +] +}' "${VERSION_ID}" did:hs:0f49341a-20ef-43d1-bc93-de30993e6c51#zEYJrMxWigf9boyeJMTRN4Ern8DJMoCXaLK77pzQmxVjf --ver-key oVtY1xceDZQjkfwlbCEC2vgeADcxpgd27vtYasBhcM/JLR6PnPoD9jvjSJrMsMJwS7faPy5OlFCdj/kgLVZMEg== --from alice --chain-id hidnode --yes + echo "----------------x----------------" +} + +second_test_case () { + echo "\n\n----------------Test case 2: Deactivating User-2's DID using its verification key----------------" + VERSION_ID=$(hid-noded query ssi did did:hs:0f49341a-20ef-43d1-bc93-de30993e6c52 --output json | jq -r '.didDoc.metadata.versionId') + hid-noded tx ssi deactivate-did '{ +"context": [ +"https://www.w3.org/ns/did/v1", +"https://w3id.org/security/v1", +"https://schema.org" +], +"id": "did:hs:0f49341a-20ef-43d1-bc93-de30993e6c52", +"controller": ["did:hs:0f49341a-20ef-43d1-bc93-de30993e6c52"], +"alsoKnownAs": ["did:hs:1f49341a-de30993e6c52"], +"verificationMethod": [ +{ +"id": "did:hs:0f49341a-20ef-43d1-bc93-de30993e6c52#z8BXg2zjwBRTrjPs7uCnkFBKrL9bPD14HxEJMENxm3CJ4", +"type": "Ed25519VerificationKey2020", +"controller": "did:hs:0f49341a-20ef-43d1-bc93-de30993e6c52", +"publicKeyMultibase": "z8BXg2zjwBRTrjPs7uCnkFBKrL9bPD14HxEJMENxm3CJ4" +} +], +"authentication": [ +"did:hs:0f49341a-20ef-43d1-bc93-de30993e6c52#z8BXg2zjwBRTrjPs7uCnkFBKrL9bPD14HxEJMENxm3CJ4" +] +}' "${VERSION_ID}" did:hs:0f49341a-20ef-43d1-bc93-de30993e6c52#z8BXg2zjwBRTrjPs7uCnkFBKrL9bPD14HxEJMENxm3CJ4 --ver-key bZBUkLGChnJujYHUZ4L8PECoN2Odv6adWGXc1qVWCRVqtEx0o/FmtFZnd5pT3laR518P58TRUGY5q5KSrToSmQ== --from alice --chain-id hidnode --yes + echo "----------------x----------------" +} + +third_test_case () { + echo "\n\n----------------Test case 3: Attempting to update the deactivated DID----------------" + echo "----------------It should throw an Error----------------" + VERSION_ID=$(hid-noded query ssi did did:hs:0f49341a-20ef-43d1-bc93-de30993e6c52 --output json | jq -r '.didDoc.metadata.versionId') + hid-noded tx ssi update-did '{ +"context": [ +"https://www.w3.org/ns/did/v1", +"https://w3id.org/security/v1", +"https://schema.org" +], +"id": "did:hs:0f49341a-20ef-43d1-bc93-de30993e6c52", +"controller": ["did:hs:0f49341a-20ef-43d1-bc93-de30993e6c52","did:hs:0f49341a-20ef-43d1-bc93-de30993e6c51"], +"alsoKnownAs": ["did:hs:1f49341a-de30993e6c52"], +"verificationMethod": [ +{ +"id": "did:hs:0f49341a-20ef-43d1-bc93-de30993e6c52#z8BXg2zjwBRTrjPs7uCnkFBKrL9bPD14HxEJMENxm3CJ4", +"type": "Ed25519VerificationKey2020", +"controller": "did:hs:0f49341a-20ef-43d1-bc93-de30993e6c52", +"publicKeyMultibase": "z8BXg2zjwBRTrjPs7uCnkFBKrL9bPD14HxEJMENxm3CJ4" +} +], +"authentication": [ +"did:hs:0f49341a-20ef-43d1-bc93-de30993e6c52#z8BXg2zjwBRTrjPs7uCnkFBKrL9bPD14HxEJMENxm3CJ4" +] +}' "${VERSION_ID}" did:hs:0f49341a-20ef-43d1-bc93-de30993e6c52#z8BXg2zjwBRTrjPs7uCnkFBKrL9bPD14HxEJMENxm3CJ4 --ver-key bZBUkLGChnJujYHUZ4L8PECoN2Odv6adWGXc1qVWCRVqtEx0o/FmtFZnd5pT3laR518P58TRUGY5q5KSrToSmQ== --from alice --chain-id hidnode --yes + echo "----------------x----------------" +} + +run_tests() { + first_test_case + second_test_case + third_test_case +} + +run_tests \ No newline at end of file diff --git a/tests/didDoc/test_did.sh b/tests/didDoc/test_update_did.sh similarity index 73% rename from tests/didDoc/test_did.sh rename to tests/didDoc/test_update_did.sh index 5dac4cd..216621f 100755 --- a/tests/didDoc/test_did.sh +++ b/tests/didDoc/test_update_did.sh @@ -4,10 +4,11 @@ echo "----------- Testing for DID Controller -----------" - first_test_case () { echo "\n\n ------------- TC-1: Adding User-1's DID to User-2's controller -------------" +VERSION_ID=$(hid-noded query ssi did did:hs:0f49341a-20ef-43d1-bc93-de30993e6c52 --output json | jq -r '.didDoc.metadata.versionId') + hid-noded tx ssi update-did '{ "context": [ "https://www.w3.org/ns/did/v1", @@ -28,7 +29,7 @@ hid-noded tx ssi update-did '{ "authentication": [ "did:hs:0f49341a-20ef-43d1-bc93-de30993e6c52#z8BXg2zjwBRTrjPs7uCnkFBKrL9bPD14HxEJMENxm3CJ4" ] -}' did:hs:0f49341a-20ef-43d1-bc93-de30993e6c52#z8BXg2zjwBRTrjPs7uCnkFBKrL9bPD14HxEJMENxm3CJ4 --ver-key bZBUkLGChnJujYHUZ4L8PECoN2Odv6adWGXc1qVWCRVqtEx0o/FmtFZnd5pT3laR518P58TRUGY5q5KSrToSmQ== --from alice --chain-id hidnode --yes +}' "${VERSION_ID}" did:hs:0f49341a-20ef-43d1-bc93-de30993e6c52#z8BXg2zjwBRTrjPs7uCnkFBKrL9bPD14HxEJMENxm3CJ4 --ver-key bZBUkLGChnJujYHUZ4L8PECoN2Odv6adWGXc1qVWCRVqtEx0o/FmtFZnd5pT3laR518P58TRUGY5q5KSrToSmQ== --from alice --chain-id hidnode --yes echo "\n\n ------------- TC-1 tested successfully -------------" } @@ -37,6 +38,8 @@ echo "\n\n ------------- TC-1 tested successfully -------------" second_test_case() { echo "\n\n ------------- TC-2: Making changes in User-2's DIDDoc with User-1's verification key. (Adding a new element in context field) -------------" +VERSION_ID=$(hid-noded query ssi did did:hs:0f49341a-20ef-43d1-bc93-de30993e6c52 --output json | jq -r '.didDoc.metadata.versionId') + hid-noded tx ssi update-did '{ "context": [ "https://www.w3.org/ns/did/v1", @@ -58,7 +61,7 @@ hid-noded tx ssi update-did '{ "authentication": [ "did:hs:0f49341a-20ef-43d1-bc93-de30993e6c52#z8BXg2zjwBRTrjPs7uCnkFBKrL9bPD14HxEJMENxm3CJ4" ] -}' did:hs:0f49341a-20ef-43d1-bc93-de30993e6c51#zEYJrMxWigf9boyeJMTRN4Ern8DJMoCXaLK77pzQmxVjf --ver-key oVtY1xceDZQjkfwlbCEC2vgeADcxpgd27vtYasBhcM/JLR6PnPoD9jvjSJrMsMJwS7faPy5OlFCdj/kgLVZMEg== --from alice --chain-id hidnode --yes +}' "${VERSION_ID}" did:hs:0f49341a-20ef-43d1-bc93-de30993e6c51#zEYJrMxWigf9boyeJMTRN4Ern8DJMoCXaLK77pzQmxVjf --ver-key oVtY1xceDZQjkfwlbCEC2vgeADcxpgd27vtYasBhcM/JLR6PnPoD9jvjSJrMsMJwS7faPy5OlFCdj/kgLVZMEg== --from alice --chain-id hidnode --yes echo "\n\n ------------- TC-2 tested successfully -------------" } @@ -67,6 +70,8 @@ echo "\n\n ------------- TC-2 tested successfully -------------" third_test_case() { echo "\n\n ------------- TC-3: User-3 trying to add it's DID in User-2's DIDDoc using its verification key -------------" +VERSION_ID=$(hid-noded query ssi did did:hs:0f49341a-20ef-43d1-bc93-de30993e6c52 --output json | jq -r '.didDoc.metadata.versionId') + hid-noded tx ssi update-did '{ "context": [ "https://www.w3.org/ns/did/v1", @@ -90,7 +95,7 @@ hid-noded tx ssi update-did '{ "authentication": [ "did:hs:0f49341a-20ef-43d1-bc93-de30993e6c52#z8BXg2zjwBRTrjPs7uCnkFBKrL9bPD14HxEJMENxm3CJ4" ] -}' did:hs:0f49341a-20ef-43d1-bc93-de30993e6c53#zE2seaoaAwBzfLaTd7oqEf5GJZdEiQgo64ayJgMstRZ91 --ver-key JFfT5yPnBbwcDkmry9vdqX9eBKJmfnTT9C1r0LZ5S73BosdZL7AaZ9AYx6Mpvvw/ebaKPyaIiVZ3StijU8RRAA== --from alice --chain-id hidnode --yes +}' "${VERSION_ID}" did:hs:0f49341a-20ef-43d1-bc93-de30993e6c53#zE2seaoaAwBzfLaTd7oqEf5GJZdEiQgo64ayJgMstRZ91 --ver-key JFfT5yPnBbwcDkmry9vdqX9eBKJmfnTT9C1r0LZ5S73BosdZL7AaZ9AYx6Mpvvw/ebaKPyaIiVZ3StijU8RRAA== --from alice --chain-id hidnode --yes echo "\n\n ------------- TC-3 tested successfully -------------" } @@ -99,6 +104,8 @@ echo "\n\n ------------- TC-3 tested successfully -------------" fourth_test_case() { echo "\n\n ------------- TC-4: Adding User-3's DID to User-2's DIDDoc using User-2's verification key -------------" +VERSION_ID=$(hid-noded query ssi did did:hs:0f49341a-20ef-43d1-bc93-de30993e6c52 --output json | jq -r '.didDoc.metadata.versionId') + hid-noded tx ssi update-did '{ "context": [ "https://www.w3.org/ns/did/v1", @@ -120,7 +127,7 @@ hid-noded tx ssi update-did '{ "authentication": [ "did:hs:0f49341a-20ef-43d1-bc93-de30993e6c52#z8BXg2zjwBRTrjPs7uCnkFBKrL9bPD14HxEJMENxm3CJ4" ] -}' did:hs:0f49341a-20ef-43d1-bc93-de30993e6c52#z8BXg2zjwBRTrjPs7uCnkFBKrL9bPD14HxEJMENxm3CJ4 --ver-key bZBUkLGChnJujYHUZ4L8PECoN2Odv6adWGXc1qVWCRVqtEx0o/FmtFZnd5pT3laR518P58TRUGY5q5KSrToSmQ== --from alice --chain-id hidnode --yes +}' "${VERSION_ID}" did:hs:0f49341a-20ef-43d1-bc93-de30993e6c52#z8BXg2zjwBRTrjPs7uCnkFBKrL9bPD14HxEJMENxm3CJ4 --ver-key bZBUkLGChnJujYHUZ4L8PECoN2Odv6adWGXc1qVWCRVqtEx0o/FmtFZnd5pT3laR518P58TRUGY5q5KSrToSmQ== --from alice --chain-id hidnode --yes echo "\n\n ------------- TC-4 tested successfully -------------" } diff --git a/x/ssi/client/cli/query.go b/x/ssi/client/cli/query.go index c283d90..03b4561 100644 --- a/x/ssi/client/cli/query.go +++ b/x/ssi/client/cli/query.go @@ -31,9 +31,7 @@ func GetQueryCmd(queryRoute string) *cobra.Command { cmd.AddCommand(CmdSchemaCount()) - cmd.AddCommand(CmdGetDidDocById()) - - cmd.AddCommand(CmdDidDocCount()) + cmd.AddCommand(CmdResolveDID()) // this line is used by starport scaffolding # 1 diff --git a/x/ssi/client/cli/query_ssi.go b/x/ssi/client/cli/query_ssi.go index b863548..36bfb8d 100644 --- a/x/ssi/client/cli/query_ssi.go +++ b/x/ssi/client/cli/query_ssi.go @@ -102,7 +102,7 @@ func CmdSchemaCount() *cobra.Command { return cmd } -func CmdGetDidDocById() *cobra.Command { +func CmdResolveDID() *cobra.Command { cmd := &cobra.Command{ Use: "did [didDoc-id]", Short: "Query DidDoc for a given didDoc id", @@ -117,9 +117,9 @@ func CmdGetDidDocById() *cobra.Command { queryClient := types.NewQueryClient(clientCtx) - params := &types.QueryGetDidDocByIdRequest{DidDocId: argDidDocId} + params := &types.QueryGetDidDocByIdRequest{DidId: argDidDocId} - res, err := queryClient.GetDidDocById(cmd.Context(), params) + res, err := queryClient.ResolveDid(cmd.Context(), params) if err != nil { return err } @@ -133,32 +133,3 @@ func CmdGetDidDocById() *cobra.Command { return cmd } -func CmdDidDocCount() *cobra.Command { - cmd := &cobra.Command{ - Use: "did-count", - Short: "Query the DID Count", - Args: cobra.ExactArgs(0), - RunE: func(cmd *cobra.Command, args []string) (err error) { - - clientCtx, err := client.GetClientTxContext(cmd) - if err != nil { - return err - } - - queryClient := types.NewQueryClient(clientCtx) - - params := &types.QueryDidDocCountRequest{} - - res, err := queryClient.DidDocCount(cmd.Context(), params) - if err != nil { - return err - } - - return clientCtx.PrintProto(res) - }, - } - - flags.AddQueryFlagsToCmd(cmd) - - return cmd -} \ No newline at end of file diff --git a/x/ssi/client/cli/tx.go b/x/ssi/client/cli/tx.go index b669da9..a6d4c4d 100644 --- a/x/ssi/client/cli/tx.go +++ b/x/ssi/client/cli/tx.go @@ -33,6 +33,7 @@ func GetTxCmd() *cobra.Command { cmd.AddCommand(CmdCreateDID()) cmd.AddCommand(CmdUpdateDID()) cmd.AddCommand(CmdCreateSchema()) + cmd.AddCommand(CmdDeactivateDID()) // this line is used by starport scaffolding # 1 return cmd diff --git a/x/ssi/client/cli/tx_ssi.go b/x/ssi/client/cli/tx_ssi.go index b8f8d3f..2ea11d2 100644 --- a/x/ssi/client/cli/tx_ssi.go +++ b/x/ssi/client/cli/tx_ssi.go @@ -68,12 +68,13 @@ func CmdCreateDID() *cobra.Command { func CmdUpdateDID() *cobra.Command { cmd := &cobra.Command{ - Use: "update-did [did-doc-string] [verification-method-id]", + Use: "update-did [did-doc-string] [version-id] [verification-method-id]", Short: "Updates the DID", - Args: cobra.ExactArgs(2), + Args: cobra.ExactArgs(3), RunE: func(cmd *cobra.Command, args []string) (err error) { argDidDocString := args[0] - argVerificationMethodId := args[1] + argVersionId := args[1] + argVerificationMethodId := args[2] clientCtx, err := client.GetClientTxContext(cmd) if err != nil { @@ -104,6 +105,7 @@ func CmdUpdateDID() *cobra.Command { msg := types.MsgUpdateDID{ Creator: clientCtx.GetFromAddress().String(), DidDocString: &didDoc, + VersionId: argVersionId, Signatures: []*types.SignInfo{&signInfo}, } @@ -172,3 +174,58 @@ func CmdCreateSchema() *cobra.Command { cmd.Flags().String(VerKeyFlag, "", "Base64 encoded ed25519 private key to sign identity message with. ") return cmd } + +func CmdDeactivateDID() *cobra.Command { + cmd := &cobra.Command{ + Use: "deactivate-did [did-doc-string] [version-id] [verification-method-id]", + Short: "Deactivates the DID", + Args: cobra.ExactArgs(3), + RunE: func(cmd *cobra.Command, args []string) (err error) { + argDidDocString := args[0] + argVersionId := args[1] + argVerificationMethodId := args[2] + + clientCtx, err := client.GetClientTxContext(cmd) + if err != nil { + return err + } + + var didDoc types.Did + err = clientCtx.Codec.UnmarshalJSON([]byte(argDidDocString), &didDoc) + if err != nil { + return err + } + + verKeyPriv, err := getVerKey(cmd, clientCtx) + if err != nil { + return err + } + + // // Build identity message + signBytes := didDoc.GetSignBytes() + signatureBytes := ed25519.Sign(verKeyPriv, signBytes) + + signInfo := types.SignInfo{ + VerificationMethodId: argVerificationMethodId, + Signature: base64.StdEncoding.EncodeToString(signatureBytes), + } + + msg := types.MsgDeactivateDID{ + Creator: clientCtx.GetFromAddress().String(), + DidDocString: &didDoc, + VersionId: argVersionId, + Signatures: []*types.SignInfo{&signInfo}, + } + + if err := msg.ValidateBasic(); err != nil { + return err + } + + return tx.GenerateOrBroadcastTxCLI(clientCtx, cmd.Flags(), &msg) + }, + } + + flags.AddTxFlagsToCmd(cmd) + cmd.Flags().String(VerKeyFlag, "", "Base64 encoded ed25519 private key to sign identity message with. ") + return cmd +} diff --git a/x/ssi/handler.go b/x/ssi/handler.go index 3861c70..94622cd 100644 --- a/x/ssi/handler.go +++ b/x/ssi/handler.go @@ -26,6 +26,9 @@ func NewHandler(k keeper.Keeper) sdk.Handler { case *types.MsgCreateSchema: res, err := msgServer.CreateSchema(sdk.WrapSDKContext(ctx), msg) return sdk.WrapServiceResult(ctx, res, err) + case *types.MsgDeactivateDID: + res, err := msgServer.DeactivateDID(sdk.WrapSDKContext(ctx), msg) + return sdk.WrapServiceResult(ctx, res, err) // this line is used by starport scaffolding # 1 default: errMsg := fmt.Sprintf("unrecognized %s message type: %T", types.ModuleName, msg) diff --git a/x/ssi/keeper/did.go b/x/ssi/keeper/did.go index acf06a7..177454e 100644 --- a/x/ssi/keeper/did.go +++ b/x/ssi/keeper/did.go @@ -32,14 +32,14 @@ func (k Keeper) HasDid(ctx sdk.Context, id string) bool { } // Retrieves the DID from the store -func (k Keeper) GetDid(ctx *sdk.Context, id string) (*types.Did, error) { +func (k Keeper) GetDid(ctx *sdk.Context, id string) (*types.DidDocument, error) { store := prefix.NewStore(ctx.KVStore(k.storeKey), types.KeyPrefix(types.DidKey)) if !k.HasDid(*ctx, id) { return nil, sdkerrors.ErrNotFound } - var value types.Did + var value types.DidDocument var bytes = store.Get([]byte(id)) if err := k.cdc.Unmarshal(bytes, &value); err != nil { return nil, sdkerrors.Wrap(sdkerrors.ErrInvalidType, err.Error()) @@ -61,21 +61,31 @@ func (k Keeper) SetDidCount(ctx sdk.Context, count uint64) { } // SetDid set a specific did in the store -func (k Keeper) SetDid(ctx sdk.Context, did types.Did) error { +func (k Keeper) SetDid(ctx sdk.Context, didDoc types.DidDocument) error { store := prefix.NewStore(ctx.KVStore(k.storeKey), types.KeyPrefix(types.DidKey)) - b := k.cdc.MustMarshal(&did) - store.Set([]byte(did.Id), b) + b := k.cdc.MustMarshal(&didDoc) + store.Set([]byte(didDoc.Did.Id), b) return nil } -func (k Keeper) AppendDID(ctx sdk.Context, didSpec types.Did) uint64 { +// SetDid set a specific did in the store +func (k Keeper) SetDidDeactivate(ctx sdk.Context, didDoc types.DidDocument, id string) error { + store := prefix.NewStore(ctx.KVStore(k.storeKey), types.KeyPrefix(types.DidKey)) + b := k.cdc.MustMarshal(&didDoc) + store.Set([]byte(id), b) + return nil +} + +func (k Keeper) AppendDID(ctx sdk.Context, didDoc *types.DidDocument) uint64 { // Get the current number of DIDs in the store count := k.GetDidCount(ctx) // Get the store store := prefix.NewStore(ctx.KVStore(k.storeKey), []byte(types.DidKey)) + // Get ID from DID Doc + id := didDoc.GetDid().GetId() // Marshal the DID into bytes - didDocString := k.cdc.MustMarshal(&didSpec) - store.Set(utils.UnsafeStrToBytes(didSpec.Id), didDocString) + didDocBytes := k.cdc.MustMarshal(didDoc) + store.Set([]byte(id), didDocBytes) // Update the Did count k.SetDidCount(ctx, count+1) return count diff --git a/x/ssi/keeper/grpc_query_did.go b/x/ssi/keeper/grpc_query_did.go index ba3b73f..7226515 100644 --- a/x/ssi/keeper/grpc_query_did.go +++ b/x/ssi/keeper/grpc_query_did.go @@ -2,38 +2,119 @@ package keeper import ( "context" + "time" + //"fmt" + + "github.com/cosmos/cosmos-sdk/store/prefix" sdk "github.com/cosmos/cosmos-sdk/types" + "github.com/cosmos/cosmos-sdk/types/query" + + //sdkerrors "github.com/cosmos/cosmos-sdk/types/errors" "github.com/hypersign-protocol/hid-node/x/ssi/types" + "github.com/hypersign-protocol/hid-node/x/ssi/utils" "google.golang.org/grpc/codes" "google.golang.org/grpc/status" ) -func (k Keeper) DidDocCount(goCtx context.Context, req *types.QueryDidDocCountRequest) (*types.QueryDidDocCountResponse, error) { +func (k Keeper) DidParam(goCtx context.Context, req *types.QueryDidParamRequest) (*types.QueryDidParamResponse, error) { if req == nil { return nil, status.Error(codes.InvalidArgument, "invalid request") } ctx := sdk.UnwrapSDKContext(goCtx) + store := prefix.NewStore(ctx.KVStore(k.storeKey), types.KeyPrefix(types.DidKey)) - var didDocCount uint64 = k.GetDidCount(ctx) + var didResolveList []*types.DidResolutionResponse + _, err := query.Paginate(store, req.Pagination, func(key []byte, value []byte) error { + var ( + didResolve types.DidResolutionResponse + didDoc types.DidDocument + ) + if err := k.cdc.Unmarshal(value, &didDoc); err != nil { + return err + } + + didResolve.DidDocument = didDoc.Did + didResolve.DidDocumentMetadata = didDoc.Metadata + didResolve.DidResolutionMetadata = &types.DidResolveMeta{ + Error: "", + Retrieved: ctx.BlockTime().Format(time.RFC3339), + } + + didResolveList = append(didResolveList, &didResolve) + return nil + }) + + // Throw an error if pagination failed + if err != nil { + return nil, status.Error(codes.Internal, err.Error()) + } - return &types.QueryDidDocCountResponse{Count: didDocCount}, nil + var didDocCount uint64 = k.GetDidCount(ctx) + if req.Count { + return &types.QueryDidParamResponse{TotalDidCount: didDocCount}, nil + } + return &types.QueryDidParamResponse{TotalDidCount: didDocCount, DidDocList: didResolveList}, nil } -func (k Keeper) GetDidDocById(goCtx context.Context, req *types.QueryGetDidDocByIdRequest) (*types.QueryGetDidDocByIdResponse, error) { +// Ref: https://w3c-ccg.github.io/did-resolution/#resolving-algorithm +func (k Keeper) ResolveDid(goCtx context.Context, req *types.QueryGetDidDocByIdRequest) (*types.QueryGetDidDocByIdResponse, error) { if req == nil { return nil, status.Error(codes.InvalidArgument, "invalid request") } ctx := sdk.UnwrapSDKContext(goCtx) - didDoc, err := k.GetDid(&ctx, req.DidDocId) + // Invalid DID Check + err := utils.IsValidDid(req.DidId) + switch err { + case types.ErrInvalidDidElements: + return &types.QueryGetDidDocByIdResponse{ + DidDocument: nil, + DidDocumentMetadata: nil, + DidResolutionMetadata: &types.DidResolveMeta{ + Error: "invalidDid", + }, + }, nil + case types.ErrInvalidDidMethod: + return &types.QueryGetDidDocByIdResponse{ + DidDocument: nil, + DidDocumentMetadata: nil, + DidResolutionMetadata: &types.DidResolveMeta{ + Error: "methodNotSupported", + }, + }, nil + } + + // Check if DID Document exists + didDoc, err := k.GetDid(&ctx, req.DidId) if err != nil { - return nil, status.Error(codes.NotFound, "DidDoc not found") + return &types.QueryGetDidDocByIdResponse{ + DidDocument: nil, + DidDocumentMetadata: nil, + DidResolutionMetadata: &types.DidResolveMeta{ + Error: "notFound", + }, + }, nil + } + + // Check if DID Document is deactivated + if didDoc.GetMetadata().GetDeactivated() { + return &types.QueryGetDidDocByIdResponse{ + DidDocument: nil, + DidDocumentMetadata: didDoc.GetMetadata(), + DidResolutionMetadata: &types.DidResolveMeta{ + Retrieved: ctx.BlockTime().Format(time.RFC3339), + }, + }, nil } return &types.QueryGetDidDocByIdResponse{ - DidDoc: didDoc, + DidDocument: didDoc.GetDid(), + DidDocumentMetadata: didDoc.GetMetadata(), + DidResolutionMetadata: &types.DidResolveMeta{ + Retrieved: ctx.BlockTime().Format(time.RFC3339), + }, }, nil } diff --git a/x/ssi/keeper/grpc_query_schema.go b/x/ssi/keeper/grpc_query_schema.go index ff0ef16..0e6f3c6 100644 --- a/x/ssi/keeper/grpc_query_schema.go +++ b/x/ssi/keeper/grpc_query_schema.go @@ -5,8 +5,8 @@ import ( "github.com/cosmos/cosmos-sdk/store/prefix" sdk "github.com/cosmos/cosmos-sdk/types" - "github.com/hypersign-protocol/hid-node/utils" "github.com/cosmos/cosmos-sdk/types/query" + "github.com/hypersign-protocol/hid-node/utils" "github.com/hypersign-protocol/hid-node/x/ssi/types" "google.golang.org/grpc/codes" "google.golang.org/grpc/status" @@ -75,4 +75,4 @@ func (k Keeper) Schemas(goCtx context.Context, req *types.QuerySchemasRequest) ( return nil, status.Error(codes.Internal, err.Error()) } return &types.QuerySchemasResponse{SchemaList: schemas, Pagination: pageRes}, nil -} \ No newline at end of file +} diff --git a/x/ssi/keeper/msg_server_did.go b/x/ssi/keeper/msg_server_did.go index 0143ed9..287f9d9 100644 --- a/x/ssi/keeper/msg_server_did.go +++ b/x/ssi/keeper/msg_server_did.go @@ -16,8 +16,8 @@ func (k msgServer) CreateDID(goCtx context.Context, msg *types.MsgCreateDID) (*t didMsg := msg.GetDidDocString() did := didMsg.GetId() // Checks if the DID has a valid format - if !utils.IsValidDid(did) { - return nil, types.ErrBadRequestIsNotDid.Wrap(did) + if err := utils.IsValidDid(did); err != nil { + return nil, err } // Checks if the DidDoc is a valid format @@ -52,11 +52,18 @@ func (k msgServer) CreateDID(goCtx context.Context, msg *types.MsgCreateDID) (*t CapabilityInvocation: didMsg.GetCapabilityInvocation(), CapabilityDelegation: didMsg.GetCapabilityDelegation(), Service: didMsg.GetService(), - Created: didMsg.GetCreated(), - Updated: didMsg.GetUpdated(), + } + + // Create the Metadata + metadata := types.CreateNewMetadata(ctx) + + // Form the DID Document + didDoc := types.DidDocument{ + Did: &didSpec, + Metadata: &metadata, } // Add a DID to the store and get back the ID - id := k.AppendDID(ctx, didSpec) + id := k.AppendDID(ctx, &didDoc) // Return the Id of the DID return &types.MsgCreateDIDResponse{Id: id}, nil } @@ -66,17 +73,25 @@ func (k msgServer) UpdateDID(goCtx context.Context, msg *types.MsgUpdateDID) (*t didMsg := msg.GetDidDocString() did := msg.GetDidDocString().GetId() + versionId := msg.GetVersionId() oldDIDDoc, err := k.GetDid(&ctx, didMsg.Id) if err != nil { return nil, err } + oldDid := oldDIDDoc.GetDid() + oldMetaData := oldDIDDoc.GetMetadata() + + // Check if the DID is already deactivated + if err := VerifyDidDeactivate(oldMetaData, didMsg.Id); err != nil { + return nil, err + } - // TODO: Implement this when we have generic type for Create and Update DID - // didDocCheck := utils.IsValidDidDoc(didMsg) - // if didDocCheck != "" { - // return nil, sdkerrors.Wrap(types.ErrInvalidDidDoc, didDocCheck) - // } + // Check if the didDoc is valid + didDocCheck := utils.IsValidDidDoc(didMsg) + if didDocCheck != "" { + return nil, sdkerrors.Wrap(types.ErrInvalidDidDoc, didDocCheck) + } // Checks if the DID is not present in the store if !k.HasDid(ctx, did) { @@ -87,15 +102,15 @@ func (k msgServer) UpdateDID(goCtx context.Context, msg *types.MsgUpdateDID) (*t return nil, sdkerrors.Wrap(types.ErrInvalidDidDoc, "DID controller is not valid") } - if err := k.VerifySignatureOnDidUpdate(&ctx, oldDIDDoc, didMsg, msg.Signatures); err != nil { + if err := k.VerifySignatureOnDidUpdate(&ctx, oldDid, didMsg, msg.Signatures); err != nil { return nil, err } - // TODO: Implement this when the version ID is used - // if oldStateValue.Metadata.VersionId != didMsg.VersionId { - // errMsg := fmt.Sprintf("Ecpected %s with version %s. Got version %s", didMsg.Id, oldStateValue.Metadata.VersionId, didMsg.VersionId) - // return nil, sdkerrors.Wrap(types.ErrUnexpectedDidVersion, errMsg) - // } + // Check if the versionId passed is the same as the one in the Latest DID Document in store + if oldMetaData.VersionId != versionId { + errMsg := fmt.Sprintf("Expected %s with version %s. Got version %s", didMsg.Id, oldMetaData.VersionId, versionId) + return nil, sdkerrors.Wrap(types.ErrUnexpectedDidVersion, errMsg) + } var didSpec = types.Did{ Context: didMsg.GetContext(), @@ -108,15 +123,85 @@ func (k msgServer) UpdateDID(goCtx context.Context, msg *types.MsgUpdateDID) (*t KeyAgreement: didMsg.GetKeyAgreement(), CapabilityInvocation: didMsg.GetCapabilityInvocation(), Service: didMsg.GetService(), - Created: didMsg.GetCreated(), - Updated: didMsg.GetUpdated(), } - didSpec.Updated = ctx.BlockTime().String() + // Create the Metadata + metadata := types.CreateNewMetadata(ctx) + // Assign `created` and `deactivated` to previous DIDDoc's metadata values + metadata.Created = oldDIDDoc.GetMetadata().Created + metadata.Deactivated = oldDIDDoc.GetMetadata().Deactivated - if err := k.SetDid(ctx, didSpec); err != nil { + // Form the DID Document + didDoc := types.DidDocument{ + Did: &didSpec, + Metadata: &metadata, + } + if err := k.SetDid(ctx, didDoc); err != nil { return nil, err } return &types.MsgUpdateDIDResponse{UpdateId: didSpec.Id}, nil -} \ No newline at end of file +} + +func (k msgServer) DeactivateDID(goCtx context.Context, msg *types.MsgDeactivateDID) (*types.MsgDeactivateDIDResponse, error) { + ctx := sdk.UnwrapSDKContext(goCtx) + + didMsg := msg.GetDidDocString() + id := msg.GetDidDocString().GetId() + versionId := msg.GetVersionId() + + oldDIDDoc, err := k.GetDid(&ctx, didMsg.Id) + if err != nil { + return nil, err + } + oldDid := oldDIDDoc.GetDid() + oldMetaData := oldDIDDoc.GetMetadata() + + // Check if the didDoc is valid + didDocCheck := utils.IsValidDidDoc(didMsg) + if didDocCheck != "" { + return nil, sdkerrors.Wrap(types.ErrInvalidDidDoc, didDocCheck) + } + + // Checks if the DID is not present in the store + if !k.HasDid(ctx, id) { + return nil, sdkerrors.Wrap(sdkerrors.ErrKeyNotFound, fmt.Sprintf("DID doesnt exists %s", id)) + } + + if k.ValidateDidControllers(&ctx, id, didMsg.GetController(), didMsg.GetVerificationMethod()) != nil { + return nil, sdkerrors.Wrap(types.ErrInvalidDidDoc, "DID controller is not valid") + } + + if err := k.VerifySignatureOnDidUpdate(&ctx, oldDid, didMsg, msg.Signatures); err != nil { + return nil, err + } + + // Check if the versionId passed is the same as the one in the Latest DID Document in store + if oldMetaData.VersionId != versionId { + errMsg := fmt.Sprintf("Expected %s with version %s. Got version %s", didMsg.Id, oldMetaData.VersionId, versionId) + return nil, sdkerrors.Wrap(types.ErrUnexpectedDidVersion, errMsg) + } + + // Check if the DID is already deactivated + if err := VerifyDidDeactivate(oldMetaData, didMsg.Id); err != nil { + return nil, err + } + + // Create the Metadata + metadata := types.CreateNewMetadata(ctx) + // Assign `created` and `deactivated` to previous DIDDoc's metadata values + metadata.Created = oldDIDDoc.GetMetadata().Created + metadata.Deactivated = true + + // Form the DID Document + didDoc := types.DidDocument{ + Did: nil, + Metadata: &metadata, + } + + if err := k.SetDidDeactivate(ctx, didDoc, id); err != nil { + return nil, err + } + + return &types.MsgDeactivateDIDResponse{Id: 1}, nil +} diff --git a/x/ssi/keeper/msg_server_schema.go b/x/ssi/keeper/msg_server_schema.go index 9702659..3fca8ef 100644 --- a/x/ssi/keeper/msg_server_schema.go +++ b/x/ssi/keeper/msg_server_schema.go @@ -31,7 +31,8 @@ func (k msgServer) CreateSchema(goCtx context.Context, msg *types.MsgCreateSchem } // Signature check - if err := k.VerifySignatureOnCreateSchema(&ctx, schemaMsg, authorDID.GetSigners(), msg.GetSignatures()); err != nil { + didSigners := authorDID.GetDid().GetSigners() + if err := k.VerifySignatureOnCreateSchema(&ctx, schemaMsg, didSigners, msg.GetSignatures()); err != nil { return nil, err } diff --git a/x/ssi/keeper/verify.go b/x/ssi/keeper/verify.go index 8eaa808..d4b51d1 100644 --- a/x/ssi/keeper/verify.go +++ b/x/ssi/keeper/verify.go @@ -109,7 +109,7 @@ func AppendSignerIfNeed(signers []types.Signer, controller string, msg *types.Di // Link to DID Controller Spec: https://www.w3.org/TR/did-core/#did-controller func (k *Keeper) VerifySignature(ctx *sdk.Context, msg *types.Did, signers []types.Signer, signatures []*types.SignInfo) error { var validArr []types.ValidDid - + if len(signers) == 0 { return types.ErrInvalidSignature.Wrap("At least one signer should be present") } @@ -127,8 +127,8 @@ func (k *Keeper) VerifySignature(ctx *sdk.Context, msg *types.Did, signers []typ return types.ErrDidDocNotFound.Wrap(signer.Signer) } - signer.Authentication = didDoc.Authentication - signer.VerificationMethod = didDoc.VerificationMethod + signer.Authentication = didDoc.Did.Authentication + signer.VerificationMethod = didDoc.Did.VerificationMethod } valid, err := VerifyIdentitySignature(signer, signatures, signingInput) @@ -149,7 +149,7 @@ func (k *Keeper) VerifySignature(ctx *sdk.Context, msg *types.Did, signers []typ } // TODO: Look for a better way to do this -func contains(s []types.ValidDid) (types.ValidDid) { +func contains(s []types.ValidDid) types.ValidDid { for _, v := range s { if v.IsValid { return v @@ -208,7 +208,7 @@ func (k *Keeper) ValidateController(ctx *sdk.Context, id string, controller stri if err != nil { return types.ErrDidDocNotFound.Wrap(controller) } - if len(didDoc.Authentication) == 0 { + if len(didDoc.Did.Authentication) == 0 { return types.ErrBadRequestInvalidVerMethod.Wrap( fmt.Sprintf("Verificatition method controller %s doesn't have an authentication keys", controller)) } @@ -229,4 +229,12 @@ func (k msgServer) ValidateDidControllers(ctx *sdk.Context, id string, controlle } } return nil -} \ No newline at end of file +} + +// Check the Deactivate status of DID +func VerifyDidDeactivate(metadata *types.Metadata, id string) error { + if metadata.Deactivated { + return sdkerrors.Wrap(types.ErrDidDocDeactivated, fmt.Sprintf("DidDoc ID: %s", id)) + } + return nil +} diff --git a/x/ssi/types/codec.go b/x/ssi/types/codec.go index 815ce22..effed28 100644 --- a/x/ssi/types/codec.go +++ b/x/ssi/types/codec.go @@ -11,6 +11,7 @@ func RegisterCodec(cdc *codec.LegacyAmino) { cdc.RegisterConcrete(&MsgCreateDID{}, "ssi/CreateDID", nil) cdc.RegisterConcrete(&MsgUpdateDID{}, "ssi/UpdateDID", nil) cdc.RegisterConcrete(&MsgCreateSchema{}, "ssi/CreateSchema", nil) + cdc.RegisterConcrete(&MsgDeactivateDID{}, "ssi/DeactivateDID", nil) // this line is used by starport scaffolding # 2 } @@ -24,6 +25,9 @@ func RegisterInterfaces(registry cdctypes.InterfaceRegistry) { registry.RegisterImplementations((*sdk.Msg)(nil), &MsgCreateSchema{}, ) + registry.RegisterImplementations((*sdk.Msg)(nil), + &MsgDeactivateDID{}, + ) // this line is used by starport scaffolding # 3 msgservice.RegisterMsgServiceDesc(registry, &_Msg_serviceDesc) diff --git a/x/ssi/types/did.go b/x/ssi/types/did.go index 2e6ec5f..fca2439 100644 --- a/x/ssi/types/did.go +++ b/x/ssi/types/did.go @@ -38,4 +38,4 @@ func (v VerificationMethod) GetPublicKey() ([]byte, error) { // panic(err) // } // return []sdk.AccAddress{signerAccAddr} -// } \ No newline at end of file +// } diff --git a/x/ssi/types/did.pb.go b/x/ssi/types/did.pb.go index 7fde4ef..2af1de1 100644 --- a/x/ssi/types/did.pb.go +++ b/x/ssi/types/did.pb.go @@ -34,8 +34,6 @@ type Did struct { CapabilityInvocation []string `protobuf:"bytes,9,rep,name=capabilityInvocation,proto3" json:"capabilityInvocation,omitempty"` CapabilityDelegation []string `protobuf:"bytes,10,rep,name=capabilityDelegation,proto3" json:"capabilityDelegation,omitempty"` Service []*Service `protobuf:"bytes,11,rep,name=service,proto3" json:"service,omitempty"` - Created string `protobuf:"bytes,12,opt,name=created,proto3" json:"created,omitempty"` - Updated string `protobuf:"bytes,13,opt,name=updated,proto3" json:"updated,omitempty"` } func (m *Did) Reset() { *m = Did{} } @@ -148,20 +146,126 @@ func (m *Did) GetService() []*Service { return nil } -func (m *Did) GetCreated() string { +type Metadata struct { + Created string `protobuf:"bytes,1,opt,name=created,proto3" json:"created,omitempty"` + Updated string `protobuf:"bytes,2,opt,name=updated,proto3" json:"updated,omitempty"` + Deactivated bool `protobuf:"varint,3,opt,name=deactivated,proto3" json:"deactivated,omitempty"` + VersionId string `protobuf:"bytes,4,opt,name=versionId,proto3" json:"versionId,omitempty"` +} + +func (m *Metadata) Reset() { *m = Metadata{} } +func (m *Metadata) String() string { return proto.CompactTextString(m) } +func (*Metadata) ProtoMessage() {} +func (*Metadata) Descriptor() ([]byte, []int) { + return fileDescriptor_cddfa22cf6c6aba3, []int{1} +} +func (m *Metadata) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *Metadata) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_Metadata.Marshal(b, m, deterministic) + } else { + b = b[:cap(b)] + n, err := m.MarshalToSizedBuffer(b) + if err != nil { + return nil, err + } + return b[:n], nil + } +} +func (m *Metadata) XXX_Merge(src proto.Message) { + xxx_messageInfo_Metadata.Merge(m, src) +} +func (m *Metadata) XXX_Size() int { + return m.Size() +} +func (m *Metadata) XXX_DiscardUnknown() { + xxx_messageInfo_Metadata.DiscardUnknown(m) +} + +var xxx_messageInfo_Metadata proto.InternalMessageInfo + +func (m *Metadata) GetCreated() string { if m != nil { return m.Created } return "" } -func (m *Did) GetUpdated() string { +func (m *Metadata) GetUpdated() string { if m != nil { return m.Updated } return "" } +func (m *Metadata) GetDeactivated() bool { + if m != nil { + return m.Deactivated + } + return false +} + +func (m *Metadata) GetVersionId() string { + if m != nil { + return m.VersionId + } + return "" +} + +type DidResolveMeta struct { + Retrieved string `protobuf:"bytes,2,opt,name=retrieved,proto3" json:"retrieved,omitempty"` + Error string `protobuf:"bytes,3,opt,name=error,proto3" json:"error,omitempty"` +} + +func (m *DidResolveMeta) Reset() { *m = DidResolveMeta{} } +func (m *DidResolveMeta) String() string { return proto.CompactTextString(m) } +func (*DidResolveMeta) ProtoMessage() {} +func (*DidResolveMeta) Descriptor() ([]byte, []int) { + return fileDescriptor_cddfa22cf6c6aba3, []int{2} +} +func (m *DidResolveMeta) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *DidResolveMeta) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_DidResolveMeta.Marshal(b, m, deterministic) + } else { + b = b[:cap(b)] + n, err := m.MarshalToSizedBuffer(b) + if err != nil { + return nil, err + } + return b[:n], nil + } +} +func (m *DidResolveMeta) XXX_Merge(src proto.Message) { + xxx_messageInfo_DidResolveMeta.Merge(m, src) +} +func (m *DidResolveMeta) XXX_Size() int { + return m.Size() +} +func (m *DidResolveMeta) XXX_DiscardUnknown() { + xxx_messageInfo_DidResolveMeta.DiscardUnknown(m) +} + +var xxx_messageInfo_DidResolveMeta proto.InternalMessageInfo + +func (m *DidResolveMeta) GetRetrieved() string { + if m != nil { + return m.Retrieved + } + return "" +} + +func (m *DidResolveMeta) GetError() string { + if m != nil { + return m.Error + } + return "" +} + type VerificationMethod struct { Id string `protobuf:"bytes,1,opt,name=id,proto3" json:"id,omitempty"` Type string `protobuf:"bytes,2,opt,name=type,proto3" json:"type,omitempty"` @@ -173,7 +277,7 @@ func (m *VerificationMethod) Reset() { *m = VerificationMethod{} } func (m *VerificationMethod) String() string { return proto.CompactTextString(m) } func (*VerificationMethod) ProtoMessage() {} func (*VerificationMethod) Descriptor() ([]byte, []int) { - return fileDescriptor_cddfa22cf6c6aba3, []int{1} + return fileDescriptor_cddfa22cf6c6aba3, []int{3} } func (m *VerificationMethod) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -240,7 +344,7 @@ func (m *Service) Reset() { *m = Service{} } func (m *Service) String() string { return proto.CompactTextString(m) } func (*Service) ProtoMessage() {} func (*Service) Descriptor() ([]byte, []int) { - return fileDescriptor_cddfa22cf6c6aba3, []int{2} + return fileDescriptor_cddfa22cf6c6aba3, []int{4} } func (m *Service) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -299,7 +403,7 @@ func (m *SignInfo) Reset() { *m = SignInfo{} } func (m *SignInfo) String() string { return proto.CompactTextString(m) } func (*SignInfo) ProtoMessage() {} func (*SignInfo) Descriptor() ([]byte, []int) { - return fileDescriptor_cddfa22cf6c6aba3, []int{3} + return fileDescriptor_cddfa22cf6c6aba3, []int{5} } func (m *SignInfo) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -342,49 +446,111 @@ func (m *SignInfo) GetSignature() string { return "" } +type DidDocument struct { + Did *Did `protobuf:"bytes,1,opt,name=did,proto3" json:"did,omitempty"` + Metadata *Metadata `protobuf:"bytes,2,opt,name=metadata,proto3" json:"metadata,omitempty"` +} + +func (m *DidDocument) Reset() { *m = DidDocument{} } +func (m *DidDocument) String() string { return proto.CompactTextString(m) } +func (*DidDocument) ProtoMessage() {} +func (*DidDocument) Descriptor() ([]byte, []int) { + return fileDescriptor_cddfa22cf6c6aba3, []int{6} +} +func (m *DidDocument) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *DidDocument) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_DidDocument.Marshal(b, m, deterministic) + } else { + b = b[:cap(b)] + n, err := m.MarshalToSizedBuffer(b) + if err != nil { + return nil, err + } + return b[:n], nil + } +} +func (m *DidDocument) XXX_Merge(src proto.Message) { + xxx_messageInfo_DidDocument.Merge(m, src) +} +func (m *DidDocument) XXX_Size() int { + return m.Size() +} +func (m *DidDocument) XXX_DiscardUnknown() { + xxx_messageInfo_DidDocument.DiscardUnknown(m) +} + +var xxx_messageInfo_DidDocument proto.InternalMessageInfo + +func (m *DidDocument) GetDid() *Did { + if m != nil { + return m.Did + } + return nil +} + +func (m *DidDocument) GetMetadata() *Metadata { + if m != nil { + return m.Metadata + } + return nil +} + func init() { proto.RegisterType((*Did)(nil), "hypersignprotocol.hidnode.ssi.Did") + proto.RegisterType((*Metadata)(nil), "hypersignprotocol.hidnode.ssi.Metadata") + proto.RegisterType((*DidResolveMeta)(nil), "hypersignprotocol.hidnode.ssi.DidResolveMeta") proto.RegisterType((*VerificationMethod)(nil), "hypersignprotocol.hidnode.ssi.VerificationMethod") proto.RegisterType((*Service)(nil), "hypersignprotocol.hidnode.ssi.Service") proto.RegisterType((*SignInfo)(nil), "hypersignprotocol.hidnode.ssi.SignInfo") + proto.RegisterType((*DidDocument)(nil), "hypersignprotocol.hidnode.ssi.DidDocument") } func init() { proto.RegisterFile("ssi/v1/did.proto", fileDescriptor_cddfa22cf6c6aba3) } var fileDescriptor_cddfa22cf6c6aba3 = []byte{ - // 501 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0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xce, 0x47, 0x68, 0x94, 0x2b, 0xfd, 0xd7, 0xf3, 0x5d, 0x38, 0x2a, 0x17, 0x7f, 0x27, - 0x45, 0xa6, 0x48, 0xda, 0x72, 0x86, 0x4d, 0xb8, 0xf3, 0x19, 0xf6, 0xaf, 0x69, 0x24, 0xfb, 0xf2, - 0x56, 0xb1, 0xd7, 0xf0, 0x7c, 0x3d, 0x59, 0x37, 0x63, 0xb7, 0xef, 0xcd, 0xea, 0xb5, 0xe3, 0xed, - 0xdc, 0xf5, 0x05, 0x7b, 0x01, 0xcd, 0xc2, 0x86, 0xc8, 0xe6, 0x7a, 0x39, 0xc4, 0x03, 0xf0, 0xf6, - 0xfd, 0xcf, 0x99, 0xef, 0xdd, 0xcf, 0x7c, 0xef, 0xf7, 0xcc, 0xf7, 0xbe, 0xcf, 0xfd, 0xca, 0xfd, - 0xdc, 0xaf, 0xfc, 0x9a, 0xfb, 0x95, 0x4f, 0xbd, 0x11, 0xd9, 0x24, 0x1f, 0x06, 0xb1, 0x1a, 0x87, - 0x2b, 0x33, 0x4f, 0x97, 0x6e, 0x86, 0x09, 0x89, 0xd3, 0xc2, 0xce, 0xf0, 0x2e, 0x2c, 0x3e, 0xf1, - 0x62, 0x2d, 0x33, 0xdc, 0x73, 0xf4, 0xab, 0x3f, 0x01, 0x00, 0x00, 0xff, 0xff, 0xc2, 0x83, 0xf3, - 0xd4, 0xf6, 0x03, 0x00, 0x00, + // 613 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x8c, 0x54, 0xc1, 0x4e, 0xdb, 0x4c, + 0x10, 0xc6, 0x18, 0x48, 0x32, 0xf9, 0x05, 0xbf, 0x56, 0xe8, 0x97, 0x0f, 0x7f, 0xad, 0xc8, 0x07, + 0x9a, 0x0b, 0x8e, 0x48, 0x79, 0x80, 0xd2, 0xa6, 0x87, 0x88, 0x72, 0x31, 0x52, 0x2b, 0xf5, 0x50,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d, 0xda, 0x73, 0xe9, 0x17, 0xbf, 0x03, 0x00, 0x00, 0xff, 0xff, 0x0a, 0x3c, 0xfb, + 0x16, 0x13, 0x05, 0x00, 0x00, } func (m *Did) Marshal() (dAtA []byte, err error) { @@ -407,20 +573,6 @@ func (m *Did) MarshalToSizedBuffer(dAtA []byte) (int, error) { _ = i var l int _ = l - if len(m.Updated) > 0 { - i -= len(m.Updated) - copy(dAtA[i:], m.Updated) - i = encodeVarintDid(dAtA, i, uint64(len(m.Updated))) - i-- - dAtA[i] = 0x6a - } - if len(m.Created) > 0 { - i -= len(m.Created) - copy(dAtA[i:], m.Created) - i = encodeVarintDid(dAtA, i, uint64(len(m.Created))) - i-- - dAtA[i] = 0x62 - } if len(m.Service) > 0 { for iNdEx := len(m.Service) - 1; iNdEx >= 0; iNdEx-- { { @@ -531,6 +683,97 @@ func (m *Did) MarshalToSizedBuffer(dAtA []byte) (int, error) { return len(dAtA) - i, nil } +func (m *Metadata) Marshal() (dAtA []byte, err error) { + size := m.Size() + dAtA = make([]byte, size) + n, err := m.MarshalToSizedBuffer(dAtA[:size]) + if err != nil { + return nil, err + } + return dAtA[:n], nil +} + +func (m *Metadata) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *Metadata) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + if len(m.VersionId) > 0 { + i -= len(m.VersionId) + copy(dAtA[i:], m.VersionId) + i = encodeVarintDid(dAtA, i, uint64(len(m.VersionId))) + i-- + dAtA[i] = 0x22 + } + if m.Deactivated { + i-- + if m.Deactivated { + dAtA[i] = 1 + } else { + dAtA[i] = 0 + } + i-- + dAtA[i] = 0x18 + } + if len(m.Updated) > 0 { + i -= len(m.Updated) + copy(dAtA[i:], m.Updated) + i = encodeVarintDid(dAtA, i, uint64(len(m.Updated))) + i-- + dAtA[i] = 0x12 + } + if len(m.Created) > 0 { + i -= len(m.Created) + copy(dAtA[i:], m.Created) + i = encodeVarintDid(dAtA, i, uint64(len(m.Created))) + i-- + dAtA[i] = 0xa + } + return len(dAtA) - i, nil +} + +func (m *DidResolveMeta) Marshal() (dAtA []byte, err error) { + size := m.Size() + dAtA = make([]byte, size) + n, err := m.MarshalToSizedBuffer(dAtA[:size]) + if err != nil { + return nil, err + } + return dAtA[:n], nil +} + +func (m *DidResolveMeta) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *DidResolveMeta) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + if len(m.Error) > 0 { + i -= len(m.Error) + copy(dAtA[i:], m.Error) + i = encodeVarintDid(dAtA, i, uint64(len(m.Error))) + i-- + dAtA[i] = 0x1a + } + if len(m.Retrieved) > 0 { + i -= len(m.Retrieved) + copy(dAtA[i:], m.Retrieved) + i = encodeVarintDid(dAtA, i, uint64(len(m.Retrieved))) + i-- + dAtA[i] = 0x12 + } + return len(dAtA) - i, nil +} + func (m *VerificationMethod) Marshal() (dAtA []byte, err error) { size := m.Size() dAtA = make([]byte, size) @@ -663,6 +906,53 @@ func (m *SignInfo) MarshalToSizedBuffer(dAtA []byte) (int, error) { return len(dAtA) - i, nil } +func (m *DidDocument) Marshal() (dAtA []byte, err error) { + size := m.Size() + dAtA = make([]byte, size) + n, err := m.MarshalToSizedBuffer(dAtA[:size]) + if err != nil { + return nil, err + } + return dAtA[:n], nil +} + +func (m *DidDocument) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *DidDocument) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + if m.Metadata != nil { + { + size, err := m.Metadata.MarshalToSizedBuffer(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = encodeVarintDid(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0x12 + } + if m.Did != nil { + { + size, err := m.Did.MarshalToSizedBuffer(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = encodeVarintDid(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0xa + } + return len(dAtA) - i, nil +} + func encodeVarintDid(dAtA []byte, offset int, v uint64) int { offset -= sovDid(v) base := offset @@ -744,6 +1034,15 @@ func (m *Did) Size() (n int) { n += 1 + l + sovDid(uint64(l)) } } + return n +} + +func (m *Metadata) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l l = len(m.Created) if l > 0 { n += 1 + l + sovDid(uint64(l)) @@ -752,6 +1051,30 @@ func (m *Did) Size() (n int) { if l > 0 { n += 1 + l + sovDid(uint64(l)) } + if m.Deactivated { + n += 2 + } + l = len(m.VersionId) + if l > 0 { + n += 1 + l + sovDid(uint64(l)) + } + return n +} + +func (m *DidResolveMeta) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + l = len(m.Retrieved) + if l > 0 { + n += 1 + l + sovDid(uint64(l)) + } + l = len(m.Error) + if l > 0 { + n += 1 + l + sovDid(uint64(l)) + } return n } @@ -818,6 +1141,23 @@ func (m *SignInfo) Size() (n int) { return n } +func (m *DidDocument) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + if m.Did != nil { + l = m.Did.Size() + n += 1 + l + sovDid(uint64(l)) + } + if m.Metadata != nil { + l = m.Metadata.Size() + n += 1 + l + sovDid(uint64(l)) + } + return n +} + func sovDid(x uint64) (n int) { return (math_bits.Len64(x|1) + 6) / 7 } @@ -1209,12 +1549,62 @@ func (m *Did) Unmarshal(dAtA []byte) error { return err } iNdEx = postIndex - case 12: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field Created", wireType) + default: + iNdEx = preIndex + skippy, err := skipDid(dAtA[iNdEx:]) + if err != nil { + return err } - var stringLen uint64 - for shift := uint(0); ; shift += 7 { + if (skippy < 0) || (iNdEx+skippy) < 0 { + return ErrInvalidLengthDid + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func (m *Metadata) Unmarshal(dAtA []byte) error { + l := len(dAtA) + iNdEx := 0 + for iNdEx < l { + preIndex := iNdEx + var wire uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowDid + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + wire |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + fieldNum := int32(wire >> 3) + wireType := int(wire & 0x7) + if wireType == 4 { + return fmt.Errorf("proto: Metadata: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: Metadata: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Created", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { if shift >= 64 { return ErrIntOverflowDid } @@ -1241,7 +1631,7 @@ func (m *Did) Unmarshal(dAtA []byte) error { } m.Created = string(dAtA[iNdEx:postIndex]) iNdEx = postIndex - case 13: + case 2: if wireType != 2 { return fmt.Errorf("proto: wrong wireType = %d for field Updated", wireType) } @@ -1273,6 +1663,172 @@ func (m *Did) Unmarshal(dAtA []byte) error { } m.Updated = string(dAtA[iNdEx:postIndex]) iNdEx = postIndex + case 3: + if wireType != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field Deactivated", wireType) + } + var v int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowDid + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + v |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + m.Deactivated = bool(v != 0) + case 4: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field VersionId", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowDid + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + stringLen |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + intStringLen := int(stringLen) + if intStringLen < 0 { + return ErrInvalidLengthDid + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthDid + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.VersionId = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + default: + iNdEx = preIndex + skippy, err := skipDid(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return ErrInvalidLengthDid + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func (m *DidResolveMeta) Unmarshal(dAtA []byte) error { + l := len(dAtA) + iNdEx := 0 + for iNdEx < l { + preIndex := iNdEx + var wire uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowDid + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + wire |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + fieldNum := int32(wire >> 3) + wireType := int(wire & 0x7) + if wireType == 4 { + return fmt.Errorf("proto: DidResolveMeta: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: DidResolveMeta: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 2: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Retrieved", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowDid + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + stringLen |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + intStringLen := int(stringLen) + if intStringLen < 0 { + return ErrInvalidLengthDid + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthDid + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.Retrieved = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + case 3: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Error", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowDid + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + stringLen |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + intStringLen := int(stringLen) + if intStringLen < 0 { + return ErrInvalidLengthDid + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthDid + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.Error = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex default: iNdEx = preIndex skippy, err := skipDid(dAtA[iNdEx:]) @@ -1732,6 +2288,128 @@ func (m *SignInfo) Unmarshal(dAtA []byte) error { } return nil } +func (m *DidDocument) Unmarshal(dAtA []byte) error { + l := len(dAtA) + iNdEx := 0 + for iNdEx < l { + preIndex := iNdEx + var wire uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowDid + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + wire |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + fieldNum := int32(wire >> 3) + wireType := int(wire & 0x7) + if wireType == 4 { + return fmt.Errorf("proto: DidDocument: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: DidDocument: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Did", wireType) + } + var msglen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowDid + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + msglen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if msglen < 0 { + return ErrInvalidLengthDid + } + postIndex := iNdEx + msglen + if postIndex < 0 { + return ErrInvalidLengthDid + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + if m.Did == nil { + m.Did = &Did{} + } + if err := m.Did.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + case 2: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Metadata", wireType) + } + var msglen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowDid + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + msglen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if msglen < 0 { + return ErrInvalidLengthDid + } + postIndex := iNdEx + msglen + if postIndex < 0 { + return ErrInvalidLengthDid + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + if m.Metadata == nil { + m.Metadata = &Metadata{} + } + if err := m.Metadata.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + default: + iNdEx = preIndex + skippy, err := skipDid(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return ErrInvalidLengthDid + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} func skipDid(dAtA []byte) (n int, err error) { l := len(dAtA) iNdEx := 0 diff --git a/x/ssi/types/errors.go b/x/ssi/types/errors.go index 71ca6da..8c164b6 100644 --- a/x/ssi/types/errors.go +++ b/x/ssi/types/errors.go @@ -20,4 +20,8 @@ var ( ErrInvalidSchemaID = sdkerrors.Register(ModuleName, 110, "Invalid schema Id") ErrBadRequestInvalidVerMethod = sdkerrors.Register(ModuleName, 111, "Invalid verification method") ErrInvalidService = sdkerrors.Register(ModuleName, 112, "Invalid Service") + ErrUnexpectedDidVersion = sdkerrors.Register(ModuleName, 113, "Unexpected DID version") + ErrDidDocDeactivated = sdkerrors.Register(ModuleName, 114, "DID Document is deactivated") + ErrInvalidDidElements = sdkerrors.Register(ModuleName, 115, "Invalid DID elements") + ErrInvalidDidMethod = sdkerrors.Register(ModuleName, 116, "Invalid DID method") ) diff --git a/x/ssi/types/message_did.go b/x/ssi/types/message_did.go index 1f5a91b..6fada30 100644 --- a/x/ssi/types/message_did.go +++ b/x/ssi/types/message_did.go @@ -127,3 +127,47 @@ func (msg *MsgUpdateDID) ValidateBasic() error { } return nil } + +// MsgDeactivateDID Type Methods + +const TypeMsgDeactivateDID = "deactivate_did" + +var _ sdk.Msg = &MsgDeactivateDID{} + +func NewMsgDeactivateDID(creator string, didDocString *Did, versionId string, signatures []*SignInfo) *MsgDeactivateDID { + return &MsgDeactivateDID{ + Creator: creator, + DidDocString: didDocString, + VersionId: versionId, + Signatures: signatures, + } +} + +func (msg *MsgDeactivateDID) Route() string { + return RouterKey +} + +func (msg *MsgDeactivateDID) Type() string { + return TypeMsgDeactivateDID +} + +func (msg *MsgDeactivateDID) GetSigners() []sdk.AccAddress { + creator, err := sdk.AccAddressFromBech32(msg.Creator) + if err != nil { + panic(err) + } + return []sdk.AccAddress{creator} +} + +func (msg *MsgDeactivateDID) GetSignBytes() []byte { + bz := ModuleCdc.MustMarshalJSON(msg) + return sdk.MustSortJSON(bz) +} + +func (msg *MsgDeactivateDID) ValidateBasic() error { + _, err := sdk.AccAddressFromBech32(msg.Creator) + if err != nil { + return sdkerrors.Wrapf(sdkerrors.ErrInvalidAddress, "invalid creator address (%s)", err) + } + return nil +} diff --git a/x/ssi/types/metadata.go b/x/ssi/types/metadata.go new file mode 100644 index 0000000..51370ab --- /dev/null +++ b/x/ssi/types/metadata.go @@ -0,0 +1,18 @@ +package types + +import ( + "encoding/base64" + "time" + + sdk "github.com/cosmos/cosmos-sdk/types" + "github.com/tendermint/tendermint/crypto/tmhash" +) + +func CreateNewMetadata(ctx sdk.Context) Metadata { + return Metadata{ + VersionId: base64.StdEncoding.EncodeToString(tmhash.Sum([]byte(ctx.TxBytes()))), + Deactivated: false, + Created: ctx.BlockTime().Format(time.RFC3339), //Ref: https://www.w3.org/TR/did-core/#did-document-metadata + Updated: ctx.BlockTime().Format(time.RFC3339), + } +} diff --git a/x/ssi/types/query.pb.go b/x/ssi/types/query.pb.go index 5545b97..63a76af 100644 --- a/x/ssi/types/query.pb.go +++ b/x/ssi/types/query.pb.go @@ -378,7 +378,8 @@ func (m *QuerySchemaCountResponse) GetCount() uint64 { } type QueryGetDidDocByIdRequest struct { - DidDocId string `protobuf:"bytes,1,opt,name=didDocId,proto3" json:"didDocId,omitempty"` + DidId string `protobuf:"bytes,1,opt,name=didId,proto3" json:"didId,omitempty"` + VersionId string `protobuf:"bytes,2,opt,name=versionId,proto3" json:"versionId,omitempty"` } func (m *QueryGetDidDocByIdRequest) Reset() { *m = QueryGetDidDocByIdRequest{} } @@ -414,15 +415,25 @@ func (m *QueryGetDidDocByIdRequest) XXX_DiscardUnknown() { var xxx_messageInfo_QueryGetDidDocByIdRequest proto.InternalMessageInfo -func (m *QueryGetDidDocByIdRequest) GetDidDocId() string { +func (m *QueryGetDidDocByIdRequest) GetDidId() string { if m != nil { - return m.DidDocId + return m.DidId + } + return "" +} + +func (m *QueryGetDidDocByIdRequest) GetVersionId() string { + if m != nil { + return m.VersionId } return "" } type QueryGetDidDocByIdResponse struct { - DidDoc *Did `protobuf:"bytes,1,opt,name=didDoc,proto3" json:"didDoc,omitempty"` + XAtContext string `protobuf:"bytes,1,opt,name=_at_context,json=AtContext,proto3" json:"_at_context,omitempty"` + DidDocument *Did `protobuf:"bytes,2,opt,name=didDocument,proto3" json:"didDocument,omitempty"` + DidDocumentMetadata *Metadata `protobuf:"bytes,3,opt,name=didDocumentMetadata,proto3" json:"didDocumentMetadata,omitempty"` + DidResolutionMetadata *DidResolveMeta `protobuf:"bytes,4,opt,name=didResolutionMetadata,proto3" json:"didResolutionMetadata,omitempty"` } func (m *QueryGetDidDocByIdResponse) Reset() { *m = QueryGetDidDocByIdResponse{} } @@ -458,28 +469,51 @@ func (m *QueryGetDidDocByIdResponse) XXX_DiscardUnknown() { var xxx_messageInfo_QueryGetDidDocByIdResponse proto.InternalMessageInfo -func (m *QueryGetDidDocByIdResponse) GetDidDoc() *Did { +func (m *QueryGetDidDocByIdResponse) GetXAtContext() string { + if m != nil { + return m.XAtContext + } + return "" +} + +func (m *QueryGetDidDocByIdResponse) GetDidDocument() *Did { + if m != nil { + return m.DidDocument + } + return nil +} + +func (m *QueryGetDidDocByIdResponse) GetDidDocumentMetadata() *Metadata { + if m != nil { + return m.DidDocumentMetadata + } + return nil +} + +func (m *QueryGetDidDocByIdResponse) GetDidResolutionMetadata() *DidResolveMeta { if m != nil { - return m.DidDoc + return m.DidResolutionMetadata } return nil } -type QueryDidDocCountRequest struct { +type QueryDidParamRequest struct { + Count bool `protobuf:"varint,1,opt,name=count,proto3" json:"count,omitempty"` + Pagination *query.PageRequest `protobuf:"bytes,2,opt,name=pagination,proto3" json:"pagination,omitempty"` } -func (m *QueryDidDocCountRequest) Reset() { *m = QueryDidDocCountRequest{} } -func (m *QueryDidDocCountRequest) String() string { return proto.CompactTextString(m) } -func (*QueryDidDocCountRequest) ProtoMessage() {} -func (*QueryDidDocCountRequest) Descriptor() ([]byte, []int) { +func (m *QueryDidParamRequest) Reset() { *m = QueryDidParamRequest{} } +func (m *QueryDidParamRequest) String() string { return proto.CompactTextString(m) } +func (*QueryDidParamRequest) ProtoMessage() {} +func (*QueryDidParamRequest) Descriptor() ([]byte, []int) { return fileDescriptor_0f525f26163d85f3, []int{10} } -func (m *QueryDidDocCountRequest) XXX_Unmarshal(b []byte) error { +func (m *QueryDidParamRequest) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) } -func (m *QueryDidDocCountRequest) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { +func (m *QueryDidParamRequest) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { if deterministic { - return xxx_messageInfo_QueryDidDocCountRequest.Marshal(b, m, deterministic) + return xxx_messageInfo_QueryDidParamRequest.Marshal(b, m, deterministic) } else { b = b[:cap(b)] n, err := m.MarshalToSizedBuffer(b) @@ -489,34 +523,49 @@ func (m *QueryDidDocCountRequest) XXX_Marshal(b []byte, deterministic bool) ([]b return b[:n], nil } } -func (m *QueryDidDocCountRequest) XXX_Merge(src proto.Message) { - xxx_messageInfo_QueryDidDocCountRequest.Merge(m, src) +func (m *QueryDidParamRequest) XXX_Merge(src proto.Message) { + xxx_messageInfo_QueryDidParamRequest.Merge(m, src) } -func (m *QueryDidDocCountRequest) XXX_Size() int { +func (m *QueryDidParamRequest) XXX_Size() int { return m.Size() } -func (m *QueryDidDocCountRequest) XXX_DiscardUnknown() { - xxx_messageInfo_QueryDidDocCountRequest.DiscardUnknown(m) +func (m *QueryDidParamRequest) XXX_DiscardUnknown() { + xxx_messageInfo_QueryDidParamRequest.DiscardUnknown(m) } -var xxx_messageInfo_QueryDidDocCountRequest proto.InternalMessageInfo +var xxx_messageInfo_QueryDidParamRequest proto.InternalMessageInfo -type QueryDidDocCountResponse struct { - Count uint64 `protobuf:"varint,1,opt,name=count,proto3" json:"count,omitempty"` +func (m *QueryDidParamRequest) GetCount() bool { + if m != nil { + return m.Count + } + return false +} + +func (m *QueryDidParamRequest) GetPagination() *query.PageRequest { + if m != nil { + return m.Pagination + } + return nil +} + +type QueryDidParamResponse struct { + TotalDidCount uint64 `protobuf:"varint,1,opt,name=totalDidCount,proto3" json:"totalDidCount,omitempty"` + DidDocList []*DidResolutionResponse `protobuf:"bytes,2,rep,name=didDocList,proto3" json:"didDocList,omitempty"` } -func (m *QueryDidDocCountResponse) Reset() { *m = QueryDidDocCountResponse{} } -func (m *QueryDidDocCountResponse) String() string { return proto.CompactTextString(m) } -func (*QueryDidDocCountResponse) ProtoMessage() {} -func (*QueryDidDocCountResponse) Descriptor() ([]byte, []int) { +func (m *QueryDidParamResponse) Reset() { *m = QueryDidParamResponse{} } +func (m *QueryDidParamResponse) String() string { return proto.CompactTextString(m) } +func (*QueryDidParamResponse) ProtoMessage() {} +func (*QueryDidParamResponse) Descriptor() ([]byte, []int) { return fileDescriptor_0f525f26163d85f3, []int{11} } -func (m *QueryDidDocCountResponse) XXX_Unmarshal(b []byte) error { +func (m *QueryDidParamResponse) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) } -func (m *QueryDidDocCountResponse) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { +func (m *QueryDidParamResponse) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { if deterministic { - return xxx_messageInfo_QueryDidDocCountResponse.Marshal(b, m, deterministic) + return xxx_messageInfo_QueryDidParamResponse.Marshal(b, m, deterministic) } else { b = b[:cap(b)] n, err := m.MarshalToSizedBuffer(b) @@ -526,25 +575,100 @@ func (m *QueryDidDocCountResponse) XXX_Marshal(b []byte, deterministic bool) ([] return b[:n], nil } } -func (m *QueryDidDocCountResponse) XXX_Merge(src proto.Message) { - xxx_messageInfo_QueryDidDocCountResponse.Merge(m, src) +func (m *QueryDidParamResponse) XXX_Merge(src proto.Message) { + xxx_messageInfo_QueryDidParamResponse.Merge(m, src) } -func (m *QueryDidDocCountResponse) XXX_Size() int { +func (m *QueryDidParamResponse) XXX_Size() int { return m.Size() } -func (m *QueryDidDocCountResponse) XXX_DiscardUnknown() { - xxx_messageInfo_QueryDidDocCountResponse.DiscardUnknown(m) +func (m *QueryDidParamResponse) XXX_DiscardUnknown() { + xxx_messageInfo_QueryDidParamResponse.DiscardUnknown(m) } -var xxx_messageInfo_QueryDidDocCountResponse proto.InternalMessageInfo +var xxx_messageInfo_QueryDidParamResponse proto.InternalMessageInfo -func (m *QueryDidDocCountResponse) GetCount() uint64 { +func (m *QueryDidParamResponse) GetTotalDidCount() uint64 { if m != nil { - return m.Count + return m.TotalDidCount } return 0 } +func (m *QueryDidParamResponse) GetDidDocList() []*DidResolutionResponse { + if m != nil { + return m.DidDocList + } + return nil +} + +type DidResolutionResponse struct { + XAtContext string `protobuf:"bytes,1,opt,name=_at_context,json=AtContext,proto3" json:"_at_context,omitempty"` + DidDocument *Did `protobuf:"bytes,2,opt,name=didDocument,proto3" json:"didDocument,omitempty"` + DidDocumentMetadata *Metadata `protobuf:"bytes,3,opt,name=didDocumentMetadata,proto3" json:"didDocumentMetadata,omitempty"` + DidResolutionMetadata *DidResolveMeta `protobuf:"bytes,4,opt,name=didResolutionMetadata,proto3" json:"didResolutionMetadata,omitempty"` +} + +func (m *DidResolutionResponse) Reset() { *m = DidResolutionResponse{} } +func (m *DidResolutionResponse) String() string { return proto.CompactTextString(m) } +func (*DidResolutionResponse) ProtoMessage() {} +func (*DidResolutionResponse) Descriptor() ([]byte, []int) { + return fileDescriptor_0f525f26163d85f3, []int{12} +} +func (m *DidResolutionResponse) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *DidResolutionResponse) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_DidResolutionResponse.Marshal(b, m, deterministic) + } else { + b = b[:cap(b)] + n, err := m.MarshalToSizedBuffer(b) + if err != nil { + return nil, err + } + return b[:n], nil + } +} +func (m *DidResolutionResponse) XXX_Merge(src proto.Message) { + xxx_messageInfo_DidResolutionResponse.Merge(m, src) +} +func (m *DidResolutionResponse) XXX_Size() int { + return m.Size() +} +func (m *DidResolutionResponse) XXX_DiscardUnknown() { + xxx_messageInfo_DidResolutionResponse.DiscardUnknown(m) +} + +var xxx_messageInfo_DidResolutionResponse proto.InternalMessageInfo + +func (m *DidResolutionResponse) GetXAtContext() string { + if m != nil { + return m.XAtContext + } + return "" +} + +func (m *DidResolutionResponse) GetDidDocument() *Did { + if m != nil { + return m.DidDocument + } + return nil +} + +func (m *DidResolutionResponse) GetDidDocumentMetadata() *Metadata { + if m != nil { + return m.DidDocumentMetadata + } + return nil +} + +func (m *DidResolutionResponse) GetDidResolutionMetadata() *DidResolveMeta { + if m != nil { + return m.DidResolutionMetadata + } + return nil +} + func init() { proto.RegisterType((*QueryParamsRequest)(nil), "hypersignprotocol.hidnode.ssi.QueryParamsRequest") proto.RegisterType((*QueryParamsResponse)(nil), "hypersignprotocol.hidnode.ssi.QueryParamsResponse") @@ -556,60 +680,71 @@ func init() { proto.RegisterType((*QuerySchemaCountResponse)(nil), "hypersignprotocol.hidnode.ssi.QuerySchemaCountResponse") proto.RegisterType((*QueryGetDidDocByIdRequest)(nil), "hypersignprotocol.hidnode.ssi.QueryGetDidDocByIdRequest") proto.RegisterType((*QueryGetDidDocByIdResponse)(nil), "hypersignprotocol.hidnode.ssi.QueryGetDidDocByIdResponse") - proto.RegisterType((*QueryDidDocCountRequest)(nil), "hypersignprotocol.hidnode.ssi.QueryDidDocCountRequest") - proto.RegisterType((*QueryDidDocCountResponse)(nil), "hypersignprotocol.hidnode.ssi.QueryDidDocCountResponse") + proto.RegisterType((*QueryDidParamRequest)(nil), "hypersignprotocol.hidnode.ssi.QueryDidParamRequest") + proto.RegisterType((*QueryDidParamResponse)(nil), "hypersignprotocol.hidnode.ssi.QueryDidParamResponse") + proto.RegisterType((*DidResolutionResponse)(nil), "hypersignprotocol.hidnode.ssi.DidResolutionResponse") } func init() { proto.RegisterFile("ssi/v1/query.proto", fileDescriptor_0f525f26163d85f3) } var fileDescriptor_0f525f26163d85f3 = []byte{ - // 721 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x9c, 0x94, 0xcf, 0x4f, 0x13, 0x41, - 0x14, 0xc7, 0xbb, 0x08, 0x15, 0x1e, 0x31, 0x9a, 0xa1, 0x2a, 0x6c, 0xb4, 0x92, 0x4d, 0x10, 0x7f, - 0xb1, 0x43, 0x0b, 0x82, 0x9a, 0x68, 0x14, 0x10, 0x42, 0xc2, 0x01, 0xeb, 0x41, 0x43, 0xe2, 0x61, - 0xdb, 0x9d, 0x6c, 0x27, 0xa1, 0x3b, 0x4b, 0x67, 0x4b, 0x68, 0x08, 0x17, 0xff, 0x02, 0x13, 0xef, - 0x1e, 0x3d, 0x78, 0x33, 0xf1, 0x3f, 0xf0, 0xc2, 0xc1, 0x03, 0x89, 0x31, 0xf1, 0x64, 0x0c, 0xf8, - 0x87, 0x98, 0xce, 0xbc, 0xd2, 0xdd, 0xb6, 0xd2, 0xad, 0xb7, 0xdd, 0x37, 0xf3, 0x7d, 0xef, 0xf3, - 0x7e, 0x0d, 0x10, 0x29, 0x39, 0xdd, 0xcd, 0xd1, 0x9d, 0x1a, 0xab, 0xd6, 0xed, 0xa0, 0x2a, 0x42, - 0x41, 0xae, 0x97, 0xeb, 0x01, 0xab, 0x4a, 0xee, 0xf9, 0xea, 0xbf, 0x24, 0xb6, 0xed, 0x32, 0x77, - 0x7d, 0xe1, 0x32, 0x5b, 0x4a, 0x6e, 0x66, 0x3c, 0xe1, 0x09, 0x75, 0x42, 0x1b, 0x5f, 0x5a, 0x64, - 0x5e, 0xf3, 0x84, 0xf0, 0xb6, 0x19, 0x75, 0x02, 0x4e, 0x1d, 0xdf, 0x17, 0xa1, 0x13, 0x72, 0xe1, - 0x4b, 0x3c, 0xbd, 0x53, 0x12, 0xb2, 0x22, 0x24, 0x2d, 0x3a, 0x92, 0xe9, 0x58, 0x74, 0x37, 0x57, - 0x64, 0xa1, 0x93, 0xa3, 0x81, 0xe3, 0x71, 0x5f, 0x5d, 0xc6, 0xbb, 0x63, 0x88, 0x14, 0x38, 0x55, - 0xa7, 0x22, 0xdb, 0x8c, 0xb2, 0x54, 0x66, 0x15, 0x07, 0x8d, 0x97, 0xd0, 0xe8, 0x72, 0x17, 0x2d, - 0x17, 0xd1, 0x12, 0xee, 0x69, 0x83, 0x95, 0x01, 0xf2, 0xa2, 0x11, 0x6e, 0x53, 0x39, 0x2b, 0xb0, - 0x9d, 0x1a, 0x93, 0xa1, 0xb5, 0x05, 0x63, 0x31, 0xab, 0x0c, 0x84, 0x2f, 0x19, 0x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xc7, 0xcd, 0x87, 0xff, 0xa1, - 0x44, 0xf8, 0x55, 0x05, 0xff, 0x94, 0x3c, 0xe9, 0x05, 0xef, 0x72, 0x57, 0x8f, 0x4c, 0xcb, 0x09, - 0xdd, 0x6f, 0xbe, 0x24, 0x07, 0xe4, 0xb3, 0x01, 0xa3, 0x91, 0x8d, 0x4e, 0xd6, 0x85, 0xce, 0xd7, - 0x21, 0x59, 0x17, 0xba, 0x3c, 0x1d, 0x56, 0x4e, 0x25, 0x72, 0x97, 0xdc, 0x4e, 0x92, 0x88, 0x6a, - 0xc1, 0xd2, 0xc6, 0xe1, 0x71, 0xd6, 0x38, 0x3a, 0xce, 0x1a, 0xbf, 0x8f, 0xb3, 0xc6, 0xbb, 0x93, - 0x6c, 0xea, 0xe8, 0x24, 0x9b, 0xfa, 0x79, 0x92, 0x4d, 0x6d, 0xe5, 0x3d, 0x1e, 0x96, 0x6b, 0x45, - 0xbb, 0x24, 0x2a, 0xff, 0x70, 0x37, 0xa3, 0xfc, 0xed, 0x29, 0x8f, 0x61, 0x3d, 0x60, 0xb2, 0x98, - 0x56, 0xc7, 0x73, 0x7f, 0x03, 0x00, 0x00, 0xff, 0xff, 0xbc, 0x5d, 0x06, 0x1a, 0xc3, 0x08, 0x00, - 0x00, + // 883 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xec, 0x95, 0xbf, 0x8f, 0x1b, 0x45, + 0x14, 0xc7, 0x6f, 0x9d, 0xbb, 0xe3, 0xfc, 0x2c, 0x04, 0x9a, 0xf3, 0x81, 0xb3, 0x0a, 0x26, 0x5a, + 0x38, 0x82, 0x08, 0xde, 0x8d, 0x7f, 0x10, 0xa0, 0xa0, 0xc8, 0xd9, 0x10, 0x59, 0x0a, 0x22, 0x2c, + 0x48, 0x88, 0x48, 0x28, 0x5a, 0xef, 0x8c, 0xd6, 0x23, 0xd9, 0x3b, 0x8e, 0x67, 0x6c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xba, 0x77, 0x3e, 0x22, 0x3f, 0x58, 0x70, 0x30, 0x7d, 0x5e, 0x49, + 0xa6, 0x4a, 0x2f, 0xf5, 0x00, 0xbb, 0xb1, 0x9d, 0x08, 0x61, 0xaf, 0x6b, 0xd8, 0x63, 0xf2, 0x46, + 0x06, 0xd8, 0x93, 0x3b, 0x4f, 0xce, 0xca, 0xd6, 0xd3, 0xb3, 0xb2, 0xf5, 0xcf, 0x59, 0xd9, 0xfa, + 0xee, 0xbc, 0xbc, 0xf3, 0xf4, 0xbc, 0xbc, 0xf3, 0xd7, 0x79, 0x79, 0xe7, 0x5e, 0x2d, 0xe2, 0xaa, + 0x3b, 0xea, 0xb8, 0xa1, 0xe8, 0xff, 0x8f, 0x51, 0x45, 0x3b, 0x9d, 0x6a, 0x2f, 0x35, 0x19, 0x30, + 0xd9, 0xd9, 0xd7, 0xbf, 0xeb, 0xff, 0x05, 0x00, 0x00, 0xff, 0xff, 0xd3, 0xb7, 0x92, 0x31, 0xa0, + 0x0b, 0x00, 0x00, } // Reference imports to suppress errors if they are not otherwise used. @@ -632,10 +767,10 @@ type QueryClient interface { Schemas(ctx context.Context, in *QuerySchemasRequest, opts ...grpc.CallOption) (*QuerySchemasResponse, error) // Queries a list of SchemaCount items. SchemaCount(ctx context.Context, in *QuerySchemaCountRequest, opts ...grpc.CallOption) (*QuerySchemaCountResponse, error) - // Queries a list of GetDidDocById items. - GetDidDocById(ctx context.Context, in *QueryGetDidDocByIdRequest, opts ...grpc.CallOption) (*QueryGetDidDocByIdResponse, error) - // Queries a list of DidDocCount items. - DidDocCount(ctx context.Context, in *QueryDidDocCountRequest, opts ...grpc.CallOption) (*QueryDidDocCountResponse, error) + // Resolve DID + ResolveDid(ctx context.Context, in *QueryGetDidDocByIdRequest, opts ...grpc.CallOption) (*QueryGetDidDocByIdResponse, error) + // Did Param + DidParam(ctx context.Context, in *QueryDidParamRequest, opts ...grpc.CallOption) (*QueryDidParamResponse, error) } type queryClient struct { @@ -682,18 +817,18 @@ func (c *queryClient) SchemaCount(ctx context.Context, in *QuerySchemaCountReque return out, nil } -func (c *queryClient) GetDidDocById(ctx context.Context, in *QueryGetDidDocByIdRequest, opts ...grpc.CallOption) (*QueryGetDidDocByIdResponse, error) { +func (c *queryClient) ResolveDid(ctx context.Context, in *QueryGetDidDocByIdRequest, opts ...grpc.CallOption) (*QueryGetDidDocByIdResponse, error) { out := new(QueryGetDidDocByIdResponse) - err := c.cc.Invoke(ctx, "/hypersignprotocol.hidnode.ssi.Query/GetDidDocById", in, out, opts...) + err := c.cc.Invoke(ctx, "/hypersignprotocol.hidnode.ssi.Query/ResolveDid", in, out, opts...) if err != nil { return nil, err } return out, nil } -func (c *queryClient) DidDocCount(ctx context.Context, in *QueryDidDocCountRequest, opts ...grpc.CallOption) (*QueryDidDocCountResponse, error) { - out := new(QueryDidDocCountResponse) - err := c.cc.Invoke(ctx, "/hypersignprotocol.hidnode.ssi.Query/DidDocCount", in, out, opts...) +func (c *queryClient) DidParam(ctx context.Context, in *QueryDidParamRequest, opts ...grpc.CallOption) (*QueryDidParamResponse, error) { + out := new(QueryDidParamResponse) + err := c.cc.Invoke(ctx, "/hypersignprotocol.hidnode.ssi.Query/DidParam", in, out, opts...) if err != nil { return nil, err } @@ -710,10 +845,10 @@ type QueryServer interface { Schemas(context.Context, *QuerySchemasRequest) (*QuerySchemasResponse, error) // Queries a list of SchemaCount items. SchemaCount(context.Context, *QuerySchemaCountRequest) (*QuerySchemaCountResponse, error) - // Queries a list of GetDidDocById items. - GetDidDocById(context.Context, *QueryGetDidDocByIdRequest) (*QueryGetDidDocByIdResponse, error) - // Queries a list of DidDocCount items. - DidDocCount(context.Context, *QueryDidDocCountRequest) (*QueryDidDocCountResponse, error) + // Resolve DID + ResolveDid(context.Context, *QueryGetDidDocByIdRequest) (*QueryGetDidDocByIdResponse, error) + // Did Param + DidParam(context.Context, *QueryDidParamRequest) (*QueryDidParamResponse, error) } // UnimplementedQueryServer can be embedded to have forward compatible implementations. @@ -732,11 +867,11 @@ func (*UnimplementedQueryServer) Schemas(ctx context.Context, req *QuerySchemasR func (*UnimplementedQueryServer) SchemaCount(ctx context.Context, req *QuerySchemaCountRequest) (*QuerySchemaCountResponse, error) { return nil, status.Errorf(codes.Unimplemented, "method SchemaCount not implemented") } -func (*UnimplementedQueryServer) GetDidDocById(ctx context.Context, req *QueryGetDidDocByIdRequest) (*QueryGetDidDocByIdResponse, error) { - return nil, status.Errorf(codes.Unimplemented, "method GetDidDocById not implemented") +func (*UnimplementedQueryServer) ResolveDid(ctx context.Context, req *QueryGetDidDocByIdRequest) (*QueryGetDidDocByIdResponse, error) { + return nil, status.Errorf(codes.Unimplemented, "method ResolveDid not implemented") } -func (*UnimplementedQueryServer) DidDocCount(ctx context.Context, req *QueryDidDocCountRequest) (*QueryDidDocCountResponse, error) { - return nil, status.Errorf(codes.Unimplemented, "method DidDocCount not implemented") +func (*UnimplementedQueryServer) DidParam(ctx context.Context, req *QueryDidParamRequest) (*QueryDidParamResponse, error) { + return nil, status.Errorf(codes.Unimplemented, "method DidParam not implemented") } func RegisterQueryServer(s grpc1.Server, srv QueryServer) { @@ -815,38 +950,38 @@ func _Query_SchemaCount_Handler(srv interface{}, ctx context.Context, dec func(i return interceptor(ctx, in, info, handler) } -func _Query_GetDidDocById_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { +func _Query_ResolveDid_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { in := new(QueryGetDidDocByIdRequest) if err := dec(in); err != nil { return nil, err } if interceptor == nil { - return srv.(QueryServer).GetDidDocById(ctx, in) + return srv.(QueryServer).ResolveDid(ctx, in) } info := &grpc.UnaryServerInfo{ Server: srv, - FullMethod: "/hypersignprotocol.hidnode.ssi.Query/GetDidDocById", + FullMethod: "/hypersignprotocol.hidnode.ssi.Query/ResolveDid", } handler := func(ctx context.Context, req interface{}) (interface{}, error) { - return srv.(QueryServer).GetDidDocById(ctx, req.(*QueryGetDidDocByIdRequest)) + return srv.(QueryServer).ResolveDid(ctx, req.(*QueryGetDidDocByIdRequest)) } return interceptor(ctx, in, info, handler) } -func _Query_DidDocCount_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { - in := new(QueryDidDocCountRequest) +func _Query_DidParam_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { + in := new(QueryDidParamRequest) if err := dec(in); err != nil { return nil, err } if interceptor == nil { - return srv.(QueryServer).DidDocCount(ctx, in) + return srv.(QueryServer).DidParam(ctx, in) } info := &grpc.UnaryServerInfo{ Server: srv, - FullMethod: "/hypersignprotocol.hidnode.ssi.Query/DidDocCount", + FullMethod: "/hypersignprotocol.hidnode.ssi.Query/DidParam", } handler := func(ctx context.Context, req interface{}) (interface{}, error) { - return srv.(QueryServer).DidDocCount(ctx, req.(*QueryDidDocCountRequest)) + return srv.(QueryServer).DidParam(ctx, req.(*QueryDidParamRequest)) } return interceptor(ctx, in, info, handler) } @@ -872,12 +1007,12 @@ var _Query_serviceDesc = grpc.ServiceDesc{ Handler: _Query_SchemaCount_Handler, }, { - MethodName: "GetDidDocById", - Handler: _Query_GetDidDocById_Handler, + MethodName: "ResolveDid", + Handler: _Query_ResolveDid_Handler, }, { - MethodName: "DidDocCount", - Handler: _Query_DidDocCount_Handler, + MethodName: "DidParam", + Handler: _Query_DidParam_Handler, }, }, Streams: []grpc.StreamDesc{}, @@ -1160,10 +1295,17 @@ func (m *QueryGetDidDocByIdRequest) MarshalToSizedBuffer(dAtA []byte) (int, erro _ = i var l int _ = l - if len(m.DidDocId) > 0 { - i -= len(m.DidDocId) - copy(dAtA[i:], m.DidDocId) - i = encodeVarintQuery(dAtA, i, uint64(len(m.DidDocId))) + if len(m.VersionId) > 0 { + i -= len(m.VersionId) + copy(dAtA[i:], m.VersionId) + i = encodeVarintQuery(dAtA, i, uint64(len(m.VersionId))) + i-- + dAtA[i] = 0x12 + } + if len(m.DidId) > 0 { + i -= len(m.DidId) + copy(dAtA[i:], m.DidId) + i = encodeVarintQuery(dAtA, i, uint64(len(m.DidId))) i-- dAtA[i] = 0xa } @@ -1190,9 +1332,33 @@ func (m *QueryGetDidDocByIdResponse) MarshalToSizedBuffer(dAtA []byte) (int, err _ = i var l int _ = l - if m.DidDoc != nil { + if m.DidResolutionMetadata != nil { + { + size, err := m.DidResolutionMetadata.MarshalToSizedBuffer(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = encodeVarintQuery(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0x22 + } + if m.DidDocumentMetadata != nil { + { + size, err := m.DidDocumentMetadata.MarshalToSizedBuffer(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = encodeVarintQuery(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0x1a + } + if m.DidDocument != nil { { - size, err := m.DidDoc.MarshalToSizedBuffer(dAtA[:i]) + size, err := m.DidDocument.MarshalToSizedBuffer(dAtA[:i]) if err != nil { return 0, err } @@ -1200,12 +1366,19 @@ func (m *QueryGetDidDocByIdResponse) MarshalToSizedBuffer(dAtA []byte) (int, err i = encodeVarintQuery(dAtA, i, uint64(size)) } i-- + dAtA[i] = 0x12 + } + if len(m.XAtContext) > 0 { + i -= len(m.XAtContext) + copy(dAtA[i:], m.XAtContext) + i = encodeVarintQuery(dAtA, i, uint64(len(m.XAtContext))) + i-- dAtA[i] = 0xa } return len(dAtA) - i, nil } -func (m *QueryDidDocCountRequest) Marshal() (dAtA []byte, err error) { +func (m *QueryDidParamRequest) Marshal() (dAtA []byte, err error) { size := m.Size() dAtA = make([]byte, size) n, err := m.MarshalToSizedBuffer(dAtA[:size]) @@ -1215,20 +1388,42 @@ func (m *QueryDidDocCountRequest) Marshal() (dAtA []byte, err error) { return dAtA[:n], nil } -func (m *QueryDidDocCountRequest) MarshalTo(dAtA []byte) (int, error) { +func (m *QueryDidParamRequest) MarshalTo(dAtA []byte) (int, error) { size := m.Size() return m.MarshalToSizedBuffer(dAtA[:size]) } -func (m *QueryDidDocCountRequest) MarshalToSizedBuffer(dAtA []byte) (int, error) { +func (m *QueryDidParamRequest) MarshalToSizedBuffer(dAtA []byte) (int, error) { i := len(dAtA) _ = i var l int _ = l + if m.Pagination != nil { + { + size, err := m.Pagination.MarshalToSizedBuffer(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = encodeVarintQuery(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0x12 + } + if m.Count { + i-- + if m.Count { + dAtA[i] = 1 + } else { + dAtA[i] = 0 + } + i-- + dAtA[i] = 0x8 + } return len(dAtA) - i, nil } -func (m *QueryDidDocCountResponse) Marshal() (dAtA []byte, err error) { +func (m *QueryDidParamResponse) Marshal() (dAtA []byte, err error) { size := m.Size() dAtA = make([]byte, size) n, err := m.MarshalToSizedBuffer(dAtA[:size]) @@ -1238,24 +1433,104 @@ func (m *QueryDidDocCountResponse) Marshal() (dAtA []byte, err error) { return dAtA[:n], nil } -func (m *QueryDidDocCountResponse) MarshalTo(dAtA []byte) (int, error) { +func (m *QueryDidParamResponse) MarshalTo(dAtA []byte) (int, error) { size := m.Size() return m.MarshalToSizedBuffer(dAtA[:size]) } -func (m *QueryDidDocCountResponse) MarshalToSizedBuffer(dAtA []byte) (int, error) { +func (m *QueryDidParamResponse) MarshalToSizedBuffer(dAtA []byte) (int, error) { i := len(dAtA) _ = i var l int _ = l - if m.Count != 0 { - i = encodeVarintQuery(dAtA, i, uint64(m.Count)) + if len(m.DidDocList) > 0 { + for iNdEx := len(m.DidDocList) - 1; iNdEx >= 0; iNdEx-- { + { + size, err := m.DidDocList[iNdEx].MarshalToSizedBuffer(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = encodeVarintQuery(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0x12 + } + } + if m.TotalDidCount != 0 { + i = encodeVarintQuery(dAtA, i, uint64(m.TotalDidCount)) i-- dAtA[i] = 0x8 } return len(dAtA) - i, nil } +func (m *DidResolutionResponse) Marshal() (dAtA []byte, err error) { + size := m.Size() + dAtA = make([]byte, size) + n, err := m.MarshalToSizedBuffer(dAtA[:size]) + if err != nil { + return nil, err + } + return dAtA[:n], nil +} + +func (m *DidResolutionResponse) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *DidResolutionResponse) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + if m.DidResolutionMetadata != nil { + { + size, err := m.DidResolutionMetadata.MarshalToSizedBuffer(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = encodeVarintQuery(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0x22 + } + if m.DidDocumentMetadata != nil { + { + size, err := m.DidDocumentMetadata.MarshalToSizedBuffer(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = encodeVarintQuery(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0x1a + } + if m.DidDocument != nil { + { + size, err := m.DidDocument.MarshalToSizedBuffer(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = encodeVarintQuery(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0x12 + } + if len(m.XAtContext) > 0 { + i -= len(m.XAtContext) + copy(dAtA[i:], m.XAtContext) + i = encodeVarintQuery(dAtA, i, uint64(len(m.XAtContext))) + i-- + dAtA[i] = 0xa + } + return len(dAtA) - i, nil +} + func encodeVarintQuery(dAtA []byte, offset int, v uint64) int { offset -= sovQuery(v) base := offset @@ -1372,7 +1647,11 @@ func (m *QueryGetDidDocByIdRequest) Size() (n int) { } var l int _ = l - l = len(m.DidDocId) + l = len(m.DidId) + if l > 0 { + n += 1 + l + sovQuery(uint64(l)) + } + l = len(m.VersionId) if l > 0 { n += 1 + l + sovQuery(uint64(l)) } @@ -1385,30 +1664,80 @@ func (m *QueryGetDidDocByIdResponse) Size() (n int) { } var l int _ = l - if m.DidDoc != nil { - l = m.DidDoc.Size() + l = len(m.XAtContext) + if l > 0 { + n += 1 + l + sovQuery(uint64(l)) + } + if m.DidDocument != nil { + l = m.DidDocument.Size() + n += 1 + l + sovQuery(uint64(l)) + } + if m.DidDocumentMetadata != nil { + l = m.DidDocumentMetadata.Size() + n += 1 + l + sovQuery(uint64(l)) + } + if m.DidResolutionMetadata != nil { + l = m.DidResolutionMetadata.Size() + n += 1 + l + sovQuery(uint64(l)) + } + return n +} + +func (m *QueryDidParamRequest) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + if m.Count { + n += 2 + } + if m.Pagination != nil { + l = m.Pagination.Size() n += 1 + l + sovQuery(uint64(l)) } return n } -func (m *QueryDidDocCountRequest) Size() (n int) { +func (m *QueryDidParamResponse) Size() (n int) { if m == nil { return 0 } var l int _ = l + if m.TotalDidCount != 0 { + n += 1 + sovQuery(uint64(m.TotalDidCount)) + } + if len(m.DidDocList) > 0 { + for _, e := range m.DidDocList { + l = e.Size() + n += 1 + l + sovQuery(uint64(l)) + } + } return n } -func (m *QueryDidDocCountResponse) Size() (n int) { +func (m *DidResolutionResponse) Size() (n int) { if m == nil { return 0 } var l int _ = l - if m.Count != 0 { - n += 1 + sovQuery(uint64(m.Count)) + l = len(m.XAtContext) + if l > 0 { + n += 1 + l + sovQuery(uint64(l)) + } + if m.DidDocument != nil { + l = m.DidDocument.Size() + n += 1 + l + sovQuery(uint64(l)) + } + if m.DidDocumentMetadata != nil { + l = m.DidDocumentMetadata.Size() + n += 1 + l + sovQuery(uint64(l)) + } + if m.DidResolutionMetadata != nil { + l = m.DidResolutionMetadata.Size() + n += 1 + l + sovQuery(uint64(l)) } return n } @@ -2076,7 +2405,39 @@ func (m *QueryGetDidDocByIdRequest) Unmarshal(dAtA []byte) error { switch fieldNum { case 1: if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field DidDocId", wireType) + return fmt.Errorf("proto: wrong wireType = %d for field DidId", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowQuery + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + stringLen |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + intStringLen := int(stringLen) + if intStringLen < 0 { + return ErrInvalidLengthQuery + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthQuery + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.DidId = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + case 2: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field VersionId", wireType) } var stringLen uint64 for shift := uint(0); ; shift += 7 { @@ -2104,7 +2465,7 @@ func (m *QueryGetDidDocByIdRequest) Unmarshal(dAtA []byte) error { if postIndex > l { return io.ErrUnexpectedEOF } - m.DidDocId = string(dAtA[iNdEx:postIndex]) + m.VersionId = string(dAtA[iNdEx:postIndex]) iNdEx = postIndex default: iNdEx = preIndex @@ -2158,9 +2519,9 @@ func (m *QueryGetDidDocByIdResponse) Unmarshal(dAtA []byte) error { switch fieldNum { case 1: if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field DidDoc", wireType) + return fmt.Errorf("proto: wrong wireType = %d for field XAtContext", wireType) } - var msglen int + var stringLen uint64 for shift := uint(0); ; shift += 7 { if shift >= 64 { return ErrIntOverflowQuery @@ -2170,12 +2531,116 @@ func (m *QueryGetDidDocByIdResponse) Unmarshal(dAtA []byte) error { } b := dAtA[iNdEx] iNdEx++ - msglen |= int(b&0x7F) << shift + stringLen |= uint64(b&0x7F) << shift if b < 0x80 { break } } - if msglen < 0 { + intStringLen := int(stringLen) + if intStringLen < 0 { + return ErrInvalidLengthQuery + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthQuery + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.XAtContext = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + case 2: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field DidDocument", wireType) + } + var msglen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowQuery + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + msglen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if msglen < 0 { + return ErrInvalidLengthQuery + } + postIndex := iNdEx + msglen + if postIndex < 0 { + return ErrInvalidLengthQuery + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + if m.DidDocument == nil { + m.DidDocument = &Did{} + } + if err := m.DidDocument.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + case 3: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field DidDocumentMetadata", wireType) + } + var msglen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowQuery + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + msglen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if msglen < 0 { + return ErrInvalidLengthQuery + } + postIndex := iNdEx + msglen + if postIndex < 0 { + return ErrInvalidLengthQuery + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + if m.DidDocumentMetadata == nil { + m.DidDocumentMetadata = &Metadata{} + } + if err := m.DidDocumentMetadata.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + case 4: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field DidResolutionMetadata", wireType) + } + var msglen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowQuery + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + msglen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if msglen < 0 { return ErrInvalidLengthQuery } postIndex := iNdEx + msglen @@ -2185,10 +2650,10 @@ func (m *QueryGetDidDocByIdResponse) Unmarshal(dAtA []byte) error { if postIndex > l { return io.ErrUnexpectedEOF } - if m.DidDoc == nil { - m.DidDoc = &Did{} + if m.DidResolutionMetadata == nil { + m.DidResolutionMetadata = &DidResolveMeta{} } - if err := m.DidDoc.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + if err := m.DidResolutionMetadata.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { return err } iNdEx = postIndex @@ -2213,7 +2678,7 @@ func (m *QueryGetDidDocByIdResponse) Unmarshal(dAtA []byte) error { } return nil } -func (m *QueryDidDocCountRequest) Unmarshal(dAtA []byte) error { +func (m *QueryDidParamRequest) Unmarshal(dAtA []byte) error { l := len(dAtA) iNdEx := 0 for iNdEx < l { @@ -2236,12 +2701,68 @@ func (m *QueryDidDocCountRequest) Unmarshal(dAtA []byte) error { fieldNum := int32(wire >> 3) wireType := int(wire & 0x7) if wireType == 4 { - return fmt.Errorf("proto: QueryDidDocCountRequest: wiretype end group for non-group") + return fmt.Errorf("proto: QueryDidParamRequest: wiretype end group for non-group") } if fieldNum <= 0 { - return fmt.Errorf("proto: QueryDidDocCountRequest: illegal tag %d (wire type %d)", fieldNum, wire) + return fmt.Errorf("proto: QueryDidParamRequest: illegal tag %d (wire type %d)", fieldNum, wire) } switch fieldNum { + case 1: + if wireType != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field Count", wireType) + } + var v int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowQuery + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + v |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + m.Count = bool(v != 0) + case 2: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Pagination", wireType) + } + var msglen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowQuery + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + msglen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if msglen < 0 { + return ErrInvalidLengthQuery + } + postIndex := iNdEx + msglen + if postIndex < 0 { + return ErrInvalidLengthQuery + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + if m.Pagination == nil { + m.Pagination = &query.PageRequest{} + } + if err := m.Pagination.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex default: iNdEx = preIndex skippy, err := skipQuery(dAtA[iNdEx:]) @@ -2263,7 +2784,7 @@ func (m *QueryDidDocCountRequest) Unmarshal(dAtA []byte) error { } return nil } -func (m *QueryDidDocCountResponse) Unmarshal(dAtA []byte) error { +func (m *QueryDidParamResponse) Unmarshal(dAtA []byte) error { l := len(dAtA) iNdEx := 0 for iNdEx < l { @@ -2286,17 +2807,17 @@ func (m *QueryDidDocCountResponse) Unmarshal(dAtA []byte) error { fieldNum := int32(wire >> 3) wireType := int(wire & 0x7) if wireType == 4 { - return fmt.Errorf("proto: QueryDidDocCountResponse: wiretype end group for non-group") + return fmt.Errorf("proto: QueryDidParamResponse: wiretype end group for non-group") } if fieldNum <= 0 { - return fmt.Errorf("proto: QueryDidDocCountResponse: illegal tag %d (wire type %d)", fieldNum, wire) + return fmt.Errorf("proto: QueryDidParamResponse: illegal tag %d (wire type %d)", fieldNum, wire) } switch fieldNum { case 1: if wireType != 0 { - return fmt.Errorf("proto: wrong wireType = %d for field Count", wireType) + return fmt.Errorf("proto: wrong wireType = %d for field TotalDidCount", wireType) } - m.Count = 0 + m.TotalDidCount = 0 for shift := uint(0); ; shift += 7 { if shift >= 64 { return ErrIntOverflowQuery @@ -2306,11 +2827,235 @@ func (m *QueryDidDocCountResponse) Unmarshal(dAtA []byte) error { } b := dAtA[iNdEx] iNdEx++ - m.Count |= uint64(b&0x7F) << shift + m.TotalDidCount |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + case 2: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field DidDocList", wireType) + } + var msglen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowQuery + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + msglen |= int(b&0x7F) << shift if b < 0x80 { break } } + if msglen < 0 { + return ErrInvalidLengthQuery + } + postIndex := iNdEx + msglen + if postIndex < 0 { + return ErrInvalidLengthQuery + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.DidDocList = append(m.DidDocList, &DidResolutionResponse{}) + if err := m.DidDocList[len(m.DidDocList)-1].Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + default: + iNdEx = preIndex + skippy, err := skipQuery(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return ErrInvalidLengthQuery + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func (m *DidResolutionResponse) Unmarshal(dAtA []byte) error { + l := len(dAtA) + iNdEx := 0 + for iNdEx < l { + preIndex := iNdEx + var wire uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowQuery + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + wire |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + fieldNum := int32(wire >> 3) + wireType := int(wire & 0x7) + if wireType == 4 { + return fmt.Errorf("proto: DidResolutionResponse: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: DidResolutionResponse: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field XAtContext", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowQuery + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + stringLen |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + intStringLen := int(stringLen) + if intStringLen < 0 { + return ErrInvalidLengthQuery + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthQuery + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.XAtContext = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + case 2: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field DidDocument", wireType) + } + var msglen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowQuery + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + msglen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if msglen < 0 { + return ErrInvalidLengthQuery + } + postIndex := iNdEx + msglen + if postIndex < 0 { + return ErrInvalidLengthQuery + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + if m.DidDocument == nil { + m.DidDocument = &Did{} + } + if err := m.DidDocument.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + case 3: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field DidDocumentMetadata", wireType) + } + var msglen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowQuery + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + msglen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if msglen < 0 { + return ErrInvalidLengthQuery + } + postIndex := iNdEx + msglen + if postIndex < 0 { + return ErrInvalidLengthQuery + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + if m.DidDocumentMetadata == nil { + m.DidDocumentMetadata = &Metadata{} + } + if err := m.DidDocumentMetadata.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + case 4: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field DidResolutionMetadata", wireType) + } + var msglen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowQuery + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + msglen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if msglen < 0 { + return ErrInvalidLengthQuery + } + postIndex := iNdEx + msglen + if postIndex < 0 { + return ErrInvalidLengthQuery + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + if m.DidResolutionMetadata == nil { + m.DidResolutionMetadata = &DidResolveMeta{} + } + if err := m.DidResolutionMetadata.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex default: iNdEx = preIndex skippy, err := skipQuery(dAtA[iNdEx:]) diff --git a/x/ssi/types/query.pb.gw.go b/x/ssi/types/query.pb.gw.go index fa69192..e8c852e 100644 --- a/x/ssi/types/query.pb.gw.go +++ b/x/ssi/types/query.pb.gw.go @@ -159,7 +159,11 @@ func local_request_Query_SchemaCount_0(ctx context.Context, marshaler runtime.Ma } -func request_Query_GetDidDocById_0(ctx context.Context, marshaler runtime.Marshaler, client QueryClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { +var ( + filter_Query_ResolveDid_0 = &utilities.DoubleArray{Encoding: map[string]int{"didId": 0}, Base: []int{1, 1, 0}, Check: []int{0, 1, 2}} +) + +func request_Query_ResolveDid_0(ctx context.Context, marshaler runtime.Marshaler, client QueryClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { var protoReq QueryGetDidDocByIdRequest var metadata runtime.ServerMetadata @@ -170,23 +174,30 @@ func request_Query_GetDidDocById_0(ctx context.Context, marshaler runtime.Marsha _ = err ) - val, ok = pathParams["didDocId"] + val, ok = pathParams["didId"] if !ok { - return nil, metadata, status.Errorf(codes.InvalidArgument, "missing parameter %s", "didDocId") + return nil, metadata, status.Errorf(codes.InvalidArgument, "missing parameter %s", "didId") } - protoReq.DidDocId, err = runtime.String(val) + protoReq.DidId, err = runtime.String(val) if err != nil { - return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "didDocId", err) + return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "didId", err) } - msg, err := client.GetDidDocById(ctx, &protoReq, grpc.Header(&metadata.HeaderMD), grpc.Trailer(&metadata.TrailerMD)) + if err := req.ParseForm(); err != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) + } + if err := runtime.PopulateQueryParameters(&protoReq, req.Form, filter_Query_ResolveDid_0); err != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) + } + + msg, err := client.ResolveDid(ctx, &protoReq, grpc.Header(&metadata.HeaderMD), grpc.Trailer(&metadata.TrailerMD)) return msg, metadata, err } -func local_request_Query_GetDidDocById_0(ctx context.Context, marshaler runtime.Marshaler, server QueryServer, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { +func local_request_Query_ResolveDid_0(ctx context.Context, marshaler runtime.Marshaler, server QueryServer, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { var protoReq QueryGetDidDocByIdRequest var metadata runtime.ServerMetadata @@ -197,36 +208,61 @@ func local_request_Query_GetDidDocById_0(ctx context.Context, marshaler runtime. _ = err ) - val, ok = pathParams["didDocId"] + val, ok = pathParams["didId"] if !ok { - return nil, metadata, status.Errorf(codes.InvalidArgument, "missing parameter %s", "didDocId") + return nil, metadata, status.Errorf(codes.InvalidArgument, "missing parameter %s", "didId") } - protoReq.DidDocId, err = runtime.String(val) + protoReq.DidId, err = runtime.String(val) if err != nil { - return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "didDocId", err) + return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "didId", err) + } + + if err := req.ParseForm(); err != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) + } + if err := runtime.PopulateQueryParameters(&protoReq, req.Form, filter_Query_ResolveDid_0); err != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) } - msg, err := server.GetDidDocById(ctx, &protoReq) + msg, err := server.ResolveDid(ctx, &protoReq) return msg, metadata, err } -func request_Query_DidDocCount_0(ctx context.Context, marshaler runtime.Marshaler, client QueryClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { - var protoReq QueryDidDocCountRequest +var ( + filter_Query_DidParam_0 = &utilities.DoubleArray{Encoding: map[string]int{}, Base: []int(nil), Check: []int(nil)} +) + +func request_Query_DidParam_0(ctx context.Context, marshaler runtime.Marshaler, client QueryClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { + var protoReq QueryDidParamRequest var metadata runtime.ServerMetadata - msg, err := client.DidDocCount(ctx, &protoReq, grpc.Header(&metadata.HeaderMD), grpc.Trailer(&metadata.TrailerMD)) + if err := req.ParseForm(); err != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) + } + if err := runtime.PopulateQueryParameters(&protoReq, req.Form, filter_Query_DidParam_0); err != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) + } + + msg, err := client.DidParam(ctx, &protoReq, grpc.Header(&metadata.HeaderMD), grpc.Trailer(&metadata.TrailerMD)) return msg, metadata, err } -func local_request_Query_DidDocCount_0(ctx context.Context, marshaler runtime.Marshaler, server QueryServer, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { - var protoReq QueryDidDocCountRequest +func local_request_Query_DidParam_0(ctx context.Context, marshaler runtime.Marshaler, server QueryServer, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { + var protoReq QueryDidParamRequest var metadata runtime.ServerMetadata - msg, err := server.DidDocCount(ctx, &protoReq) + if err := req.ParseForm(); err != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) + } + if err := runtime.PopulateQueryParameters(&protoReq, req.Form, filter_Query_DidParam_0); err != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) + } + + msg, err := server.DidParam(ctx, &protoReq) return msg, metadata, err } @@ -329,7 +365,7 @@ func RegisterQueryHandlerServer(ctx context.Context, mux *runtime.ServeMux, serv }) - mux.Handle("GET", pattern_Query_GetDidDocById_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { + mux.Handle("GET", pattern_Query_ResolveDid_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { ctx, cancel := context.WithCancel(req.Context()) defer cancel() var stream runtime.ServerTransportStream @@ -340,7 +376,7 @@ func RegisterQueryHandlerServer(ctx context.Context, mux *runtime.ServeMux, serv runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) return } - resp, md, err := local_request_Query_GetDidDocById_0(rctx, inboundMarshaler, server, req, pathParams) + resp, md, err := local_request_Query_ResolveDid_0(rctx, inboundMarshaler, server, req, pathParams) md.HeaderMD, md.TrailerMD = metadata.Join(md.HeaderMD, stream.Header()), metadata.Join(md.TrailerMD, stream.Trailer()) ctx = runtime.NewServerMetadataContext(ctx, md) if err != nil { @@ -348,11 +384,11 @@ func RegisterQueryHandlerServer(ctx context.Context, mux *runtime.ServeMux, serv return } - forward_Query_GetDidDocById_0(ctx, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) + forward_Query_ResolveDid_0(ctx, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) }) - mux.Handle("GET", pattern_Query_DidDocCount_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { + mux.Handle("GET", pattern_Query_DidParam_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { ctx, cancel := context.WithCancel(req.Context()) defer cancel() var stream runtime.ServerTransportStream @@ -363,7 +399,7 @@ func RegisterQueryHandlerServer(ctx context.Context, mux *runtime.ServeMux, serv runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) return } - resp, md, err := local_request_Query_DidDocCount_0(rctx, inboundMarshaler, server, req, pathParams) + resp, md, err := local_request_Query_DidParam_0(rctx, inboundMarshaler, server, req, pathParams) md.HeaderMD, md.TrailerMD = metadata.Join(md.HeaderMD, stream.Header()), metadata.Join(md.TrailerMD, stream.Trailer()) ctx = runtime.NewServerMetadataContext(ctx, md) if err != nil { @@ -371,7 +407,7 @@ func RegisterQueryHandlerServer(ctx context.Context, mux *runtime.ServeMux, serv return } - forward_Query_DidDocCount_0(ctx, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) + forward_Query_DidParam_0(ctx, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) }) @@ -496,7 +532,7 @@ func RegisterQueryHandlerClient(ctx context.Context, mux *runtime.ServeMux, clie }) - mux.Handle("GET", pattern_Query_GetDidDocById_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { + mux.Handle("GET", pattern_Query_ResolveDid_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { ctx, cancel := context.WithCancel(req.Context()) defer cancel() inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) @@ -505,18 +541,18 @@ func RegisterQueryHandlerClient(ctx context.Context, mux *runtime.ServeMux, clie runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) return } - resp, md, err := request_Query_GetDidDocById_0(rctx, inboundMarshaler, client, req, pathParams) + resp, md, err := request_Query_ResolveDid_0(rctx, inboundMarshaler, client, req, pathParams) ctx = runtime.NewServerMetadataContext(ctx, md) if err != nil { runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) return } - forward_Query_GetDidDocById_0(ctx, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) + forward_Query_ResolveDid_0(ctx, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) }) - mux.Handle("GET", pattern_Query_DidDocCount_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { + mux.Handle("GET", pattern_Query_DidParam_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { ctx, cancel := context.WithCancel(req.Context()) defer cancel() inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) @@ -525,14 +561,14 @@ func RegisterQueryHandlerClient(ctx context.Context, mux *runtime.ServeMux, clie runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) return } - resp, md, err := request_Query_DidDocCount_0(rctx, inboundMarshaler, client, req, pathParams) + resp, md, err := request_Query_DidParam_0(rctx, inboundMarshaler, client, req, pathParams) ctx = runtime.NewServerMetadataContext(ctx, md) if err != nil { runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) return } - forward_Query_DidDocCount_0(ctx, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) + forward_Query_DidParam_0(ctx, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) }) @@ -548,9 +584,9 @@ var ( pattern_Query_SchemaCount_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2, 2, 3, 2, 4}, []string{"hypersign-protocol", "hidnode", "ssi", "schema", "count"}, "", runtime.AssumeColonVerbOpt(true))) - pattern_Query_GetDidDocById_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2, 2, 3, 2, 4, 1, 0, 4, 1, 5, 5}, []string{"hypersign-protocol", "hidnode", "ssi", "did", "queryDidDocById", "didDocId"}, "", runtime.AssumeColonVerbOpt(true))) + pattern_Query_ResolveDid_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2, 2, 3, 1, 0, 4, 1, 5, 4}, []string{"hypersign-protocol", "hidnode", "ssi", "did", "didId"}, "", runtime.AssumeColonVerbOpt(true))) - pattern_Query_DidDocCount_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2, 2, 3, 2, 4}, []string{"hypersign-protocol", "hidnode", "ssi", "did", "count"}, "", runtime.AssumeColonVerbOpt(true))) + pattern_Query_DidParam_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2, 2, 3}, []string{"hypersign-protocol", "hidnode", "ssi", "did"}, "", runtime.AssumeColonVerbOpt(true))) ) var ( @@ -562,7 +598,7 @@ var ( forward_Query_SchemaCount_0 = runtime.ForwardResponseMessage - forward_Query_GetDidDocById_0 = runtime.ForwardResponseMessage + forward_Query_ResolveDid_0 = runtime.ForwardResponseMessage - forward_Query_DidDocCount_0 = runtime.ForwardResponseMessage + forward_Query_DidParam_0 = runtime.ForwardResponseMessage ) diff --git a/x/ssi/types/tx.pb.go b/x/ssi/types/tx.pb.go index 39b8272..4c99d37 100644 --- a/x/ssi/types/tx.pb.go +++ b/x/ssi/types/tx.pb.go @@ -133,8 +133,9 @@ func (m *MsgCreateDIDResponse) GetId() uint64 { type MsgUpdateDID struct { DidDocString *Did `protobuf:"bytes,1,opt,name=didDocString,proto3" json:"didDocString,omitempty"` - Signatures []*SignInfo `protobuf:"bytes,2,rep,name=signatures,proto3" json:"signatures,omitempty"` - Creator string `protobuf:"bytes,3,opt,name=creator,proto3" json:"creator,omitempty"` + VersionId string `protobuf:"bytes,2,opt,name=version_id,json=versionId,proto3" json:"version_id,omitempty"` + Signatures []*SignInfo `protobuf:"bytes,3,rep,name=signatures,proto3" json:"signatures,omitempty"` + Creator string `protobuf:"bytes,4,opt,name=creator,proto3" json:"creator,omitempty"` } func (m *MsgUpdateDID) Reset() { *m = MsgUpdateDID{} } @@ -177,6 +178,13 @@ func (m *MsgUpdateDID) GetDidDocString() *Did { return nil } +func (m *MsgUpdateDID) GetVersionId() string { + if m != nil { + return m.VersionId + } + return "" +} + func (m *MsgUpdateDID) GetSignatures() []*SignInfo { if m != nil { return m.Signatures @@ -339,6 +347,118 @@ func (m *MsgCreateSchemaResponse) GetId() uint64 { return 0 } +type MsgDeactivateDID struct { + Creator string `protobuf:"bytes,1,opt,name=creator,proto3" json:"creator,omitempty"` + DidDocString *Did `protobuf:"bytes,2,opt,name=didDocString,proto3" json:"didDocString,omitempty"` + VersionId string `protobuf:"bytes,3,opt,name=version_id,json=versionId,proto3" json:"version_id,omitempty"` + Signatures []*SignInfo `protobuf:"bytes,4,rep,name=signatures,proto3" json:"signatures,omitempty"` +} + +func (m *MsgDeactivateDID) Reset() { *m = MsgDeactivateDID{} } +func (m *MsgDeactivateDID) String() string { return proto.CompactTextString(m) } +func (*MsgDeactivateDID) ProtoMessage() {} +func (*MsgDeactivateDID) Descriptor() ([]byte, []int) { + return fileDescriptor_73a1aa6c7279248b, []int{6} +} +func (m *MsgDeactivateDID) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *MsgDeactivateDID) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_MsgDeactivateDID.Marshal(b, m, deterministic) + } else { + b = b[:cap(b)] + n, err := m.MarshalToSizedBuffer(b) + if err != nil { + return nil, err + } + return b[:n], nil + } +} +func (m *MsgDeactivateDID) XXX_Merge(src proto.Message) { + xxx_messageInfo_MsgDeactivateDID.Merge(m, src) +} +func (m *MsgDeactivateDID) XXX_Size() int { + return m.Size() +} +func (m *MsgDeactivateDID) XXX_DiscardUnknown() { + xxx_messageInfo_MsgDeactivateDID.DiscardUnknown(m) +} + +var xxx_messageInfo_MsgDeactivateDID proto.InternalMessageInfo + +func (m *MsgDeactivateDID) GetCreator() string { + if m != nil { + return m.Creator + } + return "" +} + +func (m *MsgDeactivateDID) GetDidDocString() *Did { + if m != nil { + return m.DidDocString + } + return nil +} + +func (m *MsgDeactivateDID) GetVersionId() string { + if m != nil { + return m.VersionId + } + return "" +} + +func (m *MsgDeactivateDID) GetSignatures() []*SignInfo { + if m != nil { + return m.Signatures + } + return nil +} + +type MsgDeactivateDIDResponse struct { + Id uint64 `protobuf:"varint,1,opt,name=id,proto3" json:"id,omitempty"` +} + +func (m *MsgDeactivateDIDResponse) Reset() { *m = MsgDeactivateDIDResponse{} } +func (m *MsgDeactivateDIDResponse) String() string { return proto.CompactTextString(m) } +func (*MsgDeactivateDIDResponse) ProtoMessage() {} +func (*MsgDeactivateDIDResponse) Descriptor() ([]byte, []int) { + return fileDescriptor_73a1aa6c7279248b, []int{7} +} +func (m *MsgDeactivateDIDResponse) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *MsgDeactivateDIDResponse) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_MsgDeactivateDIDResponse.Marshal(b, m, deterministic) + } else { + b = b[:cap(b)] + n, err := m.MarshalToSizedBuffer(b) + if err != nil { + return nil, err + } + return b[:n], nil + } +} +func (m *MsgDeactivateDIDResponse) XXX_Merge(src proto.Message) { + xxx_messageInfo_MsgDeactivateDIDResponse.Merge(m, src) +} +func (m *MsgDeactivateDIDResponse) XXX_Size() int { + return m.Size() +} +func (m *MsgDeactivateDIDResponse) XXX_DiscardUnknown() { + xxx_messageInfo_MsgDeactivateDIDResponse.DiscardUnknown(m) +} + +var xxx_messageInfo_MsgDeactivateDIDResponse proto.InternalMessageInfo + +func (m *MsgDeactivateDIDResponse) GetId() uint64 { + if m != nil { + return m.Id + } + return 0 +} + func init() { proto.RegisterType((*MsgCreateDID)(nil), "hypersignprotocol.hidnode.ssi.MsgCreateDID") proto.RegisterType((*MsgCreateDIDResponse)(nil), "hypersignprotocol.hidnode.ssi.MsgCreateDIDResponse") @@ -346,39 +466,46 @@ func init() { proto.RegisterType((*MsgUpdateDIDResponse)(nil), "hypersignprotocol.hidnode.ssi.MsgUpdateDIDResponse") proto.RegisterType((*MsgCreateSchema)(nil), "hypersignprotocol.hidnode.ssi.MsgCreateSchema") proto.RegisterType((*MsgCreateSchemaResponse)(nil), "hypersignprotocol.hidnode.ssi.MsgCreateSchemaResponse") + proto.RegisterType((*MsgDeactivateDID)(nil), "hypersignprotocol.hidnode.ssi.MsgDeactivateDID") + proto.RegisterType((*MsgDeactivateDIDResponse)(nil), "hypersignprotocol.hidnode.ssi.MsgDeactivateDIDResponse") } func init() { proto.RegisterFile("ssi/v1/tx.proto", fileDescriptor_73a1aa6c7279248b) } var fileDescriptor_73a1aa6c7279248b = []byte{ - // 425 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xd4, 0x54, 0x41, 0x8b, 0xd3, 0x40, - 0x14, 0xee, 0x24, 0x52, 0xcd, 0x6b, 0xb1, 0x12, 0x05, 0x43, 0xc0, 0x50, 0x02, 0x6a, 0x45, 0x9a, - 0x60, 0x0a, 0xde, 0xbc, 0x68, 0x50, 0x0a, 0xf6, 0x92, 0xe2, 0xc5, 0x5b, 0x9b, 0x19, 0x93, 0x01, - 0x93, 0x09, 0x99, 0xb4, 0xb4, 0xff, 0xc2, 0xff, 0xe2, 0xc9, 0x7f, 0xe0, 0xb1, 0xc7, 0x85, 0xbd, - 0x2c, 0xed, 0x1f, 0x59, 0x32, 0x69, 0xd2, 0xb4, 0xcb, 0x6e, 0xdb, 0xbd, 0xed, 0xf1, 0xbd, 0xf9, - 0xde, 0xfb, 0xbe, 0xef, 0xbd, 0xc7, 0x40, 0x87, 0x73, 0x6a, 0xcf, 0x3f, 0xd8, 0xd9, 0xc2, 0x4a, - 0x52, 0x96, 0x31, 0xf5, 0x55, 0xb8, 0x4c, 0x48, 0xca, 0x69, 0x10, 0x8b, 0xd8, 0x67, 0xbf, 0xad, - 0x90, 0xe2, 0x98, 0x61, 0x62, 0x71, 0x4e, 0xf5, 0xe7, 0x5b, 0x3c, 0xf7, 0x43, 0x12, 0x4d, 0x8a, - 0x1a, 0xfd, 0xd9, 0x36, 0x89, 0x29, 0x2e, 0x32, 0xe6, 0x3f, 0x04, 0xed, 0x11, 0x0f, 0xbe, 0xa4, - 0x64, 0x92, 0x11, 0x77, 0xe8, 0xaa, 0x5f, 0xa1, 0x8d, 0x29, 0x76, 0x99, 0x3f, 0xce, 0x52, 0x1a, - 0x07, 0x1a, 0xea, 0xa2, 0x5e, 0xcb, 0x31, 0xad, 0x3b, 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- 0xe7, 0xe1, 0x4b, 0xde, 0xcf, 0xdf, 0xff, 0xaf, 0x0d, 0xb4, 0x5a, 0x1b, 0xe8, 0x6a, 0x6d, 0xa0, - 0x3f, 0x1b, 0xa3, 0xb1, 0xda, 0x18, 0x8d, 0x8b, 0x8d, 0xd1, 0xf8, 0xe9, 0x04, 0x34, 0x0b, 0x67, - 0x53, 0xcb, 0x67, 0x91, 0x5d, 0xf5, 0xee, 0x97, 0xcd, 0xed, 0x90, 0xe2, 0x7e, 0xde, 0xdd, 0x5e, - 0xd8, 0xf9, 0x3f, 0x93, 0x2d, 0x13, 0xc2, 0xa7, 0x4d, 0xf1, 0x3c, 0xb8, 0x0e, 0x00, 0x00, 0xff, - 0xff, 0x25, 0x54, 0x5e, 0x8b, 0xc0, 0x04, 0x00, 0x00, + // 501 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xac, 0x55, 0x4f, 0x8b, 0xd3, 0x40, + 0x14, 0xef, 0x24, 0x65, 0x35, 0xaf, 0xd5, 0x5d, 0xa2, 0x60, 0x08, 0x6c, 0x28, 0x01, 0xb5, 0x2a, + 0x9b, 0x60, 0x16, 0xf4, 0xe4, 0x45, 0x83, 0x52, 0xb0, 0x97, 0x14, 0x2f, 0x5e, 0xa4, 0x9b, 0x19, + 0x93, 0x01, 0x9b, 0x09, 0x99, 0xb4, 0x6c, 0xbf, 0x85, 0xdf, 0xc5, 0x93, 0xdf, 0xc0, 0xe3, 0x9e, + 0x64, 0x0f, 0x1e, 0xa4, 0xfd, 0x22, 0x92, 0x49, 0x3a, 0xdb, 0x54, 0xfa, 0x6f, 0xe9, 0x71, 0x5e, + 0xde, 0x7b, 0xbf, 0x3f, 0xf3, 0x1b, 0x02, 0xc7, 0x9c, 0x53, 0x77, 0xf2, 0xd2, 0xcd, 0x2f, 0x9d, + 0x34, 0x63, 0x39, 0xd3, 0x4f, 0xe3, 0x69, 0x4a, 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, 0x77, 0x63, 0x8a, 0xcf, 0x8a, 0xf5, 0xee, 0xa5, 0x5b, 0xfc, 0x0c, 0xf2, + 0x69, 0x4a, 0xf8, 0xc5, 0x91, 0xf8, 0x7c, 0xfe, 0x2f, 0x00, 0x00, 0xff, 0xff, 0x88, 0xf3, 0x49, + 0xec, 0x65, 0x06, 0x00, 0x00, } // Reference imports to suppress errors if they are not otherwise used. @@ -396,6 +523,7 @@ type MsgClient interface { CreateDID(ctx context.Context, in *MsgCreateDID, opts ...grpc.CallOption) (*MsgCreateDIDResponse, error) UpdateDID(ctx context.Context, in *MsgUpdateDID, opts ...grpc.CallOption) (*MsgUpdateDIDResponse, error) CreateSchema(ctx context.Context, in *MsgCreateSchema, opts ...grpc.CallOption) (*MsgCreateSchemaResponse, error) + DeactivateDID(ctx context.Context, in *MsgDeactivateDID, opts ...grpc.CallOption) (*MsgDeactivateDIDResponse, error) } type msgClient struct { @@ -433,11 +561,21 @@ func (c *msgClient) CreateSchema(ctx context.Context, in *MsgCreateSchema, opts return out, nil } +func (c *msgClient) DeactivateDID(ctx context.Context, in *MsgDeactivateDID, opts ...grpc.CallOption) (*MsgDeactivateDIDResponse, error) { + out := new(MsgDeactivateDIDResponse) + err := c.cc.Invoke(ctx, "/hypersignprotocol.hidnode.ssi.Msg/DeactivateDID", in, out, opts...) + if err != nil { + return nil, err + } + return out, nil +} + // MsgServer is the server API for Msg service. type MsgServer interface { CreateDID(context.Context, *MsgCreateDID) (*MsgCreateDIDResponse, error) UpdateDID(context.Context, *MsgUpdateDID) (*MsgUpdateDIDResponse, error) CreateSchema(context.Context, *MsgCreateSchema) (*MsgCreateSchemaResponse, error) + DeactivateDID(context.Context, *MsgDeactivateDID) (*MsgDeactivateDIDResponse, error) } // UnimplementedMsgServer can be embedded to have forward compatible implementations. @@ -453,6 +591,9 @@ func (*UnimplementedMsgServer) UpdateDID(ctx context.Context, req *MsgUpdateDID) func (*UnimplementedMsgServer) CreateSchema(ctx context.Context, req *MsgCreateSchema) (*MsgCreateSchemaResponse, error) { return nil, status.Errorf(codes.Unimplemented, "method CreateSchema not implemented") } +func (*UnimplementedMsgServer) DeactivateDID(ctx context.Context, req *MsgDeactivateDID) (*MsgDeactivateDIDResponse, error) { + return nil, status.Errorf(codes.Unimplemented, "method DeactivateDID not implemented") +} func RegisterMsgServer(s grpc1.Server, srv MsgServer) { s.RegisterService(&_Msg_serviceDesc, srv) @@ -512,6 +653,24 @@ func _Msg_CreateSchema_Handler(srv interface{}, ctx context.Context, dec func(in return interceptor(ctx, in, info, handler) } +func _Msg_DeactivateDID_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { + in := new(MsgDeactivateDID) + if err := dec(in); err != nil { + return nil, err + } + if interceptor == nil { + return srv.(MsgServer).DeactivateDID(ctx, in) + } + info := &grpc.UnaryServerInfo{ + Server: srv, + FullMethod: "/hypersignprotocol.hidnode.ssi.Msg/DeactivateDID", + } + handler := func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.(MsgServer).DeactivateDID(ctx, req.(*MsgDeactivateDID)) + } + return interceptor(ctx, in, info, handler) +} + var _Msg_serviceDesc = grpc.ServiceDesc{ ServiceName: "hypersignprotocol.hidnode.ssi.Msg", HandlerType: (*MsgServer)(nil), @@ -528,6 +687,10 @@ var _Msg_serviceDesc = grpc.ServiceDesc{ MethodName: "CreateSchema", Handler: _Msg_CreateSchema_Handler, }, + { + MethodName: "DeactivateDID", + Handler: _Msg_DeactivateDID_Handler, + }, }, Streams: []grpc.StreamDesc{}, Metadata: "ssi/v1/tx.proto", @@ -642,7 +805,7 @@ func (m *MsgUpdateDID) MarshalToSizedBuffer(dAtA []byte) (int, error) { copy(dAtA[i:], m.Creator) i = encodeVarintTx(dAtA, i, uint64(len(m.Creator))) i-- - dAtA[i] = 0x1a + dAtA[i] = 0x22 } if len(m.Signatures) > 0 { for iNdEx := len(m.Signatures) - 1; iNdEx >= 0; iNdEx-- { @@ -655,9 +818,16 @@ func (m *MsgUpdateDID) MarshalToSizedBuffer(dAtA []byte) (int, error) { i = encodeVarintTx(dAtA, i, uint64(size)) } i-- - dAtA[i] = 0x12 + dAtA[i] = 0x1a } } + if len(m.VersionId) > 0 { + i -= len(m.VersionId) + copy(dAtA[i:], m.VersionId) + i = encodeVarintTx(dAtA, i, uint64(len(m.VersionId))) + i-- + dAtA[i] = 0x12 + } if m.DidDocString != nil { { size, err := m.DidDocString.MarshalToSizedBuffer(dAtA[:i]) @@ -787,6 +957,97 @@ func (m *MsgCreateSchemaResponse) MarshalToSizedBuffer(dAtA []byte) (int, error) return len(dAtA) - i, nil } +func (m *MsgDeactivateDID) Marshal() (dAtA []byte, err error) { + size := m.Size() + dAtA = make([]byte, size) + n, err := m.MarshalToSizedBuffer(dAtA[:size]) + if err != nil { + return nil, err + } + return dAtA[:n], nil +} + +func (m *MsgDeactivateDID) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *MsgDeactivateDID) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + if len(m.Signatures) > 0 { + for iNdEx := len(m.Signatures) - 1; iNdEx >= 0; iNdEx-- { + { + size, err := m.Signatures[iNdEx].MarshalToSizedBuffer(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = encodeVarintTx(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0x22 + } + } + if len(m.VersionId) > 0 { + i -= len(m.VersionId) + copy(dAtA[i:], m.VersionId) + i = encodeVarintTx(dAtA, i, uint64(len(m.VersionId))) + i-- + dAtA[i] = 0x1a + } + if m.DidDocString != nil { + { + size, err := m.DidDocString.MarshalToSizedBuffer(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = encodeVarintTx(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0x12 + } + if len(m.Creator) > 0 { + i -= len(m.Creator) + copy(dAtA[i:], m.Creator) + i = encodeVarintTx(dAtA, i, uint64(len(m.Creator))) + i-- + dAtA[i] = 0xa + } + return len(dAtA) - i, nil +} + +func (m *MsgDeactivateDIDResponse) Marshal() (dAtA []byte, err error) { + size := m.Size() + dAtA = make([]byte, size) + n, err := m.MarshalToSizedBuffer(dAtA[:size]) + if err != nil { + return nil, err + } + return dAtA[:n], nil +} + +func (m *MsgDeactivateDIDResponse) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *MsgDeactivateDIDResponse) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + if m.Id != 0 { + i = encodeVarintTx(dAtA, i, uint64(m.Id)) + i-- + dAtA[i] = 0x8 + } + return len(dAtA) - i, nil +} + func encodeVarintTx(dAtA []byte, offset int, v uint64) int { offset -= sovTx(v) base := offset @@ -843,6 +1104,10 @@ func (m *MsgUpdateDID) Size() (n int) { l = m.DidDocString.Size() n += 1 + l + sovTx(uint64(l)) } + l = len(m.VersionId) + if l > 0 { + n += 1 + l + sovTx(uint64(l)) + } if len(m.Signatures) > 0 { for _, e := range m.Signatures { l = e.Size() @@ -904,6 +1169,45 @@ func (m *MsgCreateSchemaResponse) Size() (n int) { return n } +func (m *MsgDeactivateDID) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + l = len(m.Creator) + if l > 0 { + n += 1 + l + sovTx(uint64(l)) + } + if m.DidDocString != nil { + l = m.DidDocString.Size() + n += 1 + l + sovTx(uint64(l)) + } + l = len(m.VersionId) + if l > 0 { + n += 1 + l + sovTx(uint64(l)) + } + if len(m.Signatures) > 0 { + for _, e := range m.Signatures { + l = e.Size() + n += 1 + l + sovTx(uint64(l)) + } + } + return n +} + +func (m *MsgDeactivateDIDResponse) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + if m.Id != 0 { + n += 1 + sovTx(uint64(m.Id)) + } + return n +} + func sovTx(x uint64) (n int) { return (math_bits.Len64(x|1) + 6) / 7 } @@ -1197,6 +1501,38 @@ func (m *MsgUpdateDID) Unmarshal(dAtA []byte) error { } iNdEx = postIndex case 2: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field VersionId", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowTx + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + stringLen |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + intStringLen := int(stringLen) + if intStringLen < 0 { + return ErrInvalidLengthTx + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthTx + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.VersionId = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + case 3: if wireType != 2 { return fmt.Errorf("proto: wrong wireType = %d for field Signatures", wireType) } @@ -1230,7 +1566,7 @@ func (m *MsgUpdateDID) Unmarshal(dAtA []byte) error { return err } iNdEx = postIndex - case 3: + case 4: if wireType != 2 { return fmt.Errorf("proto: wrong wireType = %d for field Creator", wireType) } @@ -1586,6 +1922,259 @@ func (m *MsgCreateSchemaResponse) Unmarshal(dAtA []byte) error { } return nil } +func (m *MsgDeactivateDID) Unmarshal(dAtA []byte) error { + l := len(dAtA) + iNdEx := 0 + for iNdEx < l { + preIndex := iNdEx + var wire uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowTx + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + wire |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + fieldNum := int32(wire >> 3) + wireType := int(wire & 0x7) + if wireType == 4 { + return fmt.Errorf("proto: MsgDeactivateDID: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: MsgDeactivateDID: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Creator", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowTx + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + stringLen |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + intStringLen := int(stringLen) + if intStringLen < 0 { + return ErrInvalidLengthTx + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthTx + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.Creator = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + case 2: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field DidDocString", wireType) + } + var msglen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowTx + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + msglen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if msglen < 0 { + return ErrInvalidLengthTx + } + postIndex := iNdEx + msglen + if postIndex < 0 { + return ErrInvalidLengthTx + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + if m.DidDocString == nil { + m.DidDocString = &Did{} + } + if err := m.DidDocString.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + case 3: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field VersionId", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowTx + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + stringLen |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + intStringLen := int(stringLen) + if intStringLen < 0 { + return ErrInvalidLengthTx + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthTx + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.VersionId = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + case 4: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Signatures", wireType) + } + var msglen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowTx + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + msglen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if msglen < 0 { + return ErrInvalidLengthTx + } + postIndex := iNdEx + msglen + if postIndex < 0 { + return ErrInvalidLengthTx + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.Signatures = append(m.Signatures, &SignInfo{}) + if err := m.Signatures[len(m.Signatures)-1].Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + default: + iNdEx = preIndex + skippy, err := skipTx(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return ErrInvalidLengthTx + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func (m *MsgDeactivateDIDResponse) Unmarshal(dAtA []byte) error { + l := len(dAtA) + iNdEx := 0 + for iNdEx < l { + preIndex := iNdEx + var wire uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowTx + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + wire |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + fieldNum := int32(wire >> 3) + wireType := int(wire & 0x7) + if wireType == 4 { + return fmt.Errorf("proto: MsgDeactivateDIDResponse: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: MsgDeactivateDIDResponse: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field Id", wireType) + } + m.Id = 0 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowTx + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + m.Id |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + default: + iNdEx = preIndex + skippy, err := skipTx(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return ErrInvalidLengthTx + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} func skipTx(dAtA []byte) (n int, err error) { l := len(dAtA) iNdEx := 0 diff --git a/x/ssi/utils/did_vars.go b/x/ssi/utils/did_vars.go index 798e875..1b6e3fe 100644 --- a/x/ssi/utils/did_vars.go +++ b/x/ssi/utils/did_vars.go @@ -5,4 +5,5 @@ var ServiceTypes = []string{ "DIDCommMessaging", } -var DidPrefix string = "did:hs:" \ No newline at end of file +var didMethod string = "hs" +var didElementsAfterColonSplit int = 3 diff --git a/x/ssi/utils/utils.go b/x/ssi/utils/utils.go index f83dfbc..9f23f18 100644 --- a/x/ssi/utils/utils.go +++ b/x/ssi/utils/utils.go @@ -10,14 +10,31 @@ import ( "github.com/hypersign-protocol/hid-node/x/ssi/types" ) +// Check if the DID Method is valid +func IsValidDidMethod(method string) bool { + return method == didMethod +} + // Checks whether the given string is a valid DID -func IsValidDid(did string) bool { - return strings.HasPrefix(did, DidPrefix) +func IsValidDid(did string) error { + didElements := strings.Split(did, ":") + + if (didElements[0] != "did") || len(didElements) != didElementsAfterColonSplit { + return types.ErrInvalidDidElements + } + if !IsValidDidMethod(didElements[1]) { + return types.ErrInvalidDidMethod + } + + return nil } // Checks whether the ID in the DidDoc is a valid string func IsValidDidDocID(didDoc *types.Did) bool { - return strings.HasPrefix(didDoc.GetId(), DidPrefix) + if err := IsValidDid(didDoc.GetId()); err != nil { + return false + } + return true } // Cheks whether the Service is valid @@ -45,8 +62,8 @@ func IsValidDidFragment(didUrl string) bool { } did, _ := SplitDidUrlIntoDid(didUrl) - hasPrefix := IsValidDid(did) - return hasPrefix + err := IsValidDid(did) + return err == nil } // Check Valid DID service type @@ -73,7 +90,7 @@ func DuplicateServiceExists(serviceId string, services []*types.Service) bool { // Check whether the fields whose values are array of DIDs are valid DID func IsValidDIDArray(didArray []string) bool { for _, did := range didArray { - if !IsValidDid(did) { + if err := IsValidDid(did); err != nil { return false } } @@ -173,3 +190,15 @@ func IsValidSchemaID(schemaId string) error { } return nil } + +func MergeUrlWithResource(url string, resource string) string { + if url[len(url)-1] == '/' { + url = url[:len(url)-1] + } + + if resource[0] == '/' { + resource = resource[1:] + } + + return url + "/" + resource +}