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

Implementation of register-credential-status rpc #154

Merged
merged 6 commits into from
May 27, 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
4 changes: 2 additions & 2 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,8 @@
*.out

# Dependency directories (remove the comment below to include it)
vue/node_modules
vue/dist
vue

# vue/src/store/generated
release/
.idea/
Expand Down
115 changes: 4 additions & 111 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -51,115 +51,8 @@ To run a single node `hid-node` docker container, run the following:

## Operations

### Register DID
Hands-on CLI operations are present in the below docs:

```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 --keyring-backend test --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.

### Update DID

After the DIDDoc is created from running the above command, making changes to it happens through the following CLI command:

```sh
hid-noded tx ssi update-did '{
"context": [
"https://www.w3.org/ns/did/v1",
"https://w3id.org/security/v1",
"https://schema.org",
"https://some.domain"
],
"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"
]
}' <version-id> did:hs:0f49341a-20ef-43d1-bc93-de30993e6c51#zEYJrMxWigf9boyeJMTRN4Ern8DJMoCXaLK77pzQmxVjf --ver-key oVtY1xceDZQjkfwlbCEC2vgeADcxpgd27vtYasBhcM/JLR6PnPoD9jvjSJrMsMJwS7faPy5OlFCdj/kgLVZMEg== --from alice --keyring-backend test --chain-id hidnode
```

The second param `<version-id>` 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"
]
}' <version-id> did:hs:0f49341a-20ef-43d1-bc93-de30993e6c52#z8BXg2zjwBRTrjPs7uCnkFBKrL9bPD14HxEJMENxm3CJ4 --ver-key bZBUkLGChnJujYHUZ4L8PECoN2Odv6adWGXc1qVWCRVqtEx0o/FmtFZnd5pT3laR518P58TRUGY5q5KSrToSmQ== --from alice --keyring-backend test --chain-id hidnode --yes
```

### Resolve DID

There are two ways to resolve DID:

- CLI
- Blockchain API


**API**:

1. Retrieve a did Document by providing a Did ID:
```sh
curl -X GET "http://localhost:<API-PORT>/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:<API-PORT>/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**:
```sh
hid-noded query ssi did did:hs:0f49341a-20ef-43d1-bc93-de30993e6c52 --chain-id hidnode
```
- [Decentralised Identifier (DID)](docs/ssi/did-ops.md)
- [Credential Schema](docs/ssi/schema-ops.md)
- [Verifiable Credential Status](docs/ssi/cred-ops.md)
50 changes: 50 additions & 0 deletions docs/ssi/cred-ops.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
# Verifiable Credential Status

Storing Verifiable Credential on a distributed ledger could lead to privacy violation. However, we can store the status of a Verifiable Credential on-chain, with no private information attached to it. Issuers of a Verifiable Credential have the ability to revoke the credential and provide the reason behind it.

## Register VC Status

For instance, an issuer with id `did:hs:b8da6c12-0833-4c54-af98-55af55c2fd22` has issue a VC, following which they want to register it's status.

CLI Signature is as follow:

```
Usage:
hid-noded tx ssi register-credential-status [credential-status] [proof]
```

**credential-status Structure**

```json
{
claim: {
id: "vc_example1",
currentStatus: "Live",
statusReason: "Credential Active"
},
issuer: "did:hs:b8da6c12-0833-4c54-af98-55af55c2fd22",
issued: "2022-04-10T04:07:12Z"
}
```

**proof Structure**

```json
{
type: "Ed25519VerificationKey2020",
created: "2022-04-10T04:07:12Z",
verificationMethod: "did:hs:b8da6c12-0833-4c54-af98-55af55c2fd22#key-1",
proofValue: "<-- Base64 encoded signature -->",
proofPurpose: "assertion"
}
```

The field `proofValue` holds the signature that was produced by signing the `credential-status` document.

### Usage

The following command registers the status of a VC with id `vc_example1`:

```sh
hid-noded tx ssi register-credential-status '{"claim":{"id":"vc_abc1234","currentStatus":"Revoked","statusReason":"It all good"},"issuer":"did:hs:b8da6c12-0833-4c54-af98-55af55c2fd22","issued":"22 May 2022"}' '{"type":"Ed25519VerificationKey2020","created":"2022-04-10T04:07:12Z","verificationMethod":"did:hs:b8da6c12-0833-4c54-af98-55af55c2fd22#key-1","proofValue":"<-- base64 encoded signature -->","proofPurpose":"assertion"}' --from <user-blockchain-address>
```
Loading