Skip to content

Conversation

@zwalo
Copy link

@zwalo zwalo commented Jun 14, 2024

I would like to develop a ssi service using your package.

The id document of the ssi service I am developing will support "blockchainAccountId" rather than public key in the "verificationMethod" field based on the example of the link I attached below to support compatibility with the ac-1056 based DIDRegistry convention.

https://github.com/decentralized-identity/ethr-did-resolver/blob/master/doc/did-method-spec.md
https://identity.foundation/EcdsaSecp256k1RecoverySignature2020/

Therefore, I modified it to support the verification method generation function of Ecdsaecp256k1 RecoveryMethod2020 type to support that part of your package.

The code below is a logic that created a document using the code I modified :)

        newDid := "did:ethr:0xb9c5714089478a327f09197987f16f9e5d936e8a"
	didInfo, err := did.ParseDID(newDid)
	if err != nil {
		return nil, err
	}

	// Empty did document:
	doc := &did.Document{
		Context: []interface{}{did.DIDContextV1URI(), did.SECP256RecoveryURI()},
		ID:      *didInfo,
	}

	// Add an assertionMethod
	keyID, _ := did.ParseDIDURL(fmt.Sprintf("%s#key-1", newDid))

	keyID.DID.MethodID = common.Big1
	didInfo.MethodID = common.Big1

	verificationMethod, err := did.NewVerificationMethod(*keyID, ssi.ECDSASECP256K1RecoveryMethod2020, *didInfo, nil)
	if err != nil {
		return nil, err
	}

	// This adds the method to the VerificationMethod list and stores a reference to the assertion list
	doc.AddAssertionMethod(verificationMethod)

	didJson, _ := json.MarshalIndent(doc, "", "  ")
	fmt.Println(string(didJson))

result :

{
  "@context": [
    "https://www.w3.org/ns/did/v1",
    "https://w3id.org/security/suites/secp256k1recovery-2020/v2"
  ],
  "assertionMethod": [
    "did:ethr:0xb9c5714089478a327f09197987f16f9e5d936e8a#key-1"
  ],
  "id": "did:ethr:0xb9c5714089478a327f09197987f16f9e5d936e8a",
  "verificationMethod": [
    {
      "blockchainAccountId": "eip155:1:0xb9c5714089478a327f09197987f16f9e5d936e8a",
      "controller": "did:ethr:0xb9c5714089478a327f09197987f16f9e5d936e8a",
      "id": "did:ethr:0xb9c5714089478a327f09197987f16f9e5d936e8a#key-1",
      "type": "EcdsaSecp256k1RecoveryMethod2020"
    }
  ]
}

@woutslakhorst
Copy link
Member

Thank you for your contribution to this lib. Unfortunately I see 2 problems with your PR:

  1. The dependency on the ethereum library (not needed IMHO if it's only used for a hashing alg)
  2. The addition of non DID-core fields (blockchainAccountId)

What could be done is to add the (Document d) UnmarshalVerificationMethod(target any) method, that allows the use of any custom VerificationMethod. This would also require storing a Raw version when parsing a VM. Would that be sutiable for your use case?

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

Successfully merging this pull request may close these issues.

3 participants