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

Adding create-did RPC in ssi module #19

Closed
arnabghose997 opened this issue Feb 7, 2022 · 3 comments
Closed

Adding create-did RPC in ssi module #19

arnabghose997 opened this issue Feb 7, 2022 · 3 comments

Comments

@arnabghose997
Copy link
Contributor

Create a RPC create-did under the module ssi module

@arnabghose997
Copy link
Contributor Author

arnabghose997 commented Feb 10, 2022

Branch: https://github.com/hypersign-protocol/hid-node/tree/create-did-ssi-module

create-did CLI signature:

  hid-noded tx ssi create-did [did] [did-doc-string] [verification-method-id] --ver-key

Valid CLI Command for registering DID:

hid-noded tx ssi 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#zEYJrMxWigf9boyeJMTRN4Ern8DJMoCXaLK77pzQmxVjf",
"type": "Ed25519VerificationKey2020",
"publicKeyBase58": "zEYJrMxWigf9boyeJMTRN4Ern8DJMoCXaLK77pzQmxVjf"
}
],
"authentication": [
"did:hs:0f49341a-20ef-43d1-bc93-de30993e6c51#zEYJrMxWigf9boyeJMTRN4Ern8DJMoCXaLK77pzQmxVjf"
],
"assertionMethod": [
"did:hs:0f49341a-20ef-43d1-bc93-de30993e6c51#zEYJrMxWigf9boyeJMTRN4Ern8DJMoCXaLK77pzQmxVjf"
],
"keyAgreement": [
"did:hs:0f49341a-20ef-43d1-bc93-de30993e6c51#zEYJrMxWigf9boyeJMTRN4Ern8DJMoCXaLK77pzQmxVjf"
],
"capabilityInvocation": [
"did:hs:0f49341a-20ef-43d1-bc93-de30993e6c51#zEYJrMxWigf9boyeJMTRN4Ern8DJMoCXaLK77pzQmxVjf"
],
"created": "2021-04-06T14:13:14.018Z",
"updated": "2021-04-06T14:13:14.018Z"
}' did:hs:0f49341a-20ef-43d1-bc93-de30993e6c51#zEYJrMxWigf9boyeJMTRN4Ern8DJMoCXaLK77pzQmxVjf --ver-key oVtY1xceDZQjkfwlbCEC2vgeADcxpgd27vtYasBhcM/JLR6PnPoD9jvjSJrMsMJwS7faPy5OlFCdj/kgLVZMEg== --from alice --chain-id hidnode

Following are the tests for verification key validation:

Scenario 1: Invalid Public Key in the flag --verification-method-id

CLI:

hid-noded tx ssi 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#zEYJrMxWigf9boyeJMTRN4Ern8DJMoCXaLK77pzQmxVjf",
"type": "Ed25519VerificationKey2020",
"publicKeyBase58": "zEYJrMxWigf9boyeJMTRN4Ern8DJMoCXaLK77pzQmxVjf"
}
],
"authentication": [
"did:hs:0f49341a-20ef-43d1-bc93-de30993e6c51#zEYJrMxWigf9boyeJMTRN4Ern8DJMoCXaLK77pzQmxVjk"
],
"assertionMethod": [
"did:hs:0f49341a-20ef-43d1-bc93-de30993e6c51#zEYJrMxWigf9boyeJMTRN4Ern8DJMoCXaLK77pzQmxVjf"
],
"keyAgreement": [
"did:hs:0f49341a-20ef-43d1-bc93-de30993e6c51#zEYJrMxWigf9boyeJMTRN4Ern8DJMoCXaLK77pzQmxVjf"
],
"capabilityInvocation": [
"did:hs:0f49341a-20ef-43d1-bc93-de30993e6c51#zEYJrMxWigf9boyeJMTRN4Ern8DJMoCXaLK77pzQmxVjf"
],
"created": "2021-04-06T14:13:14.018Z",
"updated": "2021-04-06T14:13:14.018Z"
}' did:hs:0f49341a-20ef-43d1-bc93-de30993e6c51#zEYJrMxWigf9boyeJMTRN4Ern8DJMoCXaLK77pzQmxVjk --ver-key oVtY1xceDZQjkfwlbCEC2vgeADcxpgd27vtYasBhcM/JLR6PnPoD9jvjSJrMsMJwS7faPy5OlFCdj/kgLVZMEg== --from alice --chain-id hidnode

Result:

raw_log: 'failed to execute message; message index: 0: did:hs:0f49341a-20ef-43d1-bc93-de30993e6c51#zEYJrMxWigf9boyeJMTRN4Ern8DJMoCXaLK77pzQmxVjk:
  verification method not found: invalid signature detected'

Scenario 2: Invalid Public Key in the DidDoc's field publicKey{ publicKeyBase58 }

CLI:

hid-noded tx ssi 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#zEYJrMxWigf9boyeJMTRN4Ern8DJMoCXaLK77pzQmxVjf",
"type": "Ed25519VerificationKey2020",
"publicKeyBase58": "zEYJrMxWigf9boyeJMTRN4Ern8DJMoCXaLK77pzQmxVjk"
}
],
"authentication": [
"did:hs:0f49341a-20ef-43d1-bc93-de30993e6c51#zEYJrMxWigf9boyeJMTRN4Ern8DJMoCXaLK77pzQmxVjf"
],
"assertionMethod": [
"did:hs:0f49341a-20ef-43d1-bc93-de30993e6c51#zEYJrMxWigf9boyeJMTRN4Ern8DJMoCXaLK77pzQmxVjf"
],
"keyAgreement": [
"did:hs:0f49341a-20ef-43d1-bc93-de30993e6c51#zEYJrMxWigf9boyeJMTRN4Ern8DJMoCXaLK77pzQmxVjf"
],
"capabilityInvocation": [
"did:hs:0f49341a-20ef-43d1-bc93-de30993e6c51#zEYJrMxWigf9boyeJMTRN4Ern8DJMoCXaLK77pzQmxVjf"
],
"created": "2021-04-06T14:13:14.018Z",
"updated": "2021-04-06T14:13:14.018Z"
}' did:hs:0f49341a-20ef-43d1-bc93-de30993e6c51#zEYJrMxWigf9boyeJMTRN4Ern8DJMoCXaLK77pzQmxVjf --ver-key oVtY1xceDZQjkfwlbCEC2vgeADcxpgd27vtYasBhcM/JLR6PnPoD9jvjSJrMsMJwS7faPy5OlFCdj/kgLVZMEg== --from alice --chain-id hidnode

Result:

raw_log: 'failed to execute message; message index: 0: did:hs:0f49341a-20ef-43d1-bc93-de30993e6c51:
  invalid signature detected'

Scenario 3: Invalid Public Key in the DidDoc's field authentication

CLI:

hid-noded tx ssi 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#zEYJrMxWigf9boyeJMTRN4Ern8DJMoCXaLK77pzQmxVjf",
"type": "Ed25519VerificationKey2020",
"publicKeyBase58": "zEYJrMxWigf9boyeJMTRN4Ern8DJMoCXaLK77pzQmxVjf"
}
],
"authentication": [
"did:hs:0f49341a-20ef-43d1-bc93-de30993e6c51#zEYJrMxWigf9boyeJMTRN4Ern8DJMoCXaLK77pzQmxVjk"
],
"assertionMethod": [
"did:hs:0f49341a-20ef-43d1-bc93-de30993e6c51#zEYJrMxWigf9boyeJMTRN4Ern8DJMoCXaLK77pzQmxVjf"
],
"keyAgreement": [
"did:hs:0f49341a-20ef-43d1-bc93-de30993e6c51#zEYJrMxWigf9boyeJMTRN4Ern8DJMoCXaLK77pzQmxVjf"
],
"capabilityInvocation": [
"did:hs:0f49341a-20ef-43d1-bc93-de30993e6c51#zEYJrMxWigf9boyeJMTRN4Ern8DJMoCXaLK77pzQmxVjf"
],
"created": "2021-04-06T14:13:14.018Z",
"updated": "2021-04-06T14:13:14.018Z"
}' did:hs:0f49341a-20ef-43d1-bc93-de30993e6c51#zEYJrMxWigf9boyeJMTRN4Ern8DJMoCXaLK77pzQmxVjk --ver-key oVtY1xceDZQjkfwlbCEC2vgeADcxpgd27vtYasBhcM/JLR6PnPoD9jvjSJrMsMJwS7faPy5OlFCdj/kgLVZMEg== --from alice --chain-id hidnode

Result:

raw_log: 'failed to execute message; message index: 0: did:hs:0f49341a-20ef-43d1-bc93-de30993e6c51#zEYJrMxWigf9boyeJMTRN4Ern8DJMoCXaLK77pzQmxVjk:
  verification method not found: invalid signature detected'

@arnabghose997
Copy link
Contributor Author

Following are the tests for DIDDoc Validation:

Scenario 1: Invalid DID provided in the [did] CLI param:

hid-noded tx ssi create-did did:hskk: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#zEYJrMxWigf9boyeJMTRN4Ern8DJMoCXaLK77pzQmxVjf",
"type": "Ed25519VerificationKey2020",
"publicKeyBase58": "zEYJrMxWigf9boyeJMTRN4Ern8DJMoCXaLK77pzQmxVjf"
}
],
"authentication": [
"did:hs:0f49341a-20ef-43d1-bc93-de30993e6c51#zEYJrMxWigf9boyeJMTRN4Ern8DJMoCXaLK77pzQmxVjf"
],
"assertionMethod": [
"did:hs:0f49341a-20ef-43d1-bc93-de30993e6c51#zEYJrMxWigf9boyeJMTRN4Ern8DJMoCXaLK77pzQmxVjf"
],
"keyAgreement": [
"did:hs:0f49341a-20ef-43d1-bc93-de30993e6c51#zEYJrMxWigf9boyeJMTRN4Ern8DJMoCXaLK77pzQmxVjf"
],
"capabilityInvocation": [
"did:hs:0f49341a-20ef-43d1-bc93-de30993e6c51#zEYJrMxWigf9boyeJMTRN4Ern8DJMoCXaLK77pzQmxVjf"
],
"created": "2021-04-06T14:13:14.018Z",
"updated": "2021-04-06T14:13:14.018Z"
}' did:hs:0f49341a-20ef-43d1-bc93-de30993e6c51#zEYJrMxWigf9boyeJMTRN4Ern8DJMoCXaLK77pzQmxVjf --ver-key oVtY1xceDZQjkfwlbCEC2vgeADcxpgd27vtYasBhcM/JLR6PnPoD9jvjSJrMsMJwS7faPy5OlFCdj/kgLVZMEg== --from alice --chain-id hidnode

Result:

raw_log: 'failed to execute message; message index: 0: did:hskk:0f49341a-20ef-43d1-bc93-de30993e6c51:
  is an invalid Hypersign DID format'

Scenario 2: Invalid Id provided in the [didDocString]:

hid-noded tx ssi 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:hskk:0f49341a-20ef-43d1-bc93-de30993e6c51",
"name": "Vishwas",
"publicKey": [
{
"context": "https://w3id.org/security/v2",
"id": "did:hs:0f49341a-20ef-43d1-bc93-de30993e6c51#zEYJrMxWigf9boyeJMTRN4Ern8DJMoCXaLK77pzQmxVjf",
"type": "Ed25519VerificationKey2020",
"publicKeyBase58": "zEYJrMxWigf9boyeJMTRN4Ern8DJMoCXaLK77pzQmxVjf"
}
],
"authentication": [
"did:hs:0f49341a-20ef-43d1-bc93-de30993e6c51#zEYJrMxWigf9boyeJMTRN4Ern8DJMoCXaLK77pzQmxVjf"
],
"assertionMethod": [
"did:hs:0f49341a-20ef-43d1-bc93-de30993e6c51#zEYJrMxWigf9boyeJMTRN4Ern8DJMoCXaLK77pzQmxVjf"
],
"keyAgreement": [
"did:hs:0f49341a-20ef-43d1-bc93-de30993e6c51#zEYJrMxWigf9boyeJMTRN4Ern8DJMoCXaLK77pzQmxVjf"
],
"capabilityInvocation": [
"did:hs:0f49341a-20ef-43d1-bc93-de30993e6c51#zEYJrMxWigf9boyeJMTRN4Ern8DJMoCXaLK77pzQmxVjf"
],
"created": "2021-04-06T14:13:14.018Z",
"updated": "2021-04-06T14:13:14.018Z"
}' did:hs:0f49341a-20ef-43d1-bc93-de30993e6c51#zEYJrMxWigf9boyeJMTRN4Ern8DJMoCXaLK77pzQmxVjf --ver-key oVtY1xceDZQjkfwlbCEC2vgeADcxpgd27vtYasBhcM/JLR6PnPoD9jvjSJrMsMJwS7faPy5OlFCdj/kgLVZMEg== --from alice --chain-id hidnode

Result:

raw_log: 'failed to execute message; message index: 0: The DidDoc ID did:hskk:0f49341a-20ef-43d1-bc93-de30993e6c51
  is invalid: DidDoc is invalid'

Scenario 3: Invalid DID Array (keyAgreement)

hid-noded tx ssi 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#zEYJrMxWigf9boyeJMTRN4Ern8DJMoCXaLK77pzQmxVjf",
"type": "Ed25519VerificationKey2020",
"publicKeyBase58": "zEYJrMxWigf9boyeJMTRN4Ern8DJMoCXaLK77pzQmxVjf"
}
],
"authentication": [
"did:hs:0f49341a-20ef-43d1-bc93-de30993e6c51#zEYJrMxWigf9boyeJMTRN4Ern8DJMoCXaLK77pzQmxVjf"
],
"assertionMethod": [
"did:hs:0f49341a-20ef-43d1-bc93-de30993e6c51#zEYJrMxWigf9boyeJMTRN4Ern8DJMoCXaLK77pzQmxVjf"
],
"keyAgreement": [
"did:hslp:0f49341a-20ef-43d1-bc93-de30993e6c51#zEYJrMxWigf9boyeJMTRN4Ern8DJMoCXaLK77pzQmxVjf"
],
"capabilityInvocation": [
"did:hs:0f49341a-20ef-43d1-bc93-de30993e6c51#zEYJrMxWigf9boyeJMTRN4Ern8DJMoCXaLK77pzQmxVjf"
],
"created": "2021-04-06T14:13:14.018Z",
"updated": "2021-04-06T14:13:14.018Z"
}' did:hs:0f49341a-20ef-43d1-bc93-de30993e6c51#zEYJrMxWigf9boyeJMTRN4Ern8DJMoCXaLK77pzQmxVjf --ver-key oVtY1xceDZQjkfwlbCEC2vgeADcxpgd27vtYasBhcM/JLR6PnPoD9jvjSJrMsMJwS7faPy5OlFCdj/kgLVZMEg== --from alice --chain-id hidnode

Result:

raw_log: 'failed to execute message; message index: 0: The field keyAgreement is an
  invalid DID Array: DidDoc is invalid'

@arnabghose997
Copy link
Contributor Author

PR has been merged: #24

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant