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

Typescript issue for bbs key together with BBS Signature JsonLD #129

Open
vongohren opened this issue Jun 11, 2021 · 3 comments
Open

Typescript issue for bbs key together with BBS Signature JsonLD #129

vongohren opened this issue Jun 11, 2021 · 3 comments

Comments

@vongohren
Copy link
Contributor

So, I like that all the good crypto is collected in this library, but starting to use external libraries quickly breaks the typescriptness of things

If you use: https://github.com/mattrglobal/jsonld-signatures-bbs/blob/master/src/BbsBlsSignature2020.ts
And want to send in a key, it is not possible to send in this repos keyType, because it complains on certain methods variables that this class signature dont have. Here, the instance check is this bls key pair, but if I send that into the Signature function, I will get errors. I had to reconstruct it doing the things below to get it to work together.

    if(key instanceof Bls12381G2KeyPair) {
      const jwk = key.toJsonWebKeyPair(true);
      const keyPair = key.toKeyPair(true);
      const recontstructedKey = {
        ...key,
        publicKey: keyPair.publicKeyBase58,
        publicKeyJwk: jwk.publicKeyJwk,
        privateKey: keyPair.privateKeyBase58,
        privateKeyJwk: jwk.privateKeyJwk,
        signer: key.signer,
        verifier: key.verifier,
        fingerprint: key.fingerprint,
        addEncodedPublicKey: ()=>{},
        verifyFingerprint: () => {}
      }
      return new BbsBlsSignature2020({ key: recontstructedKey })

What would be best approach to get this to be a bit more seamless? So that this key is accepted as a type for the key from BbsBlsSignature package?

@OR13 @tplooker @kdenhartog

@vongohren
Copy link
Contributor Author

I did reuse the mattr key lib to reconstruct from a key.toKeyPair(true);
So not need to look at that earlier reconstruction.
But what would be best practise for this?

@vongohren
Copy link
Contributor Author

@OR13 great to hear that you are on the case! Anything I can support with?

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

2 participants