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

feat: add secp256k1 diddoc and verification method #1736

Merged

Conversation

sairanjit
Copy link
Contributor

@sairanjit sairanjit commented Feb 2, 2024

Summary

  • Added keyDidSecp256k1
  • Added Verification method Type EcdsaSecp256k1VerificationKey2019
  • Added a test-vector from https://github.com/w3c-ccg/did-method-key/blob/main/test-vectors/secp256k1.json

Signed-off-by: Sai Ranjit Tummalapalli <sairanjit.tummalapalli@ayanworks.com>
@sairanjit sairanjit changed the title feat: add secp256k1 diddoc feat: add secp256k1 diddoc and verification method Feb 2, 2024
Signed-off-by: Sai Ranjit Tummalapalli <sairanjit.tummalapalli@ayanworks.com>
@sairanjit
Copy link
Contributor Author

sairanjit commented Feb 2, 2024

There are two formats of verification methods for key-type secp256k1 from test vectors

Which verification method should be used ?

{
  "id": "did:key:zQ3shokFTS3brHcDQrn82RUDfCZESWL1ZdCEJwekUDPQiYBme#zQ3shokFTS3brHcDQrn82RUDfCZESWL1ZdCEJwekUDPQiYBme",
  "type": "EcdsaSecp256k1VerificationKey2019",
  "controller": "did:key:zQ3shokFTS3brHcDQrn82RUDfCZESWL1ZdCEJwekUDPQiYBme",
  "publicKeyBase58": "23o6Sau8NxxzXcgSc3PLcNxrzrZpbLeBn1izfv3jbKhuv"
}

or

{
  "id": "did:key:zQ3shjRPgHQQbTtXyofk1ygghRJ75RZpXmWBMY1BKnhyz7zKp#zQ3shjRPgHQQbTtXyofk1ygghRJ75RZpXmWBMY1BKnhyz7zKp",
  "type": "JsonWebKey2020",
  "controller": "did:key:zQ3shjRPgHQQbTtXyofk1ygghRJ75RZpXmWBMY1BKnhyz7zKp",
  "publicKeyJwk": {
    "kty": "EC",
    "crv": "secp256k1",
    "x": "RwiZITTa2Dcmq-V1j-5tgPUshOLO31FbsnhVS-7lskc",
    "y": "3o1-UCc3ABh757P58gDISSc4hOj9qyfSGl3SGGA7xdc"
  }
}

@@ -27,7 +33,7 @@ const didDocumentKeyTypeMapping: Record<KeyType, (did: string, key: Key) => DidD
[KeyType.P256]: getJsonWebKey2020DidDocument,
[KeyType.P384]: getJsonWebKey2020DidDocument,
[KeyType.P521]: getJsonWebKey2020DidDocument,
[KeyType.K256]: getJsonWebKey2020DidDocument,
[KeyType.K256]: getSecp256k1DidDoc,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Let's use JsonWebKey by default. This seems to be one of the two defaults in DataIntegrity. I think they're moving away from key specific types

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

  • Updated to JsonWebKey as default
  • Should we later add a way to use different didDoc If someone specifically wants to use them ?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah that might be useful -- currently they can call the getSecpVerificationMethod and construct a did doc on their own.

@TimoGlastra
Copy link
Contributor

@sairanjit would be great to get this in for 0.5.0, so if you can update it somewhere today to use JsonWebKey that would be great, thanks 🙏

@sairanjit
Copy link
Contributor Author

@sairanjit would be great to get this in for 0.5.0, so if you can update it somewhere today to use JsonWebKey that would be great, thanks 🙏

Sure will do it today itself

Signed-off-by: Sai Ranjit Tummalapalli <sairanjit.tummalapalli@ayanworks.com>
@TimoGlastra TimoGlastra enabled auto-merge (squash) February 5, 2024 12:18
@TimoGlastra TimoGlastra merged commit f245386 into openwallet-foundation:main Feb 5, 2024
7 checks passed
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.

2 participants