Open Vishwas1 opened 2 years ago
Cheqd Docs Link: https://docs.cheqd.io/node
There are operations that can be can be done from cheqd CLI:
However, while going through cheqd docs (https://docs.cheqd.io/node/docs/identity-api), they seem to have more functionalities such as:
Creation and Querying of:
Also, the command structure of Create, Query and Update DID are different in CLI as compared to the Docs
cheqd-noded tx cheqd create-did '{
"id": "did:cheqd:testnet:OTc5Ngo=",
"verification_method": [{
"id": "did:cheqd:testnet:OTc5Ngo=#key1",
"type": "Ed25519VerificationKey2020",
"controller": "did:cheqd:testnet:OTc5Ngo=",
"public_key_multibase": "z9qGG3aSfagvN3e1wofSdjBQZQqNQHXfkUUA9DTXPXTH4"
}],
"authentication": [
"did:cheqd:testnet:OTc5Ngo=#key1"
]
}' did:cheqd:testnet:OTc5Ngo=#key1 --ver-key YOSwduF/jlg4NvesrAgKpIxuBDbCBu6zwHO5ILEMRzeDOqDKf5YFJtAHHFvo2C4tc38rtTbU3ydx0GtQL4R4mw== --from alice --node http://localhost:26657 --keyring-backend test --output json --chain-id cheqdnode --gas-prices 25ncheq --yes
The input is formed out side the RPC / node. using client (it seems). Also the signatures are formed (by signing the payload usig the private key) on the client side and then sent to the RPC.
So RPC only get payload
and signature
as params.
CreateDID definition
func NewMsgCreateDid(payload *MsgCreateDidPayload, signatures []*SignInfo) *MsgCreateDid {}
didMsg := msg.GetPayload()
if err := k.VerifySignature(&ctx, didMsg, didMsg.GetSigners(), msg.GetSignatures()); err != nil {
var did = types.Did{
Context: didMsg.Context,
Id: didMsg.Id,
Controller: didMsg.Controller,
VerificationMethod: didMsg.VerificationMethod,
Authentication: didMsg.Authentication,
AssertionMethod: didMsg.AssertionMethod,
CapabilityInvocation: didMsg.CapabilityInvocation,
CapabilityDelegation: didMsg.CapabilityDelegation,
KeyAgreement: didMsg.KeyAgreement,
AlsoKnownAs: didMsg.AlsoKnownAs,
Service: didMsg.Service,
}
metadata := types.NewMetadata(ctx)
id, err := k.AppendDid(ctx, did, &metadata)
{"height":"5","txhash":"6CCF53E4A232039956CB5C1D3E389F86F249B0CCDF17454DA37C2E13CD63353C","codespace":"","code":0,"data":"0A480A282F636865716469642E63686571646E6F64652E63686571642E76312E4D7367437265617465446964121C0A1A6469643A63686571643A746573746E65743A4F5463354E676F3D","raw_log":"[{\"events\":[{\"type\":\"message\",\"attributes\":[{\"key\":\"action\",\"value\":\"MsgCreateDid\"}]}]}]","logs":[{"msg_index":0,"log":"","events":[{"type":"message","attributes":[{"key":"action","value":"MsgCreateDid"}]}]}],"info":"","gas_wanted":"200000","gas_used":"70577","tx":null,"timestamp":"","events":[{"type":"coin_spent","attributes":[{"key":"c3BlbmRlcg==","value":"Y2hlcWQxd2o3amhrZXljd3E4NWdybGZ5N3I4dXVqcTJncGt3dnM1eHVrNXY=","index":true},{"key":"YW1vdW50","value":"NTAwMDAwMG5jaGVx","index":true}]},{"type":"coin_received","attributes":[{"key":"cmVjZWl2ZXI=","value":"Y2hlcWQxN3hwZnZha20yYW1nOTYyeWxzNmY4NHoza2VsbDhjNWw3bTBxcXY=","index":true},{"key":"YW1vdW50","value":"NTAwMDAwMG5jaGVx","index":true}]},{"type":"transfer","attributes":[{"key":"cmVjaXBpZW50","value":"Y2hlcWQxN3hwZnZha20yYW1nOTYyeWxzNmY4NHoza2VsbDhjNWw3bTBxcXY=","index":true},{"key":"c2VuZGVy","value":"Y2hlcWQxd2o3amhrZXljd3E4NWdybGZ5N3I4dXVqcTJncGt3dnM1eHVrNXY=","index":true},{"key":"YW1vdW50","value":"NTAwMDAwMG5jaGVx","index":true}]},{"type":"message","attributes":[{"key":"c2VuZGVy","value":"Y2hlcWQxd2o3amhrZXljd3E4NWdybGZ5N3I4dXVqcTJncGt3dnM1eHVrNXY=","index":true}]},{"type":"tx","attributes":[{"key":"ZmVl","value":"NTAwMDAwMG5jaGVx","index":true}]},{"type":"tx","attributes":[{"key":"YWNjX3NlcQ==","value":"Y2hlcWQxd2o3amhrZXljd3E4NWdybGZ5N3I4dXVqcTJncGt3dnM1eHVrNXYvMQ==","index":true}]},{"type":"tx","attributes":[{"key":"c2lnbmF0dXJl","value":"UXN1akZuR2tuQnV0ZURMOE5UMmVkVldaR1JqWnFDdHJ0YzR5dWZ4T3JqRkFyZDBlcEJpeGJRcEJ6UTRydXJLMVNQYkdKUW1EeEtpMGtrMU1RMEpPUnc9PQ==","index":true}]},{"type":"message","attributes":[{"key":"YWN0aW9u","value":"TXNnQ3JlYXRlRGlk","index":true}]}]}
We need to pass the did as param
cheqd-noded query cheqd did did:cheqd:testnet:OTc5Ngo= --output json
and it returs a didDoc alng with metadata
{
"did": {
"context": [],
"id": "did:cheqd:testnet:OTc5Ngo=",
"controller": [],
"verification_method": [
{
"id": "did:cheqd:testnet:OTc5Ngo=#key1",
"type": "Ed25519VerificationKey2020",
"controller": "did:cheqd:testnet:OTc5Ngo=",
"public_key_jwk": [],
"public_key_multibase": "z9qGG3aSfagvN3e1wofSdjBQZQqNQHXfkUUA9DTXPXTH4"
}
],
"authentication": [
"did:cheqd:testnet:OTc5Ngo=#key1"
],
"assertion_method": [],
"capability_invocation": [],
"capability_delegation": [],
"key_agreement": [],
"service": [],
"also_known_as": []
},
"metadata": {
"created": "2022-02-03 12:57:32.937886125 +0000 UTC",
"updated": "2022-02-03 12:57:32.937886125 +0000 UTC",
"deactivated": false,
"version_id": "bM9T5KIyA5lWy1wdPjifhvJJsMzfF0VNo3wuE81jNTw="
}
}
While updating here means making changes in the existing DID, we will assume that the DID is already created
The input DID is:
{
"id": "did:cheqd:testnet:OTc5Ngo=",
"verification_method": [{
"id": "did:cheqd:testnet:OTc5Ngo=#key1",
"type": "Ed25519VerificationKey2020",
"controller": "did:cheqd:testnet:OTc5Ngo=",
"public_key_multibase": "z9qGG3aSfagvN3e1wofSdjBQZQqNQHXfkUUA9DTXPXTH4"
}],
"authentication": [
"did:cheqd:testnet:OTc5Ngo=#key1"
]
}
Upon querying the DID
{
"did":{
"context":[
],
"id":"did:cheqd:testnet:OTc5Ngo=",
"controller":[
],
"verification_method":[
{
"id":"did:cheqd:testnet:OTc5Ngo=#key1",
"type":"Ed25519VerificationKey2020",
"controller":"did:cheqd:testnet:OTc5Ngo=",
"public_key_jwk":[
],
"public_key_multibase":"z9qGG3aSfagvN3e1wofSdjBQZQqNQHXfkUUA9DTXPXTH4"
}
],
"authentication":[
"did:cheqd:testnet:OTc5Ngo=#key1"
],
"assertion_method":[
],
"capability_invocation":[
],
"capability_delegation":[
],
"key_agreement":[
],
"service":[
],
"also_known_as":[
]
},
"metadata":{
"created":"2022-02-03 23:43:29.188201351 +0000 UTC",
"updated":"2022-02-03 23:43:29.188201351 +0000 UTC",
"deactivated":false,
"version_id":"W5Jc+DcxOcocWiz1BIhaplCff9vvNgT2EWVaSZKFiow="
}
}
cheqd-noded tx cheqd update-did '{
"id": "did:cheqd:testnet:OTc5Ngo=",
"version_id": "W5Jc+DcxOcocWiz1BIhaplCff9vvNgT2EWVaSZKFiow=",
"verification_method": [{
"id": "did:cheqd:testnet:OTc5Ngo=#key1",
"type": "Ed25519VerificationKey2020",
"controller": "did:cheqd:testnet:OTc5Ngo=",
"public_key_multibase": "z9qGG3aSfagvN3e1wofSdjBQZQqNQHXfkUUA9DTXPXTH4"
}],
"authentication": [
"did:cheqd:testnet:OTc5Ngo=#key1"
],
"capability_delegation": [
"did:cheqd:testnet:OTc5Ngo=#key1"
]
}' did:cheqd:testnet:OTc5Ngo=#key1 --ver-key YOSwduF/jlg4NvesrAgKpIxuBDbCBu6zwHO5ILEMRzeDOqDKf5YFJtAHHFvo2C4tc38rtTbU3ydx0GtQL4R4mw== --from alice --node http://localhost:26657 --keyring-backend test --output json --chain-id cheqdnode --gas-prices 25ncheq --yes
What we are updating in this existing DID is that the capability_delegation
field is being updated from null
to ["did:cheqd:testnet:OTc5Ngo=#key1"]
It is similar to the Create DID
scenario, where the payload is formed outside of RPC side, and the signatures are formed on the client side.
UpdateDID definition
func NewMsgUpdateDid(payload *MsgUpdateDidPayload, signatures []*SignInfo) *MsgUpdateDid
didMsg := msg.GetPayload()
if !k.HasDid(ctx, didMsg.Id) {return nil, sdkerrors.Wrap(sdkerrors.ErrKeyNotFound, fmt.Sprintf("key %s doesn't exist", didMsg.Id))}
oldStateValue, err := k.GetDid(&ctx, didMsg.Id)
if err != nil {
return nil, err
}
oldDIDDoc, err := oldStateValue.UnpackDataAsDid()
if err != nil {
return nil, err
}
if err := k.VerifySignatureOnDidUpdate(&ctx, oldDIDDoc, didMsg, msg.Signatures); err != nil {
return nil, err
}
version_id
is passed)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)
}
var did = types.Did{
Context: didMsg.Context,
Id: didMsg.Id,
Controller: didMsg.Controller,
VerificationMethod: didMsg.VerificationMethod,
Authentication: didMsg.Authentication,
AssertionMethod: didMsg.AssertionMethod,
CapabilityInvocation: didMsg.CapabilityInvocation,
CapabilityDelegation: didMsg.CapabilityDelegation,
KeyAgreement: didMsg.KeyAgreement,
AlsoKnownAs: didMsg.AlsoKnownAs,
Service: didMsg.Service,
}
metadata := types.NewMetadata(ctx)
metadata.Created = oldStateValue.Metadata.Created
metadata.Deactivated = oldStateValue.Metadata.Deactivated
if err = k.SetDid(ctx, did, &metadata); err != nil {
return nil, err
}
{
"did": {
"context": [],
"id": "did:cheqd:testnet:OTc5Ngo=",
"controller": [],
"verification_method": [
{
"id": "did:cheqd:testnet:OTc5Ngo=#key1",
"type": "Ed25519VerificationKey2020",
"controller": "did:cheqd:testnet:OTc5Ngo=",
"public_key_jwk": [],
"public_key_multibase": "z9qGG3aSfagvN3e1wofSdjBQZQqNQHXfkUUA9DTXPXTH4"
}
],
"authentication": [
"did:cheqd:testnet:OTc5Ngo=#key1"
],
"assertion_method": [],
"capability_invocation": [],
"capability_delegation": [
"did:cheqd:testnet:OTc5Ngo=#key1"
],
"key_agreement": [],
"service": [],
"also_known_as": []
},
"metadata": {
"created": "2022-02-03 23:43:29.188201351 +0000 UTC",
"updated": "2022-02-04 00:04:58.460013461 +0000 UTC",
"deactivated": false,
"version_id": "RGRbYXzapMPTqz4wlCQxTB6fxvmrd50WzvKET1JJlbM="
}
}
Cheqd:
Cheqd built on top of cosmos sdk
It connects with cosmos hub as well and leverage all features of cosmos including IBC
Cheqd says they are building SSI + tokens inorder to incentivise node operators
Cheqd uses Hyperldeger Aries on top of ched-node for SSI related things
Cheqd’s current supported functionality
Cheqd DID method
Setting up a new cheqd node
Building and testing
https://blog.cheqd.io/why-self-sovereign-identity-needs-a-token-an-expanded-version-46e93e9f519f
Cheqd uses Hyperldeger Aries on top of ched-node for SSI related things