Skip to content
New issue

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

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

Already on GitHub? Sign in to your account

Changes in DID Spec format: controller and verificationMethod are implemented #65

Merged
merged 2 commits into from
Feb 18, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
41 changes: 36 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -48,14 +48,45 @@ Notice the `--module` flag. This is required to specify the module for which we

## Register DID

```
hid-noded tx did create-did "did:hs:0f49341a-20ef-43d1-bc93-de30993e6c51" "{\"@context\":[\"https://www.w3.org/ns/did/v1\",\"https://w3id.org/security/v1\",\"https://schema.org\"],\"@type\":\"https://schema.org/Person\",\"id\":\"did:hs:0f49341a-20ef-43d1-bc93-de30993e6c51\",\"name\":\"Vishwas\",\"publicKey\":[{\"@context\":\"https://w3id.org/security/v2\",\"id\":\"did:hs:0f49341a-20ef-43d1-bc93-de30993e6c51#z6MkjAwRoZNV1oifLPb2GzLatZ7sVxY5jZ16xYTTAgSgCqQQ\",\"type\":\"Ed25519VerificationKey2018\",\"publicKeyBase58\":\"5igPDK83gGECDtkKbRNk3TZsgPGEKfkkGXYXLQUfHcd2\"}],\"authentication\":[\"did:hs:0f49341a-20ef-43d1-bc93-de30993e6c51#z6MkjAwRoZNV1oifLPb2GzLatZ7sVxY5jZ16xYTTAgSgCqQQ\"],\"assertionMethod\":[\"did:hs:0f49341a-20ef-43d1-bc93-de30993e6c51#z6MkjAwRoZNV1oifLPb2GzLatZ7sVxY5jZ16xYTTAgSgCqQQ\"],\"keyAgreement\":[\"did:hs:0f49341a-20ef-43d1-bc93-de30993e6c51#z6MkjAwRoZNV1oifLPb2GzLatZ7sVxY5jZ16xYTTAgSgCqQQ\"],\"capabilityInvocation\":[\"did:hs:0f49341a-20ef-43d1-bc93-de30993e6c51#z6MkjAwRoZNV1oifLPb2GzLatZ7sVxY5jZ16xYTTAgSgCqQQ\"],\"created\":\"2021-04-06T14:13:14.018Z\",\"updated\":\"2021-04-06T14:13:14.018Z\"}" "2022-01-21T13:03:22.023Z" --from alice --chain-id hidnode
```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-de30993e6c51",
"controller": ["did:hs:0f49341a-20ef-43d1-bc93-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"
]
}' did:hs:0f49341a-20ef-43d1-bc93-de30993e6c51#zEYJrMxWigf9boyeJMTRN4Ern8DJMoCXaLK77pzQmxVjf --ver-key oVtY1xceDZQjkfwlbCEC2vgeADcxpgd27vtYasBhcM/JLR6PnPoD9jvjSJrMsMJwS7faPy5OlFCdj/kgLVZMEg== --from alice --chain-id hidnode
```
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.

## Resolve DID

There are two ways to resolve DID:

- CLI
- Blockchain API


**API**:
```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/did/did%3Ahs%3A0f49341a-20ef-43d1-bc93-de30993e6c51%3A" -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.
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**:
```sh
hid-noded query ssi did did:hs:0f49341a-20ef-43d1-bc93-de30993e6c52
```
86 changes: 43 additions & 43 deletions docs/static/openapi.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11892,24 +11892,24 @@ paths:
type: array
items:
type: string
type:
type: string
id:
type: string
name:
type: string
publicKey:
controller:
type: array
items:
type: string
verificationMethod:
type: array
items:
type: object
properties:
context:
type: string
id:
type: string
type:
type: string
publicKeyBase58:
controller:
type: string
publicKeyMultibase:
type: string
authentication:
type: array
Expand Down Expand Up @@ -20164,24 +20164,24 @@ definitions:
type: array
items:
type: string
type:
type: string
id:
type: string
name:
type: string
publicKey:
controller:
type: array
items:
type: string
verificationMethod:
type: array
items:
type: object
properties:
context:
type: string
id:
type: string
type:
type: string
publicKeyBase58:
controller:
type: string
publicKeyMultibase:
type: string
authentication:
type: array
Expand Down Expand Up @@ -20210,24 +20210,24 @@ definitions:
type: array
items:
type: string
type:
type: string
id:
type: string
name:
type: string
publicKey:
controller:
type: array
items:
type: string
verificationMethod:
type: array
items:
type: object
properties:
context:
type: string
id:
type: string
type:
type: string
publicKeyBase58:
controller:
type: string
publicKeyMultibase:
type: string
authentication:
type: array
Expand Down Expand Up @@ -20269,17 +20269,6 @@ definitions:
hypersignprotocol.hidnode.ssi.Params:
type: object
description: Params defines the parameters for the module.
hypersignprotocol.hidnode.ssi.PublicKeyStruct:
type: object
properties:
context:
type: string
id:
type: string
type:
type: string
publicKeyBase58:
type: string
hypersignprotocol.hidnode.ssi.QueryDidDocCountResponse:
type: object
properties:
Expand All @@ -20296,24 +20285,24 @@ definitions:
type: array
items:
type: string
type:
type: string
id:
type: string
name:
type: string
publicKey:
controller:
type: array
items:
type: string
verificationMethod:
type: array
items:
type: object
properties:
context:
type: string
id:
type: string
type:
type: string
publicKeyBase58:
controller:
type: string
publicKeyMultibase:
type: string
authentication:
type: array
Expand Down Expand Up @@ -20501,6 +20490,17 @@ definitions:
type: string
signature:
type: string
hypersignprotocol.hidnode.ssi.VerificationMethod:
type: object
properties:
id:
type: string
type:
type: string
controller:
type: string
publicKeyMultibase:
type: string
ibc.applications.transfer.v1.DenomTrace:
type: object
properties:
Expand Down
19 changes: 9 additions & 10 deletions proto/ssi/v1/did.proto
Original file line number Diff line number Diff line change
Expand Up @@ -6,14 +6,13 @@ import "ssi/v1/tx.proto";

message Did {
repeated string context = 1;
string type = 2;
string id = 3;
string name = 4;
repeated PublicKeyStruct publicKey = 5;
repeated string authentication = 6;
repeated string assertionMethod = 7;
repeated string keyAgreement = 8;
repeated string capabilityInvocation = 9;
string created = 10;
string updated = 11;
string id = 2;
repeated string controller = 3; // DID Controller Spec: https://www.w3.org/TR/did-core/#did-controller
repeated VerificationMethod verificationMethod = 4;
repeated string authentication = 5;
repeated string assertionMethod = 6;
repeated string keyAgreement = 7;
repeated string capabilityInvocation = 8;
string created = 9;
string updated = 10;
}
48 changes: 23 additions & 25 deletions proto/ssi/v1/tx.proto
Original file line number Diff line number Diff line change
Expand Up @@ -23,37 +23,35 @@ message MsgCreateDID {

message DidDocStructCreateDID {
repeated string context = 1;
string type = 2;
string id = 3;
string name = 4;
repeated PublicKeyStruct publicKey = 5;
repeated string authentication = 6;
repeated string assertionMethod = 7;
repeated string keyAgreement = 8;
repeated string capabilityInvocation = 9;
string created = 10;
string updated = 11;
string id = 2;
repeated string controller = 3; // DID Controller Spec: https://www.w3.org/TR/did-core/#did-controller
repeated VerificationMethod verificationMethod = 4;
repeated string authentication = 5;
repeated string assertionMethod = 6;
repeated string keyAgreement = 7;
repeated string capabilityInvocation = 8;
string created = 9;
string updated = 10;
}

message DidDocStructUpdateDID {
repeated string context = 1;
string type = 2;
string id = 3;
string name = 4;
repeated PublicKeyStruct publicKey = 5;
repeated string authentication = 6;
repeated string assertionMethod = 7;
repeated string keyAgreement = 8;
repeated string capabilityInvocation = 9;
string created = 10;
string updated = 11;
string id = 2;
repeated string controller = 3; // DID Controller Spec: https://www.w3.org/TR/did-core/#did-controller
repeated VerificationMethod verificationMethod = 4;
repeated string authentication = 5;
repeated string assertionMethod = 6;
repeated string keyAgreement = 7;
repeated string capabilityInvocation = 8;
string created = 9;
string updated = 10;
}

message PublicKeyStruct {
string context = 1;
string id = 2;
string type = 3;
string publicKeyBase58 = 4;
message VerificationMethod {
string id = 1;
string type = 2;
string controller = 3;
string publicKeyMultibase = 4;
}

message MsgCreateDIDResponse {
Expand Down
10 changes: 10 additions & 0 deletions tests/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
## Tests

### DID Controller

- Run `create-users.sh` to create three users
- Run `tests/test_did_controllers.sh` to run the tests for DID Controllers. 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
Loading