hypersign-protocol / hid-node

A permissionless blockchain network to manage digital identity and access rights
https://hypersign.id
Apache License 2.0
223 stars 23 forks source link

refactor: `createDID`, `deactivateDID`, `updateDID` RPCs #338

Closed arnabghose997 closed 1 year ago

arnabghose997 commented 1 year ago

This PR intends to refactor createDID, deactivateDID, updateDID RPCs. Following are some of the major changes:

arnabghose997 commented 1 year ago

@Vishwas1

The RPCs were tested on following test cases:

Create DID Tests

  1. FAIL: Alice has a registered DID Document where Alice is the controller. Bob tries to register their DID Document by keeping both Alice and Bob as controllers, and by sending only his signature.

  2. PASS: Alice has a registered DID Document where Alice is the controller. Bob tries to register their DID Document by keeping both Alice and Bob as controllers, and by sending only both Alice's and Bob's signatures.

  3. PASS: Alice has a registered DID Document where Alice is the controller. She tries to create an organization DID, in which Alice is the only controller and it's verification method field is empty.

  4. FAIL: Alice has a registered DID Document where Alice is the controller. Alice tries to register an Org DID Document where Alice is the sole controller, and there are two verification Methods, of type EcdsaSecp256k1RecoveryMethod2020, and Alice is the controller for each one of them. Signature is provided by only one of the VMs.

  5. PASS: Alice has a registered DID Document where Alice is the controller. Alice tries to register an Org DID Document where Alice is the sole controller, and there are two verification Methods, of type EcdsaSecp256k1RecoveryMethod2020, and Alice is the controller for each one of them. Signature is provided by both VMs.

  6. FAIL: Alice creates an Org DID where Alice is the controller, and she adds a verification method of her friend Eve. Only Alice sends the singature.

  7. PASS: Alice creates an Org DID where Alice is the controller, and she adds a verification method of her friend Eve. Both Alice and Eve send their singatures.

Update DID Tests

  1. FAIL: Alice creates an Org DID where alice is the controller, and Bob's VM is added to its VM List only. Bob attempts to update Org DID by sending his signature.

  2. PASS: Alice creates an Org DID where alice is the controller, and Bob's VM is added to its VM List only. Alice attempts to update Org DID by sending her signature.

  3. FAIL: Alice attempts to add George as controller of Org ID. Only George's Signature is sent.

  4. FAIL: Alice attempts to add George as controller of Org ID. Only Alice's Signature is sent.

  5. PASS: Alice attempts to add George as controller of Org ID. Both Alice's and George's Signatures are sent.

  6. PASS: Alice attempts to remove George as controller of Org ID. Only Alice's Signature is sent.

  7. PASS: Addition of George as a controller and simultaneous removal of Alice as a controller. Both alice's and george's signature are passed.

  8. FAIL: Alice has already created two didDocs, each representing a wallet. Now, she creates a DID where she is the controller, and the VMs from two DIDDocs are just added in the VM List. Each of these VMs have different controllers. One of the VMs attempts to update DIDDoc.

  9. PASS: Alice has already created two didDocs, each representing a wallet. Now, she creates a DID where she is the controller, and the VMs from two DIDDocs are just added in the VM List. Each of these VMs have different controllers. Alice attempts to update DIDDoc.

  10. Alice tries to update her DID, be she doesn't bother changing anything in her DID.

  11. PASS: Jenny creates herself a DID with empty Controller list. She then attempts to update the DIDDoc by changing the context field and passes her signature only

Deactivate DID

  1. PASS: Alice creates an Org DID with herself and Bob being the Controller. Alice attempts to deactivate it.

  2. PASS: Mike creates a DID for himself, but the controller list is empty. Mike attempts to deactivate it.